[HD2 Android SD Development] marco.palumbi:
New initrd mod for NativeSD - UPDATE

UPDATE from http://xdaforums.com/showpost.php?p=32909294&postcount=1238

Hello to everyone.

With the great help of Robbie P I got this method to work from HaRET too.

For now it has been successfully tested with MAGLDR and HaRET bootloaders and Tytung's "NexusHD2-ICS-4.0.4-CM9-HWA V2.7 [NativeSD]".

Attached to this post there is the initrd.gz that I used for test with Tytung's ROM.

I am sure it will work with CLK too (testers needed).

According with Robbie P this method fixes some Bluetooth related issues.

This method is simpler, cleaner and should be more compatible with NAND roms.

In respect to NAND initrd, the only files modified are init.rc and ueventd.htcleo.rc

busybox and e2fsck are added to /bin and deleted after use.

(please note that busybox and e2fsck binaries must be statically linked to libraries)

this is the diff from Tytung's "NexusHD2-ICS-4.0.4-CM9-HWA V2.7" NAND init.rc and my NativeSD init.rc:

--- /sdcard/NativeSD/init.rc.TytungOriginal
+++ init.rc
@@ -97,11 +97,35 @@
on fs
# mount mtd partitions
# Mount /system rw first to give the filesystem a chance to save a checkpoint
- mount yaffs2 mtd@system /system noatime nodiratime
+ #mount yaffs2 mtd@system /system noatime nodiratime
#mount yaffs2 mtd@system /system ro remount

# move cache to data -TYT
- mount yaffs2 mtd@userdata /data nosuid nodev noatime nodiratime
+ #mount yaffs2 mtd@userdata /data nosuid nodev noatime nodiratime
+
+ # wait for sdcard
+ # wait has a timeot of 5 seconds.
+ # calling it 4 times allows 20 seconds for the mmcblk0p2 partition to show up
+ wait /dev/block/mmcblk0p2
+ wait /dev/block/mmcblk0p2
+ wait /dev/block/mmcblk0p2
+ wait /dev/block/mmcblk0p2
+ # SD Card Speed Fix
+ write /sys/devices/virtual/bdi/179:0/read_ahead_kb 2048
+ # File system check
+ exec /bin/busybox sh -c "/bin/e2fsck -p /dev/block/mmcblk0p2 > /fsck.log"
+ # mount the 1st (NativeSD) SD-EXT partition
+ mkdir /NativeSD
+ mount ext4 /dev/block/mmcblk0p2 /NativeSD wait noatime nodiratime barrier=0
+ # mount the system data app dir
+ exec /bin/busybox mount --bind /NativeSD/NexusHD2-ICS/system /system
+ exec /bin/busybox mount --bind /NativeSD/NexusHD2-ICS/data /data
+ # cleanup
+ # delete /bin to free ram
+ rm /bin/busybox
+ rm /bin/e2fsck
+ rmdir /bin
+
mount yaffs2 mtd@cache /mnt/cache nosuid nodev

on post-fs

this is the diff from Tytung's "NexusHD2-ICS-4.0.4-CM9-HWA V2.7" NAND ueventd.htcleo.rc and my NativeSD ueventd.htcleo.rc:

--- /sdcard/NativeSD/ueventd.htcleo.rc.TytungOriginal
+++ ueventd.htcleo.rc
@@ -1,5 +1,8 @@
# misc partition
-mtd@misc 0460 radio diag
+# mtd@misc 0460 radio diag
+# commented out becouse it conflicts booting with HaRET.
+# when mtd@misc partition doesn't exists in ROM the above
+# makes ueventd to hang.

# the genlock client device node is world writable/readable.
/dev/genlock 0666 system graphics

as you can see all the job is started from init.rc

here some comments:

"wait /dev/block/mmcblk0p2" is called 4 times because the wait has a timeout of 5 seconds. In this ways we allow up to 20 seconds of waiting for the mmcblk0p2 partition to show up.

e2fsck is now running and you will find the log on the very root of te filesystem tree: /fsck.log.

please note that if the root filesystem is not rw you will mot get the log but the check is performed anyway.

Please remember that root filesystem is in RAM so you cannot find the log if you reboot with recovery.

busybox and e2fsck must be statically linked because at the moment they run there are no shared libraries in /system/lib.

ueventd - It's not true that ueventd is not compatible with HaRET or SD roms. The problem is that if you have in ROM WinMobile6.5 or WP7 you don't have a NAND partition named misc. In this condition the presence of the line:

mtd@misc 0460 radio diag

on ueventd configuration file will causes ueventd to stop running. Being ueventd a critical service Android wont boot.

I think that it is safe to rmove this line on NAND roms too.

I have not much time to support this but I will see what I can do.

attached an initrd.gz for Tytung's "NexusHD2-ICS-4.0.4-CM9-HWA V2.7" NativeSD version

-