yashsingh1/xdaforums huggingface dataset:
[Android Software Development] osm0sis:
The AIK-Mobile one runs from the command-line on the N7 and any other ARM device (I use it on my GN as well). The new AIK-Linux one is similarly for desktop Linux's command-line. I'll probably load up a virtual machine tomorrow to test if no Linux users volunteer first. :good:
[Android Software Development] HolyAngel:
This is the only thing I've been able to use repack the boot images for HTC One M8, works absolutely perfectly! Thank you very much for the hard work! ^^
[Android Software Development] talich:
Hi. Could I check you AI kitchen under linux? I've checked the repacked boot.img & recovery.img under Win7x64 on my K910S before. it's working fine, thanx for the hard work.

HolyAngel

There is another new tool for repacking boot & recovery on the net from And_pda. It works fine like the AIK did.
[Android Software Development] osm0sis:
Please don't advertise other tools in my thread.. :rolleyes::(
[Android Software Development] EnerJon:
Brother, why don't you add MTK boot/recovery.img unpacking repacking support in this amazing tool?

---------- Post added at 10:08 AM ---------- Previous post was at 10:07 AM ----------

This way we can have all in one tool :)
[Android Software Development] osm0sis:
I appreciate the love, but my tool deals with images that follow the Android image standard. MTK chose not to follow it for whatever reason..

Info/links are available via the OP to a good simple MTK repack tool by [MENTION=455439]bgcngm[/MENTION].
[Android Software Development] EnerJon:
Yes i know about that tool, and another windows tool... But i wanted to have a all in one tool :) and your tool is very well coded :)
[Android Software Development] kin912:
Works very well,thanks!:good:
[Android Software Development] osm0sis:
New versions of the Mobile and Linux Editions up in the OP. :D

AIK-mobile v1.1:

- Updated to a newer (and smaller!) busybox (1.21.1) binary, compiled by Google for their Glass XE16 Factory Image.

- Updated file (5.18), xz (5.0.5) and lz4 (r116) to their latest versions.

- Also rebuilt my slimmed magic file from the latest source (5.18), adding Android magics to hopefully provide some more info if an image fails due to format differences.

- Fix to "nothing to repack" detection, avoiding a minor error (that was hidden by the screen clear anyway).

AIK-Linux v1.1:

- Updated magic file and lz4 as above.

Updated binary authors/credits lists in the AIK-mobile and AIK-Linux initial release notes. View for install notes and details on each edition.

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] somboons:
Can support LG G2 D802?
[Android Software Development] osm0sis:
The LG G2 is mentioned in the OPs as requiring the Loki workaround (thanks [MENTION=2471504]jeboo[/MENTION]), if you're using the Windows version. There is no required Loki workaround for Mobile or Linux because that's what the Loki tools/binaries available in the linked information threads were originally compiled for, so that should be covered. :good:
[Android Software Development] somboons:
Thank you for quick reply.

I will testing torrow.Can you unpack/repack other img such as cust.img modem.img of LG?
[Android Software Development] osm0sis:
The only images with ramdisks that I know of are kernel (boot.img) and recovery (recovery.img).
[Android Software Development] -CALIBAN666-:
what about zimage files?i have kernel for lg optimus l5 which is packed as flashable zimage and i need the ramdisk from it,so my question is,how can i extract it using windows and is this possible with windows?
[Android Software Development] osm0sis:
A zImage is only the compiled kernel source. No ramdisk there. :confused:
[Android Software Development] -CALIBAN666-:
hahaa,so sorry my thinking was total wrong,lol
[Android Software Development] DexedrineXR:
Found an error in your "repackimg.sh". Line 21 was:

if [ ! -z "$(ls split_img/* 2> /dev/null)" ]; then
echo "No files found to be packed/built.";
abort;
return 1;
fi;

Should be (correct me if I'm wrong, it's late at night and I'm about to go to bed)

if [ ! -z ./split_img/* ]; then
echo "No files found to be packed/built.";
abort;
return 1;
fi;

I always use the mobile tools... I really like your work. :)

EDIT EDIT EDIT:

It would have helped if I noticed in line 21 the space was in the wrong spot... Meh, I'm SO tired right now... "2> /dev/null" should be "2 >/dev/null". Both ways work though....

Anywho, I guess just ONE extra space screws up everything. My mind is officially tired... LOL I debugged that script on my phone, not a good idea.
[Android Software Development] osm0sis:
I originally had ! -f split_img/* which worked, but caused a minor error once there actually were files there! :eek:

So I switched to this more complex, ugly version of the same idea, which appears to work flawlessly. ;) :)

The ./ isn't necessary for a relative path when not executing something and the scripts always go local with a cd "$PWD" at the beginning anyway. :good:

Don't think the spacing appears to matter with funneling the stderr to null either, but definitely thanks for the help (always great to have a fresh set of eyes take a look) and great to hear people are liking the mobile version. :D
[Android Software Development] kgp700:
Is this working for Galaxy S4 LTE-A ? (GT-i9506 or SHV-E330S)

Is this working for Galaxy S4 LTE-A ? (GT-i9506 or SHV-E330S)
[Android Software Development] osm0sis:
Try and see? :)

[MENTION=5291228]DexedrineXR[/MENTION]: Gah! I took another look today and it turns out what I uploaded for AIK-mobile contained a typo I had fixed in my local version; ! -z instead of -z. So you were totally right about the logic being broken there. :eek:

I guess you and I are the only 2 using them and everyone else is just downloading them to look at? :p
[Android Software Development] manan001:
unable unpack my samsung galaxy grand2 duos SM-G7102 recovery.img file..
[Android Software Development] kgp700:
I just tried unpack/repack Korean galaxy s4 LTE-A (SHV-E330S) boot.img on windows

It seems to be working...

no problem at unpack/repack :)

but not yet tested about actually working that boot.img
[Android Software Development] osm0sis:
Link to the file if you want help please. I don't have time to hunt down images for every random device people post about. :p
[Android Software Development] osm0sis:
Found a few more issues with the current versions, so new Mobile and Linux Editions are up in the OP. :) :good:

AIK-mobile v1.2 + AIK-Linux v1.2:

- Fix detection and bailing with unknown compression/data.

- Fix "No files found" incorrectly displaying on repack (typo introduced in v1.1). (AIK-mobile)

- Extend "No files found" to cover both split_img and ramdisk directories.

- Fix magic file for xz and lzma support (broken by new magic file in v1.1).

- Fix unpacking on systems without busybox; use included binary's basename applet. (AIK-mobile)

Installation information and details on each edition can be found in 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] tdhite:
Do we have a static linked version of this for ARM (want to run it in recovery)? If not, I'll build it, so just wondering.
[Android Software Development] osm0sis:
The binaries will run in recovery as long as /system is mounted, I use it in my updated AnyKernel2 zip template:

http://v.ht/AK2-

I thought it was just some oddity with running them from /tmp but now that you mention it, it might be the linking. Do you think that's it?

If that isn't good enough or doesn't work on your device then yeah feel free. :)
[Android Software Development] :
Get the FREAK OUT OF HERE!!!! You mean to tell me that I have spent the last THREE DAYS writing scripts only to fail getting my unmkbootimg binary to work in /tmp/sbin all because the system ISN'T MOUNTED!?!?!?!

I'm about to try that now and see if it fixes this. It's the only ISSUE I have.

Edit: that actually worked, but getting a segmentation fault so most likely my binary is faulty. :P
[Android Software Development] :
Well, I'm for sure my binaries aren't bad. I used yours [MENTION=4544860]osm0sis[/MENTION] and got the segmentation fault also.... Just cant point my finger on the problem.

More work for me :)

This is what I am working with write now. It's a draft until I get it working and then I plan to do some cleaning afterwards.

#!/sbin/sh
#
# This script has two optional parameters:
#

base_dir=/tmp;
base2=/tmp/sbin/unmkbootimg;

#
# Check for strange boot.img header
#

check_header=`$base_dir/busybox od -A n -h -j 0 -N 8 $base_dir/boot.img | sed 's/ //g'`

if [ "$check_header" != "4e415244494f2144" ]
then

echo
echo "Android 'magic' header not found at start of boot.img"
echo "Checking if it exists elsewhere ..."

# Mac OS X adds extra spaces between the numbers!
hex_offset=`$base_dir/busybox od -x -A x $base_dir/boot.img | grep -m 1 "4e41 [ ]*5244 [ ]*494f [ ]*2144" | sed -e 's/ .*//'`

if [ "$hex_offset" != "" ]
then

#
# Remove leading bytes before the Android header
#

dec_offset=`printf "%d" 0x$hex_offset`
echo "Android header found at offset $dec_offset"
echo "Removing extra stuff before it so boot.img can be read properly ..."

dd if=$base_dir/boot.img of=$base_dir/modboot.img bs=1 skip=$dec_offset
rm -f $base_dir/boot.img
mv $base_dir/modboot.img $base_dir/newboot.img
echo

dump_boot() {
cd $base_dir;
$base2 -i $base_dir/newboot.img >> $base_dir/repackbootimg.txt;
rm $base_dir/kernel;
mv $base_dir/zImage $base_dir/kernel;
}

prep_boot() {
echo \#!/sbin/sh > $base_dir/createnewboot.sh;
sed -n 5,10p $base_dir/repackbootimg.txt >> $base_dir/createnewboot.sh;
chmod 777 $base_dir/createnewboot.sh;
sh $base_dir/createnewboot.sh;
}

dump_boot;
prep_boot;
return $?
exit 0

else
echo "Warning: Android header not found in boot.img (unsupported format)"
return $?
exit 1
fi
fi

mv $base_dir/boot.img $base_dir/newboot.img
rm -f $base_dir/boot.img

dump_boot() {
cd $base_dir;
$base2 -i $base_dir/newboot.img >> $base_dir/repackbootimg.txt;
rm $base_dir/kernel;
mv $base_dir/zImage $base_dir/kernel;
}

prep_boot() {
echo \#!/sbin/sh > $base_dir/createnewboot.sh;
sed -n 5,10p $base_dir/repackbootimg.txt >> $base_dir/createnewboot.sh;
chmod 777 $base_dir/createnewboot.sh;
sh $base_dir/createnewboot.sh;
}

dump_boot;
prep_boot;
return $?
exit 0
[Android Software Development] osm0sis:
Hmm interesting, [MENTION=4615478]boype[/MENTION] reported seg faults too (with my AnyKernel2) but I was never able to reproduce the issue. :confused:

Only time I've ever seen unpackbootimg do that is when the output directory doesn't already exist. So I just create it first and everything worked fine.
[Android Software Development] :
Yea, maybe that is the problem and I'm not seeing this in my scripts. I wrote a script to use my unmkbootimg binary and push the results to a text file, then I use sed to pull the strings from that text in order to build with mkbootimg, but the unmkbootimg binary reports back with segmentation fault so my other scripts fail obviously due to that.

I then decided to rewrite the script just slightly in order to use your unpackbootimg binary and the same problem arises.

But you may be right, because this morning I got it to work and when it did I went to make some additional changes and next thing I know it stopped working again lol. Been fighting to fix this all day....
[Android Software Development] ShinySide:
Galaxy Tab 4 7 inch wifi model

Ive tried every tool out there and nothing works for unpacking .img files from its firmware. And nothing except AIK gives an out put of any kind. So figured your thread was the best place to bring up this issue since your tool is the only thats given me an actually output of an error or any output in the terminal really.

When trying to unpack the Tab 4s boot.img I get this error in the out put

http://hastebin.com/ejaziqajab.md

Im guessing tools need to be updated or edited to successfully unpack it, unfortunately is out of my abilities so maybe you can help?

Any help would be appreciated Thanks
[Android Software Development] osm0sis:
The pagesize and dtsize are insane. Not sure about the tags offset, but it doesn't look good for support.

Per usual, post the actual boot image for me somewhere and I'll try and figure out why. :)
[Android Software Development] ShinySide:
Oops I meant to attach it to my first post Haha My bad.

Yeah Ive tried just about every option Ive been able to find out there and AIK is the the only to display any of that info. Same thing happens to when trying to unpack the recovery img so the attached zip contains both the boot.img and recovery.img incase of any use to you.

Whether good or bad outcome, Thanks for looking into it.
[Android Software Development] DualJoe:
I'm trying to unpack this image. It just unpacks 3 libs from '/lib/modules' though. I expected the whole ramdisk with all init scripts and such. What's wrong here?
[Android Software Development] osm0sis:
Seems to be all there is in the standard ramdisk. You'll have to ask DerTeufel where he's hiding everything else. Possibly has them in decompress from the zImage or something crazy. ;)
[Android Software Development] DualJoe:
Its actually xz (lzma) compressed. Haven't found an automation script yet though. This is what i've reversed so far:

- Image is xz/lzma compressed.

- Split with 'unpackbootimg'.

- Magic bytes (start) '0x5D0000' in 'boot.img-zImage'.

- dd if=boot.img-zImage bs=1 skip=`grep -P -a -b -m 1 --only-matching $'\x5D\x\0\0\x\0\0' boot.img-zImage | cut -f 1 -d :` | lzcat > kernel.img

(end pos not yet resolved -> throws error at the end atm). An alternative to 'lzcat' is 'lzma'.

- Uncompressed image holds multiple cpio images (start=0x070701, stop=TRAILER!!!)
[Android Software Development] :
OMG

osm0sis, you effin rock

i JUST found this thread yesterday

i have a samsung galaxy tab 3 10.1 gt-p5210 x86

i got aik set up and with the exception of changing the script

to point at /system/xbin/busybox [x86] i'm good

thank you :good:
[Android Software Development] antutu:
[MENTION=4544860]osm0sis[/MENTION] You should added samsung galaxy tab2 7", aik workings great on my p3100

Now i can modify [MENTION=4021423]ketut.kumajaya[/MENTION] next kernel anywhere

Thanks :good:
[Android Software Development] osm0sis:
I'm amazed the other binaries still work as expected on x86. Good to know! :D
[Android Software Development] :
yeah man

everything is good, i went throught the process a poop load of time tinkering with recovery.img

so you can add p5210 to the list. remember busybox x86

:good:

hey, while i have your ear, i was wondering do have any static binaries, specifically cp,file,wget ?

if so could you hook me up?
[Android Software Development] E:V:A:
[MENTION=4544860]osm0sis[/MENTION]: I'm trying to understand what version of the ARM binaries you have included, but I don't find this info. Could you opdate OP to show what versions you're using. Thanks.
[Android Software Development] osm0sis:
What do you mean by versions? ARM version or binary version?
[Android Software Development] E:V:A:
For example, the latest "file" utility is version 5.18. And so are most of the other sources on which those binaries are based upon. I know that the Android sources are usually crippled from displaying version info, but it should be there... Sometimes its also know as the "revision" (e.g. lz4).
[Android Software Development] adeelraj:
I am getting this error on aik mobile 1.2

Device is sky vega a850k

Jellybean 4.1 boot.img

Plz help
[Android Software Development] osm0sis:
Ah gotcha. :)

lz4 r116

file 5.18

busybox 1.21.1

xz 5.05

As far as I know there aren't versions for mkbootfs, mkbootimg or unpackbootimg, but they're all current as of last month. :)
[Android Software Development] osm0sis:
Looks like a dynamic linking issue. Damn, I was hoping I wouldn't need to statically link for booted Android.. ;)

Try replacing the binaries in /data/local/AIK-mobile/bin/ with the static compiles from my AnyKernel2 package: http://v.ht/AK2-

Let me know how it goes. :)
[Android Software Development] adeelraj:
I have replaced makeboot and unpack files with the anykernel 2 tools/makeboot and unpack

But still same error occures.
[Android Software Development] osm0sis:
Paste me the output of this:

echo "Device Info: `getprop ro.product.manufacturer` `getprop ro.product.model` (`getprop ro.product.board` `getprop ro.product.device`)";
echo "Architecture: `getprop ro.product.cpu.abi` - Android SDK: `getprop ro.build.version.sdk`";
[Android Software Development] adeelraj:
Actually my device is sky vega a850k but using ported rom of a870k
[Android Software Development] osm0sis:
[MENTION=4300198]adeelraj[/MENTION] Hmm okay so I'm thinking the main binaries should be okay, especially considering they even work on x86. You have busybox installed? Make sure you do. Then try changing the bb= in the scripts to /system/xbin/busybox

Let me know if that works. I probably need to find a better (static) busybox binary to include, and throw in one for x86 for [MENTION=4938788]antutu[/MENTION] while I'm at it.
[Android Software Development] adeelraj:
After changing busybox with the 1.22.1 version in bin folder

I have successfully unpacked the boot.img

But in ramdisk folder sys folder is empty
[Android Software Development] osm0sis:
Check your PMs please. ;)

And that's normal. sys is just a placeholder for the sysfs mount point. So it, data, system, dev, etc. should be empty. Looks like it unpacks fine now, judging by the screenshot. :good:
[Android Software Development] adeelraj:
So how can i alter the ramdisk
[Android Software Development] osm0sis:
Everything it unpacked to the ramdisk directory is the ramdisk. Alter it how you like. :)

Respond to my PM to you please. :good:
[Android Software Development] adeelraj:
So if i want to add a patch or module to the kernel what things should i do plz guide.
[Android Software Development] osm0sis:
You can't patch the kernel. The kernel source is compiled in the zImage. You can only edit the ramdisk.
[Android Software Development] adeelraj:
Which things i can edit and what are the benefits of editing ramdisk
[Android Software Development] osm0sis:
Change your bootsplash (if your device has one), apply any sysfs tweaks you want to .rc files, start services to add init.d or call .sh files to do more complicated tweaks.

If you couldn't look that up, I'm not entirely sure you should be messing with this stuff though..
[Android Software Development] Gold_Phenix:
Sorry . Wrong topic :(

Wysłane z mojego LT26i przy użyciu Tapatalka
[Android Software Development] :
things to do

experiment for starters,

alter services , redirect/hijack your boot process,

here's a neat one rename init.rc to initb.rc the create a blank init.rc to call up other stuff [.sh scripts do many things]

just remember to put import/initb.rc in your new init rc, like i said, experiment, have fun, learn stuff, contribute

take over the world, muahahahaha :D

---------- Post added at 07:05 AM ---------- Previous post was at 07:01 AM ----------

i was looking at diif logs kmsg dmsg etc and i'm thinkin if you add a logo.rle whether it was there in the first place

it might override the one in parameter block, [i have to check location again]

anyway :good:
[Android Software Development] :
Hahahahaha, epic!

---------- Post added at 05:36 PM ---------- Previous post was at 05:34 PM ----------

Could also add init.d support in your init.rc file of your ramdisk. Then handle the rest on your device. Using scripts with init.d support can take you VERY FAR with tweaking your device :D
[Android Software Development] hell_lock:
Hey I want to change the zImage of the boot.img. Can you tell me where it is unpacked to? I'm using the win32 version.
[Android Software Development] Captain_Throwback:
The /split_img folder, named "boot.img-zImage."
[Android Software Development] adeelraj:
how will u change zimage

can i add other kernel zimage
[Android Software Development] :
Just unpack your boot.img and swap out the old kernel with your new kernel, but I must WARN you that if the new kernel has a modified build version then there may be complications between your new kernel and your devices current kernel modules.

You will need to swap out your old modules with this kernels new modules in such a case...

UNLESS, this kernel you are wanting to use is properly built without module support, thus allowing the kernel to use whatever current modules there are on your device.

Otherwise, you may run into some issues. One common issue resulting in your WiFi breaking :).
[Android Software Development] hell_lock:
I have noticed that the compression ratio with this tool is very small. A kernel compressed using this tool packs to 10mb whereas a kernel compressed using standard kitchen is of 8.7 mb. By kernel I obviously mean the boot.img here..
[Android Software Development] anagramgenius:
standard kitchen? championswimmer's?
[Android Software Development] osm0sis:
Probably. :rolleyes: ;)

There's no way to read the compression level used or I'd mimic it exactly, so for compatibility reasons I go with middle-of-the-road standard. Some devices can't handle higher levels of compression, for example. :)
[Android Software Development] anagramgenius:
ah! it never worked for me either in ubuntu or cygwin. your tool works fine.
[Android Software Development] Davy Bartoloni:
i've some issues on Mediatek recovery.img... when i extract the img.. for example: ( w ww .wcn.it/recovery.zip )

i receive this error (on windows) :

Splitting image to "/split_img/" . . .

BOARD_KERNEL_CMDLINE

BOARD_KERNEL_BASE 10000000

BOARD_PAGE_SIZE 2048

BOARD_KERNEL_OFFSET 00008000

BOARD_RAMDISK_OFFSET 01000000

BOARD_TAGS_OFFSET 00000100

Unpacking ramdisk to "/ramdisk/" . . .

Compression used: data

Error!
[Android Software Development] osm0sis:
Read the 2nd post in the thread where I state Mediatek devices aren't supported because they don't follow the standards. I link to my post explaining why, which also has a link to a MTK specific tool package you can use instead. :good:
[Android Software Development] superuser.pm:
i try unpack/re-pack file recovery TWRP.img . i can flash it for my nexus 7?

need relock file new_image.img before i flash it ?

how to relock file new-image ?
[Android Software Development] osm0sis:
Huh? Reloki? N7 doesn't require lokifying. If you had to unloki it to edit it then I think you downloaded TWRP for the wrong device.