Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,742,912 Members 39,491 Now Online
XDA Developers Android and Mobile Development Forum

[SCRIPTS] Unpack / repack MT65xx/MT83xx boot.img, recovery.img or logo.bin

Tip us?
 
bgcngm
Old
(Last edited by bgcngm; 15th January 2014 at 10:23 AM.)
#1  
bgcngm's Avatar
Recognized Developer - OP
Thanks Meter 3332
Posts: 3,328
Join Date: Apr 2007
Location: Lisbon

 
DONATE TO ME
Prompt [SCRIPTS] Unpack / repack MT65xx/MT83xx boot.img, recovery.img or logo.bin

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 and MT6582)
  • MT6589
  • MT83xx (MT8377 and MT8389)

The most up to date version of the scripts is always available at my public github repository: bgcngm/mtk-tools. Scripts require Perl v5.14+ to be installed and were fully tested under Ubuntu 12.04 as well as Windows 7 x64 (using Cygwin).

Please don't just leech the files and go away. You can easily say thanks just by pressing "Thanks" button.
Unpack script usage:
Code:
Select Code
Usage: unpack-MT65xx.pl <infile> [COMMAND ...]
  Unpacks boot, recovery or logo image

Optional COMMANDs are:

  -kernel_only
    Extract kernel only from boot or recovery image

  -ramdisk_only
    Extract ramdisk only from boot or recovery image

  -force_logo_res <width> <height>
    Forces logo image file to be unpacked by specifying image resolution,
    which must be entered 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)
Repack script usage:
Code:
Select Code
Usage: repack-MT65xx.pl COMMAND [...]

COMMANDs are:

  -boot <kernel> <ramdisk-directory> <outfile>
    Repacks boot image

  -recovery <kernel> <ramdisk-directory> <outfile>
    Repacks recovery image

  -logo [--no_compression] <logo-directory> <outfile>
    Repacks logo image
Version history:

Changes by Bruno Martins:
  • modified to work with MT6516 boot and recovery images (17-03-2011)
  • included support for MT65x3 and eliminated the need of header files (16-10-2011)
  • added cygwin mkbootimg binary and propper fix (17-05-2012)
  • included support for MT65xx logo images (31-07-2012)
  • fixed problem unpacking logo images containing more than nine packed rgb565 raw files (29-11-2012)
  • re-written logo images file verification (29-12-2012)
  • image resolution is now calculated and shown when unpacking logo images (02-01-2013)
  • added colored screen output (04-01-2013)
  • included support for logo images containing uncompressed raw files (06-01-2013)
  • more verbose output when unpacking boot and recovery images (13-01-2013)
  • kernel or ramdisk extraction only is now supported (13-01-2013)
  • re-written check of needed binaries (13-01-2013)
  • ramdisk.cpio.gz deleted after successful extraction (15-01-2013)
  • added rgb565 <=> png images conversion (27-01-2013)
Credits:
  • Android-DLS for the initial scripts
  • starix (from forum.china-iphone.ru) for the decryption of logo.bin files structure
Latest custom ROMs: ZTE V987 (MT6589) / ZTE V970 (MT6577)

If you like my work, please feel free to donate...

The Following 223 Users Say Thank You to bgcngm For This Useful Post: [ Click to Expand ]
 
bgcngm
Old
(Last edited by bgcngm; 3rd December 2012 at 02:02 PM.)
#2  
bgcngm's Avatar
Recognized Developer - OP
Thanks Meter 3332
Posts: 3,328
Join Date: Apr 2007
Location: Lisbon

 
DONATE TO ME
Tutorial Editing .rgb565 raw files

There may be other ways for doing this, but here's a short info that will help you to edit .rgb656 raw files found inside MTK logo images.
  • Download and install Paint.NET
  • Download the attached plugin and copy the RGB565.dll file to the folder: "C:\Program Files\Paint.Net\FileTypes"
  • Open the .rgb565 file and enter image height and width

Information:

The plugin will allow read and write support to the RGB565 or RAW565 format. This format is used by the Android platform for the initial boot screen of the device. It will also allow you to open a BMP, PNG, JPG or other image and save it as a RGB565 file.

RGB565 is simply the raw pixel data of a bitmap file. It does not contain any header information and does not contain the dimensions of the image. The only thing that is known is the total number of pixels. When opening a .rgb565 file, the user must specify the height and width of the image, which is the resolution of your device's screen.

Just as an example, for a device with a 540 x 960 screen, the .rgb565 file for that device will have 518400 pixels. The size of the file in bytes will be twice the number of pixels, i.e. 1036800 bytes.
Attached Files
File Type: rar rgb565.rar - [Click for QR Code] (4.7 KB, 1666 views)
Latest custom ROMs: ZTE V987 (MT6589) / ZTE V970 (MT6577)

If you like my work, please feel free to donate...

The Following 20 Users Say Thank You to bgcngm For This Useful Post: [ Click to Expand ]
 
varun.chitre15
Old
(Last edited by varun.chitre15; 23rd April 2012 at 10:45 AM.)
#3  
varun.chitre15's Avatar
Recognized Contributor / Recognized Developer
Thanks Meter 9185
Posts: 2,781
Join Date: Oct 2011
Location: Sangli

 
DONATE TO ME
hello,
i tried ur script and works with MT6573 but i need some help.
How to repack?
The syntax u posted looks little jumbled and i need a example on unpack and repacking from u


Burned from my laser torch using pencil cells
 
bgcngm
Old
#4  
bgcngm's Avatar
Recognized Developer - OP
Thanks Meter 3332
Posts: 3,328
Join Date: Apr 2007
Location: Lisbon

 
DONATE TO ME
Simple... let's say you unpack a boot.img:
Code:
Select Code
unpack-MT65xx.pl boot.img
This extracts the kernel (it will be named boot.img-kernel.img) and the ramdisk folder (it will be named boot.img-ramdisk).

In order to repack, you should run:
Code:
Select Code
repack-MT65xx.pl boot.img-kernel.img boot.img-ramdisk new-boot.img
If you are repacking a recovery.img, then it should be:
Code:
Select Code
repack-MT65xx.pl -recovery recovery.img-kernel.img recovery.img-ramdisk new-recovery.img
Latest custom ROMs: ZTE V987 (MT6589) / ZTE V970 (MT6577)

If you like my work, please feel free to donate...

The Following 13 Users Say Thank You to bgcngm For This Useful Post: [ Click to Expand ]
 
varun.chitre15
Old
(Last edited by varun.chitre15; 23rd April 2012 at 10:45 AM.)
#5  
varun.chitre15's Avatar
Recognized Contributor / Recognized Developer
Thanks Meter 9185
Posts: 2,781
Join Date: Oct 2011
Location: Sangli

 
DONATE TO ME
I m getting "can't exec "mkbootimg" : No such file or directory at ./repack-Mt65xx.pl line 66" error
Now?

Edit: Solved the error

Burned from my laser torch using pencil cells
 
ckethan
Old
#6  
Senior Member
Thanks Meter 34
Posts: 252
Join Date: Dec 2010
Location: Chennai
How did u solve?

Sent from my Android using Tapatalk 2
 
bgcngm
Old
#7  
bgcngm's Avatar
Recognized Developer - OP
Thanks Meter 3332
Posts: 3,328
Join Date: Apr 2007
Location: Lisbon

 
DONATE TO ME
Probably it was just a matter of setting the proper permissions.
Latest custom ROMs: ZTE V987 (MT6589) / ZTE V970 (MT6577)

If you like my work, please feel free to donate...

The Following User Says Thank You to bgcngm For This Useful Post: [ Click to Expand ]
 
marsavo
Old
#8  
Junior Member
Thanks Meter 0
Posts: 12
Join Date: Sep 2008
Hello, sorry for my bad english

help me please

i'm getting this error:
C:\Perl\MT65xx_scripts>unpack-MT65xx.pl recovery.img
Subroutine Cwd::fastcwd redefined at C:/Perl/lib/Cwd.pm line 819.
Subroutine Cwd::getcwd redefined at C:/Perl/lib/Cwd.pm line 819.
Subroutine Cwd::abs_path redefined at C:/Perl/lib/Cwd.pm line 819.

kernel written to boot/recovery.img-kernel.img
the boot image does not appear to contain a valid gzip file at C:\Perl\MT65xx_sc
ripts\unpack-MT65xx.pl line 48.

My telephone have a MT6573 processor
 
bgcngm
Old
#9  
bgcngm's Avatar
Recognized Developer - OP
Thanks Meter 3332
Posts: 3,328
Join Date: Apr 2007
Location: Lisbon

 
DONATE TO ME
I have only used the scripts under Ubuntu, so never tested it on a Windows environment.

Are you sure that you have Perl correctly installed?
Latest custom ROMs: ZTE V987 (MT6589) / ZTE V970 (MT6577)

If you like my work, please feel free to donate...

 
marsavo
Old
#10  
Junior Member
Thanks Meter 0
Posts: 12
Join Date: Sep 2008
tried with ubuntu works.

Thanks!!!

Tags
mt6516, mt6575, mt6577, mt6589, mt65x3
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes