Unpacking/repacking boot.img to test custom kernel build

I’ve compiled a kernel from this repo: GitHub - Teracube-Inc/kernel_teracube_emernia-4.19: Kernel source for the Teracube 2e (2020/2021). Config: emerald_defconfig
and I’d like to test running it on my device.

Passing all the components (kernel, ramdisk, dtb) to fastboot boot didn’t work, so I tried unpacking/repacking an existing boot.img (from sys_zirconia-ota-14.1.0+a459c97).

Using upstream mkbootimg produces a boot.img that’s half the size of the original even though I passed all the info back in that unpack_bootimg produced (even using the original kernel, so it should result in an equivalent image).

Am I missing something? Can you tell me which tools you used to create a working boot.img?
Alternatively, is there a way to get fastboot boot to work? It’d be a lot better for the hardware if I didn’t have to flash the same partition over and over again for testing changes.

1 Like

To answer my own question: using magiskboot binaries from here gave me a working boot.img in the end. I flashed it via fastboot and can confirm it runs (yay!).

Still, is there a way to use fastboot boot instead for development?

Also, somewhat related: could you release your most recent kernel source for zirconia? I noticed the 14.1 update had .325 and the one I built from GitHub is .304.

1 Like

I’ve asked the team to refresh the sources.

Do you think you can make an issue or PR to modify the documentation to indicate that magiskboot is needed for that boot.img modification?

1 Like

Thanks! :slight_smile:
Which documentation are you referring to?

I feel like it should be also possible to use mkbootimg to make an inage from scratch, but maybe I’m holding it wrong.

Initially I’ve used imjtool to inspect and unpack boot.img.
That worked fine; however, after rebuilding via mkbootimg I always got an image that made imjtool segfault which seems sketchy for a tool that can parse all sorts of wacky vendor images across many android versions.

I’ve tried many versions of mkbootimg (from apt on ubuntu 24.04, upstream from google and osm0sis fork that’s apparently used by postmarketOS I’ve read) and neither of them built me an image that does not crash imjtool, which seems suspicious to me.

Maybe it’s the way the kernel is expected to be compressed?

I tried flashing a repack of the most recent boot.img created with upstream mkbootimg and it worked. My guess at what was happening is that imjtool got confused because most official vendor images have some AVB data after the ramdisk and mine does not.

Can you ask anyone from the team if fastboot boot without flashing works on zirconia or if it can be made to work? It’d be really nice if I didn’t have to flash every time after building a boot image.

1 Like