yashsingh1/xdaforums huggingface dataset:
[Android Software Development] seh6183:
Yep perfectly. Unpack, repack, broken. I suspect that it has something to do with lzo compression? Also what is that other generated file for lol

---------- Post added at 02:26 PM ---------- Previous post was at 02:24 PM ----------

boot.img zip attached to previous post
[Android Software Development] osm0sis:
If it's lzo then that's the compression you're using. ;)

Try repackimg --original from the command line, see if that's broken too.
[Android Software Development] seh6183:
--original works and it generated a new .img but did not generate a ramdisk-new.cpio.lzo. Reflashing now to test.

---------- Post added at 03:06 PM ---------- Previous post was at 02:58 PM ----------

Same thing "kernel is not seandroid enforcing" and won't boot.

---------- Post added at 04:04 PM ---------- Previous post was at 03:06 PM ----------

I have tried every varition of compressison possbile and nothing :(
[Android Software Development] osm0sis:
Okay yeah, --original should produce an image that is literally the same (identical checksum) as the factory image/ROM build trimmed image, by using the original ramdisk.

That narrows it down to unpackbootimg and mkbootimg. Totally unrelated to the ramdisk. Must be something missing from the image. Maybe the cmdline. I'll look into it. Can you try it with AIK-mobile?
[Android Software Development] shoey63:
Try unpacking and repacking AS ROOT.
[Android Software Development] jurben:
Few days ago i on windows 10 amd x64 unpacked my device' boot.img, than make a litle editing and repack and flash the new img succesfully and had no problem.

Today i want to make few more editing on ubuntu x64 on the same machine. Unfortunately i can't unpack the repacked img, but when i backup the flashed one from device i can unpack it succesfully.

I tested unpacking it then repacking and unpack the new img and the error occur .. Weird.

I tested that on windows and the error didn't come out.

Weird.
[Android Software Development] osm0sis:
Shouldn't matter on Windows because of mkbootfs. But yeah, I think we already ruled out the ramdisk. :confused:

I need him to try with AIK-mobile to see if it's just another issue of batch files handling strings poorly and something getting messed up in the cmdline or something when it rebuilds. Looking into it today.
[Android Software Development] osm0sis:
You made some mistake somewhere down the line here...

kernel = boot-selinux.img-zImage
ramdisk = boot-selinux.img-ramdisk.cpio.lzo
cmdline =

Chris@Homebase /cygdrive/c/Users/Chris/Documents/Projects/Android Image Kitchen
$ md5sum *.img
d6b225e7216a93b5d9e9142beaeaf5b3 *boot-selinux.img
d6b225e7216a93b5d9e9142beaeaf5b3 *image-new.img

So --original produces a literally identical file, your ramdisk is lzo, there is no cmdline to mess up, and the problem does lie in the ramdisk. I still need you to try with AIK-mobile. Might be an issue in mkbootfs or lzop.
[Android Software Development] seh6183:
Will be flashing with mobile in the next couple hours. On the road.
[Android Software Development] osm0sis:
[MENTION=264630]acer73[/MENTION] Looked into it more and the 512KB cutoff isn't actually part of the Android image standard, but an arbitrary limit CyanogenMod imposed when they created unpackbootimg. I'm going to raise the limit to 4096 to support your device's images (and others like it) for the next release.

https://github.com/osm0sis/mkbootimg/commit/19cc43d35ea95ce9219b556d5231df19e139bb9c

There's still the potential that chopping off the pre-header data is a terrible idea, but there are other devices within the 512KB cutoff that this happens on with no ill effects (some HTC and AMLogic devices) so we might as well support it, since otherwise the image is standard.
[Android Software Development] seh6183:
Flashed with AIK mobile and same exact outcome as windows. Unpacked, didnt touch a thing, repacked. Renamed to boot.img, packaged in my rom zip, flashed entire rom with new boot.img included. Hangs at first screen saying seandroid kernel not enforcing in red at the top. Never goes further.

It also generated a "ramdisk-new.cpio.lzo" file just like windows does. Is this a good or bad thing? What is this file for?

Damn I really want this to work lol I love this script, so easy to use.
[Android Software Development] osm0sis:
As I said, that's your ramdisk. It's normal. Not sure where the problem lies. Do you have access to Linux? Using AIK-Linux with the --sudo command would possibly rule out mkbootfs.
[Android Software Development] seh6183:
I have a pretty low IQ so please bear with me lol

If the LZO file is being generated outside of the .img file, wouldn't that not be the problem? Shouldn't the .lzo file somehow be packed in with it?
[Android Software Development] osm0sis:
It is packed with it into image-new.img, that's what the script does: repacks the ramdisk into ramdisk-new then mkbootimg packs the original split zImage with ramdisk-new; if it weren't then the file size wouldn't be so close. :silly:

Anyway, I did a quick search and found some more info on the Samsung bootloader error you provided:

Meaning, that error isn't even relevant. So now we still need to figure out why it isn't booting. Again, comes down to mkbootfs and lzop. Do you have access to Linux to try AIK-Linux with --sudo to unpack and repack?
[Android Software Development] seh6183:
The thing is, that kernel that I am using is already a modified kernel. Before I unpack it, it flashes and boots without any warning whatsoever. I unpack it, repack it, flash it. No boot and the warning is there. No changes made to the kernel.
[Android Software Development] osm0sis:
Right, but those posts suggest there is special signing to be done to avoid that message.
[Android Software Development] seh6183:
Hmm maybe that's the problem. Maybe the kernel needs to be built and then somehow signed, kind of like a system apk.
[Android Software Development] osm0sis:
Exactly. But everything says it should still boot, hence that error is unrelated to it not booting.
[Android Software Development] seh6183:
Got it. I'll gladly ignore that message as long as it boots.
[Android Software Development] raimondomartire:
Thanks a lot mate. Where I can take new mkbootimg.exe (for windows) I must compile or you have already?
[Android Software Development] osm0sis:
It'll be in the next release. See your PMs for a test executable.
[Android Software Development] seh6183:
Osmosis do you have access to Linux? You could try with the boot img I uploaded to see if anything changes. Send me back the packed img and I can test.
[Android Software Development] raimondomartire:
Guys our [MENTION=4544860]osm0sis[/MENTION] is a genius so work on MAte 8. Thanks again sir
[Android Software Development] osm0sis:
Okay, I did ./unpackimg.sh --sudo boot-selinux.img and then ./repackimg.sh with no changes on AIK-Linux. [MENTION=3843055]seh6183[/MENTION], give the attached (zipped) image a shot.

[ Attachment removed ]
[Android Software Development] seh6183:
Its funny how fast things can change. The note 5 is for sale as I have a Nexus 6p arriving today. However I will be using your tool for that phone as well, so Ill be sure to come back here and bug you when I can't unpack the kernel on that device LOL

No seriously, does this even work for Marshmallow yet?
[Android Software Development] osm0sis:
Test the image and report back please. I'd like to know if the problem lies in mkbootfs.

What kind of a flippant question is that? Of course it supports Marshmallow, read the changelogs.
[Android Software Development] seh6183:
Eh I don't read changelogs, too much work. Ill flash the image in just a bit here. Have to flash modded recovery back first.

---------- Post added at 10:47 AM ---------- Previous post was at 10:27 AM ----------

Building rom now. Will have it flashed in 10 minutes and have your answer.
[Android Software Development] seh6183:
Okay flashed, sorry for the delay. Zipped rom with your new .img and same exact result. Never gets passed first splash screen and says the seandroid enforcing notice at the top.

If you're interested I can continue to test with you, but if the phone sells its gone.
[Android Software Development] osm0sis:
Bizarre. Wait.. you said when you used repackimg --original it still didn't work for you, right?
[Android Software Development] seh6183:
Correct. The strangest part is that we are unpacking the kernel and repacking it without mods. The before and after kernels are exactly the same size down to the byte, but one works and the other doesn't. So strange.
[Android Software Development] osm0sis:
Unpacking and repacking will always cause a change to the checksum due to the date of repack being included in the archive, even without modification.

Byte size isn't really the most important factor here; I did a repackimg --original and it produced a file with an identical checksum. That means the file is exactly the same. Literally the same as unmodified. So provided you flashed the correct file when you tried that, that suggests that it's not an issue with my kitchen at all, it's an issue with the process you're using to flash the resulting files.
[Android Software Development] seh6183:
I'm going to try something here in a bit. Will post the results when finished.
[Android Software Development] seh6183:
Got it. Repacking with --original does work, don't know why it didn't the first time. I just tried --original and it flashed 2 different ways. Flashed on it's own and then built directly into my rom. All working.

Even though this works, would I be able to make changes to the ramdisk and then repack using --original? Or would using --original wipe out all my changes and restore it back to stock? I don't quite understand exactly what is happening by using that command. Thanks a million.
[Android Software Development] osm0sis:
--original uses the ramdisk it split from the .img which is why it's literally identical with no changes. Still not sure why normal repacking doesn't work for your device, obviously something's going on in the ramdisk that not even unpacking/repacking as root on Linux can resolve, which is a new one.

My best suggestion is to look into the build process that created the original ROM .img and see if there's anything extra in there we're missing. If it's only that signing then perhaps the bootloader's more strict than previously on your device and doesn't allow unsigned at all anymore.

Edit: Hey [MENTION=4898097]arter97[/MENTION], I see you build a Note 5 kernel.. Any ideas what we're missing here that's causing a hung boot with a "kernel not seandroid enforcing" message after an unpack+repack with no changes? Thanks for any help you can provide! :)
[Android Software Development] seh6183:
Hilariously this has been his kernel that we have been trying to take apart the whole time. I reached out to him and another kernel dev with no response. I believe they are afraid of giving information to potential competition. His kernel is amazing and I had no intentions of releasing a rom with his kernel, it was just for personal use.

I was trying to edit a script in the kernel which is building Knox folders on each boot. I wanted to just take one line out of the init.d script to fix it. That's all I was doing.

Being that I am typing this from my brand new nexus 6p I'm not sure how much more energy I will have for the note 5. But I will try to test if possible.
[Android Software Development] osm0sis:
[MENTION=3843055]seh6183[/MENTION], seeing as you had an issue with your flash of --original originally, and were mistaken, can you double check that my root repack (attached on the previous page) actually doesn't work? Thanks in advance.
[Android Software Development] SidRobo:
hi. sorry for replying here as a noob but i have a question

i flashed android 6.0.1 beta rom to my s6 edge... and still there isn't twrp that be compatible with new sboot so is there anyway to edit ramdisk of twrp 2.7.8.1 that is compatibe with my device in android 5.1.1 and old sboot, to be used in 6.0.1 ?
[Android Software Development] osm0sis:
How would I know? No way to know unless you try.
[Android Software Development] kaotd99:
kaotd99@NokiaX2VN:~/AIK-Linux$ sudo sh unpackimg.sh boot.img

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

Supplied image: boot.img

Setting up work folders...

Splitting image to "split_img/"...
BOARD_KERNEL_CMDLINE console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 androidboot.selinux=permissive
BOARD_KERNEL_BASE 00000000
BOARD_NAME
BOARD_PAGE_SIZE 2048
BOARD_KERNEL_OFFSET 00008000
BOARD_RAMDISK_OFFSET 02000000
BOARD_TAGS_OFFSET 01e00000
BOARD_DT_SIZE 129024
/home/kaotd99/AIK-Linux/bin/magic, 1293: Warning: string extension `l' invalid
file: could not find any valid magic files!

Unpacking ramdisk to "ramdisk/"...

Compression used:
Error!
kaotd99@NokiaX2VN:~/AIK-Linux$
[Android Software Development] osm0sis:
Don't quote the OP. The magic from file can make Linux file binary angry. I thought I'd removed all the troublesome entries since I had it working on my Ubuntu VM..

You're using v2.0?
[Android Software Development] kaotd99:
of course !
[Android Software Development] osm0sis:
Okay. Please edit your post to remove the quoted OP.

Then edit AIK-Linux/bin/magic and go to line 1293 and remove the entire "# Android Backup archive # From: Ariel Shkedi" section that line is a part of. Let me know if AIK-Linux/unpackimg.sh executes correctly after.

If you want to do it as root, do: ./unpackimg.sh --sudo boot.img
[Android Software Development] kaotd99:
root@NokiaX2VN:/home/kaotd99/AIK-Linux# ./unpackimg.sh boot.img

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

Supplied image: boot.img

Setting up work folders...

Splitting image to "split_img/"...
BOARD_KERNEL_CMDLINE console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 androidboot.selinux=permissive
BOARD_KERNEL_BASE 00000000
BOARD_NAME
BOARD_PAGE_SIZE 2048
BOARD_KERNEL_OFFSET 00008000
BOARD_RAMDISK_OFFSET 02000000
BOARD_TAGS_OFFSET 01e00000
BOARD_DT_SIZE 129024

Unpacking ramdisk to "ramdisk/"...

Compression used: gzip
2127 blocks

Done!
root@NokiaX2VN:/home/kaotd99/AIK-Linux# ./repackimg.sh boot.img

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

Packing ramdisk (as root)...

Using compression: gzip

Getting build information...
kernel = boot.img-zImage
cmdline = console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 androidboot.selinux=permissive
board =
base = 00000000
pagesize = 2048
kernel_offset = 00008000
ramdisk_offset = 02000000
tags_offset = 01e00000
dtb = boot.img-dtb

Building image...

Done!
root@NokiaX2VN:/home/kaotd99/AIK-Linux#

Thanks! It's work correctly :D
[Android Software Development] osm0sis:
Bugfix/maintenance releases up! These add support for devices with pre-header data greater than the original arbitrary unpackbootimg seek cutoff of 512KB; I have raised this to a reasonable 4096 which is the highest I've seen on an image. I went ahead and sync'd up everything else to AOSP master and the CM13 branches. :good:

Android Image Kitchen v2.4:

- Update mkbootimg, unpackbootimg and mkbootfs binaries from my repos.

- Update to the latest Cygwin binaries and libraries.

- Fix slimmed magic file (from file 5.25) for certain file binaries.

AIK-mobile v2.1 + AIK-Linux v2.1:

- Update mkbootimg, unpackbootimg and mkbootfs binaries from my repos.

- Update busybox binary (still 1.24.1) with the latest official patches (AIK-mobile).

- Fix mounting/installation and improve systemless root detection/support on CM Simple Recovery (AIK-mobile).

- Fix slimmed magic file (from file 5.25) for certain file binaries.

More on my own build changes in the commits here: https://github.com/osm0sis/mkbootimg; https://github.com/osm0sis/mkbootfs.

Installation information and details on each edition can be found in the OP for Win32 or the AIK-mobile and AIK-Linux initial release notes.

If you are reporting a problem with your device, please clearly state your device name and model/variant as well as provide a link to the image file.
[Android Software Development] seh6183:
Sorry I reflashed this 2 days ago but forgot to tell you. Still doesn't work sorry. Certainly did not make any mistakes. During the flashing process all readouts display on screen as if nothing is wrong and then it fails to boot.
[Android Software Development] pabloc97:
Hi, i'm young dev and i want to compile my kernel to work on lg g3, but when i compile using this.. i get system security error...what can i do¿?
[Android Software Development] osm0sis:
This tool doesn't compile at all, it only allows you to edit the ramdisk. Since you're using LG G3 my guess is you need to "Bump" the resulting image file before flash. Google that and you'll find the extra tools required.
[Android Software Development] pabloc97:
i bump my boot as you said using this tool http://xdaforums.com/lg-g2/orig-development/tool-bump-sign-boot-images-t2950595 but.. i can't, it get lopp i'm waiting a long time for public my rom but i can't.. can you unpack and repack and bump if i ask you? please, is the only i need to finish... if yes, send me a private please. i can send you my boot.img and i only want ot replace 2 files in ramdisk.. and then repack and bump...

regard my friend
[Android Software Development] osm0sis:
What little free time I have is pretty much already spoken for with my various projects, so I can't really be taking on everyone else's. Research/test more and ask in the bump thread.
[Android Software Development] pabloc97:
Thanks a lot, i rode all the post i send in the last reply, and i find the solution and work great! I only need to replace one of this.. And great! Thanks again

Enviado desde mi LG-D855 mediante Tapatalk
[Android Software Development] Singular777:
Spreadtrum

Hi all! Help me please, my phone is HTC 326g, don't work recovery after compiling this tool, even unpack and pack files without changing the tool is still not working. Sorry for my bad english, i'm from Russia.

Всем привет! Не работает recovery на HTC 326g после сборки с помощью данной программы, даже если распаковать и заново запаковать с помощью этой программы всё равно не работает, помогите!
[Android Software Development] pendor24:
Hello

try kali linux should run

( It sits on xda )
[Android Software Development] osm0sis:
Attach the recovery.img please. What AIK were you using?
[Android Software Development] Singular777:
I'm using Android Image Kitchen v2.4 for windows and Android Image Kitchen v2.1 for linux, result one, after unpack and repack no recovery enter.

P.S. CPU= spreadtrum sc7731
[Android Software Development] osm0sis:
Please try AIK-Linux with ./unpackimg.sh --sudo recovery.img
[Android Software Development] Singular777:
thank you for answer, but this don't work...after repacking (with sudo) problem remained
[Android Software Development] osm0sis:
I'm not sure then, this is the second otherwise working image reported to not work after a simple repack. There must be something going on we're not aware of currently. :confused:

Edit: [MENTION=7288398]Singular777[/MENTION], does ./repackimg.sh --original produce a working image?
[Android Software Development] osm0sis:
[MENTION=7288398]Singular777[/MENTION], okay, this one is actually pretty straightforward I think. Different from the previous reported ramdisk that didn't make it through a repack (causing SELinux failure from that device's bootloader). Looking at your image, it's one that's only newly supported by my latest unpackbootimg patch:

Splitting image to "/split_img/" . . .
Android magic found at: 1024

My new unpackbootimg only displays that when the file deviates from the standard, which has Android magic at 0. Looking at the .img itself there is something looking like a signature at the beginning that is probably necessary on your device to boot:

SPRD-SECUREFLAG.
................
CODE....PC......
VLR:............

<28 blank lines>

ÿVLR%´õêX±‡Ð.÷Yi
ìcúD¹1Ý¨ª£hUµ.'á
Š¨.ÈÑ'É.ñS.r/€¼.
sSú.Óu®Ñ¨©‹Æ¥Ó`€
É¯‚ã|’.Ã‰M..ö<¦)
.øÅÇóHƒOxE¨.*.s.
Ô3„YáèšPÓS‘“‡t.˜
xËP´³J¬ÞŽK6.ál.ö
6¹D+.....*†.....

You can try to copy that chunk out of the original file in a hex editor and prepend it to your image-new.img but mileage will definitely vary for something like that device to device. That hash/data might be a checksum of the rest of the image, in which case you're out of luck unless you can hunt down the signing tool for your device to use after my tool, before flashing. Good luck!

Edit: Looks like Huawei Honor Bee also falls into this category, a wealth of useful information can be found here: https://forum.hovatek.com/thread-15695.html
[Android Software Development] munimkazia:
Hey.. Thanks for your scripts, they are very helpful.

I've been using them to make custom boot images for a lot of devices at work.

However, I've been trying to do this for Moto X 2nd gen with android 6 update, and the wifi doesn't work after flashing the repacked image. If I supply --original to the repack script, it works, but if I simply unpack and repack without touching any file inside the ramdisk directory, the wifi doesn't work (it just keeps trying to switch on without any success).

I am using the latest AIK-linux provided in the OP, but I have compiled the binaries from github, just to make sure I have the latest binaries.

Here is the boot image: dropbox.com/s/uo82lhg0ljbn42x/boot.img?dl=0

Update: I was playing around with the options, and I tried the --sudo flag for unpacking and the --level 1 flag for making the boot image, and everything seems to be working now! Thanks anyway for this awesome tool.
[Android Software Development] GTDarthYoda:
I'm blind where are the batch scripts for the Windows version?

Edit: NVM just completely blew past the folder that had them in it lol
[Android Software Development] osm0sis:
Compared a mkbootfs-built ramdisk for your image to the original and found the following differences:

diff rootorig.txt mkbootfs.txt
12c12
< -rwxr-xr-x 1 root root 2794 Feb 26 init.class_main.sh
---
> -rwxr-x--- 1 root root 2794 Feb 26 init.class_main.sh
35c35
< -r-------- 1 root root 5125 Feb 26 module_hashes
---
> -rw-r--r-- 1 root root 5125 Feb 26 module_hashes
113c113
< -rwxr-x--- 1 root root 198816 Feb 26 qe
---
> -rw-r--r-- 1 root root 198816 Feb 26 qe

So my best guess is that module_hashes gaining read/write permissions, or the /xbin/qe binary becoming non-executable are at fault, since init.class_main.sh has to do with radio/multiSIM, not WiFi, and its permissions are still pretty much intact.

A quick Google shows qe is a root-checker Moto uses and module_hashes contains a whitelist of system module sha1sums the kernel can safely load. Probably the WiFi driver for your device is a system module, and module_hashes permissions changing somehow interferes with the loading process. I'll see if there are any mkbootfs patches for this, and if not I'll see about making one myself. :good:

Edit

: Okay [MENTION=7299016]munimkazia[/MENTION], since you're compiling your own binaries, try with this new patch:

https://github.com/osm0sis/mkbootfs/commit/35beba3e5f48c74c779e70d046fd792cea44ea70

Also, I just noticed a little fix required at the top of AIK-Linux's unpackimg.sh when working with --sudo repeatedly and no cleanup.sh in between:

cleanup() { $sudo rm -rf ramdisk split_img *new.*; }