FORUMS

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

14,178 posts
Thanks Meter: 31,659
 
By osm0sis, Senior Recognized Developer / Recognized Contributor on 30th December 2012, 03:55 PM
Post Reply Email Thread
10th December 2017, 07:28 PM |#1581  
Wolfcity's Avatar
Recognized Contributor
Thanks Meter: 2,478
 
Donate to Me
More
Quote:
Originally Posted by osm0sis

Yeah it's su -c "<commands>" with a space

Should have known that... Thanks,worked now.

Sent from my Moto G 2014 using XDA Labs
The Following User Says Thank You to Wolfcity For This Useful Post: [ View ] Gift Wolfcity Ad-Free
14th December 2017, 03:21 PM |#1582  
osm0sis's Avatar
OP Senior Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 31,659
 
Donate to Me
More
With this major release we finally get to bid good riddance to mkbootfs. The idea behind this is to ensure everything is as likely to work correctly as possible the first time, with no added command-line switches, no matter if OEM X adds crazy binary Y into /sbin and it requires stupid Z specific permissions, any file from the original unpacked ramdisk will now retain all of its original permissions. Please see my previous Development Update posts regarding AIK-mobile, AIK-Win32 and the NEW(!) macOS (Darwin) support for AIK-Linux for more details on the specific workarounds I had to employ for each platform.

Please also note that for now SIN support is absent from macOS in AIK-Linux because I cannot compile the SIN unpacking tool myself due to the closed-source nature of it. However, I have been in contact with @munjeni and he assures me that he will work on macOS cross-compiles of it when he has some time; hopefully we'll have full feature parity for macOS in AIK v3.1.

Special thanks to @nathanchance who spent several long hours with me trying to work out the totally crazy loop mount command behaviors on the Pixel 2; AIK-mobile would not support Pixel devices right now if it weren't for his excellent help! Check out Flash Kernel if you're on one of his supported devices.

Per usual, the AIK Build Farm has been updated accordingly. Happy hacking!

Flashlt v3.0 is available over in my Odds and Ends thread in case anyone missed it, as it's the perfect companion package to AIK-mobile. It now has some new features like flashing/dumping any device partition and Pixel 2 support.

NOTE: Downloads are hosted on the XDA DevDB Project Downloads page since AIK-mobile exceeds the 20mb zip attachment size limit. These are now also direct-linked in the OP which should get around any issues from downloading via Tapatalk/XDA Labs or without an account, as I'd noticed the download rates and counts were pretty much cut in half on the first versions served from the DevDB.

I work on these projects in my limited time off, so if you like the progress I'm making, or enjoy anything else I've done on xda, please do hit the donate link from my profile. Thanks for your support!


Android Image Kitchen v3.0:
- remove mkbootfs
- add proper cpio repacking, setting UID:GID to root:root to work around Windows incompatibilities
- use Windows "sudo" (Administrator privileges) with find to traverse 000 permissioned (restricted) directories for the cpio repack when detected
- use chmod during cleanup to ensure full removal of 000 permissioned (restricted) ramdisk directories
- when no file name is supplied use the first one found in the working directory
- actually fix AVB signature detection in some scenarios
- fix bug where cpio would dump to main working directory if ramdisk directory could not be accessed (e.g. open in another window/prompt)
- fix handling of filenames with ), as would fail inside if()else() statements
- explicitly set ramdisk root directory (booted "/") to 755 permissions (AOSP default) to avoid issues in some environments
- fix bizarre expansion of saved script paths if run from outside AIK directory
- fix to remain in start directory when cleanup run from outside AIK directory
- fix unpacking with relative filename in start directory when run from outside AIK directory
- update to the latest Cygwin binaries and libraries
- update dumpimage and mkimage binaries (2017.11)
- update mkbootimg, unpackbootimg, pxa-mkbootimg, pxa-unpackbootimg, unpackelf, futility, mkmtkhdr and dhtbsign binaries from my repos
- add current run directory to --avbkey name search list

