yashsingh1/xdaforums huggingface dataset:
[Android Software Development] Captain_Throwback:
I don't appear to have any drag and drop option in my Ubuntu 15.10 File Manager. Maybe it works on the Desktop, but that's not where I usually have my files (I like to keep things organized). It would be nice to be able to call aik from bin like the mobile version allows. But with the way the bins are set up, I didn't think that was possible. I guess I'll try a few things and see if any work.

I just tried unpacking the boot.img again (so I could pull that error for you), and I got a lot more information than I was expecting:

throwback@QuadCore-SSD-BuildBox:~/android/AIK/M8/GPE/5.07.1700.6_boot$ ./unpackimg.sh --sudo boot.img

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

Supplied image: boot.img

Removing old work folders and files...

rm: cannot remove ‘ramdisk/res/images/charger/battery_scale.png’: Permission denied
rm: cannot remove ‘ramdisk/res/images/charger/battery_fail.png’: Permission denied
rm: cannot remove ‘ramdisk/sbin’: Permission denied
Setting up work folders...

mkdir: cannot create directory ‘ramdisk’: File exists
Splitting image to "split_img/"...
BOARD_KERNEL_CMDLINE console=ttyHSL0,115200,n8 androidboot.hardware=qcom user_debug=30 msm_rtb.filter=0x3b7 ehci-hcd.park=3
BOARD_KERNEL_BASE 00000000
BOARD_NAME
BOARD_PAGE_SIZE 2048
BOARD_KERNEL_OFFSET 00008000
BOARD_RAMDISK_OFFSET 02000000
BOARD_TAGS_OFFSET 01e00000
BOARD_DT_SIZE 1337344

Unpacking ramdisk (as root) to "ramdisk/"...

Compression used: gzip
[sudo] password for throwback:
cpio: res/images/charger/battery_fail.png not created: newer or same age version exists
cpio: res/images/charger/battery_scale.png not created: newer or same age version exists
cpio: sbin/adbd not created: newer or same age version exists
cpio: sbin/crashdump not created: newer or same age version exists
cpio: sbin/gzip_recvy not created: newer or same age version exists
cpio: sbin/healthd not created: newer or same age version exists
cpio: sbin/mfgsrv not created: newer or same age version exists
cpio: sbin/sfc not created: newer or same age version exists
cpio: sbin/ueventd not created: newer or same age version exists
cpio: sbin/watchdogd not created: newer or same age version exists
4444 blocks

Done!
throwback@QuadCore-SSD-BuildBox:~/android/AIK/M8/GPE/5.07.1700.6_boot$

As for my error, it was this on repacking:

Android Image Kitchen - RepackImg Script
by osm0sis @ xda-developers

Packing ramdisk (as root)...

Using compression: gzip
[sudo] password for throwback:

Getting build information...
kernel = boot.img-zImage
cmdline = console=ttyHSL0,115200,n8 androidboot.hardware=qcom user_debug=30 msm_rtb.filter=0x3b7 ehci-hcd.park=3
board =
base = 00000000
pagesize = 2048
kernel_offset = 00008000
ramdisk_offset = 02000000
tags_offset = 01e00000
dtb = boot.img-dtb

Building image...

error: could not load device tree image 'split_img/boot.img-dtb'
Error!
throwback@QuadCore-SSD-BuildBox:~/android/AIK/M8/GPE/5.07.1700.6_boot$

Because I was using a root File Manager to edit the ramdisk files, AIK didn't have the proper permissions to zip the updated zImage and dtb, which explains the error.
[Android Software Development] osm0sis:
Fair enough. Easy fix though: one just needs to remember the only things that must be edited as root are the ramdisk/ files, and that's only if you use --sudo to unpack.
[Android Software Development] Captain_Throwback:
Got it.

I still haven't found a way to run AIK from any folder, though. I put it into its own folder, added it to PATH, but when I tried to run it from a different folder, it's still looking in the AIK folder for the boot.img rather than the folder I'm currently in. Is there any way around that requirement?
[Android Software Development] osm0sis:
Use the full path to the file rather than the relative and it should work. That's likely how it works with drag-and-drop.

"$bin/$arch/unpackbootimg" -i "$1" -o split_img;
[Android Software Development] Captain_Throwback:
Yeah, that works. A bit inconvenient, but I guess it's better than nothing. Thanks!
[Android Software Development] fonz93:
[MENTION=4544860]osm0sis[/MENTION], unfortunately this new 2.0 version doesn't work on my Moto G, same problems as 1.9.1 (no wifi, no network/IMEI), dmesg here: http://pastebin.com/RB9X1DWB, 1.9 still working fine
[Android Software Development] osm0sis:
As I said, use the new --sudo commandline option with unpackimg. Check the AIK-Linux release notes.
[Android Software Development] fonz93:
Sorry, i didn't read carefully, i'll try again
[Android Software Development] BuHaneenHHHH:
i justed wanted to say thanks a lot

it has been days since i was trying to build a kernel for my samsung galaxy note pro lte sm-p905

i always get the zimage and unpack the ramdisk using mkbootimg tools that i downloaded from somewhere else (can't remember the site now)

the repack the zimage that i compiled with the ramdisk the prepare the boot.img.tar and flash it through odin

but the device never boots up

i never suspected that the mkbootimg tools i was using could be corrupted

until a few minutes ago i downloaded your tools and unpacked the stock boot.img

then replaced the zimage with the one i built and it worked

thanks a lot and keep up the good work
[Android Software Development] fonz93:
[MENTION=4544860]osm0sis[/MENTION]

I can confirm 2.0 (linux) it's working now with --sudo, thanks again and sorry for the troubles
[Android Software Development] thgxda:
Hi everybody,

I just downloaded the latest AIK 2.0 for Linux, I would expect, that this is the version with the fixed "file: could not find any magic files"-error, but with my Moto G XT1039 I still have this error, even as "root".

I don't know if the script is supposed to work with CyanogenMod too, I am using "cm-13.0-20151218-NIGHTLY-peregrine".

After removing all the "magic" stuff from the scripts, assuming to use only gzip and manually "filling" the ramdisk-directory with the extracted files (with cpio I also get an error, s.th. like "unexpected end of archive"), I was able to build a new, working boot.img for my device.

It's not that important for me to get it fixed, I found a "workaround", but may be others still have the same problem.

So just attached the "boot.img" from cm13 for this device.

Thanks a lot,

kind regards,

thgxda
[Android Software Development] osm0sis:
Working fine here. rm -rf the old AIK-Linux directory, rm the old downloaded .tar.gz of v2.0 then download from the OP again to make sure you've got the reuploaded version, then tar xzvf it again. To replicate from scratch I downloaded it from the OP and did the above and AIK-Linux v2.0 unpacked your boot.img with no issues on my Ubuntu 13.10 VM.
[Android Software Development] Sun Shower:
I don't know how to unpack zImage file, please somebody help me. windows or Linux. THX
[Android Software Development] USBhost:
first off that's the kernel.

You can't really edit it.

You have to build it from source.
[Android Software Development] DarkHeart Z:
[MENTION=4544860]osm0sis[/MENTION] it doesn't work in cm13 rom . I typed aik in terminal emulator it returned back to root@sprout4:/# . it doesn't cd into /data/local/AIK-mobile directly .
[Android Software Development] osm0sis:
What method of root?
[Android Software Development] DarkHeart Z:
cm's built in root feature .
[Android Software Development] osm0sis:
It's pretty restrictive, try it with SuperSU and let me know how it goes.
[Android Software Development] DarkHeart Z:
Supersu worked flawlessly . Is there any way you can figure out to make it work for cm's built in root feature ? And how can I remove it for reinstalling purpose ?
[Android Software Development] osm0sis:
The only issue is that CM's doesn't keep you in the same directory you were in after the root prompt gets triggered. It's just poor unintuitive coding on their part.

Test this potential workaround/fix with CM's: edit /data/local/AIK-mobile/bin/aik and add another "cd $aik;" line after the "su;" line under "# go local". Then try to trigger it again from a prompt.

Edit: Never mind, the command doesn't make it into the new shell that way.
[Android Software Development] LoScienzo:
Samsung GT-I9301I (S3 Neo)

Recovery: TWRP 2.8.5.0 + Materialised + custom curtain

ROM: unofficial Cyanogenmod 12.1

As for 2nd post, I can say that AIK_Mobile v2.0 works for recovery.img of my phone
[Android Software Development] raimondomartire:
[MENTION=4544860]osm0sis[/MENTION] I've extract Huawei Mate 8 boot.img. Android boot magic error can you help? Thanks
[Android Software Development] osm0sis:
If it's got no magic I can't help at all; they don't follow the standard. :(

Edit: [MENTION=264630]acer73[/MENTION] They do break it in a new and interesting way though; the magic is just located way later than usual, past the 512KB cutoff the standard is designed with. There's a fair amount of data in the added header so I'm not sure if it'd be safe to just chop it off in a hex editor, but you could try.
[Android Software Development] moonlight@china:
can you tell me how to unpack and repack ramdisk.cpio from Sony Z2 CM12.1'S BOOT.IMG
[Android Software Development] shoey63:
Firstly, there is no need to quote the entire op.

Secondly, if you follow the instructions, it will unpack/repack sony cm12 boot images without issue.

Thirdly

- Did you try?

- Did it throw an error?

- What is it you are trying to achieve?
[Android Software Development] Sun Shower:
Thank you for answering my question. I download the kernel source from LGE opensource website and compile the zimage successfully. but there's no dtb file like boot.img-dtb, so how can I get this done?
[Android Software Development] USBhost:
zimage is for older kernels

the image.gz-dtb are the newer kernels

if you have a zimage your fine.

use that
[Android Software Development] moonlight@china:
yes, i have try some days ago,but don't know how to unpack and repack ramdisk.cpio which is unpaked from boot.img,i want to change some file to patch flymeos?
[Android Software Development] osm0sis:
What error is reported? Upload or link to the boot.img.
[Android Software Development] elesbb:
[MENTION=4544860]osm0sis[/MENTION] you deserve a million likes. This tool is freaking perfection. thank. you. so. very. much. You rock.
[Android Software Development] shoey63:
[MENTION=4544860]osm0sis[/MENTION]

There wont be an error. Sony (until recently) have not had a dedicated recovery partition, so a workaround is used.

[MENTION=4591679]moonlight@china[/MENTION]

- Unpack the bootimg

- Move the ramdisk.cpio from /ramdisk/sbin to the AIK directory.

- Rename ramdisk folder to, let's say ramdisk.bak

- Extract ramdisk.cpio

- Modify it

- Use kitchen to repack

- Extract ramdisk-new.cpio.gz to ramdisk-new.cpio

- Rename ramdisk-new.cpio to ramdisk.cpio

- Move it to ramdisk.bak/sbin

- Delete ramdisk folder

- Rename ramdisk.bak to ramdisk

- Repack

- Fastboot image-new.img

- Done
[Android Software Development] moonlight@china:
very thanks

---------- Post added at 12:58 PM ---------- Previous post was at 12:49 PM ----------

1.AIK directory is a folder whic i have made a new?

2.Extract ramdisk.cpio is using “Right mouse button”？

3.how to “ Extract ramdisk-new.cpio.gz to ramdisk-new.cpio”？
[Android Software Development] shoey63:
I use Linux. Just experiment until you get it right. This is not a tutorial thread.

Edit: However:

1. AIK is the working directory of the kitchen (I renamed it)

2. Right "click" and "extract here"

3. Right "click" and "extract here"
[Android Software Development] droidbits:
Deleted!
[Android Software Development] euricoalex:
Great tool unpack recovery change some things repack and works good on Vodafone smart 6 ultra
[Android Software Development] pendor24:
Hello

thank you very very good tool

nickel works on Samsung Galaxy note4 910F

Thank you
[Android Software Development] immadeofpixels27:
Hi all, sorry if this has been answered before in the thread, but after the little searching I have time for I found nothing.

So here's the question: how do you use the mobile distribution? I've flashed it in recovery and run a terminal in /data/local/AIK-mobile but it doesn't recognize any commands? What am I missing?

I attached a screenshot of the commands I ran.

Many thanks in advance.
[Android Software Development] osm0sis:
From a fresh command prompt you type "aik" which handles root and going to /data/local/AIK-mobile

From there, Linux commands that aren't in the path (ie. local ones) need to be executed with the path to the script/binary, so in our case you need to specify it's in the current directory like: ./unpackimg.sh boot.img
[Android Software Development] tajimura:
Whoops, missed that part. Using SEMC Xperia Arc LT18i.

ADD: the error happened when I was trying to repack after changing ramdisk.

Nobody cares what/where is this sent from.
[Android Software Development] osm0sis:
Link to the kernel image please?
[Android Software Development] tajimura:
Kernel is 0503anzu from here http://goo.im/devs/shufuking/CM10.1/BUild 20130502/boot.img

Ramdisk is from this one: www.mediafire.com/download.php?5uv8k2kmqrsrgnf

Nobody cares what/where is this sent from.
[Android Software Development] osm0sis:
shu_cm-10.1-20130503-anzu-boot.img:

Okay, specifically the output is "error: unsupported page size 131072" - this is important. Supported page sizes should be multiples of 1024, and (for older images) no more than 4096. trevd has informed me that there's a new commit to the mkbootimg code on AOSP that now allows 8192 and 16384 max page sizes (and AIK can't support those with its current mkbootimg), but that still doesn't explain why the Xperia Arc's is apparently 131072, or 128 x 1024, which is 8x the (new) 16384 max. Not really sure what's going on there. I'll try and investigate further when I can.

3.0.8-nAa-02_MT11.img:

Your actual error output is "gzip: ../split_img/3.0.8-nAa-02_MT11.img-ramdisk.gz: not in gzip format" - again, that pretty much answers it right there. I took a look at the split ".gz" ramdisk file and it's actually not GZIP at all, it's LZO, which is currently unsupported in AIK. If you want to rig it up yourself you can grab a utility to unpack LZO and then AIK should be able to repack it as GZIP.

LuPuS_haida_jBv7.img:

Here the error output is "gzip: ../split_img/LuPuS_haida_jBv7.img-ramdisk.gz: not in gzip format" - as well, but here the split ramdisk file doesn't appear to be GZIP or LZO, not sure what it is honestly. There is nothing to identify it in the header. Probably one of the other less commonly used ramdisk compressions, like BZIP2 or something, which isn't supported either. No way to work around this unless you know what it is.

Either way, this one also has a pagesize of 131072 so likely wouldn't work even if you could unpack it in the first place. See my response above. Seems I might have to add Xperia Arc S and Neo V to the OP under unsupported because of the weird page size, even though the images are basically in Android format.
[Android Software Development] tajimura:
Thanks for such a detailed answer, mate, it's very pleasant when a dev respects the users so much.

Seems like I had to go for cygwin and do everything manually.

