Linuxカーネルの初期化、/bin/shが存在しますが実行できません(エラー-8)。

Linuxカーネルの初期化、/bin/shが存在しますが実行できません(エラー-8)。

バグ:Linuxカーネルが起動し、initramfs / CPIOイメージがロードされますが、initプロセスはエラー-8(NOEXEC)のために失敗します。

[    3.499638] Run /init as init process
[    3.506228] Failed to execute /init (error -8)
[    3.510820] Run /sbin/init as init process
[    3.517222] Run /etc/init as init process
[    3.523164] Run /bin/init as init process
[    3.530061] Run /bin/sh as init process
[    3.536048] Starting init: /bin/sh exists but couldn't execute it (error -8)
[    3.543643] Kernel panic - not syncing: No working init found.  Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance.

使用されるハードウェアとソフトウェア:

  • STM32F429-探索ボード
  • カスタムカーネルとデバイスツリーの設定
  • 最初からカスタムビルドスクリプト(buildrootなし、yoctoなし、uclinuxなし)
  • 静的に接続されたビジボックスの使用

私が試したこと:

  • 外部からCPIOイメージを構築する代わりに、rootfs /ディレクトリを指定し、INITRAMFS_SOURCE=../rootfs/Linux makefileにinitramfs自体を構築するようにしました。また、spec.txtを使ってみました(下記のcat spec.txt)。
  • "noexec = off"パラメータで始めてください〜rdinit=/bin/sh console=ttySTM0,115200n8 earlyprintk noexec=off
  • busybox ELF実行可能ファイルのアーキテクチャが正しいこと、静的にリンクされていることを確認してください。
$ readelf -A rootfs/bin/busybox 
Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "7-M"
  Tag_CPU_arch: v7
  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

$ readelf -A linux/vmlinux
Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "7-M"
  Tag_CPU_arch: v7
  Tag_CPU_arch_profile: Microcontroller
  Tag_THUMB_ISA_use: Thumb-2
  Tag_FP_arch: VFPv2
  Tag_ABI_PCS_wchar_t: 2
  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_enum_size: int

$ cat spec.txt 
dir /dev 755 0 0
nod /dev/console 644 0 0 c 5 1
dir /bin 755 1000 1000
slink /bin/sh busybox 777 0 0
slink /bin/mknod busybox 777 0 0
file /bin/busybox ../rootfs/bin/busybox 755 0 0
dir /proc 755 0 0
dir /sys 755 0 0
dir /mnt 755 0 0
file /init ../rootfs/init 755 0 0```

カーネルフルブートログ: https://pastebin.com/raw/kG78ksKJ

カーネル.config: https://pastebin.com/raw/2Dk4w99h

busybox.config: https://pastebin.com/raw/KzuFdKFr

ベストアンサー1

おすすめ記事