AIK-mobile v3.0 + AIK-Linux v3.0:
- remove mkbootfs
- loopback mount a make_ext4fs .img to unpack the ramdisk into to allow proper cpio repacking within booted Android with full control of ramdisk properties (AIK-mobile)
- add remount.sh script and README into unmounted ramdisk directory in case the ramdisk .img becomes unmounted (AIK-mobile)
- call cleanup.sh from unpackimg.sh for cleanup functions
- make --sudo functionality the only unpack/repack method to ensure proper full control of ramdisk properties (dummy switch remains for backwards compatibility) (AIK-Linux)
- create magisk.img if needed (e.g. clean recovery flash of Magisk 14+) (AIK-mobile)
- possible fix for stuck Magisk module update message on some devices by ensuring install is to magisk_merge.img (AIK-mobile)
- bump Magisk template version to 1400 (AIK-mobile)
- actually fix AVB signature detection in some scenarios (AIK-Linux)
- fix unpacking with relative filename in start directory when run from outside AIK directory
- add a silent run of cleanup.sh to aik --uninstall functionality to avoid any mount issues (AIK-mobile)
- add macOS (Darwin support), with readlink, dd, cpio, file and tail functions/substitutions as workarounds for poor/broken distro binaries (AIK-Linux)
- add the latest MacPorts binaries and libraries for dd, cpio, file, lzop, tail and xz functionality on macOS (AIK-Linux)
- add workaround to use the latest installed JRE on macOS since it still ships with JDK 7, too old for AVBv1 signing (AIK-Linux)
- fix to ensure the ramdisk root is always root:root ownership (AIK-Linux)
- update dumpimage and mkimage binaries (2017.11)
- update mkbootimg, unpackbootimg, pxa-mkbootimg, pxa-unpackbootimg, unpackelf, futility, mkmtkhdr and dhtbsign binaries from my repos
- fix --avbkey name without path
- clean up --level output (AIK-Linux)
- add current run directory to --avbkey name search list


More on my own build changes in the commits here: https://github.com/osm0sis/mkbootimg; https://github.com/osm0sis/pxa-mkbootimg; https://github.com/osm0sis/unpackelf; https://github.com/osm0sis/futility; https://github.com/osm0sis/mkmtkhdr; https://github.com/osm0sis/dhtbsign.

Installation information and details on each edition can be found in the OP for Win32 or the AIK-mobile and AIK-Linux initial release notes.


If you are reporting a problem with your device, please clearly state your device name and model/variant as well as provide a link to the image file.
The Following 24 Users Say Thank You to osm0sis For This Useful Post: [ View ]
15th December 2017, 05:21 AM |#1583  
ashyx's Avatar
Recognized Contributor
Thanks Meter: 9,888
 
Donate to Me
More
Superb work as usual. Your tireless work is much appreciated.
The Following User Says Thank You to ashyx For This Useful Post: [ View ] Gift ashyx Ad-Free
15th December 2017, 10:20 AM |#1584  
shoey63's Avatar
Recognized Contributor
Flag Somewhere in Oz...
Thanks Meter: 4,013
 
Donate to Me
More
Excellent! Unpacks Sony kernel.sin and repacks as AOSP boot.img perfectly on Windows 10
Edit: And flashing repacked image boots fine without any issues. (Unlocked bootloader obviously)
The Following User Says Thank You to shoey63 For This Useful Post: [ View ] Gift shoey63 Ad-Free
15th December 2017, 02:58 PM |#1585  
Alxoom33's Avatar
Senior Member
Flag New York
Thanks Meter: 1,716
 
More
Quote:
Originally Posted by osm0sis

