Add logs for commands

This commit is contained in:
Thomas Roth 2020-11-29 12:31:12 +01:00
parent d2a7abb9bc
commit 59436a2251
5 changed files with 14 additions and 11 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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!"
echo "Success, your device should be running the original firmware again!"
echo "(You should power-cycle the device now)"

View File

@ -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