clearfog: Add a crude eMMC flashing script
Boot the board via UART with a USB flash disk loaded with
`usb-flash.img`:
./tools/kwboot -b ./u-boot-spl.kwb -t -p /dev/ttyUSB0
usb start; fatload usb 0:1 00800000 boot.scr; source 00800000
Run this from within U-Boot:
mount /dev/sda1 /mnt; sh /mnt/usb-reflash-factory.sh
Don't forget to re-jumper the board for eMMC boot afterwards (00111), do
not leave it in the UART mode (01001).
Change-Id: Iea55c065b2a7e2cf01eed2cbf7cf480d4db85f65
diff --git a/board/czechlight/clearfog/usb-reflash-factory.sh b/board/czechlight/clearfog/usb-reflash-factory.sh
new file mode 100644
index 0000000..aec77c0
--- /dev/null
+++ b/board/czechlight/clearfog/usb-reflash-factory.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+set -ex
+
+mkdir /tmp/sdcard.image
+mount /mnt/sdcard.img.squashfs /tmp/sdcard.image/
+blkdiscard /dev/mmcblk0
+ddrescue --force /tmp/sdcard.image/sdcard.img /dev/mmcblk0
+echo 0 > /sys/block/mmcblk0boot0/force_ro
+ddrescue --force /mnt/u-boot-spl.kwb /dev/mmcblk0boot0
+echo 1 > /sys/block/mmcblk0boot0/force_ro
+echo 0 > /sys/block/mmcblk0boot1/force_ro
+ddrescue --force /mnt/u-boot-spl.kwb /dev/mmcblk0boot1
+echo 1 > /sys/block/mmcblk0boot1/force_ro
+sync
+echo b > /proc/sysrq-trigger