[TOOL]AIK-Unpack/Repack Boot.img and Recovery.img

Android Image Kitchen -- Unpack/Repack Kernel+Recovery Images, and Edit the ramdisk.

Windows ports of the necessary Linux utils for Android image (kernel/recovery) mod work:
unpackbootimg, mkbootimg: https://github.com/osm0sis/mkbootimg
mkbootfs: https://github.com/osm0sis/mkbootfs
unpackelf: https://github.com/osm0sis/unpackelf
mkmtkhdr: https://github.com/osm0sis/mkmtkhdr
loki_tool: https://github.com/osm0sis/lokitool
futility: https://github.com/osm0sis/futility
bzip2, chmod, cpio, cut, dd, file, gzip, lzop, printf, tail xz;
cygbz2-1, cygcrypto-1.0.0, cyggcc_s-1, cygiconv-2, cygintl-8, cyglzma-5, cyglzo2-2, cygmagic-1, cygwin1, cygz: http://cygwin.com/
lz4: http://lz4.github.io/lz4/
magic: http://www.darwinsys.com/file/

See the Mobile Edition (AIK-mobile) initial
release notes for the specifics on the native Android version.
Likewise for the Linux Edition (AIK-Linux) initial
release notes.

My original intent was to have this package dependency-free, but as you can see, I did have to include Cygwin. Initially just for mkbootimg since the huaixzk standalone version wouldn't work (it wasn't loading the kernel as binary, thanks trevd); then I discovered that using the GNUWin32 cpio to unpack somehow didn't play nice with repacking the ramdisk in a usable state, so at that point I decided I might as well go Cygwin across the board. As it is, I've included the latest Cygwin-dependent executables and required libraries from their repos and built my own custom Cygwin image and ramdisk utilities built from the latest sources.
Originally only for Google Pixel/Nexus/AOSP standard boot.img files, built-in support has now expanded to ChromeOS signed boot.img files, Loki patched boot.img files, Sony ELF kernel.elf files (repacked as boot.img for unlocked bootloaders), MTK headers for zImage/ramdisk, and LG Bump/Samsung SEAndroid footers for boot.img.

The main advantage here is you don't need Cygwin shell or PERL scripts. Other guides exist but none of them are universal for target device, compression and/or developed for Windows, Android ARM/x86/MIPS, and now Android ARM64/x86_64/MIPS64. With this universality in mind I've automated the whole process with batch/shell scripts.
My development work on my many projects comes out of my free time, so if you enjoy this project or anything else I've done on xda, please do hit the donate link from my profile. Thank you for your support!

1) Unzip.
2) Either use the command-line "unpackimg <image-filename.img>", or simply drag-and-drop the image. This will split the image and unpack the ramdisk to a subdirectory.
3) Alter the ramdisk as you like.
4) The repackimg batch script requires no input and simply recombines the previously split zImage with the newly packed modified ramdisk using all the original image information (which was also split and saved).
5) The cleanup batch script resets the folder to its initial state, removing the split_img+ramdisk directories and any new packed ramdisk or image files.

There are two optional, advanced command-line arguments for repackimg: "--original", which will cause it to repack using the original split ramdisk instead of repacking, this is useful for testing or trimming dumps; and "--level" with 1-9 and possibly 0 allows changing the compression level used to repack to more closely match the original.

Usage is similar for the Android and Linux versions, again, just review the release notes for them.

Hopefully this is some help to someone. It's been extremely useful for me in my messing around with kernel ramdisks, which is why I created it in the first place.

Questions, comments and feedback welcome.
Credits & Thanks: All authors of the included binaries and libraries for their amazing work, as linked (or linked via GitHub) above. Peteragent5, alansj & iridaki for the general methods used in their PERL scripts and Linux guides. SuperR. & tobias.waldvogel for the general methods used in their kernel.elf unpacking scripts. Chainfire for the ChromeOS and SEAndroid general methods.
cybojenix for the Bump general method.

Thanks to Goatshocker for testing out things for the HTC image issues, leading to the workaround and subsequent fix, avinashrocks1990 & tajimura for testing out compression support and the large pagesize fix, civato for testing out dtb support, talich for testing out the Linux version, shoey63 for testing out Linux + ELF support, and moonbutt74 for testing out Android-x86 support. Huge thank you to trevd and Modding.MyMind/SHM for all the contributing work they've each done and support they've provided.

Disclaimer: Naturally, you take all the responsibility for what happens to your device when you start messing around with things.

Go to the Source post for Downloads!
Click HERE! to go!

Popular Posts