• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!
  • Fill out your device list and let everyone know which phones you have!    Edit Your Device Inventory
Search This thread


New member
Jun 22, 2021
Hi everyone,

I'm having trouble generating a boot.img using Android Image Kitchen to be the same size as the stock boot.img that I first unpacked! The stock boot.img is 69.1MB and if I unpack that and immediately repack it reduces to 39.1MB.

Samsung S20 Ultra 5G (G988B)
Android 10
PDA: G988BXXU4BTH5 (August 2020)

What I've Done So Far

I've compiled a custom kernel using source straight from Samsung's open source repo. For testing purposes I have made no changes and simply compiled with the relevant toolchains.

To take my compiled kernel and package it up into a boot.img I can flash with Odin, I have followed this guide how-to-unpack-and-edit-android-boot-img using osm0sis' Android Image Kitchen tools (AIK)

I have done the following:
  1. Download custom firmware (PDA: G988BXXU4BTH5) and extract boot.img from AP archive
  2. Unpack boot.img using AIK
    unpackbootimg -i ./boot.img
  3. Construct arguments for mkbootimg based on above step's output
  4. Run mkbootimg with arguments:
    set -e
    set -x
    ./bin/linux/x86_64/mkbootimg \
    --kernel ./boot.img-kernel \
    --ramdisk ./boot.img-ramdisk.gz \
    --dtb ./boot.img-dtb \
    --cmdline "$(cat ./boot.img-cmdline)" \
    --base "$(cat ./boot.img-base)" \
    --kernel_offset "$(cat ./boot.img-kernel_offset)" \
    --ramdisk_offset "$(cat ./boot.img-ramdisk_offset)" \
    --tags_offset "$(cat ./boot.img-tags_offset)" \
    --dtb_offset "$(cat ./boot.img-dtb_offset)" \
    --os_version "$(cat ./boot.img-os_version)" \
    --os_patch_level "$(cat ./boot.img-os_patch_level)" \
    --board "$(cat ./boot.img-board)" \
    --pagesize "$(cat ./boot.img-pagesize)" \
    --header_version "$(cat ./boot.img-header_version)" \
    --hashtype "$(cat ./boot.img-hashtype)" \
    --output ./new-boot.img \
For some reason the resulting boot.img file is 39.1MB whereas the stock boot.img is 69.1MB

To confirm it wasn't my custom kernel, I simply unpacked the stock boot.img and then repacked the extracted files. The output is again 39.1MB. This leads me to believe that AIK is either not extracting all the required files from the stock boot.img or is not packing all the required files into the generated boot.img

I came across this post in which someone successfully built a Samsung S21 boot.img, without size issues, using a fork of AIK however all projects I've used to generate boot.img give me the exact same size inconsistency.

I tried seeing what would happen if I flashed the 39.1MB boot.img on anyway and after succesfully flashing, I got a boot error:
ODIN MODE (DT Load Fail)!
[DTH] dt table header check Fail: FDT_ERR_BADMAGIC


Does this suggest AIK is not packaging the dtb file correctly? Given boot.img-dtb is only 340.1KB, it must be missing more than just this.

I seem to be at an impasse and would be deeply appreciative if the smart people on XDA could lend some advice!

Thank you!

Update #1:
I was able to flash 39.1MB boot.img (with both stock and custom kernel) on and avoiding above DTB Load Fail by:
1. Ensuring name/dir structure is boot.img inside boot.img.tar
2. Using stock dtb file

It then bootloops until I am presented with recovery and error:

From this post it seems like repacking changes hash leading to 'integrity_failed' error above.

Update #2:
I managed to successfully load generated boot.img with custom kernel. I had to disable Android Verified Boot by flashing vbmeta_disabled.tar in the UserData tab in ODIN. This disables integrity checking in the bootloader sequence when the ROM bootloader passes control to the kernel in boot.img

I hope this helps others!


  • vbmeta_disabled.tar
    2 KB · Views: 4
Last edited: