yashsingh1/xdaforums huggingface dataset:
[Android Software Development] osm0sis:
[MENTION=4179234]trevd[/MENTION] Great! I may have just been thinking of that reply and didn't actually PM. My mistake, I've been working a lot lately and it's been hard to keep track of some things.

Please check out those Vega images too. I'm really not sure what to make of that last page with the random data in the stock image hkfriends posted that I wrote the workaround for.

http://xdaforums.com/showpost.php?p=45157543&postcount=144

Good news is it seems to work fine on all other dtb devices/images, but since the rooted stock image I found for the device didn't have that extra page of data and apparently also works fine I'm wondering what the function of it is and if it's worth having the workaround in there for it if it's of no consequence removing it.

Thanks in advance for your thoughts. I'll try to get mkbootfs compiling later today after I'm done with the Xposed zip update I promised people. ;)
[Android Software Development] navneetasnavi:
[REQ]

Can You plese post a new STEPWISE TUTORIAL to unpack/repack Boot.img/Recovery.img and edit the Ramdisk.

I'm new to the developement of Kernels

I used [MENTION=673068]dsixda[/MENTION] 's Rom kitchen to unpack boot.img to but after decomping i get the ramdisk folder and zimage aside

I think Zimage includes the kernel or some important files

but dont know how to get the files out from the Zimage

So It would b better if you can post a new stepwise tutorial.

That will help me and other begginers a Lot :fingers-crossed:
[Android Software Development] osm0sis:
It says this in the OP, and this isn't dsixda's kitchen, but here you go :rolleyes::

1) drag and drop image (in same directory) onto unpackimg

2) change files in ramdisk

3) double-click repackimg

