0

I have created a custom initramfs using the below command in my custom initramfs directory: find . | cpio --quiet -H newc -o | gzip -9 -n > ../diaginitrd.img

Then I built a custom bootimage with the above cpio using the command mkbootimg --kernel --ramdisk

Defconfig variables are as below:

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

I have not provided CONFIG_INITRAMFS_SOURCE variable in defconfig.

Kernel command line given is as: Kernel command line: console=ttyMSM0,115200n8 androidboot.console=ttyMSM0 androidboot.configfs=true loop.max_part=7 androidboot.usbcontroller=a600000.dwc3 root=/dev/dm-0 rdinit=/init user_debug=31

On build when i unpack my bootimage i can see my initramfs . On unpacking the initramfs i can see the content of my initamfs.

When i boot the my device with this bootimage i get below logs:

[   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

I am not sure why kernel is not able to read my /init file

Note: my /init is a shell script of type 
init: POSIX shell script, ASCII text executable.
All the binaries in initramfs are statically linked.
  • `error -2` is `-ENOENT` "No such file or directory". So it couldn't find something. Is the `#!` ("shebang") path in your `/init` file correct? – Ian Abbott Jun 17 '20 at 15:20
  • #!/bin/sh this is the shebang path . /bin/sh is present but all are 32 bit . and aarch of system is 64 bit . Can this be a possible issue ? – shivam seth Jun 17 '20 at 16:34
  • possible FS issue caused by your customisation... paste complete log. Suggest to make changes one by one from original working code to backtrace. – Manish Jun 18 '20 at 08:06

1 Answers1

0

I found the answer: It was issue of sh and all other binaries. They were not cross compiled for my system architecture. Now after cross-compiling the script can work.

Thanks "Ian Abbot" for pointing out the issue