yashsingh1/xdaforums huggingface dataset:
[Android Software Development] t0pa2:
Made a mistake..

So I had a boot.img from my ROM sitting in my Downloads folder. I used Image Kitchen to unpack the image. But when I used the cleanup button it essentially cleaned out my internal storage. My intention was to open boot.img, dig around in its contents, then delete it from my phone. Is there any way to recover my internal storage after this? OnePlus 3, OOS 4.0.2, EX Kernel, SuperSU.
[Android Software Development] osm0sis:
Wow.. That should not happen. All the scripts switch directory to their own locations before doing anything, and even then cleanup.sh only removes 3 specific things: `rm -rf ramdisk split_img *new.*;` :confused::eek:

Can you explain step-by-step your method of executing AIK-mobile so I can understand better? If I can figure out how things got deleted, and it is indeed a script issue, I'll try to add some safeguards in the next version to make sure that doesn't happen ever again..

As for data recovery options.. This old guide is the only thing that comes to mind:

https://xdaforums.com/galaxy-nexus/general/guide-internal-memory-data-recovery-yes-t1994705 :(
[Android Software Development] ashyx:
The best tool I've used is an app called diskdigger pro.

If it can be recovered this will do it.
[Android Software Development] agalardi:
Dear osm0sis and USBhost,

It seems that my boot.img could not be unpacked and repacked. Do you have any suggestion? What could be my next step for reach the root goal?

I am really lost and I don't want to give up.

Thanks again.
[Android Software Development] Captain_Throwback:
Hey osm0sis! Thanks for adding Magisk compatibility to Mobile AIK. Unfortunately your module gets deleted because it doesn't include a module.prop file, which is required for valid Magisk modules. Any way you can add that?

EDIT: Here's a link to that file from the module template.
[Android Software Development] osm0sis:
Damn, I was basing support on a mod of my busybox zip from the Magisk module collection thread. Guess that was for an older version of Magisk. I'll fix it for the next version. I'll also try to fix it, probably tomorrow, for the Odds and Ends thread zips I also thought I'd added support to. :p

Thanks for letting me know. Anything else I'm missing for minimal proper Magisk support?
[Android Software Development] Captain_Throwback:
I think that's it, although Magisk seems to have an issue mounting symlinks, so if the aik symlink is all you're putting in the /magisk module folder, it might not work anyway (I was having that issue when I tried building a Mobile AIK module from your zip). But I won't know for sure until I test your updated zip.
[Android Software Development] osm0sis:
In v2.5 it went back to being a copy of the aik script since Nougat doesn't allow cross-device executable symlinks in general, so should hopefully just work. :good:
[Android Software Development] t0pa2:
So I had my boot.img in the downloads folder, I unpacked the image, then I hit clean up. Then everything was gone. At this point I don't expect my data back. I glanced at the method you posted, but I guess I'm more worried about missing file structures than my photos. If I saw the folders that got deleted I could tell if they were important. Thanks for the help.
[Android Software Development] osm0sis:
Right, that doesn't make any sense though. It was in /sdcard/Downloads? You unpacked it how; command line, FX File Explorer? Then you "hit" cleanup how?

Step by step and details please. I can't reproduce it on my end at all.
[Android Software Development] t0pa2:
The only application I used was AIK. My boot.img was in /SD card/download/. I used the "unpack img" in AIK to unpack boot.img. Next I used the "cleanup" button inside AIK, which proceeded to wipe everything inside /SD card/.
[Android Software Development] osm0sis:
I'm sorry that happened to you but that's not my app.

Go find the developer of that crap and report the issue to them. He's using my scripts without my permission and clearly did a sh*tty job of it, not to mention he stole my AIK branding for his icon. Accept no imitations.
[Android Software Development] zaibansari20:
It happened to me

This app wiped my internal storage by cleanup option
[Android Software Development] t0pa2:
Thanks mate. I had no idea it was an imitation app, and now I feel stupid for posting here. Also, now I understand your confusion.
[Android Software Development] osm0sis:
Same goes for you. F*ck that off-brand garbage app.

I've tried to report that app to Google Play for removal (months ago) but they didn't do anything about it. Guess they don't respect my IP. :(

Believe me, you'll know when I've got an app. ;)

