diff options
author | Nicolas Dechesne <nicolas.dechesne@linaro.org> | 2017-06-12 23:39:22 +0200 |
---|---|---|
committer | Nicolas Dechesne <nicolas.dechesne@linaro.org> | 2017-06-12 23:39:22 +0200 |
commit | b59aecdf78797c49e55829d7101abc58379d0a3c (patch) | |
tree | e2ae364c49916aab029ffc956ce93be73ce6e8ce | |
parent | 8ef3754584430c8b72f3e342f4d238cc50450e7a (diff) |
mksdcard: erase partition when no file is to be flashederase-default
Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
-rwxr-xr-x | mksdcard | 28 |
1 files changed, 16 insertions, 12 deletions
@@ -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 |