2

my platform:

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

I've created rootfs by following this guide.

my kernel cannot execute any file even the init file >>> /linuxrc or /sbin/init.

for making sure that the problem is not from busybox files, I wrote a C helloworld program with -mcpu=cortex-m7 flag and compiled it with arm-linux-gnueabi-gcc but again the kernel paniced and throwed the -8 error (Exec format error).

my busybox files are all linked to the busybox binary and the binary is correctly compiled for 32bit 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

the kernel error:

[    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). ]---

my helloworld program:

$ 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

the kernel error:

[    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 the kernel can't execute binaries?

1

the problem is that you are compiling it in a normal static elf format. you should compile it as an FDPIC-ELF executable (because you need a position independent executable (FDPIC) due to the lack of MMU).

FDPIC ELF is not ET_EXEC type. it is ET_DYN (it means it's shared) type and it is loaded by the Linux dynamic loader.

just add a -mfdpic flag to it and turn off the built static binary in the busybox's kconfig menu.

note that -mfdpic flag is on by default in arm-uclinux-fdpicabi toolchains.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.