yashsingh1/xdaforums huggingface dataset:
[Android Software Development] greeshan:
You are right about new files and permissions... What i do now and get intresting moment:

1. create empty txt file in "TWRP\ramdisk\sbin" with 0 byte = no problem, twrp is working after repack and size of img 45 744 128 byte.

2. create txt file in "TWRP\ramdisk\sbin" with 1 800 000 byte = no problem, twrp is working after repack and size of img 45 744 128 byte.

3. add file busybox in "TWRP\ramdisk\sbin" with 1 577 040 byte = have problem, get "System corrupted" message when boot to TWRP. But size of img 46 641 152 byte (larged than in step 2).

I can't understand why, if size 1 577 040 byte < 1 800 000 byte and i haven't problem with file from step 2. I think file in step 2 was more compressed than in step 3.

How i can check my new image for repack is normal size or too large? ramdisk + split_img dirs should have smallest size than original img?
[Android Software Development] osm0sis:
This is a twrp image? Does it already have busybox? Must just be something conflicting with twrp I guess.
[Android Software Development] greeshan:
Yes, TWRP. No, haven't busybox.

I have TWRP with busybox and if i just move it to other dir = no problem after repack, but if i add busybox to TWRP without busybox = problem.

Now i work with this TWRP, if i repack it without changes = no problem and boot to TWRP normal, if i add busybox = problem, bootloop. Can you try repack it with adding this busybox and send me? Maybe i do something wrong...
[Android Software Development] osm0sis:
Sounds like you're doing it right, but twrp just doesn't like it being there.
[Android Software Development] greeshan:
One of differents between repacked images with changes and without changes is a size image after repack. I think problem with size...

Now i try repack worked TWRP without changes, but using --origsize flag and TWRP don't boot after this... after repacking without --origsize is ok, no problem.

Maybe someone can give me link to manual or information about unpacking\repacking or build recovery.img?
[Android Software Development] chronolz:
Hi, i am sorry for posting this twice... i used AIK v3.8 to unpack a s21 ultra stock boot.img. the original file is 64mb but both the unpacked and repacked files are only about 29mb. Am i missing something?
[Android Software Development] osm0sis:
If you would search the thread for similar questions you'd know most of the boot partition is empty space.

You should listen to the warning in your output though, and downgrade to cpio 2.12 or your repack might not work.
[Android Software Development] BWRainbow:
Hello!

Sorry for bother you but here I am, trying to port TWRP to Xcover Pro.

When I have to unpackimg, I got this error:

Compression used: tar

Unsupported format.

Error!

I'm using AIK 3.8 and here is the recovery.img.lz4

EDIT: What I did was rename from .img.lz4 to .img

File on MEGA

mega.nz
[Android Software Development] Postman1year:
You can not easy to rename LZ4 to IMG, but I have unpack and repack the right format IMG for your recovery.img.lz4 TO recovery.img, and add AVB hash & AVB 2.0, you can direct use on your phone, please test the file I upload

recovery-XcoverPro.img

drive.google.com
[Android Software Development] Postman1year:
You must add the AVB hash and AVB 2.0 structure to your repacked BOOT.img, and set the size to 64MB, otherwise you can boot to fastboot mode, and boot your repacked BOOT.img to test, not advise to flash boot
[Android Software Development] BWRainbow:
Thank you so much, but I'm afraid that I don't understand it very well. So, this .img is patched now with TWRP? Should I flash it and that's all? BTW, I need access to the file because I can't download it so please, allow me access (or make it public access).

Again, thank you so much.
[Android Software Development] Postman1year:
Yes, sure

you can flash this recovery.img, it is a regular twrp image

recovery-XcoverPro.img

drive.google.com
[Android Software Development] BWRainbow:
Thank you! When I try to flash it on odin (with AP option) it does nothing:

<ID:0/010> Odin engine v(ID:3.1303)..

<ID:0/010> File analysis..

<OSM> All threads completed. (succeed 0 / failed 1)

EDIT: Ok so I did this:

Convert TWRP .img to .tar (for ODIN)[Easy]

