-
Notifications
You must be signed in to change notification settings - Fork 58
/
config.sh
45 lines (37 loc) · 1.13 KB
/
config.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/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