tizen: bootscript: unpack initramfs and pass its actual size to kernel
authorMarek Szyprowski <m.szyprowski@samsung.com>
Mon, 7 Oct 2024 08:48:01 +0000 (10:48 +0200)
committerJaehoon Chung <jh80.chung@samsung.com>
Mon, 28 Oct 2024 11:28:48 +0000 (20:28 +0900)
The initramfs ramdisk image (CPIO compressed archive) is stored on the
separate ramdisk/ramdisk-recovery partitions, thus it is not possible to
determine size of the compresszed archive. Passing the size of the
partition as the size of initramfs image to the kernel instructs the
kernel to check if the remaining bytes are another CPIO archive with more
initramfs data.

Decompressing or interpreting such additional garbage bytes sometimes
fails, what results in kernel ignoring the whole initramfs data as broken
one and thus breaking the Tizen boot sequence.

To avoid such problems and dependency on unknown/garbage data from
ramdisk partitions, lets decompres initramfs data (CPIO gzip archive)
directly in u-boot and pass the kernel only the single, uncompressed CPIO
archive as iniramfs image.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Change-Id: Ic373477589e2b29f7bf89c803241bc29d6c7b983

tizen/bootscript/tizen-boot-rpi4.scr
tizen/bootscript/tizen-boot-vf2.scr

index b284cea662ae155ebe982e09e3c3201818eefcd4..6e7c495880636e023bed87a572be7f955f06bd9b 100644 (file)
@@ -120,6 +120,10 @@ if test -e $devtype $devnum:$ramdiskpart sbin/init; then;
 elif itest.w *$ramdisk_addr_r == 0x8b1f; then; # check for gzip (initramfs) magic
        echo "Using initramfs from partition ${ramdiskpart}";
        setenv rootargs
+       setexpr ramdisk2_addr_r $ramdisk_addr_r + $ramdisk_size
+       unzip $ramdisk_addr_r $ramdisk2_addr_r
+       setenv ramdisk_size $filesize
+       setenv ramdisk_addr_r $ramdisk2_addr_r
 else
        echo "Booting without initrd/initramfs";
        setenv bootmode normal
index 89ccbf94cbc6d732c326af07861cf79de5d650ac..1ef0d36527dc74b5b35046caa0796787afd4163d 100644 (file)
@@ -103,6 +103,10 @@ if test -e $devtype $devnum:$ramdiskpart sbin/init; then;
 elif itest.w *$ramdisk_addr_r == 0x8b1f; then; # check for gzip (initramfs) magic
        echo "Using initramfs from partition ${ramdiskpart}";
        setenv rootargs
+       setexpr ramdisk2_addr_r $ramdisk_addr_r + $ramdisk_size
+       unzip $ramdisk_addr_r $ramdisk2_addr_r
+       setenv ramdisk_size $filesize
+       setenv ramdisk_addr_r $ramdisk2_addr_r
 else
        echo "Booting without initrd/initramfs";
        setenv bootmode normal