Skip to content

Commit 3608b8c

Browse files
committed
Add tools files for debugging
- Add debug-dap.sh to spawn OpenOCD process & gdb-multiarch process for debugging. Requires MaximSDK install & path settings inside this script. Also depends on gdb-multiarch and connected CMSIS-DAP probe over USB. - debug-dap.gdb simply holds the gdb commands for this script + small style fix on common-hal/microcontroller/Pin.c
1 parent 3ce7bdd commit 3608b8c

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

ports/analog/common-hal/microcontroller/Pin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void reset_all_pins(void) {
3737
}
3838

3939
void reset_pin_number(uint8_t pin_port, uint8_t pin_pad) {
40-
if (pin_port == INVALID_PIN || pin_port > NUM_GPIO_PORTS) {
40+
if ( (pin_port == INVALID_PIN) || (pin_port > NUM_GPIO_PORTS) ) {
4141
return;
4242
}
4343

ports/analog/tools/debug-dap.gdb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
target remote :3333
2+
break main
3+
continue

ports/analog/tools/debug-dap.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
# Primer on taking cmd line args in Linux shell scripts
4+
# $0 is the script itself
5+
# $1 $2 $3 are arg1, arg2, arg3, etc
6+
7+
# Export OCD Path
8+
### USER ACTION: Replace with your path to OpenOCD ###
9+
OCD_PATH="~/MaximSDK/Tools/OpenOCD"
10+
11+
# Call openocd to setup the debug server, storing the PID for OpenOCD
12+
sh -c "openocd -s $OCD_PATH/scripts -f interface/cmsis-dap.cfg -f target/$1.cfg -c \"init; reset halt\" " &
13+
14+
# Allow enough time for OCD server to set up
15+
# + wait for the sleep to finish
16+
sleep 3 &
17+
wait $!
18+
19+
# spawn the gdb process and store the gdb_pid
20+
gdb-multiarch build-apard32690/firmware.elf -x "tools/debug-dap.gdb"
21+
22+
# when gdb exits, kill all openocd processes
23+
killall openocd

0 commit comments

Comments
 (0)