Files
game-and-watch-backup/config.sh
James Ide 2edf360b9e Add support for CMSIS-DAP debuggers
OpenOCD 0.11.0 and up works with CMSIS-DAP debuggers like the Raspberry Pi Debug Probe/Pico Probe and the Flipper Zero.

The Flipper Zero has an installable DAP Link app (through the companion mobile app) that supports SWD. The pinouts are straightforward: the DAP Link app tells you which GPIO pins are SWDCLK and SWDIO, respectively, and of course GND is GND.

Tested all five steps with OpenOCD 0.12.0 on macOS and Flipper Zero firmware 0.88.0. An example step looks like: `./2_backup_flash.sh cmsis-dap mario`. The G&W plays fine after all steps. Also tested with a Picoprobe.

(Also fixed two typos in the main README that are unrelated to this PR but very small.)
2023-08-31 21:14:44 +02:00

45 lines
1.1 KiB
Bash

#!/bin/bash
OPENOCD=${OPENOCD:-$(which openocd)}
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
helptext() {
echo "Usage: $0 <Adapter: jlink or stlink or rpi or cmsis-dap> <mario or zelda>"
}
OPENOCD_VERSION=$(${OPENOCD} -v 2> >(cut -f 4 -d" " ) |head -1)
ADAPTER=$1
TARGET=$2
if [[ $TARGET == "mario" ]]; then
SPIFLASH_SKIP_16=0
SPIFLASH_COUNT_16=$(( 0xfe000 / 16 ))
FLASH_OFFSET=0
elif [[ $TARGET == "zelda" ]]; then
# 0x0000_0000 - 0x0000_008f volatile area
# 0x0000_1000 - 0x0000_108f volatile area
# 0x0000_2000 - 0x0000_2b1f volatile area
# 0x0000_4000 - 0x0000_4b1f volatile area
# 0x0000_6000 - 0x0000_6b1f volatile area
# 0x0000_8000 - 0x0000_8b1f volatile area
# 0x0002_0000 - 0x0032_549f ROM area
# 0x003e_0000 - 0x0040_0000 volatile area
SPIFLASH_SKIP_16=$(( 0x20000 / 16 ))
SPIFLASH_COUNT_16=$(( (0x3254a0 - 0x20000) / 16 ))
FLASH_OFFSET=$(( 0x30c3a8 ))
else
helptext
exit 1
fi
if [[ $# -ne 2 ]] && [[ ! "$0" =~ .*"config.sh" ]]; then
helptext
exit 1
fi
mkdir -p logs backups