yashsingh1/xdaforums huggingface dataset:
[Android Software Development] osm0sis:
He doesn't even know if it boots. He's just confused by the partition sized dump vs. the size of the actual boot.img contents.

In short it's most likely nothing to worry about. Partition dumps are just padded with zeros.
[Android Software Development] geiti94:
[MENTION=4544860]osm0sis[/MENTION] can you check the s10/s10+ recovery img? it is protected wby avb with vbmeta.img and when i decompile it with your tool and recompile it again without touch it he dont boots anymore. he gives me then an error on the phone display that says: Recovery: verifing footer error (6). i am thinking samsung have the signed location different as aosp or so. here is the recovery img.

https://drive.google.com/file/d/1SmXPk56YESTM0HFWPN1lFCSo_MDR7FSa/view?usp=sharing
[Android Software Development] shoey63:
fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img

is the command to use before flashing modified boot images on new slot a/b devices, as dm-verity flag is no longer in the ramdisk or dtbo
[Android Software Development] geiti94:
on phones that have fastboot yes i know that. samsung dont have fastboot
[Android Software Development] osm0sis:
I suggest you wait for [MENTION=4470081]topjohnwu[/MENTION] to figure out how to root it, since you'll need to handle an unlock or disable verity somehow to boot.
[Android Software Development] geiti94:
allready done. i need now only to get twrp booting :) omni aosp recovery boots. now i am editing kernel for let twrp boot
[Android Software Development] KaMyKaSii:
Should AIK Mobile work on TWRP (3.2.1) terminal?

Edit: I was able to make it work after removing the character "&" but now there is another error at the time of repack:

repackimg.sh: line 145: syntax error unexpected "(" (ex
pecting "fi")
[Android Software Development] osm0sis:
There are instructions linked in the AIK-mobile release post (linked in the OP). Basically you need to mount system and run it through the system sh (which is mksh) since it needs mksh allowing that |& for proper special characters support for filenames/paths.
[Android Software Development] bigrammy:
DT verity removal.

Hi,

Is there a stand alone script or switch to remove verity from the dtb of the kernel automatically :confused:

If I try to do this manually using ghex the modified boot.img fails to boot. (note this is probably due to my own ineptness rather than ghex)

Flashing magisk on the AIK repacked .img's works fine but if I try to remove verity myself it fails to boot or am I missing something else?? :silly:

I can take care of the .fstab's that are /system and/or /vendor and or /nvram side so no problem there.

Reason:

I would like to be able to pre-patch the boot.img's using AIK on my PC, flash the edited .fstab's (eg: simply disable verity) and boot the rom then test everything is working prior to flashing Magisk as I suspect that Magisk may be breaking something's on the rom (mediatek specific but not mtk headers)

EG: Flashing the Nokia 3 Android v8.0 ROM using the newer version's of Magisk breaks the radio "no signal" but using an old version of Magisk it seems to work fine.

I would like to try debug this issue and see just whats breaking the radio (baby steps)

NOTE:

I am using AIK Linux version.

My coding skill is abysmal or less. :laugh:
[Android Software Development] ashyx:
AIK cannot do this, nor it intended to.

If you're patching the dtb and it's not booting without any other changes then your patching method is likely wrong.

As a suggestion would be to let Magisk patch the dtb then pull the image and just use AIK to separate the DTB.

The other alternative is to modify the boot patch script for magiskboot to only patch the dtb.

https://github.com/topjohnwu/Magisk/blob/master/scripts/boot_patch.sh
[Android Software Development] bigrammy:
Hi ashyx,

As already stated in my post I strongly suspect I am doing it totally wrong hence why I wondered if there was a standalone script.

Not sure what you mean by this? Do you mean remove the DTB altogether or just view the changes Magisk made??

As said my code skill is pretty poor to say the least :o there is a project similar to what you suggest HERE but applying that alone breaks the booting of the rom unless Magisk is applied afterwards. Using Magisk defeats my objective as I want to see what changed in Magisk that caused the issue described.

I want the rom to boot with as little changes as possible over stock and the boot_patch.sh of Magisk maybe the issue here so I would of liked to do it independently of Magisk and thought someone may of had a simplified script/ .sh that could be run to correctly remove all instances of ",verify" (note the , comma too) from the dtb.

I don't expect anyone to solve this for me but wondered if anyone had already wrote a script / .sh to do the above dtb edit and let AIK do the unpacking and repacking. :confused:

To Sum Up:

1. AIK unpack repack flash. ROM boots no issues

2. AIK unpack repack do my rubbish edits flash. flash modded .fstab's ROM bootloops

3. Flash Magisk Old version on stock boot. flash modded .fstab's ROM boots no issues

4. Flash Magisk Newer version's on stock boot. flash modded .fstab's ROM boots but no radio signal

5. Use tool from above to patch stock boot.img. flash modded .fstab's ROM bootloops

6. On Nokia 3 a combo of flashing 5 and 3 also 5 and 4 results in. ROM bootloops but seems to work on older rom versions and other devices I have. :eek:
[Android Software Development] ashyx:
When I say let magisk do the patching, by that I mean let it patch the dtb. Pull the boot.img from the device, unpack it with AIK, save the patched dtb, unpack the untouched boot.img then replace the dtb with the patched one.

Finally repack and flash.

As far as I know the only modification magisk does to the dtb is the dm-verity patch, so it should boot the stock boot.img.

If it doesn't then you know there is an issue patching the dtb.

Of course you could do all this by using Linux tools to unpack and repack the dtb itself, but letting magisk hex patch is the easier way IMO.

If you want to post both unpatched and your patched dtb, I could take a look at how you've patched it.

All you really need do is replace every character with zero bytes.
[Android Software Development] bigrammy:
Thanks ashyx,

I think I maybe missing a trick here so from what you say it's possible for me to repack the dtb and re append using linux tools :confused:

I already figured out how to extract the dtb and unpack it but for the life of me could not work out how to repack it and re append it to the boot.img.

Forgive my ignorance but I am not a IT guy so I do have some huge gaps in my knowledge and I occasionally fall into these holes :silly:

If you could give me a couple of pointers for repacking and appending the dtb that would be great :good:

If I am still stuck after that I will take you up on generous your offer. :D

PS: Regarding "zero bytes" do you use ghex and if so how do you replace a character with a zero byte. When I use the GUI it does not insert a "zero bite" it just deletes the character altogether. Is there a key to use to overwrite a character with a "zero bite" rather than simply delete it. Google is not throwing up anything obvious unless my search terms are wrong. :eek:

EDIT: Found out how to do it now :victory:

"Find and Replace" So embarrassing :crying:
[Android Software Development] martyfender:
On my devices, when I repacked the boot.img in the past, it was always about half the size of the original and it booted fine.
[Android Software Development] bigsupersquid:
Hi.

AIK-Linux, ubuntu 14.04 with everything needed to build LineageOS, Halium, PostmarketOS, kernels, etc.

I am working with my first Rockchip device.

