Modified boot.img does not boot (17.04.1)


#1

Hi Everyone!

I am trying to boot custom kernel. At first step I build everything (Image, dtb, dt.img and boot-db410.img) without modification. If I use the original initrd.img for creating the boot image everything is working fine, BUT if I build the modules and install/copy them into the initrd.img, the created boot.img does not start.
Even the size of the new boot.img becomes huge (~108MB).

Commands used:
make defconfig distro.config
make -j8 Image dtbs KERNELRELEASE=4.9.30-linaro-lt-qcom
make -j8 modules KERNELRELEASE=4.9.30-linaro-lt-qcom
make KERNELRELEASE=4.9.30-linaro-lt-qcom modules_install INSTALL_MOD_PATH=…/temp_folder

zcat …/kernel/initrd.img-4.9.30-linaro-lt-qcom | cpio -idmv //to extract the initrd image
Copy the installed modules from the temp_folder (…/lib/modules/) to the extracted file system.
find . | cpio -o -c | gzip -9 > /boot/initrd.img-4.9.30-linaro-lt-qcom //to repack everything

after that I am creating the boot-db410.img again

./skales/mkbootimg --kernel arch/arm64/boot/Image --ramdisk initrd.img-4.9.30initrd.img-4.9.30-linaro-lt-qcom-linaro-lt-qcom --output boot-db410c.img --dt dt.img --pagesize 2048 --base 0x80000000 --cmdline “root=/dev/disk/by-partlabel/rootfs rw rootwait console=ttyMSM0,115200n8”

The size of the new boot image is 108,1 MB.

after the command
sudo fastboot boot boot-db410.img
I am getting the following output on the serial consol:

[41100] [41100] fastboot: download:0671b800
[45540] [45540] fastboot: boot
[45540] [45540] DTB Total entry: 5, DTB version: 3
[45550] [45550] Using DTB entry 0x000000f7/00000000/0x00000018/0 for device 0x000000f7/00010000/0x00010018/0
[45560] [45560] Using pmic info 0xb/0x0/0x0/0x0 for device 0x2000b/0x0/0x0/0x0
[45610] [45610] data abort, halting
[45610] [45610] r0 0x85a00000 r1 0x94b7b810 r2 0x01c77e4b r3 0x1317b800
[45610] [45610] r4 0x2a7a0601 r5 0xa48e7083 r6 0xc676270b r7 0x5a929ad9
[45610] [45610] r8 0x0107b000 r9 0x90100000 r10 0x0107b000 r11 0x90100800
[45610] [45610] r12 0x00000001 usp 0x00000000 ulr 0x00000000 pc 0x8f629a28
[45610] [45610] spsr 0x20000153

What am I doing wrong?
Could be a config file problem?

Any comment is welcomed.
Attila


#2

It’s probably a mistake to copy all the modules into the initrd. Normally an initrd contains only the subset of modules needed to mount the rootfs (on a PC “mount” of rootfs may require decryption keys, and therefore a GUI to get the user password so what is needed to mount rootfs can be quite large… but its still only a subset).

Take a look at the unpacked initrd and see what I mean… there shouldn’t be many .ko files.

In fact, IIRC, the main function of the initrd on the Dragonboards it to run udev so we can mount the rootfs using a name rather than a number. The kernel probably has all the modules needed to mount rootfs built in so regenerating the initrd probably isn’t needed. Its more important to copy the modules to /lib/modules in the rootfs.


#3

hi,

i agree that it looks suspicious that you end up with such a large initrd… I remember we had one user who reported issues when the boot image got too large (i don’t remember how large it was, but that was when enabling KASAN in the kernel, which generates a huge kernel Image file).

There is potentially a LK patch that has been floating around, which we never merged into our release for this issue. The patch is the following:

diff --git a/platform/msm8916/include/platform/iomap.h b/platform/msm8916/include/platform/iomap.h
index 4094d66..bc57716 100644
--- a/platform/msm8916/include/platform/iomap.h
+++ b/platform/msm8916/include/platform/iomap.h
@@ -48,8 +48,8 @@
#define DDR_START                   get_ddr_start()
#define ABOOT_FORCE_KERNEL_ADDR     DDR_START + 0x8000
#define ABOOT_FORCE_KERNEL64_ADDR   DDR_START + 0x80000
-#define ABOOT_FORCE_RAMDISK_ADDR    DDR_START + 0x2000000
-#define ABOOT_FORCE_TAGS_ADDR       DDR_START + 0x1E00000
+#define ABOOT_FORCE_RAMDISK_ADDR    DDR_START + 0x4000000
+#define ABOOT_FORCE_TAGS_ADDR       DDR_START + 0x3E00000

There are instructions in the release notes to rebuild LK and reflash it. Can you please try this patch and let us know? If it works for you, i will try to test and merge this change for our next release…


#4

I think you might be running into a problem I encountered last year. When you install the modules you need to strip them, otherwise that have all the symbol tables and end up too large to fit into the partition. I haven’t rebuilt LK, but I believe that you also need to strip the modules for LK.

sudo make INSTALL_MOD_STRIP=1 modules_install KERNELRELEASE=`make kernelversion`-linaro-lt-qcom

I build the kernel directly on the DragonBoard so this command strips all the modules and installs them into the root partition.

Full disclosure: I am an employee of Qualcomm Canada, any opinions I may have expressed in this or any other post may not reflect the opinions of my employer.


#5

Thank you guys for the ideas.
I will check them tonight and give you feedback.

Update!

I tried STRIP on the installed modules:
find . -name *.ko -exec …/aarch64-linux-gnu-strip --strip-unneeded {} +
The result was really good 13MB instead of the previous 100+ MB.
After merging the new modules into initrd.img and creating new Boot.img
It starts to boot but fail at a later point.

Now the next step will be to try a native build on the Dragonboard itself. The only thing I changed on the kernel that I added a TPM driver with menuconfig. It should not be a problem.