The mele flash kitchen_v2 contains scripts to generate the sdcard version, look here:
Mele A2000: my own Linux flash kitchen
Testing new firmwares could be a pain since everything is wiped out at each update.
My idea (an I see some people had the same idea before) is to write the Android partitions on sdcard and boot from it.
There are already Linux distributions that boot from SDCard, like ArchLinux:
http://archlinuxarm.org/platforms/armv7/mele-a100
I have taken this Linux distribution as the base system.
The principle is quite easy: take a SDCard u-boot, give it the Android kernel, create the Android partitions on SDCard, fill them to make Android happy, change all "nandx" references by "mmcblk0px" in init scripts.
The Android system boots and does not need any access to NAND, a good point since I can test firmwares without affecting my flashed one.
Partitioning
Under linux, I have partitioned the SDCard (SDHC class 10, for boot speed) with fdisk.Here is the resulting partitions:
Note that a free space of 16MB is kept at start of sdcard, it embeds the spl bootloader
I put 4GB for "data" and 10GB for /sdcard (16GB SDCard gives lot of space).
Exact size doesn't matter; if you set to 15,95MB one partition, that's not a big issue. The important thing is the number of partitions, see below.
So the matching nand-sdcard partitions are:
-nand- -sdcard- -name- -format-
nanda mmcblk0p1 bootloader vfat
nandb -N/A- env
nandc mmcblk0p2 boot ext4
nandd mmcblk0p3 system ext4
nande mmcblk0p5 data ext4
nandf mmcblk0p6 misc ext4
nandg -N/A- recovery
nandh mmcblk0p7 cache ext4
nandi mmcblk0p8 private vfat
nandj -N/A- sysrecovery
nandk mmcblk0p9 UDISK vfat
Note: I just found out that link: http://linux-sunxi.org/Android/partitions
Almost same thing...
Note(2): under linux, mmcblk0p1 is /dev/sdb1, mmcblk0p2 is /dev/sdb2, ...
Filling partitions
Then I formatted partitions using mkfs.vfat for FAT partitions, and mkfs.ext4 for ext4 partitions that need to be formatted (look at the above table for the ones that need to be formatted, the others will be formatted by Android).
Then, from ArchlinuxARM/Mele-Bootloader I did:
# write SPL
dd if=sun4i-spl.bin of=$DRIVE bs=1024 seek=8
# write mele u-boot
dd if=mele-u-boot.bin of=$DRIVE bs=1024 seek=32
where DRIVE is /dev/sdb is sdcard is on sdb.
In the bootloader partition, I put the Mele's script.bin, and the Mele's kernel (the 3.0.8+ one), transformed into a u-boot image using this:
mkimage -A ARM -C none -T kernel -O linux -a 40008000 -e 40008000 -d zImage uImage
I added uEnv.txt:
boot_mmc=fatload mmc 0 0x43000000 ${fexfile}; fatload mmc 0 0x48000000 ${kernel}; bootm 0x48000000
extraargs=rootwait init=/init mac_addr=00:BA:D0:MA:C0:FF
fexfile=script.bin
The "boot" partition contains the initrd contents of root.fex, and must be in mmcblk0p2 (default root partition of the spl u-boot, you can change it with root=xxx in extraargs variable)
The "system" partitions contents the files of the /system partition (system.fex mounted partition)
That's all.
Changing init scripts
In "boot" partition, you need to edit init.sun4i.rc and uevent.sun4i.rc, to change all "nandX" references into "mmcblk0pN" references conforming to the above table.
grep -r nand * shows you all the files that need to be modified.
In the same manner, change /system:
bin/sop.sh
bin/preinstall.sh
bin/data_resume.sh
etc/vold.fstab
The proof
Here is the mount table from my functional system:
root@android:/ # busybox mount
rootfs on / type rootfs (rw)
/dev/root on / type ext4 (ro,relatime,user_xattr,barrier=1,data=ordered)
devtmpfs on /dev type devtmpfs (rw,relatime,size=156796k,nr_inodes=39199,mode=755)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,mode=755)
devpts on /dev/pts type devpts (rw,relatime,mode=600,ptmxmode=000)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
tmpfs on /mnt type tmpfs (rw,relatime,mode=777,gid=1000)
tmpfs on /mnt/asec type tmpfs (rw,relatime,mode=755,gid=1000)
tmpfs on /mnt/obb type tmpfs (rw,relatime,mode=755,gid=1000)
/dev/block/mmcblk0p3 on /system type ext4 (ro,relatime,user_xattr,barrier=0,data=ordered)
/dev/block/mmcblk0p5 on /data type ext4 (rw,nosuid,nodev,noatime,user_xattr,barrier=0,journal_checksum,data=ordered,noauto_da_alloc)
/dev/block/mmcblk0p7 on /cache type ext4 (rw,nosuid,nodev,noatime,user_xattr,barrier=0,journal_checksum,data=ordered,noauto_da_alloc
)
/dev/block/mmcblk0p8 on /mnt/private type vfat (rw,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=ascii,sh
ortname=mixed,errors=remount-ro)
/dev/block/vold/179:1 on /mnt/extsd/179_1 type vfat (rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1023,fmask=0702,dmask=0702
,allow_utime=0020,codepage=cp437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)
/dev/block/vold/179:6 on /mnt/extsd/179_6 type vfat (rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1023,fmask=0702,dmask=0702
,allow_utime=0020,codepage=cp437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)
/dev/block/vold/179:8 on /mnt/extsd/179_8 type vfat (rw,nosuid,nodev,noexec,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage
=cp437,iocharset=ascii,shortname=mixed,errors=remount-ro)
/dev/block/vold/179:9 on /mnt/extsd/179_9 type vfat (rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1023,fmask=0702,dmask=0702
,allow_utime=0020,codepage=cp437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)