-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug_swd.sh
executable file
·48 lines (40 loc) · 1.54 KB
/
debug_swd.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
46
47
48
#!/bin/bash
# ----------------------------------------------------------------------------
# Copyright (c) 2023 Thomas Buck ([email protected])
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# See <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------------
set -euo pipefail
cd "$(dirname "$0")"
echo Starting OpenOCD in background
echo "\n\nstarting new openocd" >> openocd.log
./build_debug/openocd/src/openocd -s build_debug/openocd/tcl -f interface/cmsis-dap.cfg -f target/rp2040.cfg -c "adapter speed 5000" -c "cmsis_dap_vid_pid 0x2e8a 0x000c" >> openocd.log 2>&1 &
OPENOCD_PID=$!
# give OpenOCD some time to output stuff
sleep 1
echo -n Waiting for debugger to appear
while ! netstat -tna | grep 'LISTEN\>' | grep -q ':3333\>'; do
echo -n .
sleep 1
done
echo Starting GDB
arm-none-eabi-gdb \
-ex "set history save" \
-ex "show print pretty" \
-ex "target extended-remote localhost:3333" \
-ex "tui new-layout default src 1 status 1 cmd 2" \
-ex "tui layout default" \
-ex "tui enable" \
$1
echo Killing OpenOCD instance in background
kill $OPENOCD_PID