No time to learn to write one currently, but I'm also pretty content for now with how my AIK-mobile functionality works within FX File Explorer. Check it out here: https://xdaforums.com/showpost.php?p=66146450&postcount=881
[Android Software Development] Tkkg1994:
[MENTION=4544860]osm0sis[/MENTION] just tried to unpack latest s7 boot.img with your new 2.5 AIK (on a linux running machine). The 2.4 version worked fine however the latest update results in a error message (check attached screen shot)

The img doesn't get unpacked.

I've also attached the boot.img as a zip below :)

Hope I can help you out somehow
[Android Software Development] osm0sis:
Damn, I tested a lot to try and avoid regressions, but I guess one slipped through.

Segfaults are usually the unpackbootimg binary failing to have its output directories set up beforehand. Not sure how that could happen.

Thanks for the boot.img, I'll check it out.
[Android Software Development] shoey63:
Look who is back ;) https://xdaforums.com/showthread.php?p=70803150
[Android Software Development] kykint:
Maybe this could be a temporary workaround I think, I was having the same issue :p ..
[Android Software Development] SuperR.:
I have not looked into the cause, but I can confirm that this happens when I run AIK like this:

cd /path/to/AIK
./unpackimg boot.img

If I run it like this, no problem:

cd /path/to/AIK
./unpackimg /path/to/AIK/boot.img
[Android Software Development] osm0sis:
Yup, I can reproduce it on AIK-mobile this way as well.

It's definitely because of the change starting here:

https://github.com/osm0sis/Android-...8ba3#diff-4db37212a41881b7528d0c62ae97a8faL53

To accommodate the different split commands I plan to add it now goes into split_img before executing, but of course that then means we can't just use the pathless filename anymore. :rolleyes::silly:

As-is your patch will break AIK-mobile's sourced execution (maybe drag-and-drop on Linux as well), but something like that is definitely the best solution. Paths for all. Thank you. :highfive:

Everyone please consider the following a hotfix for AIK-mobile and AIK-Linux and either adjust your usage (always use full paths) or fix unpackimg.sh with it until v2.6 is ready. AIK-Win32 is unaffected. :)

Patch the unmodified AIK-mobile v2.5 with the following at a root command prompt:

sed -i '38s/^/img="$(readlink -f "$img")";\n/' /data/local/AIK-mobile/unpackimg.sh;

Or this within the script directory of unmodified AIK-Linux v2.5 to patch it:

sed -i '31s/^/img="$(readlink -f "$img")";\n/' ./unpackimg.sh;
[Android Software Development] kevin mitnick:
I try unpack recovery.img and found folder split_img and ramdisk

I found file recovery.img-ramdisk.cpio.gz

how to decompress file .gz ?

anyone please explain how to use this amazing tool on windows

thank you
[Android Software Development] ashyx:
Why do you need to decompress it again when it's already done?
[Android Software Development] drajp:
I am total newbie in kernal modification and wanna learn and create custom kernal! Please suggest me any thread/book/article i should go through before starting development!
[Android Software Development] Vagelis1608:
All you need is Google.

Start with something like "build android kernel". ;)
[Android Software Development] Tkkg1994:
Finally had time to test it, what should I say, works perfect! Thank you man
[Android Software Development] REtails:
Thank you so much for quickly addressing this - I just started using your project today and troubleshooting that segfault was beyond my scope of knowledge. I was so eager to get my android setup running smoothly after using the win32 version earlier this afternoon, and after this little correction I am now unpacking the boot.img without issue on my tablet. You can add the Galaxy Tab A 10.1" (2016/SM-T580/gtaxlwifi) to the supported devices list! :)

Moreover, thank you so very, very much for this project! I am just getting into rom customization and have given myself a crash course today. Thanks to your project I am already making kernel modifications and so thrilled with my progress. I am broke now as using my brain is only a hobby interest for the time being, but I get paid at the end of the week. I would happily buy you a beer if you accept donations!!

Now that I have my setup up and running I will happily answer any questions anyone has pertaining to the installation or usage of AIK-mobile, especially those that the developer may have already been asked a few hundred times. ;) hehe
[Android Software Development] osm0sis:
Added, thanks! Glad to hear of your successes! I do accept donations, there's a button on my profile, or the following link should also work: https://xdaforums.com/donatetome.php?u=4544860

