[HTC Pico (Explorer)] abhinavthms:
/* FOLLOWING PROCEDURE IS FOR SENSE 4.0a AND DERIVED ROMS ONLY */​

THE PROCEDURE

================

The procedure consists of four parts. They are listed below:

Preparing The SDcard

Kernel Level Changes

Setting Up RamDisk

Removing Memory Increasing Script

Detailed description of each part is given below:

PART 1 : Preparing The SDcard

==========================

********YOU MUST USE CLASS 10 OR ATLEAST CLASS 6 SDCARD WITH MINIMUM 8GB CAPACITY*******

CLASS 4 and CLASS 2 SDcards will definitely cause slow responsiveness because /data/data is on SDcard. Furthermore these SDcards can't handle OC at high frequencies and will die out quickly.

SO PROCEED ONLY IF YOU ARE HAVING CLASS 6 OR CLASS 10 SDCARD. YOU CAN TRY CLASS 4 SDCARD BUT YOU CAN'T OVERCLOCK ABOVE A CERTAIN LIMIT AND NO GUARANTEE ABOUT HOW LONG THE CARD WILL LAST.

We are going to create three ext2 partitions ( First one for /sd-ext, second one for replacing /data and third one for replacing /cache in NAND ) on the SDcard, in addition to the normal FAT32 partition.

Using MiniTool Partition Wizard, create three ext2 partitions as shown in following figure:

For SD-EXT, around 512MB is enough. It contains only system files.

For SD-DATA, you can give whatever size you want. This where the user applications are installed.

For SD-CACHE, around 65MB is enough.

You should keep the order in which partitions are created. Partition Type for SD-EXT, SD-DATA and SD-CACHE should be Primary.

Assuming you have successfully prepared SDcard, lets go the second part:

PART 2 : Kernel Level Changes

==========================

First, you need to replace arch/arm/mach-msm/acpuclock-7201 with this one: https://dl.dropboxusercontent.com/u/95625633/acpuclock-7201.c

This contains the overclocked frequencies and logic to dynamically calculate PLL2 values according to different frequencies.

When you look through the overclocked frequencies, you can see I have disabled 900MHz. This is because Class 4 SDcards can't handle data rate at this frequency. Those who have Class 10 SDcards can enable and try whether it is stable for them.

**** DO NOT OC GPU. ITS FAKE AND ACTUALLY DEGRADES PERFORMANCE. REVERT GPU OC IF YOU HAVE ENABLED IT ****

Next, you need to edit the configuration file ( pico_defconfig in my case ) and enable the following option. Its disabled by default so you have to enable it:

[COLOR="Blue"][B]CONFIG_LBDAF=y[/B][/COLOR]

That's all. Now compile your kernel.

PART 3 : Setting Up RamDisk

========================

Since, we are not using /data and /cache in NAND anymore, the changes must be made in RamDisk.

All modifications are performed on init.rc file.

Open init.rc and perform the following modifications:

1. Find the following line:

[B][COLOR="Red"]mount yaffs2 mtd@userdata /data nosuid nodev[/COLOR][/B]

Replace the above line with following:

[B][COLOR="Blue"]
# Mount SD-EXT
wait /dev/block/mmcblk0p2
wait /dev/block/mmcblk0p2
wait /dev/block/mmcblk0p2
wait /dev/block/mmcblk0p2
mount ext2 /dev/block/mmcblk0p2 /sd-ext nosuid nodev noatime nodiratime barrier=0 data=ordered commit=15 noauto_da_alloc nouser_xattr errors=continue

# Mount SD-DATA
wait /dev/block/mmcblk0p3
wait /dev/block/mmcblk0p3
wait /dev/block/mmcblk0p3
wait /dev/block/mmcblk0p3
mount ext2 /dev/block/mmcblk0p3 /data nosuid nodev noatime nodiratime barrier=0 data=ordered commit=15 noauto_da_alloc nouser_xattr errors=continue
[/COLOR][/B]

2. Now find the following line:

[B][COLOR="Red"]mount yaffs2 mtd@cache /cache nosuid nodev[/COLOR][/B]

Replace the above line with following:

[B][COLOR="Blue"]# Mount SD-CACHE
wait /dev/block/mmcblk0p4
wait /dev/block/mmcblk0p4
wait /dev/block/mmcblk0p4
wait /dev/block/mmcblk0p4
mount ext2 /dev/block/mmcblk0p4 /cache nosuid nodev noatime nodiratime barrier=0 data=ordered commit=15 noauto_da_alloc nouser_xattr errors=continue[/COLOR][/B]

3. Since we are extensively using SDcard, we should adjust the read_ahead_kb parameter for maximum performance:

Add the following lines after this line: mount yaffs2 mtd@persist /persist nosuid nodev

[B][COLOR="Blue"]# SDcard read speed boost
write /sys/block/mmcblk0/bdi/read_ahead_kb 2048[/COLOR][/B]

PART 4 : Removing Memory Increasing Script

=====================================

We are going to remove the memory scripts in the rom.But sense 4 roms have some of their system folder mounted to sd-ext.So to remove it we have to make some changes to the updater script

1.Find and remove all lines in the updater script with sd-ext in them.

2.Next paste the following lines just after the line "package_extract_dir("system", "/system");"

[B][COLOR="Blue"]
ui_print("Mounting sd-ext");
ui_print("------------------");
run_program("/sbin/mkdir", "/sd-ext");
run_program("/sbin/busybox", "mount", "-t", "auto", "/dev/block/mmcblk0p2", "/sd-ext");

ui_print("Preparing sd-ext for flashing");
ui_print("------------------");

run_program("/sbin/mkdir","/sd-ext/app_s");

set_progress(0.25);

ui_print("Flashing stuff to sd-ext");
ui_print("------------------");

package_extract_dir("sd-ext/app_s", "/sd-ext/app_s");
set_perm_recursive(0, 0, 0755, 0644, "/sd-ext/app_s");

ui_print("Linking /sd-ext contents to /system");
ui_print("-----------------------------------");

symlink("/sd-ext/app_s", "/system/app");[/COLOR][/B]

3.(Rom dependend):Some Sense 4 roms have more folders in sd-ext.To know that just check in the sd-ext folder of your rom.zip.Then add the required lines under right sections.

[B][COLOR="Blue"]
ui_print("Preparing sd-ext for flashing");
ui_print("------------------");

run_program("/sbin/mkdir","/sd-ext/system_s");
run_program("/sbin/mkdir","/sd-ext/usr_s");
run_program("/sbin/mkdir","/sd-ext/media_s");

ui_print("Flashing stuff to sd-ext");
ui_print("------------------");

package_extract_dir("sd-ext/media_s", "/sd-ext/media_s");
package_extract_dir("sd-ext/usr_s", "/sd-ext/usr_s");
package_extract_dir("sd-ext/system_s", "/sd-ext/system_s");
set_perm_recursive(0, 0, 0755, 0644, "/sd-ext/media_s");
set_perm_recursive(0, 0, 0755, 0644, "/sd-ext/usr_s");
set_perm_recursive(0, 0, 0755, 0644, "/sd-ext/system_s");
package_extract_dir("bootanimation", "/sd-ext/media_s");

ui_print("Linking /sd-ext contents to /system");
ui_print("-----------------------------------");
symlink("/sd-ext/usr_s", "/system/usr");
symlink("/sd-ext/system_s", "/system/app");
symlink("/sd-ext/media_s", "/system/media");[/COLOR][/B]

4.Now remove the memory script. Try to find the name of the memory script as it is different for different roms.

*** This is very important. You should remove any memory increasing script that you were using. Because /data partition is now on SDcard, using memory increasing script will cause conflict and makes ROM unbootable. ***

NOTE: A new Recovery must be made to support the new /SD-DATA and /SD-CACHE partitions.