Sometimes the latest version of TWRP is in ".img", so some people use an older version instead, which is in .tar, so they can flash it with ODIN. The thing is that the ".tar" version is just the ".img" compressed XD, so I'm going to show you how...

xdaforums.com

And now I have this error:

ODIN MODE (AVB Fail)

recovery: Error validating footer. (0)

revovery: Error verifying vbmeta image: invalidad vbmeta header (6)

VBMETA G715FNXXU8CUE1, 40003014R
[Android Software Development] Postman1year:
recovery-XcoverPro2.img

drive.google.com

OH, Please try this file again
[Android Software Development] BWRainbow:
Thank you! This time it flashed correctly, no error and the phone boots, but when I try to enter TWRP it shows me regular samsung's recovery.

EDIT: I used Vol Up + Power on
[Android Software Development] osm0sis:
You shouldn't spoon feed people.. this person will never know how to unlz4 an .img.lz4 to then be able to unpack it in AIK now. Let alone whatever extra signing you're doing. 🤷‍♂️
[Android Software Development] BWRainbow:
Thanks to him I learnt exactly that. Helping people isn't a bad thing if the other person (me in this case) is interested on the topic.

Did you learn the stuff the learn alone or maybe somebody sometime did help you? ;)
[Android Software Development] osm0sis:
The best way to learn is to do it yourself. I would have pointed you in to right direction so you could do the process yourself. You didn't really learn anything because he did it all for you.
[Android Software Development] BWRainbow:
I'm not going to discuss with you because I know what I have learn and what not.

Fortunaletly not everybody is like you in internet.
[Android Software Development] osm0sis:
You're welcome for using my tools. Carry on renaming things and thinking that's the same as unpacking them. Which is also covered in this thread if you would have searched first.
[Android Software Development] BWRainbow:
I searched first but this is a 130+ pages topic so it's very hard to find stuff. And as I said, I did in fact unzip lz4 properly and everything, my issue wasn't related with that now, but with other stuff (I even posted the error code and what was happening and when).

I did install linux vm no my computer, execute scripts, follow step by step... EVERYTHING. But at some point, I couldn't find more information and that's why I started to ask.

BTW, this is the guide I used

How to Create and Port TWRP Recovery to any Android Device

In this tutorial, we will show you detailed steps to create and port TWRP Recovery for any Android Device using Android Image Kitchen tool.

www.droidwin.com
[Android Software Development] osm0sis:
Yeah, definitely going to add a FAQ here soon..

The frequency of ".img.lz4 -> .img" and "repack is smaller?" questions alone lately.. I swear the last 10 pages is mostly these questions repeatedly. 😅

Edit

: https://xdaforums.com/t/tool-androi...-win-android-linux-mac.2073775/#post-36069499 😜
[Android Software Development] chronolz:
Hi, can you please share some references for these? Thank you!
[Android Software Development] osm0sis:
Most devices don't need AVBv2 signing, since it's not supposed to be enforced on unlocked and/or rooted devices.

To sign AVBv2 you need avbtool from AOSP, which is a Python script. I've also bundled it for experimental command-line use on Android here: https://xdaforums.com/t/beta-2017-10-01-supersu-v2-82-sr5.2868133/page-572#post-74498246

That link also has a basic example for using avbtool. 👍
[Android Software Development] XDgamerCZ:
This tool doesn't work for me, I always get this message. Anyone who could help me?View attachment 5344181
[Android Software Development] osm0sis:
First, reboot and try it outside of Termux.

Latest remount.sh should go up to loop64 trying to find or make an available one: https://github.com/osm0sis/Android-...bile/data/local/AIK-mobile/bin/remount.sh#L34

Are you sure you're also on the latest release?
[Android Software Development] phanimitra vadlamani:
New_boot.img is 1/6th of the size of the original img(but has all the components)......when i flashed it, my device didnt boot.......i already have flashed vbmeta......if its the size issue.....how can i overcome it?
[Android Software Development] osm0sis:
Read the FAQ
[Android Software Development] phanimitra vadlamani:
Thank you.....my bad😅
[Android Software Development] Marvin732:
how to port lineageos base 16.0 to 18.1?

