Thursday, October 9, 2014

Increase/Decrease MTK6572 Cache

This is going to be somewhat like this previous post, increasing internal storage on the MTK6572, with the exception of increasing, or decreasing, the cache, you can decide which is better.

Somebody asked me about a mod I tried on my tablet where the Cache size was decreased, giving a total of 2.95gb of internal storage.  Seeing the internal storage at almost 3gb was pretty cool, although, it seemed as if the performance of the tablet decreased somewhat.  After trying the mod again, noticed that some apps slowed down and others would not open.  This reminded me of something learned in a college course, the instructor had said something about, the more space you have will give you better speed.  Another words, if you install an 80gb hard drive with a RPM of 5400 and 4gb of RAM in your computer.  Now if one were to upgrade that hard drive, without changing anything else, to 100gb with a RPM of 7200, you will notice the difference in speed. This made a little light click, thinking, well if there is more cache for apps, would the tablet run faster, in my opinion it does appear to run a little better then before.

What I noticed yesterday is that when playing with the numbers, in order to get a working number to enter in the EBR1, everything has to be in 16 bytes, so that the numbers, for the Internal Application Storage, are divisible by 32.  A couple of of the caches sizes I did looked at are 126 MiB and 376 MiB.  Not sure if there are any other sizes when it comes to the MTK6572, did successfully make a workable EBR1 work with a cache size of 512 MiB.

--- 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: 512 MiB (536870912 bytes, 1048576 sectors from 2213376)
  Type 0x83 (Linux)
Partition 3: 1.998 TiB (2197353135616 bytes, 4291705343 sectors from 3261952)
  Type 0x83 (Linux)


This means, 394264576 bytes / 376 MiB = 770048 decimal value, BC000 hexadecimal value.


BC000 will then be converted to C00B:

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

Where does the extra bytes come from?  Well, if you do another math solution, it actually works out a little better when modding.  Lets take a number that is divisible by 2, how about 376 MiB, and see what the hex value is.



It's 3F, using some imagination, you have to fill in the blanks zeros, x3xF is read from right to left, entered from left to right as F0 03 now here is a EBR1 from the THL TS MTK6572:

00 00 83 00 00 00 00 56 11 00 00 F0 03 00 00 00 
00 00 83 00 00 00 00 46 15 00 00 E0 1C 00 00 00 
00 00 83 00 00 00 00 26 32 00 FF D9 CD FF 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA

When you check the EBR1, disktype EBR1 

--- EBR1
Regular file, size 512 bytes
DOS/MBR partition map
Partition 1: 126 MiB (132120576 bytes, 258048 sectors from 1136128)
  Type 0x83 (Linux)
Partition 2: 924 MiB (968884224 bytes, 1892352 sectors from 1394176)
  Type 0x83 (Linux)
Partition 3: 1.998 TiB (2197340552704 bytes, 4291680767 sectors from 3286528)
  Type 0x83 (Linux)


Quite slick of them wouldn't you say?  This makes it so much easier, if somebody doesn't want to increase the cache by to much or decrease it to small, you just need a number that can be divided by 2.  Lets play around with a random number, if the cache is 126, lets just double it, giving a value of 256.


Looking at the hexadecimal value, yes it shows 80, so one has to use their brain power.  The hex total needs to be read from right to left, mentally add the 2 missing zeros from right to left then entering the hex value into the EBR1 from left to right.  So the Hex value is read x8x0 then entered as 00 08.

This is how it would looked after the change has been made:

00 00 83 00 00 00 00 56 11 00 00 00 08 00 00 00 
00 00 83 00 00 00 00 46 15 00 00 E0 1C 00 00 00 
00 00 83 00 00 00 00 26 32 00 FF D9 CD FF 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA 

This is where all those mysterious bytes come from, disktype EBR1 now shows:

--- EBR1
Regular file, size 512 bytes
DOS/MBR partition map
Partition 1: 256 MiB (268435456 bytes, 524288 sectors from 1136128)
  Type 0x83 (Linux)
Partition 2: 924 MiB (968884224 bytes, 1892352 sectors from 1394176)
  Type 0x83 (Linux)
Partition 3: 1.998 TiB (2197340552704 bytes, 4291680767 sectors from 3286528)
  Type 0x83 (Linux)

Maybe a simple way of explainging would be, to obtain the correct numbers would be, if you are unsure of exactly what was increased/decreased, take the byte value from the original EBR1, subtract the byte value from the new byte value of the modified EBR1:

New EBR1: 
Partition 1: 256 MiB (268435456 bytes, 524288 sectors from 1136128)
  Type 0x83 (Linux)

Original EBR1:
Partition 1: 376 MiB (394264576 bytes, 770048 sectors from 1443328)
  Type 0x83 (Linux)


394264576-268435456=125829120 should be added as USERDATA+FAT+125829120 if decreasing your cache.
394264576-268435456=125829120 should be subtract as USERDATA+FAT-125829120 if increasing your cache

Just like the MTK6572 repartition mod for internal storage, the same rule applies, partition #2 start address needs to be one number higher then partition #1 end address.

gdisk EBR1

Number  Start (sector)    End (sector)  Size       Code  Name
   1         1136128         1660415   256.0 MiB   8300  Linux filesystem
   2         1394176         3286527   924.0 MiB   8300  Linux filesystem
   3         3286528      4294967294   2.0 TiB     8300  Linux filesystem


To fix the second two hex numbers in the EBR1, this means that the end sector of partition #1, 1660415 needs to be 1660416 for the start sector of partition #2.  In calculator enter 1660415 as a decimal value and you will get this:


Also, same rule applies, ignore the last two zeros and reading from right to left enter 1956 as 56 19 in your EBR1 like this:

00 00 83 00 00 00 00 56 11 00 00 00 08 00 00 00 
00 00 83 00 00 00 00 56 19 00 00 E0 1C 00 00 00 
00 00 83 00 00 00 00 26 32 00 FF D9 CD FF 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA


Now check to make sure everything lines up, gdisk EBR1

Number  Start (sector)    End (sector)  Size       Code  Name
   1         1136128         1660415   256.0 MiB   8300  Linux filesystem
   2         1660416         3552767   924.0 MiB   8300  Linux filesystem
   3         3286528      4294967294   2.0 TiB     8300  Linux filesystem


Next make sure to update your scatter file, in terminal again enter disktype EBR1:

Regular file, size 512 bytes
DOS/MBR partition map
Partition 1: 256 MiB (268435456 bytes, 524288 sectors from 1136128)
  Type 0x83 (Linux)
Partition 2: 924 MiB (968884224 bytes, 1892352 sectors from 1660416)
  Type 0x83 (Linux)
Partition 3: 1.998 TiB (2197340552704 bytes, 4291680767 sectors from 3286528)

  Type 0x83 (Linux)

Enter 268435456 into the calculator to get the scatter hex value:

Change:

- partition_index: SYS16
  partition_name: CACHE
  file_name: cache.img
  is_download: true
  type: YAFFS_IMG
  linear_start_addr: 0x3C140000
  physical_start_addr: 0x3BB40000
  partition_size: 0x17800000
  region: EMMC_USER
  storage: HW_STORAGE_EMMC
  boundary_check: true
  is_reserved: false
  operation_type: UPDATE
  reserve: 0x00


To:

- partition_index: SYS16
  partition_name: CACHE
  file_name: cache.img
  is_download: true
  type: YAFFS_IMG
  linear_start_addr: 0x3C140000
  physical_start_addr: 0x3BB40000
  partition_size: 0x10000000
  region: EMMC_USER
  storage: HW_STORAGE_EMMC
  boundary_check: true
  is_reserved: false
  operation_type: UPDATE
  reserve: 0x00


Unlike the mod to increase the internal application storage, you do not need to worry about partition #3 end sector, this mod will not change it.  If you want to move on to the next step, increasing internal application storage for MTK6572, just click the link and follow the directions according to the modified cache scatter text.

**WARNING** THIS MOD IS TRICKIER WHEN CHANGING THE CACHE PARTITION, THESE STEPS ARE IMPORTANT TO SUCCESSFULLY FLASH  IN SPFLASH TOOLS

Open spflash tools, select the format tab and you need to manually format the three following areas and enter, ONE BY ONE, the linear_start_addr and partition_size according to the modified scatter.

- partition_index: SYS15
  partition_name: ANDROID
  file_name: system.img
  is_download: true
  type: YAFFS_IMG
  linear_start_addr: 0x3D40000
  physical_start_addr: 0x3740000
  partition_size: 0x38400000
  region: EMMC_USER
  storage: HW_STORAGE_EMMC
  boundary_check: true
  is_reserved: false
  operation_type: UPDATE
  reserve: 0x00

- partition_index: SYS16
  partition_name: CACHE
  file_name: cache.img
  is_download: true
  type: YAFFS_IMG
  linear_start_addr: 0x3C140000
  physical_start_addr: 0x3BB40000
  partition_size: 0x17800000
  region: EMMC_USER
  storage: HW_STORAGE_EMMC
  boundary_check: true
  is_reserved: false
  operation_type: UPDATE
  reserve: 0x00

- partition_index: SYS17
  partition_name: USRDATA
  file_name: data.img
  is_download: true
  type: YAFFS_IMG
  linear_start_addr: 0x53940000
  physical_start_addr: 0x53340000
  partition_size: 0x3E800000
  region: EMMC_USER
  storage: HW_STORAGE_EMMC
  boundary_check: true
  is_reserved: false
  operation_type: UPDATE
  reserve: 0x00










Once that is done, make sure that you do not download the ANDROID USRDATA and CACHE, change them from true to false according to this line:

From

is_download: true

To:


is_download: false

After you have flashed, in clockwork mod recovery, restore ONLY the data and system.  Do not do anything with the cache, your backup is according to the old cache size and will cause a soft brick, leaving the device stuck at the boot logo.  You will need to create a new backup for future restores according to the cache size.

2 comments :

  1. Excellent work!
    I increased cache and userdata partitions on my Chinese Mtk6275 phone. It works much better now!

    Thanks!

    ReplyDelete
  2. My lg v495 tablet is stuck on the lg logo I done tried hard reset but didn't work can you help me?

    ReplyDelete

My Blog List