Post Reply

[Development] MKBOOTIMG TOOLS

OP Modding.MyMind

Modding.MyMind
5th October 2014, 12:31 AM   |  #1  
Guest
Thanks Meter: 0
 
n/a posts
MKBOOTIMG-TOOLS

MY GITHUB SOURCE:
https://github.com/ModdingMyMind/mkbootimg_tools

Original Author: xiaolu (GITHUB SOURCE: https://github.com/xiaolu/mkbootimg_tools)
Heavily Modified By: Modding.MyMind

This project is originally based from xiaolu. To make this compatible for ARM I modified the script, compiled some binaries such as file, bash, grep, gzip, lzma, xz, mkbootimg, etc.

-- This project uses busybox but due to how stripped and limited busybox is it ultimately led to me having to compile a few binaries from source. These binaries must be part of the project in order for the project to be successful. For example, busybox grep will not always give accurate offsets for the android header. One of MANY bugs found with busybox.

This project supports device tree binaries found inside the Boot.img and Recovery.img.

This project supports multiple Ramdisk compressions.

-- This project will check the ramdisk compression and if it determines that the tool does not support that particular compression then it will display a hazard warning letting the user know that the compression is not supported and that the ramdisk currently cannot be decompressed or compressed until support has been officially added.
-- If the compression is supported it will display what type of compression the Ramdisk is and how many blocks it has when unpacked.

This project will determine your kernel size, ramdisk size, and TRUE OFFSETS (not just the standard mkbootimg.c offsets).

-- With respect to the offsets; You will learn that many available tools found available specifically handle images where the ANDROID! header is located at 0x0. Not all images are built like this from stock. This project will find the header, base, kernel offset, ramdisk offset, second offset, and tags offset. It will rebuild the image using DD to insure the android header is located at 0x0. The found offsets inside the image will be cross referenced to see if the OEM of that image built it using the standard mkbootimg.c. If it detects any offsets which are built using NON-standard offsets then it will display a warning as well as show you what the image TRUE offsets actually are. Those same offsets are then applied to properly rebuild your image to insure that it boots like it was intended to do.
-- The warning will let you know that you may modify mkbootimg.c with the NON-standard values if you wish to have a binary specific to your device. The offsets displayed are not the address. Because the offsets are determined and not the address this makes it possible for this project to not have to rebuild mkbootimg.c. When the project is used to rebuild your image using the mkbootimg args such as --ramdisk_offset, --kernel_offsets, etc, etc, this then tells mkbootimg.c to ignore the hardcoded offsets and only use the ones it has been instructed to use. This is even more successful by insuring the BASE is accurate and applying the base as one of the mkbootimg args (--base 0 <-- this is lazy and stupid).

The mkboot script requires two args whether unpacking the image or repacking the image.

-- mkboot boot.img bootfolder (This will unpack the image)
1. mkboot is the script.
2. boot.img is the actual image.
3. bootfolder will be created and become the project folder.

-- mkboot bootfolder newboot.img (This will repack the image)
1. mkboot is the script.
2. bootfolder is the project folder which has the needed files and information to repack.
3. This will be the name of the finished build.


UNPACK STANDARD IMAGE

This image uses standard mkbootimg.c:
Quote:

root@android:/data/local/tmp/mkbootimg_tools-master # ./mkboot boot.img work

Unpack & decompress boot.img to work

kernel : zImage
ramdisk : ramdisk
page size : 2048
kernel size : 2529072
ramdisk size : 230255
base : 0x12200000
kernel offset : 0x00008000
ramdisk offset : 0x01000000
second_offset : 0x00f00000
tags offset : 0x00000100
cmd line : mem=471M console=ttyMSM2,115200n8 androidboot.hardware=thunderc lge.rev=10

Ramdisk is lzma format.
1436 blocks
Unpack completed.

root@android:/data/local/tmp/mkbootimg_tools-master #

REPACK STANDARD IMAGE

Image repacked with standard mkbootimg.c:
Quote:

root@android:/data/local/tmp/mkbootimg_tools-master # ./mkboot work boot.img

mkbootimg from work/img_info.

kernel : zImage
ramdisk : new_ramdisk.lzma
page size : 2048
kernel size : 2529072
ramdisk size : 230029
base : 0x12200000
kernel offset : 0x00008000
ramdisk offset : 0x01000000
tags offset : 0x00000100
cmd line : mem=471M console=ttyMSM2,115200n8 androidboot.hardware=thunderc lge.rev=10

Kernel size: 2529072, new ramdisk size: 230029, boot.img: 2762752.

boot.img has been created.

root@android:/data/local/tmp/mkbootimg_tools-master #

UNPACK NON-STANDARD IMAGE

This image uses non-standard mkbootimg.c:
Quote:

root@android:/data/local/tmp/mkbootimg_tools-master # ./mkboot recovery.img work

Unpack & decompress recovery.img to work

****** WARNING ******* WARNING ******* WARNING ******

This image is built using NON-standard mkbootimg!

RAMDISK_OFFSET is 0x01608000

You can modify mkbootimg.c with the above value(s)

****** WARNING ******* WARNING ******* WARNING ******

kernel : zImage
ramdisk : ramdisk
page size : 2048
kernel size : 5834192
ramdisk size : 4351685
base : 0x80600000
kernel offset : 0x00008000
ramdisk offset : 0x01608000
second_offset : 0x00f00000
tags offset : 0x00000100
cmd line : console=ttyHSL0,115200,n8 user_debug=31

Ramdisk is gzip format.
14837 blocks
Unpack completed.

root@android:/data/local/tmp/mkbootimg_tools-master #

REPACK NON-STANDARD IMAGE

Image repacked with non-standard mkbootimg.c:
Quote:

root@android:/data/local/tmp/mkbootimg_tools-master # ./mkboot work recovery.img

mkbootimg from work/img_info.

kernel : zImage
ramdisk : new_ramdisk.gzip
page size : 2048
kernel size : 5834192
ramdisk size : 4358038
base : 0x80600000
kernel offset : 0x00008000
ramdisk offset : 0x01608000
tags offset : 0x00000100
cmd line : console=ttyHSL0,115200,n8 user_debug=31

Kernel size: 5834192, new ramdisk size: 4358038, recovery.img: 10194944.

recovery.img has been created.

root@android:/data/local/tmp/mkbootimg_tools-master #

UNPACK IMAGE WITH INCOMPATIBLE RAMDISK

Quote:

root@android:/data/local/tmp/mkbootimg_tools-master # ./mkboot boot-1.img work

Unpack & decompress boot-1.img to work

kernel : zImage
ramdisk : ramdisk
page size : 2048
kernel size : 3580032
ramdisk size : 594701
base : 0x10000000
kernel offset : 0x00008000
ramdisk offset : 0x01000000
second_offset : 0x00f00000
tags offset : 0x00000100
cmd line :

****** HAZARD ******* HAZARD ******* HAZARD ******

Ramdisk is data format. Can't unpack ramdisk.
This tool currently does not support data.

****** HAZARD ******* HAZARD ******* HAZARD ******

root@android:/data/local/tmp/mkbootimg_tools-master #

REPACK IMAGE WITH INCOMPATIBLE RAMDISK

Quote:

root@android:/data/local/tmp/mkbootimg_tools-master # ./mkboot work boot-1.img

mkbootimg from work/img_info.


****** HAZARD ******* HAZARD ******* HAZARD ******

Ramdisk is data format. Can't repack ramdisk.
This tool currently does not support data.

****** HAZARD ******* HAZARD ******* HAZARD ******

root@android:/data/local/tmp/mkbootimg_tools-master #

The Following 4 Users Say Thank You to For This Useful Post: [ View ]
Modding.MyMind
5th October 2014, 12:32 AM   |  #2  
Guest
Thanks Meter: 0
 
n/a posts
*Reserved*
The Following User Says Thank You to For This Useful Post: [ View ]
Modding.MyMind
5th October 2014, 12:32 AM   |  #3  
Guest
Thanks Meter: 0
 
n/a posts
If your boot.img and/or recovery.img is found to not be supported using this tool then please send me your boot.img and recovery.img so I may review it and determine if official support can be added. Thanks.
Last edited by Modding.MyMind; 5th October 2014 at 07:42 PM.
The Following User Says Thank You to For This Useful Post: [ View ]
Modding.MyMind
6th October 2014, 02:32 AM   |  #4  
Guest
Thanks Meter: 0
 
n/a posts
Add support for MediaTek Images:

-- Unpack and repack boot/recovery images.
-- Append proper headers to ramdisk when repacking.
-- Compiled mkimage to assist with the headers.

-- This support currently does not include the logo images at this time.

-- MT6516
-- MT65x3 (MT6513 and MT6573)
-- MT65x5 (MT6515 and MT6575)
-- MT6577
-- MT65x2 (MT6572 and MT6582)
-- MT6589
-- MT83xx (MT8377 and MT8389)
Last edited by Modding.MyMind; 6th October 2014 at 12:11 PM. Reason: Removed commit. See source for latest changes.
6th October 2014, 01:33 PM   |  #5  
H3LL's Avatar
Senior Member
Thanks Meter: 71
 
237 posts
Join Date:Joined: Jan 2014
More
Quote:
Originally Posted by Modding.MyMind

If your boot.img and/or recovery.img is found to not be supported using this tool then please send me your boot.img and recovery.img so I may review it and determine if official support can be added. Thanks.

getting error

Code:
 u0_a34@android:/ $ su
/mkbootimg_tool/ARM                                <
/mkboot boot.img h3ll                              <
<Unpack and repack boot.img tool>
----------------------------------------------------------------------
Not enough parameters or parameter error!
unpack boot.img & decompress ramdisk
    mkboot [img] [output dir]
    mkboot boot.img boot20130905
^[[?1;2cUse the unpacked directory repack boot.img(img_info)
    mkboot [unpacked dir] [newbootfile]
    mkboot boot20130905 newboot.img
^[[?1;2croot@android:/data/local/tmp/mkbootimg_tool/A;2c1;2c                                            <
sh: 1: not found
sh: 2c1: not found
sh: 2c: not found
127|root@android:/data/local/tmp/mkbootimg_tool/ARM #
Modding.MyMind
6th October 2014, 02:51 PM   |  #6  
Guest
Thanks Meter: 0
 
n/a posts
Quote:
Originally Posted by H3LL

getting error

Code:
 u0_a34@android:/ $ su
/mkbootimg_tool/ARM                                <
/mkboot boot.img h3ll                              <

----------------------------------------------------------------------
Not enough parameters or parameter error!
unpack boot.img & decompress ramdisk
    mkboot [img] [output dir]
    mkboot boot.img boot20130905
^[[?1;2cUse the unpacked directory repack boot.img(img_info)
    mkboot [unpacked dir] [newbootfile]
    mkboot boot20130905 newboot.img
^[[?1;2croot@android:/data/local/tmp/mkbootimg_tool/A;2c1;2c                                            <
sh: 1: not found
sh: 2c1: not found
sh: 2c: not found
127|root@android:/data/local/tmp/mkbootimg_tool/ARM #

Check the permissions, check that bash is placed at /system/xbin, and insure the image you are trying to unpack is in the same directory where the mkboot script is located or else, insure you specify the image path properly.

If it still errors out insure your device is ARM and compatible for the project. If yes, then at the top of the script will be; #set -x. Uncomment it and run the script again, then copy and paste it's output here.

Also, send me your image to download and verify on my end. Thanks.
6th October 2014, 04:15 PM   |  #7  
H3LL's Avatar
Senior Member
Thanks Meter: 71
 
237 posts
Join Date:Joined: Jan 2014
More
Quote:
Originally Posted by Modding.MyMind

Check the permissions, check that bash is placed at /system/xbin, and insure the image you are trying to unpack is in the same directory where the mkboot script is located or else, insure you specify the image path properly.

If it still errors out insure your device is ARM and compatible for the project. If yes, then at the top of the script will be; #set -x. Uncomment it and run the script again, then copy and paste it's output here.

Also, send me your image to download and verify on my end. Thanks.

tried same output as above here's boot.IMG
Modding.MyMind
6th October 2014, 08:29 PM   |  #8  
Guest
Thanks Meter: 0
 
n/a posts
Quote:
Originally Posted by H3LL

tried same output as above here's boot.IMG

Your image doesn't have an android header. It's elf. This tool currently doesn't support it but now that I have your boot.img I can see about adding support. Can you send me your recovery image as well so I may verify that the process is the same for both when unpacking and repacking. Some images such as MediaTek have different headers for the ramdisk depending on whether it's the boot or recovery and so I would like to confirm the same with yours as well. Thanks.

Edit: Also, this tool won't work on your device unless the binaries are compiled from source for your machine. It's currently for ARM, but your device won't play nice with it.
7th October 2014, 03:58 AM   |  #9  
H3LL's Avatar
Senior Member
Thanks Meter: 71
 
237 posts
Join Date:Joined: Jan 2014
More
Quote:
Originally Posted by Modding.MyMind

Your image doesn't have an android header. It's elf. This tool currently doesn't support it but now that I have your boot.img I can see about adding support. Can you send me your recovery image as well so I may verify that the process is the same for both when unpacking and repacking. Some images such as MediaTek have different headers for the ramdisk depending on whether it's the boot or recovery and so I would like to confirm the same with yours as well. Thanks.

Edit: Also, this tool won't work on your device unless the binaries are compiled from source for your machine. It's currently for ARM, but your device won't play nice with it.

there is no recovery. img for this device (its not mediatek) its in ramdisk of the boot.img....yeah my device is ARM
The Following User Says Thank You to H3LL For This Useful Post: [ View ]
Modding.MyMind
7th October 2014, 05:48 PM   |  #10  
Guest
Thanks Meter: 0
 
n/a posts
Quote:
Originally Posted by H3LL

there is no recovery. img for this device (its not mediatek) its in ramdisk of the boot.img....yeah my device is ARM

Reviewed the binaries and somehow overlooked a few after compiling them. Some aren't even true static when I originally thought I did compile them as such. There are also some which are true static but focus on either hard floats or soft floats. So, I need to go back and recompile the ones which stood out and push them to my repo. This may very well be why it isn't playing fair on your Sony device.

With that said, adding support for your image is gonna be a bit complicated to write out in bash since it is very involved lol. However, I am gonna make an attempt by taking on the challenge and seeing if I can get it done .

The Following User Says Thank You to For This Useful Post: [ View ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Android Software and Hacking General [Developers Only] by ThreadRank