Final requirement to use a flag to enable auto reset, also explain in readme file.
This commit is contained in:
parent
af4b609036
commit
3b38fff056
28
5_restore.sh
28
5_restore.sh
|
@ -2,6 +2,14 @@
|
||||||
|
|
||||||
source config.sh $1
|
source config.sh $1
|
||||||
|
|
||||||
|
autoReset=false
|
||||||
|
|
||||||
|
option=$2
|
||||||
|
|
||||||
|
if option=="-r" || "-reset"; then
|
||||||
|
autoReset=true
|
||||||
|
fi
|
||||||
|
|
||||||
if ! test -f backups/internal_flash_backup.bin; then
|
if ! test -f backups/internal_flash_backup.bin; then
|
||||||
echo "No backup of internal flash found in backups/internal_flash_backup.bin"
|
echo "No backup of internal flash found in backups/internal_flash_backup.bin"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -32,22 +40,18 @@ if ! ./scripts/flashloader.sh $ADAPTER backups/flash_backup.bin; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Restart device. Continue? (y/N)"
|
if $autoReset; then
|
||||||
read -n 1 -r
|
echo "Restarting device..."
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
if ! ${OPENOCD} -f openocd/interface_"${ADAPTER}".cfg \
|
||||||
then
|
|
||||||
echo "Success, your device should be running the original firmware again!"
|
|
||||||
echo "(You should power-cycle the device now)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Restarting device..."
|
|
||||||
if ! ${OPENOCD} -f openocd/interface_"${ADAPTER}".cfg \
|
|
||||||
-c "init;" \
|
-c "init;" \
|
||||||
-c "reset run;" \
|
-c "reset run;" \
|
||||||
-c "exit;" >>logs/5_openocd-2.log 2>&1; then
|
-c "exit;" >>logs/5_openocd-2.log 2>&1; then
|
||||||
echo "Reseting failed. Check debug connection and try again."
|
echo "Reseting failed. Check debug connection and try again."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Success, your device should be running the original firmware again!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Success, your device should be running the original firmware again!"
|
echo "Success, your device should be running the original firmware again!"
|
||||||
|
echo "(You should power-cycle the device now)"
|
||||||
|
|
|
@ -85,7 +85,7 @@ The scripts are split into 5 parts:
|
||||||
- 2_backup_flash.sh - Backs up the contents of the SPI flash. Does not modify device contents.
|
- 2_backup_flash.sh - Backs up the contents of the SPI flash. Does not modify device contents.
|
||||||
- 3_backup_internal_flash.sh - Backs up the internal flash. To do this the contents of the SPI flash are modified. Your device will stop working until it's restored in step 5.
|
- 3_backup_internal_flash.sh - Backs up the internal flash. To do this the contents of the SPI flash are modified. Your device will stop working until it's restored in step 5.
|
||||||
- 4_unlock_device.sh - This will disable the active read protection. This will erase the internal flash of the STM32.
|
- 4_unlock_device.sh - This will disable the active read protection. This will erase the internal flash of the STM32.
|
||||||
- 5_restore.sh - This will restore the original firmware.
|
- 5_restore.sh - This will restore the original firmware. You can use the -r flag after the debugger option to auto reset the device (note, your debugger must have the reset line connected to the SWD, otherwise you must power cycle the device).
|
||||||
|
|
||||||
Just run these scripts *from the checked out directory* one after each other. All scripts are safe to be re-run in case of error.
|
Just run these scripts *from the checked out directory* one after each other. All scripts are safe to be re-run in case of error.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue