Git Product home page Git Product logo

mtk-tools's Introduction

MTK-Tools by Bruno Martins

MTK unpack and repack scripts

If you are looking for a way to easily unpack / repack boot.img, recovery.img or logo.bin from your MediaTek device, don't look any further. Here you can find my own Perl scripts.

Scripts were first based on the ones available on Android-DLS WiKi, but are now highly modified in order to work with specific MTK boot and recovery images. The scripts fully work with every image from all known MediaTek SoC:

  • MT6516
  • MT65x3 (MT6513 and MT6573)
  • MT65x5 (MT6515 and MT6575)
  • MT6577
  • MT65x2 (MT6572, MT6582 and MT6592)
  • MT6589
  • MT83xx (MT8377 and MT8389)
  • MT6595

Unpack script usage:

Usage: unpack-MTK.pl <infile> [COMMAND ...]
  Unpacks MediaTek boot, recovery or logo images

Optional COMMANDs for boot or recovery images are:

  -info_only
    Display file information only
     (useful to check image information without unpacking)

  -kernel_only [--debug]
    Extract kernel only

  -ramdisk_only [--debug]
    Extract ramdisk only

    (optional argument '--debug' can additionally be used to provide useful
     information for debugging purposes, even while unpacking both kernel
     and ramdisk)

Optional COMMANDs for logo images are:

  -force_logo_res <width> <height>
    Forces file to be unpacked by specifying image resolution (in pixels)
     (only useful when no zlib compressed images are found)

  -invert_logo_res
    Invert image resolution (width <-> height)
     (may be useful when extracted images appear to be broken)
  • Note: for the new platforms requirements, the unpack script will now display the complete information about input image (example shown bellow) and also create an extra file with arguments needed for further repacking.
Input file information (example):

 Header:

  Boot magic:                   ANDROID!
  Kernel size (bytes):          3436480         (0x00346fc0)
  Kernel load address:          0x10008000

  Ramdisk size (bytes):         1989254         (0x001e5a86)
  Ramdisk load address:         0x11000000
  Second stage size (bytes):    0               (0x00000000)
  Second stage load address:    0x10f00000

  Tags address:                 0x10000100
  Page size (bytes):            2048            (0x00000800)
  ASCIIZ product name:          ''
  Command line:                 ''
  ID:                           727cb3e6a37d7973d94f5061a4fb6169a8c4da77

 Other:

  Boot magic offset:            0x00000000
  Base address:                 0x10000000

  Kernel offset:                0x00008000
  Ramdisk offset:               0x01000000
  Second stage offset:          0x00f00000
  Tags offset:                  0x00000100

Repack script usage:

Usage: repack-MTK.pl <COMMAND ...> <outfile>
  Repacks MediaTek boot, recovery or logo images

COMMANDs for boot or recovery images are:

  -boot [--debug] <kernel> <ramdisk-directory>
    Repacks boot image

  -recovery [--debug] <kernel> <ramdisk-directory>
    Repacks recovery image

    (optional argument '--debug' can additionally be used to provide useful
     information for debugging purposes, while repacking)

COMMANDs for logo images are:

  -logo [--no_compression] <logo-directory>
    Repacks logo image

    (optional argument '--no_compression' can be used to repack logo images
     without compression)
  • Note: for the new platforms requirements, repack script now takes into account the file (created when unpacking) containing extra arguments. More information about the built image is now also displayed (example shown bellow).
Build information (example):

 Base address and offsets:

  Base address:                 0x10000000
  Kernel offset:                0x00008000
  Ramdisk offset:               0x01000000
  Second stage offset:          0x00f00000
  Tags offset:                  0x00000100

 Other:

  Page size (bytes):            2048
  ASCIIZ product name:          ''
  Command line:                 ''

Credits:

  • Android-DLS for the initial scripts
  • starix (from forum.china-iphone.ru) for the decryption of logo.bin files structure
  • carliv (from forum.xda-developers.com) for new platform support and new binaries

Support page:

Visit the support page for any questions or comments. Please don't just leech the files and go away. You can easily say thanks just by pressing "Thanks" button on XDA-Developers forum.

Copyright:

Copyright (C) 2012 Bruno Martins (bgcngm@XDA)

You may not distribute nor sell this software or parts of it in Source, Object nor in any other form without explicit permission obtained from the original author.

mtk-tools's People

Contributors

bgcngm avatar dr-shadow avatar stephenbalaban avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mtk-tools's Issues

MTK6785

Hey, I know this script this very old and doesn't support newer chipsets, but I really wanted to mod my logo.bin, it would be pleasure if you could look into my device's logo.bin, please message me at @moonkepler (Telegram) or email at [email protected], if you're ready, I cannot upload the file right here, thanks

ThL w100s boot.img

Hello,

I've been trying to use this tool with the ThL w100s stock rom.

Here is the output log:

./unpack-MT65xx.pl ../boot.img
MTK-Tools by Bruno Martins
MT65xx unpack script (last update: 27-01-2013)

Valid Android signature found...

Input file information:

Kernel size: 3987480 bytes / load address: 0x10008000
Ramdisk size: 704062 bytes / load address: 0x11000000
Second stage size: 0 bytes / load address: 0x10f00000
Page size: 2048 bytes
ASCIIZ product name: 'V1_WCDMA'
Command line: (none)

Kernel written to '../boot.img-kernel.img'
Ramdisk size: gzip: ../../boot.img-ramdisk.cpio.gz: No such file or directory
cpio: fim prematuro do arquivo
rm: impossível remover «../../boot.img-ramdisk.cpio.gz»: Ficheiro ou directoria inexistente
Extracted ramdisk contents to directory '../boot.img-ramdisk'

Successfully unpacked kernel and ramdisk.

Also:
md5sum boot.img
23d5751875c13d4c8d432aa94a311b6d boot.img

After some digging I've found that the initrd ramdisk is output as 'data' and not as a gunzip file.

I've heard you made a CWM build for this phone. Do you know why this is happening?

Thanks!

To fix: unpack fail if cpio not found

Currently the unpack script outputs success even when cpio does not exist:

MTK-Tools by Bruno Martins
MT65xx unpack script (last update: 31-07-2012)

Valid Android signature found...

Kernel written to recovery.img-kernel.img
Ramdisk written to recovery.img-ramdisk.cpio.gz
Ramdisk size: sh: cpio: command not found
Extracted ramdisk contents to directory recovery.img-ramdisk

Successfully unpacked kernel and ramdisk.

A simple check and die will be nice just before line 88:

system ("gzip -d -c ../$ARGV[0]-ramdisk.cpio.gz | cpio -i");

After simple unpack/repack - phone does not boot

Have fake Xiaomi Mi2S with MT6577 chip

Tried already 3 different unpack/repack scripts for MTK chips - all has same issue, phone cannot boot after i flash repacked kernel

Very simple test case - take original kernel 'boot.img'. Unpack it (no errors), Repack it (no errors). Take newly built boot.img (has lower size, i think because original kernel has 0-s filled end of file). Flash to phone - it will not boot. Stuck on logo. Trying to connect to PC, got 'device is not recognized.'

Using Win 8.1 x64 with latest cygwin x86 installed.

Do you have any ideas why it can happen ?

mkbootimg.osx not working

Binary is not executable under Yosemite 10.10.1

zsh: exec format error: ./mkbootimg.osx

bash: ./mkbootimg.osx: cannot execute binary file

bug compilation in ubuntu 14.04

Hello.

root@dw0rd-virtual-machine:~/Desktop/andr-kernl# ./mkbootimg
bash: ./mkbootimg: cannot execute binary file: Exec format error

full compilation log:

root@dw0rd-virtual-machine:~/Desktop/andr-kernl# ./repack-MTK.pl -boot ./boot.img-kernel.img ./boot.img-ramdisk ./my-boot.img
MTK-Tools by Bruno Martins
MTK repack script (last update: 06-01-2015)

Repacking boot image...
Ramdisk size: 3215 blocks

Build information:

Base address and offsets:

Base address: 0x10000000
Kernel offset: 0x00008000
Ramdisk offset: 0x01000000
Second stage offset: 0x00f00000
Tags offset: 0x00000100

Other:

Page size (bytes): 2048
ASCIIZ product name: '1414054265'
Command line: ''
/home/dw0rd/Desktop/andr-kernl/mkbootimg: 1: /home/dw0rd/Desktop/andr-kernl/mkbootimg: �ELF����: not found
/home/dw0rd/Desktop/andr-kernl/mkbootimg: 2: /home/dw0rd/Desktop/andr-kernl/mkbootimg: Syntax error: "(" unexpected
root@dw0rd-virtual-machine:~/Desktop/andr-kernl#

MT6752

fail for mt6752

Kernel written to 'boot.img-kernel.img'
�[31m
Error: the specified boot image does not appear to contain a valid gzip file!�[0m

MT8127

Hi!
We have used your tool for many MTK devices with great success. However now we have Lenovo A7-10 that we want to use and this version uses the MT8127 chip. We use CWM 6.0.30 to extract the boot.img and your tool can extract it. Then we modify the default.props and repacka it. One noticeable thing here is that the size of the original boot.img is about 6.2 MB and after repack its around 4MB. But then when we reload it and set a md5 sum we get MD5 sum missmatch. If I work around this and force the new boot.img to load the device cant boot correct and has a lot of issues.

Do you know if there is anything special with MT8127 since you dont have it in your list? Can support for this version be added?

Thanks for a great tool anyhow

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.