[Samsung Galaxy Mini] Doc_cheilvenerdi.org:
Patched Boot Image "Deep Inside"

As I stated in the previous Post, I skip the Long Explanation of this How to (Italian Threads online anyway) and briefly describe What I did!

1) Split Boot.img

I splitted boot.img into it's two main parts: The Kernel and the Ramdisk.

2) Edit ramdisk

2.1) Strip Samsung Kernel Modules

I figured out that Samsung modules used for rfs filesystem are compiled with all the debug symbols inside, so I stripped them saving more than 3Mb into the ramdisk!

NOTICE: The boot.img must not exceed 8Mb Size or I cannot flash it! BEWARE!

2.2) Add Ext4 kernel Modules

I compiled the jbd2.ko and ext4.ko modules for the attached Kernel and put them into /lib/modules inside the ramdisk:

gandalf $ ls -l ./ramdisk/lib/modules/
totale 1304
-rw-r--r-- 1 root root 236116 11 dic 08.24 [b]ext4.ko[/b]
-rw-r--r-- 1 root root 363932 11 dic 08.24 fsr.ko
-rw-r--r-- 1 root root 211200 11 dic 08.24 fsr_stl.ko
-rw-r--r-- 1 root root 58176 11 dic 08.24 [b]jbd2.ko[/b]
-rw-r--r-- 1 root root 260568 11 dic 08.24 rfs_fat.ko
-rw-r--r-- 1 root root 90968 11 dic 08.24 rfs_glue.ko
-rw-r--r-- 1 root root 99532 11 dic 08.24 sec_param.ko
gandalf $

2.3) Patch init.rc file

I patched the init.rc file into the ramdisk to load these modules into the kernel immediately after the first boot stage of the firmware:

# insmod fsr/rfs modules
insmod /lib/modules/fsr.ko
insmod /lib/modules/fsr_stl.ko
insmod /lib/modules/rfs_glue.ko
insmod /lib/modules/rfs_fat.ko
insmod /lib/modules/sec_param.ko
[color=red]insmod /lib/modules/jbd2.ko[/color]
[color=red]insmod /lib/modules/ext4.ko[/color]

2.4) Add busybox

I added a copy of busybox into /sbin.

I'll need it to mount ext4 filesystems on microSD later on.

gandalf $ ls -l ./ramdisk/sbin/
totale 2088
-rwxr-x--- 1 root root 117948 11 dic 08.18 adbd
-rw[color=red][b]s[/b][/color]r-xr-x 1 root root 2016700 11 dic 08.21 [b]busybox[/b]
lrwxrwxrwx 1 root root 7 11 dic 08.18 ueventd -> ../init
(i686) gandalf ~ (i686) $

2.5) Patch init.rc again

I changed the mount command for /data!

Original code:

# Mounting of system/userdata is moved to 'on emmc' and 'on nand' sections
# We chown/chmod /data again so because mount is run as root + defaults
[color=red][b]mount rfs /dev/stl13 /data nosuid nodev check=no[/b][/color]
chown system system /data
chmod 0771 /data

Patched code:

# Mounting of system/userdata is moved to 'on emmc' and 'on nand' sections
# We chown/chmod /data again so because mount is run as root + defaults
[color=red][b]exec /sbin/busybox sh /init.data.sh[/b][/color]
chown system system /data
chmod 0771 /data

2.6) add init.data.sh file

I added an external shell file, used to mount microsd /data avoiding the Android Init Language used by init.rc.

gandalf $ cat ./ramdisk/init.data.sh
#!/sbin/busybox sh
/sbin/busybox mount -o nosuid,nodev -t ext4 /dev/block/mmcblk0p2 /data || /sbin/busybox mount -o nosuid,nodev -t rfs /dev/stl13 /data
gandalf $

3) Repack ramdisk and kernel into boot.img

I used the AOSP mkbootimg tool to repack alltoghether.

4) Prepare Odin Archive ready for flash

I created a PDA Archive with only boot.img inside.

A command sequence could be, for example:

tar -H ustar -c boot.img > CODE_S5570XWKS7_boot.tar
md5sum CODE_S5570XWKS7_boot.tar >> CODE_S5570XWKS7_boot.tar
mv CODE_S5570XWKS7_boot.tar CODE_S5570XWKS7_boot.tar.md5

That's All!

Enjoy!