App

[TOOL] Android Image Kitchen-Unpack/Repack Kernel Ramdisk [Win/Android/Linux/Mac]

osm0sisosm0sis

You are reading: [TOOL] Android Image Kitchen-Unpack/Repack Kernel Ramdisk [Win/Android/Linux/Mac]

osm0sis

Senior Recognized Developer / Contributor

Mar 14, 2012
14,950
33,890

Halifax

GT-i9250

Google Nexus 4

  • Dec 30, 2012

  • #1

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:

mkbootimg, unpackbootimg:

https://github.com/osm0sis/mkbootimg

pxa-mkbootimg, pxa-unpackbootimg:

https://github.com/osm0sis/pxa-mkbootimg

elftool:

https://github.com/osm0sis/elftool

unpackelf:

https://github.com/osm0sis/unpackelf

mboot:

https://github.com/osm0sis/mboot

dumpimage, mkimage:

https://www.denx.de/wiki/U-Boot/WebHome

mkmtkhdr:

https://github.com/osm0sis/mkmtkhdr

loki_tool:

https://github.com/djrbliss/loki

futility:

https://github.com/osm0sis/futility

boot_signer.jar (requires JRE 8+):

https://forum.xda-developers.com/an…signing-boot-images-android-verified-t3600606

blobpack, blobunpack:

https://github.com/AndroidRoot/BlobTools

dhtbsign:

https://github.com/osm0sis/dhtbsign

rkcrc:

https://github.com/rockchip-linux/rkflashtool

sony_dump:

https://forum.xda-developers.com/crossdevice-dev/sony/tool-unpack-format-sony-kernel-image-t3530077

bzip2, cat, chmod, cpio, cut, dd, file, find, gzip, hexdump, lzop, printf, tail, truncate, xz;
cygbz2-1, cygcrypto-1.1, cyggcc_s-1, cygiconv-2, cygintl-8, cyglzma-5, cyglzo2-2, cygmagic-1, cygncursesw-10.dll, cygstdc++-6.dll, cygssl-1.1, cygwin1, cygz:

https://cygwin.com/

lz4:

https://lz4.github.io/lz4/

sudo:

https://github.com/mattn/sudo

magic:

https://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/macOS 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 Google Pixel/AOSP vendor_boot.img files, Android Verified Boot (AVBv1)/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, amonet patched boot.img files, Sony SIN signed/packaged kernel.elf extraction, Sony ELF kernel.elf files, Intel OSIP Android image files, DENX U-Boot uImage files, Rockchip KRNL signed ramdisk image files, MTK headers for kernel/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 + 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 consider sponsoring my ongoing work using my

GitHub Sponsors

profile. For a one-time donation you can hit the

donate link

from my profile. Thank you for your support!

Instructions

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 script requires no input and simply recombines the previously split kernel with the newly packed modified ramdisk using all the original image information (which was also split and saved).
5) The cleanup 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; “–origsize”, which will cause it to repack then pad it to the size of the original image, this is useful for repacking dumps to then be fastboot flashed; “–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; “–forceelf” to attempt to make an older unpacked Sony ELF file repack as an ELF.

All scripts also allow unpacking/repacking with the current directory instead of the AIK directory if “–local” is the first command-line argument.

Supported ramdisk compression formats in the *-ramdiskcomp file are gzip, lzop, lzma, xz, bzip2, lz4, lz4-l (for lz4 legacy), cpio (for uncompressed), and empty (for no ramdisk).

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.

Enjoy!
Questions, comments and feedback welcome.

Downloads

Android.Image.Kitchen.v3.8-Win32.zip

UPDATE-AIK.Mobile.Installer.v3.8-ALL-signed.zip

AIK-Linux-v3.8-ALL.tar.gz

Source Code

https://github.com/osm0sis/Android-Image-Kitchen

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. xyz` & k4y0z for the amonet 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, moonbutt74 for testing out Android-x86 support, nathanchance for testing out the new AIK-mobile cpio method on his Pixel 2, leading to important fixes for its support, shakalaca for the great help with completing and testing Intel OSIP support, and Postman1year & CXZa for their help testing to find out the workaround for the Cygwin cut + symlink regression issues. 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.

Download counts:
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. v3.0: 2810. v3.1: 6502. v3.2: 27104. v3.3: 17736. v3.4: 25988. v3.5: 19051. v3.6: 32472. v3.7: 21457.
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. v3.0: 1301. v3.1: 3300. v3.2: 3254. v3.3: 6824. v3.4: 10786. v3.5: 8624. v3.6: 14020. v3.7: 8951.
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. v3.0: 1455. v3.1: 2957. v3.2: 14508. v3.3: 10046. v3.4: 16294. v3.5: 12651. v3.6: 16478. v3.7: 12927.

 

Attachments

  • Android.Image.Kitchen.v3.8-Win32.zip

    7.5 MB · Views: 17,507

  • UPDATE-AIK.Mobile.Installer.v3.8-ALL-signed.zip

    14.1 MB · Views: 9,120

  • AIK-Linux-v3.8-ALL.tar.gz

    13.1 MB · Views: 8,699

Last edited: Sep 9, 2021

  • Like
  • Love

Reactions:

kirichen, dcbakkk, martinsegura84 and 763 others

Chuyên mục: App

Related Articles

Leave a Reply

Your email address will not be published.

Back to top button
444 live app 444 live 444 live app 444live kisslive kiss live yy live yylive