yashsingh1/xdaforums huggingface dataset:
[Android Software Development] osm0sis:
And does ./repackimg.sh --original produce a working image on AIK-Linux?

If so, I might have to start building mkbootfs for Linux even though it's always been fine with just cpio before.

Are you trying AIK-Linux at userlevel or root?
[Android Software Development] USBhost:
No

Rebooted to recovery
[Android Software Development] osm0sis:
Interesting. That suggests mkbootimg is at fault on Linux. Odd because it definitely worked for me on Lollipop images. I'll take a look at the image to see if there's anything special and try it out with my N7 and N5. Are you running things as root?
[Android Software Development] USBhost:
Yes it does work just fine on lollipop

I can pack and repack just fine

But the marshmallow images

Don't work

Also it's if selinux is permissive and or disabled

It boots fine.

When on M preview 2

with my nexus 9 I was trying to make a none force encrypt boot image

I could not. When I tried investigating the problem and looked at the kernel

Log on my nexus 9 it said something about init could not change contacts.

do you want the log?

Edit: no should I?

Edit2: running as root worked [MENTION=4544860]osm0sis[/MENTION]

Was running as root mandatory?

Because I didn't need to run as root for lollipop
[Android Software Development] osm0sis:
Very odd. I only suggested root because I noticed with one of my test images the other day that cpio couldn't unpack it completely due to a rwx------ permission on one of the directories, but unpacking (and repacking) as root of course resolved it. That showed a clear error in the unpack process however.

Are you positive repacking with the --original argument worked as intended (ie. repacked with original split ramdisk), and also didn't create a working image? You having success with root naturally makes me think ramdisk issue again until I can look into it on my own devices...
[Android Software Development] USBhost:
--original worked just fine

But the image was still broken

So yes
[Android Software Development] osm0sis:
Crazy. Hopefully I can reproduce it with my Marshmallow devices so I can experiment with some solutions. :confused:
[Android Software Development] MysteryIII:
Hello,

I am trying to change the partition layout for a Sony Xperia Pro (MK16/Iyokan) to get internal storage onto SD Card. Target of this is: no longer depending on Link2SD, as it is on one hand a great solution but on the other hand a fragile one.

What I am aiming for has already been done for CM12 for the phone but it's very laggy. So I want to "port" it to CM11 which is very stable.

I already asked what I have to do for this and these are the answers I got (Link 1/2):

My question is how can I do it with your tool?

My first attempt was using Archi Kitchen with VirtualBox but I found out it has a different purpose.

Now I tried it with your Kitchen and it seems to be the right way, but not far enough? If I don't get it wrong I need to extract the boot.img even deeper/ extract the files I got from extracting boot.img. Am I right? How can I do it?

Thanks for your help in advance.
[Android Software Development] osm0sis:
Not sure what the procedure for your device is, you'll have to do that research, but yes, this is the right tool for ramdisk modifications.

I'd recommend you look in the CM12.1 ramdisk commits perhaps to see how they did it, then maybe you can bring those changes directly to the CM11 ramdisk.

Next look in the .rc files. Many ramdisks set up SD symlinks in there. A command to bind mount the existing partitions after the fact could also be an option for you to research.
[Android Software Development] fhem:
I'm confused :confused: but that's normal for an old retired guy like me :D. I have used your AIK-linux tool successfully many times on KK and LP builds and I really appreciate your work. I have tried using your latest update on some M builds and I am having mixed results --- similiar to [MENTION=5501864]USBhost[/MENTION]. What is confirmed working or not on M --- 32 or 64, linux or windows, etc. I am trying to figure out if it is me or your Kitchen haha usually me. Thanks in advance for your help. If I can test/help in any way please ask.
[Android Software Development] Rhyn:
Maybe this helps. These were the two mentioned patch:

https://github.com/LegacyXperia/and...mmit/b45d6aa117a8ca8f9aa2a7042adbc4878a19c7d6

https://github.com/LegacyXperia/and...mmit/51e3adcf51b1dc229a5253ff206eaf8e6d68aed9
[Android Software Development] MysteryIII:
Thanks for this, it tells me what I have to do. But there is still the question how to do it. I am no coder. So I only use tools like this kitchen to get a long, but don't know to much about de-/compiling myself.

Also I want to get this feature into a existing ROM/boot.img, because I don't use "naked" CM11 on this phone but a feature rich mod (Carbon ROM / Pac ROM)
[Android Software Development] topjohnwu:
AIK-OSX for Mac

I compiled mkbootimg unpackbootimg and lz4 for OS X, zip in attachment.

Because recent macs only come with x86_64 Intel CPUs, I only included x64 binaries.
[Android Software Development] cam30era:
I am having exactly the same problem, with AIK-Linux, trying to modify the 6.0 boot.img for Nexus 6. Trying to make "encryptable" instead of "forceencrypt".

It worked fine with Android 5.X.X, but with Android 6.0 it loops at the splash screen, then freezes.

BTW: thanks a lot for everything you have done for this so far. It is much appreciated.
[Android Software Development] USBhost:
I was wondering if I was the only one :confused:
[Android Software Development] osm0sis:
Haven't had time to look into it myself yet, but please try to run AIK-Linux as root with sudo to see if it resolves it reproducibly. Having a reliable workaround is better than nothing. :)
[Android Software Development] cam30era:
After I unpack it as root, I have permission issues (padlock symbol in corner of file). Says "you can not perform this operation because you are not the owner", when I try to open fstab with gedit.
[Android Software Development] USBhost:
Use nano as root
[Android Software Development] cam30era:
II don't know what that is, or how to do it.
[Android Software Development] USBhost:
sudo su

nano "location of fstab"

In terminal
[Android Software Development] cam30era:
First, I want to thank both of you for your help.

Secondly, I'm glad to report that running AIK-Linux as root does work. I was able to make the kernel encryptable, and it booted fine.

Thanks, again.
[Android Software Development] :
+1 for nano.
[Android Software Development] osm0sis:
So sudo gedit?

Edit: haha way late to the party

Thanks guys, I've added a note about the workaround as a PSA to the latest release post. :good: :)

Hopefully I can reproduce it; I'd like to hex compare the original file, an --original repack as user, and an --original repack as root, since normally they'd all be identical.
[Android Software Development] cam30era:
Attached is the stock, unmodified 6.0 (Marshmallow) boot.img for Nexus 6. (Shamu MRA58K)

Edit: I've also attached copies of the user repack, and root repack boot.img.
[Android Software Development] cam30era:
FWIW...

The factory image for the Nexus 5X has been posted. I was curious to see if encryption was handled the same way as Nexus 6 (Shamu), and indeed it is. Boot.img, fstab, userdata "forceencrypt" all looked the same.

So, it appears that unencrypting the 5X (and hopefully the 6P) should be the same process as the current Nexus 6 and 9.
[Android Software Development] osm0sis:
Thanks! Were these done with the --original commandline argument? The ramdisk_size is different for all 3, which shouldn't happen if you repacked using the original split ramdisk.

Attempting to reproduce the issues in my Ubuntu VM with the flo Marshmallow boot.img...

Edit

: [MENTION=5501864]USBhost[/MENTION] a ./repackimg.sh --original at user level still results in an md5sum identical image-new.img to the input boot.img for me, so I'm not sure what's up with what you reported there. However, I do notice that unpacking a ramdisk packed by AIK-Linux run at user level results in all the contents being user level, even if unpacked as root with sudo, so I could certainly see how that could be a problem for the increasingly strict SELinux rules baked into Marshmallow's ramdisk.

[MENTION=3209971]cam30era[/MENTION] Try adding --no-preserve-owner to the cpio commandline in unpackimg.sh and see if that fixes things at the user level.

ie.

$unpackcmd "../split_img/$file-ramdisk.cpio$compext" $extra | cpio -id --no-preserve-owner;

If that doesn't work (likely since the issue is with cpio in repacking non-root ownership, as it doesn't accept --no-preserve-owner), then I might have to build mkbootfs for Linux and see if that resolves it by building the rootfs of the ramdisk with its hardcoded ownership and permissions.

Edit 2

: Hmm yup, I can reproduce the user level ramdisk repack bootloop/boot back to recovery, and it still seems to happen with my --no-preserve-owner addition. I'm guessing my AnyKernel2 zips still work on Marshmallow because they always run in recovery, which is also root. Guess we'll stick to sudo for now until I can find time to cross-compile mkbootfs and test it out.
[Android Software Development] USBhost:
after I said that I realized --original never got used

sorry I did not get back to you on that.
[Android Software Development] :
[MENTION=4544860]osm0sis[/MENTION], I would recommend using mkbootfs. I run it for arm and Linux. No issues.
[Android Software Development] cam30era:
As an old sage said, "I'm late to the party". ;)

But I'll try to answer your question, anyway.

For the "userrepackboot.img" I did:

1) ./unpackimg.sh boot.img (from terminal)

2) Used gedit to edit fstab.shamu, only replacing "force-encrypt" with "encryptable" in the line following "userdata".

3) ./repackimg.sh boot.img

That's it. Nothing else. When I fastboot flash this boot.img, the N6 will not boot up. Device freezes on splash screen.

For the "rootrepackboot.img" I did:

1) sudo ./unpackimg.sh boot.img

2) Then I edited fstab via > sudo nano fstab.shamu. Once again, only replacing "force-encrypt" with "encryptable" in the line following "userdata".

3) sudo ./repackimg.sh boot.img

When I fastboot flash this boot.img, the N6 boots up with no issue.

Edit: and FWIW, I didn't make any changes to your .sh files...
[Android Software Development] osm0sis:
Yeah. Shame to lose the complete control we had previously on Linux over every file's permissions going into the ramdisk (eg. added script files we want as 755, etc.), but c'est la vie I guess if it's the only way to roll for Marshmallow without making people feel less secure by running things on their Linux box with sudo.
[Android Software Development] osm0sis:
I've uploaded an interim release to the OP to resolve the AIK-Linux issues with Marshmallow boot images when run at user level. I'll leave up v1.9 as well for pre-Marshmallow and those who would prefer to have full control over their Marshmallow ramdisk filesystems (when run as sudo). I'll be making running as root optional with a commandline switch for the next proper release.

AIK-Linux v1.9.1:

- replace find/cpio with mkbootfs from my repo to resolve Marshmallow ramdisk rootfs ownership issues.

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

Installation information and details can be found in the 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] cam30era:
[MENTION=4544860]osm0sis[/MENTION],

Thanks for this.

I'm having a problem, though. Am I doing something wrong?

claude@claude-desktop:~/1.9.1 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/"...

./unpackimg.sh: 49: ./unpackimg.sh: /home/claude/1.9.1: not found

Error!

claude@claude-desktop:~/1.9.1 AIK-Linux$
[Android Software Development] osm0sis:
Don't unpack it to a weird folder, just tar xzvf AIK-Linux*.tar.gz from your home (~) directory. It should unpack to "AIK-Linux". I'll try to fix it up to allow for renaming the working directory to contain spaces for the next release, but don't expect it any time soon for such a minor thing. ;)
[Android Software Development] cam30era:
Got it. Thanks. I renamed it so I could distinguish it from 1.9. I'll fix it now. Really appreciate your help.

---------- Post added at 08:00 AM ---------- Previous post was at 07:45 AM ----------

Just reporting back that it works fine (of course). Thanks, again. :o
[Android Software Development] blueyes:
Great tool. Esp for on the go devs/maintainers. I use mobile version routinely. Never fails me. Tried on several devices. Couple you can add to your list; Samsung Galaxy S5, Lg G Pad 7" v410, and of course shamu, flo, deb,vk810 (already listed). Thanks [MENTION=4544860]osm0sis[/MENTION] for the work!

Official Team Bliss Flo, Deb, v410 Maintainer
[Android Software Development] osm0sis:
[MENTION=5501864]USBhost[/MENTION] installing manually on a x64 device does AIK-mobile seem to work okay with the 32bit compatibility layer, or are some x64 binaries definitely necessary?
[Android Software Development] USBhost:
yep they work just fine on my nexus 9

well at lest for gzip
[Android Software Development] aLchiEro_06:
Its working on s5282(galaxy star) .orayt .:):)
[Android Software Development] gouster3:
Working:

- SonyEricsson Xperia Neo

- Sony Xperia M

Not working:

- ASUS TF103C (boot.img something about image magic not found)
[Android Software Development] osm0sis:
Haha excellent, because I just noticed I wrote the installer with case wildcards, so arm64 should install arm, mips64 should install mips and x86_64 should install x86. Future-compatible and I didn't even realize it at the time. Gotta love the 32-bit compatibility layer on 64-bit devices. ;)

I'll look into building my own busybox so I'm not reliant on 3rd-party builds and if I can get that going then I'll do it for the 3 x64 architectures as well and do native x64 builds of everything for the next release. :cowboy:

That "boot.img" is a completely different format from anything I've seen before. Interesting! They've got their own "$OS$" magic with some possible addresses and the kernel commandline present a while further. No obvious sign of a ramdisk either (but it's hard to pick out just skimming through with no idea where it starts).

Edit: All available information on the $OS$ header is collected in my posts beginning here: https://xdaforums.com/showthread.php?p=69821039#post69821039 (including a link to my fork of Intel's own Python script to unpack/repack which I updated for all variants)

Edit 2: Will be supported as of AIK v3.5! :victory::cool:
[Android Software Development] :
[MENTION=4544860]osm0sis[/MENTION], are you familiar with an error, "unsupported dev_type" when attempting to flash a boot.img. In this case it pertains to a Samsung device via Odin, and I know you are a die hard Nexus user, however, you have seen a lot of issues over the years and coming to you would be a wise decision and good starting point for my hunt to resolve this. My research shows that this could be related to Odin specifically and not just the cause of one unpacking and repacking an image. I also don't see anything out of the ordinary with mkbootfs that may cause this small yet annoying dilemma. Any insight would be appreciated friend. Support thread can be found here.

~ My hunt continues

Edit: After reading up on the post in the link I shared I noticed he was using the wrong command. It appears to be user error on his end and I gave instructions for proper command usage.
[Android Software Development] baszu:
[MENTION=4544860]osm0sis[/MENTION] I'm trying to unpack twrp recovery, but getting "Android boot magic not found" error.

Could you help? It's twrp of Zenfone 5 (x86)

https://drive.google.com/file/d/0BwEWY6gMvYOeSTVva2xXbzlhNDg/view
[Android Software Development] osm0sis:
Unfortunately it's not a standard image. It's the same issue as the Asus Transformer Pad image I describe 2 posts above yours. Shame on Asus for being standard-compliant with the Zenfone 2 and now deviating to something completely different with the 5 (or somewhere in between). :(
[Android Software Development] osm0sis:
Good news! I debugged the file binary and submitted the issues to the file bugtracker. I also figured out that I can work around the bugs by renaming the slimmed magic file we use, so either way I will be able to include the latest file binary in the next release of AIK-mobile again. :victory: :cowboy:

I've also got the new AIK-Linux all ready to go with the new --sudo commandline argument for unpackimg to force the ramdisk unpacking as root so that people can maintain full control of their added ramdisk file permissions. repackimg will automatically detect the ramdisk is unpacked as root, and correct the ownership of any edited files before also repacking as root. AIK-Linux can still be run as always without any option and now mkbootfs will handle all that stuff for the stock files, you'd just have to set your extra file permissions in init.rc or a script instead. :good:

AIK-mobile is all ready for Android x64 as well, not to mention support for the new systemless root experiment on Marshmallow. So the only thing I'm waiting on are busybox compiles for arm64, x86_64 and mips64. I'm working on compiling them myself but hitting a bit of a wall at the moment since configuring busybox's build setup doesn't appear to like cooperating with the Android NDK on Windows. :(
[Android Software Development] 6ril1:
Hi [MENTION=4544860]osm0sis[/MENTION],

Thank you for sharing these super practical tools.

I would like to open a topic, in the section of LG G3, in which I would use the binary that you compiled, and that you distribute with AIK.

For this device (LG G3), must be added to the kernel the signature of the manufacturer, so the locked bootloader allows the continuation of the boot (bump! http://xdaforums.com/lg-g3/orig-development/bump-unlock-lg-g3-twrp-d852-d852g-f400-t2900614).

I would therefore make minor changes to repackimg.sh, that are:

- Replace

$PWD

by

BASEDIR = $ (dirname $ 0)

, this to facilitate drag and drop files to a terminal;

- Add

printf 'signing in hexa' >> image new.img

just after mkbootimg.

- Replace the header

#!/Bin/sh

by

#!/ Bin/bash

because

printf 'hexa' >> file

is not working properly in posix shell unlike it does with bash.

The injection of the signature to be made immediately after the last used page of the kernel, we have to remove unnecessary bytes before doing so, and unpack/repack kernel is the easiest way to do so (http://xdaforums.com/showpost.php?p=60086231&postcount=42). To share a tutorial that should use these binaries (unpackbootimg and mkbootimg), I prefer to offer these binaries already compiled rather than having to explain how to compile them. That's why I would like to use those you proposed in AIK, including for cross-platform (win + linux).

Finally, I would also, as part of this project topic, showing how to include support init.d + SELinux permissive in the ramdisk, using your AIK for this.

Do you authorized me to use everything I talk here, knowing that as usual, I will mention my sources and will give credits, give link to this topic, and describe precisely all minor changes I have made ?
[Android Software Development] osm0sis:
You could just make a new bump.sh to apply those changes to image-new.img without editing repackimg.sh - that way it can basically be a bump add-on. :)
[Android Software Development] 6ril1:
Thank you for your answer. Do not worry, I can also add an external script, as you proposed.

I was suggesting as well, just not to have to call a third script to bump, but no problem, it can be a "plug-in" as well ;)

About my proposal to change $PWD by $(dirname $ 0), in the script sh, you would see there a downside ?

I propose that, because if you open a terminal from anywhere other than the AIK folder, and drag and drop sh + boot file, $PWD does not return the AIK folder, while $(dirname $ 0) returns the well AIK folder.

I tested it on mint, with a drag and drop sh file + drag and drop kernel file, and $PWD, called on the script sh, returns the home folder instead of AIK folder, so the rest of the script no longer works correctly, on this situation, unlike the $(dirname $ 0) does.

BASEDIR=$(dirname $0);
bin="$BASEDIR/bin";
chmod -R 755 "$bin" "$BASEDIR"/*.sh;
chmod 644 "$bin/magic";
cd "$BASEDIR";
[Android Software Development] Ram121:
I have tried AIK windows version for Galaxy Note 4 910G the kernel unpack repack working good.

But I am not clear with changes to be done in ramdisk, as I have done changes as per most of guides available on XDA, in default.prop, but the stock kernel is going in bootloop.

If anyone could help into this would be great
[Android Software Development] osm0sis:
Great idea! I did something similar in my rewrites the other day for 2.0 (coming as soon as I get busybox to build for the 3 Android x64 architectures...) to make sure it went back to the AIK dir on an error but this sounds even better. Thanks! :D
[Android Software Development] 6ril1:
Thank's ;)

Full script for bumping a G3 kernel with your bins (script sh must be in root aik folder, kernel file can be anywere, and both can be drag and drop in an opened terminal), in a one shot (in the case we don't need to modify ramdisk , but just bump kernel):

#!/bin/bash
BASEDIR=$(dirname $0);
bin="$BASEDIR/bin";
chmod -R 755 "$bin" "$BASEDIR"/*.sh;
chmod 644 "$bin/magic";
cd "$BASEDIR";
arch=`uname -m`;

if [ ! -d "out" ];then
mkdir out
chmod 755 out
else
rm -rf out/*;
fi

if [ -e "bumped.img" ];then
rm -rf bumped.img;
fi

$bin/$arch/unpackbootimg -i $1 -o out;
if [ -e out/${1##*/}-ramdisk.gz ]; then
rdcomp=out/${1##*/}-ramdisk.gz
elif [ -e out/${1##*/}-ramdisk.lz4 ]; then
rdcomp=/out/${1##*/}-ramdisk.lz4
else
exit 1
fi

$bin/$arch/mkbootimg --kernel out/${1##*/}-zImage \
--ramdisk $rdcomp \
--dt out/${1##*/}-dtb \
--cmdline "$(cat out/${1##*/}-cmdline)" \
--pagesize $(cat out/${1##*/}-pagesize) \
--base $(cat out/${1##*/}-base) \
--ramdisk_offset $(cat out/${1##*/}-ramdiskoff) \
--tags_offset $(cat out/${1##*/}-tagsoff) \
--output bumped.img

printf '\x41\xA9\xE4\x67\x74\x4D\x1D\x1B\xA4\x29\xF2\xEC\xEA\x65\x52\x79' >> bumped.img

Note: bash instead of sh is very important for an expected result for printf cmd. It doesn't work with sh.

And code that can be an addon to AIK and that we need if we've modified ramdisk after unpacking with your tool, to execute just after repacking:

#!/bin/bash
printf '\x41\xA9\xE4\x67\x74\x4D\x1D\x1B\xA4\x29\xF2\xEC\xEA\x65\x52\x79' >> image-new.img

I'll make a thread soon on the G3 section about this ;)
[Android Software Development] osm0sis:
echo -en might be more portable than printf to allow us using it with sh.
[Android Software Development] 6ril1:
Alas, doesnt' work with sh too. It doesn't inject the value in hexa, exactly as printf does, with sh.

I don't understand why, but just changing sh by bash does the trick (both for printf and echo -en).

In the same way, i've not find a way to inject hexa bump signature, in windows, with script. I do it with an hexa editor for the moment.

if someone had an idea, I would be interested