• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Mods [Development] MKBOOTIMG TOOLS [Root only]

  • Thread starter Thread starter ModdingMyMind
  • Start date Start date
M

ModdingMyMind

Guest
MKBOOTIMG-TOOLS

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 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 succesfull. 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:
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:
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:
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:
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

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

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 #
 
https://github.com/ModdingMyMind/mkbootimg_tools/commit/cad7fbaaa51d4a98c20d3c573da4f29d0befa092

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)
 
MMM theme-
You're The Best Around - Karate Kid: http://youtu.be/uGleclSAhdA

MMM is the Daniel San of android, fighting the evil Cobra Dojo(binary bugs):p
With the sexy young in the 80's Elisabeth Shue(his loyal fans) rooting him on

Thanks for your hard work MrMightyMind,
The man who helps get recovery's to boot on devices without them.
A big round of applause please, it's about time for some praise for a dev
And a damn thank you
 
Back
Top Bottom