[TOOL] Android Image Kitchen - Unpack/Repack Kernel Ramdisk [Win/Android/Linux/Mac]

Search This thread

KaMyKaSii

Senior Member
Feb 25, 2015
1,369
654
`fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img` was the main thing I was thinking of... I see your image is signed with AVBv2, so maybe it somehow needs to still be signed with it? Magisk started patching AVBv2 flags in place recently, for example: https://github.com/topjohnwu/Magisk/commit/027ec7026252bf1615c19205855ae58a79f1225e
I don't think AVB is necessary because the attached TWRP image is bootable and not signed. But the repack with the original ramdisk and size still fails to boot
 

Attachments

  • twrp-3.5.1_10.0-citrus-brigudav.zip
    37.2 MB · Views: 13

osm0sis

Senior Recognized Developer / Recognized Contribut
Mar 14, 2012
14,529
32,687
Halifax
GT-i9250
Nexus 7 (2013)
I'm trying to use AIK (tried Linux and mobile) to repack some recovery images for my Poco M3 and I'm going crazy. The device refuses to boot recovery after flash the repack image by fastboot. Even repacking the stock recovery image with --original --origsize parameters does not work. The device goes back to fastboot. And at that point where the repack image is installed on the recovery partition, it also refuses to start Android with "fastboot reboot" or by long press power button. The device only starts in fastboot. But it is possible to circumvent this and start Android with the command "fastboot continue" (which becomes necessary with each restart). But I realized that if I install the repack image on the boot partition and then proceed with "fastboot continue" then the recovery image is finally loaded. I think maybe this has to do with android boot verification? At the moment I am using an Android 10 GSI and installed the vbmeta image provided by Google with the command "fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img". I'll leave attached the stock recovery image. I hope you have some idea why this is happening. Thank you!

`fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img` was the main thing I was thinking of... I see your image is signed with AVBv2, so maybe it somehow needs to still be signed with it? Magisk started patching AVBv2 flags in place recently, for example: https://github.com/topjohnwu/Magisk/commit/027ec7026252bf1615c19205855ae58a79f1225e

I don't think AVB is necessary because the attached TWRP image is bootable and not signed. But the repack with the original ramdisk and size still fails to boot
I compared in a hex editor the stock recovery.img you uploaded with the image-new.img produced by --original --origsize and literally the only difference is the AVBv2 signature, as I suspected. That TWRP .img you uploaded is actually also AVBv2 signed, by the way. AIK recognizes it and everything. So my hunch is that my hunch is still probably right? 🤷‍♂️

Either use Google's latest avbtool with Python on your Linux machine, or you can play around with signing on-device with my previous avbtool-arm experiment: https://forum.xda-developers.com/t/beta-2017-10-01-supersu-v2-82-sr5.2868133/page-572#post-74498246
 
Last edited:

shadowstep

Forum Moderator
Staff member
  • Jun 6, 2014
    4,992
    9,936
    30
    Ambala
    OnePlus 5
    @osm0sis Hey Chris, I've been getting multiple warnings while unpacking and repacking the latest version of TWRP v3.5.1 using AIK v3.7. Although the both unpacking and repacking end up going through successfully, I've never seen these warnings before (I tested unpacking and repacking TWRP v3.5.0 and there were no warnings at all). Any clue on what might be the issue? For reference, I tried extracting twrp-3.5.1_9-0-cheeseburger_dumpling.img and got the following (the ones in red are what I'm referring to):
    Rich (BB code):
    Android Image Kitchen - UnpackImg Script
    by osm0sis @ xda-developers
    
    Supplied image: twrp-v3.5.1_9-0-official-cheeseburgerdumpling.img
    
    Setting up work folders . . .
    
    Image type: AOSP
    
    Splitting image to "split_img/" . . .
    
    BOARD_KERNEL_CMDLINE androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 sched_enable_hmp=1 sched_enable_power_aware=1 service_locator.enable=1 swiotlb=2048 androidboot.usbconfigfs=true androidboot.usbcontroller=a800000.dwc3 firmware_class.path=/vendor/firmware_mnt/image loop.max_part=7 androidboot.selinux=permissive buildvariant=eng
    BOARD_KERNEL_BASE 0x00000000
    BOARD_NAME
    BOARD_PAGE_SIZE 4096
    BOARD_HASH_TYPE sha1
    BOARD_KERNEL_OFFSET 0x00008000
    BOARD_RAMDISK_OFFSET 0x01000000
    BOARD_SECOND_OFFSET 0x00f00000
    BOARD_TAGS_OFFSET 0x00000100
    BOARD_OS_VERSION 9.0.0
    BOARD_OS_PATCH_LEVEL 2019-10
    BOARD_HEADER_VERSION 0
    
    Unpacking ramdisk to "ramdisk/" . . .
    
    Compression used: gzip
    /android_win_tools/cpio: system/etc/terminfo/2/2621a not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/e/eterm not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/e/eterm-color not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/h/hp2621a not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/h/hp70092a not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/l/lft-pc850 not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/n/ncr260vt300wpp not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/n/ncrvt100wpp not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p12 not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p12-m not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p12-m-w not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p12-w not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p14 not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p14-m not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p14-m-w not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p14-w not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p4 not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p5 not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p7 not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p8 not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p8-w not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p9 not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p9-8 not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p9-8-w not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p9-w not created: newer or same age version exists
    108569 blocks
    
    Done!
    
    Press any key to continue . . .
     
    • Like
    Reactions: osm0sis

    osm0sis

    Senior Recognized Developer / Recognized Contribut
    Mar 14, 2012
    14,529
    32,687
    Halifax
    GT-i9250
    Nexus 7 (2013)
    @osm0sis Hey Chris, I've been getting multiple warnings while unpacking and repacking the latest version of TWRP v3.5.1 using AIK v3.7. Although the both unpacking and repacking end up going through successfully, I've never seen these warnings before (I tested unpacking and repacking TWRP v3.5.0 and there were no warnings at all). Any clue on what might be the issue? For reference, I tried extracting twrp-3.5.1_9-0-cheeseburger_dumpling.img and got the following (the ones in red are what I'm referring to):
    Rich (BB code):
    Android Image Kitchen - UnpackImg Script
    by osm0sis @ xda-developers
    
    Supplied image: twrp-v3.5.1_9-0-official-cheeseburgerdumpling.img
    
    Setting up work folders . . .
    
    Image type: AOSP
    
    Splitting image to "split_img/" . . .
    
    BOARD_KERNEL_CMDLINE androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 sched_enable_hmp=1 sched_enable_power_aware=1 service_locator.enable=1 swiotlb=2048 androidboot.usbconfigfs=true androidboot.usbcontroller=a800000.dwc3 firmware_class.path=/vendor/firmware_mnt/image loop.max_part=7 androidboot.selinux=permissive buildvariant=eng
    BOARD_KERNEL_BASE 0x00000000
    BOARD_NAME
    BOARD_PAGE_SIZE 4096
    BOARD_HASH_TYPE sha1
    BOARD_KERNEL_OFFSET 0x00008000
    BOARD_RAMDISK_OFFSET 0x01000000
    BOARD_SECOND_OFFSET 0x00f00000
    BOARD_TAGS_OFFSET 0x00000100
    BOARD_OS_VERSION 9.0.0
    BOARD_OS_PATCH_LEVEL 2019-10
    BOARD_HEADER_VERSION 0
    
    Unpacking ramdisk to "ramdisk/" . . .
    
    Compression used: gzip
    /android_win_tools/cpio: system/etc/terminfo/2/2621a not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/e/eterm not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/e/eterm-color not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/h/hp2621a not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/h/hp70092a not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/l/lft-pc850 not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/n/ncr260vt300wpp not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/n/ncrvt100wpp not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p12 not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p12-m not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p12-m-w not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p12-w not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p14 not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p14-m not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p14-m-w not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p14-w not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p4 not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p5 not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p7 not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p8 not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p8-w not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p9 not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p9-8 not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p9-8-w not created: newer or same age version exists
    /android_win_tools/cpio: system/etc/terminfo/p/p9-w not created: newer or same age version exists
    108569 blocks
    
    Done!
    
    Press any key to continue . . .
    They added terminfo for nano, and it includes files with the same name except for case, and of course Windows doesn't handle those. Pretty much nothing I can do about that other than suggest you use AIK-mobile or AIK-Linux instead; maybe AIK-Linux would work on WSL2? 🤔

    Edit:

    The errors could likely be ignored without issue since those are all terminfo setups that will never be used on Android. 😛

    You could also try this registry hack, but I definitely won't be forcing that on everybody:

    ntkern-disable-case-insens.reg:
    Code:
    Windows Registry Editor Version 5.00
    
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel]
    "obcaseinsensitive"=dword:00000000
     
    Last edited:

    shadowstep

    Forum Moderator
    Staff member
  • Jun 6, 2014
    4,992
    9,936
    30
    Ambala
    OnePlus 5
    They added terminfo for nano, and it includes files with the same name except for case, and of course Windows doesn't handle those. Pretty much nothing I can do about that other than suggest you use AIK-mobile or AIK-Linux instead.
    Alright, thanks! I'll make the switch and see how it goes. (y)

    EDIT: Made the change manually in regedit, but the warnings still popped up. I'll try rebooting once just because Windows can be finicky that way.
     
    Last edited:

    osm0sis

    Senior Recognized Developer / Recognized Contribut
    Mar 14, 2012
    14,529
    32,687
    Halifax
    GT-i9250
    Nexus 7 (2013)
    @osm0sis When will the HDRv3 support bootimg package tool be released? Or if there is a beta?
    You're seriously asking for an ETA on xda? Pretty poor form. It'll be out when it's out.

    That said, I've been - working - on it.

    BUT, remember, I am a Registered Nurse doing 12-hour shifts on a Mental Health inpatient unit, that's my full time job, and this xda stuff is entirely done with my free time, and out of my goodwill and passion/itch to mess around with Android, with very little in return for my effort.

    I work all this weekend, so we'll see what I can get done maybe next week, but no promises.. Not to mention all the work I still need to be doing on my house and other real life things..
     
    Last edited:

    chronolz

    Member
    Jan 27, 2016
    5
    0
    Hi,

    I have been trying to unpack boot.img.lz4 for SM-G998B/DS. I have tried this in Win 10 and Ubuntu 2004 WSL 2 using AIK v3.7.

    This is the output I get from "unpacking.bat boot.img.lz4"

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

    Supplied image: boot.img.lz4

    Setting up work folders . . .

    Image type: AOSP

    Signature with "AVBv2" type detected.

    Splitting image to "split_img/" . . .

    Android magic found at: 21
    BOARD_KERNEL_CMDLINE ☻□¶☺☺,
    BOARD_KERNEL_BASE 0x000a2356
    BOARD_NAME ux=permissive3
    BOARD_PAGE_SIZE 1868719209
    BOARD_HASH_TYPE sha256
    BOARD_KERNEL_OFFSET 0x00008000
    BOARD_RAMDISK_OFFSET 0x00f5e2d6
    BOARD_SECOND_OFFSET 0x60f5dcaa
    BOARD_TAGS_OFFSET 0x6f684118
    BOARD_OS_VERSION 55.26.45
    BOARD_OS_PATCH_LEVEL 2070-05
    BOARD_DT_SIZE 1932424303

    Unpacking ramdisk to "ramdisk/" . . .

    Compression used: tar
    '"Android.Image.Kitchen.v3.7-Win32\Android Image Kitchen\\android_win_tools"\tar' is not recognized as an internal or external command,
    operable program or batch file.

    When I check files in the split_cmd folder, the files seem to be there... see dir list below. Also if I cat boot.img.lz4-zImage I will get a typical binary output. One more thing to note in the dir list is that boot.img.lz4-dt is 0 in size

    04/17/2021 10:19 AM <DIR> .
    04/17/2021 10:19 AM <DIR> ..
    04/17/2021 10:19 AM 11 boot.img.lz4-base
    04/17/2021 10:19 AM 15 boot.img.lz4-board
    04/17/2021 10:19 AM 7 boot.img.lz4-cmdline
    04/17/2021 10:19 AM 0 boot.img.lz4-dt
    04/17/2021 10:19 AM 6 boot.img.lz4-dttype
    04/17/2021 10:19 AM 7 boot.img.lz4-hashtype
    04/17/2021 10:19 AM 6 boot.img.lz4-imgtype
    04/17/2021 10:19 AM 11 boot.img.lz4-kernel_offset
    04/17/2021 10:19 AM 10 boot.img.lz4-origsize
    04/17/2021 10:19 AM 8 boot.img.lz4-os_patch_level
    04/17/2021 10:19 AM 9 boot.img.lz4-os_version
    04/17/2021 10:19 AM 11 boot.img.lz4-pagesize
    04/17/2021 10:19 AM 369,099,091 boot.img.lz4-ramdisk.cpio.tar
    04/17/2021 10:19 AM 4 boot.img.lz4-ramdiskcomp
    04/17/2021 10:19 AM 11 boot.img.lz4-ramdisk_offset
    04/17/2021 10:19 AM 51,641,600 boot.img.lz4-second
    04/17/2021 10:19 AM 11 boot.img.lz4-second_offset
    04/17/2021 10:19 AM 11 boot.img.lz4-tags_offset
    04/17/2021 10:19 AM 28,807,680 boot.img.lz4-zImage
    19 File(s) 449,548,509 bytes
    2 Dir(s) 1,517,954,637,824 bytes free

    Also if I copy tar.exe (i dont think this is kosher after studying unpacking.sh on the linux side) from the win10 system32 into the AIK android tools bin folder and rerun "unpacking.bat boot.img.lz4" I get the following output

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

    Supplied image: boot.img.lz4

    Setting up work folders . . .

    Image type: AOSP

    Signature with "AVBv2" type detected.

    Splitting image to "split_img/" . . .

    Android magic found at: 21
    BOARD_KERNEL_CMDLINE ☻□¶☺☺,
    BOARD_KERNEL_BASE 0x000a2356
    BOARD_NAME ux=permissive3
    BOARD_PAGE_SIZE 1868719209
    BOARD_HASH_TYPE sha256
    BOARD_KERNEL_OFFSET 0x00008000
    BOARD_RAMDISK_OFFSET 0x00f5e2d6
    BOARD_SECOND_OFFSET 0x60f5dcaa
    BOARD_TAGS_OFFSET 0x6f684118
    BOARD_OS_VERSION 55.26.45
    BOARD_OS_PATCH_LEVEL 2070-05
    BOARD_DT_SIZE 1932424303

    Unpacking ramdisk to "ramdisk/" . . .

    Compression used: tar
    Usage:
    List: tar -tf <archive-filename>
    Extract: tar -xf <archive-filename>
    Create: tar -cf <archive-filename> [filenames...]
    Help: tar --help
    /android_win_tools/cpio: premature end of archive
    Error!

    Press any key to continue . . .

    Now, When I try AIK in Ubuntu 2004 WSL 2 I get the following output

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

    Supplied image: boot.img.lz4

    Setting up work folders...

    Image type: AOSP

    Signature with "AVBv2" type detected.

    Splitting image to "split_img/"...
    Android magic found at: 21
    BOARD_KERNEL_CMDLINE ,
    BOARD_KERNEL_BASE 0x000a2356
    BOARD_NAME ux=permissive3
    BOARD_PAGE_SIZE 1868719209
    BOARD_HASH_TYPE sha256
    BOARD_KERNEL_OFFSET 0x00008000
    BOARD_RAMDISK_OFFSET 0x00f5e2d6
    BOARD_SECOND_OFFSET 0x60f5dcaa
    BOARD_TAGS_OFFSET 0x6f684118
    BOARD_OS_VERSION 55.26.45
    BOARD_OS_PATCH_LEVEL 2070-05
    BOARD_DT_SIZE 1932424303

    Unpacking ramdisk (as root) to "ramdisk/"...

    Warning: Using cpio 2.13 may result in an unusable repack; downgrade to 2.12 to be safe!

    Compression used: tar
    Unsupported format.
    Error!

    when i check files in the split_img folder, they seem to be listing however cat of any binary just shows blank. Also boot.img.lz4-dt is approx 1.8GB

    total 2.3G
    drwxr-xr-x 2 user user 4.0K Apr 17 10:33 .
    drwxr-xr-x 5 user user 4.0K Apr 17 10:33 ..
    -rw-r--r-- 1 user user 11 Apr 17 10:33 boot.img.lz4-base
    -rw-r--r-- 1 user user 15 Apr 17 10:33 boot.img.lz4-board
    -rw-r--r-- 1 user user 7 Apr 17 10:33 boot.img.lz4-cmdline
    -rw-r--r-- 1 user user 1.8G Apr 17 10:33 boot.img.lz4-dt
    -rw-r--r-- 1 user user 5 Apr 17 10:33 boot.img.lz4-dttype
    -rw-r--r-- 1 user user 7 Apr 17 10:33 boot.img.lz4-hashtype
    -rw-r--r-- 1 user user 5 Apr 17 10:33 boot.img.lz4-imgtype
    -rw-r--r-- 1 user user 11 Apr 17 10:33 boot.img.lz4-kernel_offset
    -rw-r--r-- 1 user user 9 Apr 17 10:33 boot.img.lz4-origsize
    -rw-r--r-- 1 user user 8 Apr 17 10:33 boot.img.lz4-os_patch_level
    -rw-r--r-- 1 user user 9 Apr 17 10:33 boot.img.lz4-os_version
    -rw-r--r-- 1 user user 11 Apr 17 10:33 boot.img.lz4-pagesize
    -rw-r--r-- 1 user user 353M Apr 17 10:33 boot.img.lz4-ramdisk.cpio
    -rw-r--r-- 1 user user 11 Apr 17 10:33 boot.img.lz4-ramdisk_offset
    -rw-r--r-- 1 user user 4 Apr 17 10:33 boot.img.lz4-ramdiskcomp
    -rw-r--r-- 1 user user 50M Apr 17 10:33 boot.img.lz4-second
    -rw-r--r-- 1 user user 11 Apr 17 10:33 boot.img.lz4-second_offset
    -rw-r--r-- 1 user user 11 Apr 17 10:33 boot.img.lz4-tags_offset
    -rw-r--r-- 1 user user 28M Apr 17 10:33 boot.img.lz4-zImage

    Can I attach the boot.img.lz4-dt "from samsung stock image" in the forum?

    I am trying to replace "boot.img.lz4-zImage" with a custom kernel "Image", do I really need to unpack ramdisk for this?

    Last, between the win 10 and ubuntu wsl2 unpacking the boot.img.lz4-dt is 0bytes and 1.8GB. Would this be an issue if somehow I can bypass ramdisk unpacking and only replace boot.imag.lz4-zImage in the split_img folder and repack boot.img.lz4 in win 10?

    Thank you... any direction would be helpful

    chronolz
     

    chronolz

    Member
    Jan 27, 2016
    5
    0
    Well, I tried decompressing the lz4 first and running unpacking on boot.img also

    and this is the output


    WSL2

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

    Supplied image: boot.img

    Setting up work folders...

    Image type: AOSP

    Signature with "AVBv2" type detected.

    Splitting image to "split_img/"...
    BOARD_KERNEL_CMDLINE permissive
    BOARD_KERNEL_BASE 0x000a2356
    BOARD_NAME oidboot.selinux=permissive
    BOARD_PAGE_SIZE 0
    BOARD_HASH_TYPE sha1
    BOARD_KERNEL_OFFSET 0x00008000
    BOARD_RAMDISK_OFFSET 0xfff5e2d6
    BOARD_SECOND_OFFSET 0xfff5dcaa
    BOARD_TAGS_OFFSET 0xfff5dcaa
    BOARD_OS_VERSION 57.25.13
    BOARD_OS_PATCH_LEVEL 2102-01
    BOARD_HEADER_VERSION 3
    BOARD_HEADER_SIZE 0
    unpackbootimg: malloc.c:2379: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.
    ./unpackimg.sh: line 218: 182 Aborted "$bin/$arch/unpackbootimg" -i "$img"
    Error!

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

    Supplied image: boot.img

    Setting up work folders . . .

    Image type: AOSP

    Signature with "AVBv2" type detected.

    Splitting image to "split_img/" . . .

    BOARD_KERNEL_CMDLINE permissive
    BOARD_KERNEL_BASE 0x000ee9a2
    BOARD_NAME oidboot.selinux=permissive
    BOARD_PAGE_SIZE 0
    BOARD_HASH_TYPE sha1
    BOARD_KERNEL_OFFSET 0x00008000
    BOARD_RAMDISK_OFFSET 0xfff11c8a
    BOARD_SECOND_OFFSET 0xfff1165e
    BOARD_TAGS_OFFSET 0xfff1165e
    BOARD_OS_VERSION 57.25.13
    BOARD_OS_PATCH_LEVEL 2102-01
    BOARD_HEADER_VERSION 3
    BOARD_HEADER_SIZE 0
    0 [main] ∩âò∩â│♂@∩â╣∩âá♥☻∩é¬∩â╜{┬¿^∩éÄ_∩â╕∩âÇ♥_∩âû^∩éå 1755 cygwin_exception::eek:pen_stackdumpfile: Dumping stack trace to unpackbootimg.exe.stackdump
    Error!

    Press any key to continue . . .
     

    T3chDelicious

    Senior Member
    Oct 7, 2016
    57
    22
    I get the "unrecognized format" error. Got a Sony Xperia 5 II. I downloaded whole Firmware and make a boot.img from the boot.sin inside firmware folder with the program UnSin. Than patched this img with Magisk. I need to remove some lines in ramdisk/fstab.qcom or it will bootloop. But when I drag the patched Magisk.img over unpackimg and than I get the error. Does I do something wrong?

    Thanks in advance!
     

    T3chDelicious

    Senior Member
    Oct 7, 2016
    57
    22
    I get the "unrecognized format" error. Got a Sony Xperia 5 II. I downloaded whole Firmware and make a boot.img from the boot.sin inside firmware folder with the program UnSin. Than patched this img with Magisk. I need to remove some lines in ramdisk/fstab.qcom or it will bootloop. But when I drag the patched Magisk.img over unpackimg I get the error. Does I do something wrong?

    Thanks in advance!
    Sorry....messed here a little up. Didn't mean to quote myself.
     

    osm0sis

    Senior Recognized Developer / Recognized Contribut
    Mar 14, 2012
    14,529
    32,687
    Halifax
    GT-i9250
    Nexus 7 (2013)
    I get the "unrecognized format" error. Got a Sony Xperia 5 II. I downloaded whole Firmware and make a boot.img from the boot.sin inside firmware folder with the program UnSin. Than patched this img with Magisk. I need to remove some lines in ramdisk/fstab.qcom or it will bootloop. But when I drag the patched Magisk.img over unpackimg and than I get the error. Does I do something wrong?

    Thanks in advance!
    You didn't supply the image so I can't really help. 🤷‍♂️
     

    T3chDelicious

    Senior Member
    Oct 7, 2016
    57
    22
    You didn't supply the image so I can't really help. 🤷‍♂️
    I totally forgot about it. Sorry for that. Here is the patched image.

    Edit: Cant attach file. Uploaded on Google Drive. Here ist the link:

    Edit: I did figure it out. But anyway much thanks for your reply and help.
     
    Last edited:

    FearNaiim

    Member
    Sep 19, 2019
    14
    0
    Hi
    Sorry for this off topic question but I tried a lot of things and no sucess
    I'm trying to turn off SELINUX from Samsung S21 by modifying the kernel image. The image is compiled without any problem. When I try to unpack and repack the boot image with modifying kernel using Magiskboot tool, the phone doesn't start up and get stuck in samsung logo. do you know what could be the problem? I can easily modify the kernel for Samsung S20 but with S21 I got stuck
    thanks
    by the way I have exynos samsung s21
     

    Top Liked Posts

    • 3
      Let's try this again! After a few more final struggles it looks like we have a release! Right off the top, massive thanks to @Postman1year and @CXZa. 🙌 They went the extra mile with testing the earlier v3.8 "pre"-release which ended up having major last minute issues with hangs for many from the cut command, and then regressions to cpio/symlink creation, all from bad Cygwin updates! 😳 That should all be resolved now, and I'll be freezing Cygwin at the lower, working version in AIK until I can report on and verify these issues have been fixed by Cygwin. Upside of all this being I had a bit more time to polish up a few more things in the build scripts and other platforms while I was at it, so we should be even more solid now. 💪

      Big news is of course full boot_img_hdr_v3 support, and along with it support for the new AOSP vendor_boot format, which I'm calling AOSP_VNDR within AIK due to its "VNDRBOOT" header magic. These almost completely break backwards compatibility with the previous boot_img_hdr versions so took a bit more effort to backport to my tools, but I'm pleased with the results and rewrites it allowed me to do even if it did take longer, plus upkeep should be easier again going forward. (y)

      AIK false positives from heuristics with Windows Defender, et al. seem to go back and forth over time, but have indeed gotten worse again lately. Thanks to @CXZa for the help investigating the Windows sudo false positives and alternatives, and ideas for fixing the multiple sudo prompts, which are included in this release. I submitted the old UPX-packed sudo.exe to Microsoft again as a false positive and pointed them to my source and compile method, so hopefully Windows Defender will stop trying to quarantine my AIK archived zips while we're at it. :p

      I have also tweaked my updated boot_signer.jar to have a higher cutoff before it determines that the image has a dt (since the header_version value the dt_size conflicts with is up to 4 already in AOSP upstream), and added more graceful error catching and messages for attempting to verify or sign boot_img_hdr_v3 (which is not supported by AVBv1 at all).

      Please note there is a Windows Registry fix if you run into duplicate "terminfo" files errors unpacking the latest TWRP images.

      The AIK Build Farm scripts are updated with fixes, including updates to the cross-platform regression tester, for any wanting to play along at home.

      FlashIt was updated over in my Odds and Ends thread as well, highly recommended as it's the perfect companion package to AIK-mobile.

      I work on these projects in my limited time off, so if you like the progress I'm making, or enjoy anything else I've done on xda, please consider sponsoring my ongoing work using my GitHub Sponsors profile. For a one-time donation you can hit the donate link from my profile. Thanks for your support!


      Android Image Kitchen v3.8:

      - fix majority of sudo.exe VirusTotal false positives by UPX decompressing it
      - fix magic detection false positives of OSIP bootimg headerless
      - add test to ensure Windows sudo is executable
      - fix multiple Windows sudo prompts by putting ramdisk packing commands into a single find2cpio.bat to execute
      - update mkbootimg, unpackbootimg, pxa-mkbootimg, pxa-unpackbootimg and unpackelf binaries from my repos
      - fix for corrected unpackbootimg/unpackelf kernel+ramdisk suffixes
      - update AOSP support for boot_img_hdr_v3
      - add AOSP vendor_boot VNDRBOOT magic detection and support
      - fix false no files error on ramdisks with only directories in root
      - update lz4 binary (1.9.3)
      - fix lz4 and lz4-l ramdisk default repack compression level to match what Google seems to be using
      - update mkimage and dumpimage binaries (2021.04)
      - update slimmed magic file (from file 5.40) with my own fixes
      - update boot_signer*.jar to more clearly catch failure with hdr_v3
      - fix exiting scripts with an error code on failures
      - update to the latest Cygwin binaries and libraries
      - revert Cygwin library (3.1.4-1) due to hangs for most users with cut related to 3.2.0-1, and broken cpio symlink creation related to 3.1.5-1+

      AIK-mobile v3.8 + AIK-Linux v3.8:
      - fix magic detection false positives of OSIP bootimg headerless
      - update busybox binary (1.32.1) with the latest patches and fixes from my repo (AIK-mobile)
      - clean up old `test` style tic
      - fix sloppy/unpredictable `cmd && this || that` statements
      - update Diffusion Installer Backend for Android 11 and latest Magisk (AIK-mobile)
      - update mkbootimg, unpackbootimg, pxa-mkbootimg, pxa-unpackbootimg and unpackelf binaries from my repos
      - fix for corrected unpackbootimg/unpackelf kernel+ramdisk suffixes
      - update AOSP support for boot_img_hdr_v3
      - add AOSP vendor_boot VNDRBOOT magic detection and support
      - update lz4 binary (1.9.3)
      - fix lz4 and lz4-l ramdisk default repack compression level to match what Google seems to be using
      - update mkimage and dumpimage binaries (2021.04)
      - update file binary (5.40) (AIK-mobile)
      - update slimmed magic file (from file 5.40) with my own fixes
      - update boot_signer*.jar to more clearly catch failure with hdr_v3
      - update to the latest MacPorts binaries and libraries (AIK-Linux)
      - revert xz binary (5.2.4) due to arm64 segfaults in 5.2.5 with levels -4 to -9 (AIK-mobile)


      More on my own build changes in the commits here: https://github.com/osm0sis/mkbootimg; https://github.com/osm0sis/pxa-mkbootimg; https://github.com/osm0sis/unpackelf; https://github.com/osm0sis/android-busybox-ndk.

      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.
    • 9
      @osm0sis When will the HDRv3 support bootimg package tool be released? Or if there is a beta?
      You're seriously asking for an ETA on xda? Pretty poor form. It'll be out when it's out.

      That said, I've been - working - on it.

      BUT, remember, I am a Registered Nurse doing 12-hour shifts on a Mental Health inpatient unit, that's my full time job, and this xda stuff is entirely done with my free time, and out of my goodwill and passion/itch to mess around with Android, with very little in return for my effort.

      I work all this weekend, so we'll see what I can get done maybe next week, but no promises.. Not to mention all the work I still need to be doing on my house and other real life things..
      6
      Hey all!

      [ Release removed ... ]

      Edit: So, uh, we'll call this a "soft launch" I guess and do a proper release once these regressions are fully worked out. :(
      4
      So yup, hdr_v3 support will be added in the upcoming 3.8 release.

      Also, please edit your posts using [code] and [hide] tags for the logs so they don't dominate the thread as much. 👍
      4
      Yes, they're actually non-functional in Windows.
      So, I can only trouble you, sorry, I just want AIK-3.8 be perfect
      Haha no no I'm glad you guys are finding stuff this fast. Here I thought I was so fancy and thorough with all my automated regression testing and yet missed this basic breakage when I updated the Cygwin libraries 2 days before release. 😅

      Working night shift at the hospital tonight but should be able to upload a fixed release build tomorrow in the day at some point. 👍

      Edit: Aw sweet! Chrome Remote Desktop'd into my build PC from work and it seems like downgrading Cygwin back to 3.14-1 also fixed my NDK build environment in Cygwin, so uh, damn, the Cygwin devs ****ed up wildly lately I guess but at least I'm back in action. 🤷‍♂️💪
      3
      Let's try this again! After a few more final struggles it looks like we have a release! Right off the top, massive thanks to @Postman1year and @CXZa. 🙌 They went the extra mile with testing the earlier v3.8 "pre"-release which ended up having major last minute issues with hangs for many from the cut command, and then regressions to cpio/symlink creation, all from bad Cygwin updates! 😳 That should all be resolved now, and I'll be freezing Cygwin at the lower, working version in AIK until I can report on and verify these issues have been fixed by Cygwin. Upside of all this being I had a bit more time to polish up a few more things in the build scripts and other platforms while I was at it, so we should be even more solid now. 💪

      Big news is of course full boot_img_hdr_v3 support, and along with it support for the new AOSP vendor_boot format, which I'm calling AOSP_VNDR within AIK due to its "VNDRBOOT" header magic. These almost completely break backwards compatibility with the previous boot_img_hdr versions so took a bit more effort to backport to my tools, but I'm pleased with the results and rewrites it allowed me to do even if it did take longer, plus upkeep should be easier again going forward. (y)

      AIK false positives from heuristics with Windows Defender, et al. seem to go back and forth over time, but have indeed gotten worse again lately. Thanks to @CXZa for the help investigating the Windows sudo false positives and alternatives, and ideas for fixing the multiple sudo prompts, which are included in this release. I submitted the old UPX-packed sudo.exe to Microsoft again as a false positive and pointed them to my source and compile method, so hopefully Windows Defender will stop trying to quarantine my AIK archived zips while we're at it. :p

      I have also tweaked my updated boot_signer.jar to have a higher cutoff before it determines that the image has a dt (since the header_version value the dt_size conflicts with is up to 4 already in AOSP upstream), and added more graceful error catching and messages for attempting to verify or sign boot_img_hdr_v3 (which is not supported by AVBv1 at all).

      Please note there is a Windows Registry fix if you run into duplicate "terminfo" files errors unpacking the latest TWRP images.

      The AIK Build Farm scripts are updated with fixes, including updates to the cross-platform regression tester, for any wanting to play along at home.

      FlashIt was updated over in my Odds and Ends thread as well, highly recommended as it's the perfect companion package to AIK-mobile.

      I work on these projects in my limited time off, so if you like the progress I'm making, or enjoy anything else I've done on xda, please consider sponsoring my ongoing work using my GitHub Sponsors profile. For a one-time donation you can hit the donate link from my profile. Thanks for your support!


      Android Image Kitchen v3.8:

      - fix majority of sudo.exe VirusTotal false positives by UPX decompressing it
      - fix magic detection false positives of OSIP bootimg headerless
      - add test to ensure Windows sudo is executable
      - fix multiple Windows sudo prompts by putting ramdisk packing commands into a single find2cpio.bat to execute
      - update mkbootimg, unpackbootimg, pxa-mkbootimg, pxa-unpackbootimg and unpackelf binaries from my repos
      - fix for corrected unpackbootimg/unpackelf kernel+ramdisk suffixes
      - update AOSP support for boot_img_hdr_v3
      - add AOSP vendor_boot VNDRBOOT magic detection and support
      - fix false no files error on ramdisks with only directories in root
      - update lz4 binary (1.9.3)
      - fix lz4 and lz4-l ramdisk default repack compression level to match what Google seems to be using
      - update mkimage and dumpimage binaries (2021.04)
      - update slimmed magic file (from file 5.40) with my own fixes
      - update boot_signer*.jar to more clearly catch failure with hdr_v3
      - fix exiting scripts with an error code on failures
      - update to the latest Cygwin binaries and libraries
      - revert Cygwin library (3.1.4-1) due to hangs for most users with cut related to 3.2.0-1, and broken cpio symlink creation related to 3.1.5-1+

      AIK-mobile v3.8 + AIK-Linux v3.8:
      - fix magic detection false positives of OSIP bootimg headerless
      - update busybox binary (1.32.1) with the latest patches and fixes from my repo (AIK-mobile)
      - clean up old `test` style tic
      - fix sloppy/unpredictable `cmd && this || that` statements
      - update Diffusion Installer Backend for Android 11 and latest Magisk (AIK-mobile)
      - update mkbootimg, unpackbootimg, pxa-mkbootimg, pxa-unpackbootimg and unpackelf binaries from my repos
      - fix for corrected unpackbootimg/unpackelf kernel+ramdisk suffixes
      - update AOSP support for boot_img_hdr_v3
      - add AOSP vendor_boot VNDRBOOT magic detection and support
      - update lz4 binary (1.9.3)
      - fix lz4 and lz4-l ramdisk default repack compression level to match what Google seems to be using
      - update mkimage and dumpimage binaries (2021.04)
      - update file binary (5.40) (AIK-mobile)
      - update slimmed magic file (from file 5.40) with my own fixes
      - update boot_signer*.jar to more clearly catch failure with hdr_v3
      - update to the latest MacPorts binaries and libraries (AIK-Linux)
      - revert xz binary (5.2.4) due to arm64 segfaults in 5.2.5 with levels -4 to -9 (AIK-mobile)


      More on my own build changes in the commits here: https://github.com/osm0sis/mkbootimg; https://github.com/osm0sis/pxa-mkbootimg; https://github.com/osm0sis/unpackelf; https://github.com/osm0sis/android-busybox-ndk.

      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.
    • 743
      Android Image Kitchen -- Unpack/Repack Kernel+Recovery Images, and Edit the ramdisk.

      Windows ports of the necessary Linux utils for Android image (kernel/recovery) mod work:

      mkbootimg, unpackbootimg: https://github.com/osm0sis/mkbootimg
      pxa-mkbootimg, pxa-unpackbootimg: https://github.com/osm0sis/pxa-mkbootimg
      elftool: https://github.com/osm0sis/elftool
      unpackelf: https://github.com/osm0sis/unpackelf
      mboot: https://github.com/osm0sis/mboot
      dumpimage, mkimage: https://www.denx.de/wiki/U-Boot/WebHome
      mkmtkhdr: https://github.com/osm0sis/mkmtkhdr
      loki_tool: https://github.com/djrbliss/loki
      futility: https://github.com/osm0sis/futility
      boot_signer.jar (requires JRE 8+): https://forum.xda-developers.com/an...signing-boot-images-android-verified-t3600606
      blobpack, blobunpack: https://github.com/AndroidRoot/BlobTools
      dhtbsign: https://github.com/osm0sis/dhtbsign
      rkcrc: https://github.com/rockchip-linux/rkflashtool
      sony_dump: https://forum.xda-developers.com/crossdevice-dev/sony/tool-unpack-format-sony-kernel-image-t3530077
      bzip2, cat, chmod, cpio, cut, dd, file, find, gzip, hexdump, lzop, printf, tail, truncate, xz;
      cygbz2-1, cygcrypto-1.1, cyggcc_s-1, cygiconv-2, cygintl-8, cyglzma-5, cyglzo2-2, cygmagic-1, cygncursesw-10.dll, cygstdc++-6.dll, cygssl-1.1, cygwin1, cygz: https://cygwin.com/
      lz4: https://lz4.github.io/lz4/
      sudo: https://github.com/mattn/sudo
      magic: https://www.darwinsys.com/file/

      See the Mobile Edition (AIK-mobile) initial release notes for the specifics on the native Android version.
      Likewise for the Linux/macOS Edition (AIK-Linux) initial release notes.

      My original intent was to have this package dependency-free, but as you can see, I did have to include Cygwin. Initially just for mkbootimg since the huaixzk standalone version wouldn't work (it wasn't loading the kernel as binary, thanks trevd); then I discovered that using the GNUWin32 cpio to unpack somehow didn't play nice with repacking the ramdisk in a usable state, so at that point I decided I might as well go Cygwin across the board. As it is, I've included the latest Cygwin-dependent executables and required libraries from their repos and built my own custom Cygwin image and ramdisk utilities built from the latest sources.

      Originally only for Google Pixel/Nexus/AOSP standard boot.img files, built-in support has now expanded to Google Pixel/AOSP vendor_boot.img files, Android Verified Boot (AVBv1)/ChromeOS/SignBlob signed boot.img files, Barnes & Noble Nook "Green Loader" signed boot.img files, Samsung/Spreadtrum DHTB header signed boot.img files, the Samsung/Marvell PXA1088/1908 board boot.img variant (AOSP-PXA), Loki patched boot.img files, amonet patched boot.img files, Sony SIN signed/packaged kernel.elf extraction, Sony ELF kernel.elf files, Intel OSIP Android image files, DENX U-Boot uImage files, Rockchip KRNL signed ramdisk image files, MTK headers for kernel/ramdisk, and LG Bump/Samsung SEAndroid footers for boot.img.

      The main advantage here is you don't need Cygwin shell or PERL scripts. Other guides exist but none of them are universal for target device, compression and/or developed for Windows, Android ARM/x86/MIPS + ARM64/x86_64/MIPS64, and now macOS. With this universality in mind I've automated the whole process with batch/shell scripts.

      My development work on my many projects comes out of my free time, so if you enjoy this project or anything else I've done on xda, please consider sponsoring my ongoing work using my GitHub Sponsors profile. For a one-time donation you can hit the donate link from my profile. Thank you for your support!


      Instructions

      1)
      Unzip.
      2) Either use the command-line "unpackimg <image-filename.img>", or simply drag-and-drop the image. This will split the image and unpack the ramdisk to a subdirectory.
      3) Alter the ramdisk as you like.
      4) The repackimg script requires no input and simply recombines the previously split kernel with the newly packed modified ramdisk using all the original image information (which was also split and saved).
      5) The cleanup script resets the folder to its initial state, removing the split_img+ramdisk directories and any new packed ramdisk or image files.

      There are a few optional, advanced command-line arguments for repackimg: "--original", which will cause it to repack using the original split ramdisk instead of repacking, this is useful for testing or trimming dumps; "--origsize", which will cause it to repack then pad it to the size of the original image, this is useful for repacking dumps to then be fastboot flashed; "--level" with 1-9 and possibly 0 allows changing the compression level used to repack to more closely match the original; "--avbkey" with (optionally path and) a keyname allows changing from the default AOSP verity key; "--forceelf" to attempt to make an older unpacked Sony ELF file repack as an ELF.

      All scripts also allow unpacking/repacking with the current directory instead of the AIK directory if "--local" is the first command-line argument.

      Usage is similar for the Android and Linux versions, again, just review the release notes for them.

      Hopefully this is some help to someone. It's been extremely useful for me in my messing around with kernel ramdisks, which is why I created it in the first place.

      Enjoy!
      Questions, comments and feedback welcome.



      Downloads

      Android.Image.Kitchen.v3.8-Win32.zip

      UPDATE-AIK.Mobile.Installer.v3.8-ALL-signed.zip

      AIK-Linux-v3.8-ALL.tar.gz


      Source Code

      https://github.com/osm0sis/Android-Image-Kitchen


      Credits & Thanks: All authors of the included binaries and libraries for their amazing work, as linked (or linked via GitHub) above. Peteragent5, alansj & iridaki for the general methods used in their PERL scripts and Linux guides. SuperR. & tobias.waldvogel for the general methods used in their kernel.elf unpacking scripts. _that and rayman for the general methods used to repack a working boot.blob. Chainfire for the ChromeOS and SEAndroid general methods. cybojenix for the Bump general method. xyz` & k4y0z for the amonet general method.

      Thanks to Goatshocker for testing out things for the HTC image issues, leading to the workaround and subsequent fix, avinashrocks1990 & tajimura for testing out compression support and the large pagesize fix, civato for testing out dtb support, talich for testing out the Linux version, shoey63 for testing out Linux + ELF support, moonbutt74 for testing out Android-x86 support, nathanchance for testing out the new AIK-mobile cpio method on his Pixel 2, leading to important fixes for its support, shakalaca for the great help with completing and testing Intel OSIP support, and Postman1year & CXZa for their help testing to find out the workaround for the Cygwin cut + symlink regression issues. Huge thank you to trevd and Modding.MyMind/SHM for all the contributing work they've each done and support they've provided.

      Disclaimer: Naturally, you take all the responsibility for what happens to your device when you start messing around with things.

      Download counts:

      AIK - v1.0: 1540; +HTCFix: 430. v1.5: 4718. v1.6: 3556. v1.8: 8678; +Lok2Img: 1629. v1.9: 2580. v2.0: 22886. v2.2: 20522. v2.3: 14524. v2.4: 84432; +LokiAddon: 20071. v2.5: 5004. v2.6: 9354. v2.7: 5442. v2.8: 6639. v2.9: 7672. v3.0: 2810. v3.1: 6502. v3.2: 27104. v3.3: 17736. v3.4: 25988. v3.5: 19051. v3.6: 32472. v3.7: 21457.
      Mobile - v1.0: 311. v1.1: 265. v1.2: 302. v1.3: 100. v1.4: 486. v1.5: 224. v1.6: 3303. v1.7: 7798. v1.8: 16286. v1.9: 3800. v2.0: 5444. v2.1: 2526. v2.2: 926. v2.3: 1346. v2.4: 18426. v2.5: 2586. v2.6: 6068. v2.7: 2936. v2.8: 3932. v2.9: 4181. v3.0: 1301. v3.1: 3300. v3.2: 3254. v3.3: 6824. v3.4: 10786. v3.5: 8624. v3.6: 14020. v3.7: 8951.
      Linux - v1.0: 75. v1.1: 208. v1.2: 233. v1.3: 112. v1.4: 421. v1.5: 173. v1.6: 1838. v1.7: 2596. v1.8: 4818. v1.9: 604; +v1.9.1: 1068. v2.0: 1836. v2.1: 1240. v2.2: 466. v2.3: 522. v2.4: 8126. v2.5: 1052. v2.6: 2018. v2.7: 1248. v2.8: 2486. v2.9: 5057. v3.0: 1455. v3.1: 2957. v3.2: 14508. v3.3: 10046. v3.4: 16294. v3.5: 12651. v3.6: 16478. v3.7: 12927.
      151
      AIK should be universal for devices that accept Android, ELF, OSIP, U-Boot and KRNL format images in theory, but there is always a chance it doesn't work for your device due to image packing differences, etc. Here is a running list of confirmed working and questionably/confirmed not working devices. If your device isn't in either list odds are that it will still work fine.

      Known Working Devices

      Amazon Fire HD 10
      Asus Nexus 7 (2012, 2013)
      Asus Transformer Pad
      Asus Zenfone (2, 5)
      Auchan QiLive (Q5, Q7)
      Barnes & Noble Nook ( , HD+, 7)
      BQ Aquaris M8
      Coolpad Catalyst
      Essential PH-1
      Google Pixel (C, , XL, 2, 2 XL, 3, 3 XL, 3a, 3a XL, 4, 4 XL, 4a, 4a 5G, 5)
      Huawei Ascend Y300
      Huawei Mate 8
      Huawei Nexus 6P
      Huawei U8800 Ideos X5
      HTC Nexus 9
      HTC One (M7, M8, S, X)
      HTC Vivid/Raider 4G
      HP Slate 21
      LeEco Le Pro3
      Lenovo A706
      Lenovo K900
      Lenovo Vibe K5
      LG G(2, 2 Mini, 3, 3 Stylus, 5)
      LG GPad (7.0, 8.3, X 8.0)
      LG Nexus (4, 5, 5X)
      LG Optimus (3D, 4X HD)
      LG Stylo 3 Plus
      LG V(10, 20)
      Micromax Ninja/Bolt A27
      Motorola Moto G (2013, 2014)
      Motorola Moto X 2014
      Motorola Nexus 6
      Nextbit Robin
      OnePlus (One, 2, X, 3, 3T, 5, 5T, 6, 6T, 7, 7 Pro, 7T, 7T Pro, 8, 8 Pro, 8T, 9, 9 Pro)
      Pantech Vega Iron
      Pantech Vega Secret Note
      Samsung Galaxy A3 2016
      Samsung Galaxy Ace II X
      Samsung Galaxy Core Mini 4G
      Samsung Galaxy Mega
      Samsung Galaxy Nexus
      Samsung Galaxy Note (2, 3, 4, Pro 12.2)
      Samsung Galaxy S(3, 3 Mini, 4, 5)
      Samsung Galaxy Star
      Samsung Galaxy Tab (2 7.0, 3 10.1, 4 7.0, 4 8.0, 4 10.1, A 7.0, A 10.1, Pro 8.4)
      Samsung Galaxy Victory
      Samsung Galaxy Xcover 3
      Samsung Nexus 10
      Sony Xperia (Arc S, M, Neo, Neo V, SP, Tab Z4, Z, Z1, Z5)
      Spice Mi-355 Stellar Craze
      Vodafone Smart Ultra 6
      Xiaomi Mi Pad
      Xiaomi Poco X2
      Xiaomi Redmi (6A, Note 3 Pro)


      Confirmed Not Working Devices
      • Blackview BV4000 - some newer MediaTek (MTK) devices use special image signing that adds a "BFBF" pre-header signature. While present on multiple MTK devices, it only appears to be enforced by the bootloader on some. See this post.
      • HTC Desire 326G, Huawei Honor Bee, Huawei MediaPad T1 7.0 - some newer Spreadtrum devices use special image signing that adds a "SPRD-SECUREFLAG" pre-header signature, so images will unpack/repack but most likely won't boot unless run through their internal signing tool. See this post.
      • Nibiru V05-A - some RockChip (RK) devices use a variant of the AOSP image format with extra checksums and hidden sections with extra data. There is not currently an open source tool that can handle repacking these. See this post.
      • Samsung Galaxy S (Advance, Captivate, Vibrant), Samsung Galaxy S2, Samsung Galaxy Note & Samsung Galaxy Tab - contain zImage (kernel) + ramdisk (possibly within the zImage) but are the "headerless" Linux kernel blob format and require a full cross-compiler to repack correctly. See this post.
      • Samsung [various] - the image and SEANDROIDENFORCE footer are followed by a signature that, while present on many Samsung devices, only appears to be enforced by the bootloader on some. See this post.
      • Skyworth 50G2A TV - some newer MediaTek (MTK) devices use special image part signing that adds a 256-byte checksum/signature to both Image.gz-dtb/zImage-dtb (kernel) and ramdisk.cpio.gz, so images will unpack/repack but most likely won't boot unless run through their internal signing tool. See this post.
      • Xiaomi Mi Box 3S, ZTE B860H STB - some newer Amlogic devices use special image signing that adds an "AMLSECU!" signature within the header and appears to encrypt the ramdisk, so the image itself will unpack/repack but cannot be re-signed, and the ramdisk cannot be unpacked or modified.

      Note: For devices requiring Loki patched images (e.g. LG G2, AT&T Samsung Galaxy S4), your device's aboot.img dump must be in the script directory to Re-Loki. (Thank you to jeboo for the original one-way Lok2Img Workaround's binary source, used prior to the official Loki Tool gaining un-Loki support).


      Release Notes

      Windows:
      v1.0 - Dec 30, 2012 - Initial release.    
      v1.5 - May 6, 2013 - Linked.
      v1.6 - Sep 16, 2013 - Linked.
      v1.8 - Dec 9, 2013 - Linked.
      v1.9 - Jun 7, 2014 - Linked.
      v2.0 - Aug 3, 2014 - Linked.
      v2.2 - Mar 25, 2015 - Linked.
      v2.3 - Oct 11, 2015 - Linked.
      v2.4 - Feb 8, 2016 - Linked.
      v2.5 - Jan 26, 2017 - Linked.
      v2.6 - Feb 27, 2017 - Linked.
      v2.7 - May 1, 2017 - Linked.
      v2.8 - Jun 5, 2017 - Linked.
      v2.9 - Sep 14, 2017 - Linked.
      v3.0 - Dec 14, 2017 - Linked.
      v3.1 - Jan 7, 2018 - Linked.
      v3.2 - Mar 19, 2018 - Linked.
      v3.3 - Jul 23, 2018 - Linked.
      v3.4 - Oct 28, 2018 - Linked.
      v3.5 - Apr 17, 2019 - Linked.
      v3.6 - Sep 22, 2019 - Linked.
      v3.7 - May 22, 2020 - Linked.
      v3.8 - May 5, 2021 - Linked.

      Android:
      v1.0 - Mar 23, 2014 - Linked. (ARM only)
      v1.1 - Apr 19, 2014 - Linked. (ARM only)
      v1.2 - May 15, 2014 - Linked. (ARM only)
      v1.3 - Jun 7, 2014 - Linked. (ARM, x86 with emulation)
      v1.4 - Jun 17, 2014 - Linked. (ARM, x86 with emulation)
      v1.5 - Aug 3, 2014 - Linked. (32bit, x64 with emulation)
      v1.6 - Aug 19, 2014 - Linked. (32bit, x64 with emulation)
      v1.7 - Dec 26, 2014 - Linked. (32bit, x64 with emulation)
      v1.8 - Mar 25, 2015 - Linked. (32bit, x64 with emulation)    
      v1.9 - Oct 11, 2015 - Linked. (32bit, x64 with emulation)
      v2.0 - Dec 7, 2015 - Linked.
      v2.1 - Feb 8, 2016 - Linked.
      v2.2 - Mar 16, 2016 - Linked.
      v2.3 - Apr 1, 2016 - Linked.
      v2.4 - Apr 20, 2016 - Linked.
      v2.5 - Jan 26, 2017 - Linked.
      v2.6 - Feb 27, 2017 - Linked.
      v2.7 - May 1, 2017 - Linked.
      v2.8 - Jun 5, 2017 - Linked.
      v2.9 - Sep 14, 2017 - Linked.
      v3.0 - Dec 14, 2017 - Linked.
      v3.1 - Jan 7, 2018 - Linked.
      v3.2 - Mar 19, 2018 - Linked.
      v3.3 - Jul 23, 2018 - Linked.
      v3.4 - Oct 28, 2018 - Linked.
      v3.5 - Apr 17, 2019 - Linked.
      v3.6 - Sep 22, 2019 - Linked.
      v3.7 - May 22, 2020 - Linked.
      v3.8 - May 5, 2021 - Linked.

      Linux/macOS:
      v1.0 - Apr 11, 2014 - Linked. (x86, Linux only)
      v1.1 - Apr 19, 2014 - Linked. (x86, Linux only)
      v1.2 - May 15, 2014 - Linked. (x86, Linux only)
      v1.3 - Jun 7, 2014 - Linked. (x86, Linux only)
      v1.4 - Jun 17, 2014 - Linked. (x86, Linux only)
      v1.5 - Aug 3, 2014 - Linked. (x86, Linux only)
      v1.6 - Aug 19, 2014 - Linked. (x86, Linux only)
      v1.7 - Dec 26, 2014 - Linked. (Linux only)
      v1.8 - Mar 25, 2015 - Linked. (Linux only)
      v1.9 - Oct 11, 2015 - Linked. (Linux only)
      v2.0 - Dec 7, 2015 - Linked. (Linux only)
      v2.1 - Feb 8, 2016 - Linked. (Linux only)
      v2.2 - Mar 16, 2016 - Linked. (Linux only)
      v2.3 - Apr 1, 2016 - Linked. (Linux only)
      v2.4 - Apr 20, 2016 - Linked. (Linux only)
      v2.5 - Jan 26, 2017 - Linked. (Linux only)
      v2.6 - Feb 27, 2017 - Linked. (Linux only)
      v2.7 - May 1, 2017 - Linked. (Linux only)
      v2.8 - Jun 5, 2017 - Linked. (Linux only)
      v2.9 - Sep 14, 2017 - Linked. (Linux only)
      v3.0 - Dec 14, 2017 - Linked.
      v3.1 - Jan 7, 2018 - Linked.
      v3.2 - Mar 19, 2018 - Linked.
      v3.3 - Jul 23, 2018 - Linked.
      v3.4 - Oct 28, 2018 - Linked.
      v3.5 - Apr 17, 2019 - Linked.
      v3.6 - Sep 22, 2019 - Linked.
      v3.7 - May 22, 2020 - Linked.
      v3.8 - May 5, 2021 - Linked.




      Everyone please let me know if AIK works for your devices or if you encounter any problems, so I can make these lists more comprehensive. 👍

      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.
      61
      Android ARM/ARM64, x86/x86_64 + MIPS/MIPS64 version of Android Image Kitchen! Now you can easily modify ramdisks on the go! :D

      AIK-mobile:
      - Almost complete feature parity with the Windows/Linux version, including compression support, --original to repack with the original ramdisk, --origsize to pad the repacked image to the size of the original, --level to change the compression level of the repacked ramdisk, --avbkey to change the key used for Android Verified Boot (AVBv1) signing of the repacked image, and --forceelf to make an older unpacked Sony ELF file repack as an ELF. The only thing missing is --local since AIK-mobile's ability to unpack/repack while booted in Android is too complex to easily allow moving the unpack/repack directory around.
      - The flashable zip installs AIK for your Android architecture (ARM/ARM64, x86/x86_64, MIPS/MIPS64) to /data/local/AIK-mobile/ and a helper script created at /system/xbin/aik (alternately /su/bin/aik or /sbin/supersu/bin/aik if SuperSU systemless root is detected, or, /sbin/.magisk/img/aik-mobile/bin/aik or /data/adb/modules/aik-mobile/bin/aik if Magisk is detected).
      - Type "aik" in Terminal Emulator to automatically go to the install directory and get a root prompt, then use, eg. "unpackimg.sh boot.img" to get started.
      - Running su -c "/data/local/AIK-mobile/bin/aik --restore" will recreate the aik helper script in the appropriate place (see above), e.g. after a ROM flash with su.img SuperSU or magisk.img Magisk removed.
      - "aik --uninstall" should be self-explanatory, and "--help" is also available for all included scripts.

      Now also possible to run entirely from a file explorer app, see this post for details!

      To run from TWRP (recovery shell), follow the instructions in this post.

      mkbootimg, unpackbootimg: https://github.com/osm0sis/mkbootimg
      pxa-mkbootimg, pxa-unpackbootimg: https://github.com/osm0sis/pxa-mkbootimg
      elftool: https://github.com/osm0sis/elftool
      unpackelf: https://github.com/osm0sis/unpackelf
      mboot: https://github.com/osm0sis/mboot
      dumpimage, mkimage: https://www.denx.de/wiki/U-Boot/WebHome
      mkmtkhdr: https://github.com/osm0sis/mkmtkhdr
      loki_tool: https://github.com/djrbliss/loki
      futility: https://github.com/osm0sis/futility
      boot_signer-dexed.jar: https://forum.xda-developers.com/an...signing-boot-images-android-verified-t3600606
      blobpack, blobunpack: https://github.com/AndroidRoot/BlobTools
      dhtbsign: https://github.com/osm0sis/dhtbsign
      rkcrc: https://github.com/rockchip-linux/rkflashtool
      sony_dump: https://forum.xda-developers.com/crossdevice-dev/sony/tool-unpack-format-sony-kernel-image-t3530077
      busybox: https://busybox.net/; https://github.com/osm0sis/android-busybox-ndk
      file, magic: https://www.darwinsys.com/file/
      xz: https://tukaani.org/xz/
      lz4: https://lz4.github.io/lz4/

      GitHub: https://github.com/osm0sis/Android-Image-Kitchen/commits/AIK-mobile

      Originally all but busybox were compiled natively on my Nexus 7 2013 using a KBox2 build environment, now cross-compiled with the NDK on my PC and my own AIK Build Farm. :cowboy:

      Notes: You may delete /data/local/AIK-mobile/bin/busybox if you want to use your ROM's busybox instead.


      Linux will be next on the list, and should be pretty easy since I did all of the shell script leg work with the Android version. ;) :good:


      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.
      34
      Another longtime request. New Linux version of Android Image Kitchen up in the OP! Bringing my updated binaries back home! ;)

      Now also supporting macOS out-of-the-box (i.e. no Homebrew or MacPorts addons needed) with v3.0+!

      AIK-Linux:
      - Complete feature parity with the Windows/Android versions, including compression support, --original to repack with the original ramdisk, --origsize to pad the repacked image to the size of the original, --level to change the compression level of the repacked ramdisk, --avbkey to change the key used for Android Verified Boot signing of the repacked image, and --forceelf to make an older unpacked Sony ELF file repack as an ELF.
      - Unpacks as root by default to maintain full control over all repacked ramdisk file permissions, --nosudo argument available to attempt unpack/repack as user if possible.
      - All scripts allow unpacking/repacking with the current directory instead of the AIK directory if --local is the first command-line argument.
      - "--help" is also available for all included scripts.
      - Unpack with "tar -xzvf AIK-Linux-*.tar.gz" in your home directory then you can go to AIK-Linux and use, eg. "./unpackimg.sh boot.img" to get started.

      mkbootimg, unpackbootimg: https://github.com/osm0sis/mkbootimg
      pxa-mkbootimg, pxa-unpackbootimg: https://github.com/osm0sis/pxa-mkbootimg
      elftool: https://github.com/osm0sis/elftool
      unpackelf: https://github.com/osm0sis/unpackelf
      mboot: https://github.com/osm0sis/mboot
      dumpimage, mkimage: https://www.denx.de/wiki/U-Boot/WebHome
      mkmtkhdr: https://github.com/osm0sis/mkmtkhdr
      loki_tool: https://github.com/djrbliss/loki
      futility: https://github.com/osm0sis/futility
      boot_signer.jar (requires JRE 8+): https://forum.xda-developers.com/an...signing-boot-images-android-verified-t3600606
      blobpack, blobunpack: https://github.com/AndroidRoot/BlobTools
      dhtbsign: https://github.com/osm0sis/dhtbsign
      rkcrc: https://github.com/rockchip-linux/rkflashtool
      sony_dump: https://forum.xda-developers.com/crossdevice-dev/sony/tool-unpack-format-sony-kernel-image-t3530077
      lz4: https://lz4.github.io/lz4/
      magic: https://www.darwinsys.com/file/
      cpio, dd, file, lzop, tail, truncate, xz; libiconv.2, libintl.8, liblzma.5, liblzo2.2, libmagic.1 (macOS): https://www.macports.org/
      gzip, bzip2, lzop, xz; awk, basename, bash, cpio, cut, dd, dirname, env, file, find, grep, hexdump, java, printf, rev, sed, stat, sudo, tail, truncate, wc (Linux): (required system packages/commands)

      GitHub: https://github.com/osm0sis/Android-Image-Kitchen/commits/AIK-Linux

      Most included binaries were compiled using my patched crosstool-ng i686 and x86_64 Cygwin to Linux cross-compiler toolchains, now as part of my own AIK Build Farm. :cowboy:

      macOS compiles built with osxcross. Instructions available via my Build Farm post.

      I'm not going to interfere with anyone's Linux installations, nor needlessly bundle a ton of commonly available binaries, so if you need extra compression support you need to have those packages installed. In my Ubuntu Server VM gzip, bzip2 and xz/lzma all seem to come pretty much by default, and "apt-get install lzop" handles lzop. Java depends on your setup, but openjdk-8-jre will be what most will want if not already included. lz4 would be the only one that would have to be built from source on many distros, so I have considered it an exception, built it and included it myself.

      Thanks to shoey63 and talich for testing. Cheers! :)


      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.
      30
      It's been a busy few weeks!

      After a Herculean effort to get the DENX U-Boot utilities to build with the NDK, which required me firing up my Ubuntu VM (for more than testing for once) and then hacking both the NDK toolchains and tool sources, say hello to U-Boot support! It's a *nix standard, and pretty rare on Android but it does exist (e.g. LG Optimus 3D) and I'm extremely pleased to add support for this completely different type of image format to AIK! :cowboy:

      I then added support for the Samsung/Marvell variant of the AOSP standard for their pxa1088 board, which I've termed "AOSP-PXA", by updating a modified bootimg tools fork to continue the excellent work done by @ketut.kumajaya and @akuhak. There aren't a lot of known examples of these either (e.g. Samsung Galaxy Core Mini 4G, Samsung Galaxy Tab 4 7.0 & Samsung Galaxy Xcover 3) but it was pretty straightforward and removes another entry from the "Confirmed Not Working" list in the OPs. ;)

      Next up, Sony SIN packaging/signature unpack support, thanks to the brilliant research and development of @munjeni for his closed-source kernel_dump binary, of which he also supplied the builds.

      Last but not least, it turns out the signatures I identified on the Pixels last month almost immediately went into enforcement after my release.. and it turns out we misunderstood the nature of these signatures so I have reverted the unpackbootimg patch that was originally submitted to me for the Xioami Mi MAX where these signatures were first found; while reappending the original signature was reported to have worked for the Mi MAX, the Pixel bootloader appears to be enforcing it even more strictly and so they must be signed correctly. Luckily, thanks to the great and ongoing work of @Chainfire we've got a cross-platform working signing tool, but it does rely on a Java-like VM - Java Runtime Environment (JRE) 8+ for Windows/Linux to run correctly - and we can use the Dalvik VM on Android without any issues drawing in part from my previous experiments in this area.

      Since the original AVB signing OEM keys are naturally unavailable this presents a bit of a problem and there are numerous keys already floating around including SuperSU, ElementalX and a few custom Pixel ROMs. To be sensible we the modding community should all try to use the same keys for interoperability, to make sure different mods stack correctly and avoid any possible problems with encrypted devices, so I have generated the required extra certificate for AVB signing from the usual AOSP testkeys and would encourage all other boot image modifying projects to use them; they are available for use on my GitHub. They are the default for AIK, but a user may specify --avbkey on the repackimg commandline to force the use of other keys. The keys may be placed in the main AIK directory and specified without path with only the base name of the files (e.g. --avbkey supersu for supersu.pk8 and supersu.x509.der) or with a path, but still omitting the file extensions to keep it simple (e.g. --avbkey /path/to/ex for /path/to/ex.pk8 and /path/to/ex.x509.der). Hopefully that'll cover all the bases and some other projects will come around to using the testkeys.

      Per usual, the AIK Build Farm has been updated accordingly. Enjoy! :)

      NOTE: Downloads have switched to being hosted on the XDA DevDB Project Downloads page since AIK-mobile now exceeds the 20mb zip attachment size limit.

      I work on these projects in my limited time off, so if you like the progress I'm making, or enjoy anything else I've done on xda, please do hit the donate link from my profile. Thanks for your support!


      Android Image Kitchen v2.8:
      - general cleanup using if/else and absolute paths wherever possible and removing hidden hideErrors option for simplicity since it's no longer needed
      - add detection if running directly from a command prompt and do not pause if so
      - add error catching for unsupported/unrecognized formats on repack, and compression formats on unpack
      - update unpackbootimg and unpackelf binaries from my repos
      - add DENX U-Boot uImage detection and use dumpimage and mkimage to unpack/repack
      - add Samsung/Marvell boot.img variant (AOSP-PXA) and use pxa1088-unpackbootimg and pxa1088-mkbootimg to unpack/repack
      - add Sony SIN signature/packaging detection and use kernel_dump to extract the kernel.elf
      - add Android Verified Boot (AVB) signature footer detection and use BootSignature.jar to re-sign with AOSP testkeys (https://github.com/osm0sis/testkeys)
      - dump AVB type (boot/recovery) to -avbtype so that it may be changed for repack if desired
      - refactor repackimg commandline parameter parsing and introduce --avbkey to specify custom keys (accepts path and/or filename minus extensions) to use for AVB re-signing
      - update slimmed magic file (from file 5.31) with my own fixes
      - update to the latest Cygwin binaries and libraries

      AIK-mobile v2.8 + AIK-Linux v2.8:
      - general cleanup using absolute paths wherever possible
      - add error catching for unsupported formats on repack, and compression formats on unpack
      - fix unpack error output on some xz/lzma ramdisks by using included xz binary instead of busybox (AIK-mobile)
      - update unpackbootimg and unpackelf binaries from my repos
      - add DENX U-Boot uImage detection and use dumpimage and mkimage to unpack/repack
      - add Samsung/Marvell boot.img variant (AOSP-PXA) and use pxa1088-unpackbootimg and pxa1088-mkbootimg to unpack/repack
      - add Sony SIN signature/packaging detection and use kernel_dump to extract the kernel.elf
      - add Android Verified Boot (AVB) signature footer detection and use BootSignature.jar to re-sign with AOSP testkeys (https://github.com/osm0sis/testkeys)
      - dump AVB type (boot/recovery) to -avbtype so that it may be changed for repack if desired
      - refactor repackimg commandline parameter parsing and introduce --avbkey to specify custom keys (accepts path and/or filename minus extensions) to use for AVB re-signing
      - actually fix chromeos subfolder permissions during install (AIK-mobile)
      - fix unpackimg --help to show --sudo option (AIK-Linux)
      - update file binary (5.31) (AIK-mobile)
      - update slimmed magic file (from file 5.31) with my own fixes


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

      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.
    Our Apps
    Get our official app!
    The best way to access XDA on your phone
    Nav Gestures
    Add swipe gestures to any Android
    One Handed Mode
    Eases uses one hand with your phone