Donations are pretty rare despite the number of downloads this project sees (~85,000 downloads of the previous Win32 version alone :eek:), and are so, so very much appreciated considering how much time I put into it! :D
[Android Software Development] dimenfer:
I'm having the error below on Windows, v2.5, tried the batch file and manually.

"Supplied image: twrp.img

Setting up work folders . . .

Image type: ELF

Splitting image to "split_img/" . . .

error: Unexpected number of elements: 4

Error!"
[Android Software Development] osm0sis:
Upload the file and maybe give some info about your device? :rolleyes:
[Android Software Development] dimenfer:
Here is the TWRP img, i'm using Sony XperiaSP (Huashan) and Windows 10.
[Android Software Development] shoey63:
Something is not right. twrp.img shouldn't be in elf format.
[Android Software Development] dimenfer:
Yeah, now I can see it, I downloaded TWRP for Moto G XT1032 and it worked normally on Windows and AIK Mobile, maybe the way TWRP work in Xperia SP is different, sad :(, I will look in the Xperia SP threads to see if anyone use AIK, Thanks again.
[Android Software Development] osm0sis:
Hmm but for that device it is.. and one that unpackelf doesn't yet support. I'll look into it.
[Android Software Development] REtails:
Donation from a guest on XDA Developers ()
$X.00 USA

Receipt No: XXXX-XXXX-XXXX-8656

Thanks again for your hard work! I'm taking the challenge level up a notch and setting out to build a custom kernel with drivers added this weekend. Eek!

PS. I will continue to contribute as I am able, sorry I couldn't donate more!
[Android Software Development] osm0sis:
Amazing! Thank you so much! Good luck with the build! :D
[Android Software Development] zainifame:
on intel zenfone 5 x86 image with $OS$ header can detect image but at the end showing error like this
[Android Software Development] osm0sis:
Yeah no support for $OS$ yet. There are several different implementations of it which is pretty tricky. Just (bad) luck that it recognized something on that particular image.
[Android Software Development] osm0sis:
As an update to this, I've only received 1 person's input about dropping Windows XP support due to Cygwin and it was to tell me to do so, so unless there are any major objections I'll probably move up my timeline and do this for the next version since it'll also help me out with development.
[Android Software Development] osm0sis:
Got it. ;)

https://github.com/osm0sis/unpackelf/commit/a664608f51daae7a0c5c3c4f8a9a701e40ca488a

As with all ELF files, it depends on your device whether your unlocked bootloader will accept the standard Android boot.img repack AIK will create, but, that said, AIK v2.6 will definitely be able to unpack your file now! :cowboy:
[Android Software Development] Joeisgood99:
Hey [MENTION=4544860]osm0sis[/MENTION]

When attempting to split stock Nougat kernel.elf from Sony Z5c I get the following error

~/development/AIK-Linux$ sudo ./unpackimg.sh kernel.elf
Android Image Kitchen - UnpackImg Script
by osm0sis @ xda-developers

Supplied image: kernel.elf

Setting up work folders...

Image type: ELF

Splitting image to "split_img/"...
error: Could not open kernel image kernel.elf

Error!
ben@ben-G55VW:~/development/AIK-Linux$

So I cloned source and attempted to build unpackelf on my pc (ubuntu 16.4)

I got the following erors.

:~/development/unpackelf$ make
gcc -o unpackelf.o -ffunction-sections -O3 -c unpackelf.c -Werror
unpackelf.c: In function ‘read_elf’:
unpackelf.c:181:2: error: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Werror=unused-result]
fread(buffer, 1, sizeof(buffer), f);
^
unpackelf.c:197:3: error: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Werror=unused-result]
fread(&elf32, 1, sizeof(elf32), f);
^
unpackelf.c:221:3: error: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Werror=unused-result]
fread(ph32, 1, sizeof(ph32), f);
^
unpackelf.c:227:4: error: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Werror=unused-result]
fread(obj[i], 1, obj_len[i], f);
^
unpackelf.c:233:4: error: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Werror=unused-result]
fread(&sh32, 1, sizeof(sh32), f);
^
unpackelf.c:238:4: error: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Werror=unused-result]
fread(obj[3], 1, obj_len[3], f);
^
unpackelf.c:252:3: error: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Werror=unused-result]
fread(&elf64, 1, sizeof(elf64), f);
^
unpackelf.c:276:3: error: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Werror=unused-result]
fread(ph64, 1, sizeof(ph64), f);
^
unpackelf.c:282:4: error: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Werror=unused-result]
fread(obj[i], 1, obj_len[i], f);
^
unpackelf.c:288:4: error: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Werror=unused-result]
fread(&sh64, 1, sizeof(sh64), f);
^
unpackelf.c:293:4: error: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Werror=unused-result]
fread(obj[3], 1, obj_len[3], f);
^
cc1: all warnings being treated as errors
Makefile:24: recipe for target 'unpackelf.o' failed
make: *** [unpackelf.o] Error 1