Nobody cares what/where is this sent from.
[Android Software Development] osm0sis:
Did a bit more reading. It's just some bizarre difference with the Neo V and Arc S (at least). Found some great info over in the Neo V CM kernel thread: http://xdaforums.com/showpost.php?p=38840594&postcount=123

CosmicDan there built the newer Cygwin mkbootimg.exe with "large pagesize support" for the Neo V and as you can see from his commands, that crazy 128mb page size is no mistake.

Drop his compile in to android_win_tools and give it a try:

https://github.com/cosmicdan/Xperia-2011-Kernel-2.6.32.9-KRsH/blob/jellybean/mkbootimg.exe?raw=true

I have a feeling it will work. ;):D

Can't do anything about LZO support/other compression support, but decompressing it with lzma as shown in CosmicDan's post and then repacking with gzip isn't too crazy hard. And hmm.. with all these fixes piling up I might have to release a new version even though I was trying to wait it out for [MENTION=4179234]trevd[/MENTION]'s all-in-one.
[Android Software Development] trevd:
I've just ran these through my tool so I can add some more info

shu_cm-10.1-20130503-anzu-boot.img: the original image pagesize is 131072 like [MENTION=4544860]osm0sis[/MENTION] says is weird and although the standard mkbootimg doesn't support that page there's actually nothing to wrong per se with having a pagesize that large. Might be worth asking the dev what tool he's using to pack it. Saying that you should be able to repack with a normal ( supported ) page size and it still boot, ( I've just tested it on an N7 , adjusting the pagesize from 2048 to 16384 and it boot's fine )

The pagesize it's self just tells the boot image unpacker how the boot image is aligned and where to look for the ramdisk and the kernel inside the boot image

LuPuS_haida_jBv7.img: This image also has a pagesize of 131072 and is packed with lzma so a custom unpack is required ( 7zip should unpack it to a cpio level )

Regarding repacking as long as the kernel has support for gzip ramdisks repacking as gzip should be fine. if you pull the /proc/config.gz ( if it exists) from that boot image while it's booted and unzip it, then search the file for CONFIG_RD_GZIP=y if that's there gzipped ramdisks are supported. if /proc/config.gz

Hope that helps.
[Android Software Development] trevd:
[MENTION=4544860]osm0sis[/MENTION] I'll tell you now, I'm way off multiple compression support, Gzip was easy Lzo's a bloody nightmare as It looks like I have to implement my own version of the algorithm. not looked at xz , bzip2 and lzma yet.
[Android Software Development] avinashrocks1990:
can you help out

some way or some file to unpack ramdisk compressed by LZO and LZMA
[Android Software Development] trevd:
On windows 7zip should work just fine or winrar or you could download LZO for windows from here http://gnuwin32.sourceforge.net/packages/lzo.htm. Then the cpio tool in osm0sis' package should unpack the un-lzo'd cpio file, although apparently 7zip will unpack that as well

Here's the instruction on how to use cpio command line tool - http://www.gnu.org/software/cpio/manual/cpio.html

Here's some suggestion on visual tools if you have an aversion to the command prompt : http://reboot.pro/topic/7099-cpio-support-on-windows-with-gui/ :)
[Android Software Development] osm0sis:
Android Image Kitchen v1.5

Uploaded a new version to the OP. Huge thanks to the >1500 people who have downloaded my little project here (v1.0) already in a few short months. :D

v1.5 Changelog:

Added trevd's more recent compile of mkbootfs to fix the charger binary permissions issue on kernels/devices that include this file in their ramdisks to control power-off charging.

Added CosmicDan's patched compile of mkbootimg which supports pagesizes >16384 (new standard max; used to be 4096) to fix the Sony Xperia Arc S/Neo V massive pagesize issue, and widens support to other devices with similar differences.

Fortunately, CosmicDan's custom mkbootimg also supports the --ramdiskaddr argument, allowing me to finally fix the HTC One S/X header issue properly, once and for all (and completely removes the need for an extra workaround like FixHTCImg). I wrote a manual extraction of the ramdiskaddr from the supplied image header since unpackbootimg doesn't split this info out to file on its own. Should also widen support to other devices that are picky about their ramdiskaddr.

Last but not least, support for all the major compression algorithms/containers used for ramdisks(!): gzip, lzop, lzma, xz & bzip2; gzip is the standard and most common, but some developers use others in an attempt to improve boot times. The type of compression is determined and written out to file (ramdiskcomp), then used to unpack appropriately. Repacking is done with the same compression used by the original image.

