在把Linux内核3.6.10移植到s3c2410开发板上的时候,创建init进程时出现如下错误,我的init进程编译时采用的是静态链接
Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004
Backtrace:
[<c0018c90>] (dump_backtrace+0x0/0x10c) from [<c034cdf0>] (dump_stack+0x18/0x1c)
r6:c381ad60 r5:00000004 r4:c04663e4
[<c034cdd8>] (dump_stack+0x0/0x1c) from [<c034ce7c>] (panic+0x88/0x1f0)
[<c034cdf4>] (panic+0x0/0x1f0) from [<c0028550>] (do_exit+0x658/0x750)
r3:c3820c40 r2:c381ae80 r1:00000004 r0:c03d40c0
[<c0027ef8>] (do_exit+0x0/0x750) from [<c0028698>] (do_group_exit+0x50/0xb8)
[<c0028648>] (do_group_exit+0x0/0xb8) from [<c00343cc>] (get_signal_to_deliver+0x1f0/0x534)
r4:00000000
[<c00341dc>] (get_signal_to_deliver+0x0/0x534) from [<c0017df4>] (do_work_pending+0xc8/0x4f8)
[<c0017d2c>] (do_work_pending+0x0/0x4f8) from [<c0015b3c>] (work_pending+0xc/0x20)
Backtrace:
[<c0018c90>] (dump_backtrace+0x0/0x10c) from [<c034cdf0>] (dump_stack+0x18/0x1c)
r6:c381ad60 r5:00000004 r4:c04663e4
[<c034cdd8>] (dump_stack+0x0/0x1c) from [<c034ce7c>] (panic+0x88/0x1f0)
[<c034cdf4>] (panic+0x0/0x1f0) from [<c0028550>] (do_exit+0x658/0x750)
r3:c3820c40 r2:c381ae80 r1:00000004 r0:c03d40c0
[<c0027ef8>] (do_exit+0x0/0x750) from [<c0028698>] (do_group_exit+0x50/0xb8)
[<c0028648>] (do_group_exit+0x0/0xb8) from [<c00343cc>] (get_signal_to_deliver+0x1f0/0x534)
r4:00000000
[<c00341dc>] (get_signal_to_deliver+0x0/0x534) from [<c0017df4>] (do_work_pending+0xc8/0x4f8)
[<c0017d2c>] (do_work_pending+0x0/0x4f8) from [<c0015b3c>] (work_pending+0xc/0x20)
通过google搜索发现有人遇到过同样的问题
为了方便查看,内容转载如下:
===================================================================================================================
为设备更新内核,稍微更改默认配置arch/arm/configs/at91sam9260_defconfig后就开始测试,但加载到设备后一直提示如下错误
Uncompressing Linux... done, booting the kernel.
Booting Linux on physical CPU 0
Linux version 3.6.0-rc4 (wenjing@centos6.localdomain) (gcc version 4.3.5 (Buildroot 2011.02) ) #5 Sat Sep 22 14:44:45 CST 2012
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
... ...
Kernel command line: console=ttyS0,115200 initrd=0x21100040,5242880 root=/dev/ram0 rw time
PID hash table entries: 256 (order: -2, 1024 bytes)
... ...
RAMDISK: gzip image found at block 0
VFS: Mounted root (ext2 filesystem) on device 1:0.
Freeing init memory: 108K
Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004
Backtrace:
[<c0012a1c>] (dump_backtrace+0x0/0x104) from [<c0169860>] (dump_stack+0x18/0x1c)
r6:c381ed60 r5:00000004 r4:c01fa4bc
[<c0169848>] (dump_stack+0x0/0x1c) from [<c01698e0>] (panic+0x7c/0x1f0)
初以为是文件系统中busybox的依赖库没有及时跟交叉工具链同步,确保同步lib后错误仍在,而且busybox是静态编译,即使没有任何库也可以运行busybox中的applet。换其他内核版本也是类似错误
Kernel panic - not syncing: No init found. Try passing init= option to kernel. See Linux Documentation/init.txt for guidance
A) Unable to mount root FS
B) init binary doesn't exist on rootfs
C) broken console device
D) binary exists but dependencies not available
E) binary cannot be loaded
文档init.txt给的5个可能原因对我的现象就只有最后一条可能,但为什么不能加载没太明白
休息了几天继续调试问题,估计问题还是在内核配置上,仔细检查发现EABI没有选上,具体关于OABI/EABI如下
COPY FROM
http://blog.csdn.net/cybertan/article/details/5662087
/
ABI(Application Binary Interface)或EABI(Extend ABI)通常是处理器体系结构的一部分,它与平台是紧密相连的。
我们可以把ABI理解为一套规则,这套规则一般包括定义了以下内容:
1。应用程序如何发出系统调用来trap到内核态。
2。如何使用机器的寄存器。比如,RISC处理器的ABI就要规定用那个通用寄存器来作stack pointer和frame pointer。
3。规定如何进行procedure call。
那么eabi和oabi的差别, The ARM EABI improves the floating point performance
a) 无论是否有FPU,浮点执行非常迅速。软件浮点和硬件浮点代码可以混合。
b)Structure packing is not as painful as it used to be
c) More compatibility with various tools (in future - currently linux-elf is well supported)
d)更有效的 syscall 调用(这个影响很大)
那么如何确认这个toolchain支持或不支吃eabi呢?如下,我编译一个文件
[wenjing@centos6 script]$ gcc -mabi=aapcs-linux -mfloat-abi=soft sizeof_test.c
cc1: error: unrecognized command line option "-mabi=aapcs-linux"
cc1: error: unrecognized command line option "-mfloat-abi=soft"
[wenjing@centos6 script]$
[wenjing@centos6 script]$ arm-linux-gcc -mabi=aapcs-linux -mfloat-abi=soft sizeof_test.c
sizeof_test.c: In function ‘main’:
sizeof_test.c:38: warning: large integer implicitly truncated to unsigned type
sizeof_test.c:39: warning: large integer implicitly truncated to unsigned type
sizeof_test.c:41: warning: incompatible implicit declaration of built-in function ‘printf’
[wenjing@centos6 script]$
一般来说,应用程序,以及库以及kernel,如果有一方使用eabi来编译,那么另外一方也需要采用eabi的方式,不然可能出现crash的情况。
看一下ARM处理器是如何处理浮点运算的
交叉编译器在编译的时候,对于浮点运行会预设硬浮点运算FPA(Float Point Architecture),而没有FPA的CPU,比如SAMSUNG S3C2410/S3C2440,会使用FPE(Float Point Emulation 即软浮点),这样在速度上就会遇到极大的限制。也就是说如果有浮点协处理器则交给它去做,如果没有则会产生一个陷阱(trap,处理器响应异常的机制), 而我们事先准备好针对浮点指令的陷阱处理程序就可以通过软件来模拟浮点运算指令。
以下部分转载至http://linux.chinaunix.net/bbs/thread-1143604-1-1.html。
1。什么是ABI
ABI,application binary interface (ABI),应用程序二进制接口。
既然是 接口,那就是某两种东西之间的沟通桥梁,此处有这些种情况:
A。应用程序 <-> 操作系统;
B。应用程序 <-> (应用程序所用到的)库
C。应用程序各个组件之间
类似于API的作用是使得程序的代码间的兼容,ABI目的是使得程序的二进制(级别)的兼容。
2。什么是OABI 和 EABI
OABI中的O,表示“Old”,“Lagacy”,旧的,过时的,OABI就是旧的/老的ABI。
EABI中的E,表示“Embedded”,是一种新的ABI。
EABI有时候也叫做GNU EABI。
OABI和EABI都是专门针对ARM的CPU来说的。
3。EABI的好处 / 为何要用EABI
A。支持软件浮点和硬件实现浮点功能混用
B。系统调用的效率更高
C。和今后的工具更兼容
D。软件浮点的情况下,EABI的软件浮点的效率要比OABI高很多。
4。OABI和EABI的区别
两种ABI在如下方面有区别:
A。调用规则(包括参数如何传递及如何获得返回值)
B。系统调用的数目以及应用程序应该如何去做系统调用
C。目标文件的二进制格式,程序库等
D。结构体中的 填充(padding/packing)和对齐
传统的ABI和EABI 区别 :
Legacy ABI
1)ABI flags passed to binutils: - mabi =apcs-gnu -mfpu=fpa
2)gcc -dumpmachine: arm-unknown-linux
EABI
1)ABI flags passed by gcc to binutils: -mabi =aapcs-linux -mfloat-abi=soft -meabi=4
2)gcc -dumpmachine: arm-unknown-linux-gnueabi
/
内核支持EABI需要进行配置,配置如下
内核中关于对该配置的说明如下:
CONFIG_AEABI:
This option allows for the kernel to be compiled using the latest
ARM ABI (aka EABI). This is only useful if you are using a user
space environment that is also compiled with EABI.
Since there are major incompatibilities between the legacy ABI and
EABI, especially with regard to structure member alignment, this
option also changes the kernel syscall calling convention to
disambiguate both ABIs and allow for backward compatibility support
如下对应两个分别支持EABI和不支持EABI的内核ELF信息打印
[wenjing@centos6 script]$ arm-linux-readelf -h ~/linux-3.5.3/vmlinux | grep "Flags"
Flags: 0x5000002, has entry point, Version5 EABI
[wenjing@centos6 script]$
[wenjing@centos6 script]$ arm-linux-readelf -h ~/linux-3.6-rc4/vmlinux | grep "Flags"
Flags: 0x602, has entry point, GNU EABI, software FP, VFP
[wenjing@centos6 linux-3.6-rc4]$ diff .config .config.old
377c377,378
< # CONFIG_AEABI is not set
---
> CONFIG_AEABI=y
> CONFIG_OABI_COMPAT=y
449d449
< # CONFIG_ARTHUR is not set
975d974
< CONFIG_FRAME_POINTER=y
1009a1009
> CONFIG_ARM_UNWIND=y
[wenjing@centos6 linux-3.6-rc4]$
而且我得busybox也是支持EABI的
[wenjing@centos6 script]$ arm-linux-readelf -h ~//busybox-1.19.2_new/busybox | grep "Flags"
Flags: 0x5000002, has entry point, Version5 EABI
[wenjing@centos6 script]$
[wenjing@centos6 script]$ arm-linux-readelf -h ~/busybox-1.19.2/busybox | grep "Flags"
Flags: 0x4000002, has entry point, Version4 EABI
不管是V5还是V4运行起来都没问题
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
关于编译器选项的一片文章,写得比较全面,收藏一下