Any tips??

Thanks in advance
[Android Software Development] osm0sis:
Don't use "sudo" use the --sudo argument.

And of course make sure you use the hotfix and/or the full path to the kernel.elf file.
[Android Software Development] Captain_Throwback:
[MENTION=4544860]osm0sis[/MENTION]

Wanted to let you know that AIK-Mobile doesn't work with Magisk I think because it's missing module.prop like nano was. Just FYI if I didn't mention it before :).
[Android Software Development] osm0sis:
You did mention and it is already fixed for v2.6. :)
[Android Software Development] :
I'm looking to try and pack a boot.img for my stock 5.1.1 Xperia C3 and there are currently 0 development/developers for it so I'm going in blind. I've managed to create a zImage and would like to pack it into a boot.img using this tool, I have an original boot.img that someone else used as well.

So my question is are there anything else I need that is device specific before using it? I hear Xperia kernels are a pain to compile, and I hope to make a flashable zip from this.

Edit: I'm also new to Ubuntu/Linux. From what I gather, download all the files mentioned here and just run the script?
[Android Software Development] Vagelis1608:
You can use AnyKernel2 (by [MENTION=4544860]osm0sis[/MENTION] ) to put the zImage you made in the kernel on the device.

I don't have an Xperia phone, so I don't know if you need anything else. Just try it and see if it works.

You will need an unlocked bootloader.
[Android Software Development] :
I'm not sure about that one, since it asks for boot partition location. Isn't that the one thing that bricks your phone if you have no idea what you're doing?

Also I've no idea how to call that one up or what to replace.

Edit: [MENTION=4544860]osm0sis[/MENTION] Thank you so much. I now have a working boot.img and the changes I made are all reflected!
[Android Software Development] Vagelis1608:
The boot partition is the kernel, so you will have to modify it in order to modify the kernel.
[Android Software Development] :
Hmmm so that means if I were to add a lot of features to the kernel then I would have to modify the boot partition size am I correct? Or else the boot partition won't have space for the image and thus won't flash?
[Android Software Development] shoey63:
Not quite. The boot.img contains the kernel (ie: zImage) PLUS ramdisk and offsets. To modify the zImage you need to compile it from source. The ramdisk can be modified with the kitchen.
[Android Software Development] :
Well my test kernel worked perfectly, but when I added KCAL drivers it broke even TWRP. I can't boot past the splash screen nor into TWRP, so I don't think it's the driver problem. I guess maybe the ramdisk or boot partition needs to be modified or something.

Also, when I repack a new boot.img do I use the stock boot.img as base or my new compiled ones?
[Android Software Development] Vagelis1608:
If you compile a kernel or zImage from source, then you use your own.

The boot partition is larger than the kernel.

E.g. my phone's kernel is about 11 MB, while the boot partition is about 22 MB.
[Android Software Development] :
I've no idea why you mentioned boot partition being larger than the kernel. Are you implying something?
[Android Software Development] Vagelis1608:
In your previous post you mentioned the boot partition size.
[Android Software Development] osm0sis:
Say hello to ChromeOS support! Also, there are a number of fixes I've made to unpackbootimg and mkbootfs for better rooted Pixel support, as well as adding support for more Sony ELF devices to unpackelf. The magic for Bump and SEAndroid Enforce footers are now detected and appended again on repack. Lastly, I'm now building my own lz4 binary for Cygwin so it's finally up to date with the other platforms and I can clean up the workarounds I had in place for the antique one. ;)

In the ongoing saga of the file binary, a fix for my linker issue was added to 5.30, but it seems they've altered some logic so now "search" in the magic file isn't working as expected, so we'll have to stick with 5.29-git for now until I can investigate further.

Flashlt v2.6 is available over in my Odds and Ends thread as well in case anyone missed it. It has some nice fixes adding Pixel and basic Magisk install support!

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.6:

- always export and write second_offset, reordering output slightly

- add a bit more error catching for the new imgtype detection

- add ChromeOS header detection and use futility with test-keys + arm arch (per Chainfire) to sign repacked image

- update lz4 binary (1.7.5)

- update slimmed magic file (from file 5.30) with my own fixes

- add Samsung SEAndroid and LG Bump footer detection and write support

- update unpackbootimg, mkbootfs and unpackelf binaries from my repos

- update to the latest Cygwin binaries and libraries (dropping Windows XP support)

- add Intel OS header detection to avoid false positives when also containing "ANDROID!"

AIK-mobile v2.6 + AIK-Linux v2.6:

- fix basic Magisk support (add module.prop) (AIK-mobile)

- fix pathless execution in current directory

- add ChromeOS header detection and use futility with test-keys + arm arch (per Chainfire) to sign repacked image

- always export and write second_offset, reordering output slightly

- add a bit more error catching for the new imgtype detection

- update slimmed magic file (from file 5.30) with my own fixes

- add Samsung SEAndroid and LG Bump footer detection and write support

- update unpackbootimg, mkbootfs and unpackelf binaries from my repos

- add Intel OS header detection to avoid false positives when also containing "ANDROID!"

- fix aik --restore with Magisk (AIK-mobile)

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

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.
[Android Software Development] osm0sis:
Fixed and reuploaded. :silly: Thanks! :highfive:

Edit: And before anyone notices.. I reuploaded again with the correct version number in the Magisk module.prop (I had 2.5). :p
[Android Software Development] dr.bathman:
Is this working in twrp 3.1?
[Android Software Development] Midomad:
Yes.
[Android Software Development] dr.bathman:
I tried to change splash screen of twrp 3.1 after flashing this.. but it was not creating any img file.. any solution?
[Android Software Development] BelzIgoh:
Yes
[Android Software Development] Midomad:
Dunno,works fine.
[Android Software Development] ahmed.ismael:
works fine for me ( htc 0ne m8 )

put the stock twrp.img in your internal storage and do it again
[Android Software Development] harsh.:
[MENTION=4544860]osm0sis[/MENTION]

My device don't have internal storage for files.

It can only store apps.(Android one 1st gen) sprout4 device. What can i do? Should i use twrp's file manager to place img in internal storage.? :eek: bit confused
[Android Software Development] osm0sis:
AIK is in /data/local so it should be installed fine, and the location of the image file to be unpacked shouldn't technically matter, since it's all done within the AIK directory.

If you're asking about an issue with the TWRP Materialized theme using AIK to repack then you need to bring it up with [MENTION=2719389]z31s1g[/MENTION]. Maybe he can automate it further by copying the file into the AIK directory first, or copy it to /tmp first and unpack from there.

Edit: Looks like he already copies the files into the AIK working directory, so that's not the issue. :good:
[Android Software Development] harsh.:
It says img is repacking but when i try to flash it, it ends with error :1

.img file that is created​ is empty. File size is 0. :rolleyes:

I hope any of the following helps.
[Android Software Development] dr.bathman:
That's worked in lenovo vibe k5.. Thanks :)
[Android Software Development] osm0sis:
Well it unpacks okay according to the log, but this doesn't look good:

unzip: write error: No space left on device

Does your device have a /cache partition? That seems to be where the Materialized theme is attempting to unzip the theme.. but again this is out of the scope of this thread since my half of things (AIK-mobile) seems to be functioning correctly.

You'll have to report it or continue troubleshooting it in [MENTION=2719389]z31s1g[/MENTION]'s theme thread and maybe he can figure something out for the next version.
[Android Software Development] avinashrocks1990:
no not working tested on Haida(neo v) with nAa 3.4.45 kernel

my anzu is out of order

but if i remember properly it was working with nAa 3.0.8 kernel on anzu

i know the two kernel are totally different but both of them use lzop compression
[Android Software Development] osm0sis:
Huh, well same kernel and device tajimura is having trouble with (haida), and I recall you saying it worked on your other device (anzu) as well, so I guess it's just some complexity of nAa's lzop packaging for haida that's causing trouble.. Thanks for helping me look into it. No ideas at this point but it's all good info.