game-and-watch-backup/4_unlock_device.sh

34 lines
1.0 KiB
Bash
Raw Permalink Normal View History

2020-11-29 10:58:55 +00:00
#!/bin/bash
2021-11-14 14:06:48 +00:00
source config.sh $@
2020-11-29 10:58:55 +00:00
echo "Unlocking your device will erase its internal flash. Even though your backup"
echo "is validated, this still can go wrong. Are you sure? (y/N)"
2020-11-29 10:58:55 +00:00
read -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "Aborted."
exit 1
fi
echo "Validating internal flash backup before proceeding..."
2021-11-14 14:06:48 +00:00
if ! shasum --check shasums/internal_flash_backup_${TARGET}.bin.sha1 >/dev/null 2>&1; then
2020-11-29 10:58:55 +00:00
echo "Backup is not valid. Aborting."
exit 1
fi
echo "Unlocking device... (Takes up to 30 seconds.)"
2021-11-14 14:06:48 +00:00
if ! ${OPENOCD} -f "openocd/interface_${ADAPTER}.cfg" \
2020-11-29 10:58:55 +00:00
-c "init;" \
-c "halt;" \
2020-11-29 11:31:12 +00:00
-f openocd/rdp0.cfg >>logs/4_openocd.log 2>&1; then
2020-11-29 10:58:55 +00:00
echo "Unlocking device failed."
exit 1
fi
echo "Congratulations, your device has been unlocked. Just a few more steps!"
echo "- The Game & Watch will not yet be functional"
echo "- Disconnect power from the device for the changes to take full effect"
echo "- Power it again"
echo "- Run the 5_restore.sh script to restore the SPI and Internal Flash."