Added support for large SPI flashes when restoring.
Added a device reset upon restore success. Updated README.md to reflect the changes.
This commit is contained in:
parent
c1bddaf86f
commit
64cd24396d
13
5_restore.sh
13
5_restore.sh
|
@ -23,22 +23,29 @@ fi
|
|||
|
||||
echo "Ok, restoring original firmware! (We will not lock the device, so you won't have to repeat this procedure!)"
|
||||
|
||||
echo "Restoring SPI flash..."
|
||||
if [[ $LARGE_FLASH == "1" ]]; then
|
||||
echo "Restoring large SPI flash (no verify)..."
|
||||
# verify is broken on large flashes
|
||||
VERIFY_CMD=""
|
||||
else
|
||||
echo "Restoring SPI flash..."
|
||||
VERIFY_CMD="verify"
|
||||
fi
|
||||
if ! ${OPENOCD} -f "openocd/target_${TARGET}.cfg" -f "openocd/interface_${ADAPTER}.cfg" \
|
||||
-c "init;" \
|
||||
-c "halt;" \
|
||||
-c "program backups/flash_backup_${TARGET}.bin 0x90000000 verify;" \
|
||||
-c "program backups/flash_backup_${TARGET}.bin 0x90000000 ${VERIFY_CMD};" \
|
||||
-c "exit;" >>logs/5_openocd.log 2>&1; then
|
||||
echo "Restoring SPI flash failed. Check debug connection and try again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
echo "Restoring internal flash..."
|
||||
if ! ${OPENOCD} -f "openocd/target_${TARGET}.cfg" -f "openocd/interface_${ADAPTER}.cfg" \
|
||||
-c "init;" \
|
||||
-c "halt;" \
|
||||
-c "program backups/internal_flash_backup_${TARGET}.bin 0x08000000 verify;" \
|
||||
-c "reset;" \
|
||||
-c "exit;" >>logs/5_openocd.log 2>&1; then
|
||||
echo "Restoring internal flash failed. Check debug connection and try again."
|
||||
exit 1
|
||||
|
|
|
@ -127,6 +127,12 @@ Step 4 will cause a mass erase, and leave your device empty. To restore it, run
|
|||
|
||||
Step 5 should succeed, if it doesn't: Try to run the script while holding down the power button of the Game & Watch. Try power-cycling the target in between attempts.
|
||||
|
||||
If you replaced the SPI flash with a bigger size then also try :
|
||||
|
||||
```
|
||||
LARGE_FLASH=1 ./5_restore.sh <stlink or jlink or rpi> <mario or zelda>
|
||||
```
|
||||
|
||||
### Getting help and contributing
|
||||
|
||||
Feel free to join our [discord channel](https://discord.gg/rE2nHVAKvn) and ask any support questions in *#game-and-watch-support*.
|
||||
|
|
|
@ -63,8 +63,14 @@ proc hxa-001_qspi_init { } {
|
|||
sleep 20 ;# wait for the flash to come out of reset
|
||||
|
||||
mmw 0x52005000 0x30000000 0x00000001 ;# OCTOSPI_CR |= FMODE=0x3, &= ~EN
|
||||
|
||||
if { [env LARGE_FLASH] == 0 } {
|
||||
# OCTOSPI1: memory-mapped 1-line read mode with 3-byte addresses
|
||||
mww 0x52005100 0x01002101 ;# OCTOSPI_CCR: DMODE=0x1, ABMODE=0x0, ADSIZE=0x2, ADMODE=0x1, ISIZE=0x0, IMODE=0x1
|
||||
} else {
|
||||
# OCTOSPI1: memory-mapped 1-line read mode with 4-byte addresses
|
||||
mww 0x52005100 0x01003101 ;# OCTOSPI_CCR: DMODE=0x1, ABMODE=0x0, ADSIZE=0x3, ADMODE=0x1, ISIZE=0x0, IMODE=0x1
|
||||
}
|
||||
mww 0x52005110 0x00000003 ;# OCTOSPI_IR: INSTR=READ
|
||||
mmw 0x52005000 0x00000001 0x00000000 ;# OCTOSPI_CR |= EN
|
||||
|
||||
|
|
Loading…
Reference in New Issue