Runs android 5 userdebug with root ADB out of the box, and appears to have standard AOSP boot and recovery images according to unpackimg.sh (dd'd from their by-name partitions)

When dd'd back unmodified to the recovery partition they both work fine. (not messing with the boot partition yet until I have a better handle on what is going on. a system reboot rewrites recovery_from_boot.p and I have a usable recovery again.)

Issue is: I unpack recovery or boot. Do not modify. See ramdisk contents, lists zImage ramdisk and config variables in split_img.

repackimg.sh, whether --original or not, --level set or unset, doesn't change output.

recovery image goes from 33554432 (ls -al) to 10502144 after repacking. No longer boots, drops to bootloader. boot ends up a little smaller, also drops to bootloader when dd'd to recovery partition and rebooted to it.

Something is seemingly being left out. Though they may be inflated beyond their actual contents as the img files are produced by dd'ing their entire partitions to a file each. I may need to use the Android AIK toolset to dump and flash the images correctly for modification, your unpack and repack tools are likely giving a more accurate representation of used space than the dd'd img files themselves. The ramdisk and kernel appear identical after repack/unpack again.

Interestingly, twrp for similar device unpacks with KRNL format, no zImage in it to be seen, repacks to slightly larger size, boots before and after on my hardware (built for wrong device entirely but still Rockchip RK3288.) Unfortunately this is not a touchscreen device so twrp is mostly only useful for adb.

I would like to learn how to manipulate this device, the Rockchip chipset having much mainline linux kernel support from the chip manufacturer is an interesting change from my other android devices.

It's a v05-a vr headset by the way, runs nibiru android flavor.

Here is the stock boot dd'd image which is giving me trouble, plus the oddball twrp.

I can't upload the recovery.img here. uncompressed boot and recovery are 33MB. boot compresses. recovery only compresses to 27MB, though when unpacked recovery and boot look very similar. maybe the image resources, pretty 3d recovery animations.

also attached is boot image from OTA update I grabbed from the device. It unpacks then repacks with no changes and boots after repacking. this enhances my thought that using the full dd'd images may be causing my problem, I don't think it is AIK causing the problem.

recovery image on AFH for temporary storage.

I appreciate how you help developers and wanna be developers even with some awfully noob-ish questions, and how you are constantly improving your lovely open source tools.
[Android Software Development] tomatolei:
Samsung S10 boot.img Ramdisk cannot unpack

This link is S10+ boot.img

https://1drv.ms/f/s!Ap5pXnpA2A8AtBIBjTOj41yTplPk
[Android Software Development] KaMyKaSii:
Provide the boot.img file
[Android Software Development] tomatolei:
https://1drv.ms/f/s!Ap5pXnpA2A8AtBIBjTOj41yTplPk
[Android Software Development] osm0sis:
If it's got no ramdisk then it's got no ramdisk. The output is pretty clear.
[Android Software Development] tomatolei:
Android Image Kitchen - UnpackImg Script
by osm0sis @ xda-developers

Supplied image: boot.img

Setting up work folders . . .

Image type: AOSP

Splitting image to "split_img/" . . .

BOARD_KERNEL_CMDLINE console=null androidboot.hardware=qcom 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
BOARD_KERNEL_BASE 00000000
BOARD_NAME RILRI20B001
BOARD_PAGE_SIZE 4096
BOARD_HASH_TYPE sha1
BOARD_KERNEL_OFFSET 00008000
BOARD_RAMDISK_OFFSET 02000000
BOARD_SECOND_OFFSET 00f00000
BOARD_TAGS_OFFSET 01e00000
BOARD_OS_VERSION 9.0.0
BOARD_OS_PATCH_LEVEL 2019-02
BOARD_DT_SIZE 1

Unpacking ramdisk to "ramdisk/" . . .

Compression used: empty

[B][COLOR="Red"]Unsupported format.[/COLOR][/B]
Error!

Unsupported format

can you test unpack？

This link is S10+ boot.img

https://1drv.ms/f/s!Ap5pXnpA2A8AtBIBjTOj41yTplPk

thank you very much！
[Android Software Development] osm0sis:
The boot.img at your link unpacks fine with the latest AIK, as you've already shown. Like I just said, there's no ramdisk.
[Android Software Development] tomatolei:
I understand, thank you!:good:
[Android Software Development] osm0sis:
You've got some weird ones there!

Once they are trimmed to the nearest pagesize you can see that these device images aren't exactly normal AOSP bootimg format. For example, the boot.img and an image-new.img generated from repackimg --original are identical except for 3 things: the standard sha1 checksum and what appears to be an added second sha256 checksum (though I'm not sure of what) after it, along with a single 01 byte that perhaps indicates the deviation from the standard.

Your OTA boot.img also has this extra checksum, so if it boots fine after repack then that's even more bizarre. I have no explanation for this.

The recovery.img has both this extra checksum as well as a big 17.2mb chunk of data on the end that doesn't appear to be another ramdisk (didn't get recognized as any usual compression format at least), nor a usual fdt dtb format. Could be a second loader, but if so, again they didn't add it to the recovery.img in the normal AOSP bootimg format way, so yeah, weirdness.

Then, the twrp.img is indeed normal RK KRNL format which is just a signed ramdisk.

You'll have to look into where that second checksum comes from, why the first checksum is different (since it's normally just a checksum of the rest of the bootimg data after the header) and then maybe you could work out a mod of mkbootimg to repack it for their variant. This is the only device I've seen like this so far.

Can you tell me the proper full name of your device so I can add it to the unsupported section in the OPs?

Also, thanks for the donation! :):highfive:
[Android Software Development] bigsupersquid:
Well, I did find a utility that can unpack and repack them functionally. There is a whole double chunk of weirdness in those img files. ramdisk, kernel, also includes a dt and two .bmp images. I have attached a tar.gz of the full boot.img dump by the other tool for your reference here. If you want the one for recovery let me know and I'll upload that too.

unfortunately the unpack/repack tool has no posted source code. for reference, though, it's here: https://xdaforums.com/showthread.php?t=2257331

