summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Dechesne <nicolas.dechesne@linaro.org>2017-06-12 23:39:22 +0200
committerNicolas Dechesne <nicolas.dechesne@linaro.org>2017-06-12 23:39:22 +0200
commitb59aecdf78797c49e55829d7101abc58379d0a3c (patch)
treee2ae364c49916aab029ffc956ce93be73ce6e8ce
parent8ef3754584430c8b72f3e342f4d238cc50450e7a (diff)
mksdcard: erase partition when no file is to be flashederase-default
Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
-rwxr-xr-xmksdcard28
1 files changed, 16 insertions, 12 deletions
diff --git a/mksdcard b/mksdcard
index 440ee6f..a4e2cb9 100755
--- a/mksdcard
+++ b/mksdcard
@@ -235,20 +235,24 @@ while IFS=, read part start end name size align type format file; do
# create partition only, do not write file
if [ "$PARTONLY" = "1" ] ; then continue; fi
- # no file to write
- if [ -z "$file" ] ; then continue; fi
-
# push the blob
DPATH=$(losetup --show -f $IMG -o $(($start * 512)) --sizelimit $(( ($end-$start+1) * 512)))
- echo "=== Writing $file to $name: ${DPATH} ... "
- case "$format" in
- fastboot)
- simg2img $file ${DPATH}
- ;;
- *)
- dd if=$file of=${DPATH}
- ;;
- esac
+
+ # no file to write
+ if [ -z "$file" ] ; then
+ echo "=== Erasing $name: ${DPATH} ... "
+ dd if=/dev/zero of=${DPATH} count=$size bs=1024
+ else
+ echo "=== Writing $file to $name: ${DPATH} ... "
+ case "$format" in
+ fastboot)
+ simg2img $file ${DPATH}
+ ;;
+ *)
+ dd if=$file of=${DPATH}
+ ;;
+ esac
+ fi
losetup -d ${DPATH}
done < $gpt