Tampilkan postingan dengan label sdcard. Tampilkan semua postingan
Tampilkan postingan dengan label sdcard. Tampilkan semua postingan

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

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

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

fail to install apps? try this solution

when you download and install apps from the market, sometimes you will find that INSTALL_FAILED_CONTAINER_ERROR in the log or "Application not installed" error

they are usually SDCARD related problem, do this and reinstall your app and see if it helps:

- unmount external sdcard
goto settings-> sd card and phone storage -> unmount sd card

if you can install the app after, then it's should be sdcard related problem. to avoid or fix this permanently, do this (root is needed):

- change the permission of /mnt/secure/asec/smdl2tmp1.asec to 777
OR
- delete /mnt/secure/asec/smdl2tmp1.asec

switch modem anytime anywhere

i made this little update.zip just for testing with different modems anytime i want to, so it may be useless to most of u guys but i think some ppl may need it in some cases

the attached is ONLY a skeleton, the modem file inside the zip is an empty file

usage:
- open the update-modem-xxx.zip file and drag the modem.bin u want to flash in the zip and replace the zero size modem.bin in it (no need to chg other files), close the zip and that's all
- make copies of zip file for different modems if u wish (sorry but no time to make fancy file selection at the moment)
- flash the modem by selecting ur desire modem in cwm under /sdcard (pls refer to cwm page for how-to)
- no need to worry about recovery2e or 3x coz as long as u can run cwm, u r with recovery2e (or others in the future)

so possibilily, u can have update-modem-jpp.zip, update-modem-jpa.zip, and so forth

and for me, i've the following files on my sdcard:
update-modem-I9000XWJPA.zip
update-modem-I9000XXJPP.zip
update-modem-I9000ZSJP8.zip
update-modem-I9000ZSJPE.zip


why?
- provides a way to let u switch modem if u suspects the modem causes problems
- see if u can find the best modem for u

how?
- the modem will be flashed with redbend_ua, a direct write to ur phone's /dev/block/bml12

Note: ur phone will flick 2 or 3 times during flash



WARNING: i tested it on my phone with JPx, froyo 2.2 on galaxy i9000 only. I cannot say it's 100% safe although i flashed my phone a lot of times, so use it at your own risks

Also note that there will be NO updates in the future


EDIT: the redbend_ua is taken from somwhere, all credits go to the modder


update-modem-xxx.zip


more info