原始报错信息:
Krj@VM:~/soc_workspace/1stQuarter_BarBoard/15_NandFlash/NandFlash_codeTest$ make cleanDepend && make
delete all module files succeed!
delete all depend files succeed!
start.s compile running...
start.s compile succeed!
src/memCtrl/memCtrl.c compile running...
src/memCtrl/memCtrl.c compile succeed!
src/nand_flash/nand_flash.c compile running...
src/nand_flash/nand_flash.c compile succeed!
src/soc_s3c2440_init.c compile running...
src/soc_s3c2440_init.c compile succeed!
src/uart/uart.c compile running...
src/uart/uart.c compile succeed!
src/exception/interrupt.c compile running...
src/exception/interrupt.c compile succeed!
src/led/led.c compile running...
src/led/led.c compile succeed!
src/tools/tools.c compile running...
src/tools/tools.c compile succeed!
src/log/syslog.c compile running...
src/log/syslog.c compile succeed!
src/test/test.c compile running...
src/test/test.c compile succeed!
src/exception/exception.c compile running...
src/exception/exception.c compile succeed!
src/timer/timer.c compile running...
src/timer/timer.c compile succeed!
src/nor_flash/nor_flash.c compile running...
src/nor_flash/nor_flash.c compile succeed!
soc_s3c2440.c compile running...
soc_s3c2440.c compile succeed!
lib1funcs.s compile running...
lib1funcs.s: Assembler messages:
lib1funcs.s:44: Error: junk at end of line, first unrecognized character is `\'
lib1funcs.s:45: Error: bad instruction `align'
lib1funcs.s:45: Error: junk at end of line, first unrecognized character is `\'
lib1funcs.s:216: Error: bad instruction `entry(__udivsi3)'
lib1funcs.s:226: Error: selected processor does not support `clz r3,r1'
lib1funcs.s:226: Error: selected processor does not support `clz r2,r0'
lib1funcs.s:235: Error: selected processor does not support `clz r2,r1'
lib1funcs.s:241: Error: bad instruction `entry(__umodsi3)'
lib1funcs.s:251: Error: selected processor does not support `clz r2,r1'
lib1funcs.s:251: Error: selected processor does not support `clz r3,r0'
lib1funcs.s:256: Error: bad instruction `entry(__divsi3)'
lib1funcs.s:271: Error: selected processor does not support `clz r2,r1'
lib1funcs.s:271: Error: selected processor does not support `clz r0,r3'
lib1funcs.s:286: Error: selected processor does not support `clz r2,r1'
lib1funcs.s:294: Error: bad instruction `entry(__modsi3)'
lib1funcs.s:308: Error: selected processor does not support `clz r2,r1'
lib1funcs.s:308: Error: selected processor does not support `clz r3,r0'
lib1funcs.s compile failure!
commpile project S3C2440 is running...
./src/nand_flash/nand_flash.o: In function `nand_flash_get_mem_info':
nand_flash.c:(.text+0x374): undefined reference to `__aeabi_uidiv'
nand_flash.c:(.text+0x3a0): undefined reference to `__aeabi_uidiv'
link all files to target file S3C2440.bin failure!
Krj@VM:~/soc_workspace/1stQuarter_BarBoard/15_NandFlash/NandFlash_codeTest$
是在编译lib1funs.S时报的错误。
1、先处理两个宏定义引起的报错:
lib1funcs.s: Assembler messages:
lib1funcs.s:44: Error: junk at end of line, first unrecognized character is `\'
lib1funcs.s:45: Error: bad instruction `align'
lib1funcs.s:45: Error: junk at end of line, first unrecognized character is `\'
直接将源有宏定义全部去掉,用到宏定义的地方直接一个个定义就行,对于换行符编译器不是别的问题,暂时也没有搜索到好的方式解决,反正文件中用到该宏就只有几处,怎么修改快速怎么来。
2、处理剩余的报错(指令不支持):
lib1funcs.s: Assembler messages:
lib1funcs.s:221: Error: selected processor does not support `clz r3,r1'
lib1funcs.s:221: Error: selected processor does not support `clz r2,r0'
lib1funcs.s:230: Error: selected processor does not support `clz r2,r1'
lib1funcs.s:248: Error: selected processor does not support `clz r2,r1'
lib1funcs.s:248: Error: selected processor does not support `clz r3,r0'
lib1funcs.s:269: Error: selected processor does not support `clz r2,r1'
lib1funcs.s:269: Error: selected processor does not support `clz r0,r3'
lib1funcs.s:284: Error: selected processor does not support `clz r2,r1'
lib1funcs.s:307: Error: selected processor does not support `clz r2,r1'
lib1funcs.s:307: Error: selected processor does not support `clz r3,r0'
lib1funcs.s compile failure!
经过百度,搜索到解决方案,将原有的:
CC += -march=armv4
替换为:
CC += -march=armv5te
即可解决。
3、但是又报了新的错误,除法不支持:
commpile project S3C2440 is running...
./src/nand_flash/nand_flash.o: In function `nand_flash_get_mem_info':
nand_flash.c:(.text+0x370): undefined reference to `__aeabi_uidiv'
nand_flash.c:(.text+0x39c): undefined reference to `__aeabi_uidiv'
link all files to target file S3C2440.bin failure!
按照网上解决方案,使用libgcc自带除法运算库函(需要确认本地编译环境库的实际路径):
Krj@VM:/opt/FriendlyARM/toolschain/4.4.3/lib/gcc/arm-none-linux-gnueabi/4.4.3$ grep "__aeabi_uidiv" * -Rn
匹配到二进制文件 libgcc.a
匹配到二进制文件 libgcov.a
Krj@VM:/opt/FriendlyARM/toolschain/4.4.3/lib/gcc/arm-none-linux-gnueabi/4.4.3$
#指定连接库文
LIBPATH :=
LIBPATH +=-lgcc -L/opt/FriendlyARM/toolschain/4.4.3/lib/gcc/arm-none-linux-gnueabi/4.4.3/
#连接时使用链接库即可
$(TARGETP_ROJECT):$(ALLOBJS)
@echo "commpile project $(TARGETP_ROJECT) is running..." && \
$(LD) $(START) $(OBJS) $(LIBPATH) -o [email protected] && \
$(OBJCOPY) -O binary -S [email protected] [email protected] && \
$(OBJDUMP) -D [email protected] > [email protected] && \
echo "link all files to target file $(TARGETP_ROJECT).bin succeed!" || \
echo "link all files to target file $(TARGETP_ROJECT).bin failure!"
4、解决了除法运算不支持的问题,又有新的报错,未定义的raise:
commpile project S3C2440 is running...
/opt/FriendlyARM/toolschain/4.4.3/lib/gcc/arm-none-linux-gnueabi/4.4.3//libgcc.a(_dvmd_lnx.o): In function `__div0':
/opt/FriendlyARM/mini2440/build-toolschain/working/src/gcc-4.4.3/libgcc/../gcc/config/arm/lib1funcs.asm:1093: undefined reference to `raise'
link all files to target file S3C2440.bin failure!
按照博客博主lock1501的解决方案,进行修改:
/*
* 2020-2-16 15:44:27
* 解决编译问题:
* /opt/FriendlyARM/toolschain/4.4.3/lib/gcc/arm-none-linux-gnueabi/4.4.3//libgcc.a(_dvmd_lnx.o): In function `__div0':
* /opt/FriendlyARM/mini2440/build-toolschain/working/src/gcc-4.4.3/libgcc/../gcc/config/arm/lib1funcs.asm:1093: undefined reference to `raise'
* 代码参考u-boot-2012.04.01
*/
int raise (int signum)
{
print_screen("raise: Signal # %d caught\n", signum);
return 0;
}
最终编译成功,撒花:
lib1funcs.s compile succeed!
commpile project S3C2440 is running...
link all files to target file S3C2440.bin succeed!
Krj@VM:~/soc_workspace/1stQuarter_BarBoard/15_NandFlash/NandFlash_codeTest$
从解决llib1funcs.s编译不过到最后,发现除法可以直接再编译器自带库里取,而不再需要lib1funcs.s文件了。这样的话,不再编译lib1funcs.s,恢复CC += -march=armv5te为CC += -march=armv4,不恢复的话,对于S3C2440来讲,可能会产生未定义指令异常(2020年2月21日23:01:04),在使用armv5te的时候,发现过多条未定义指令异常:blx指令(函数指针可能会用到该指令)、ldrd、strd指令等。