uboot2014.10移植(一)

最新有点时间,所以想折腾点东西,于是拿起了几年前的TQ2440玩玩,下载了uboot2014.10版本,准备移植到板子上去,没想到折腾环境都折腾了一下午。

1.工具链安装

    我的工具链直接用命令安装的:

sudo apt-get install arm-linux-gnueabi

    安装完之后测试下:

k@localhost ~/w/0/uboot2014.10> arm-linux-gnueabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabi/5/lto-wrapper
Target: arm-linux-gnueabi
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-armel-cross/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-armel-cross --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-armel-cross --with-arch-directory=arm --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libgcj --enable-objc-gc --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv5t --with-float=soft --disable-werror --enable-multilib --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabi --program-prefix=arm-linux-gnueabi- --includedir=/usr/arm-linux-gnueabi/include
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4) 

2.修改顶层makefile:

ifeq ($(HOSTARCH),$(ARCH))
CROSS_COMPILE ?= 
endif

修改成:
ifeq ($(HOSTARCH),$(ARCH))
CROSS_COMPILE ?= arm-linux-gnueabi-
endif
 

默认的configs文件在comfgs/目录下,于是直接运行以下命令:

k@localhost ~/w/0/uboot2014.10> make smdk2410_defconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/zconf.lex.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
In file included from scripts/kconfig/zconf.tab.c:2537:0:
scripts/kconfig/menu.c: In function ‘get_symbol_str’:
scripts/kconfig/menu.c:590:18: warning: ‘jump’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     jump->offset = strlen(r->s);
                  ^
scripts/kconfig/menu.c:551:19: note: ‘jump’ was declared here
  struct jump_key *jump;
                   ^
  HOSTLD  scripts/kconfig/conf
#
# configuration written to .config
#
k@localhost ~/w/0/uboot2014.10> make 
scripts/kconfig/conf --silentoldconfig Kconfig
  CHK     include/config.h
  UPD     include/config.h
  GEN     include/autoconf.mk
cc1: error: bad value (armv4) for -march= switch
/home/k/work/02-uboot/uboot2014.10/scripts/Makefile.autoconf:64: recipe for target 'include/autoconf.mk' failed
make[2]: *** [include/autoconf.mk] Error 1
/home/k/work/02-uboot/uboot2014.10/Makefile:466: recipe for target 'silentoldconfig' failed
make[1]: *** [silentoldconfig] Error 1
make: *** No rule to make target 'include/config/auto.conf', needed by 'include/config/uboot.release'.  Stop.
k@localhost ~/w/0/uboot2014.10> 

猜测是ifeq那个判断不成立,所以导致工具链没有指定,所以我用下面命令执行:

make ARCH=arm  CROSS_COMPILE=arm-linux-gnueabi-

也可以修改Makefile如下:

ARCH = arm
CROSS_COMPILE ?= arm-linux-gnueabi-

ifeq ($(HOSTARCH),$(ARCH))
CROSS_COMPILE ?=
endif

在那个判断语句上面制定ARCH和CROSS_COMPILE,保存退出然后直接make也可以的。

这次编译没问题,但又出现include/linux/compiler-gcc.h:106:30: fatal error: linux/compiler-gcc5.h:No such file or directory的错误,原因是ubuntu的版本太高了,网上下载不到这个文件,也有人提出了其它的处理方式,我是直接执行下面命令:

k@localhost ~/w/0/uboot2014.10> cd include/linux/
k@localhost ~/w/0/u/i/linux> cp compiler-gcc4.h compiler-gcc5.h 

再次执行make,运行又有地方报错:

arch/arm/lib/board.c:67:6: error: ‘coloured_LED_init’ aliased to external symbol ‘__coloured_LED_init’
 void coloured_LED_init(void)__attribute__((weak, alias("__coloured_LED_init")));
      ^
arch/arm/lib/board.c:83:6: error: ‘blue_led_off’ aliased to external symbol ‘__blue_led_off’
 void blue_led_off(void) __attribute__((weak, alias("__blue_led_off")));
      ^
arch/arm/lib/board.c:81:6: error: ‘blue_led_on’ aliased to external symbol ‘__blue_led_on’
 void blue_led_on(void) __attribute__((weak, alias("__blue_led_on")));
      ^
arch/arm/lib/board.c:79:6: error: ‘yellow_led_off’ aliased to external symbol ‘__yellow_led_off’
 void yellow_led_off(void) __attribute__((weak, alias("__yellow_led_off")));
      ^
arch/arm/lib/board.c:77:6: error: ‘yellow_led_on’ aliased to external symbol ‘__yellow_led_on’
 void yellow_led_on(void) __attribute__((weak, alias("__yellow_led_on")));
      ^
arch/arm/lib/board.c:75:6: error: ‘green_led_off’ aliased to external symbol ‘__green_led_off’
 void green_led_off(void) __attribute__((weak, alias("__green_led_off")));
      ^
arch/arm/lib/board.c:73:6: error: ‘green_led_on’ aliased to external symbol ‘__green_led_on’
 void green_led_on(void) __attribute__((weak, alias("__green_led_on")));
      ^
arch/arm/lib/board.c:71:6: error: ‘red_led_off’ aliased to external symbol ‘__red_led_off’
 void red_led_off(void) __attribute__((weak, alias("__red_led_off")));
      ^
arch/arm/lib/board.c:69:6: error: ‘red_led_on’ aliased to external symbol ‘__red_led_on’
 void red_led_on(void) __attribute__((weak, alias("__red_led_on")));
      ^
scripts/Makefile.build:275: recipe for target 'arch/arm/lib/board.o' failed
make[1]: *** [arch/arm/lib/board.o] Error 1
Makefile:1037: recipe for target 'arch/arm/lib' failed
make: *** [arch/arm/lib] Error 2

这是因为内联函数不能为weak属性,直接将这些函数注释掉算了:

inline void __coloured_LED_init(void) {}
//void coloured_LED_init(void)__attribute__((weak, alias("__coloured_LED_init")));
inline void __red_led_on(void) {}
//void red_led_on(void) __attribute__((weak, alias("__red_led_on")));
inline void __red_led_off(void) {}
//void red_led_off(void) __attribute__((weak, alias("__red_led_off")));
inline void __green_led_on(void) {}
//void green_led_on(void) __attribute__((weak, alias("__green_led_on")));
inline void __green_led_off(void) {}
//void green_led_off(void) __attribute__((weak, alias("__green_led_off")));
inline void __yellow_led_on(void) {}
//void yellow_led_on(void) __attribute__((weak, alias("__yellow_led_on")));
inline void __yellow_led_off(void) {}
//void yellow_led_off(void) __attribute__((weak, alias("__yellow_led_off")));
inline void __blue_led_on(void) {}
//void blue_led_on(void) __attribute__((weak, alias("__blue_led_on")));
inline void __blue_led_off(void) {}
//void blue_led_off(void) __attribute__((weak, alias("__blue_led_off")));

再次make

arch/arm/lib/built-in.o: In function `clbss_l':
/home/k/work/02-uboot/uboot2014.10/arch/arm/lib/crt0.S:122: undefined reference to `coloured_LED_init'
/home/k/work/02-uboot/uboot2014.10/arch/arm/lib/crt0.S:123: undefined reference to `red_led_on'
arm-linux-gnueabi-ld.bfd: BFD (GNU Binutils for Ubuntu) 2.26.1 assertion fail ../../bfd/elf32-arm.c:8472
arm-linux-gnueabi-ld.bfd: BFD (GNU Binutils for Ubuntu) 2.26.1 assertion fail ../../bfd/elf32-arm.c:8472
arm-linux-gnueabi-ld.bfd: error: required section '.rel.plt' not found in the linker script
arm-linux-gnueabi-ld.bfd: final link failed: Invalid operation
Makefile:1019: recipe for target 'u-boot' failed
make: *** [u-boot] Error 1

刚才将函数注释掉了,现在当然报错了。

#    bl coloured_LED_init
#    bl red_led_on

直接注释掉了。

再次make,终于没问题了。

 

转载于:https://www.cnblogs.com/kent-hu/p/7711311.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值