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:

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
{ 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

Free more available disk space from NAND - PART I

The nand partitions layout in Samsung Galaxy S I9000 is controlled by a pit file (Partition Information Table), while for the mmc drive, it is hard coded in the init file.

For example, in Samsung Galaxy S I9000, the stock partition tables for s1_odin_20100512.pit should look like this:

NAND disk */dev/block/stl1 - stl6 omitted
device name mount point size in MB remarks
/dev/block/stl7 n/a 7.5 known as KERNEL, for holding zImage
/dev/block/stl8 n/a 7.5 known as RECOVERY, for storing a copy of zImage
/dev/block/stl9 /system 286.5 known as FACTORYFS
/dev/block/stl10 /dbdata 134 known as DBDATA
/dev/block/stl11 /cache 35 known as CACHE
/dev/block/stl12 n/a 7.5 known as MODEM, for storing modem.bin
MMC disk
device name mount point size in MB remarks
/dev/block/mmcblk0p1 /mnt/sdcard (/sdcard) ~6200 (8G) / ~14200 (16G) none
/dev/block/mmcblk0p2 /data ~2000 none

For other pit files like s1_odin_20100513 and s1_odin_20100803, the size of /system and /dbdata are different. So for a larger /system partition, a smaller /dbdata and/or /cache will be resulted and vice versa since the total size of the nand is fixed (~500MB)

When we flash a rom to our phone, the above information will be read by odin to decide where the files will be stored. For instance, the zImage will be written to /dev/block/stl7 (/dev/block/bml7) and /dev/block/stl8 (/dev/block/bml8), while the FACTORYFS.rfs will be stored on /dev/block/stl9 (or /dev/block/bml9) at a specific start block address, up to the size of the file and so forth.

As a result, if we wanna use our own customized partition layout, we have to deal with the pit file and the mmc via fdisk or parted, etc


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




for more details, read:
Investigation Into PIT Files
The reality of PIT files

Minggu, 24 Juli 2011

getting bored with ur i9000 already? yet more to come!

hi all,
i still have some more mods/tweaks not yet published. pls kindly give me some time to tidy them up and be patient. i also have to decide in what way to publish them since, as usual, i prefer not to release mods in a complete rom format


:)

Selasa, 05 Juli 2011

JVQ Browser lag quick fix

i'm too frustrated with samsung's stock browser since JP6, and the deodexed one from JVQ is totally rubbish. it's sooooo lag that i've to wait for 2 seconds after each scroll


so, after studying some great posts in xda, i've modded a deodexed JVQ browser with all the lag things disappeared. now it just perform like what it used to be, u can scroll from the top to the bottom of the page with 1 single scroll. HOWEVER, i cannot say it's 100% bugs-free



so, USE IT AT YOUR OWN RISKS!! and remember to do BACKUP!




installation (for deodexed rom):
simply remove the existing Browser.apk from /system/app, and put this one there

PS you may notice some strange thing when u start this modded browser for the 1st time like a blank page is shown or cant scroll the page. just reload the page or restart the browser will do


NOTICE to all users:
- this is a one-off mod and it is not supposed to have any further modifications/adjustments

NOTICE to modders/developers:
- if u want to keep this alive or help to maintain this mod, etc, feel free to ask for the trick in xda


you can get it here