yashsingh1/xdaforums huggingface dataset:
[Android Software Development] DarkHeart Z:
Don't use mingw compiler if it's not recommened

Yep . got it man . this two are my new target . I just found out one tremendous issues with mingw compiler . i compiled mkbootimg and unpackbootimg . I tried extracting and recompiling boot.img manually . But it failed . Always the no kernel found error occured ; even if the kernel binary lies right infront of mkbootimg . But it always showed this error . i guess thats because some parameters got avoided while compiling through mingw . That is why this executables had functional errors . From now on ; i think it's best if we stick with cygwin's built in gcc and cross compiler .
[Android Software Development] Geko45:
Tried to do something I thought would be simple. Wanted to put a few more utilities from my ROM into my recovery so that they would be available if I needed them. Unpacked TWRP, copied the statically linked binaries I wanted over into the ram disk, and repacked and flashed with a dd into the recovery partition. When I boot into recovery, I can see the files I added in the /sbin directory and they show as executable but if I try to run them I get a "sh: filename: not found" message. I know they can work because when I mount the system partition and cd into the /system/xbin directory (where I grabbed them from) they work fine.

Any idea on what I'm missing here?
[Android Software Development] osm0sis:
The sh command is for scripts when used sh ./filename. Check permissions and try running the files directly with ./filename or sh -c ./filename

If that doesn't work maybe they aren't actually statically linked after all.
[Android Software Development] Geko45:
Yeah, that's what I'm doing. I type "./filename" to run the binary (not script) file.

And if I copy the binary from my system partition to the /sbin folder it works fine (but then, of course, it's gone after a reboot since that's the ramdisk).
[Android Software Development] osm0sis:
Try running the binaries you added to /sbin in your edited ramdisk, but with system mounted. If they work then it was a linking issue and you need to find actual static binaries.
[Android Software Development] Geko45:
Ok, yeah, that was it. They weren't statically linked after all. They only worked when /system was mounted.

Thanks!
[Android Software Development] osm0sis:
Wow! Look at those download counts getting pretty high.. must be time for another feature release! ;):D

I had originally planned on one major v3.0 release, but it will now be split into incremental updates for each additional image type I have planned, leading up to a v3.0 release, since each has taken significantly more R+D time than I'd hoped (basically I've had to rewrite or at least patch a number of tools and am researching and writing one pretty much from scratch at the moment), and I didn't want to sit on the updates/fixes I've made to mkbootimg/unpackbootimg and mkbootfs any longer.

I'm updating Cygwin (slightly, see below) and finishing up some things on it still but I'm excited to release what I have so far, so I'm hoping to have it ready later today or tomorrow.

Happy new year all! Thanks to all who brought the download count up to ~80,000 for Windows, ~16,500 for Android, and ~7,500 for Linux (remember I do this all for free.. haha I wish I had even a penny donation for every download.. :p). Here's to another year of hacking Android! :):cowboy:

REQUEST FOR INPUT:

Cygwin has dropped Windows XP support after Cygwin 2.5.2 and is now up to 2.6.1, so, open question: Should I freeze the libraries and binaries to maintain Windows XP support for AIK indefinitely, or, should I continue to update them to make Vista the earliest Windows supported?

I'll likely freeze them for XP support until after AIK v3.0 so there's lots of time to voice your opinions. :good:
[Android Software Development] binz2016:
Mate9 cannot work with AIK

Hi God,

I found it cannot work on Mate 9,

I just unpacked the boot.img, and then repacked directly without changing anything, but the phone cannot boot, did you find the same issue on Huawei Mate9 ?
[Android Software Development] shoey63:
[MENTION=4544860]osm0sis[/MENTION] hasn't quite achieved that status yet, but I'm sure he's working on it?
[Android Software Development] osm0sis:
Please upload the original boot.img file as the OP states. I'll take a look and see if I can fix it for the next release.

Speaking of which - general update notice for everyone - looks like I got a bit ahead of myself. AIK-Windows is nearly done (needs testing), but the AIK Build Farm took a lot more work yesterday than I'd planned, so I'm behind on AIK-mobile and AIK-Linux and probably won't have the release finished and tested until next week at the very earliest. Sorry for the bad ETA! (Which is why you should never give ETAs! :p)
[Android Software Development] Tkkg1994:
I've uploaded latest boot.img of the huawei mate 9 for you. Oddly enough phh superuser can unpack and repack the boot.img during root process without generating that bootloop problem. Hope this helps somehow

Wish you a happy new year as well and no problem about the ETA, we all know you do this in your spare time!
[Android Software Development] binz2016:
image

Yes, I also found that superuser can unpack/repack boot.img succesfully during rooting, i upload the Boot.img, this is from Mate9 AL00 devcie, version should be B125
[Android Software Development] osm0sis:
Thanks guys! In recovery cpio can unpack and repack the ramdisk contents as root exactly as they were, but since Windows and booted Android are a different story for permissions and users we have to rely on mkbootfs, and this can sometimes lead to issues when OEMs add weird things to the ramdisk - for example, some Motorola devices would lose Wi-Fi, so I had to add this: https://github.com/osm0sis/mkbootfs/commit/77dff554ce108cd77ba270d0cdff5e249169eada

Hopefully it'll be a similarly simple matter for Huawei. :)

Do either of you have access to Linux? AIK-Linux when used with the unpackimg.sh --sudo switch should be unaffected by these types of issues, since it also then uses cpio and root. Maybe one of you can verify.
[Android Software Development] binz2016:
I tried on Linux, but with the image new packed, the device cannot boot normally either.
[Android Software Development] osm0sis:
With `unpackimg.sh --sudo boot.img`? That switch is crucial.
[Android Software Development] binz2016:
Yes, i already did that, but the device still cannot boot normally, boot loop.
[Android Software Development] osm0sis:
Does repackimg --original create a working image?

There's 4096 bytes of pre-header that appears to be non-standard image signing (similar to the Mate 8), and even though second_size is 0, second_addr differs when repacked. :confused:
[Android Software Development] Tkkg1994:
I'm sorry my mate 9 is currently in repair, can't test anything at the moment :/
[Android Software Development] dreas74:
hi guys,

i have a bq aquaris m8 and the boot image is very tricky.

i tried to unpack with the tools from osmOsis but it fails.

i opened a thread for this : https://xdaforums.com/android/general/root-help-to-root-twrp-recovery-bq-t3536170

attached my boot image for development.

unlocking works but unpacking fails:

please have a view on this.

thanks in advance

dreas
[Android Software Development] osm0sis:
Tricky indeed! This is one of the crazier boot.img files I've ever seen.

You say it's Loki'd but I don't see any sign of that in what you uploaded. Is this the original untouched boot.img?

It's got a pre-header signature much like the Huawei Mate devices, but it's also got 16448 of pre-header instead of the 4096 maximum anything I've seen before now has had. For now, try using a hex editor to chop out everything before the ANDROID! header. That will get you an image that will unpack.

Then you have the MTK headers in there to contend with. My next version of the kitchen will support that using dd and my new mkmtkhdr tool, but for now you can chop them off (512 bytes from each). That will at least allow you to unpack the ramdisk manually from that point.

Edit: Next AIK will handle that massive BQ pre-header as well - https://github.com/osm0sis/mkbootimg/commit/c880f45a28dd5b029e16d0e1428232f88b42eb35 :good:

Hopefully that signature isn't required for booting (same concern I've currently got for the Mate 9 - not sure how phh/Chainfire would have gotten around that either though).

Edit 2:
[Android Software Development] dreas74:
hi osmOsis,

thanks for your fast answer.:good:

well, to your questions, yes, it is the untouched boot.img. i dont know what the correct sign for the boot.img is.

here find you the complete firmware from bq: http://storage.googleapis.com/otas/...016-10-24_11-14-25-FW-7019021406647539512.zip

in generally, the firmware is crazy stuff for this little company! iam wondering about that. but it's a challenge^^

thanks for the tipps with the hex editor. i will it tastet.

dreas
[Android Software Development] osm0sis:
[MENTION=7405420]binz2016[/MENTION] can you tell me if repackimg --original creates a working image? Also I need to know if a dump of the boot.img AFTER SuperSU has rooted it will repack and boot correctly.
[Android Software Development] noob4598:
Hey dude thanks for this great tool. I have learned more about kernels and ramdisks in a couple weeks unpacking with AIK mobile and digging through files than I have in a year trying to learn how to compile one. I need some assistance if anyone can help. I have a Tmobile Note 4 (N910T) and I can use every kernel that is made for the international Note 4 (N910F) except for 1. And it just so happens to be the only one I want. After unpacking I have discovered that it is built on sprint source code. Which should make it more likely to have 0 issues on my phone. I can boot the kernel and it will run flawlessly as long as it's on airplane mode. And when I turn airplane mode off it will run fine until I try to use mobile data. If I open the Internet it will load the whole page until the loading progress bar reaches the very end then the phone reboots. Same with play store. I have been working on this for months trying to find the issue and now am to the point of pulling my hair out so I figured I would ask for assistance. Are there ways to adjust the network and WiFi properties outside of the compiled zimage or is there a way to rebuild the boot.img to my variant with the precompiled zimage ? Or can anyone give me some advice/tips/even knowing I'm wasting my time would be helpful haha. Thanks in advance.
[Android Software Development] osm0sis:
Try a ramdisk from a working variant with the zImage from the one you want.
[Android Software Development] noob4598:
Thanks for the quick reply. I have tried but it wasn't a stock one. It was from a custom kernel (beastmode) that I think is basically oc modified stock and is also built on Sprint source but for Tmobile. I have tried every combination of the files that I could imagine. I just can't wrap my head around what network issue could possibly cause a kernel panic so bad it reboots but run perfect except for that.

---------- Post added at 11:52 PM ---------- Previous post was at 11:51 PM ----------

Can I pm you. I wanted to add to my first post that I forgot but I feel like I should ask you first.
[Android Software Development] agalardi:
Hello to everybody and thanks to all for your contributions.

I am trying to change init.rc of an Android STB, but after 2 intense weeks I only have a big headache.

I have access to root with ADB and I got the boot.img with dd (attached).

When I changed system files, STB started a bootloop, but in this case booted and rebooted after a while (seems dm-verity but I couldn't find fstab...).

I succed to extract ramdisk with sukernel tool from SuperSU, after I modified init.rc, recreated ramdisk and I replaced ramdisk again with sukernel tool. All seemed to be fine, but STB didn't boot... It is different to a system change...

Could you help me with this? I really don't know how to get an advance and it's being frustrating. I don't know if it is some kind of checksum, or simply I am doing some wrong change.

Many thanks in advance
[Android Software Development] agalardi:
bootloop again :crying:

- Downloaded AIK for Android

- Unpacked and repacked without any change

- Wrote to partition again with dd

- BOOTLOOP

:confused:
[Android Software Development] osm0sis:
You haven't posted any information about your device so how you expect any help?

image-new.img doesn't do me any good, give me the original unaltered file.

Edit: I see now you left boot-dd.img above, I'll take a look, but you need to tell me more about your device.
[Android Software Development] agalardi:
Thanks for your response... I missed to attach the original boot.img, I just edited my first post to include it, but you can find it attached in this post too.

Device is STB based on Hi3796MV100. I can provide any info, only tell me what.

On my side, I am trying to compare files with hexviewer, but I am thinking that this task goes beyond my possibilities... :silly:
[Android Software Development] osm0sis:
Looks like a pretty standard .img with normal ramdisk contents. Does repacking with repackimg.sh --original result in a working file?
[Android Software Development] agalardi:
YES! just done now and it is my first working repacked boot.img.

If I 'm not wrong --original repack the original ramdisk. How to go to next step? maybe trying different compressions levels?
[Android Software Development] osm0sis:
That narrows down the issue to something with the repacked ramdisk. Do you have access to a Linux box to try AIK-Linux with unpackimg.sh --sudo ?
[Android Software Development] agalardi:
Not just now, but I could try tomorrow with a linux VM at work. :good:

I am a newbee and I am not sure to fully understand all the processes... tomorrow I will prepare AIK for Linux in a Linux VM and I will try unpackimg.sh --sudo.

I can't find manuals for the AIK tools, what "--sudo" does? I mean that currently unpackimg.sh seems to be working because I can obtain the ramdisk and work with it.

Thanks again for your help... those are my first progresses in a couple of weeks and I am excited!
[Android Software Development] osm0sis:
It's in the AIK-Linux documentation linked in the OP, on Linux unpackimg.sh --sudo uses root to preserve ownership and permissions while unpacking the ramdisk, then uses root and cpio to repack so that they remain exactly how the user leaves them.
[Android Software Development] agalardi:
I am using Android version and root with ADB SHELL. Maybe is the same?
[Android Software Development] osm0sis:
Nope. Even with root, booted Android's permissions/ownership situation is too different to allow direct repacks. AnyKernel2 can do it in recovery's /tmp, but for AIK only -Linux with --sudo can do it.
[Android Software Development] agalardi:
Bad news... unpacked from Linux with --sudo, repacked without change and bootloop again :(

Investigating with hex editor I notice something after ramdisk... it seems to be some kind of signature... I will try to append this block to a repacked image.

I will post the result when done
[Android Software Development] osm0sis:
I also tried unpackimg --sudo and compared the ramdisk contents with one repacked with mkbootfs and there were no changes I could see.. so perhaps whatever signing/extra data you're seeing there is the real culprit.
[Android Software Development] agalardi:
bad news... again!

I am almost sure that it is a kind of signature, but appending it to a repacked image results in a unworking img.

Comparing boot.img readed with dd and a repacked one: original one has a block of 900 bytes stating with:

"Hisilicon_ADVCA_ImgHead_Magic_Numv1.0.0.3" and followed by unknown hex "garbage". After that, only zeros to fill the size of the partition.

Copying those 900 bytes does not the trick. I bet that after the text there is some kind of checksum or CRC or hash or .... :silly:

I am surprised to see that I can't find info of that "signature" in the Internet.

Some idea?
[Android Software Development] USBhost:
[MENTION=2475985]agalardi[/MENTION]

Can you get a last kmsg of the failed boot?
[Android Software Development] noob4598:
Does anyone know how I can fix this? Please.
[Android Software Development] agalardi:
I am a little bit newbie... I am not sure if I can.... It is a STB and I have not access to console while boot.

The only way to recover from bootloop is to reflash complete firmware from recovery, and I think that previous kmsg was cleaned... but I am not sure...

If you can explain a little I could try.

Thank you for your help too!
[Android Software Development] USBhost:
what kernel version?

do you have adb (root) access in recovery?
[Android Software Development] agalardi:
KERNEL Version: Linux-3.10.0_s40

Recovery in my STB is only a mode that can be reached touching power-on key 2 times during very first boot stage. Unfortunately, in recovery mode RomUpdate/RomUpdate.bin is readed from USB and flashed.

I am not able to reach any other recovery or even fastboot mode.
[Android Software Development] USBhost:
Can you replace the kernel?

If it boots with this commit https://github.com/USBhost/FIRE-ICE/commit/5f06fe67306781387ebe8b508a1448aded085c0f

Then we know it's a selinux problem.
[Android Software Development] agalardi:
Not tested and I don't know how to do it.

How to replace it if I can't obtain a working boot.img after repacking?.... ohh.. wait... you mean that if the original Kernel is checking the signature, maybe other kernel could boot a repacked image without signature... good view!

What kernel to put? Where to find it? Any other Android 4.4.2 Kernel should be compatible?
[Android Software Development] USBhost:
Do you know where the kernel source for your device is?
[Android Software Development] agalardi:
nope! :( No idea!

Quick search in google for "Hisilicon Hi3796MV100 kernel source" bringme to "https://github.com/hisilicon/linux-hisi".

I will try to read documentation to see if it is for my device.

Edit: I don't know what am I looking for... but I can see 4.1 kernel rc1 in several descriptions... it seems that this is not for me.

I found other source but seems to be for chipset Hi3798 instead Hi3796. In several forums they are referred as "3796/3798" so maybe they are fully kernel compatible: https://github.com/Spitzbube/hisilicon-kernel/tree/3.10.0_s40

If only you can tell me what should I look for...

FOUNDED!!! (I think):

In multiple source files I can find code similar to:

"if defined(CHIP_TYPE_hi3798mv100) || defined(CHIP_TYPE_hi3796mv100) || ...."

the source seems to be in https://github.com/Spitzbube/hisilicon-kernel/tree/3.10.0_s40

I am lost with next steps :confused:
[Android Software Development] agalardi:
I am doing my best... but it is not enough.

I setup a "builduntu" Linux VM, installed "build-essential kernel-package libncurses5-dev bzip2", downloaded the kernel source and ndk.

I am not able to identify the defconfig of my device.

I am not able to know what to do in "make ARCH=arm menuconfig" wizard.

Of course... "make -j3 ARCH=arm" failed to compile.

All those steps are done only to see if I can compile kernel by myself and if it can boot... but really I don't know what I am doing.
[Android Software Development] USBhost:
[MENTION=2475985]agalardi[/MENTION] give me your bootimage i can take the defconfig out of it.

thanks for the source. ill look into compiling it.
[Android Software Development] agalardi:
Thank you very much USBHost, attached you cand find current boot-img.

It can sound desesperate, but I tried to repack a boot.img with a kernel of other device based on the same chip... Of course it didn't work.

I have an unpacked firmware for my device (other recovery.imgs, system files, etc.). I don't know if it can be useful for our task.
[Android Software Development] USBhost:
One more thing can you do this in adb

"cat /proc/version" I want to know what GCC was used to build it.

Also just double checking...

When you unpacked and repacked the ramdisk.

Did the whole thing reboot, stuck at the boot loader image or Android bootimage?
[Android Software Development] agalardi:
Linux version 3.10.0_s40 (hisi01@mk-hisi) (gcc version 4.4.1 (Hisilicon_v200(gcc4.4-290+glibc-2.11+eabi+nptl)) ) #1 SMP Wed Sep 28 14:18:11 CST 2016
u

Every change until now results in a boot loop in the bootloader logo.

The only changes made that result in a "booting system" were changes to system files (ex: build.prop or /system/init.mk.sh or init.bigfish.sh, etc.). But after some time (few seconds) the system rebooted. As far as I know it can me due to dm-verity, but I can't find fstab to change it.... but this is the next war!
[Android Software Development] USBhost:
My word that's an old compiler... July 22, 2009 https://gcc.gnu.org/gcc-4.4/

Thanks for the info. I'll work on it in the morning! Good night and safe journeys.

Edit: you did say Android 4.4 right? If so it's not dm-verity
[Android Software Development] USBhost:
[MENTION=2475985]agalardi[/MENTION] make sure this one does not boot

rename boot.apk to boot.img

btw why do you want to edit your ramdisk?
[Android Software Development] agalardi:
As you said, this new one don't boot either.

The reason to edit ramdisk is, of course, get full access to my device.

I mean that currently I have root with adb, but I need to activate it after every reboot. I want to install oscam or program my own script but it needs to be run as root by cron.d.

I can't enable adb at boot, because when I change build.prop the system reboots. If you said that dm-verity is not the reason, it seems to be some kind of system files check.

If I try to start my script as service in init.rc the result is nothing because init.rc is restored with ramdisk....

For those, ramdisk change is optional... the real goal is full access to the device.

I have access to the unpacked firmware, and one tool (GN-OTT 600-500 & Clone(s) HISI37XX Toolv02) that can unpack and pack again (only unpack tested). I can see several images (boot, recovery, logo...) and "system" directory but I can't find the way to reach the goal.

I don't want to attach full firmware here (300MB), but if you think that you can help, I can provide links.

Many thanks again for your help
[Android Software Development] USBhost:
ok do let's start finding debugging info.

1. make sure there are files in here "/sys/fs/pstore/" if not then look here "/proc/last_kmsg" and if you dont find that then your kernel does not support it. if so just do step 2 and give me that file "/sdcard/good.txt"

2. from a good boot do this "dmesg > /sdcard/good.txt"

3. after trying to write to system, when it reboots copy everything in "/sys/fs/pstore/"

4. now try to boot the boot.img i gave you. let it bootloop then hold what ever button to make it boot to the bootloader. flash the good boot.img reboot then try to copy everything in "/sys/fs/pstore/"

some updates in compiling the kernel.

i was able to compile it from kernel_config.

but... the kernel was only 4MB vs the stock kernel that was 8MB.

so im like 100% sure it won't boot from that.
[Android Software Development] agalardi:
There is not a pstore folder neither /proc/last_kmsg:

root@Hi3796MV100:/lab # ll /sys/fs
total 0
drwxr-xr-x 8 0 0 0 Jan 20 21:28 ext4
drwxr-xr-x 3 0 0 0 Jan 20 21:28 fuse
drwxr-xr-x 2 0 0 0 Dec 31 2013 selinux

root@Hi3796MV100:/lab # ll /proc/last*
ls: /proc/last*: No such file or directory
1|root@Hi3796MV100:/lab #

Attached you can find good.txt.

Going to bed (22:35 in Spain), let me know how to proced without /sys/fs/pstore
[Android Software Development] Jubri:
Thanks [MENTION=2475985]agalardi[/MENTION]! ;)

Regards
[Android Software Development] sagar846:
Can someone please help me?

The boot.img unpacked just fine but when I tried to repack it keeps giving this error.

[sagar@sagar-pc AIK-Linux]$ ./repackimg.sh
No files found to be packed/built.
Error!

I changed the zImage only nothing else was touched.

Edit : I fixed it myself. I hadn't installed the cpio package in my distro. It works fine after I did.