本文是U-boot移植到UP-ARM2410-S上时编译过程的笔记 系统环境:ubuntu 9.04 交叉编译器:gcc 4.3.3 建立自己的开发板在board下为开发板供应商名称新建一个目录,取名uptech
在 uptech 下为所用的开发板新建一个目录
UP-ARM2410-S为arm920t的处理器,与之接近的为/board/samsung/smdk2410,将smdk2410目录下的所有文件都拷贝到 uptech2410下
在include/configs/中建立配置头文件,其中大都是编译uptech2410时用到的一些宏
在Makefile 中增加配置项
arm arm920t uptech2410 uptech s3c24×0为make uptech2410时传进去的参数,分别代表:CPU的架构、CPU的类型、 开发板的型号(BOARD),uptech: 开发商vender)、s3c24×0: 片上系统(SOC)。 这些参数在编译时都会作为参数作为进入对应的目录用。其中arm920t对应于cpu/arm920t子目录。uptech2410对应/board/uptech/up2410,如果参数中的开发商uptech 设为NULL,那么上面第一步直接在/board目录下新建uptech2410就可以了,否则会出现NO Target 的错误,另外我在编译中将s3c24×0写成s3c2410也出现类似的错误 编译调试
1 出现如下错误信息
从错误信息可以得知,交叉编译器没有设置好,我们可以在make时加上CROSS_COMPILE=arm-none-linux-gnueabi-作为参数传进去 另外我们也可以更改配置文件纠正这个错误.打开Makefile 文件查找关键字 CROSS,可以看到:
根据include 进入 config.mk文件,查找关键字 CROSS,可以看到:
可以看出此处定义的为make时所用到的一些变量,因此可以在此处添加
注意:此处的gnueabi-中的字符'i’和'-’间不能有空格,否则会不识别该参数而报错 2 修正后继续编译,出现如下错误信息
可以看出找不到目标uptech,进入/uptech/uptech2410目录下的makefile查看,发现 COBJS := smdk2410.o flash.o 恍然大悟!原来在开始将smdk2410复制到uptech2410时makefile中编译后的目标没有做对应的更改,因此将smdk2410.o改为uptech2410.o 3 接着编译 make clean make uptech2410_config make 还是出现了错误: arm-none-linux-gnueabi-ld: error: Source object /usr/local/arm-2009q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.3/libgcc.a(_dvmd_lnx.o) has EABI version 5, but target u-boot has EABI version 0 (.text+0×8): undefined reference to `raise’ 这里出现了除0异常,在google搜索undefined reference to `raise’ 得到这样的信息 On Thu, Jan 17, 2008 at 06:44:51PM +0300, Alexander Vasiliev wrote: > 1) The uboot (the universal boolloader > http://www./wiki/UBoot/WebHome) is not creation of mine and > it's hard for me to say what it exactly needs. But it is builded by > other toolchain (MontaVista) without problems. > > 2) 'raise' should be placed in libc. libc is provided by "Code > sourcery". Is it correct? Or some path should be setted? I set PATH > only to 'arm-2007q3/bin'. The `raise' is part of the C library standard, and it is provided by Codesourcery's C library. Uboot does not use a C library, it defines its own s, therefore the source for uboot may need to be updated when the compiler is updated. Montavista provides excellent value by building uboot and fixing such issues themselves. The workaround is provide an implementation of `raise' for uboot. 原文链接:http://www./archives/arm-gnu/msg01672.html 从信息中可以得知,'raise’异常是C库抛出的,uboot调用的是自己的库,再 google 关键字 `__aeabi_ldiv0' 看到如下信息: U-Boot is not a GNU/Linux application. However, you're using the GNU/Linux toolchain to compile it -- so the libraries assume the presence of a GNU/Linux C library. In this case, the division routine wants to call "raise" to signal a division-by-zero exception ……like our "ARM EABI" toolchains. There are often these kinds of problems with U-Boot when moving between different architectures or toolchain versions because the U-Boot source code has tricks to try to make the GNU/Linux toolchain work, and those tricks only work with particular toolchains. 原文链接:http://www./archives/arm-gnu/msg02332.html 我们知道arm用的是精简指令集,没有专门的除法运算,更没有处理这种异常的机制。从信息中可以看出uboot调用的是自己的库,我们用的编译器gcc 4.3.3是有EABI工具链,这点从arm-none-linux-gnueabi很清楚可以看出。于是在uboot 搜索div0.c这个文件
显示: ./lib_arm/.depend:div0.o: div0.c 于是进入/lib_arm查看,找到div0.c,但没有生成div0.o可以看出没有选用uboot中的关于除0的函数。因此我们打开/lib_arm下的makefile 查找关键字div0 GLCOBJS += div0.o 根据GLCOBJS 往上逐层查看其依赖关系:GLCOBJS->LGOBJS->LIBGCC 可以看出div0需要依赖LIBGCC,继续搜索LIBGCC,有下面的条件编译语句 ifdef USE_PRIVATE_LIBGCC else all: $(LIB) endif 因此,我们要让USE_PRIVATE_LIBGCC为真.在该Makefile 的开始定义USE_PRIVATE_LIBGCC=yes或在顶层Makefile中加入export USE_PRIVATE_LIBGCC =yes 都报错,再在该Makefile下搜索关键字USE_PRIVATE_LIBGCC,看到下面的代码段: 258 ifdef USE_PRIVATE_LIBGCC 260 PLATFORM_LIBGCC = -L $(OBJTREE)/lib_$(ARCH) -lgcc 261 else 262 PLATFORM_LIBGCC = -L $(USE_PRIVATE_LIBGCC) -lgcc 263 endif 264 else 265 PLATFORM_LIBGCC = -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-na me`) -lgcc 266 endif 267 PLATFORM_LIBS += $(PLATFORM_LIBGCC) 268 export PLATFORM_LIBS 这就要求USE_PRIVATE_LIBGCC在此之前就有定义,于是在顶层目录的config.mk中的用到export 的地方添加. ######################################################################### export HOSTCC HOSTCFLAGS CROSS_COMPILE \ export TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS export USE_PRIVATE_LIBGCC =yes ######################################################################### 再编译,终于通过了。。。 arm -L /usr/local/arm-2009q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.3 -lgcc -Map u-boot.map -o u-boot arm-none-linux-gnueabi-objcopy –gap-fill=0xff -O binary u-boot u-boot.bin 将cpu /arm920t/config.mk 改为 PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -ffixed-r8 / -msoft-float PLATFORM_CPPFLAGS += # ========================================================================= # # Supply options according to compiler version # # ========================================================================= PLATFORM_CPPFLAGS +=$(call cc-option,) PLATFORM_RELFLAGS +=$(call cc-option,$(call cc-option,)) 在uboot的根目录中把PLATFORM_LIBS 修该为如下值 PLATFORM_LIBS += -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc -lc -L/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/usr/lib 然后重新 make distclean make 应就能通过了 我遇到问题就是在移植uboo1.1.6 中加入 CFG_CMD_NAND 就报那个错误 不过友善提供的可以通过 通过对比 修改了上面两个地方 就不在提示那个错误了 |
|
来自: t涂鸦 > 《embedded》