As you can see.. laughably simple. The zImage is the compiled kernel source, there are no files to get out of it. The only thing you change is the ramdisk.
[Android Software Development] osm0sis:
If you can try it on with AIK-Linux on Linux or macOS, or AIK-mobile on device that would be good. Another thing to try is unzipping AIK Windows on your desktop and trying again there. (I've seen it fail from weird inherited Windows permissions before - a hopeful fix for this will be in AIK v3.5).
[Android Software Development] rejinarudo:
I got my linux laptop and tried unpacking and repacking the original boot image without touching anything and flashing it and it worked.

I tried changing a few default.prop properties, rebuilding the boot image and flashing it again and it worked as well.

I then extracted AIK to my Windows desktop, unpacking and repacking the boot image without touching anything and it worked.

I tried changing a few default.prop properties there as well, rebuilding and flashing the boot image and it is working now.

I guess what I am trying to say is that it works. :laugh:

It must have been the weird Windows permissions.
[Android Software Development] Spaceminer:
[MENTION=4544860]osm0sis[/MENTION]

Is it possible to add support for unpacking/repacking a bootloader image? (I completely understand the risks involved.) The image in question is made by Motorola. I was able to gather the following information, which looked extremely useful for this purpose.

ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: ARM
Version: 0x1
Entry point address: 0x8f600000
Start of program headers: 52 (bytes into file)
Start of section headers: 1040688 (bytes into file)
Flags: 0x5000002, Version5 EABI, <unknown>
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 2
Size of section headers: 40 (bytes)
Number of section headers: 11
Section header string table index: 8

If you have no interest in assisting with this, I can completely understand. I would definitely like to hear any input you may have about this. Thanks for your time and consideration.
[Android Software Development] CurtisMJ:
[MENTION=7718083]Spaceminer[/MENTION] Sorry, but out of interest, what resources are you expecting to find in the bootloader? I'm not sure if the image has anything after the elf binary but if that's all there is then you need a decompiler, not an unpacker. It's a straight program, like the zImage in the kernel image.

Edit: I'd like to apologize, I wasn't trying to be rude either and realize this comment wasn't nearly as helpful as osm0sis' reply below. I wish you luck in your modifications!
[Android Software Development] Spaceminer:
They can be unpacked just the same as a boot.img or a recovery.img. (Unless something drastic changed in the last few years.) Older bootloaders could be stripped of their headers by using a byte skip during the dump, and then unpacked like a normal image. (This is why I posted header information.) You could then have a look at the contents in a more readable fashion.

As for what resources do I expect to find? I'm not trying to sound rude but that's a very funny question. Have you ever ran grep on one? Or looked at one with a hex editor? There's an absurd amount of commands that exist in a bootloader. Commands that, if you got access to them, would give you god like power over a phone. You ever seen the N/A screen upon booting an unlocked android? That's controlled in the bootloader. There's also a command to change it back to the normal logo inside. That command is blocked. So, in order to use that (or many other useful commands), I gotta unpack the image and make an edit. It's a bit more complicated than that though. The short answer is, this is for reverse engineering.
[Android Software Development] osm0sis:
To answer you both, in my experience with bootloaders and bootable images in Android over the last 7 years what Curtis said is completely accurate: I have never seen a bootloader.img which can be unpacked like a boot.img.

The commands in a bootloader are compiled code. Gaining "access to them" and rewriting/hacking the core part of a bootloader is pretty unlikely since fastboot does signature checks on them when you try to flash them on most OEMs/devices, and if you flash it manually with dd in recovery you're likely going to brick the device since it'll fail the chain of trust from your changes.

If you still intend to try then you really want IDA (Interactive Disassembler), possibly the Hex-rays add-on, which is also what Curtis said.

My 2 personal experiences with altering a bootloader (other than finding the unlock bytes for several older LK bootloader devices) were changing the bootsplash logo on my Galaxy Nexus, which was successful only because the logo was stored in the sbl which luckily wasn't integrity/signature checked, and my Nexus 7 2013, which I bricked trying to change the bootsplash logo, even by a single innocuous byte in what we'd found was the logo area of aboot. Both of those can be found linked in my Odds thread and used a hex editor or raw hex changes via script.
[Android Software Development] Spaceminer:
[MENTION=4544860]osm0sis[/MENTION]

I will definitely try using an IDA, and check out your odds and ends. I definitely appreciate the detailed answer as well.

I honestly can't remember which devices I unpacked like this, I think it was the Zte awe, and the kyocera rise. Pre Jellybean I believe. I used the guide found here to do it. Only, when I got to the IDA part, I never bothered. I ran it through cygwins image tools anyways and pulled it apart. It looked very much like a boot.img when unpacked. I'm sure it did not work properly, but it gave many files that could actually be read. I never had an interest in looking into it again until Motorola slapped with me the N/A screen.
[Android Software Development] KaMyKaSii:
I'm sorry for being a bit off topic, but since you're talking about bootloader, I'd like to ask: Do you know if a tutorial like the one below works on current devices?

https://www.xda-developers.com/how-to-discover-hidden-fastboot-commands/

I have a Zenfone 4 with sd660 and even doing "strings * | grep oem" in a folder with all partitions of the device (except boot, recovery, cache, system and userdata) I still have no interesting results. A command that I know works on the device is "fastboot oem device-info" but even with the command "strings * | grep device-info" I have no results pointing me if some partition actually saves the existing oem commands of my device. Many thanks for any help and once again I apologize for being off topic
[Android Software Development] osm0sis:
Hmm, I checked my devices and no aboot on the newer OnePlus, so I checked abl and xbl which were the only obvious bootloader partitions I could see, but no list of fastboot commands that I could see.
[Android Software Development] osm0sis:
Very cool find! You should post an updated how-to somewhere for modern devices! :)
[Android Software Development] darix96:
Hi! After unpack my boot.img can i edit frequency table to add some frequency for overclock?
[Android Software Development] ashyx:
That's not how it works.

Overclocking requires modifying the kernel source. You can't modify the kernel unless you hex edit it and you've got little to no chance of hex editing a kernel to overclock it.
[Android Software Development] alecxs:
try kernel adiutor or ask in thread
[Android Software Development] ashyx:
You can't overclock a cpu beyond what the kernel already supports.

I'm guessing from the question the poster above posed that he has already tried various kernel tuners.

A custom kernel is required that supports overclocking or compile it from source and modify the frequencies yourself.

Not a particularly easy task unless you know where you're looking.
[Android Software Development] zlatan123:
Will it be working for lenovo a6000
[Android Software Development] osm0sis:
You tell me
[Android Software Development] Geofferey:
Hi, [MENTION=4544860]osm0sis[/MENTION] I have a question regarding Pixel boot.img modifications. Please forgive me if this has been asked before but I couldn't turn anything up in my thread/forum searches. When I unpack a OG pixel boot.img using AIK and go inside the ramdisk I only get the recovery side of the image. I remember having this issue before and the solution was to root with SuperSU which would create directory ramdisk/boot when unpacked with AIK & allow me to modify the boot side of img. Now SuperSU is dead and so is that solution for me (I tried it on P). Is it possible to modify the android boot side of image instead of recovery side with AIK alone? I really need this so I can inject a modified sepolicy for init.d support along with some other things.
[Android Software Development] osm0sis:
Magisk is not dead. It allows anything in an /overlay directory to add/replace files in the booted root / filesystem. You're also in luck because Magisk forces the use of a monolithic sepolicy file in / as well.
[Android Software Development] Geofferey:
EDIT: [MENTION=4544860]osm0sis[/MENTION] Now I am starting to get what you meant. This "overlay" directory you're speaking of is /system_root? I guess when the device boots anything in there is placed at the root /. So if I place /system_root/sepolicy it will replace /sepolicy on boot? My lack of understanding is all due to a refusal to move on, I just recently decided to move on from 7.1.1 and now I got a lot to learn lol. :P

My problem with Magisk is that it does not survive user data wipes despite what I have read. Re-rooting of device is required after any wipe on this version of android. Besides that I don't want Magisk to modify the boot, I want to do it like I had done before when SuperSU wasn't retired by Chainfire. As I said before when I flashed SuperSU and unpacked the boot.img the ramdisk had a separate directory "AIK-mobile/ramdisk/boot/sepolicy". If the device was erased SuperSU would disappear but my kernel mods of init.d, sepolicy etc stayed. When I flash Magisk and unpack the boot.img with AIK that directory is nonexistent.

If and when the device is wiped init.d and all will just disappear. I really want a way to modify the boot side of image then it wouldn't matter if magisk is installed or not just like I had before with SuperSU.

I really hate that Google decided to combine boot and recovery cause it makes modifying the kernel nearly impossible and AIK seems to only extract the recovery. I also tried Init.d injector without Magisk installed and it makes the necessary mods but does so to the recovery side which of course won't work.
[Android Software Development] osm0sis:
... Okay? Pretty sure I recall systemless SuperSU didn't survive a data wipe without some issues either.

You know the files are just in your system partition now instead of the boot partition ramdisk right? You can still take them from there. As for sepolicy, starting recently they're split, so you can use `magiskpolicy --compile-split --save sepolicy` to get a monolith.

Magisk does this all itself on the fly at boot time and puts it in / so you can just grab it and anything else you want to throw into /overlay from there while booted. You could even use AIK-mobile and do it all on-device.

[MENTION=3421557]Geofferey[/MENTION] No, it's literally /overlay like I told you. Unpack the Magisk-rooted boot.img, create a directory in ramdisk named "overlay" and it's just like the one named "boot" that SuperSU used to create.

Magisk just doesn't put the actual files there like SuperSU did because some ramdisks were running out of space. For the record, the final SuperSU versions did something similar but used empty placeholder files instead.
[Android Software Development] Geofferey:
[MENTION=4544860]osm0sis[/MENTION] Thanks dude! You totally just enlightened me. Your post basically just answered all of my questions. I didn't know I had to created the /overlay directory in ramdisk , I just kinda expected it to be there with files in it already when I unpacked. I also noticed when I modified /system_root/default.prop that changes reflected in /default.prop so that's what lead me to my false conclusion. One last question, would you happened to know magisk's secontext off hand? With SuperSU it was u:r:supersu:s0. That's last missing piece for init.d I think.
[Android Software Development] osm0sis:
Magisk's was originally u:r:su:s0 but that has been deprecated for a few versions now and u:r:magisk:s0 must be used on the latest versions.

If you're rooting with Magisk why not just use the built-in post-fs-data.d or service.d?
[Android Software Development] @ta:
Hi, I've used "AIK-Linux-v3.4-ALL.tar.gz" to flash my custom kernel to Samsung Galaxy S9 (SM-G960N). AIK gives me the new boot.img but after I flashed the boot.img using twrp, the Samsung logo pops up and then window goes black and phone just stuck!

Kernel version is 4.9 (Android 8.0), I've downloaded the kernel from Samsung official website, and customized it and the compiled it.

Why my phone does't boot?

Is it because the Samsung Galaxy s9 does't have boot-loader mode?

please help me!
[Android Software Development] osm0sis:
You compiled the kernel source? Could be lots of reasons completely unrelated to AIK that it didn't boot.

Did you base your new boot.img off of an existing one for your device? You should have uploaded a boot.img that works on your device and the new boot.img that doesn't so I can take a look.
[Android Software Development] zputnyq:
Hi [MENTION=4544860]osm0sis[/MENTION],

Aik is a great tool, I really love it.

Just wanna confirm, does the latest version v3.4 for windows still support win xp ?

I tried it, but it doesn't work
[Android Software Development] osm0sis:
Correct. It does not. People gotta let XP die, my dude. :p

I actually put it up for discussion before AIK v2.6 but nobody seemed to care, soo done deal. That was over 2 full years ago.

https://xdaforums.com/search/thread/2073775?query=Windows XP
[Android Software Development] zputnyq:
Ok no problem, I wasn't aware of it.

So the latest version for win xp is 2.6 right ?
[Android Software Development] osm0sis:
Discussion was before v2.6 so therefore v2.5 is the last I believe. I do not recommend downgrading. :rolleyes:

You could just use AIK-mobile on device with a good file explorer app like FX File Explorer and not lose out on all the advances and format updates since v2.5, like Samsung SEAndroid, LG Bump, ChromeOS, AVBv1, and most recently the current AOSP bootimg v1 format which didn't exist back then, just to name a few... ;)
[Android Software Development] zputnyq:
Ok thank you so much for the information :good: :)
[Android Software Development] dandyfarid:
nice tool i love it very thanks :)
[Android Software Development] zputnyq:
Hi [MENTION=4544860]osm0sis[/MENTION],

I tried aik for mobile but somehow I don't understand, it gave me "su command not found" in terminal after I typed aik then hit enter. My device is rooted with magisk v18.1 & all apps that needed root has no problem. I wanna send you recovery log but xda always shows error.

I tried v2.5 on my win xp as well but it didn't work too, so I decided to give v2.4 a try to unpack a kernel (Nautilus Kernel) for My device, Xperia M4 & it works. Btw, the unpacking result between aik for mobile & windows pc is it the same or different, I mean it will be 2 folders (ramdisk & split which contains some compressed files) on both version ?

Edit: sorry, tried the mobile version for the second time, the latest version for mobile works great. I must use explorer for it. I thought I have to use terminal, since I have read somewhere that to use aik, terminal is needed to operate it :D
[Android Software Development] osm0sis:
su command not found means there's something wrong with your Terminal (like you've got root hidden in MagiskHide or it doesn't have access like Termux or something), or there's something wrong with your Magisk installation. Yes all platforms for AIK work about the same.
[Android Software Development] @ta:
I tried to add the link of boot images in Dropbox, but xda does not allow me!! (because i'm new user in xda)

How can I upload the files??
[Android Software Development] osm0sis:
Uhh so break the url so you can post it. :confused:
[Android Software Development] @ta:
What I have done:

I Downloaded the SMG-960N (Korean version) kernel source (4.9.59) from:

opensource

.samsung.

com/reception.do

Modified Kernel and compiled it, I got the Image file :

dropbox.

com/s/49huv2xy6ge4c1l/Kernel-Image?dl=0

Then pulled boot.img of phone using ADB, and placed it in AIK directory. This is download link of phone-boot.img:

dropbox.

com/s/rjtz8jkhh5ef3pm/phone-boot.img?dl=0

After that ran ./unpackimg.sh to get split_img folder. Replaced the boot.img-zImage in split_img folder with newly compiled Image file and renamed it.

./repackimg command & got this new boot img:

dropbox.

com/s/akkauu31xq9bysv/image-new.img?dl=0

But new boot.img is not working on the phone!

I use Ubuntu desktop!
[Android Software Development] ashyx:
You haven't mentioned the fact that you or something else has modified the DTB?

Have you tried booting the stock boot.img with this DTB?
[Android Software Development] @ta:
I modified the kerne source then compiled it.

actually the compilation gave me just Image (not zImage or zImage-dtb).

I replaced the Image with the boot.img-zImage file I got after unpacking the phone boot.img.

The phone has stock firmware.
[Android Software Development] osm0sis:
Does unpacking the stock firmware boot.img then repacking without any changes produce a working image?
[Android Software Development] ashyx:
The DTB hasn't been modified at all?

Someone or something has removed the dm-verity flags from the DTB.

I highly doubt that AIK is responsible nor do I believe AIK is causing your issue.

Did you root this device prior to pulling the boot.img?

I have downloaded and checked the stock DTB for G960NKSU1ARG5 (latest kernel source available) and G960NKSU1ARJ2, both have the flags intact.

I would suggest that you use the stock boot.img from the firmware and also ensure your firmware is stock untouched and the same build as the kernel source.

Which firmware build are you running?

Also as [MENTION=4544860]osm0sis[/MENTION] states the quickest test is a simple unpack/repack of the stock boot.img.
[Android Software Development] @ta:
Ohhh, I'm sorry! I did't get what you mean at first!

You are right!

I flashed twrp and dm-verity, in order to flash the boot.img with twrp because phone does not have fastboot mode and fastboot does not recognize the phone!

I pulled the boot.omg after rooting the phone!! :( (I'm totally new in this field)

So, you mean I must unroot the phone then pull the boot.img?
[Android Software Development] ashyx:
Samsung devices do not support Fastboot they use Odin to flash firmware.

You can download the appropriate boot image below:

https://desktop.firmware.mobi/device:1982

I suggest starting as stock then flashing the custom kernel.

You 'may' have to remove dm-verity again for the device to boot.

Out of interest what did you use to patch the boot.img and remove dm-verity?

However your first port of call should be an unpack and repack of the stock boot.img to determine where the issue lies. I doubt it's AIK.
[Android Software Development] @ta:
I appreciate for your help.

flashed twrp with odin and installed no-verity-encrypt file using twrp.

dropbox.com/s/85cak5l8c2zx8pd/no-verity-opt-encrypt-6.0-star.zip?dl=0

---------- Post added at 09:37 AM ---------- Previous post was at 09:31 AM ----------

thanks for your reply.

I did a mistake, I pulled boot.img after rooting the phone.

I will try again with stock boot.img
[Android Software Development] osm0sis:
No, try with the rooted boot.img instead so you don't run into dm-verity issues. Take your rooted boot.img, unpack and repack in AIK with no changes and see if it still boots.
[Android Software Development] ashyx:
Good thinking batman. :good:
[Android Software Development] @ta:
I unrooted the phone by flashing stock firmware (build number: G960NKSU1ARJ2) and then flashed the stock boot, the phone rebooted without any problem.

Next, I unpacked and repacked (with no changes)the stock boot.img with AIK and flashed it using odin , but this time phone gives error and even if I try to flash boot as I did in first step, phone gives the same error.

Error is:

Verification failed

unable to restart your device. the integrity verification has failed. you need to reset your device to factory default settings.
[Android Software Development] ashyx:
As [MENTION=4544860]osm0sis[/MENTION] pointed out it seems you are running into dm-verity issues.

You have several choices, patch it manually, install Magisk or as suggested use the pre-patched boot image from the device without making any changes.
[Android Software Development] @ta:
I used the pre-patched boot image and without any changes it worked on phone.

I found where is my problem, I have changed the kernel of S9 with build number : G960NKSU1ARC7

but the firmware on the phone is : G960NKSU1RJ2

so, version of kernel image that I'm using in AIK is different from firmware!

I can not find the source code of G960NKSU1RJ2 in SAMSUNG web-site.

also I couldn't find the G960NKSU1ARC7 firmware.

Would you please let me know, where can if find G960NKSU1ARC7 firmware or source code of G960NKSU1RJ2?
[Android Software Development] ashyx:
You will have to contact Samsung to request the updated kernel source.
[Android Software Development] ahhl:
hi

what is the commad to execute repackimg.bat

i just double click repackimg, it create image-new.img but the size is half of the orignal boot.img.

have i done something wrong.

using windows 10 with aik 3.2
[Android Software Development] alecxs:
the size may vary, but the content is the same. if size is important, you can enlarge the file with zero bytes:

- rename file to boot.part1

- create empty file (512 bytes × n)

- concatenate the files

android_win_tools\dd.exe if=/dev/zero bs=512 of=boot.part2 count=9999
copy /v /y boot.part1 /b + boot.part2 /b image-new-2.img /b