Recent

Author Topic: Debugging with Black Magic Probe is available in Lazarus Trunk  (Read 1698 times)

MiR

  • Full Member
  • ***
  • Posts: 246
Debugging with Black Magic Probe is available in Lazarus Trunk
« on: September 17, 2019, 09:12:19 am »
Thanks to the help of Martin Frb latest trunk has support for the Black Magic Debug-Probe.
More Info on BMP can be found here:
https://github.com/blacksphere/blackmagic/wiki

The main advantages of BMP are:
- Works on ST-Link Hardware (also Cheap Chinese ST-Link V2 Clones and BluePill boards)
- Supports not only debugging STM32 Chips, but also Atmel, NXP and Freescale chips
- Does not need additional Software, it directly connects to gdb over COM Port, so no more need to install st-link software or ST Toolchain for debugging.

To convert your Chinese clone check here (you need to scroll down on the page to find instructions for the Clones):
http://embdev.net/articles/STM_Discovery_as_Black_Magic_Probe
and
https://madnessinthedarkness.transsys.com/blog:2017:0122_black_magic_probe_bmp_on_st-link_v2_clones

now compile trunk of lazarus and fire up the debugger settings.

To find out correct configuration check

/dev/cu.usbmodem* device entries on Mac, the right port to connect to is the first found

open Device Manager on Windows and check for COM Ports, on my PC the 2nd COM Port (COM5) was the correct one to connect to.

Now go to Debugger Backend Settings and configure according to the screenshot attached.

Here's the complete script that needs to go into EventProperties->AfterConnect:
Code: Text  [Select][+][-]
  1. monitor swdp_scan
  2. #!timeout=1000
  3. #!timeoutwarn=false
  4. attach 1
  5. #!timeout=default
  6. #!timeoutwarn=true
  7. set mem inaccessible-by-default off
  8.  

After this debugging should work.

For troubleshooting fire up gdb and enter the following:

Code: Text  [Select][+][-]
  1. (gdb) target extended-remote COM5
  2. Remote debugging using COM5
  3. (gdb)
  4. (gdb)
  5. (gdb) monitor
  6. Black Magic Probe (Firmware v1.6.1-352-g3a6947a) (Hardware Version 0)
  7. Copyright (C) 2015  Black Sphere Technologies Ltd.
  8. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
  9.  
  10. (gdb) monitor swdp_scan
  11. Target voltage: unknown
  12. Available Targets:
  13. No. Att Driver
  14.  1      STM32F1 medium density M3/M4
  15.  
  16.  

don't bother trying to troubleshoot connectivity issues from within lazarus, firing up gdb is far more efficient and faster to use!
You will need to adjust the settings in "AfterConnect" if your microcontroller does not show enumerate as Target No. 1, change the "attach 1" line to the number that you see for your controller.

If gdb seems to hang after target extended-remote command unplug and re-plug the debug probe and try the other port.

Please note that I was NOT able to connect to the Debug Probe inside of VMWare Fusion, so if you use a virtual Machine to run  Windows then BMP is perhaps not the first choice.

Have fun,

Michael

d.ioannidis

  • Full Member
  • ***
  • Posts: 221
    • Nephelae
Re: Debugging with Black Magic Probe is available in Lazarus Trunk
« Reply #1 on: September 17, 2019, 11:50:24 am »
Hi Michael,
 
  very nice. I'll convert my ST-Link V2 clone to Black Magic Probe and give it a try .

  BTW, when we'll see the changes regarding AVR support in MBF at Github ?  ;)

regards,
« Last Edit: September 17, 2019, 12:07:17 pm by Dimitrios Chr. Ioannidis »

MiR

  • Full Member
  • ***
  • Posts: 246
Re: Debugging with Black Magic Probe is available in Lazarus Trunk
« Reply #2 on: September 17, 2019, 12:09:43 pm »
On AVR: Soonish.... I changed the interface of the SPI routines so that I can cut down code size for common usecases, but now I have to implement those changes for all the other Chips. This takes a lot of testing and weather was simply too nice in the last weeks.

I also want to include better support for BluePill so when those tasks are ready I will push to github.

If you want to already use AVR then download the snapshot I did for the Debugging tests on Arm

http://temp.michael-ring.org/mbf-snapshot.zip

Michael

 

TinyPortal © 2005-2018