uboot-2009.08.tar.bz2移植到TQ2440

gongping11   2011-9-20 20:21 楼主
依据上几次搭建的环境进行uboot的移植,出现了一些错误,我特此做出一些总结,已经将编译器转换到旧一点的arm-linux-gcc-4.3.2,具体的原因是为什么,我查找了天嵌的网站说需要转换到3.4版本的编译器,因此我改用了友善之臂的uboot-2009.08.tar.bz2移植,尽然通过了,不知道原因,需要大家的帮组。两公司的板子各有千秋,但是在uboot移植方面友善要做的好一点。我现将自己的过程分享以下.

我的平台是Fedora14,交叉编译器是支持EABI arm-2011.03-41-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2,是arm-linux-gcc-4.5.2版本的。本着学习的态度,做了很多自己的笔记,不知道对不对。知道的人指点。

移植的参考是http://blog.chinaunix.net/space.php?uid=22174347&do=blog&id=1786933

这篇文献写的更加详细http://www.cnblogs.com/hanyan225/archive/2011/06/26/2085316.html


我主要是熟悉一下移植的方法,到TQ2440可能存在一些问题。

1、解压缩:tar -jxvf /mnt/hgfs/Linux/uboot-2009.08.tar.bz2 -C /opt/uboot

2、进入解压缩包:cd /opt/uboot/u-boot-2009.08/

3、进入board文件夹,由于TQ2440smdk2410是同一种结构,而且大量的寄存器相同,不一样的地方相对较少,因此采用smdk2410作为TQ2440的蓝本,找到三星公司的板子smdk2410

cd board/samsung/

[root@Gong-Computer samsung]# ls -a

. .. smdk2400 smdk2410 smdk6400

4、创建一个板子模板my2440

[root@Gong-Computer samsung]# mkdir my2440

[root@Gong-Computer samsung]# ls -a

. .. my2440 smdk2400 smdk2410 smdk6400

复制smdk2410中的内容到my2440

[root@Gong-Computer samsung]# cp -fr smdk2410/* my2440/

进入my2440目录,修改smdk2410.cmy2440.c

[root@Gong-Computer samsung]# ls -a

. .. my2440 smdk2400 smdk2410 smdk6400

[root@Gong-Computer samsung]# cd my2440/

[root@Gong-Computer my2440]# ls -a

. .. config.mk flash.c lowlevel_init.S Makefile smdk2410.c

[root@Gong-Computer my2440]# mv smdk2410.c my2440.c

[root@Gong-Computer my2440]# ls -a

. .. config.mk flash.c lowlevel_init.S Makefile my2440.c

回到uboot根目录

[root@Gong-Computer my2440]# cd ../../ ../

创建板级相关的头文件,依然按照smdk2410,也就是复制smdk2410.hmy2440.h

[root@Gong-Computer u-boot-2009.08]# cd include/configs/smdk

smdk2400.h smdk2410.h smdk6400.h

[root@Gong-Computer u-boot-2009.08]# cd include/configs/smdk24

smdk2400.h smdk2410.h

[root@Gong-Computer u-boot-2009.08]# cp include/configs/smdk2410.h include/configs/my2440.h

同时在刚才创建my2440.c添加到该目录下的Makefile中,这样才能实现最基础的编译过程。实现的过程如下:

[root@Gong-Computer u-boot-2009.08]# vi board/samsung/my2440/Makefile

修改:

COBJS := my2440.o flash.o

SOBJS := lowlevel_init.o


修改uboot根目录下的Makefile按照smdk2410_config的格式建立my2440_config的编译选项,另外还要指定交叉编译器。


[root@Gong-Computer u-boot-2009.08]# vi Makefile

在打开的文件中查找smdk2410的基本配置

输入:/smdk2410_config

跳转到

smdk2410_config : unconfig

@$(MKCONFIG) $(@:_config=) arm arm920t smdk2410 samsung s3c24x0


输入:2yy

输入:p


修改为:

smdk2410_config : unconfig

@$(MKCONFIG) $(@:_config=) arm arm920t smdk2410 samsung s3c24x0


my2440_config : unconfig

@$(MKCONFIG) $(@:_config=) arm arm920t smdk2440 samsung s3c24x0



*说明:

arm CPU的架构(ARCH)

arm920tCPU的类型

my2440 :对应在board目录下建立新的开发板项目的目录

samsung:新开发板项目目录的上级目录,如直接在board下建立新的开发板项目的目录,则这里就为NULL

s3c24x0CPU型号

*注意:编译选项格式的第二行要用Tab键开始,否则编译会出错


按下ESC

