1. Are you ready for the Galaxy S20? Here is everything we know so far!

[Development] MKBOOTIMG TOOLS [Root only]

Discussion in 'Android Development' started by ModdingMyMind, Oct 4, 2014.

  1. ModdingMyMind

    Thread Starter



    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.


    This image uses standard mkbootimg.c:

    Image repacked with standard mkbootimg.c:

    This image uses non-standard mkbootimg.c:

    Image repacked with non-standard mkbootimg.c:



    1. Download the Forums for Android™ app!


  2. ModdingMyMind

    Thread Starter

  3. ModdingMyMind

    Thread Starter

    *Last Reserved*
  4. ModdingMyMind

    Thread Starter


    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)
  5. phan9998

    phan9998 Member

    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

Share This Page