yashsingh1/xdaforums huggingface dataset:
[Android Software Development] osm0sis:
What about `repackimg --original` ? Does the AIK repacked image boot after that?
[Android Software Development] xinulhacker:
No. Still hangs.

What other options flags are available in AIK? I will experiment with them.
[Android Software Development] osm0sis:
Interesting. I'll take a look when I have some time and see if I can figure out what alignment refers to... In the middle of setting my laptop up again after RMAing for the faulty SSD, and lost all of my dev setup, so will likely be awhile.
[Android Software Development] xinulhacker:
No problem. Thanks for taking the time to look into it.

I'm very appreciative. Sorry to hear you lost your setup! That sux.

I'll ask exactly what he means by alignment.

Thanks again.
[Android Software Development] xinulhacker:
Here are the Rockchip images that I unpack and repack without changing anything (with AIK mobile) and the boot hangs for some reason.

According to the person helping, he is using an imagerepacker option on windows to "align" the Rockchip images.

I'm still not certain what that means.

I'm guessing Rockchip image suites repack in some special way... (The images repacked with his tool are above.)

Thanks for your time and help.
[Android Software Development] xinulhacker:
A quote from him--

I use this repack option as parameter for imgrepackerrk program, I have no source of this program, only binary exe file, don't know exactly what alignment is taking place.
[Android Software Development] osm0sis:
Maybe he means "signing" when he says "aligning" 🤔

Please note the "Nibiru V05-A" Rockchip RK device listed as Not Supported in the OPs and follow the link, very likely that your device falls in this category.

You can find the closed-source imgrepackerrk tool by reading through the relevant thread posts I linked as well, but I have no plans to include it in AIK while it remains closed source and there's no documentation of what the different chipset variants require or how anything's calculated and patched.

Edit: I see you've posted on the imgrepackerrk thread, so I'm not sure why you're here acting like you've never heard of it... 🤨

What device are you using? I'll add it to the unsupported list.
[Android Software Development] xinulhacker:
Yes. Maybe he means signing.... Idk.

As for this device, it's a Pipo Max. Old device.

I actually didn't even realize I was "watching" imagepackerrk. Apparently I responded to a post saying to use Android Image Kitchen. Ha! Promotional fees not necessary.

Thanks for your help. I'll continue to research.
[Android Software Development] fbalder18:
I have a problem unpacking and repacking a recovery for Poco X3 Pro (vayu) installed firmware fw_vayu_miui_VAYUGlobal_V13.0.5.0.SJUMIXM and crDroidAndroid-12.1-20220818-vayu-v8.8 (now ota-updated to 20220828). The official TWRP 3.6.2 is maintained by Nebrassy, but he also has a development version for A12 that supports decryption (TWRP-3.6.2-vayu-Nebrassy-03-07-22.img), thats the one I use and it works fine. But I would like to modify twrp.flags so that the internal storage can be backed up.

I use Ubuntu 20.04 virtual machine because the recovery has files with matching names differing in upper/lowercase. AIK is 3.8. After unpack and repack without modifying anything there is the strange behaviour that the recovery startet with

fastboot boot image-new.img

boots fine, but after flashing it with

fastboot flash recovery image-new.img

the recovery doesn't start but falls back to bootloader (fastboot screen). Also the system can't be booted any more and also falls back to bootloader. Only way to use the system again is to flash Nebrassy's img, fastboot into that recovery and boot to system from there. Then everything is fine. But no backup of internal storage...

Downgrading cpio to 2.12 didn't solve the problem.

Does anyone has an idea whats going wrong?
[Android Software Development] joenka:
When execute ./mboot boot.img.lz4

board : SRPTL16A001

kernel : kernel

ramdisk : ramdisk

page size : 2048

kernel size : 15492534

ramdisk size : 1475623

dtb size : 2

base : 0x40078000

kernel offset : 0x00008000

ramdisk offset : 0x11a88000

tags offset : 0x07808000

dtb img : dt.img

cmd line : bootopt=64S3,32N2,64N2 androidboot.tag=TabA7lite_Huaqin_BSP_20210408174009 loop.max_part=7

ramdisk is unknown format,can't unpack ramdisk

Unpack completed.
[Android Software Development] osm0sis:
Why would you think that would work? mboot isn't for boot.img.lz4. That's not even the output from mboot. RTFM please.
[Android Software Development] joenka:
Thank you for your answer. It works, befor un-lz4 boot.img.lz4 and after mboot unpack.

I' ll withdraw the question.
[Android Software Development] HassanMirza01:
any update for supporting header version 4? for now using magiskboot to unpack repack imgs with ver 4 but this tool is more good instead of magiskboot,

Thanks for this awesome work @osm0sis
[Android Software Development] fbalder18:
I solved the problem. After un-/repackimg I added an AVBv2 signature using avbtool. Now also the flashed recovery image boots fine. It looks like the Poco X3 Pro bootloader only accepts signed images.
[Android Software Development] HassanMirza01:
bro, am having same issue now in new roms, they dont boot recovery until booted from fastboot, seems like xiaomi updated bootloader for all devices, can u explain how you added signature using avbtool?
[Android Software Development] fbalder18:
You need Python (I think it will work on both Windows and Linux) and the Python script avbtool.py, e.g. from here. Then you call the script with

avbtool.py add_hash_footer --image image-new.img --partition_size 134217728 --partition_name recovery

This will extend the image and add avb with the builtin default signature.

I also found a zip with avbtool for arm64 here. It should work on the mobilephone, it has the python interpreter included. But I didn't try it, I used my notebook where I had python anyhow.
[Android Software Development] fbalder18:
@osm0sis

Probably you could add avbtool.py to the next release of Android Image Kitchen? And a minimum Python interpreter to the Windows and Android variant?

EDIT

It doesn't make sense to add Python to the Windows variant. avbtool.py only allows a subset of arguments (e.g. info_image) there. With add_hash_footer there is the error missing dev/urandom. But probably in the faq WSL could be mentioned.

EDIT 2

avbtool can also be used on Windows, so the interpreter could be included also on that variant. One has to use the additional parameter salt, e.g.

avbtool.py add_hash_footer --image image-new.img --partition_size 134217728 --partition_name recovery --salt 00000000
[Android Software Development] osm0sis:
Yeah it's my plan to add avbtool and have a Windows/Linux/Mac Python install be a prerequisite like we do for Java. Then on Android we'll rely on QPython.
[Android Software Development] Korylek1231:
@osm0sis Hi!

Today i tried to get ramdisk files from my boot.img, even if i haven't got any errors my ramdisk folder is empty! Any Ideas? Phone - Nokia 2720 Flip KaiOS version: 2.5.2.2. Unpacked with WinRar, antivirus disabled, boot.img in AIK folder, Windows 10
[Android Software Development] osm0sis:
Does it warn you that it's empty? Probably totally as expected. Not every Android boot.img contains a ramdisk, e.g. legacy system-as-root (SAR).
[Android Software Development] Korylek1231:
Thanks for the answer, no it doesn't

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

Supplied image: boot.img

Setting up work folders . . .

Thats all i got
[Android Software Development] osm0sis:
Where's the rest of the log? Why haven't you uploaded the boot.img?
[Android Software Development] dogansan:
Hi @osm0sis , I have a Xperia Z5 dual rooted , running with a mod Nougat 7.1.1 kernel and boot.img with drmfix. And I have rooted it with Magisk 25.2. After using a couple of tools to replace my very bright white splash logo and failing in all attempts , I reached your thread. I used unpackimg , replaced original logo.rle with attached one , repacked it and obtained image-new.img. Then copied it to sdcard, shutdown, opened recovery TWRP and flashed image-new.img. It flashed successfully without any error. Then I rebooted , but it still opens with original logo. Any help is vey much appreaciated. I am sorry, if my explanations are not accurate, I am learning yet
[Android Software Development] AnonVendetta:
@osm0sis: Can you modify your AIK Mobile so it completely removes itself after being uninstalled? When removing the mod from Magisk Manager, it still leaves /data/local/AIK-mobile directory and its' contents. No images were present at the time of uninstallation, and nothing had been unpacked/repacked at that time.

It's not a big deal to delete it myself, but to me the whole point of a Magisk module is that it "takes out its' trash" when no longer needed.
[Android Software Development] osm0sis:
It works the other way. If you aik --uninstall it'll take out the helper module with it.
[Android Software Development] AnonVendetta:
I just figured that uninstalling it from Magisk should be enough to make it clean itself up.
[Android Software Development] osm0sis:
In my mind it's just the helper module in Magisk, not AIK itself.
[Android Software Development] AnonVendetta:
Alot of Magisk modules have an uninstall.sh script. Apparently yours doesn't. It wouldn't be very hard to add something to it like:

rm -r -f /data/local/AIK-mobile

And then have Magisk parse and run that script when uninstall is initiated.
[Android Software Development] osm0sis:
Oh, I know. I've also considered having the helper module have logic to remove itself if AIK gets removed from /data/local. But again, AIK is not a Magisk module, only the helper module which allows running the "aik" helper command from anywhere is. AIK doesn't require Magisk at all and can be run from recovery even.
[Android Software Development] Ardany Jolón:
Can you help me sir? I need that too.
[Android Software Development] dogansan:
Hi, any help would be possible ?
[Android Software Development] osm0sis:
I have never worked with logo.rle before. Are you sure you converted your new image to rle correctly? Otherwise no clue.
[Android Software Development] dogansan:
I am assuming that I have done png to rle conversion, then inserting into ramdisk and creating boot.img correct. Because when I do the reverse process of extracting image-new.img created by your tool in kernel-tools kit , getting logo.rle and then converting to png , I see the correct picture. But, of course , there are small changes in the size of the final png file. I am not sure if the png to rle conversion should have exactly same size and byte or otherwise, it will be discarded and an original backup picture(whie Sony Xperia) will be used. I also have taken of backup of boot.img gtom mmcblk0p29 and have seen that it contains new picture. But for some reason, it still displays original splash picture. There was an old discussion on this saying "anyway when you find the file you will be interested in rle2png converter but before flashing / adding file ensure the converter is converting properly by converting original file to png and back to rle then hex compare results (on my lg android device first 4 bytes of file are size in big-endian) if the file is not same then do not use the new created file". I don't know if this is true for Z5 running on Nougat
[Android Software Development] jpzex:
Probably you bootlogo is flashed on a separate partition. Motorola does this, maybe yours does too. Check at /dev/block/bootdevice/by-name if there is something related to logo. Cheers
[Android Software Development] dogansan:
Hi, I checked /dev/block/bootdevice/by-name folder, there are many very small size files including boot (/dev/block/mmcblkop29) . I know that boot.img is stored in this memory location but I don't know what to do.
[Android Software Development] DuskGolem:
@osm0sis

Hello mate, hope you are doing well. I am working on reviving the famous TWRP Materialised theme by z31s1g and i was looking at the code snippet for the AIK in the xml file. Although the official support is for v3.1 according to TWRP Materialised thread, I tried the theme using the latest AIK V3.8 and it worked without a hitch. My setup details are;

Device: Samsung Galaxy A8 2018

Android Version: Pie 9.0 (Stock Rom)

TWRP Version: v3.2.3 (Used for the sake of theme testing, no errors in recovery log)

TWRP Materialised Version: Latest available v321X

AIK Mobile Version: v3.8

Fla****: Latest Installed but not used for this test

Operation Performed: ADAPT SPLASH

Now, the code used in the theme for AIK v3.1 (by G.M.L) is HERE and your latest iteration is HERE. According to your post, the code is not suitable for android 10+ implementation. Also I am confused as to whether the following code is required anymore or not.

echo -e '#/sbin/sh\nshift; sh "$@";' > /sbin/su;
chmod 755 /sbin/su;

Another thing is, in the theme itself, z31s1g had used "busybox ash" instead of "busybox sh" (as you recommended) but it works fine without any errors or lags. Does this mean that you have catered the need to check whether the device is booted or is in recovery mode within the AIK Mobile implementation and if so, should I remove the above mentioned lines or let them be?

I am no developer by any stretch of the imagination, nor do I have any strong grip regarding unix/bash commands. I just recently took interest in twrp theming and decided to work (and hopefully succeed) on reviving this awesome theme. Please, if you have the time, can you kindly look into this? I am willing to test and report with logs as needed.

####################################################################################################

####################################################################################################

####################################################################################################

Now For fla**** (CORRECT ME IF I AM WRONG), since it does not require to be invoked from the android terminal and is placed inside the twrp folder for this theme, all I need is to install your latest fla**** script manually first and then copy the resulting fla****.zip, which is copied to the /sdcard, to the twrp folder for the theme to access it when needed. Is this correct?

Waiting for your reply.

Kind Regards

Adil
[Android Software Development] osm0sis:
Hey! Cool that you're looking into keeping those excellent themes going. Looking forward to seeing your work published. 🙂

First off, the shell situation in TWRP is a bit complex. Back when we worked out those scripts TWRP was only using busybox ash for a shell while the ROM would use mksh/toolbox/toybox, but now any modern device's TWRP uses mksh/toybox, old device TWRPs might still use busybox ash, and new ROMs pretty much only use mksh/toybox.

So where does that leave us for AIK-mobile in recovery requiring mksh? Well, for one, if mksh is the TWRP shell and is located as /system/bin/sh then there's no need to attempt to mount system at all, which is good news since mounting a working system partition sh binary on a current ROM requires getting apex and a bunch of **** mounted first. Then, TWRPs still building on old branches that use busybox ash would use my old script still. Only wrinkle in that would be on twrp-10 branch where mksh/toybox is used but from /sbin/sh and with /system_root mount point, plus apex is already a thing. Too much tech debt to try to upkeep the scripts with apex support for that I'd imagine, so it might just have to remain a gap in support.

Echoing a fake su out to /sbin or /system/bin (wherever TWRP's sh is) would still be necessary I believe.

As for Fla****, yeah, I think that's how z31s1g had it set up.
[Android Software Development] DuskGolem:
@osm0sis Thanks for clarifying. Then I am going to remove AIK and Fla**** for Android 10+ since it will be better for those devices to run these while the OS is booted which makes things easier for me.

1) One question I have is, for android 9.0 there may be some A/B Devices as evident from the android 9 branch of TWRP. Do I have to add this code snippet which, from what I can tell, is checking and picking the active slot?

umount /system;
umount /system_root;
umount /system;
mount -o ro -t auto /system;
slot=$(getprop ro.boot.slot_suffix 2>/dev/null);
test ! "$slot" && slot=$(grep -o 'androidboot.slot_suffix=.*$' /proc/cmdline | cut -d\ -f1 | cut -d= -f2);
if [ ! "$slot" ]; then
slot=$(getprop ro.boot.slot 2>/dev/null);
test ! "$slot" && slot=$(grep -o 'androidboot.slot=.*$' /proc/cmdline | cut -d\ -f1 | cut -d= -f2);
test "$slot" && slot=_$slot;
fi;
test ! "$slot" -o ! -e "/dev/block/bootdevice/by-name/system$slot" && unset slot;

Or should I just use the code in z31s1g's theme as is, which I think has this functionality but does not use a separate "if" condition for it (i may be wrong)?

2) If I use z31s1g's implementation as is, which version of AIK Mobile should I recommend for use within the recovery, v3.1 or v3.8 (which works from what I have tested on my NON A/B galaxy A8 on android pie)?

I will be first porting the theme for android 9 since it is the only device I have at hand and after that will try to implement for Android 10+
[Android Software Development] Stitch777:
Noob question:

wget -O aik-linux-v3-8-all-tar-gz https://xdaforums.com/attachments/aik-linux-v3-8-all-tar-gz.5300923/

tar -xzf aik-linux-v3-8-all-tar-gz

cd AIK-Linux/

wget https://tmpfiles.org/dl/678321/boot.img

./unpackimg.sh --nosudo

Setting up work folders...

Unrecognized format.

Error!

That same image works on Windows, not linux or MacOs (Arm) What am I missing other than google skils

?
[Android Software Development] osm0sis:
I mean, looks like that tmpfiles link is dead.
[Android Software Development] Stitch777:
yeah it is right now, like it was temporary : ) I think the issue might just be ARM no ? works on any other platform
[Android Software Development] osm0sis:
Ohh, yeah, I don't have arm Linux or arm MacOS builds in there.

Android arm binaries could potentially work since they're all static builds, if you want to mess with setting it up manually.
[Android Software Development] alecxs:
Have a question regarding TWRP A/B Installer Backend. I don't have that specific phone but thought it should be possible to apply the installer to boot.img manually with AIK (to help out other member). To my surprise not only ramdisk is replaced, there is also cmd line flag + some hex patches. do you know (in plain text) what it does? or should I try to execute (adapted script) with older (x86) magiskboot on linux? ramdisk-recovery.cpio only needs gzip compression and can be placed (renamed) in split_img as is?
[Android Software Development] osm0sis:
Sounds not really like an AIK question...

Anyway, the TWRP script is documented pretty well.

twrp_abtemplate/META-INF/com/google/android/update-binary at master · osm0sis/twrp_abtemplate

TWRP A/B Installer Zip Template. Contribute to osm0sis/twrp_abtemplate development by creating an account on GitHub.

github.com

Since swapping in TWRP's ramdisk in effect unroots the device, the kernel/cmdline patches from root/kernel installations forcing ramdisk booting on system-as-root would cause a recovery loop if they remained in place, so we revert them.

Ramdisk can be whatever format you want that the kernel supports, only the final filenaming of it is limited by what magiskboot accepts.
[Android Software Development] alecxs:
thx. if these are the reverts, I don't have to apply it to stock boot.img, just unpack with AIK and replace boot.img-ramdisk.cpio.gz then... ;)
[Android Software Development] CXZa:
Found a bug when trying make AIK usable system-wide**...

The cygwin's file.exe causes an error when using "--local" if unpacking an image on a different disk than the AIK is.

Fix: TheGnuWin32 's file seems to work fine...

file for Windows

file {whatisit}

gnuwin32.sourceforge.net

**by adding shortcuts for it to the File Explorer's SendTo Menu.

(A batch file doing it attached to a later post. Run it in AIK's folder.)
[Android Software Development] CXZa:
Same kind of bug seems to be with cpio and case sensitive file names on Windows. If using --local and target image is on a different disk/partition. Mainly affects those terminfo files...

https://xdaforums.com/t/tool-androi...k-win-android-linux-mac.2073775/post-84776319

Some sort of before and after batch maybe needed that does unpacking in the AIK's folder and then copies the files to where wanted. That is, if not wanting to change the script completely...

edit: I'll update the shortcut batch with the above and post it here later...
[Android Software Development] CXZa:
Okay, here is that Send to menu adding batch script. It fixes the problem by making a link to the working dir on a different partition.

Edit: Added some sensitive stuff... :)
[Android Software Development] CXZa:
Tested numerous windows [bsd]cpio programs. None worked or had some other issues.

And the other ways to do it aren't as easy as dir tree that one can just modify...

(though on windows while those terminfo files may unpack, one cannot modify them )

Two interesting ones related programs I stumbled upon while seaching this.

@Renate 's imgutil (edit: she really should add more info how to use it, same goes with other stuff there... bread machine project.. lol want to hear more)

ImgUtil

teplofizik's nyaimagetool

GitHub - teplofizik/nyaimagetool: Linux Images (kernel, rootfs, dtb) edit tool: fit, legacy, raw, compressed

Linux Images (kernel, rootfs, dtb) edit tool: fit, legacy, raw, compressed - teplofizik/nyaimagetool

github.com
[Android Software Development] Noah Allen:
Hi People

I used AIK-Linux to unpack my stock boot.img to edit kernel. After I've successfully unpacked my boot.img, I replace the kernel with my own modified one. And I repacked my boot.img. All went smoothly. But after I got an edited kernel boot.img, there were size differences. My stock boot.img has 64MB, and my own modified kernel boot.img has 29MB. Did I make any mistakes while repacking boot.img?
[Android Software Development] alecxs:
@Keith2122004 this question has asked many times. it's polite to read a thread before posting. Please delete your attachments to avoid pointless bloat. next time use the search button.
[Android Software Development] Noah Allen:
Hello, I'm really sorry for what I did. I searched a lot in everywhere but I didn't get any proper way to solve my issue. May I know any methods that can fix my issue?
[Android Software Development] shoey63:
@Keith2122004

Check post 3, 2nd answer
[Android Software Development] Noah Allen:
Thank You Very Much For Helping Me out
[Android Software Development] ip-drop:
Hi guys!

I'm repacking boot.img, but the ramdisk won't open..I'm interested in the init file, but it's encrypted, how can I open it?

Hi guys!

I'm repacking boot.img, but ramdisk dont opening..
[Android Software Development] alecxs:
see FAQ 5. SAR in post #2
[Android Software Development] osm0sis:
Very similar to FAQ #5, your device is 2-stage-init (2SI) by the looks of it, so there's nothing in the ramdisk except 1st stage files.
[Android Software Development] puturaya20:
Image.gz-dtb gz-dtb not supprt?
[Android Software Development] osm0sis:
Not sure what you mean, the split -kernel file can be Image.lz4, Image.gz or Image.gz-dtb, etc.; you just need to rename it or whatever.
[Android Software Development] puturaya20:
I can't try it
[Android Software Development] TianLong379:
Thanks will try tomorrow