Trying to use the 16.0 base for galaxy s5+ kccat6 which is G901F and 18.1 base from Galaxy S5 klte G900F
[Android Software Development] osm0sis:
Not at all what this thread is about. Take it somewhere else, please.
[Android Software Development] Marvin732:
The Program doesnt extract the required split_img files
[Android Software Development] osm0sis:
Are you talking about a boot.img? That wasn't clear at all. Upload the file.
[Android Software Development] Marvin732:
uploaded the G901F lineage os 16.0 boot img

and the G900F lineageos 18.1 boot img

According to this video

the tool instead extracts different split_img files which is why i was confused.

I am following this guide

https://xdaforums.com/t/guide-how-to-port-roms-snapdragon-windows-linux.3801391/

and i need boot.img-zImage and boot.img-dtb
[Android Software Development] osm0sis:
Yeah I can't help you follow that guide. Older Samsung uses dt instead of dtb, and zImage is renamed kernel now. Anything else ask in that guide thread.
[Android Software Development] sdeft:
@osm0sis

I hope you are well.

I downgraded to cpio 2.12 but repacking a twrp.img gives system destroyed in redmi phone. I repacked with repackimg.sh --origsize. Have I missed anything ?
[Android Software Development] osm0sis:
Try --original --origsize to rule out the ramdisk entirely.
[Android Software Development] sdeft:
Same problem.

I am using binary from cpio_2.12+dfsg-9_amd64.deb to overwrite 2.13 on Debian 11.
[Android Software Development] osm0sis:
Well we just ruled out ramdisk entirely so your cpio is fine. Likely it's your device requiring AVBv2 signing, or you may need to do the fastboot disable verification+verity command to boot differently signed images. You haven't posted any log or .img or device info yet. 🧐
[Android Software Development] sdeft:
device is redmi note 8

recovery link below

Download twrp-3.5.2_9-1-ginkgo.img

Download page for twrp-3.5.2_9-1-ginkgo.img

dl.twrp.me

where is the log of AIK stored ? I can't find it.
[Android Software Development] osm0sis:
It's printed on screen. Cut and paste or >> aik.log

Anyway:

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

Supplied image: twrp-3.5.2_9-1-ginkgo.img

Setting up work folders...

Image type: AOSP

Signature with "AVBv2" type detected.

Splitting image to "split_img/"...
ANDROID! magic found at: 0
BOARD_KERNEL_CMDLINE console=ttyMSM0,115200n8 earlycon=msm_geni_serial,0xa90000 androidboot.hardware=qcom androidboot.console=ttyMSM0 androidboot.memcg=1 lpm_levels.sleep_disabled=1 video=vfb:640x400,bpp=32,memsize=3072000 msm_rtb.filter=0x237 service_locator.enable=1 swiotlb=2048 firmware_class.path=/vendor/firmware_mnt/image loop.max_part=7 androidboot.usbcontroller=a600000.dwc3 androidboot.selinux=permissive buildvariant=eng
BOARD_KERNEL_BASE 0x00000000
BOARD_NAME
BOARD_PAGE_SIZE 4096
BOARD_HASH_TYPE sha1
BOARD_KERNEL_OFFSET 0x00008000
BOARD_RAMDISK_OFFSET 0x01000000
BOARD_SECOND_OFFSET 0x00f00000
BOARD_TAGS_OFFSET 0x00000100
BOARD_OS_VERSION 16.1.0
BOARD_OS_PATCH_LEVEL 2099-12
BOARD_HEADER_VERSION 1
BOARD_RECOVERY_DTBO_SIZE 977967
BOARD_RECOVERY_DTBO_OFFSET 31641600
BOARD_HEADER_SIZE 1648

Unpacking ramdisk to "ramdisk/"...

Compression used: gzip
109889 blocks

Done!

So, yeah, AVBv2, like I thought. Google avbtool and sign it and it'll likely work. I'll have to add that and the fastboot disable verification/verity to the FAQ next.
[Android Software Development] sdeft:
I guess you mean to download the AVBTOOL from below and apply it on the repacked image, correct ?

avbtool.py - platform/external/avb - Git at Google

558bd75ef0eb86629c8d561b94ce15544910ee06 - platform/external/avb - Git at Google
[Android Software Development] sdeft:
do you have any instructions on what needs to be done on resulted image-new.img with avbtool ?
[Android Software Development] osm0sis:
Probably just the basic boot partition image signing commands it tells you, check with `avbtool --help`. Here's an example in my post here though that might still be correct: https://xdaforums.com/t/beta-2017-10-01-supersu-v2-82-sr5.2868133/page-572#post-74498246
[Android Software Development] HemanthJabalpuri:
I can't able to unpack in Realme UI 2.0 Android 11 in my Realme C12 using Phh AOSP GSI. img is not a issue since all are working fine in Realme UI 1.0 Android 10.

I am using AIK 3.8.

Anything wrong on my side?
[Android Software Development] osm0sis:
Loop devices might be all full? Pretty sure I've got it able to open up to 64 though.. really hard to debug. You'll have to check through the commands in remount.sh.

You can unpack on desktop in the meantime.
[Android Software Development] HemanthJabalpuri:
Ah found the culprit.

I cant able to get AIK working with Phh Superuser in Phh AOSP GSI. But with Magisk, unpack works fine in same Phh AOSP GSI.
[Android Software Development] ace2nutzer:
Hi, i've to report a boot-loop on first Samsung bootlogo using latest v.3.8-ALL.

Device: Galaxy S8 aka G950F

Codename: dreamlte

Android 9 stock

Stock boot.img

It worked fine before with some older version like 3.6 or 3.7.

Don't know how to check the version, since it's unpacked ...

Also i've tried with --original, but it results in real boot-loop. (Not just hanging on Samsung logo)

Q1: How i can get v.3.7 and v.3.6 original packages ? (i want to check which one worked)

I hope you can fix it. :)
[Android Software Development] osm0sis:
This is an old "hdr v0" device with Samsung dt. There have been no changes to how these are handled. 🤔
[Android Software Development] osm0sis:
Did you try NOT using --nosudo? It's deprecated.

I unpacked/repacked with AIK-mobile --original and will compare for any differences. Can you also try AIK Windows or mobile and try with --original?
[Android Software Development] ace2nutzer:
Well i've found the culprit ! - It was because in latest version of AIK-Linux the boot.img-dtb and boot.img-zImage was renamed.

My build_kernel.sh script was adding those files to split_img without to replace the right ones, so no wonder that it didn't work at all.

Boots properly now without --nosudo and default compression gzip.

Question: is it safe to use LZ4 instead gzip ? - I guess it's required to have CONFIG_RD_LZ4 enabled in kernel, right ?
[Android Software Development] osm0sis:
Yeah kernel config needs to support any ramdisk compression changes, and bootloader needs to support any kernel compression changes.
[Android Software Development] ace2nutzer:
Thanks Boss ! - How i can make sure that the bootloader really supports LZ4 compressed ramdisk ? - If it boots it's OK and if not i can forget ?

I'm asking because around 2 years ago i had released a kernel with LZ4 compressed ramdisk and some users reported boot issues when using Magisk canary builds. After switching back to gzip Magisk canary worked properly. Stable Magisk builds was not affected.
[Android Software Development] osm0sis:
Pretty sure any compression issues in Magisk are resolved currently. Also please read again, bootloader support is for kernel compression, not ramdisk.
[Android Software Development] osm0sis:
You probably want lz4-l for ramdisk. Old releases aren't the answer, you just need to know about what you're trying to do. 🙃
[Android Software Development] ace2nutzer:
It works with old release using lz4 in split_img. :unsure:

Never heard about lz4-l.

Edit: ahh now i got it, you mean lz4-l instead to use lz4.

Let me see if it'll finally boot.
[Android Software Development] osm0sis:
Legacy. Ramdisks are almost always lz4 legacy. Abbreviated in AIK and AK3 as lz4-l since the actual lz4 command-line option is `lz4 -l`. Read the release notes for 3.7 and 3.8 for more explanation.
[Android Software Development] ace2nutzer:
Finally latest AIK with lz4-l works like a charm !

I've read release notes 3.7 && 3.8. :)

It's really insane how much work you did !

I hope many people will consider to donate to you, you deserve it.

Some feedback about this tool:

It's a very powerful tool for every kernel developer, basically a must have.

But somehow it lacks a proper documentation.

There is no usage info on Post #1, no Readme file, also no wiki and no readme in GitHub.

./repackimg.sh --help
usage: repackimg.sh [--local] [--original] [--origsize] [--level <0-9>] [--avbkey <name>] [--forceelf]

Nothing about LZ4.

Something like:

./repackimg.sh -c --help // c for "compress"
usage: repackimg.sh -c <gzip|lzo|lz4>

would be great, just an idea.

Once again, thanks for this great tool and your help !
[Android Software Development] osm0sis:
Usage info is in the OP in and below the "Instructions" list. You're right the compression options aren't entirely documented, so I've just updated it with the list. 👍

That said, the method of dumping the values out to files to then be changed will stay that way, since it's pretty straightforward and I wouldn't want to convolute that with a command-line option override. Glad you got it working! 🙂
[Android Software Development] ace2nutzer:
Great !

All right.

btw:

Known Working Devices

You could add S8 / S8+ Exynos variant as well.

I can confirm it works even with recovery. (TWRP)
[Android Software Development] Wishmasterflo:
Hi all!

First of all thanks a lot for this great tool. :)

I have one question where I am not 100% sure how to do that correctly.

If I have a .lmza file like ramdisk-new.cpio.lzma and I want to have the pure/extracted .CPIO file out of it.

How exactly do I get that?

Thanks in advance!
[Android Software Development] osm0sis:
Just unlzma it with `unlzma` or `xz -d`, or 7zip or any major multi-format archiver should be able to do this as well.
[Android Software Development] Wishmasterflo:
That worked like a charm with xz -d . Thanks a lot!
[Android Software Development] ipdev:
Just a quick note.

I had no issues unpacking Pixel 6 and 6 Pro boot images with AIK. :D

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

Supplied image: oriole-sd1a.210817.015.a4-boot.img

Setting up work folders...

Image type: AOSP

Signature with "AVBv2" type detected.

Splitting image to "split_img/"...
ANDROID! magic found at: 0
BOARD_KERNEL_CMDLINE
BOARD_PAGE_SIZE 4096
BOARD_OS_VERSION 12.0.0
BOARD_OS_PATCH_LEVEL 2021-10
BOARD_HEADER_VERSION 4
BOARD_HEADER_SIZE 1584

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

Compression used: lz4-l
4937 blocks

Done!

Cheers all. :cowboy:
[Android Software Development] osm0sis:
Huh! Cool. Glad it's not totally useless out of the gate for Pixel 6. 😎

vendor_boot v4 will definitely eat sh*t though, since it adds a whole crazy bootconfig and multi-ramdisk table system which will be a nightmare to back-port. 😖

include/bootimg/bootimg.h - platform/system/tools/mkbootimg - Git at Google

Edit: Oh wait, there's also an official "signature" section and size header value added in bootimg v4, so that could be problematic on repacks. 😑
[Android Software Development] ipdev:
Umm..

The vendor boot unpacked also.

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

Supplied image: oriole-sd1a.210817.015.a4-vendor_boot.img

Setting up work folders...

Image type: AOSP_VNDR

Signature with "AVBv2" type detected.

Splitting image to "split_img/"...
VNDRBOOT magic found at: 0
BOARD_VENDOR_CMDLINE dyndbg="func alloc_contig_dump_pages +p" earlycon=exynos4210,0x10A00000 console=ttySAC0,115200 androidboot.console=ttySAC0 printk.devkmsg=on cma_sysfs.experimental=Y stack_depot_disable=off page_pinner=on at24.write_timeout=100 log_buf_len=1024K bootconfig
BOARD_VENDOR_BASE 0x10000000
BOARD_NAME
BOARD_PAGE_SIZE 2048
BOARD_KERNEL_OFFSET 0x00008000
BOARD_RAMDISK_OFFSET 0x01000000
BOARD_TAGS_OFFSET 0x00000100
BOARD_HEADER_VERSION 4
BOARD_HEADER_SIZE 2128
BOARD_DTB_SIZE 492894
BOARD_DTB_OFFSET 0x01f00000

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