/CROSS_COMPILE

# set default to nothing for native builds

ifeq ($(HOSTARCH),$(ARCH))

CROSS_COMPILE ?=

endif


修改为:

# set default to nothing for native builds

ifeq ($(HOSTARCH),$(ARCH))

CROSS_COMPILE ?= arm-linux-

endif

保存!退出


测试创建的板子my2440能不能编译通过:

[root@Gong-Computer u-boot-2009.08]# make my2440_config

Configuring for my2440 board... ------说明my2440能够配置成功了,但是还不能编译成功,还不能使用,需要进行修改

[root@Gong-Computer u-boot-2009.08]# make ----编译过程

/opt/arm/arm-2011.03/bin/arm-linux-gcc: line 1: !#/bin/sh: No such file or directory

/opt/arm/arm-2011.03/bin/arm-linux-gcc: line 1: !#/bin/sh: No such file or directory

Generating include/autoconf.mk

/opt/arm/arm-2011.03/bin/arm-linux-gcc: line 1: !#/bin/sh: No such file or directory

/opt/arm/arm-2011.03/bin/arm-linux-gcc: line 1: !#/bin/sh: No such file or directory

Generating include/autoconf.mk.dep

/opt/arm/arm-2011.03/bin/arm-linux-gcc: line 1: !#/bin/sh: No such file or directory

/opt/arm/arm-2011.03/bin/arm-linux-gcc: line 1: !#/bin/sh: No such file or directory

/opt/arm/arm-2011.03/bin/arm-linux-gcc: line 1: !#/bin/sh: No such file or directory

/opt/arm/arm-2011.03/bin/arm-linux-gcc: line 1: !#/bin/sh: No such file or directory

for dir in tools examples/standalone examples/api ; do make -C $dir _depend ; done

/opt/arm/arm-2011.03/bin/arm-linux-gcc: line 1: !#/bin/sh: No such file or directory

/opt/arm/arm-2011.03/bin/arm-linux-gcc: line 1: !#/bin/sh: No such file or directory

make[1]: Entering directory `/opt/uboot/u-boot-2009.08/tools'

make[1]: Leaving directory `/opt/uboot/u-boot-2009.08/tools'

/opt/arm/arm-2011.03/bin/arm-linux-gcc: line 1: !#/bin/sh: No such file or directory

..........

make[1]: Entering directory `/opt/uboot/u-boot-2009.08/lib_arm'

arm-linux-gcc -g -Os -fno-strict-aliasing -fno-common -ffixed-r8 -msoft-float -D__KERNEL__ -I/opt/uboot/u-boot-2009.08/include -fno-builtin -ffreestanding -nostdinc -isystem /opt/arm/arm-2011.03/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.2/include -pipe -DCONFIG_ARM -D__ARM__ -marm -mabi=aapcs-linux -mno-thumb-interwork -march=armv4 -Wall -Wstrict-prototypes -fno-stack-protector -o board.o board.c -c

/opt/arm/arm-2011.03/bin/arm-linux-gcc: line 1: !#/bin/sh: No such file or directory

board.c:127:13: error: inline function 'coloured_LED_init' cannot be declared weak

board.c:129:13: error: inline function 'red_LED_on' cannot be declared weak

board.c:131:13: error: inline function 'red_LED_off' cannot be declared weak

board.c:133:13: error: inline function 'green_LED_on' cannot be declared weak

board.c:135:13: error: inline function 'green_LED_off' cannot be declared weak

board.c:137:13: error: inline function 'yellow_LED_on' cannot be declared weak

board.c:139:13: error: inline function 'yellow_LED_off' cannot be declared weak

board.c:141:13: error: inline function 'blue_LED_on' cannot be declared weak

board.c:143:13: error: inline function 'blue_LED_off' cannot be declared weak

make[1]: *** [board.o] Error 1

make[1]: Leaving directory `/opt/uboot/u-boot-2009.08/lib_arm'

make: *** [lib_arm/libarm.a] Error 2


以上是编译的基本过程,出现了错误,根据提示是 lib_arm/board.c出现了问题,因此打开该文件观察其为什么出现问题。

/************************************************************************

* Coloured LED functionality

************************************************************************

* May be supplied by boards if desired

*/

void inline __coloured_LED_init (void) {}

void inline coloured_LED_init (void) __attribute__((weak, alias("__coloured_LED_init")));

void inline __red_LED_on (void) {}

void inline red_LED_on (void) __attribute__((weak, alias("__red_LED_on")));

void inline __red_LED_off(void) {}

void inline red_LED_off(void) __attribute__((weak, alias("__red_LED_off")));

void inline __green_LED_on(void) {}

void inline green_LED_on(void) __attribute__((weak, alias("__green_LED_on")));

void inline __green_LED_off(void) {}

void inline green_LED_off(void)__attribute__((weak, alias("__green_LED_off")));

void inline __yellow_LED_on(void) {}

void inline yellow_LED_on(void)__attribute__((weak, alias("__yellow_LED_on")));

void inline __yellow_LED_off(void) {}

void inline yellow_LED_off(void)__attribute__((weak, alias("__yellow_LED_off")));

void inline __blue_LED_on(void) {}

void inline blue_LED_on(void)__attribute__((weak, alias("__blue_LED_on")));

void inline __blue_LED_off(void) {}

void inline blue_LED_off(void)__attribute__((weak, alias("__blue_LED_off")));


/************************************************************************

修改以后的内容:直接将其注释掉

/************************************************************************

* Coloured LED functionality

************************************************************************

* May be supplied by boards if desired

*/

void inline __coloured_LED_init (void) {}

//void inline coloured_LED_init (void) __attribute__((weak, alias("__coloured_LED_init")));

void inline __red_LED_on (void) {}

//void inline red_LED_on (void) __attribute__((weak, alias("__red_LED_on")));

void inline __red_LED_off(void) {}

//void inline red_LED_off(void) __attribute__((weak, alias("__red_LED_off")));

void inline __green_LED_on(void) {}

//void inline green_LED_on(void) __attribute__((weak, alias("__green_LED_on")));

void inline __green_LED_off(void) {}

//void inline green_LED_off(void)__attribute__((weak, alias("__green_LED_off")));

void inline __yellow_LED_on(void) {}

//void inline yellow_LED_on(void)__attribute__((weak, alias("__yellow_LED_on")));

void inline __yellow_LED_off(void) {}

//void inline yellow_LED_off(void)__attribute__((weak, alias("__yellow_LED_off")));

void inline __blue_LED_on(void) {}

//void inline blue_LED_on(void)__attribute__((weak, alias("__blue_LED_on")));

void inline __blue_LED_off(void) {}

//void inline blue_LED_off(void)__attribute__((weak, alias("__blue_LED_off")));


/************************************************************************

编译以后又会出现新的问题:

lib_arm/eabi_compat.o -L /opt/arm/arm-2011.03/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.2/armv4t -lgcc -Map u-boot.map -o u-boot

/opt/arm/arm-2011.03/bin/arm-linux-gcc: line 1: !#/bin/sh: No such file or directory

cpu/arm920t/start.o: In function `start_code':

/opt/uboot/u-boot-2009.08/cpu/arm920t/start.S:117: undefined reference to `coloured_LED_init'

/opt/uboot/u-boot-2009.08/cpu/arm920t/start.S:118: undefined reference to `red_LED_on'

/opt/arm/arm-2011.03/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.2/armv4t/libgcc.a(_bswapsi2.o):(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'

make: *** [u-boot] Error 1


根据上面的提示,将两行注释掉

msr cpsr,r0

/*

bl coloured_LED_init

bl red_LED_on */

重新编译

make -C /opt/uboot/u-boot-2009.08/cpu/arm920t/ u-boot.lds

/opt/arm/arm-2011.03/bin/arm-linux-gcc: line 1: !#/bin/sh: No such file or directory

/opt/arm/arm-2011.03/bin/arm-linux-gcc: line 1: !#/bin/sh: No such file or directory

make[1]: Entering directory `/opt/uboot/u-boot-2009.08/cpu/arm920t'

make[1]: Nothing to be done for `u-boot.lds'.

