new: [config] Added config.sh file
This commit is contained in:
parent
5304a154ba
commit
62d81e943d
|
@ -1,11 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
source config.sh placeHolder
|
||||
|
||||
echo "Running sanity checks..."
|
||||
if ! openocd -v >/dev/null 2>&1; then
|
||||
if ! ${OPENOCD} -v >/dev/null 2>&1; then
|
||||
echo "OpenOCD does not seem to be working. Please validate that you have it installed correctly!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "${OPENOCD_VERSION}" == "0.10.0" ]]; then
|
||||
echo "You seem to be using a vanilla version of openocd."
|
||||
echo "In case you see the following error: "
|
||||
echo " openocd/interface_stlink.cfg:1: Error: Can't find interface/stlink.cfg"
|
||||
echo "Update your openocd version."
|
||||
fi
|
||||
|
||||
if ! /usr/bin/env python3 -V >/dev/null 2>&1; then
|
||||
echo "Could not run python3. Please validate that you have it installed correctly!"
|
||||
exit 1
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
source config.sh $1
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Usage: backup_flash.sh <Adapter: jlink or stlink>"
|
||||
exit 1
|
||||
|
@ -10,17 +12,12 @@ if test -f backups/flash_backup.bin; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
ADAPTER=$1
|
||||
|
||||
echo "Make sure your Game & Watch is turned on and in the time screen. Press return when ready!"
|
||||
read -n 1
|
||||
|
||||
mkdir -p backups
|
||||
mkdir -p logs
|
||||
|
||||
echo "Attempting to dump flash using adapter $1."
|
||||
echo "Attempting to dump flash using adapter ${ADAPTER}."
|
||||
echo "Running OpenOCD... (This will take roughly 30 seconds, your Game and Watch screen will blink in between.)"
|
||||
if ! openocd -f openocd/flash_"$1".cfg >>logs/2_openocd.log 2>&1; then
|
||||
if ! ${OPENOCD} -f openocd/flash_"${ADAPTER}".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
|
||||
|
|
|
@ -2,13 +2,7 @@
|
|||
|
||||
set -e
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Usage: $0 <Adapter: jlink or stlink>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ADAPTER=$1
|
||||
mkdir -p logs
|
||||
source config.sh $1
|
||||
|
||||
if test -f backups/internal_flash_backup.bin; then
|
||||
echo "Already have a backup in backups/internal_flash_backup.bin, refusing to overwrite."
|
||||
|
@ -48,7 +42,7 @@ echo "- Press return (while still holding the power button)!"
|
|||
read -n 1
|
||||
|
||||
echo "Dumping internal flash..."
|
||||
if ! openocd -f openocd/interface_"$1".cfg \
|
||||
if ! ${OPENOCD} -f openocd/interface_"${ADAPTER}".cfg \
|
||||
-c "init;" \
|
||||
-c "halt;" \
|
||||
-c "dump_image backups/internal_flash_backup.bin 0x24000000 131072" \
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Usage: $0 <Adapter: jlink or stlink>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ADAPTER=$1
|
||||
mkdir -p logs
|
||||
source config.sh $1
|
||||
|
||||
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)"
|
||||
|
@ -25,7 +18,7 @@ if ! shasum --check shasums/internal_flash_backup.bin.sha1 >/dev/null 2>&1; then
|
|||
fi
|
||||
|
||||
echo "Unlocking device... (Takes up to 30 seconds.)"
|
||||
if ! openocd -f openocd/interface_"$1".cfg \
|
||||
if ! ${OPENOCD} -f openocd/interface_"${ADAPTER}".cfg \
|
||||
-c "init;" \
|
||||
-c "halt;" \
|
||||
-f openocd/rdp0.cfg >>logs/4_openocd.log 2>&1; then
|
||||
|
|
11
5_restore.sh
11
5_restore.sh
|
@ -1,11 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Usage: $0 <Adapter: jlink or stlink>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source config.sh $1
|
||||
|
||||
if ! test -f backups/internal_flash_backup.bin; then
|
||||
echo "No backup of internal flash found in backups/internal_flash_backup.bin"
|
||||
|
@ -17,13 +12,11 @@ if ! test -f backups/flash_backup.bin; then
|
|||
exit 1
|
||||
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!)"
|
||||
|
||||
|
||||
echo "Restoring internal flash..."
|
||||
if ! openocd -f openocd/interface_"$1".cfg \
|
||||
if ! ${OPENOCD} -f openocd/interface_"${ADAPTER}".cfg \
|
||||
-c "init;" \
|
||||
-c "halt;" \
|
||||
-c "program backups/internal_flash_backup.bin 0x08000000 verify;" \
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
OPENOCD=${OPENOCD:-$(which openocd)}
|
||||
OPENOCD_VERSION=$(openocd -v 2> >(cut -f 4 -d\ ) |head -1)
|
||||
ADAPTER=$1
|
||||
|
||||
|
||||
mkdir -p logs backups
|
||||
|
||||
if [[ $# -ne 1 ]] && [[ ! "$0" =~ .*"config.sh" ]]; then
|
||||
echo "Usage: $0 <Adapter: jlink or stlink>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z ${OPENOCD} ]]; then
|
||||
echo "Cannot find 'openocd' in the PATH. You can set the environment variable 'OPENOCD' to manually specify the location"
|
||||
exit 2
|
||||
fi
|
|
@ -1,17 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Usage: $0 <Adapter: jlink or stlink>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ADAPTER=$1
|
||||
mkdir -p logs
|
||||
|
||||
source config.sh $1
|
||||
|
||||
echo "Installing on internal flash..."
|
||||
if ! openocd -f openocd/interface_"$1".cfg \
|
||||
if ! ${OPENOCD} -f openocd/interface_"${ADAPTER}".cfg \
|
||||
-c "init;" \
|
||||
-c "halt;" \
|
||||
-c "program prebuilt/gw_retrogo_nes.elf;" \
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
source config.sh $1
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
ELF=firmware/flash_programmer.elf
|
||||
ADDRESS=0
|
||||
|
@ -23,7 +25,7 @@ VAR_program_done=$(printf '0x%08x\n' $(get_symbol "program_done"))
|
|||
VAR_program_erase=$(printf '0x%08x\n' $(get_symbol "program_erase"))
|
||||
|
||||
|
||||
if ! openocd -f openocd/interface_"$1".cfg \
|
||||
if ! ${OPENOCD} -f openocd/interface_"${ADAPTER}".cfg \
|
||||
-c "init;" \
|
||||
-c "echo \"Resetting device\";" \
|
||||
-c "echo \"Programming ELF\";" \
|
||||
|
@ -51,7 +53,7 @@ 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)"
|
||||
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)
|
||||
DONE_MAGIC=$(${OPENOCD} -f openocd/interface_${ADAPTER}.cfg -c "init; mdw ${VAR_program_done}" -c "exit;" 2>&1 | grep ${VAR_program_done} | cut -d" " -f2)
|
||||
if [[ "$DONE_MAGIC" == "cafef00d" ]]; then
|
||||
echo "Done!"
|
||||
break;
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Usage: $0 <Adapter: jlink or stlink>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ADAPTER=$1
|
||||
mkdir -p logs
|
||||
source config.sh $1
|
||||
|
||||
echo "This will look your device! Are you sure? (Y/y)"
|
||||
read -n 1 -r
|
||||
|
@ -24,7 +17,7 @@ if ! shasum --check shasums/internal_flash_backup.bin.sha1 >/dev/null 2>&1; then
|
|||
fi
|
||||
|
||||
echo "Locking device... (Takes up to 30 seconds.)"
|
||||
if ! openocd -f openocd/interface_"$1".cfg \
|
||||
if ! ${OPENOCD} -f openocd/interface_"${ADAPTER}".cfg \
|
||||
-c "init;" \
|
||||
-c "halt;" \
|
||||
-f openocd/rdp1.cfg >>logs/rdp1_openocd.log 2>&1; then
|
||||
|
|
Loading…
Reference in New Issue