[TOOL] Android Image Kitchen - Unpack/Repack Kernel Ramdisk [Win/Android/Linux/Mac]
Windows ports of the necessary Linux utils for Android image (kernel/recovery) mod work:
mkbootimg, unpackbootimg: https://github.com/osm0sis/mkbootimg
pxa-mkbootimg, pxa-unpackbootimg: https://github.com/osm0sis/pxa-mkbootimg
dumpimage, mkimage: http://www.denx.de/wiki/U-Boot/WebHome
BootSignature.jar (requires JRE 8+): https://forum.xda-developers.com/and...ified-t3600606
blobpack, blobunpack: https://github.com/AndroidRoot/BlobTools
bzip2, chmod, cpio, cut, dd, file, find, gzip, lzop, printf, tail, xz;
cygbz2-1, cygcrypto-1.0.0, cyggcc_s-1, cygiconv-2, cygintl-8, cyglzma-5, cyglzo2-2, cygmagic-1, cygssl-1.0.0, cygwin1, cygz: http://cygwin.com/
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 Android Verified Boot (AVB)/ChromeOS/SignBlob signed boot.img files, Barnes & Noble Nook "Green Loader" signed boot.img files, Samsung/Spreadtrum DHTB header signed boot.img files, the Samsung/Marvell PXA1088/1908 board boot.img variant (AOSP-PXA), Loki patched boot.img files, Sony SIN signed/packaged kernel.elf extraction, Sony ELF kernel.elf files (repacked as boot.img for unlocked bootloaders), Rockchip KRNL signed ramdisk image files, 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, Android ARM64/x86_64/MIPS64, and now macOS. 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!
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 a few 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; "--level" with 1-9 and possibly 0 allows changing the compression level used to repack to more closely match the original; "--avbkey" with (optionally path and) a keyname allows changing from the default AOSP verity key.
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. _that and rayman for the general methods used to repack a working boot.blob. 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.
AIK - v1.0: 1540; +HTCFix: 430. v1.5: 4718. v1.6: 3556. v1.8: 8678; +Lok2Img: 1629. v1.9: 2580. v2.0: 22886. v2.2: 20522. v2.3: 14524. v2.4: 84432; +LokiAddon: 20071. v2.5: 5004. v2.6: 9354. v2.7: 5442. v2.8: 6639. v2.9: 7672.
Mobile - v1.0: 311. v1.1: 265. v1.2: 302. v1.3: 100. v1.4: 486. v1.5: 224. v1.6: 3303. v1.7: 7798. v1.8: 16286. v1.9: 3800. v2.0: 5444. v2.1: 2526. v2.2: 926. v2.3: 1346. v2.4: 18426. v2.5: 2586. v2.6: 6068. v2.7: 2936. v2.8: 3932. v2.9: 4181.
Linux - v1.0: 75. v1.1: 208. v1.2: 233. v1.3: 112. v1.4: 421. v1.5: 173. v1.6: 1838. v1.7: 2596. v1.8: 4818. v1.9: 604; +v1.9.1: 1068. v2.0: 1836. v2.1: 1240. v2.2: 466. v2.3: 522. v2.4: 8126. v2.5: 1052. v2.6: 2018. v2.7: 1248. v2.8: 2486. v2.9: 5057.
Android Image Kitchen, Tool/Utility for the Android General
Current Stable Version: 3.0
Stable Release Date: 2017-12-14
Last Updated 2017-12-15