FORUMS
Remove All Ads from XDA

[TOOL][UTILITY] Carliv Image Kitchen for Android - unpack/repack boot-recovery

1,027 posts
Thanks Meter: 5,057
 
By bluefirebird, Senior Member on 26th January 2015, 07:00 PM
Thread Closed Email Thread


Hi, I present you my tool for unpacking/repacking boot and recovery images for Android phones: Carliv Image Kitchen for Android.

2016-06-30 Update to version 1.3 stable
Changelog:
- detect mtk header during unpacking;
- removed grep method;

Instructions can be found in every variant folder.

To start it just double click on carliv.bat script (windows) or carliv script (Linux) then choose "Run in terminal" from dialog box.





Credits:
yuweng for his assistance and help on testing and troubleshooting (you should thank him too guys - it was a great help);
michfood for initial starting ideea;
osm0sis for bootimg-info source and some hints from his kitchen;
Cyanogenmod for mkbootimg source folder;
Omnirom for their clean implementation of MTK header.
Pete Batard for bootimage tools windows fix.
Thomas Polaert ([email protected]) for CECHO DOS coloring tool (windows version).

If you want to share this in other websites, blogs or forums please keep the credits from script files (I wrote those from scratch), and give proper credits for me.



Contributors
carliv, yuweng
The Following 179 Users Say Thank You to bluefirebird For This Useful Post: [ View ] Gift bluefirebird Ad-Free
26th January 2015, 07:00 PM |#2  
bluefirebird's Avatar
OP Senior Member
Thanks Meter: 5,057
 
More
Drag & Drop on linux CarlivImageKitchen version! function implemented by yuweng
Alternative linux version with Drag and Drop functionality, modded by my friend yuweng! -* carliv's edit: copied here from my friend's post.

Yes, now you can also Drag&Drop to UnPack/ RePack Android images on linux using CarlivImageKitchen !
Download CarlivImageKitchen-DnD.zip & extract to your linux Desktop, copy out all the five .desktop files to your Desktop & start Dragging & Dropping . . . You can also Drag&Drop it to same .desktop files inside CarlivImageKitchen folder & it'll to work too . . .

Tested working perfectly on BBQLinux & also Ubuntu, however, for Ubuntu you need to open the .desktop launcher shortcut with any text editor & manual edit the command as below . . .
Code:
gnome-terminal -e "bash -c \"~/Desktop/CarlivImageKitchen/image_info %f\""
i have also tested it on numerous of linux terminal program & it works perfectly too so you gotta manual edit it if you are using those . . .
Code:
terminator -e "bash -c "~/Desktop/CarlivImageKitchen/image_info %f""
konsole -e "bash -c "~/Desktop/CarlivImageKitchen/unpack_MTK_img %f""
mate-terminal -e "bash -c "~/Desktop/CarlivImageKitchen/image_info %f""
gnome-terminal -e "bash -c "~/Desktop/CarlivImageKitchen/repack_MTK_img %f""
lxterminal -e "bash -c "~/Desktop/CarlivImageKitchen/image_info %f""
roxterm -e "bash -c "~/Desktop/CarlivImageKitchen/image_info %f""
terminology -e "bash -c "~/Desktop/CarlivImageKitchen/repack_img %f""
sakura -e "bash -c "~/Desktop/CarlivImageKitchen/image_info %f""
xterm -e "bash -c "~/Desktop/CarlivImageKitchen/image_info %f""
xfce4-terminal -e "bash -c "~/Desktop/CarlivImageKitchen/unpack_img %f""
No more typing to unpack/ repack, just draaaagggg & drooooopppp it like you use to do that on Windows . . .

Full credits to Master Shifu Carliv, i just modded a few lines to support Drag&Drop, that's all . . .

Drag&Drop in Action !



Konsole


roxterm


sakura


gnome-terminal


lxterminal


mate-terminal


xterm


terminator


terminology


xfce4-terminal

If you want to hit the THANKS button for yuweng's version, go here and do it.
Attached Files
File Type: zip CarlivImageKitchen-Linux-DnD-yuweng.zip - [Click for QR Code] (117.3 KB, 24790 views)
The Following 42 Users Say Thank You to bluefirebird For This Useful Post: [ View ] Gift bluefirebird Ad-Free
26th January 2015, 07:00 PM |#3  
bluefirebird's Avatar
OP Senior Member
Thanks Meter: 5,057
 
More
Mirror Downloads
2015-04-08 Big Update to version 1.0 stable
Changelog:
- corrected few issues in scripts;
- rebuilt all modules also to correct some issues;
- cleaned up the source;
- added more compression support - see next;
- now the kitchen supports ramdisks compressions as following: gz, bz2, lzma, xz, lzo, lz4;
- converted to a Menu driven interface: now everything can be done from inside kitchen menu with few clicks;
- updated Instructions (can be loaded in kitchen interface for reading).

* for those of you who don't want the menu interface, there is version 0.5 in download list, with the old individual scripts structure but updated with same modules and compression support as version 1.0 (I kept this especially for windows, where it can be used with drag and drop).

2015.02.16 Update version 0.3
  • rebuilt binaries to correct few issues.
  • some fixes in scripts.
  • generate correct sha id.
  • use minigzip for repacking ramdisk as in recovery building.
  • compiled standalone bzip2 module.

So, what's this?
It's a utility (tool) for unpacking and repacking boot and recovery images for many kind of android phones. I made two versions, one for windows users and one for linux users. The windows version works by dragging&dropping over the script you want to use, while the linux version will work with terminal commans (very simple commands though).
What's inside?
For windows version the scripts are batch files and for linux bash files, but the names are the same and they do same thing:
  1. clear_all will clear the working folder deleting any unpacked boot/recovery folder, but not the boot or recovery files (original or repacked).
  2. image_info will print on screen all informations about the image you want to check (sizes, offsets, cmdline, etc.) and all these infos will be saved in a text file (which will be deleted when you clear the folder - see point 1). This is handy if you don't want to unpack the image, but only to see its infos. This script works for all kind of images (not specific to a hardware platform).
  3. unpack_img is the script for unpacking images for all kind of phones with different platforms (qcom, exynos,...) but not MTK. It will work I think for AndroidOne project phones.
  4. unpack_MTK_img is the script for unpack any MTK image, including the ones from new platforms (mt6595, mt6752, mt6753, and whatever they are).
  5. repack_img is the repacking script for regular (non-MTK) phones.
  6. repack_MTK_img is the repacking script for all MTK boot/recovery images.
Besides these in Utility folder there is a bin folder (hidden) with all executables needed by the scripts.
How to use it?
As I said, for windows just drag&drop an image (boot or recovery) you want to unpack over the corresponding script, and drag&drop the folder of the unpacked image over the repacking script when you want to repack it. Choose the scripts with MTK in name for MTK images, and the other ones for any other kind.
For linux open a terminal window in CarlivImageKitchen folder and type (or just copy/paste from here) the commands:
Code:
./unpack_img boot.img
or
Code:
./unpack_MTK_img recovery.img
or what name has your image.
To repack type like this:
Code:
./repack_img recovery
or
Code:
./repack_MTK_img boot
and so on.
NOTICE here for repacking just type the name of the folder, without slashes.

Important, my utility doesn't have any request for position on partitions or directories. In testes worked in a third sub-sub-subfolder on an external partition (both in linux and windows), and it proves to work with any kind of name (except special characters that may break the script), including spaces or dots in folders names, but I recommend you to use dashes or underscores instead of spaces, and avoid dots. In repacking procedure, the script will prompt you to introduce a name for the new image, and if it will contain dots or spaces you will see an error. Also the name must include the type of image (boot or recovery) - Eg: "boot-stock-repack" or "recovery_cwm_m7", and without the extension (.img).
Same condition about names applies for images you want to unpack; if they have other names, like "cwm-m7.img", rename it including the type of image in name: eg "recovery-cwm-m7.img". Why this? As many of you used bgcngm's tool you noticed he asked for including an argument in script command ("-boot" or "-recovery") because this is the way his script can apply the right header for ramdisks in repacking. My tool does that from image name and you don't have to add extra arguments in command.
A second note: This tool doesn't support Rockchip Android images.
What's under hood?
All modules used in my tools are compiled by me, both for windows and linux.
Also for windows, because it requires few cygwin libraries to work with compressing/uncompressing executables, I used those libraries and executables from latest cygwin release (gzip, xz, bzip2, cpio and the corresponding dlls).
But my utility doesn't require a cygwin installed. Well, linux version worked very well in cygwin environment, but it's not necessary since I provided a standalone windows version.
The executable modules:
  1. imageinfo - a initial source is shared by osm0sis here, but I used that only for inspiration because I liked the ideea; I used the unpackbootimg from cyanogenmod 12, system/core/mkbootimg and modded to get a similar output as in osm0sis bootimg-info.
  2. mkbootfs - built in cygwin for windows and normal in linux. I used the "stock" source from cyanogenmod 12 /system/core/cpio.
  3. mkbootimg - based cyanogenmod 12 source, but modded, and for windows fixed to work (the standard source it builds in windows but doesn't work). I used for fixing the ideeas from Pete Batard's source. This module repack also dtb-images back to repacked image.
  4. mtkbootimg - same as mkbootimg, but with additions from omnirom code for MTK, to append the MTK header to this kind of images. This one will check first the kernel and then the ramdisk for MTK header, and if it's not there it will append it, but if it's there will skip.
  5. unpackbootimg - from same cyanogenmod 12 source, with few extra additions by me.
  6. unpackmtkimg - same as unpackbootimg but adapted for MTK images, for which will strip the header off before unpacking, to be easy to work with.
For windows I used jeremejevs cmdcolor source to build a module which add colors in cmd console, for a pleasant experience.
All these sources are modified, improved and fixed in some aspects.

Why I did it?
Well, the trigger was the apparition of the new platforms from MTK, which didn't worked with any of the old tools. First who found out what's changed was mrjavum. Starting from his findings I explored more, and then provided the update ideea and binaries for bgcngm's tool. But that is only for linux. I know it can be used in windows with cygwin, but we had a standalone tool, michfood's tool, which now doesn't work with the new platforms.
So I started to think for a new utility for windows to solve that need. After I did it I thought I can do it for linux too even if there exists already bgcngm's tool and works great. And I made it not only for MTK phones.
That's the reason I called it Image Kitchen. It is like a tool that combines michfood's tool with osm0sis Kitchen, and serves for different platforms (I tested MTK, Qualcomm, Exynos, with or without dtb, and all worked great). But it's first release, not fully tested (I don't have all kind of phones for that), and so it is marked beta.[/HIDE]

Cygwin-windows version
Removed since it was only for some specific testing, and anyway the windows version now works and it shows exactly the same with linux, producing same result.
Attached Thumbnails
Click image for larger version

Name:	logo.png
Views:	55164
Size:	30.6 KB
ID:	3251533  
The Following 30 Users Say Thank You to bluefirebird For This Useful Post: [ View ] Gift bluefirebird Ad-Free
26th January 2015, 09:58 PM |#4  
superdragonpt's Avatar
Recognized Developer
Flag Lisbon / Taiwan / USA
Thanks Meter: 19,164
 
Donate to Me
More
awesome

More goodies for me to test.

Thanks guys
The Following 3 Users Say Thank You to superdragonpt For This Useful Post: [ View ]
27th January 2015, 12:54 AM |#5  
Senior Member
Flag Manila
Thanks Meter: 151
 
More
This is great! No need to shuffle programs for unpacking/repacking boot and recovery images of various platforms.

Windows version working (MTK and non-MTK).

Tried to use the Linux version in cygwin and encountered the following errors:
Attached Thumbnails
Click image for larger version

Name:	CIKA.jpg
Views:	2424
Size:	81.1 KB
ID:	3135543  
The Following 2 Users Say Thank You to iZLeeP For This Useful Post: [ View ] Gift iZLeeP Ad-Free
27th January 2015, 03:51 AM |#6  
yuweng's Avatar
Senior Member
Thanks Meter: 4,232
 
More
There are already separate package for Windows & Linux so use the appropriate package however for beta-testing sake . . .
  1. Copy all the *.exe from Windows package -> hidden folder bin to Linux .bin folder.
  2. Add the extension exe to all linux binary at the script
Eg.
gzip -> gzip.exe
mkbootfs -> mkbootfs.exe
unpackmtkimg -> unpackmtkimg.exe
mtkbootimg -> mtkbootimg.exe

unpackbootimg -> unpackbootimg.exe
mkbootimg -> mkbootimg.exe
Now the linux script will work on cygwin . . .
The Following 6 Users Say Thank You to yuweng For This Useful Post: [ View ] Gift yuweng Ad-Free
27th January 2015, 05:49 AM |#7  
Senior Member
Flag Manila
Thanks Meter: 151
 
More
Thanks for the suggestion.

Now, unpack (MTK and non-MTK) works but repack does not. The repacked image is much smaller in size than that of the original. It also produces errors when I unpack the repacked image.
Attached Thumbnails
Click image for larger version

Name:	Untitled1.jpg
Views:	1942
Size:	79.4 KB
ID:	3135887   Click image for larger version

Name:	Untitled2.jpg
Views:	1864
Size:	79.9 KB
ID:	3135888   Click image for larger version

Name:	Untitled3.jpg
Views:	1818
Size:	89.1 KB
ID:	3135889   Click image for larger version

Name:	Untitled4.jpg
Views:	1318
Size:	91.1 KB
ID:	3135890  
27th January 2015, 06:13 AM |#8  
bluefirebird's Avatar
OP Senior Member
Thanks Meter: 5,057
 
More
Quote:
Originally Posted by iZLeeP

Thanks for the suggestion.

Now, unpack (MTK and non-MTK) works but repack does not. The repacked image is much smaller in size than that of the original. It also produces errors when I unpack the repacked image.

If you want to test it in cygwin you need to add all binaries from windows bin with exe extension except dlls (those are native) and compressing modules, and to replace those from linux. You can see in linux version all compressing modules are missing - they have to be installed in system. Same for cygwin. It's possible you got a cygwin with some packages missing. That error message you see is because it's missing cpio probably. The linux binaries are much smaller because the compiler works different in linux. In windows the modules are standalone and don't need any dll, except those for archiving from cygwin, but we are not talking about those.
Anyway what you do here is just cross testing, and you don't need to use linux version in windows because windows version works the same.
The Following 6 Users Say Thank You to bluefirebird For This Useful Post: [ View ] Gift bluefirebird Ad-Free
27th January 2015, 06:23 AM |#9  
Senior Member
Flag Manila
Thanks Meter: 151
 
More
Quote:
Originally Posted by carliv

If you want to test it in cygwin you need to add all binaries from windows bin with exe extension except dlls (those are native) and compressing modules, and to replace those from linux. You can see in linux version all compressing modules are missing - they have to be installed in system. Same for cygwin. It's possible you got a cygwin with some packages missing. That error message you see is because it's missing cpio probably. The linux binaries are much smaller because the compiler works different in linux. In windows the modules are standalone and don't need any dll, except those for archiving from cygwin, but we are not talking about those.
Anyway what you do here is just cross testing, and you don't need to use linux version in windows because windows version works the same.

Yes, I was just testing the functionality of the linux version in cygwin. As I don't have linux here (office), I use cygwin instead. I'll re-download full cygwin package and test again. Nonetheless, I have no problems with the windows version (tested in Vista and 7). I'll try it on XP at home.
27th January 2015, 06:33 AM |#10  
bluefirebird's Avatar
OP Senior Member
Thanks Meter: 5,057
 
More
Quote:
Originally Posted by iZLeeP

Yes, I was just testing the functionality of the linux version in cygwin. As I don't have linux here (office), I use cygwin instead. I'll re-download full cygwin package and test again. Nonetheless, I have no problems with the windows version (tested in Vista and 7). I'll try it on XP at home.

It's ok, but you have to be carefull to search manually for some packages, because depending from what mirror you install cygwin, they may be there or not. This situation is very well exposed in cygwin forums. When I built mkbootfs in cygwin for windows the compiler complains for few missing packages and I had to add them one by one searching online in cygwin packages. Some of them were on mirrors.kernel.org and some on cygwin.cybermirror.org. In any other mirror site they were missing. Same for compression packages: xz was only in mirrors.kernel.org. When you install cygwin you don't see any message of something not being there.
Or maybe I don't know how to work with cygwin, I don't know...
The Following 6 Users Say Thank You to bluefirebird For This Useful Post: [ View ] Gift bluefirebird Ad-Free
27th January 2015, 07:09 AM |#11  
Senior Member
Flag Manila
Thanks Meter: 151
 
More
Quote:
Originally Posted by carliv

It's ok, but you have to be carefull to search manually for some packages, because depending from what mirror you install cygwin, they may be there or not. This situation is very well exposed in cygwin forums. When I built mkbootfs in cygwin for windows the compiler complains for few missing packages and I had to add them one by one searching online in cygwin packages. Some of them were on mirrors.kernel.org and some on cygwin.cybermirror.org. In any other mirror site they were missing. Same for compression packages: xz was only in mirrors.kernel.org. When you install cygwin you don't see any message of something not being there.
Or maybe I don't know how to work with cygwin, I don't know...

It's working now after updating cygwin. If I recall correctly, I used dsixda's instructions on how to setup cygwin for kitchen. The procedure required to install additional packages including cpio. Maybe, the files were just outdated since I had this last 2011.
The Following 2 Users Say Thank You to iZLeeP For This Useful Post: [ View ] Gift iZLeeP Ad-Free
Thread Closed Subscribe to Thread

Tags
boot, carliv, recovery, repack, unpack
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes