yashsingh1/xdaforums huggingface dataset:
[Android Software Development] bigsupersquid:
I'm using a nexus 5 running lineageOS Q...

adb root; adb remount is working fine for me while booted into android for modifying system.

I haven't dug into source to see if it's using dynamic partitions, the one clue I can offer is that in recovery things like priv-app are located in /system/system where in the android OS, they're just in plain old /system.

I could check if I knew what I was looking for, since I'm building from source. I just haven't messed with android since N, so I'm out of date.
[Android Software Development] Fillint:
Yes, I noticed that as well(at least, It's the same on most GSI Roms) and I think they use dynamic partitions(Thanks to osm0sis's answer) for that purpose. anyhow you can check system as root for generic partition layout(linked below) though I don't know if that's of any help.

https://source.android.com/devices/bootloader/system-as-root
[Android Software Development] m8980:
Hello,

is it possible to repack optics.img with this tool?

Since Samsung Galaxy S20 the carriers CSC files are stored in this file.

My device Samsung Galaxy S20 Ultra is rooted with patched stock kernel and bootloader is unlocked, but without custom recovery and /system is read-only at the moment.

I've unpacked the optics.img to decrypt the csc-files and add some csc features. Done successfully.

Now I'm looking for a method to repack the optics.img for flashing with latest odin.

I hope someone can help me?!

Thanks
[Android Software Development] osm0sis:
Nope. OP is pretty clear: boot and recovery images.

Go ask in the S20 Ultra forums.
[Android Software Development] m8980:
ok. thanks
[Android Software Development] MrGreenFR:
Galaxy S2 I9100 unpack error

Hello all,

is there a solution to unpack and repack for SGS2 (GT-9100) ?

The image size is 8Mb, and i've error on unpack :

Unrecognized format.

Error!

Best regard

PS : AIK is really a good tools, i've use it on 3 phone and old Galaxy Tab 2! all ok
[Android Software Development] osm0sis:
That's listed under Confirmed Not Working in the OPs. Please read. :good:
[Android Software Development] msubhani:
Hi [MENTION=4544860]osm0sis[/MENTION] I am using you wonderful tool on windows and ubuntu it work on these platforms. But today i encountered issue on manjaro linux the boot.img pack and unpack without any error but phone didn't boot. Same thing when i did on Ubuntu phone booted fine.

Any idea why it failed to boot when its compiled on manjaro.

P.s. the boot.img is from Samsung s8+ pie.
[Android Software Development] osm0sis:
Does manjaro use cpio 2.13? There's a known bug with it mangling paths when using --no-absolute-paths, so I recommend anyone using AIK-Linux to ensure they're on cpio 2.12 instead.
[Android Software Development] msubhani:
Yes its on cpio 2.13 but i try to downgrade in 2.12 and same issue

---------- Post added at 10:05 PM ---------- Previous post was at 10:05 PM ----------

Yes its on cpio 2.13 but i try to downgrade in 2.12 and same issue

Update: I did it from scratch and itt works. Thanks and it confirmed cpio 2.13 was culprit
[Android Software Development] Knightrider_kit:
Using AIS. Trying to port custom recovery but first thing I've tried is to just unpack and repack stock recovery. When repacking output of AIS is new IMG and new ramdisk. New IMG is smaller than original but from what I've read this should be okay. Flashed new IMG and attempted reboot recovery and all I got was black screen. Flashed stock recovery and it booted recovery fine. Not sure what I'm doing wrong. Any help greatly appreciated! Also can't find how to use --original flag in AIS. New at this sorry if I seem thick headed.:confused:
[Android Software Development] osm0sis:
Uhh, you mean AIK that whole time, right?

If so, then your first step should be `./repackimg.sh --original` (or `repackimg.bat --original` on Windows) to rule out any potential ramdisk repack interference.
[Android Software Development] sathya:
Getting this error. What i am doing wrong?
[Android Software Development] osm0sis:
It's from your path at the top. Probably don't run it from a network drive.
[Android Software Development] Knightrider_kit:
So I guess maybe I was confused cause when I first started this journey a search for Android Image Kitchen brought me to this link:

https://m.apkpure.com/image-kitchen-for-android/com.redlee90.imagekitchenforandroid

I have now downloaded https://dl.xda-cdn.com/4/8/2/5/0/9/1/UPDATE-AIK.Mobile.Installer.v3.6-ALL-signed.zip?key=6knC1nPXCwPjFnnKLXPUvw&ts=1588423148 and will be trying to figure it out later today. Sorry if I was asking questions while using software that wasn't yours. :crying: I am hoping that using your software will help since I figured out that the problem with what I was using seems to be with how it repacks ramdisk.cpio. :confused:
[Android Software Development] Knightrider_kit:
got AIK now

Ok so I don't have Magisk and cannot install it as far as I know. I cannot access my device with adb, cannot do anything in stock recovery except reboot, fastboot only produces a black screen which you cannot press vol-down and then power to get to recovery. So this is why I am trying to port a recovery on the device and then flash it. The only download for mobile I saw was at the beginning of this thread and is in update form for Magisk. So I went through the installer and have attempted to install manually on my device. I am including a text file that shows where I installed files. Not sure what else I might need to do. Anyway, trying to follow this guide https://xdaforums.com/android/general/guide-porting-twrp-source-t3843473. Move my recovery.img to same directory as unpackimg.sh and attempt to unpack it. The first time I got an error on unpacking ramdisk. Deleted split_image but could not delete /ramdisk - system busy. Rebooted, deleted empty dir /ramdisk, attempted unpack again in an attempt to get a record of the exact error and to my surprise everything went off without a hitch. So I immediatly repacked with --original flag and flashed but still same problem, recovery won't boot, all I get is a black screen. All help greatly appreciated.

https://i.postimg.cc/PJs0XNbG/list.png[IMG="list"]http:// i.postimg.cc/PJs0XNbG/list.png[/IMG]

Hope this image comes up. I've been trying to figure out how to do an attachment but I guess maybe I have to have ten posts.
[Android Software Development] osm0sis:
If you don't have modern root you probably shouldn't be using AIK-mobile, and would be better off trying to use AIK-Linux on Linux/macOS or Android Image Kitchen for Windows.

If using --original doesn't work then there's something off with the structure of the .img, perhaps some signing your device bootloader requires. You'll have to compare the repacked .img with the original in a hex editor.
[Android Software Development] Knightrider_kit:
Unfortunately, I don't have access to a computer right now but I did look at the files and see something having to do with a signature but from what I've read signatures are supposed to be at the end but this is at the beginning. This is what it looks like. Please let me know if there is a way to sign the image myself. Thanks again.

root@android:/ # od -c /mnt/sdcard/recoveryProject/stock/recovery.img | more created with cat

0000000 A N D R O I D ! $ 360 204 \0 \0 200 @ `

0000020 o 254 275 \0 \0 \0 \0 b \0 \0 \0 \0 \0 \0 360 `

0000040 \0 200 \b ` \0 @ \0 \0 \0 \0 \0 \0 \0 \0 \0 \0

0000060 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0

*

0001100 * C 244 374 \v 226 337 H ; = ( 271 241 376 204 6

0001120 022 224 B B \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0

0001140 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0

*

0002000 S I G N 200 \0 \0 \0 \b 346 z 371 323 255 ; 261

0002020 M 264 325 . 225 5 224 220 Q l 233 a c 277 372 361

0002040 F S ; 005 \v 232 J 267 , + 253 003 277 \n 314 275

0002060 243 301 037 260 004 y [ V 255 306 Y - 265 330 004

0002100 ; 5 F 002 r 376 L 360 / E 313 334 262 a \f 216

0002120 320 346 > 374 354 246 334 033 274 313 242 ( 300 316 . '

0002140 5 H 030 250 X 016 017 366 375 256 355 R 231 b { 371

0002160 242 ( 226 257 332 305 ( 361 272 \n 215 270 356 273 275 #

0002200 N 324 ) ' = E u K \0 \0 \0 \0 \0 \0 \0 \0

0002220 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0

*

0040000 323 360 ! 343 020 237 020 356 262 032 030 353 005 240 260 341

0040020 301 032 030 \n ( 0 217 342 020 001 223 350 004 @ C 340

0040040 004 200 210 340 9 \0 \0 353 \a \0 \0 353 \f 320 237 345

0040060 004 340 217 342 004 200 240 341 020 360 212 342 224 032 030 352

--More--

root@android:/ # od -c /mnt/sdcard/recoveryProject/Folder/recovery.img | more -> created with AIK --original

0000000 A N D R O I D ! $ 360 204 \0 \0 200 @ `

