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

Search This thread

superdragonpt

Recognized Developer
Apr 27, 2013
4,952
19,354
Lisbon / Taiwan / USA
www.caixamagica.pt
If you need the kernel sources and you don't have it then no, there's nothing you can do.

^This

but if i have them can i change it to make it support swap??
Please stop asking about unrelated things, to this thread.
This is not the proper place to ask for kernel compiling.
Have a look on android general please.

The thread is all about a tool to pack and repack kernel ramdisk, totally unrelated to kernel compiling.


Thanks
 
  • Like
Reactions: DerTeufel1980

SashaVeliki

Senior Member
Oct 29, 2011
80
6
Veliki Popović
I tried all night to repack and I do not know how. I have not Ubuntu. Please, can somebody to post me all needed files for dead MEIZU MX4 phone (mt6595)? Please...
 

MtwStark

New member
Aug 30, 2017
1
0
TV's firmwares?

Hello,
may it works also for TV's firmwares?

I have an Hisense TV, the chip should me a MediaTek MT8222, the firmware file is USBUpgrade.bin, it has a readable header part:

nand erase
dynpart edb64M-nand:0x40000(NPT),0x40000(KL_BP),0x500000(KL),0x1F580000(UBI),-(NA)
saveenv
ubi part UBI
set UBI
saveenv
ubi create RFS 0x700000
ubi create MSLIB 0x3C00000
ubi create CONFIG 0xA00000
ubi create customer 0xC00000
ubi create customerbackup 0xC00000
ubi create APP 0xB000000
ubi create oad 0xB400000
ubi create certificate 0x300000
saveenv
filepartload 81100000 USBUpgrade.bin 2000 1892c6
mscompress7 d 0 81100000 1892c6 80100000
nand erase KL
nand write.e 80100000 KL 48b0d0
nand read.e 80100000 KL 48b0d0
crc32 80100000 48b0d0 81100000
mw 81100004 85055c99 4
cmp.b 81100000 81100004 4
filepartload 81100000 USBUpgrade.bin 192000 3449fd
mscompress7 d 0 81100000 3449fd 80100000
ubi write 80100000 RFS 60e000 60e000
ubi partial_read 80100000 RFS 60e000 0
crc32 80100000 60e000 81100000
mw 81100004 4cce8f29 4
cmp.b 81100000 81100004 4
filepartload 81100000 USBUpgrade.bin 4e2000 92ab50
mscompress7 d 0 81100000 92ab50 80100000
ubi write 80100000 MSLIB 1000000 231e000
filepartload 81100000 USBUpgrade.bin e12000 b47f95
mscompress7 d 0 81100000 b47f95 80100000
ubi write_cont 80100000 MSLIB 1000000
filepartload 81100000 USBUpgrade.bin 1962000 17e747
mscompress7 d 0 81100000 17e747 80100000
ubi write_cont 80100000 MSLIB 31e000
ubi partial_read 80100000 MSLIB 1000000 0
crc32 80100000 1000000 81100000
mw 81100004 a9f82272 4
cmp.b 81100000 81100004 4
ubi partial_read 80100000 MSLIB 1000000 1000000
crc32 80100000 1000000 81100000
mw 81100004 59b4b669 4
cmp.b 81100000 81100004 4
ubi partial_read 80100000 MSLIB 31e000 2000000
crc32 80100000 31e000 81100000
mw 81100004 5c53a2dc 4
cmp.b 81100000 81100004 4
filepartload 81100000 USBUpgrade.bin 1ae2000 277a5f
mscompress7 d 0 81100000 277a5f 80100000
ubi write 80100000 CONFIG 535000 535000
ubi partial_read 80100000 CONFIG 535000 0
crc32 80100000 535000 81100000
mw 81100004 674dfc56 4
cmp.b 81100000 81100004 4
filepartload 81100000 USBUpgrade.bin 1d62000 a9a3ff
mscompress7 d 0 81100000 a9a3ff 80100000
ubi write 80100000 APP 1000000 66b0000
filepartload 81100000 USBUpgrade.bin 2802000 ca686c
mscompress7 d 0 81100000 ca686c 80100000
ubi write_cont 80100000 APP 1000000
filepartload 81100000 USBUpgrade.bin 34b2000 c16954
mscompress7 d 0 81100000 c16954 80100000
ubi write_cont 80100000 APP 1000000
filepartload 81100000 USBUpgrade.bin 40d2000 b55bf6
mscompress7 d 0 81100000 b55bf6 80100000
ubi write_cont 80100000 APP 1000000
filepartload 81100000 USBUpgrade.bin 4c32000 b66075
mscompress7 d 0 81100000 b66075 80100000
ubi write_cont 80100000 APP 1000000
filepartload 81100000 USBUpgrade.bin 57a2000 cc99ee
mscompress7 d 0 81100000 cc99ee 80100000
ubi write_cont 80100000 APP 1000000
filepartload 81100000 USBUpgrade.bin 6472000 3ad580
mscompress7 d 0 81100000 3ad580 80100000
ubi write_cont 80100000 APP 6b0000
ubi partial_read 80100000 APP 1000000 0
crc32 80100000 1000000 81100000
mw 81100004 4a9ce6be 4
cmp.b 81100000 81100004 4
ubi partial_read 80100000 APP 1000000 1000000
crc32 80100000 1000000 81100000
mw 81100004 6fb65345 4
cmp.b 81100000 81100004 4
ubi partial_read 80100000 APP 1000000 2000000
crc32 80100000 1000000 81100000
mw 81100004 9d6af55a 4
cmp.b 81100000 81100004 4
ubi partial_read 80100000 APP 1000000 3000000
crc32 80100000 1000000 81100000
mw 81100004 52344963 4
cmp.b 81100000 81100004 4
ubi partial_read 80100000 APP 1000000 4000000
crc32 80100000 1000000 81100000
mw 81100004 6bcfbfe9 4
cmp.b 81100000 81100004 4
ubi partial_read 80100000 APP 1000000 5000000
crc32 80100000 1000000 81100000
mw 81100004 faefbf8d 4
cmp.b 81100000 81100004 4
ubi partial_read 80100000 APP 6b0000 6000000
crc32 80100000 6b0000 81100000
mw 81100004 9a7b47e 4
cmp.b 81100000 81100004 4
filepartload 81100000 USBUpgrade.bin 6822000 de950
mscompress7 d 0 81100000 de950 80100000
ubi write 80100000 customer 2e8000 2e8000
ubi partial_read 80100000 customer 2e8000 0
crc32 80100000 2e8000 81100000
mw 81100004 55e30aa4 4
cmp.b 81100000 81100004 4
filepartload 81100000 USBUpgrade.bin 6902000 2a7
mscompress7 d 0 81100000 2a7 80100000
ubi write 80100000 customerbackup 193000 193000
ubi partial_read 80100000 customerbackup 193000 0
crc32 80100000 193000 81100000
mw 81100004 284787ec 4
cmp.b 81100000 81100004 4
filepartload 81100000 USBUpgrade.bin 6912000 2c2
mscompress7 d 0 81100000 2c2 80100000
ubi write 80100000 oad 1b2000 1b2000
ubi partial_read 80100000 oad 1b2000 0
crc32 80100000 1b2000 81100000
mw 81100004 cd1793b 4
cmp.b 81100000 81100004 4
ubi part UBI
ubi part UBI
filepartload 81100000 USBUpgrade.bin 6922000 1ad0
mscompress7 d 0 81100000 1ad0 80100000
ubi part UBI
ubi write 80100000 certificate 193000 193000
ubi partial_read 80100000 certificate 193000 0
crc32 80100000 193000 81100000
mw 81100004 c9c67c77 4
cmp.b 81100000 81100004 4
setenv MS_MEM LX_MEM=0x4345000 EMAC_MEM=0x28000 DRAM_LEN=0x18000000 LX_MEM2=0x66500000,0x8C00000 BB_ADDR=0xF1C1000
setenv MS_RFS ubi.mtd=3,2048 root=ubi:RFS rootfstype=ubifs ro
setenv bootargs quiet console=ttyS0,115200 $(MS_RFS) $(MS_MEM) $(mtdparts)
setenv verify n
saveenv
setenv filesize 48b0d0
setenv bootcmd nand read.e 803FFFC0 KL $(filesize)\; bootm 803FFFC0
saveenv
setenv MIU0_GROUP_PRIORITY 1:0:2:3
setenv MIU1_GROUP_PRIORITY 1:0:2:3
setenv MIU0_GROUP_SELMIU 1140:01E8:0000:0016
setenv MIU1_GROUP_SELMIU 4000:0000:0400:0800
saveenv
printenv
setenv MstarUpgrade_complete 1
saveenv
printenv
reset


followed by binary data.

Is it possible tu unpack, modify and repack this?

thank you
 

billyx1

Senior Member
May 25, 2012
230
80
GT-i9250
Google Nexus 10
I have been able to unpack, modify and repack an image for a Mediatek device according to several blogs and instructions in the net. But if I try to boot the image with "fastboot boot twrp.img" the device just reboots after some time.
On my first tries I got the errors 'image is not a boot image' and 'invalid kernel address: not lie in memory' so I expect to have made some steps forward, but I have no idea to analyze the next problem. Is there a possibility to find more information about the problem?
 

teknosrp

New member
Dec 18, 2017
3
2
If you are looking for a way to easily unpack / repack boot.img, recovery.img or logo.bin from your MediaTek device (all except Android One devices), don't look any further. Here you can find my own Perl scripts.

Scripts were first based on the ones available on -URL-, 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

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

Last Updated 2014-10-17

Hello!

I managed to modify sucesfully the boot logo of a MT6589 device using these scripts, but now I have tried with a MT6580 and the scripts failed. After researching a little bit and studying the differences between the logo.bin files, I have found that the structure of the MT6580 logo file is almost identical, only there are two little differences which make the script fail.

  • In the headers of the logo file, the old one uses capital letters and the new one doesn't.
  • The images contained use 32 bit color depth (bgra) instead of rgb565.

Then, with a little modifications I achieved modifying the original script and making it work with this new logo.bin file. I managed to modify the logo.bin of the MT6580 and sucesfully flash it on the phone. I think this new logo.bin format is also used in all new MT67xx devices, so I think updating the original script worth it. If you don't have time, I can try doing it myself and post it.

Sorry if my english is not very correct. I'm spanish and I don't write it very well:)

Thanks for the original work!
 
  • Like
Reactions: elisam98 and bgcngm

bgcngm

Recognized Developer
Apr 2, 2007
7,091
21,556
Lisbon
HTC One (M8)
Xiaomi Mi 5
Then, with a little modifications I achieved modifying the original script and making it work with this new logo.bin file. I managed to modify the logo.bin of the MT6580 and sucesfully flash it on the phone. I think this new logo.bin format is also used in all new MT67xx devices, so I think updating the original script worth it. If you don't have time, I can try doing it myself and post it.
You can submit a PR to my GitHub. I will take a look and be happy to merge your contribution.
 

ssuicidequad

Member
Mar 6, 2018
37
1
Vizag
I have Micromax Vdeo 2 (Q4101),I've been trying to root my device with magisk.For this, I need boot.img , I also downloaded stock rom and extracted that .rar file but I didn't find anything.. I read a thread saying that boot.img can be found in stock rom file after extracting it..but I found nothing. So, if anyone have any suggestions help me with it..
 

dtingley11222

Senior Member
Nov 16, 2020
85
15
Hi I used this to try and unpack this boot.img and I get this error:

Error!! the specified boot image does not appear to contain a valid gzip file!

Is there anything I'm not doing?

Thanks
 

Attachments

  • boot.img
    32 MB · Views: 11

Top Liked Posts

  • There are no posts matching your filters.
  • 379
    If you are looking for a way to easily unpack / repack boot.img, recovery.img or logo.bin from your MediaTek device (all except Android One devices), 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

    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:
    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)

    Repack script usage:
    Code:
    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)

    Version history:
    • 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)
    • code cleanup and revised verbose output (16-10-2014)
    • boot or recovery is now extracted to the working directory (16-10-2014)
    • unpack result is stored on the working directory, despite of the input file path (17-10-2014)
    • added support for new platforms - MT6595 (thanks @carliv) (29-12-2014)
    • minor code cleanup and revised information output for boot and recovery images (29-12-2014)
    • make scripts more future-proof by supporting even more args (30-12-2014)
    • continue repacking even if there's no extra args file (01-01-2015)
    • more verbose output when repacking boot and recovery images (02-01-2015)
    • added new cmdline option for debugging purposes when unpacking / repacking boot and recovery images (06-01-2015)

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

    XDA:DevDB Information
    MTK-Tools, Tool/Utility for the Android General

    Contributors
    bgcngm

    Version Information
    Status: Stable

    Created 2014-10-15
    Last Updated 2014-10-17
    32
    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.
    18
    Simple... let's say you unpack a boot.img:
    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:
    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:
    repack-MT65xx.pl -recovery recovery.img-kernel.img recovery.img-ramdisk new-recovery.img
    9
    I have created a public github repository (bgcngm/mtk-tools) to host the scripts. The most up to date version is always available at the repo.

    I'm currently finishing the re-write of the scripts in order to add the unpack/repack feature of MediaTek logo.bin images.

    Please don't just leech the files and go away. You can easily say thanks just by pressing "Thanks" button.
    3
    Works in windows with cygwin too with some minor tweaking...

    change the repack script line 66, mkbootimg to ./mkbootimg.exe & replace mkbootimg with this windows version...:p i think it should work with any mkbootimg.exe windows version too...

    ignore the unpack scripts error though, it works fine actually in cygwin...:)