clearfog: flashing: move related operations together
This ensures that we sync (etc) while the target partitions are still
writable, etc.
Change-Id: I9605ec3378f8b130ce5ae1962e3ccaee41233daa
diff --git a/board/czechlight/clearfog/usb-reflash-factory.sh b/board/czechlight/clearfog/usb-reflash-factory.sh
index 388ff68..7e5feef 100644
--- a/board/czechlight/clearfog/usb-reflash-factory.sh
+++ b/board/czechlight/clearfog/usb-reflash-factory.sh
@@ -6,15 +6,20 @@
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
+echo 0 > /sys/block/mmcblk0boot1/force_ro
+
+ddrescue --force /mnt/u-boot-spl.kwb /dev/mmcblk0boot0
+ddrescue --force /mnt/u-boot-spl.kwb /dev/mmcblk0boot1
+
fsck -y /dev/mmcblk0p1 || true
fsck -y /dev/mmcblk0p2 || true
fsck -y /dev/mmcblk0p3 || true
fsck -y /dev/mmcblk0p4 || true
-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 1 > /sys/block/mmcblk0boot1/force_ro
+echo 1 > /sys/block/mmcblk0boot0/force_ro
+
echo b > /proc/sysrq-trigger