Skip to content

feat(platform): extend Black Magic Debug Probe upload method to more boards #2621

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

Merged
merged 3 commits into from
Jan 8, 2025

Conversation

ALTracer
Copy link
Contributor

@ALTracer ALTracer commented Jan 7, 2025

Summary

This PR implements the following feature

  • Enable BMP upload method in Programmers menu for more boards

Black Magic Debug Probe supports interactive debugging as well as one-shot uploading, via gdb script or multi-argument command line. This is useful with Generic boards which often don't have an onboard debugger. Method was contributed here earlier and carried on for GenF1, GenF3, GenF4, GenL0, GenFlight.
Let's extend this to 3rd party boards, too. Garatronic Pybstick26 was omitted because it only has LEDs on PA13/14 SWD, no testpoints even.

Of course I am unsure about allowing this on Nucleo/Disco/Eval products from ST, which should have a working STLink/V2 or V3E running proprietary firmware; but also P1x6 SWD 2.54mm or STDC-14 headers. If you deem this okay, then it's +20 more lines in a third commit.
BMDA does not create a COM port, it will need a new upload method for tcp socket (like openocd but simpler) which is how one uses BMDA with STLink backend (or CMSIS-DAP, or FTDI MPSSE, or JLink etc.) And of course you don't ship BMDA builds, there's no xPack for it but only GH CI builds and releases.

GenU0 and GenWBA are not supported by BMP (yet), it will treat them as generic Cortex-M without flash reprogramming.

Similar PRs: PR #2528 closing #2437 (CMSIS-DAP), PR #2455 closing #2452 (JLink). I wonder if something systemwide happened that you now have to set per-family upload_methods.

Small feature request: is it possible to also Debug via BMP not OpenOCD in Theia IDE? What is required to configure Cortex-Debug for this automatically? Editing conffiles is less convenient. I may open a separate issue on this.

Validation

  • CI is likely unaffected. Manual review and testing is welcome.
  • I've used BMP-compatible debuggers to upload compiled sketches to small boards, i.e. it's now possible to develop on two blackpill-f411ce boards or so (one flashed with BMP, one running user sketches) just like two Raspberry Pico (they use picoprobe/debugprobe on one of them but it's not self-contained and needs OpenOCD/pyocd/probe-rs as gdbserver).

Code formatting

  • No code touched, only boards.txt, local astyle.py doesn't complain

Closing issues

Not opening an issue myself for this.

@fpistm
Copy link
Member

fpistm commented Jan 7, 2025

Hi @ALTracer

Of course I am unsure about allowing this on Nucleo/Disco/Eval products from ST, which should have a working STLink/V2 or V3E running proprietary firmware; but also P1x6 SWD 2.54mm or STDC-14 headers. If you deem this okay, then it's +20 more lines in a third commit.

Well, STLink can be disconnected if needed and so I guess BMP upload method can be used but don't see any interest. 😉 Except (maybe) avoid to install the STM32CubeProgrammer and driver. And also to be compatible with host arm architecture.
So, up to you. Any other feedback welcome.

What do you mean by BMDA ?

I wonder if something systemwide happened that you now have to set per-family upload_methods.

Simply due to boards.txt format. No submenu can be defined else it will be already factorized so it have to be duplicated for each menu.
To have it define only ones, all boards (>1200) would have to be listed in 1 time.

Small feature request: is it possible to also Debug via BMP not OpenOCD in Theia IDE? What is required to configure Cortex-Debug for this automatically? Editing conffiles is less convenient. I may open a separate issue on this.

We support only Arduino IDE. Maybe you mean Arduino IDE 2 by Theia IDE? If true then I guess it can be done anyway I will not have time to test/deploy this. You can open a discussion first for this not an issue, maybe other user will comment.

@fpistm fpistm added the enhancement New feature or request label Jan 7, 2025
@fpistm fpistm self-requested a review January 7, 2025 14:43
@dragonmux
Copy link

What do you mean by BMDA ?

👋🏼 lead maintainer of Black Magic Debug here, what he's referring to is Black Magic Debug App, just known as BMDA by the project. It is the BMD firmware but built to run as a host program and able to interface with BMPs and other dongles running the firmware, CMSIS-DAP adaptors, J-Link's, ST-Links, and FTDI devices being used as adaptors.

It provides the same GDB server and all the goodness of automatic part discovery, but over TCP/IP (port 2000 by default) instead of a serial device. No config files, just a single binary - blackmagic-bmda if using the nightlies and official releases, blackmagic if built yourself.

@fpistm
Copy link
Member

fpistm commented Jan 7, 2025

Hi 👋🏼 @dragonmux and thanks for the detailed explanation. Clear now :)
I'm not a BMP expert as mainly used STLink with ST software. Anyway for a community project it is fine to get this support.
So thanks for your work. 😉

@fpistm fpistm added this to the 2.10 milestone Jan 7, 2025
@ALTracer
Copy link
Contributor Author

ALTracer commented Jan 7, 2025

Well, STLink can be disconnected if needed and so I guess BMP upload method can be used ...

Then I'll add the lines to Nucleo/Disco/Eval regardless of SoC and connectors -- Nucleo-64 and 144 always have the external debugger connectors, to which a BMP can be connected with a flat cable (assuming STLink/V2-A is no-MSD, pins tristated, or even in Reset). Discovery Kits are more varied, that is 32F072B-Disco, 32F407G-Disco, 32F429i-Disc1 have 6-pin connectors, but STM32MP157D-DK1 has nothing (testpoints for pogo jig don't count). The caveat is that BMP won't immediately support newly General Available chips like STM32U0, and stm32duino shouldn't limit the Programmer selection.

BMDA is BMP logic on PC hardware (also runs on anything you compile it for, including SBC like Pi 3B) that bridges some USB wiggler to TCP socket (for Arduino 2 intents and purposes). That is the primary way some users upload&debug to Nucleo via its STLink/V2-A without resorting to OpenOCD Tcl.
Note that I won't be adding full BMDA support in this PR, it can be done separately later.

Maybe you mean Arduino IDE 2 by Theia IDE?

Yes, I mean IDE 2 as opposed to IDE 1.8 (Processing) which had no Debug capabilities. Let's run a Discussion for that, sure.

* Only GenF1, GenF3, GenF4, GenL0 and GenFlight allowed this by now,
  so extend support to the rest of chip families supported by BMP v2.0
* GenU0 and GenWBA are not supported.
@ALTracer ALTracer force-pushed the feature/upload_method_bmp branch from 7d0141a to c6b57c0 Compare January 7, 2025 16:01
Copy link
Member

@fpistm fpistm left a comment

Choose a reason for hiding this comment

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

LGTM.

@fpistm fpistm merged commit b0f56e7 into stm32duino:main Jan 8, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

3 participants