Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed bmp gdb init #4521

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions platformio/debug/config/blackmagic.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Blackmagic Probe improvements

I needed SRST under reset feature, this command has to be issued before scan, but this is currently impossible with current variables.

By changing the gdb init a bit this or even target power is possible

See: "Embedded Debugging with the Black Magic Probe", pp. 28

```
upload_protocol = blackmagic
upload_port = /dev/ttyBmpGdb
debug_tool = blackmagic
debug_port = ${this.upload_port} connect_srst
monitor_port = /dev/ttyBmpTarg
monitor_speed = 115200

```

debug_port = port [monitor_cmd]

debug_port can be /dev/ttyACM0 (/dev/ttyBmpGdb if you use the udev rules) or a Windows COM port, I use `${this.upload_port}` to use the same.
Copy link

@dragonmux dragonmux Jan 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nitpick, /dev/ttyACM0 is unreliable in name - the kernel gives us no guarantees that it didn't bring BMP up as some other name instead, hence the project udev rules. Second note, if a user wishes to connect to a specific BMP by serial number, they can update their udev rules and use /dev/ttyBmpGdb<serial>. The udev rules and serial number stuff is stable through releases


An optional param can be used to enable eg:

- tpwr (Target Power)
- connect_srst (Assert SRST during connect)

Currently it's not possibe to enable both, but this can easily be changed (iterate over args)
29 changes: 17 additions & 12 deletions platformio/debug/config/blackmagic.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,25 @@
class BlackmagicDebugConfig(DebugConfigBase):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20


GDB_INIT_SCRIPT = """
define bmconnect
target extended-remote $arg0
set $i = 1
while $i < $argc
eval "monitor $arg%d enable", $i
set $i = $i + 1
end
monitor swdp_scan

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we would suggest using the short name here (mon swd) as this might change through releases. Also, on a new enough BMP (v1.8 firmware or newer), mon auto allows what we've named "auto scan" which tries first JTAG and then SWD which opens this up to more targets.

attach 1
end

define pio_reset_halt_target
set language c
set *0xE000ED0C = 0x05FA0004
set $busy = (*0xE000ED0C & 0x4)
while ($busy)
while (1)
set $busy = (*0xE000ED0C & 0x4)
if (! $busy)
loop_break
end
end
set language auto
end
Expand All @@ -34,20 +47,12 @@ class BlackmagicDebugConfig(DebugConfigBase):
pio_reset_halt_target
end

target extended-remote $DEBUG_PORT
monitor swdp_scan
attach 1
bmconnect $DEBUG_PORT
set mem inaccessible-by-default off
$LOAD_CMDS
$INIT_BREAK

set language c
set *0xE000ED0C = 0x05FA0004
set $busy = (*0xE000ED0C & 0x4)
while ($busy)
set $busy = (*0xE000ED0C & 0x4)
end
set language auto
pio_reset_halt_target
"""

@property
Expand Down