The new pagesize, ramdiskaddr and compression support should dramatically increase the supported devices and images for AIK. 2nd post updated. :good:

Note:

It is not recommended you attempt to change the type of compression used for the ramdisk, since the kernel itself must be compiled to handle this as well. More often than not, kernel developers only enable support for the specific compression in use and disable all others.

Let me know if you encounter any issues with this new version and I'll see what I can do. It's been tested with a bit of help from avinashrocks1990 and tajimura, and pretty thoroughly personally, making sure the input compression level/options matches the output, but I couldn't find any kernels that use compressions other than gzip and xz for my devices (GN + N7). Things appear to be working perfectly at the moment though, so enjoy!

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.
[Android Software Development] GEKTHEBOSS:
Can work now on my xpu?(xperia u)
[Android Software Development] avinashrocks1990:
yes it should

i have tested it on neo/neo v/arc s
[Android Software Development] GEKTHEBOSS:
Yuppeee.test today:)
[Android Software Development] osm0sis:
Nope. It shouldn't. Sorry guys. Xperia U is still in the 2nd post under "Confirmed Not Working" because it uses a completely different header format ("ELF") to the normal "ANDROID!" one. So far there doesn't seem to be any rhyme or reason to what devices Sony chooses to use the standard or their non-standard format with, and there's no way I can think of to support "ELF" files since it would require entirely separate tools to unpack and repack them.

Please check the OPs next time, seeing as I said I updated them. :)
[Android Software Development] GEKTHEBOSS:
Ive also tried Virtuos Ten Studio and doesnt work...what can i do with this sheety kernel device?(on Windows)
[Android Software Development] osm0sis:
http://www.google.ca/search?q=unpack+elf+sony+kernel ;)

Edit: Check your PMs. :)
[Android Software Development] GEKTHEBOSS:
Ive also searched on googl but no good result for xpu|windows
[Android Software Development] tajimura:
Changed couple of lines in nAa-03 kernel ramdisk (to make it work with MIUIv5), repacked, flashed, and surprise, it doesn't boot. And it doesn't show bootlogo. Only, screen turns on, then off, on-off-on-off etc.

Link to a kernel: http://goo.im/devs/nAa/kernels/3.0.x/jb/anzu/3.0.8-nAa-03_LT18.img

Nobody cares what/where is this sent from.
[Android Software Development] osm0sis:
Does it boot when all you do is unpack and repack? ie. When you don't change anything?
[Android Software Development] immadeofpixels27:
Wow, thanks for the fast response!

Much appreciated, I can change my recovery splash now :o
[Android Software Development] Captain_Throwback:
DELETE
[Android Software Development] seh6183:
FIrst of all thank you osm0sis for this extremely usefull tool/package.

I am using this to unpack a boot.img from a Note 5 to make some ramdisk changes. After the changes and then repack, I am getting "kernel is not seandroid enforcing" and then no attempt to boot. I then realized if I take the kernel, unpack it, do not change it, repack it, then try to flash. Same problem. Kernel before and after repack are identical in size, so I don't see how they can even be different.

I suspect it has something to do with the "ramdisk-new.cpio.lzo" file that is generated in the repack. What is this file and what should I be doing with it? Isn't the newly repacked .img my new boot.img? I just rename the generated .img to boot.img and include it in my rom package. No boot however as described. Strange considering its identical (down to the byte) in size as the original boot.img.

Thanks in advance!
[Android Software Development] osm0sis:
That's a new one. Post the original unmodified image please. What platform are you attempting the repack on?
[Android Software Development] seh6183:
Windows and Ill attach the boot.img now. This is a rom I have made for myself only and not something that will ever be released.

Blazing response time btw LOL
[Android Software Development] osm0sis:
I take it the unmodified boot.img works fine? Just want to be sure.