0000020 d 7 275 \0 \0 \0 \0 b \0 \0 \0 \0 \0 \0 360 `

0000040 \0 200 \b ` \0 @ \0 \0 \0 \0 \0 \0 \0 \0 \0 \0

0000060 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0

*

0001100 274 8 237 \r 316 235 \ 246 A X 353 > 221 263 260 333

0001120 323 $ 304 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0

0001140 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0

*

0040000 323 360 ! 343 020 237 020 356 262 032 030 353 005 240 260 341

0040020 301 032 030 \n ( 0 217 342 020 001 223 350 004 @ C 340

0040040 004 200 210 340 9 \0 \0 353 \a \0 \0 353 \f 320 237 345

0040060 004 340 217 342 004 200 240 341 020 360 212 342 224 032 030 352

0040100 H 201 @ 300 D 200 @ 300 \0 \0 \0 300 001 E 210 342

0040120 001 I 204 342 004 \0 240 341 \0 0 240 343 001 i 200 342

0040140 004 0 200 344 004 0 200 344 004 0 200 344 004 0 200 344

0040160 006 \0 0 341 371 377 377 032 \b p 232 345 200 \0 217 342

0040200 h \0 220 350 003 \0 @ 340 \0 P 205 340 \0 ` 206 340

--More--
[Android Software Development] osm0sis:
Well there you go then, and signatures can be at the beginning, the end, or even in the middle like yours appears to be. Likely there isn't much you can do, but you could try using a hex editor to cut the signature out of the stock image and paste it into the same position of the repacked one.
[Android Software Development] osm0sis:
[MENTION=6376476]fawazahmed0[/MENTION] Turns out it's simple enough of an executable that it can be compiled from the command line! :cool:

The only trick was getting the bouncycastle dependencies in there, which an IDE would usually handle (extracting and including only the necessary ones), but I worked around that by just taking them directly out of the latest prebuilt boot_signer.jar from Android CI. :cowboy:

git clone --depth 1 https://android.googlesource.com/platform/system/extras aosp-system-extras
cd aosp-system-extras

# download boot_signer-support-images-with-dt.patch from [url]https://issuetracker.google.com/issues/143810860[/url] to current directory

patch --forward -p1 < boot_signer-support-images-with-dt.patch
cd verity
rm -rf build boot_signer*.jar
mkdir build prebuilt

# download latest AOSP boot_signer.jar and dx.jar from Android CI per [url]https://xdaforums.com/showpost.php?p=80680681&postcount=2272[/url] to prebuilt directory

unzip prebuilt/boot_signer.jar 'org/*' -d build
javac -cp build -d build *.java
jar -cvfm boot_signer.jar BootSignature.mf -C build .
java -jar prebuilt/dx.jar --dex --output=boot_signer-dexed.jar boot_signer.jar

Edit

: Reposted with fresh, tested jar builds over in the old Chainfire thread: https://xdaforums.com/android/softw...images-android-verified-t3600606/post82618961 :good:
[Android Software Development] kory-vadim:
Sorry, using google translator.

If the image is with a signature (boot-sign.img), then when building with finishing up to the original size, the image becomes larger by the size of the signature, that is, you need to finish up to the size without the signature.
[Android Software Development] osm0sis:
No. The padding is after signing, to the size of the dumped input image (i.e. the size of the partition you dumped it from), as in the explanation you quoted.
[Android Software Development] kory-vadim:
I did not merge it from the device, this is a stock image from the official firmware.

I mean this signature.

00000000 53 53 53 53 00 00 00 00 00 00 00 00 00 00 00 00 |SSSS............|
00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000020 00 00 00 00 01 00 00 00 94 00 00 00 40 00 00 00 |............@...|
00000030 79 7b 79 7b 00 00 00 00 00 00 00 00 00 00 00 01 |y{y{............|
00000040 41 4e 44 52 4f 49 44 21 13 b1 69 00 00 80 00 80 |ANDROID!..i.....|
00000050

Size boot-sign.img with signature from official firmware = 16777516 bytes

The size of the repackaged image-new.img = 16777516 bytes

Partition size boot = 0x1000000 = 16777216 bytes

To get it right, you need to take the size after cutting the signature at the beginning and end of the image, or else somehow determine the original size, or simply manually edit the size in the boot-sign.img-origsize file.
[Android Software Development] osm0sis:
Then you shouldn't be using --origsize, since that's not what it's for.
[Android Software Development] kory-vadim:
I just drew your attention to the fact that you need to somehow change the algorithm for determining the original size, because a situation may arise, as in the case I described.

And I would like to know your opinion on how to correctly determine the original image size without a file system?
[Android Software Development] osm0sis:
No, I'm drawing your attention to the fact that you're not using it as intended and it works like it's supposed to; it's for partition dumps, since those are the size of the partition before unpack. Your use-case idea with signatures doesn't make any sense.
[Android Software Development] agabey_42:
I'm trying to open twrp file for redmi note 9S. opens but collects incomplete while collecting back. and img file is not working. what would you suggest me to do?

Does this tool have android 10 support?
[Android Software Development] osm0sis:
It's had Android 10 support for a few versions now. The first step in troubleshooting is `repackimg --original` to see if it works with its original ramdisk.
[Android Software Development] ze7zez:
I tried to use this tool for the first time and I don't understand why it doesn't work.:confused:

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

Supplied image: [URL="https://eu.dl.twrp.me/mako/"]twrp-2.3.2.3-mako.img[/URL]

Setting up work folders . . .

Unrecognized format.
Error!

Press any key to continue . . .
[Android Software Development] osm0sis:
What? Works fine. There's nothing special about that image.

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

Supplied image: twrp-2.3.2.3-mako.img

Setting up work folders...

Image type: AOSP

Splitting image to "split_img/"...
BOARD_KERNEL_CMDLINE console=ttyHSL0,115200,n8 androidboot.hardware=mako lpj=67677
BOARD_KERNEL_BASE 0x80200000
BOARD_NAME
BOARD_PAGE_SIZE 2048
BOARD_HASH_TYPE sha1
BOARD_KERNEL_OFFSET 0x00008000
BOARD_RAMDISK_OFFSET 0x01600000
BOARD_SECOND_OFFSET 0x00f00000
BOARD_TAGS_OFFSET 0x00000100
BOARD_HEADER_VERSION 0

Unpacking ramdisk to "ramdisk/"...

Compression used: gzip
8120 blocks

Done!

Make sure you're using the latest AIK download from the OP.
[Android Software Development] ze7zez:
I'm sure of the latest version of Android.Image.Kitchen.v3.7-Win32.zip.

Does this version not work on Windows 8.1 64 bit?

OK. The script doesn't like the long path. When moved higher in the tree works well. :good:

Can unpack the huge 128 MB TWRP for Xiaomi Mi Note 10.
[Android Software Development] osm0sis:
Well yeah, that's a Windows limitation in general.
[Android Software Development] weili0752:
First of all, thank you for your work! I have a mistake

rh@rh-Aspire-T5000:~/Desktop/tools/Android-Image-Kitchen-AIK-Linux$ ./unpackimg.sh recovery.img

chmod: cannot access '/home/rh/Desktop/tools/Android-Image-Kitchen-AIK-Linux/bin/boot_signer.jar': No such file or directory

chmod: cannot access '/home/rh/Desktop/tools/Android-Image-Kitchen-AIK-Linux/bin/avb/*': No such file or directory

chmod: cannot access '/home/rh/Desktop/tools/Android-Image-Kitchen-AIK-Linux/bin/chromeos/*': No such file or directory

Android Image Kitchen - UnpackImg Script

by osm0sis @ xda-developers

Supplied image: recovery.img

Setting up work folders...

Image type: AOSP

Signature with "AVBv1" type detected.

Splitting image to "split_img/"...

./unpackimg.sh: line 219: /home/rh/Desktop/tools/Android-Image-Kitchen-AIK-Linux/bin/linux/x86_64/unpackbootimg: No such file or directory

chmod: cannot access '/home/rh/Desktop/tools/Android-Image-Kitchen-AIK-Linux/bin/boot_signer.jar': No such file or directory

chmod: cannot access '/home/rh/Desktop/tools/Android-Image-Kitchen-AIK-Linux/bin/avb/*': No such file or directory

chmod: cannot access '/home/rh/Desktop/tools/Android-Image-Kitchen-AIK-Linux/bin/chromeos/*': No such file or directory

Error!
[Android Software Development] osm0sis:
Yes, I believe your mistake was trying to `git clone` it and think it would work without any binaries. Get the AIK-Linux .tgz from the OP and untar it into your home directory.
[Android Software Development] io2345:
Is this also false positive?:

Trojan:Win32/Occamy.C05 in file Android Image Kitchen/android_win_tools/sudo.exe

Reported by Windows Defender on current Win32-Zipfile
[Android Software Development] osm0sis:
Always. and. forever.

Search the thread.
[Android Software Development] Oswald Boelcke:
[MENTION=4544860]osm0sis[/MENTION] Congratulations to your new wings! The title suits you well and is definitely well deserve!

Stay safe and stay healthy!

Regards

Oswald Boelcke
[Android Software Development] osm0sis:
Thanks so much! It was a great surprise and I'm still in disbelief of somehow being counted among some true greats! :D
[Android Software Development] erad1:
Congratulations you deserve this!
[Android Software Development] jcmm11:
Congratulations!

It's long, Long, LONG overdue.
[Android Software Development] sdeft:
[MENTION=4544860]osm0sis[/MENTION]

Although you added the truncate function in v3.7 the resulted image is still smaller and different than the original. Am I missing something in the repacking command ?
[Android Software Development] osm0sis:
repackimg --origsize, per the changelog and instructions in the OP.
[Android Software Development] sdeft:
miissed that one:) thanks!
[Android Software Development] imranpopz:
[MENTION=4544860]osm0sis[/MENTION] when i tried to unpack the recovery.img of zenfone 2 intel atom chip and repack normally it doesn't boot, if i do repack --original it boots but the changes i made is not there....

---------- Post added at 10:05 AM ---------- Previous post was at 10:05 AM ----------

[/COLOR [MENTION=4544860]osm0sis[/MENTION] when i tried to unpack the recovery.img of zenfone 2 intel atom chip and repack normally it doesn't boot, if i do repack --original it boots but the changes i made is not there....
[Android Software Development] osm0sis:
Then either your device bootloader is checking the signing so you can't make changes, or, your changes are breaking it by being incorrectly made or exceeding the allowable size of the ramdisk/partition.

You could try removing the -sig file before repack to see if unsigned works. Try it with --original first.
[Android Software Development] imranpopz:
With repackimg --original it boots
[Android Software Development] osm0sis:
Did you delete -sig?
[Android Software Development] imranpopz:
No and i can't find it too.. any particular location or cmd to build without sig..?
[Android Software Development] osm0sis:
Unpack, go into split_img and delete the file with the -sig suffix, then attempt to repackimg with --original and see if it boots, then try a normal repackimg without any ramdisk changes and see if it boots.
[Android Software Development] ranjodhricky:
what is boot.img-ramdisk.cpio.gz file in split_img is it ramdisk compressed in gzip?
[Android Software Development] VD171:
How can I extract this logo.bin?

https://xdaforums.com/android/software-hacking/how-extract-logo-bin-t4139783
[Android Software Development] osm0sis:
logo.bin is logo.bin, this thread is for boot.img/recovery.img, as the title and OP are clear about.
[Android Software Development] :
Good work, thx for this nice tool!
[Android Software Development] VD171:
How can I sign my boot.img with BFBF header ?
[Android Software Development] osm0sis:
Read the OPs. You can't.
[Android Software Development] bigrammy:
Hi osm0sis,

First up I don't think this has anything to do with your AIK Tool but recently I noticed that any boot or recovery I unpack and repack all fail to boot. It used to work just fine by the way. :confused:

AIK is used in my superR's kitchen (donate version) and I also have it as a standalone tool and I get the same results regardless of which I use.

So I suspect something has changed on my OS Linux Solus 4.1 Fortitude 64-bit

I noticed this output during the unpacking.

Unpacking ramdisk (as root) to "ramdisk/"...
Compression used: gzip
cpio: Removing leading `/' from hard link targets
cpio: Removing leading `../' from hard link targets

Is this normal?

I checked cpio in my OS and it seems it did get a update recently so could this be the issue and if so whats the easiest way to work around it?

Should I report it to Solus?

Thanks in advance.

Solus link for cpio incase they broke something in the update. https://dev.getsol.us/R561:0f0d289a65c168642ada1e5b3ebbc5c55d9f0f9c

.
[Android Software Development] osm0sis:
Are you using the latest release? It should warn when cpio 2.13 is found since cpio is known broken for our purposes.

https://github.com/osm0sis/Android-...881#diff-48f7925637c56b76cc7db67a716eab00R120
[Android Software Development] osm0sis:
Can't really be helped. If people could upload it as a false positive maybe then it would be fine, but for now you just have to whitelist it in Windows Defender.
[Android Software Development] osm0sis:
Oh it for sure is. It's been brought up several times. I built the executable myself and it's clean.

This is supposed to make that obvious to the end-user: https://github.com/osm0sis/Android-Image-Kitchen/blob/master/repackimg.bat#L79-L86
[Android Software Development] bigrammy:
Thanks osm0sis I was using v3.6 so no warning :o

I will look for a workaround or how to revert the cpio version in my OS. :(

Any plans to bundle a stand alone cpio in the kitchen?
[Android Software Development] osm0sis:
No plans for Linux, no.

It shouldn't be that hard to downgrade the cpio package in a distro install.

Also pretty pointless reporting bugs for old AIK versions.. :(
[Android Software Development] osm0sis:
Interesting. Defender silently kept removing it on my PC, hence me adding the warning. I wonder if trying to run it would return an errorlevel to catch when it's blocked. ?
[Android Software Development] bigrammy:
Yes sorry I missed the version update I thought I was on the latest one :(

I thought SuperR's Kitchen would be using the latest version also which I set auto update but since both were broken I thought I would ask here but I guess I jumped the gun a little Sorry.. :o
[Android Software Development] osm0sis:
[MENTION=5787964]SuperR.[/MENTION] has it up to date as far as I know. We generally touch base after every AIK release since he rehosts for his kitchen's purposes. :confused:
[Android Software Development] asgharSo:
hi [MENTION=4544860]osm0sis[/MENTION]

i use this project for unpack and repack on my c# window application project.

my project level is highestAvailable , after unpack boot, recovery img with android image kitchen (as administrator ), we cannot access to ramdisk folder

I could not run the process with normal access, the software runs all processes as highestAvailable.

Is there a solution to this?

thanks
[Android Software Development] osm0sis:
Not really sure what your issue is, and no idea how I'd reproduce it to test. It's not meant to be run as administrator, it only elevates for ramdisks that need it (i.e. rooted ones), so maybe don't do that. If you're having trouble in Windows directly with its difficult permission structure, maybe try AIK-Linux either with WSL2 or on Linux, or something, probably works fine there.