diff --git a/2_backup_flash.sh b/2_backup_flash.sh index 61aa8fa..f005328 100755 --- a/2_backup_flash.sh +++ b/2_backup_flash.sh @@ -16,10 +16,11 @@ echo "Make sure your Game & Watch is turned on and in the time screen. Press ret read -n 1 mkdir -p backups +mkdir -p logs echo "Attempting to dump flash using adapter $1." echo "Running OpenOCD... (This will take roughly 30 seconds, you Game and Watch screen will blink in between.)" -if ! openocd -f openocd/flash_"$1".cfg >/dev/null 2>&1; then +if ! openocd -f openocd/flash_"$1".cfg >>logs/2_openocd.log 2>&1; then echo "Failed to dump SPI flash from device. Verify debug connection and try again." exit 1 fi diff --git a/3_backup_internal_flash.sh b/3_backup_internal_flash.sh index f0b3a17..28f3475 100755 --- a/3_backup_internal_flash.sh +++ b/3_backup_internal_flash.sh @@ -8,6 +8,7 @@ if [[ $# -ne 1 ]]; then fi ADAPTER=$1 +mkdir -p logs if test -f backups/internal_flash_backup.bin; then echo "Already have a backup in backups/internal_flash_backup.bin, refusing to overwrite." @@ -40,7 +41,7 @@ if ! openocd -f openocd/interface_"$1".cfg \ -c "init;" \ -c "halt;" \ -c "dump_image backups/internal_flash_backup.bin 0x24000000 131072" \ - -c "exit;" >/dev/null 2>&1; then + -c "exit;" >>logs/3_openocd.log 2>&1; then echo "Dumping internal flash failed." exit 1 fi diff --git a/4_unlock_device.sh b/4_unlock_device.sh index 0417439..7b3e400 100755 --- a/4_unlock_device.sh +++ b/4_unlock_device.sh @@ -7,7 +7,7 @@ if [[ $# -ne 1 ]]; then fi ADAPTER=$1 - +mkdir -p logs 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/y)" @@ -28,7 +28,7 @@ echo "Unlocking device... (Takes up to 30 seconds.)" if ! openocd -f openocd/interface_"$1".cfg \ -c "init;" \ -c "halt;" \ - -f openocd/rdp0.cfg >/dev/null 2>&1; then + -f openocd/rdp0.cfg >>logs/4_openocd.log 2>&1; then echo "Unlocking device failed." exit 1 fi diff --git a/5_restore.sh b/5_restore.sh index 88e1584..b8aede9 100755 --- a/5_restore.sh +++ b/5_restore.sh @@ -18,7 +18,7 @@ if ! test -f backups/flash_backup.bin; then fi ADAPTER=$1 - +mkdir -p logs echo "Ok, restoring original firmware! (We will not lock the device, so you won't have to repeat this procedure!)" @@ -27,7 +27,7 @@ if ! openocd -f openocd/interface_"$1".cfg \ -c "init;" \ -c "halt;" \ -c "program backups/internal_flash_backup.bin 0x08000000 verify;" \ - -c "exit;" >/dev/null 2>&1; then + -c "exit;" >>logs/5_openocd.log 2>&1; then echo "Restoring internal flash failed. Check debug connection and try again." exit 1 fi @@ -39,4 +39,5 @@ if ! ./scripts/flashloader.sh $ADAPTER backups/flash_backup.bin; then exit 1 fi -echo "Success, your device should be running the original firmware again!" \ No newline at end of file +echo "Success, your device should be running the original firmware again!" +echo "(You should power-cycle the device now)" \ No newline at end of file diff --git a/scripts/flashloader.sh b/scripts/flashloader.sh index fee8b98..5383a97 100755 --- a/scripts/flashloader.sh +++ b/scripts/flashloader.sh @@ -40,7 +40,7 @@ if ! openocd -f openocd/interface_"$1".cfg \ -c "reg sp [mrw 0x20000000];" \ -c "reg pc [mrw 0x20000004];" \ -c "echo \"Starting flash process\";" \ - -c "resume; exit;" >/dev/null 2>&1; then + -c "resume; exit;" >>logs/flashloader.log 2>&1; then echo "Loading failed." exit 1 fi @@ -48,9 +48,9 @@ fi echo "Loaded flashloader, flashing SPI, please wait." -echo "(If this takes more than 2 minutes something went wrong.)" -echo "(If the screen blinks rapidly, something went wrong.)" -echo "(If the screen blinks slowly, everything worked but the script didn't detect it)" +echo "\t(If this takes more than 2 minutes something went wrong.)" +echo "\t(If the screen blinks rapidly, something went wrong.)" +echo "\t(If the screen blinks slowly, everything worked but the script didn't detect it)" while true; do DONE_MAGIC=$(openocd -f openocd/interface_${1}.cfg -c "init; mdw ${VAR_program_done}" -c "exit;" 2>&1 | grep ${VAR_program_done} | cut -d" " -f2) if [[ "$DONE_MAGIC" == "cafef00d" ]]; then