Final flash.sh fix

This commit is contained in:
Jackson Abney
2023-05-17 14:08:45 -08:00
parent 443bc1c208
commit 1fc3d610bb

View File

@@ -1,10 +1,10 @@
if [ "$1" == "" ]; then
echo "Usage: flash.sh <path to device to flash> <path to firmware file> <use Open SBI (yes/no default: no)>"
printf "Usage:\nflash.sh <path to flash mem> <path to firmware> <OpenSBI (yes/no default: no)>\n"
return 1
fi
if [ "$2" == "" ]; then
echo "Usage: flash.sh <path to device to flash> <path to firmware file> <use Open SBI (yes/no default: no)>"
printf "Usage:\nflash.sh <path to flash mem> <path to firmware> <OpenSBI (yes/no default: no)>\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