13 August, 2011

freeNANDmod - get more space from NAND - PART IV

Modifying the partitions

I have attached a modified s1_odin_20100512.c souce file provided by coolya and the corresponding compiled pit file below.

WARNING: to flash a new/modded PIT is extremely dangerous!! The files attached are provided as is and for demo only. They are only for advanced users. I am not responsible for any damages, in all kinds and/or by any means, caused by using these files. So, DO IT AT YOUR OWN RISKS!! More, make sure you have read the whole post before flashing your device.

demo_pit_1.pit (modified version of s1_odin_20100512):
This pit file serves as a demonstration of how to get 12MB more disk space from the NAND by moving the modem elsewhere. The only changes are highlighted below:

original s1_odin_20100512.c:
{ 0, 0, 0x18, 0x02, 0, 256, 140, "", "CACHE", "cache.rfs"},
{ 0, 0, 0x0b, 0x00, 0, 256, 50, "", "MODEM", "modem.bin"},

{ 0, 0, 0x18, 0x02, 0, 256, 189, "", "CACHE", "cache.rfs"},
{ 0, 0, 0x0b, 0x00, 0, 256, 1, "", "", ""},

As shown in above, the 7th column (size in units) of CACHE in original s1_odin_20100512.c has 140 units, and 50 units are assigned to modem.bin. While in demo_pit_1.c, the modem has been removed from the partition table and the units assigned are freed. The 50 units freed are assigned to the CACHE partition. Note that:
- only 49 units are assigned to CACHE with 1 unit left for MODEM (removed) since I found that assigning zero caused problems
- the new CACHE partition is now assigned with 189 units, that is, 49 more then the original s1_odin_20100512 pit file
- the partiton name (9th column) and filename (10 column) for the MODEM partition (removed) in demo_pit_1 are emptied, meaning that this partition contains no partition name, should be filled with no file, and only 1 unit in size
- although we have added an extra 49 units to the CACHE, it will not necessarily 49 units or 12MB larger (1 unit = 0.25MB) since there will be some rounding or alignment problems which reduce the actual available size to the system

If you have read the previous parts of this mod, you may noticed that in the 1st and 2nd column, which are the indicators for whether the partition is enabled, it is set to 0 (enabled or used) instead of 1 (disabled or unused). So why not set it to disabled? It is because setting it to disabled will produce problems for the system to recoginze the partition table.

to flashing with this pit:
- pick a rom of your choice to flash
- choose demo_pit_1.pit as PIT in Odin or other flashing tools
- DO NOT include any modem and leave the PHONE/MODEM empty, we don't need the modem here (in case you included the modem and see an error, reboot into download mode and reflash again without the modem file)

Note that your device will be wiped (except those resides on the internal sdcard - /sdcard and /data), so backup your files first.

possible problems encountered:
- completely blank screen
- unable to boot into recovery mode, nor normal mode
- shown with this icon

- boot into the download mode (keep the buttons pressed for a bit longer)
- reflash with a stock pit file with re-partition enabled, together with a full stock rom (PDA + PHONE + CSC) or custom rom

Setting up the modem

In order to let the system to read the modem file, we need to tell the system where the modem file (modem.bin) is. It is by default set to /dev/block/bml12 (/dev/block/stl12) but that partition has been removed (trimmed to 1 unit in size actually).

First, you have to put the modem file (modem.bin) somewhere like /data/modem.bin or /system/modem/modem.bin or wherever you want to (/data/modem.bin will be used in this example). Then, we are going to fool the system by telling it the modem is there by issuing commands to create a symbolic link (symlink) as follow:

*you need root access and busybox installed

su (do a su first)
rm /dev/block/bml12 (delete the block device created by the system during boot)
ln -s /data/modem.bin /dev/block/bml12 (creating a new symlink to modem.bin)

If you see "ln: command not found", (that means you have not set the path/symlink for ln or busybox), try:
/sbin/busybox ln -s /data/modem.bin /dev/block/bml12

*by assuming your busybox is located in /sbin

After you have set up the symlink for the modem probably, you should get the modem back. However, this symlink has to be created during the init process since so far I have no ideas to unload and reload the modem after the phone is up. As to do this in the init process, create the symlink with the help of a script or do it in the init.rc file. For me, I put it in my init script (similar to init.d) since:
- I can have total control over when to load the modem
- as I mentioned before, I have my own mount process which does not rely on the init.rc

As a result, you will benefit from:
1./ getting 12MB more from the NAND
2./ no need to flash modem file in Odin anymore, just save it to the disk!!
3/. easily switch to another modem anytime you wanted to by overwriting the file or change the symlink to point to another file location (need a reboot)

demo_pit_1 files:

read more:
Free more available disk space from NAND - PART I
Free more available disk space from NAND - PART II
freeNANDmod - get more space from NAND - PART III

Facebook Comments
1 Blogger Comments
Facebook Comments by Blogger Widgets

1 comment:

  1. You are a fucking genius.Keep experimenting,you are doing an excelent job


Note: Only a member of this blog may post a comment.