Support lz4 compression for initramfs
I am porting postmarketOS to the Google Pixel 6A, and I've run into an interesting problem, thanks to the requirement of Android 12/13 devices supporting GKI. Specifically, the way these newer devices work is that they have multiple initramfs that are concatenated-- the generic initramfs in the boot partition, and a vendor-specific one in the vendor_boot partition. The only way this concatenation works is if the initramfs compression format is the same for all of these initramfs.
My (limited and possibly incorrect) understanding of the GKI initramfs loading process is:
- the bootloader loads the vendor_boot initramfs
- the bootloader loads the generic boot initramfs on top of the unpacked vendor_boot image
Currently, mkinitfs defaults to gzip, and Google's vendor initramfs uses legacy lz4 (lz4 -l
). As such, the postmarketOS generated initramfs isn't loaded successfully by the bootloader as it's not the same kind of compression as the vendor_boot one.
One tentative workaround is replacing the initramfs in the vendor partition with a gzip-ed one, but the Android recovery is in this vendor initramfs for the Pixel 6A. Replacing the vendor initramfs means losing the Android recovery (and some fastboot
functionality, the so-called userland fastbootd
mode which is required to resize partitions using fastboot
for newer bootloaders, as this resize functionality was moved to fastbootd
).
I can try to experiment based on the LZMA recent merge and see what it might take to implement lz4 -l
support. Also, let me know if you'd like any more information about the Pixel 6A-- I still haven't managed to get a full postmarketOS install working, but as of earlier today I've at least finally confirmed the postmarketOS initramfs (that I manually re-packed with lz4 -l
) does appear to load and begin execution, before dying to some watchdog that reboots the phone.