Monday, October 6, 2014

Update: Tutoial Re-partition the MTK6572

This is an update from my previous post, the first post works, this mod is a little simpler and when flashing the new EBR1 on the MTK6572, you will not have to do a system restore, it works almost perfectly.










Three things needed that will make this process quick and painless are:

  1. A hex calculator, in Ubuntu, one is actually already installed, this tutorial will also teach you how to use it if you do not already know how, can also use an online hex calculator, here is a link to one.  Google is also a good tool for doing mathematical functions using hexadecimal formulas, click here for an example.  
  2. A hex editing program, I prefer okteta in Ubuntu, it highlights the hex numbers, making it easier to view.
  3. Linux can use terminal shell, not sure about windows, tried cygwin myself, just did not seem to like the EBR1 files for the MTK6572.
First thing that needs to be done is, in your MTK6572_Android_scatter.txt, you need to add the partition_size of USRDATA and FAT:


- partition_index: SYS17
  partition_name: USRDATA
  file_name: userdata.img
  is_download: true
  type: NONE
  linear_start_addr: 0x43F40000
  physical_start_addr: 0x43940000
  partition_size: 0x20000000
  region: EMMC_USER
  storage: HW_STORAGE_EMMC
  boundary_check: true
  is_reserved: false
  operation_type: UPDATE
  reserve: 0x00

- partition_index: SYS18
  partition_name: FAT
  file_name: NONE
  is_download: false
  type: NONE
  linear_start_addr: 0x63F40000
  physical_start_addr: 0x63940000
  partition_size: 0x87040000
  region: EMMC_USER
  storage: HW_STORAGE_EMMC
  boundary_check: true
  is_reserved: false
  operation_type: INVISIBLE
  reserve: 0x00

Open up the calculator, and under mode, select programming, now make sure that you have Hexadecimal enabled in the calculator and enter the two values, as so, and press enter:



While you have that hexadecimal value available, lets update the scatter text partition_size with the total number, in the USRDATA section, enter the total hexadecimal value, than for FAT 0x0.  Found that leaving FAT as 0x0, even with the 110kb leftover internal storage forces that internal storage to become an unallocated space, this makes it easier to hide. 

Now change the dropdown from hexadecimal to decimal, and divide that decimal into 32 from, then press enter:





Again, change the decimal drop down box back to hexadecimal, and this is going to be the new hex value in in Partition #2 of your EBR1.  Note, in the calculator, the value is actually read from right to left but entered in the EBR1 from left to right, ignoring the 0000 at the end, as I highlighted in the calculator, the number 5382 will be entered as 82 53.





Here is an example of my EBR1 file for the Irulu 7inch MTK6572, I've highligted the first two numbers that are going to be changed:

00 00 83 00 00 00 00 06 16 00 00 C0 0B 00 00 00 
00 00 83 00 00 00 00 C6 21 00 00 00 10 00 00 00 
00 00 83 00 00 00 00 C6 31 00 FF 39 CE FF 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA

The 00 10 is now going to become 82 53.  It is usually a good idea to save your EBR1 under a new name, it will load in SPFLASH tools under any name that you call the EBR1, in this case, it has been named as 2.5gb-EBR1.

In terminal shell, lets check the value of 2.5gb-EBR1, or whatever you chose to name yours:

--- 2.6gb-EBR1
Regular file, size 1 KiB (1024 bytes)
DOS/MBR partition map
Partition 1: 376 MiB (394264576 bytes, 770048 sectors from 1443328)
  Type 0x83 (Linux)
Partition 2: 2.610 GiB (2802057216 bytes, 5472768 sectors from 2213376)
  Type 0x83 (Linux)
Partition 3: 1.998 TiB (2197353135616 bytes, 4291705343 sectors from 3261952)
  Type 0x83 (Linux)


As you can see, the number is exactly the value of my USRDATA+FAT, but....there is one little issue in using the entire value, all MTK6572 that this method has been tested on various devices  The full value will not load, I have tried all different methods, just cannot figure out how to get it to work, this may be because the mod does not actually change your blocksmap.  In terminal shell, if you type adb pull /etc/dumchar_info, before and after the mod, this is where MTKdroid tools pulls the blocks maps from, it will not be changed.  There has to be a leftover value, the smallest being 110kb, in the EBR1, in order for the mod to actually work. 

In the area where the old value was 00 10 but now is 82 53, for the first number, every one adds 110kb and for the second set of numbers, every one added is 32mb.  The 82 need to be reduced by one, leaving a value of 81, enabling the modified EBR1 to successfully load without issues.  If you want to try the full value yourself, don't be surprised when the tablet doesn't get past the boot logo.

Now in terminal, once you have reduced your first number by one, again type disktype 2.6gb-EBR1 and the value is now:

--- 2.6gb-EBR1
Regular file, size 1 KiB (1024 bytes)
DOS/MBR partition map
Partition 1: 376 MiB (394264576 bytes, 770048 sectors from 1443328)
  Type 0x83 (Linux)
Partition 2: 2.609 GiB (2801926144 bytes, 5472512 sectors from 2213376)
  Type 0x83 (Linux)
Partition 3: 1.998 TiB (2197353135616 bytes, 4291705343 sectors from 3261952)
  Type 0x83 (Linux)

If you want, you can subtract that number from the first number, no matter what the size of your total USRDATA+FAT, it will come out to be 131072, which shows on the devices as 110kb.  


The next thing is to fix the beginning and end sectors of the EBR1, in terminal enter gdisk 2.6gb-EBR1 and press p.

Number  Start (sector)    End (sector)  Size       Code  Name
   1         1443328         2213375   376.0 MiB   8300  Linux filesystem
   2         2213376         7685887   2.6 GiB     8300  Linux filesystem
   3         3261952      4294967294   2.0 TiB     8300  Linux filesystem



The end sector, 7685887 needs to be increased by one, there are two ways this can be done, I found the easiest being, taking the number, 7685887, adding one and in calculator getting the hex value, as so:




Just like before, the value 754700 is going to be read from right to left starting with 47 and ending with 75 making C631 become 47 75.

00 00 83 00 00 00 00 06 16 00 00 C0 0B 00 00 
00 00 00 83 00 00 00 00 C6 21 00 00 81 53 00 00 
00 00 00 83 00 00 00 00 C6 31 00 FF 39 CE FF 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA

Back in terminal shell, when typing gdisk 2.6gb-EBR1, you can see that the end sector of partition #2 is one number less then the beginning sector of partition #3.  If you pay close attention though, you will notice that the end sector of partition #3 has reduced, this needs to be corrected in order for a successful flash in SPFLASH tools.  

After taking a look at three different MTK6572 EBR1 files, it was discovered that all three ended with a value of 4294967294, to check for yourself, type gdisk EBR1 and you will see that indeed the value is 4294967294.  To double check, gdisk your original EBR1 and check the end sector of partition #3.

What I found that works is, and if you want to try this on your own, subtracting the number, 4294967294, which is the end sector of partition #3, from the start sector of partition #3, in the original EBR1, making sure that the decimal dropdown is selected, then switch to hexadecimal, just as so:

Number  Start (sector)    End (sector)  Size       Code  Name
   1         1443328         2213375   376.0 MiB   8300  Linux filesystem
   2         2213376         3261951   512.0 MiB   8300  Linux filesystem
   3         3261952      4294967294   2.0 TiB     8300  Linux filesystem



 Now in your original EBR1 file, you can see that is where the hex value for the number, 4294967294 comes from:

00 00 83 00 00 00 00 06 16 00 00 C0 0B 00 00 
00 00 00 83 00 00 00 00 C6 21 00 00 81 53 00 00 
00 00 00 83 00 00 00 00 47 75 00 FF 39 CE FF 00

00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA

All that has to be done is to take the same value, 4294967294, subtract that that from new start sector of partiion #3 in the 2.6gb-EBR1:



39 CE will now become B8 8A, in terminal shell, gdisk 2.6gb-EBR1 will now show:

Number  Start (sector)    End (sector)  Size       Code  Name
   1         1443328         2213375   376.0 MiB   8300  Linux filesystem
   2         2213376         7685887   2.6 GiB     8300  Linux filesystem
   3         7685888      4294967294   2.0 TiB     8300  Linux filesystem

This is going to leave a storage of 110kb for internal storage, When I tried formatting in gparted to hide, gparted said could not do anything with a size of -1mb.  After a reboot it disappeared, doesn't even show in my file manager when enabling USB storage.  Some system apps are gong to want to use that 110kb for various things. Google Chrome is one example, when trying to share photos in Chrome browser, if that 110kb internal storage is enabled, it will try to use it as a cache, causing a low memory error.

12 comments :

  1. Just wanted to say a massive thank you.

    I had been looking up various methods to achieve this, but none were as easy to understand as yours. Granted it took me some time (essentially 2 days) to fully comprehend the information, and a lot of playing around with the hex/dec values until I was (almost) sure that I knew what I was doing.

    Anyway, it worked great. Thanks again.

    ReplyDelete
  2. Hi, thanks for your detail tutorial,

    I Just want to confirm, after finished editing EBR1, do I just have to flash EBR1 only ? (leave all other options like PRELOADER, MBR, UBOOT, etc unchecked)

    I will try this tonight :P hope all is going to fine

    ReplyDelete
    Replies
    1. Works GREAAAT, Thank You Liz,

      Now my IMO S50 Light (MTK 6572) have 3 GB Internal Storage, I leave 30MB for Phone Storage

      Delete
    2. Looks like you got it working, sorry never saw the comment sooner. For anybody who is wondering. Each phone can be differant. You may have to restore everything, some may not. If you restore just the EBR1 and it sticks at the logo, go back and restore everything else.

      Delete
    3. please helpme , i dont know the process.... i have mtk 6572 4gb memory intenrt

      Delete
  3. Thank you for this amazing tut.

    But I need help. Can someone do my hexing for me .I'm new at it. I can get through editing the scatter but not ebr1

    I have 304mb(from calculations hex to DEC) of /data. And 900mb of sdcard

    I want 100mb of sdcard and the rest to /data partition. Thank you in advance

    Contact me on dali786546@gmail.com
    I'll send u my dump.

    ReplyDelete
  4. Hey Elizabeth can you please do mine for me because I don't know how to use binary and stuff. Plz and thnx

    ReplyDelete
  5. Thank you for this tutorial!
    You've explained all in details, and I doubled the phone memory (I didn't need more) to my Allview A5 Smiley.
    Also I didn't have to format anything but the internal memory after the phone started.
    It's working like a charm!

    ReplyDelete
  6. Hello and Happy New Year, Ms. Elizabeth - thank you very much for your tutorial. I would like to try this on my MTK6572 phone (http://www.symbianize.com/showthread.php?t=1128125) . Does my phone need to be rooted? And how do I get the scatter.txt in the very first step? I'm really new at this, but very eager to learn how... Many Thanks, from the Philippines :-)

    ReplyDelete
  7. When you says "After a reboot it disappeared, doesn't even show in my file manager when enabling USB storage. Some system apps are gong to want to use that 110kb for various things. Google Chrome is one example, when trying to share photos in Chrome browser, if that 110kb internal storage is enabled, it will try to use it as a cache, causing a low memory error." i think that the partition not appears in the phone storage settings again but it causes problems with another apps, i'm right ?

    ReplyDelete
  8. I just can't get my China Iphone 6s plus (MTK6572)comply to this tutorial. In my backup there is no EBR file and uses NAND as storage. What should I edit to increase my internal Data Partition?

    ReplyDelete

My Blog List