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,終於沒問題了。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM