From 75bf195497f8cd25ac95b16a5afad26fe99ccc04 Mon Sep 17 00:00:00 2001 From: Robert Nelson Date: Thu, 5 Jul 2012 16:35:32 -0500 Subject: [PATCH] bug: give up when drive comes up ro Signed-off-by: Robert Nelson --- mk_mmc.sh | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/mk_mmc.sh b/mk_mmc.sh index 0a64cde..c319e96 100755 --- a/mk_mmc.sh +++ b/mk_mmc.sh @@ -990,20 +990,31 @@ function create_custom_netinstall_image { extract_zimage } +function drive_error_ro { + echo "-----------------------------" + echo "Error: for some reason your SD card is not writable..." + echo "Check: is the write protect lever set the locked position?" + echo "Check: do you have another SD card reader?" + echo "-----------------------------" + echo "Script gave up..." + + exit +} + function unmount_all_drive_partitions { - echo "" - echo "Unmounting Partitions" - echo "-----------------------------" + echo "" + echo "Unmounting Partitions" + echo "-----------------------------" - NUM_MOUNTS=$(mount | grep -v none | grep "$MMC" | wc -l) + NUM_MOUNTS=$(mount | grep -v none | grep "$MMC" | wc -l) - for (( c=1; c<=$NUM_MOUNTS; c++ )) - do - DRIVE=$(mount | grep -v none | grep "$MMC" | tail -1 | awk '{print $1}') - umount ${DRIVE} &> /dev/null || true - done + for (( c=1; c<=$NUM_MOUNTS; c++ )) + do + DRIVE=$(mount | grep -v none | grep "$MMC" | tail -1 | awk '{print $1}') + umount ${DRIVE} &> /dev/null || true + done - parted --script ${MMC} mklabel msdos + LC_ALL=C parted --script ${MMC} mklabel msdos | grep "Error:" && drive_error_ro } function uboot_in_boot_partition {