我的平台:
SOC = STM32H743 (ARMv7E-M | Cortex-M7)
Board = Waveshare CoreH7XXI
Linux Kernel = 5.8.10 (stable 2020-09-17)
initial defconfig file = stm32_defconfig
rootfs = built using busybox | busybox compiled using arm-linux-gnueabihf-gcc
我通过遵循本指南创建了rootfs。
我的内核不能执行任何文件,甚至不能执行init文件>>>、/linuxrc
或/sbin/init
。
为了确保问题不是来自busybox文件,我编写了一个带有-mcpu=cortex-m7
标志的C helloworld程序,并使用arm-linux-gnueabi-gcc
编译了它,但是内核再次修改并抛出了-8错误(Exec格式错误)。
我的busybox文件都链接到busybox二进制文件,并且为32位arm正确编译了二进制文件:
$ readelf -A bin/busybox
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "Cortex-M7"
Tag_CPU_arch: v7E-M
Tag_CPU_arch_profile: Microcontroller
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-2
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_rounding: Needed
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align_needed: 8-byte
Tag_ABI_align_preserved: 8-byte, except leaf SP
Tag_ABI_enum_size: int
Tag_CPU_unaligned_access: v6
内核错误:
[ 0.925859] Run /linuxrc as init process
[ 0.943257] Kernel panic - not syncing: Requested init /linuxrc failed (error -8).
[ 0.950654] ---[ end Kernel panic - not syncing: Requested init /linuxrc failed (error -8). ]---
我的helloworld程序:
$ readelf -A hello
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "7E-M"
Tag_CPU_arch: v7E-M
Tag_CPU_arch_profile: Microcontroller
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-2
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_rounding: Needed
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align_needed: 8-byte
Tag_ABI_align_preserved: 8-byte, except leaf SP
Tag_ABI_enum_size: int
Tag_CPU_unaligned_access: v6
内核错误:
[ 1.189550] Run /hello as init process
[ 1.198670] Kernel panic - not syncing: Requested init /hello failed (error -8).
[ 1.205977] ---[ end Kernel panic - not syncing: Requested init /hello failed (error -8). ]---
Why内核不能执行二进制文件?
发布于 2020-10-13 12:59:05
问题是,您正在编译它的一个正常的静态精灵格式。您应该将其编译为FDPIC-ELF可执行文件(因为缺乏MMU,需要一个独立于位置的可执行文件(FDPIC) )。
FDPIC不是ET_EXEC型。它是ET_DYN (它意味着它是共享的)类型,并由Linux动态加载程序加载。
只需向其添加一个-mfdpic
标志,并在busybox的kconfig菜单中关闭构建的静态二进制文件。
注意,默认情况下,在arm-uclinux-fdpicabi工具链中,-mfdpic标志是打开的。
https://unix.stackexchange.com/questions/610094
复制相似问题