I suspect the image format and unpack code is available somewhere here.

The device has no proper codename that I can find. There is very little information I can find about it at all.

It is a V05-A according to the build.prop. Android 5.0 variant by Nibiru (who refuses to release kernel source claiming they get a prebuilt kernel from the unspecified manufacturer, but their name is in the initial kernel startup line, blahblah@nibiru, so I don't believe them.)

The device is a 1080p VR headset with minimal input devices and pretty decent specs overall for a mini gaming rig.

You are quite welcome for the pittance of a donation. You do excellent publicly available work, and that should be supported (even a piddly buck at a time.)
[Android Software Development] casper-:
Hi, would i be able to use these tools to split an orignal boot.img, split a custom rom boot.img, copy the working wifi files (kernals?) from the origial boot, paste them in the split custom boot.img , repack it and then flash it? The boot img's in question have been taken from TWRP backups. Am hoping this would fix the wifi in the custom rom i found. I think the wifi files are in the ramdisk from what i understand, which is in the boot.img? Does any of these sound feasible? Thanks
[Android Software Development] ashyx:
That's entirely what this tool is for.

You didn't state which device?
[Android Software Development] casper-:
Excellent news, thanks! I have a tz95 plus 3gb box. The wifi works using the normal rom but when i try to flash the s912 poison rom it all works apart from the wifi. The Wifi chip on the board states "km63350528" which i think is the WiFi IT6335 chip and hence why the wifi doesn't work using the poison rom as it is built for an older wifi chip. Do all the wifi files have the same or common names? Am new to this so sorry for all the questions.
[Android Software Development] ashyx:
I have the same device but 2gb.

You're right you need the right wifi files.

Best place for this to s freaktab.
[Android Software Development] bigsupersquid:
my bad on last response, I think I uploaded a dump of a boot img I was messing with for postmarketOS instead of a clean one.

here is a nice fresh unsullied dump of the OTA boot.img with the imgrepackerrk tool.

and no telling about the one I thought booted after repacking with AIK, I was messing with so much variation I could have accidentally sourced the wrong one and flashed the unmodified one instead.
[Android Software Development] osm0sis:
Thanks. Yeah, that would definitely make more sense if none of them would boot after an AIK repack. Has [MENTION=4582467]RedScorpioXDA[/MENTION] been asked about releasing the source at any point?

For now I've added "Nibiru V05-A" to the unsupported section in the OP.
[Android Software Development] casper-:
Thanks for the confirmation, it sounds like it is possible! I managed to unpack the boot.img but the system folder etc are all empty. Couldn't figure out what to do next. Will google freaktab and see what comes up.
[Android Software Development] AxelBlaz3:
[MENTION=4544860]osm0sis[/MENTION] I'd like to use the kernel unpack and repack(for AnyKernel2 zip flashing) in an android app. I wonder how to do that. Would you mind helping me here? Thank you.
[Android Software Development] osm0sis:
AnyKernel2 is well documented on GitHub and in its own thread, so I would mind helping you here in the AIK thread where it's clear you haven't even tried Googling it or reading anything before posting.
[Android Software Development] AxelBlaz3:
I've been trying to run anykernel.sh script from the terminal emulator. However, I always see an error saying, it can't create directory /proc/self/fd/... Tried mounting it, changing permissions, but none of them work unfortunately.
[Android Software Development] AxelBlaz3:
Well, all I'd like to know is, how do I unpack the boot.img from within the terminal emulator without actually installing the AIK-mobile zip. Thank you. Awaiting a reply.
[Android Software Development] alecxs:
Are you a little disrespectful or just lazy? ;)

For AnyKernel2 you better post in other thread (link see osm0sis' signature)
[Android Software Development] osm0sis:
Now that you're nearly on topic I'll answer you. You can't. AIK-mobile exists because the tools to unpack a boot.img don't exist on Android by default.
[Android Software Development] AxelBlaz3:
Thank you. I have to find a way for integrating AIK into app then. :o
[Android Software Development] osm0sis:
For what? The tools AIK uses are all open source, so you can compile them yourself and include them in your app using some Terminal commands if needed.

If you just want a UI then use FX File Explorer and you can run AIK-mobile from its script execution dialogs. More on that linked in the AIK-mobile release notes post you were already directed towards.
[Android Software Development] AxelBlaz3:
I'm planning to make an app which flashes boot.img right off the bat within the app. Kinda like Flashfire. So I have to integrate AIK into app. That's what I'm back of. ;)
[Android Software Development] madbat99:
Or flashify or any number of apps that flash .img files. Google search is a good start.
[Android Software Development] ashyx:
It's usually good manners and expected protocol to at least ask the developer if you can use his/her tools for your own project. ;)
[Android Software Development] osm0sis:
Most free kernel/root toolkit/flashing apps can flash boot.img, and you don't need AIK for that. FX Explorer with my Fla**** package handles that and also is very app-like, much like I also described for AIK-mobile. Franco Kernel Manager and EX Kernel Manager can even flash AnyKernel2 zips.

I don't give you permission to use my scripts where it's apparent you haven't done any research, let alone a Google or Play Store search.
[Android Software Development] AxelBlaz3:
Sorry if that was kinda disrespectful. I have a done a lot of Google search on how to integrate scripts into apps and regarding the unpacking/repacking of boot. Guess this isn't the place for me to seek help. Thank you :)
[Android Software Development] davek17:
dfeault.prop not unpacking properly

Hi There

This has been a wonderful tool for many years for me! I finally ran into an issue today. I have an MTK6739 Android 8.1 OS. It all behaves as normal, have rooted it etc. AIK works fine on the boot.img, aoart from the default.prop file which ends up some kind of binanry file when inspected in notepad++.

I attached the boot file here (renamed to .txt to pass upload rules).

I tested my setup with other boot.imgs I have here and various past versions of AIK, all the same..

Is this an issue with Android 8.1? All the other files seem to unpack OK.

Anyway help appreciated.
[Android Software Development] ashyx:
It's not an issue with AIK at all. That's how it is on Oreo and beyond. Default.prop is merely a symlink.
[Android Software Development] davek17:
Cheers for the reply. I didn't know that, not been doling this as much as I used to.

So how do we change the ro.secure etc values on Oreo? Is this basically the end of this method?
[Android Software Development] shoey63:
Look for prop.default in the ramdisk
[Android Software Development] davek17:
Sorry I misread the text, I can see it now. I thought it was symlinking to the system folders on main system partition for some reason and could not find it.

Thank-you very much for your help.
[Android Software Development] zainifame:
[MENTION=4544860]osm0sis[/MENTION] will intel image (boot|recovery|fastboot/bootloader/pos) with intel weird header be supported for unpack/repack on next release? I've seen your project (mboot)... Hope it support for playing with intel image
[Android Software Development] osm0sis:
Bingo. ;)

boot and recovery will be supported, as with the other formats here.
[Android Software Development] zainifame:
WOW! Finally :victory:
[Android Software Development] osm0sis:
Tell me about it! :p

Great to finally have an open sourced tool for it after years of only having that Windows-only, closed source one (that didn't even handle all variants) from 4PDA. :victory:

This is the final format I'd originally wanted to have added for what was to be the big AIK v3.0 release, before I decided to space out the format additions.

Also my coding wasn't up to the task back when I first started the research into it a couple years back. Definitely helped having the leaked Intel Python script to figure out extending to all Intel OS format variants and then use as a jumping-off point for the rewrite to C as well. Very pleased with the final product.

Just squashed the last obvious bug yesterday and added it to my WIP AIK Windows, so we're good to go for cross-compiles and me adding support to AIK-mobile and AIK-Linux next, to be released in AIK v3.5. :cool:
[Android Software Development] zainifame:
got problem while unpacking Lenovo K900 and ASUS Z00D image, i'm using latest stock frimware Lenovo K900 (k900_row_1_s_2_009_0553_141125_dvt3_cpusign.tar.gz) and Z00D image is from lineage Z00D repo, bellow here...

result of: ./mboot -u -f boot.img | this output is from both image i try K900 and Z00D

header size 512

sig size 1024

bootstub size 4096

mboot: unpacking error: kernel size likely wrong

result of: file -r mboot

mboot: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/l, for GNU/Linux 2.6.32, BuildID[sha1]=daf1cb4d2deb434c07a011dc159d18f093d17f08, stripped

result of: strings mboot | grep GCC

GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609

my machine running OS Ubuntu 16.04.6 LTS, directly running make all from root of your mboot project...

and this for example image that have $OS$ on header

https://github.com/arizaini/mboot_py/raw/master/intel_image.tar.gz (emergency upload LOL)