FORUMS

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

14,176 posts
Thanks Meter: 31,649
 
By osm0sis, Senior Recognized Developer / Recognized Contributor on 30th December 2012, 03:55 PM
Post Reply Email Thread
5th June 2017, 08:12 PM |#1271  
osm0sis's Avatar
OP Senior Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 31,649
 
Donate to Me
More
It's been a busy few weeks!

After a Herculean effort to get the DENX U-Boot utilities to build with the NDK, which required me firing up my Ubuntu VM (for more than testing for once) and then hacking both the NDK toolchains and tool sources, say hello to U-Boot support! It's a *nix standard, and pretty rare on Android but it does exist (e.g. LG Optimus 3D) and I'm extremely pleased to add support for this completely different type of image format to AIK!

I then added support for the Samsung/Marvell variant of the AOSP standard for their pxa1088 board, which I've termed "AOSP-PXA", by updating a modified bootimg tools fork to continue the excellent work done by @ketut.kumajaya and @akuhak. There aren't a lot of known examples of these either (e.g. Samsung Galaxy Core Mini 4G, Samsung Galaxy Tab 4 7.0 & Samsung Galaxy Xcover 3) but it was pretty straightforward and removes another entry from the "Confirmed Not Working" list in the OPs.

Next up, Sony SIN packaging/signature unpack support, thanks to the brilliant research and development of @munjeni for his closed-source kernel_dump binary, of which he also supplied the builds.

Last but not least, it turns out the signatures I identified on the Pixels last month almost immediately went into enforcement after my release.. and it turns out we misunderstood the nature of these signatures so I have reverted the unpackbootimg patch that was originally submitted to me for the Xioami Mi MAX where these signatures were first found; while reappending the original signature was reported to have worked for the Mi MAX, the Pixel bootloader appears to be enforcing it even more strictly and so they must be signed correctly. Luckily, thanks to the great and ongoing work of @Chainfire we've got a cross-platform working signing tool, but it does rely on a Java-like VM - Java Runtime Environment (JRE) 8+ for Windows/Linux to run correctly - and we can use the Dalvik VM on Android without any issues drawing in part from my previous experiments in this area.

Since the original AVB signing OEM keys are naturally unavailable this presents a bit of a problem and there are numerous keys already floating around including SuperSU, ElementalX and a few custom Pixel ROMs. To be sensible we the modding community should all try to use the same keys for interoperability, to make sure different mods stack correctly and avoid any possible problems with encrypted devices, so I have generated the required extra certificate for AVB signing from the usual AOSP testkeys and would encourage all other boot image modifying projects to use them; they are available for use on my GitHub. They are the default for AIK, but a user may specify --avbkey on the repackimg commandline to force the use of other keys. The keys may be placed in the main AIK directory and specified without path with only the base name of the files (e.g. --avbkey supersu for supersu.pk8 and supersu.x509.der) or with a path, but still omitting the file extensions to keep it simple (e.g. --avbkey /path/to/ex for /path/to/ex.pk8 and /path/to/ex.x509.der). Hopefully that'll cover all the bases and some other projects will come around to using the testkeys.

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

NOTE: Downloads have switched to being hosted on the XDA DevDB Project Downloads page since AIK-mobile now exceeds the 20mb zip attachment size limit.

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 v2.8:
- general cleanup using if/else and absolute paths wherever possible and removing hidden hideErrors option for simplicity since it's no longer needed
- add detection if running directly from a command prompt and do not pause if so
- add error catching for unsupported/unrecognized formats on repack, and compression formats on unpack
- update unpackbootimg and unpackelf binaries from my repos
- add DENX U-Boot uImage detection and use dumpimage and mkimage to unpack/repack
- add Samsung/Marvell boot.img variant (AOSP-PXA) and use pxa1088-unpackbootimg and pxa1088-mkbootimg to unpack/repack
- add Sony SIN signature/packaging detection and use kernel_dump to extract the kernel.elf
- add Android Verified Boot (AVB) signature footer detection and use BootSignature.jar to re-sign with AOSP testkeys (https://github.com/osm0sis/testkeys)
- dump AVB type (boot/recovery) to -avbtype so that it may be changed for repack if desired
- refactor repackimg commandline parameter parsing and introduce --avbkey to specify custom keys (accepts path and/or filename minus extensions) to use for AVB re-signing
- update slimmed magic file (from file 5.31) with my own fixes
- update to the latest Cygwin binaries and libraries

AIK-mobile v2.8 + AIK-Linux v2.8:
- general cleanup using absolute paths wherever possible
- add error catching for unsupported formats on repack, and compression formats on unpack
- fix unpack error output on some xz/lzma ramdisks by using included xz binary instead of busybox (AIK-mobile)
- update unpackbootimg and unpackelf binaries from my repos
- add DENX U-Boot uImage detection and use dumpimage and mkimage to unpack/repack
- add Samsung/Marvell boot.img variant (AOSP-PXA) and use pxa1088-unpackbootimg and pxa1088-mkbootimg to unpack/repack
- add Sony SIN signature/packaging detection and use kernel_dump to extract the kernel.elf
- add Android Verified Boot (AVB) signature footer detection and use BootSignature.jar to re-sign with AOSP testkeys (https://github.com/osm0sis/testkeys)
- dump AVB type (boot/recovery) to -avbtype so that it may be changed for repack if desired
- refactor repackimg commandline parameter parsing and introduce --avbkey to specify custom keys (accepts path and/or filename minus extensions) to use for AVB re-signing
- actually fix chromeos subfolder permissions during install (AIK-mobile)
- fix unpackimg --help to show --sudo option (AIK-Linux)
- update file binary (5.31) (AIK-mobile)
- update slimmed magic file (from file 5.31) with my own fixes


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

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 30 Users Say Thank You to osm0sis For This Useful Post: [ View ]
8th June 2017, 04:16 AM |#1272  
Senior Member
Flag Tirupati
Thanks Meter: 233
 
More
Hi there,I'm getting the following error after updating to AIK 2.8(mobile)
Code:
Android Image Kitchen - UnpackImg Script
by osm0sis @ xda-developers

Supplied image: boot.img

Setting up work folders...

Image type: AOSP

Splitting image to "split_img/"...
BOARD_KERNEL_CMDLINE console=ttyS1,115200n8
BOARD_KERNEL_BASE 00000000
BOARD_NAME
BOARD_PAGE_SIZE 2048
BOARD_HASH_TYPE sha1
BOARD_KERNEL_OFFSET 00008000
BOARD_RAMDISK_OFFSET 01000000
BOARD_SECOND_OFFSET 00f00000
BOARD_TAGS_OFFSET 00000100
BOARD_DT_SIZE 53248

Unpacking ramdisk to "ramdisk/"...

Compression used: gzip
gzip: ../split_img/boot.img-ramdisk.cpio.gz: No such file or directory

Done!
Sent from my LAVA X1 Beats using XDA Labs
8th June 2017, 06:06 AM |#1273  
osm0sis's Avatar
OP Senior Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 31,649
 
Donate to Me
More
Quote:
Originally Posted by Jitheshwar

Hi there,I'm getting the following error after updating to AIK 2.8(mobile)

Code:
Android Image Kitchen - UnpackImg Script
by osm0sis @ xda-developers

Supplied image: boot.img

Setting up work folders...

Image type: AOSP

Splitting image to "split_img/"...
BOARD_KERNEL_CMDLINE console=ttyS1,115200n8
BOARD_KERNEL_BASE 00000000
BOARD_NAME
BOARD_PAGE_SIZE 2048
BOARD_HASH_TYPE sha1
BOARD_KERNEL_OFFSET 00008000
BOARD_RAMDISK_OFFSET 01000000
BOARD_SECOND_OFFSET 00f00000
BOARD_TAGS_OFFSET 00000100
BOARD_DT_SIZE 53248

Unpacking ramdisk to "ramdisk/"...

Compression used: gzip
gzip: ../split_img/boot.img-ramdisk.cpio.gz: No such file or directory

Done!

Device? Image? How are you executing it?

Give me some details, I have zero problems here.
8th June 2017, 08:09 AM |#1274  
Senior Member
Flag Tirupati
Thanks Meter: 233
 
More
Quote:
Originally Posted by osm0sis

Hi there,I'm getting the following error after updating to AIK 2.8(mobile)
[hide]

Device? Image? How are you executing it?

Give me some details, I have zero problems here.

LAVA iris X1 Beats. Earlier till 2.7 version aik worked fine.
here is my boot.img https://drive.google.com/file/d/0B-8...NXOHZtN1E/view but I got same error with other images
I executed the script using both root browser and terminal emulator but both gave same error
Code:
Compression used: gzip
gzip: ../split_img/innjooboot.img-ramdisk.cpio.gz: No such file or directory
this error results in no files in ramdisk folder

Sent from my LAVA X1 Beats using XDA Labs
The Following User Says Thank You to Jitheshwar For This Useful Post: [ View ] Gift Jitheshwar Ad-Free
8th June 2017, 09:53 AM |#1275  
Senior Member
Flag Tirupati
Thanks Meter: 233
 
More
I'm not facing this issue in my another device. Tried unpacking the same boot.img it's worked. I think the latest version of aik is incompatible with that mobile.

Sent from my Lenovo A6000/Plus using XDA Labs
The Following User Says Thank You to Jitheshwar For This Useful Post: [ View ] Gift Jitheshwar Ad-Free
8th June 2017, 10:11 AM |#1276  
osm0sis's Avatar
OP Senior Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 31,649
 
Donate to Me
More
Quote:
Originally Posted by Jitheshwar

I'm not facing this issue in my another device. Tried unpacking the same boot.img it's worked. I think the latest version of aik is incompatible with that mobile.

I'd say you should download v2.8 again and reflash. It unpacks on all of my devices no problem.. Something weird going on for sure.

Edit: @Jitheshwar, if that doesn't work then the only thing I can think of is that your devices's toolbox/toybox is extremely limited/broken and this change is what's causing your issue on that device: https://github.com/osm0sis/Android-I...62ae97a8faL181

Basically that would mean your `mv` (move) command doesn't accept "-f" (force) so the ramdisk doesn't get renamed to what the unpack command then expects.

Try removing the -f from that line in v2.8 and let me know if it resolves it; I might just have to start relying on my included busybox for more of the pedestrian tasks as well.
The Following User Says Thank You to osm0sis For This Useful Post: [ View ]
8th June 2017, 02:54 PM |#1277  
Senior Member
Flag Tirupati
Thanks Meter: 233
 
More
Quote:
Originally Posted by osm0sis

Try removing the -f from that line in v2.8 and let me know if it resolves it; I might just have to start relying on my included busybox for more of the pedestrian tasks as well.

Thanks @osm0sis that's worked.

Sent from my LAVA X1 Beats using XDA Labs
The Following User Says Thank You to Jitheshwar For This Useful Post: [ View ] Gift Jitheshwar Ad-Free
8th June 2017, 06:58 PM |#1278  
osm0sis's Avatar
OP Senior Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 31,649
 
Donate to Me
More
Quote:
Originally Posted by Jitheshwar

Thanks @osm0sis that's worked

Excellent! You can also put the -f back and make it like: $bb mv -f

That's how it'll officially be in v2.9 down the road.
The Following 2 Users Say Thank You to osm0sis For This Useful Post: [ View ]
11th June 2017, 01:22 PM |#1279  
Hacker $007 $'s Avatar
Member
Flag India
Thanks Meter: 25
 
More
how to unpack Zimage and modify it
11th June 2017, 01:32 PM |#1280  
osm0sis's Avatar
OP Senior Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 31,649
 
Donate to Me
More
Quote:
Originally Posted by Hacker $007 $

how to unpack Zimage and modify it

It's compiled code so generally you can't modify it.
14th June 2017, 01:57 PM |#1281  
Senior Member
Flag Hyderabad
Thanks Meter: 356
 
Donate to Me
More
Hi, @om0sis I tried AIK on my mobile.. Flashed the zip via twrp..and AIK is located in /data/local/AIK-mobile .I tried unpacking bootml.IMG and it worked...but symlinks are getting linked to their actual path .and ramdisk size is in gb's. Any workaround for this issue.?
PS: I'm using aosip nougat 7.1
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