0

我在我的自定义 initramfs 目录中使用以下命令创建了一个自定义 initramfs: find 。| cpio --quiet -H newc -o | gzip -9 -n > ../diaginitrd.img

然后我使用命令mkbootimg --kernel --ramdisk使用上述 cpio 构建了一个自定义引导 映像

Defconfig 变量如下:

  • CONFIG_BLK_DEV_INITRD=y
  • CONFIG_RD_LZMA=y
  • CONFIG_RD_BZIP2=y

我没有在 defconfig 中提供 CONFIG_INITRAMFS_SOURCE 变量。

给出的内核命令行如下: 内核命令行:console=ttyMSM0,115200n8 androidboot.console=ttyMSM0 androidboot.configfs=true loop.max_part=7 androidboot.usbcontroller=a600000.dwc3 root=/dev/dm-0 rdinit=/init用户调试=31

在构建时,当我解压缩引导映像时,我可以看到我的 initramfs 。在解压 initramfs 时,我可以看到我的 initamfs 的内容。

当我用这个引导映像引导我的设备时,我得到以下日志:

[   17.850396]  sde: sde1 sde2 sde3 sde4 sde5 sde6 sde7 sde8 sde9 sde10 sde11 sde12 sde13 sde14 sde15 sde16 sde17 sde18 sde19 sde20 sde21 sde22 sde23 sde24 sde25 sde26 sde27 sde28 sde29 sde30 sde31 sde32 sde33 sde34 sde35 sde36 sde37 sde38 sde39 sde40 sde41 sde42 sde43 sde44 sde45 sde46 sde47 sde48 sde49 sde50 sde51 sde52 sde53 sde54 sde55 sde56
[   17.853364] sd 0:0:0:7: [sdh] Write Protect is off
[   17.854114]  sdf: sdf1 sdf2 sdf3 sdf4 sdf5
[   17.854573] sd 0:0:0:7: [sdh] Optimal transfer size 8192 bytes
[   17.861410]  sdg: sdg1 sdg2 sdg3 sdg4 sdg5 sdg6 sdg7 sdg8
[   17.870417]  sdh: sdh1 sdh2 sdh3 sdh4 sdh5 sdh6 sdh7 sdh8 sdh9 sdh10 sdh11 sdh12 sdh13 sdh14 sdh15 sdh16 sdh17 sdh18 sdh19 sdh20
[   17.967128]  sda: sda1 sda2 sda3 sda4 sda5 sda6 sda7 sda8 sda9 sda10
[   17.995848] Freeing unused kernel memory: 7616K
[   18.002632] Initramfs ---> Failed to execute /init (error -2)
[   18.009114] Kernel panic - not syncing: Requested init /init failed (error -2).
[   18.016482] CPU: 6 PID: 1 Comm: swapper/0 Not tainted 4.9.206+ #10
[   18.022707] Hardware name: Qualcomm Technologies, Inc. sda845 v2.1 MTP (DT)
[   18.029718] Call trace:
[   18.032195] [<0000000011338cd0>] dump_backtrace+0x0/0x260
[   18.037635] [<0000000085c2bec8>] show_stack+0x20/0x28
[   18.042724] [<00000000d2899c10>] dump_stack+0xbc/0xf8
[   18.047815] [<00000000bd9287e7>] panic+0x204/0x3f8
[   18.052652] [<00000000b85fea6d>] kernel_init+0xa4/0x10c

我不确定为什么内核无法读取我的 /init 文件

Note: my /init is a shell script of type 
init: POSIX shell script, ASCII text executable.
All the binaries in initramfs are statically linked.
4

1 回答 1

0

我找到了答案:这是 sh 和所有其他二进制文件的问题。它们不是针对我的系统架构进行交叉编译的。现在交叉编译后脚本可以工作了。

感谢“Ian Abbot”指出问题

于 2020-06-19T07:15:34.360 回答