With this major release we finally get to bid good riddance to mkbootfs. The idea behind this is to ensure everything is as likely to work correctly as possible the first time, with no added command-line switches, no matter if OEM X adds crazy binary Y into /sbin and it requires stupid Z specific permissions, any file from the original unpacked ramdisk will now retain all of its original permissions. Please see my previous Development Update posts regarding AIK-mobile, AIK-Win32 and the NEW(!) macOS (Darwin) support for AIK-Linux for more details on the specific workarounds I had to employ for each platform.

Please also note that for now SIN support is absent from macOS in AIK-Linux because I cannot compile the SIN unpacking tool myself due to the closed-source nature of it. However, I have been in contact with @munjeni and he assures me that he will work on macOS cross-compiles of it when he has some time; hopefully we'll have full feature parity for macOS in AIK v3.1.

Special thanks to @nathanchance who spent several long hours with me trying to work out the totally crazy loop mount command behaviors on the Pixel 2; AIK-mobile would not support Pixel devices right now if it weren't for his excellent help! Check out Flash Kernel if you're on one of his supported devices.

Per usual, the AIK Build Farm has been updated accordingly. Happy hacking!

Flashlt v3.0 is available over in my Odds and Ends thread in case anyone missed it, as it's the perfect companion package to AIK-mobile. It now has some new features like flashing/dumping any device partition and Pixel 2 support.

NOTE: Downloads are hosted on the XDA DevDB Project Downloads page since AIK-mobile exceeds the 20mb zip attachment size limit. These are now also direct-linked in the OP which should get around any issues from downloading via Tapatalk/XDA Labs or without an account, as I'd noticed the download rates and counts were pretty much cut in half on the first versions served from the DevDB.

I work on these projects in my limited time off, so if you like the progress I'm making, or enjoy anything else I've done on xda, please do hit the donate link from my profile. Thanks for your support!


Android Image Kitchen v3.0:
- remove mkbootfs
- add proper cpio repacking, setting UID:GID to root:root to work around Windows incompatibilities
- use Windows "sudo" (Administrator privileges) with find to traverse 000 permissioned (restricted) directories for the cpio repack when detected
- use chmod during cleanup to ensure full removal of 000 permissioned (restricted) ramdisk directories
- when no file name is supplied use the first one found in the working directory
- actually fix AVB signature detection in some scenarios
- fix bug where cpio would dump to main working directory if ramdisk directory could not be accessed (e.g. open in another window/prompt)
- fix handling of filenames with ), as would fail inside if()else() statements
- explicitly set ramdisk root directory (booted "/") to 755 permissions (AOSP default) to avoid issues in some environments
- fix bizarre expansion of saved script paths if run from outside AIK directory
- fix to remain in start directory when cleanup run from outside AIK directory
- fix unpacking with relative filename in start directory when run from outside AIK directory
- update to the latest Cygwin binaries and libraries
- update dumpimage and mkimage binaries (2017.11)
- update mkbootimg, unpackbootimg, pxa-mkbootimg, pxa-unpackbootimg, unpackelf, futility, mkmtkhdr and dhtbsign binaries from my repos
- add current run directory to --avbkey name search list

AIK-mobile v3.0 + AIK-Linux v3.0:
- remove mkbootfs
- loopback mount a make_ext4fs .img to unpack the ramdisk into to allow proper cpio repacking within booted Android with full control of ramdisk properties (AIK-mobile)
- add remount.sh script and README into unmounted ramdisk directory in case the ramdisk .img becomes unmounted (AIK-mobile)
- call cleanup.sh from unpackimg.sh for cleanup functions
- make --sudo functionality the only unpack/repack method to ensure proper full control of ramdisk properties (dummy switch remains for backwards compatibility) (AIK-Linux)
- create magisk.img if needed (e.g. clean recovery flash of Magisk 14+) (AIK-mobile)
- possible fix for stuck Magisk module update message on some devices by ensuring install is to magisk_merge.img (AIK-mobile)
- bump Magisk template version to 1400 (AIK-mobile)
- actually fix AVB signature detection in some scenarios (AIK-Linux)
- fix unpacking with relative filename in start directory when run from outside AIK directory
- add a silent run of cleanup.sh to aik --uninstall functionality to avoid any mount issues (AIK-mobile)
- add macOS (Darwin support), with readlink, dd, cpio, file and tail functions/substitutions as workarounds for poor/broken distro binaries (AIK-Linux)
- add the latest MacPorts binaries and libraries for dd, cpio, file, lzop, tail and xz functionality on macOS (AIK-Linux)
- add workaround to use the latest installed JRE on macOS since it still ships with JDK 7, too old for AVBv1 signing (AIK-Linux)
- fix to ensure the ramdisk root is always root:root ownership (AIK-Linux)
- update dumpimage and mkimage binaries (2017.11)
- update mkbootimg, unpackbootimg, pxa-mkbootimg, pxa-unpackbootimg, unpackelf, futility, mkmtkhdr and dhtbsign binaries from my repos
- fix --avbkey name without path
- clean up --level output (AIK-Linux)
- add current run directory to --avbkey name search list


