Did anyone test the I/O speed for the card?
I can confirm your findings with my Transcend card:
# cd /mnt/sd
# ./busybox time ./busybox dd if=/dev/zero of=zero bs=4M count=10
10+0 records in
10+0 records out
real 0m 33.39s
user 0m 0.00s
sys 0m 6.33s
# ./busybox time ./busybox dd if=zero of=/dev/null
81920+0 records in
81920+0 records out
real 0m 17.77s
user 0m 0.55s
sys 0m 5.07s
That's 1.26 MB/s write, 2.36 MB/s read. Either the SDHC driver is poorly coded (we can't know until they release the source), or there's a limitation in the "switch" that prioritises the external host. I can only guess.
I've been looking over their modifications to the Busybox source, trying to figure out how files are synchronized between the two systems. Let me share what I've learned:
/etc/init.d/rcS calls /usr/bin/kcard_app.sh which forks the kcard_app Busybox applet during startup
kcard_app registers a SIGUSR1 handler and gives its PID to the SDHC driver by sending an ioctl to /dev/ka-main
When the SIGUSR1 handler is triggered by the driver, it requests a command from /dev/ka-main using another ioctl
The kcard_* applets then do a lot of extraneous stuff (checking for control images) using hardcoded system calls (yuck!) and remount /mnt/sd a few times
I wrote a wrapper for the ioctl syscall so I could interact with /dev/ka-main from a shell script (source below). Here's a compiled version for those who don't have a cross-compiler set up. I'm not great at C, so please don't laugh at me too hard. Just drop it in /sbin.
I then wrote a shell script to perform the minimum necessary functions of the kcard_* applets, namely remounting /mnt/sd when instructed by the SDHC driver. There are a bunch of undocumented ioctls I found in their Busybox source too. Save it as /usr/bin/kcard_handler.
Finally, I wrote a new rcS by tracing through the existing one, removing extraneous crap (logging, wifi, http) and re-ordering parts, shaving the boot time down to 6.5 seconds. This script forks my custom kcard_handler if it exists.
The source code for all of the above can be found here: https://gist.github.com/anonymous/6787023.
For the super-lazy, an initramfs.gz with my changes applied can be found here. You'll have to start wifi/telnetd from autorun.sh if you haven't soldered a serial cable to the card.
From testing with my camera and computer, the SDHC driver appears to only care about updates to the DCIM folder, not the entire filesystem, partition or block device. Writing to the card with my computer makes it choke on failed reads when remounting, so I may be doing something wrong.
This is all the progress I think I can make until Transcend/KeyASIC decides to release the source for /lib/ka2000-sdhc.ko.
Hopefully this ends up helping people, especially the guy working on a builtroot config to replace the initramfs. I look forward to viewing your progress!
Now, I have some questions of my own:
Has anyone had success using fakeroot as a normal user to unpack/repack the initramfs?
Does anyone feel brave enough to start fuzzing for new ioctls? Both /dev/ka-pwm and /dev/ka-pwm1 are undocumented.
(Last edited by kcard on 2 Oct 2013, 03:19)