Compression used: lz4-l
70369 blocks

Done!

Maybe it only unpacked the initial ramdisk? :unsure:

I know you will figure out how to incorporate header v4 properly. :D

If you do not figure it out, I know you will be right there with the one who does. ;)

Cheers. :cowboy:

PS.

I only checked to see what boot header the 6 series was using for a different issue. ;)

Magisk General Support / Discussion - xdaThread - Post # 85850431 - Link
[Android Software Development] kin912:
Hei,bro!Now I use the kitchen to repcak the kernel,but I get the img size is smaller than before.What is the reason?
[Android Software Development] osm0sis:
Read the ****ing FAQ 😉
[Android Software Development] kin912:
I see.But the kernel is not stable when I flash into the phone.The magisk app's patch is useful.
[Android Software Development] osm0sis:
Obligatory cross-post!

I've got some big news! My beautiful wife's now in third trimester and due to give birth in February, so I'm going to have to be away from Android for possibly quite awhile so we can prepare together and work on our home some more beforehand, then find our footing afterwards.

Work on Android Image Kitchen for AVBv2 signing, boot hdr v4 and all the crazy multi-ramdisk shenanigans vendor_boot hdr v4 has introduced will have to wait. Upside is that in the meantime AOSP has stepped up their game with the unpack/repack Python tools: https://android.googlesource.com/platform/system/tools/mkbootimg/+/refs/heads/master
[Android Software Development] PigFire:
Fixed
[Android Software Development] rdanielk:
Hello there,

I am trying to unpack an aml_upgrade_image file... change a few things in system partition, like model name, device name, etc...

Is there anyone here that would be interested in giving me a hand using TeamViewer?

I would be happy to pay for your time if that is the case...
[Android Software Development] AthieN:
@osm0sis - I hope all is well! Congrats on your new baby too. :)

When you get a chance, I was wondering if you could take a look at my recovery.img file? I am unable to unpack the original one directly from the stock ROM. This is on an Android TV device (BuzzTV XRS4900 running Amlogic S922X SoC)...

Error:

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

Supplied image: recovery.img

Setting up work folders...

Image type: AOSP

Splitting image to "split_img/"...
ANDROID! magic found at: 0
BOARD_KERNEL_CMDLINE androidboot.dtbo_idx=0 --cmdline root=/dev/mmcblk0p19 buildvariant=user
BOARD_KERNEL_BASE 0x01078000
BOARD_NAME
BOARD_PAGE_SIZE 2048
BOARD_HASH_TYPE sha1
BOARD_KERNEL_OFFSET 0x00008000
BOARD_RAMDISK_OFFSET 0xfff88000
BOARD_SECOND_OFFSET 0xffe88000
BOARD_TAGS_OFFSET 0xfef88100
BOARD_OS_VERSION 9.0.0
BOARD_OS_PATCH_LEVEL 2020-09
BOARD_HEADER_VERSION 1
BOARD_RECOVERY_DTBO_SIZE 438
BOARD_RECOVERY_DTBO_OFFSET 16660480
BOARD_HEADER_SIZE 1648
Unrecognized format.
Error!

Any ideas? Original recovery.img attached for your review.

Many thanks in advance for your time!
[Android Software Development] blaze2051:
can someone please example what happened?

I unpacked and repacked my patch boot.img of 65mb and now the new one is 27mb? how is it so small and how do i get it back to original size?
[Android Software Development] Eznaa:
Yeah same here from 90mb to 38Mb, something's not right
[Android Software Development] blaze2051:
yes thats normal you have to use avbtools to reinflate to correct original oem size per byte

example -

python avbtool add_hash_footer --image boot_patched_magisk.img --partition_name boot --partition_size 67108864 --key rsa4096_vbmeta.pem --algorithm SHA256_RSA4096
[Android Software Development] Eznaa:
Alright. Though I'm surprised proc, sys, system, and dev are empty (or almost empty as system only includes 1 file).

I'm trying to locate default.prop in order to get adbd insecure to work but can't find this file anywhere.