More on my own build changes in the commits here: https://github.com/osm0sis/mkbootimg; https://github.com/osm0sis/pxa-mkbootimg; https://github.com/osm0sis/unpackelf; https://github.com/osm0sis/futility; https://github.com/osm0sis/mkmtkhdr; https://github.com/osm0sis/dhtbsign.

Installation information and details on each edition can be found in the OP for Win32 or the AIK-mobile and AIK-Linux initial release notes.


If you are reporting a problem with your device, please clearly state your device name and model/variant as well as provide a link to the image file.

Tried to use for repacking modified TWRP 3.2.0-1 boot image with custom splash on Pixel 2XL. Did not boot. Any suggestions?

Sent from my Pixel 2 XL using Tapatalk
15th December 2017, 04:07 PM |#1586  
Senior Member
Flag Indianapolis, IN
Thanks Meter: 1,642
 
More
Quote:
Originally Posted by Alxoom33

Tried to use for repacking modified TWRP 3.2.0-1 boot image with custom splash on Pixel 2XL. Did not boot. Any suggestions?

Sent from my Pixel 2 XL using Tapatalk

I had a similar issue with AIK 2.9 on Linux Mint, when unpacking the custom TWRP 3.0.2 for my Intel x86 tablet. I don't recall what I modified in the ramdisk, but it would not boot for me either. I did not, at the time, pursue it any further as I assumed AIK didn't work with TWRP.

Now I recall. I have 4 different Nextbook Ares 8As. I have V1.1.1, 1.2.0, V2.1.5 and V3.0.4. They all have the same Android 6.0.1 version with the same kernel version: 3.14.64-x86_64. One thing that is different on each device is the build number. In default properties I had changed the build fingerprint to match the current version of that tablet. @vampirefo had built the TWRP on a V1.0.8 version of the tablet. I don't recall if I modified anything else. Each tablet also has a different IFWI (Intel Firmware Interface) version.
The Following User Says Thank You to martyfender For This Useful Post: [ View ] Gift martyfender Ad-Free
15th December 2017, 05:45 PM |#1587  
osm0sis's Avatar
OP Senior Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 31,659
 
Donate to Me
More
Quote:
Originally Posted by Alxoom33

Tried to use for repacking modified TWRP 3.2.0-1 boot image with custom splash on Pixel 2XL. Did not boot. Any suggestions?

Tried via the Materialised theme in recovery, or while booted?

I tested for 4 hours with @nathanchance and his Pixel 2 to work out all the weird Pixel 2 kinks so it should definitely work booted. I'll investigate the setup commands for using it in recovery again.

With v3.0 ditching mkbootfs TWRP and any .img should all repack perfectly in AIK-mobile as it would directly with AK2 in recovery or with straight Linux.
15th December 2017, 06:07 PM |#1588  
Alxoom33's Avatar
Senior Member
Flag New York
Thanks Meter: 1,716
 
More
Quote:
Originally Posted by osm0sis

Tried via the Materialised theme in recovery, or while booted?

I tested for 4 hours with @nathanchance and his Pixel 2 to work out all the weird Pixel 2 kinks so it should definitely work booted. I'll investigate the setup commands for using it in recovery again.

With v3.0 ditching mkbootfs TWRP and any .img should all repack perfectly in AIK-mobile as it would directly with AK2 in recovery or with straight Linux.

Thanks for the quick reply. Did you test on the P2XL, as it has its own quirks? I did the repacking in the new TWRP 3.2.0-1 I used the Adapt a Splash in the Black play theme v. 320Xv1. Flashed the modified image using TWRP in Boot. Rebooted and froze.

Tried again with updated AIK 3.0 Mobile signed.zip. Didn't boot, wound up on the G.
Perhaps I am doing something wrong? Should the modified Twrp image be extracted and flashed in
fastboot instad of Twrp.

Thank you for your kind efforts.

Sent from my Pixel 2 XL using Tapatalk
The Following 2 Users Say Thank You to Alxoom33 For This Useful Post: [ View ] Gift Alxoom33 Ad-Free
16th December 2017, 01:52 AM |#1589  
osm0sis's Avatar
OP Senior Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 31,659
 
Donate to Me
More
Quote:
Originally Posted by Alxoom33

Thanks for the quick reply. Did you test on the P2XL, as it has its own quirks? I did the repacking in the new TWRP 3.2.0-1 I used the Adapt a Splash in the Black play theme v. 320Xv1. Flashed the modified image using TWRP in Boot. Rebooted and froze.

Tried again with updated AIK 3.0 Mobile signed.zip. Didn't boot, wound up on the G.
Perhaps I am doing something wrong? Should the modified Twrp image be extracted and flashed in
fastboot instad of Twrp.

Thank you for your kind efforts.

It'll work if you do it manually while booted to Android (i.e. not recovery). I'm positive we tested the hell out of the Pixel 2 gremlins. There must just be something to fix up in the setup script for recovery execution. Can you upload me dumps of both the working (before) and broken (after) boot.img? The /tmp/recovery.log from directly after adapt splash was run will also be helpful.

Also worth mentioning it's going to be a losing battle on the Pixels since Magisk is going to start compressing the recovery parts into recovery.cpio.xz and the boot parts into boot.cpio.xz as files within the ramdisk on them or when it detects there's less than 500kb free, so there'll be more hoops to get through to modify the theme other than just unpacking the ramdisk going forward..
16th December 2017, 06:57 AM |#1590  
Alxoom33's Avatar
Senior Member
Flag New York
Thanks Meter: 1,716
 
More
Quote:
Originally Posted by osm0sis

It'll work if you do it manually while booted to Android (i.e. not recovery). I'm positive we tested the hell out of the Pixel 2 gremlins. There must just be something to fix up in the setup script for recovery execution. Can you upload me dumps of both the working (before) and broken (after) boot.img? The /tmp/recovery.log from directly after adapt splash was run will also be helpful.

Also worth mentioning it's going to be a losing battle on the Pixels since Magisk is going to start compressing the recovery parts into recovery.cpio.xz and the boot parts into boot.cpio.xz as files within the ramdisk on them or when it detects there's less than 500kb free, so there'll be more hoops to get through to modify the theme other than just unpacking the ramdisk going forward..

May I send it to you in an email attachment. Having a terrible time attaching files in taptalk.

Sent from my Pixel 2 XL using Tapatalk
16th December 2017, 10:09 AM |#1591  
osm0sis's Avatar
OP Senior Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 31,659
 
Donate to Me
More
Quote:
Originally Posted by Alxoom33

May I send it to you in an email attachment. Having a terrible time attaching files in taptalk.

You can also just open xda in Chrome, I upload from Chrome on my devices all the time.
Post Reply Subscribe to Thread

Tags
kernel, ramdisk, recovery, repack, unpack

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes