This is actually part of my freeNANDmod for the Samsung Galaxy S I9000. However, I would like to introduce this trick to all Samsung Galaxy SII I9100 users too.
The only difference is, for I9000, /dev/block/bml12 is used for holding the modem.bin file, while for I9100, it's /dev/block/mmcblk0p8.
In order to do the trick, put a modem file somewhere, say /data/modem/modem.bin, and create a symlink to it like the example below:
for I9000
ln -s /data/modem/modem.bin /dev/block/bml12
for I9100
ln -s /data/modem/modem.bin /dev/block/mmcblk0p8
Put it in a script file and place it under your init.d, usually /etc/init.d (or /system/etc/init.d), and it is suggested to name it with prefix 00 (zero zero) like 00-load-modem so that it can be executed first since scripts in init.d are executed in sequential order.
A sample init script should look like:
for I9000
rm /dev/block/bml12; ln -s /data/modem/modem.bin /dev/block/bml12
for I9100
rm /dev/block/mmcblk0p8; ln -s /data/modem/modem.bin /dev/block/mmcblk0p8
The "rm /dev/block/bml12" or "rm /dev/block/mmcblk0p8" command is used to remove the block device bml12 or mmcblk0p8 created by the system during init. You have to remove it first before you can create a symlink with the same name.
To see if it run correctly, put another version of modem instead of the one already on your phone to /data/modem/modem.bin after the init script is created. Reboot your phone and type *#1234# in the dialpad, you should see the new modem version is in use now. Note that after you have replaced the /data/modem/modem.bin with another modem, you'll need to reboot the phone.
So if you want to, you can place different versions of modem.bin file in /data/modem/ and symlink to modem.bin or overwritting it by copy and paste.
reference to my post: freeNANDmod - get more space from NAND - PART IV
Tampilkan postingan dengan label symlink. Tampilkan semua postingan
Tampilkan postingan dengan label symlink. Tampilkan semua postingan
Kamis, 29 September 2011
Sabtu, 13 Agustus 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"},
demo_pit_1.c:
{ 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

solution:
- 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:
demo_pit_1.pit
demo_pit_1.c
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
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"},
demo_pit_1.c:
{ 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

solution:
- 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:
demo_pit_1.pit
demo_pit_1.c
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
Jumat, 29 Juli 2011
freeNANDmod - get more space from NAND - PART III
Since the day I understood how Galaxy S works with Android about a year ago, I always ask myself why it is designed like that. So I spent a few months to modify the systems to suit my own needs with tons of modifications. Although Samsung changed the system a bit in recent roms and rectified some problems like inadequate size for the /cache partition, there are still a lot of improvements need to be done.
Among these, the most frustrating thing, in my opinion, is the way how Samsung/Android treat the modem. Why should we waste the invaluable 12.5MB for storing the modem.bin in the NAND drive as a temporary storage? So I tried to move it elsewhere but found that the location of the modem.bin is hard coded in the boot loader. More, the loading of the modem file is performed by the bml utils which reads the modem.bin from the nand drive and put it into the memory during the init process. Unfortunately, I was unable to change this due to I am not an expert in C and they are not open sources (althought I discovered some related source files at a later stage).
freeNANDmod
Finally, I found a way to remove the modem completely from the nand drive and freed the extra 12.5MB when I tried to free some more nand disk space for my own use. This finding, together with the mod for the nand drive partitons (let's call it freeNANDmod :D), allows us to get more free nand disk space available for faster reads/writes. And what it does actually is to make more room in the nand storage for larger partitions, by moving the traditional partitions in the nand disk to and from the mmc disk.
Although it looks like easy enough to move the partitions around, there are some more works needed to reflect these changes to the system. The obvious thing is to handle the new partition layout so that the system will get the right partition when needed. It is not a difficult task for me, and since I modified my system to run on loop devices, I already have my own mount and umount processes/scripts to override the system's. However, for most of the rom modders, they will need to find a way to tell the system where and which the partitions are, since afaik, they dont' have to care about this before.
Other areas which required attentions include, but not limiting to, making sure the rom and subsequent files can be written to the correct partitions during rom reflashing while maintaining your new layouts, as well as handling these info in the recovery process or otherwise neither the stock recovery nor cwm recovery will work properly especially if you made changes to the /cache.
You may ask at this point, "So what did you do to the layout and how can we benefit from your mod?"
Let's take a look at my current partitions snapshot:
As you can see in the table above, I have one single partition with 444MB available on /dbdata. It is 4x compared with the stock version (134MB with s1_odin_20100512.pit). You can also find the /system and /cache partition are moved to the mmc disk, for the reasons that:
- the /system holds read only files usually (that's why it is mounted as read-only by default), therefore the writing speed to /system can be ignored
- for those files reside on /system that require faster read, you can always put them in the new /dbdata instead
- the /cache now is a dummy partition which require limited reads/writes, and can be completely removed in case you want to handle it yourself during the boot process
PS I am not following S2's. I have made these changes for about 2 months and I only realized the /system in S2 is located at mmc also about 2 weeks ago
* wearing and tearing is not taken into account and will not be discussed
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 IV
Among these, the most frustrating thing, in my opinion, is the way how Samsung/Android treat the modem. Why should we waste the invaluable 12.5MB for storing the modem.bin in the NAND drive as a temporary storage? So I tried to move it elsewhere but found that the location of the modem.bin is hard coded in the boot loader. More, the loading of the modem file is performed by the bml utils which reads the modem.bin from the nand drive and put it into the memory during the init process. Unfortunately, I was unable to change this due to I am not an expert in C and they are not open sources (althought I discovered some related source files at a later stage).
freeNANDmod
Finally, I found a way to remove the modem completely from the nand drive and freed the extra 12.5MB when I tried to free some more nand disk space for my own use. This finding, together with the mod for the nand drive partitons (let's call it freeNANDmod :D), allows us to get more free nand disk space available for faster reads/writes. And what it does actually is to make more room in the nand storage for larger partitions, by moving the traditional partitions in the nand disk to and from the mmc disk.
Although it looks like easy enough to move the partitions around, there are some more works needed to reflect these changes to the system. The obvious thing is to handle the new partition layout so that the system will get the right partition when needed. It is not a difficult task for me, and since I modified my system to run on loop devices, I already have my own mount and umount processes/scripts to override the system's. However, for most of the rom modders, they will need to find a way to tell the system where and which the partitions are, since afaik, they dont' have to care about this before.
Other areas which required attentions include, but not limiting to, making sure the rom and subsequent files can be written to the correct partitions during rom reflashing while maintaining your new layouts, as well as handling these info in the recovery process or otherwise neither the stock recovery nor cwm recovery will work properly especially if you made changes to the /cache.
You may ask at this point, "So what did you do to the layout and how can we benefit from your mod?"
Let's take a look at my current partitions snapshot:
device name | mount point | size in MB | location |
/dev/block/stl10 | /dbdata | 444 | NAND |
/dev/block/mmcblk0p1 | /mnt/sdcard | 13757 | MMC (unchanged) |
/dev/block/mmcblk0p2 | /data | 1408 | MMC |
/dev/block/mmcblk0p3 | /system | 370 | MMC |
/dev/block/mmcblk0p4 | /cache | 105 | MMC |
As you can see in the table above, I have one single partition with 444MB available on /dbdata. It is 4x compared with the stock version (134MB with s1_odin_20100512.pit). You can also find the /system and /cache partition are moved to the mmc disk, for the reasons that:
- the /system holds read only files usually (that's why it is mounted as read-only by default), therefore the writing speed to /system can be ignored
- for those files reside on /system that require faster read, you can always put them in the new /dbdata instead
- the /cache now is a dummy partition which require limited reads/writes, and can be completely removed in case you want to handle it yourself during the boot process
PS I am not following S2's. I have made these changes for about 2 months and I only realized the /system in S2 is located at mmc also about 2 weeks ago
* wearing and tearing is not taken into account and will not be discussed
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 IV
Kamis, 28 Juli 2011
Free more available disk space from NAND - PART II
As to change the partition layout of the nand disk, we have to create the pit file ourself for custom partitions size. The pit file can be obtained by compiling a C file containing the partition info. Below shows part of the s1_odin_20100512.c provided by coolya
* /dev/block/stl1 - 6 omitted
The first entry is mapped as /dev/block/stl7 (/dev/block/bml7), and so forth. Thus MODEM will be mapped to /dev/block/stl12 (/dev/block/bml12). For the meaning of each of the column above, we have to refer to the structure listed below from the C file:
Take the CACHE partition as example, the partition info stated in s1_odin_20100512.c reads:
{ 0, 0, 0x18, 0x02, 0, 256, 140, "", "CACHE", "cache.rfs"}
That is to say, the properties of the CACHE partition should be, starts from column one:
0 - the partition is being used
0 - the partition is being used
0x18 - the partition ID
0x02 - the partition allows read/write
0 - (unknown)
256 - blocksize
140 - partition size
"empty" - (unknown)
CACHE - the partition is known as CACHE
cache.rfs - the file to be filled
Normally, we only need to deal with columns 1, 2, 4, 7, 9 and 10:
- column 1 and 2: set to 0 to mark this partition usable
- column 4: set to 0x02 for both read/write accesses
- column 7: set this to 140 units (or 35MB) for this partition, where 140 x 256 / 1024 = 35MB, ie each unit = 0.25MB
- column 9: set this as CACHE for internal reference
- column 10: set the filename required for filling this partition
So for the KERNEL or /dev/block/stl7 (/dev/block/bm7):
{ 0, 0, 0x06, 0x00, 0, 256, 30, "", "KERNEL", "zImage"}
means that this partition is known as KERNEL, with 7.5MB disk space allocated, and the required file is zImage
read more:
Free more available disk space from NAND - PART I
freeNANDmod - get more space from NAND - PART III
freeNANDmod - get more space from NAND - PART IV
* /dev/block/stl1 - 6 omitted
{ 0, 0, 0x06, 0x00, 0, 256, 30, "", "KERNEL", "zImage"},
{ 0, 0, 0x07, 0x00, 0, 256, 30, "", "RECOVERY", "zImage"},
{ 0, 0, 0x16, 0x02, 0, 256, 1146, "", "FACTORYFS", "factoryfs.rfs"},
{ 0, 0, 0x17, 0x02, 0, 256, 536, "", "DBDATAFS", "dbdata.rfs"},
{ 0, 0, 0x18, 0x02, 0, 256, 140, "", "CACHE", "cache.rfs"},
{ 0, 0, 0x0b, 0x00, 0, 256, 50, "", "MODEM", "modem.bin"},
The first entry is mapped as /dev/block/stl7 (/dev/block/bml7), and so forth. Thus MODEM will be mapped to /dev/block/stl12 (/dev/block/bml12). For the meaning of each of the column above, we have to refer to the structure listed below from the C file:
unsigned int _00; /* unknown. set to 1 is entry unused */
unsigned int _04; /* unknown. set to 1 is entry unused */
unsigned int partid; /* partition ID */
unsigned int flags; /* flags. 0x 00= RO, 0x02=R/W */
unsigned int _14; /* unknown */
unsigned int blocksize; /* blocksize in 512 byte units */
unsigned int partsize; /* partition size in blocks */
char _20[8]; /* unknown */
char partname[32]; /* partition name */
char filename[64]; /* filename */
Take the CACHE partition as example, the partition info stated in s1_odin_20100512.c reads:
{ 0, 0, 0x18, 0x02, 0, 256, 140, "", "CACHE", "cache.rfs"}
That is to say, the properties of the CACHE partition should be, starts from column one:
0 - the partition is being used
0 - the partition is being used
0x18 - the partition ID
0x02 - the partition allows read/write
0 - (unknown)
256 - blocksize
140 - partition size
"empty" - (unknown)
CACHE - the partition is known as CACHE
cache.rfs - the file to be filled
Normally, we only need to deal with columns 1, 2, 4, 7, 9 and 10:
- column 1 and 2: set to 0 to mark this partition usable
- column 4: set to 0x02 for both read/write accesses
- column 7: set this to 140 units (or 35MB) for this partition, where 140 x 256 / 1024 = 35MB, ie each unit = 0.25MB
- column 9: set this as CACHE for internal reference
- column 10: set the filename required for filling this partition
So for the KERNEL or /dev/block/stl7 (/dev/block/bm7):
{ 0, 0, 0x06, 0x00, 0, 256, 30, "", "KERNEL", "zImage"}
means that this partition is known as KERNEL, with 7.5MB disk space allocated, and the required file is zImage
read more:
Free more available disk space from NAND - PART I
freeNANDmod - get more space from NAND - PART III
freeNANDmod - get more space from NAND - PART IV
Langganan:
Postingan (Atom)