make[1]: Leaving directory `/opt/uboot/u-boot-2009.08/cpu/arm920t'

/opt/arm/arm-2011.03/bin/arm-linux-gcc: line 1: !#/bin/sh: No such file or directory

UNDEF_SYM=`arm-linux-objdump -x board/samsung/my2440/libmy2440.a lib_generic/libgeneric.a lib_generic/lzma/liblzma.a lib_generic/lzo/liblzo.a cpu/arm920t/libarm920t.a cpu/arm920t/s3c24x0/libs3c24x0.a lib_arm/libarm.a fs/cramfs/libcramfs.a fs/fat/libfat.a fs/fdos/libfdos.a fs/jffs2/libjffs2.a fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a fs/yaffs2/libyaffs2.a fs/ubifs/libubifs.a net/libnet.a disk/libdisk.a drivers/bios_emulator/libatibiosemu.a drivers/block/libblock.a drivers/dma/libdma.a drivers/fpga/libfpga.a drivers/gpio/libgpio.a drivers/hwmon/libhwmon.a drivers/i2c/libi2c.a drivers/input/libinput.a drivers/misc/libmisc.a drivers/mmc/libmmc.a drivers/mtd/libmtd.a drivers/mtd/nand/libnand.a drivers/mtd/onenand/libonenand.a drivers/mtd/ubi/libubi.a drivers/mtd/spi/libspi_flash.a drivers/net/libnet.a drivers/net/phy/libphy.a drivers/net/sk98lin/libsk98lin.a drivers/pci/libpci.a drivers/pcmcia/libpcmcia.a drivers/power/libpower.a drivers/spi/libspi.a drivers/rtc/librtc.a drivers/serial/libserial.a drivers/twserial/libtws.a drivers/usb/gadget/libusb_gadget.a drivers/usb/host/libusb_host.a drivers/usb/musb/libusb_musb.a drivers/video/libvideo.a drivers/watchdog/libwatchdog.a common/libcommon.a libfdt/libfdt.a api/libapi.a post/libpost.a | sed -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`; cd /opt/uboot/u-boot-2009.08 && arm-linux-ld -Bstatic -T u-boot.lds -Ttext 0x33F80000 $UNDEF_SYM cpu/arm920t/start.o --start-group lib_generic/libgeneric.a lib_generic/lzma/liblzma.a lib_generic/lzo/liblzo.a cpu/arm920t/libarm920t.a cpu/arm920t/s3c24x0/libs3c24x0.a lib_arm/libarm.a fs/cramfs/libcramfs.a fs/fat/libfat.a fs/fdos/libfdos.a fs/jffs2/libjffs2.a fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a fs/yaffs2/libyaffs2.a fs/ubifs/libubifs.a net/libnet.a disk/libdisk.a drivers/bios_emulator/libatibiosemu.a drivers/block/libblock.a drivers/dma/libdma.a drivers/fpga/libfpga.a drivers/gpio/libgpio.a drivers/hwmon/libhwmon.a drivers/i2c/libi2c.a drivers/input/libinput.a drivers/misc/libmisc.a drivers/mmc/libmmc.a drivers/mtd/libmtd.a drivers/mtd/nand/libnand.a drivers/mtd/onenand/libonenand.a drivers/mtd/ubi/libubi.a drivers/mtd/spi/libspi_flash.a drivers/net/libnet.a drivers/net/phy/libphy.a drivers/net/sk98lin/libsk98lin.a drivers/pci/libpci.a drivers/pcmcia/libpcmcia.a drivers/power/libpower.a drivers/spi/libspi.a drivers/rtc/librtc.a drivers/serial/libserial.a drivers/twserial/libtws.a drivers/usb/gadget/libusb_gadget.a drivers/usb/host/libusb_host.a drivers/usb/musb/libusb_musb.a drivers/video/libvideo.a drivers/watchdog/libwatchdog.a common/libcommon.a libfdt/libfdt.a api/libapi.a post/libpost.a board/samsung/my2440/libmy2440.a --end-group /opt/uboot/u-boot-2009.08/lib_arm/eabi_compat.o -L /opt/arm/arm-2011.03/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.2/armv4t -lgcc -Map u-boot.map -o u-boot

/opt/arm/arm-2011.03/bin/arm-linux-gcc: line 1: !#/bin/sh: No such file or directory

/opt/arm/arm-2011.03/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.2/armv4t/libgcc.a(_bswapsi2.o):(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'

make: *** [u-boot] Error 1


结果还是编译出错,具体的出错原因是u-boot本身的bug问题,没办法我只能换编译器了。

我换了arm-linux-gcc-4.3.2版本的编译器通过了uboot的编译。

编译结果::

arm-linux-gcc -E -g -Os -fno-strict-aliasing -fno-common -ffixed-r8 -msoft-float -D__KERNEL__ -DTEXT_BASE=0x33F80000 -I/opt/uboot/u-boot-2009.08/include -fno-builtin -ffreestanding -nostdinc -isystem /usr/local/arm/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/include -pipe -DCONFIG_ARM -D__ARM__ -marm -mabi=aapcs-linux -mno-thumb-interwork -march=armv4 -include /opt/uboot/u-boot-2009.08/include/u-boot/u-boot.lds.h -ansi -D__ASSEMBLY__ -P - </opt/uboot/u-boot-2009.08/cpu/arm920t/u-boot.lds >u-boot.lds

UNDEF_SYM=`arm-linux-objdump -x board/samsung/my2440/libmy2440.a lib_generic/libgeneric.a lib_generic/lzma/liblzma.a lib_generic/lzo/liblzo.a cpu/arm920t/libarm920t.a cpu/arm920t/s3c24x0/libs3c24x0.a lib_arm/libarm.a fs/cramfs/libcramfs.a fs/fat/libfat.a fs/fdos/libfdos.a fs/jffs2/libjffs2.a fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a fs/yaffs2/libyaffs2.a fs/ubifs/libubifs.a net/libnet.a disk/libdisk.a drivers/bios_emulator/libatibiosemu.a drivers/block/libblock.a drivers/dma/libdma.a drivers/fpga/libfpga.a drivers/gpio/libgpio.a drivers/hwmon/libhwmon.a drivers/i2c/libi2c.a drivers/input/libinput.a drivers/misc/libmisc.a drivers/mmc/libmmc.a drivers/mtd/libmtd.a drivers/mtd/nand/libnand.a drivers/mtd/onenand/libonenand.a drivers/mtd/ubi/libubi.a drivers/mtd/spi/libspi_flash.a drivers/net/libnet.a drivers/net/phy/libphy.a drivers/net/sk98lin/libsk98lin.a drivers/pci/libpci.a drivers/pcmcia/libpcmcia.a drivers/power/libpower.a drivers/spi/libspi.a drivers/rtc/librtc.a drivers/serial/libserial.a drivers/twserial/libtws.a drivers/usb/gadget/libusb_gadget.a drivers/usb/host/libusb_host.a drivers/usb/musb/libusb_musb.a drivers/video/libvideo.a drivers/watchdog/libwatchdog.a common/libcommon.a libfdt/libfdt.a api/libapi.a post/libpost.a | sed -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`; cd /opt/uboot/u-boot-2009.08 && arm-linux-ld -Bstatic -T u-boot.lds -Ttext 0x33F80000 $UNDEF_SYM cpu/arm920t/start.o --start-group lib_generic/libgeneric.a lib_generic/lzma/liblzma.a lib_generic/lzo/liblzo.a cpu/arm920t/libarm920t.a cpu/arm920t/s3c24x0/libs3c24x0.a lib_arm/libarm.a fs/cramfs/libcramfs.a fs/fat/libfat.a fs/fdos/libfdos.a fs/jffs2/libjffs2.a fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a fs/yaffs2/libyaffs2.a fs/ubifs/libubifs.a net/libnet.a disk/libdisk.a drivers/bios_emulator/libatibiosemu.a drivers/block/libblock.a drivers/dma/libdma.a drivers/fpga/libfpga.a drivers/gpio/libgpio.a drivers/hwmon/libhwmon.a drivers/i2c/libi2c.a drivers/input/libinput.a drivers/misc/libmisc.a drivers/mmc/libmmc.a drivers/mtd/libmtd.a drivers/mtd/nand/libnand.a drivers/mtd/onenand/libonenand.a drivers/mtd/ubi/libubi.a drivers/mtd/spi/libspi_flash.a drivers/net/libnet.a drivers/net/phy/libphy.a drivers/net/sk98lin/libsk98lin.a drivers/pci/libpci.a drivers/pcmcia/libpcmcia.a drivers/power/libpower.a drivers/spi/libspi.a drivers/rtc/librtc.a drivers/serial/libserial.a drivers/twserial/libtws.a drivers/usb/gadget/libusb_gadget.a drivers/usb/host/libusb_host.a drivers/usb/musb/libusb_musb.a drivers/video/libvideo.a drivers/watchdog/libwatchdog.a common/libcommon.a libfdt/libfdt.a api/libapi.a post/libpost.a board/samsung/my2440/libmy2440.a --end-group /opt/uboot/u-boot-2009.08/lib_arm/eabi_compat.o -L /usr/local/arm/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/armv4t -lgcc -Map u-boot.map -o u-boot

arm-linux-objcopy -O srec u-boot u-boot.srec

arm-linux-objcopy --gap-fill=0xff -O binary u-boot u-boot.bin ---说明已经编译成功了。

该编译器是参考中提供的链接下载得到的,网上说uboot不支持eabi,为什么这个编译器可以运用我不清楚,需要问版主。

这个时候的uboot还是不能被开发板所使用,但是说明板级大概的轮廓基本完成了,只需要进一步的配置。

清除中间文件用:make distclean

彻底的清除:make clean


libgcc.a(_bswapsi2.o):(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'的问题还是不知道怎么解决,希望知道的大牛给点意见。
坚持就是胜利!!!

回复评论 (1)

楼主太强大了,我又学到了一个uboot的移植方法
我爱电子!
点赞  2012-4-27 16:38
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复