blackmagic-debug / blackmagic

In application debugger for ARM Cortex microcontrollers.
GNU General Public License v3.0
3.13k stars 759 forks source link

can pyocd work with blackmagic probe ? #1805

Closed liboyangbj closed 2 months ago

liboyangbj commented 2 months ago

can pyocd work with blackmagic probe ?

thanks

dragonmux commented 2 months ago

If that project chooses to implement our remote protocol, yes.. though given BMP itself is a full-featured GDB server in a dongle we're not sure why you would exactly want to do that vs just using BMP. The only reason we can think of is if there's a target not supported by this project and you don't want to implement support here.

Note that BMDA isn't doing anything special to be able to drive a probe that's running the firmware from a host machine - it's purely talking the Black Magic Debug remote protocol to the probe to use the probe as a semi-dumb adaptor more akin to a J-Link or a CMSIS-DAP adaptor, ignoring the GDB server packed in the firmware, w/ all the target logic run on the host.

liboyangbj commented 2 months ago

thanks for your reply.

I'm using BMP with platformIO, it works fine. But failed in CLion. There is not a appropriate in CLion.I tried to make it work by modifying ".gdbinit", but I couldn't connect.

CLion Debug Configuration : Target: blink Executable: blink GDB: arm-none-eabi-gdb (from 'RD ARM' toolchain) Download executable: Updated Only 'target remote' args: /dev/ttyBmpGdb 0 GDB Server: /usr/bin/gdb Advanced GDB Server Options Working directory: /home/dahl/dev/pico/blink Reset command: monitor reset (After Download: Checked)

~/.gdbinit : “# redefine "target remote" as "target extended-remote" define target remote target extended-remote $arg0 “# using 2nd additional "'remote target' args" parameter to define .elf file” add-inferior -exec $arg2 inferior 2 “# using 1st additional "'remote target' args" parameter to select the core” attach $arg1 end

dragonmux commented 2 months ago

Ah, so - you don't want to add-inferior to set the file used - you want to either use the file option or get it passed on the command line. "inferiors" are programs being debugged, but your host isn't running the .elf to debug it - your target is. This is likely the cause of most of your troubles here. Additionally, you have to ask BMD to scan the bus for targets.

What you likely want to do is:

define target remote
file $arg2
target extended-remote $arg0
# this might also want to be `monitor jtag_scan` depending on if your target is on JTAG or SWD.
monitor swd_scan
attach $arg1
end

We will also note that attach takes what GDB thinks is a PID number, and these start at 1, so BMD reports targets in order of discovery starting at 1 and going up.

liboyangbj commented 2 months ago

thanks I'll try it later

liboyangbj commented 2 months ago

Running well. I added “load” under “attach $arg1”. Otherwise, CLion will not be able to run to the breakpoint. I think it may be a problem with CLion.

define target remote
file $arg2
target extended-remote $arg0
# this might also want to be `monitor jtag_scan` depending on if your target is on JTAG or SWD.
monitor swd_scan
attach $arg1
load
end
dragonmux commented 2 months ago

Glad to hear it - unless there's anything else that seems to be amiss, we'll close this as solved. The "Won't fix" label is just to document that nothing our side was actually broken here and that it's an issue in a product outside of this project.

liboyangbj commented 2 months ago

Thanks 😊😊😊