blob: 120a72a8f4ecf2821324c6a8f7bac4b497fceffb (
plain)
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
46
47
48
|
#!/bin/bash
set -e
set -o pipefail
unset elf
unset hex
unset cfg
unset openocd
unset jlink
unset gdb
while [[ "$1" != "" ]]
do
case "$1"
in
--elf) elf="$2"; shift 2;;
--bin) bin="$2"; shift 2;;
--addr) addr="$2"; shift 2;;
--openocd) openocd="$2"; shift 2;;
--openocd-config) cfg="$2"; shift 2;;
--jlink) jlink="$2"; shift 2;;
--gdb) gdb="$2"; shift 2;;
*) echo "$0: Unknown argument $1"; exit 1;;
esac
done
if [ "$elf" == "" -a "$bin" == "" ]
then
echo "$0: --elf or --bin is required" >&2
exit 1
fi
export GDB_PORT=3333
if [ "$jlink" != "" ]
then
echo -e "loadfile $bin $addr\nrnh\nexit" | $jlink -device FE310 -if JTAG -speed 4000 -jtagconf -1,-1 -autoconnect 1
else
$openocd -f $cfg &
$gdb $elf --batch -ex "set remotetimeout 240" -ex "target extended-remote localhost:${GDB_PORT}" -ex "monitor reset halt" -ex "monitor flash protect 0 64 last off" -ex "load" -ex "monitor resume" -ex "monitor shutdown" -ex "quit"
kill %1
fi
|