diff --git a/src/main/scripts/bin/flash.sh b/src/main/scripts/bin/flash.sh index 85aa08bf..89a4a4f4 100644 --- a/src/main/scripts/bin/flash.sh +++ b/src/main/scripts/bin/flash.sh @@ -1,10 +1,10 @@ if [ "$1" == "" ]; then - echo "Usage: flash.sh " + printf "Usage:\nflash.sh \n" return 1 fi if [ "$2" == "" ]; then - echo "Usage: flash.sh " + printf "Usage:\nflash.sh \n" return 1 fi @@ -16,17 +16,29 @@ if [ "$3" == "no" ]; then echo "Flashing without OpenSBI" fi -echo "Proceeding will completely erase $1 and flash the firmware\n $2 to it. This process is irreversible." +printf "Proceeding will completely erase $1 and flash your custom firmware\nto it. This process is irreversible.\n" read -p "Are you sure? " -n 1 -r echo -if [[ $REPLY =~ ^[Yy]$ ]]; then - dd ibs=$(echo "12*1024*1024" | bc) count=1 if=/dev/zero of=$1 - if [ "$3" = "yes" ]; then - dd if=/mnt/builtin/firmware_files/fw_jump.bin of=$1 - dd if=$2 of=$1 seek=2097152 oflag=seek_bytes - else - dd if=$2 of=$1 - fi -fi +case "$REPLY" in + [yY][eE][sS]|[yY]) + printf "Erasing current firmware..." + dd if=$2 of=$1 status=none # Work around for empty flash chips + dd ibs=$(echo "12*1024*1024" | bc) count=1 if=/dev/zero of=$1 status=none + printf " Done\n" + if [ "$3" = "yes" ]; then + printf "Flashing OpenSBI..." + dd if=/mnt/builtin/firmware_files/fw_jump.bin of=$1 status=none + printf " Done\n" + printf "Flashing custom firmware..." + dd if=$2 of=$1 seek=2097152 oflag=seek_bytes status=none + printf " Done\n" + else + printf "Flashing custom firmware..." + dd if=$2 of=$1 status=none + printf " Done\n" + fi + ;; + *) +esac