question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Blackmagic Probe Autodetection Picks UART

See original GitHub issue

Configuration

Operating system: macOS Catalina 10.15.7

PlatformIO Version (platformio --version): PlatformIO, version 5.0.3

Description of problem

MacOS auto-detects incorrect serial port for black magic probe. On macOS, the serial ports are labeled by the descriptor index: /dev/cu.usbmodemXXXXXXX# where XXXXXX is the serial port identifier provided by the usb device and # is the interface descriptor id. I do not know if there is a better way of distinguishing these, my computer shows None for serial.tools.list_parts.ListPartInfo.interface, but my computer does recognize the interface name: Screen Shot 2021-08-05 at 9 35 28 PM Adding a condition for macOS to filter by the interface descriptor id seems to be more reliable than searching for “GDB” in the usb description which will always be the same for both ports. For context, printing item on line 140 of builder/tools/pioupload.py shows:

{'port': '/dev/cu.usbmodem5596E0E13', 'description': 'Black Magic Probe (STLINK/V2) v1.7.1-194-g8089e05-dirty', 'hwid': 'USB VID:PID=1D50:6018 LOCATION=20-2'}
{'port': '/dev/cu.usbmodem5596E0E11', 'description': 'Black Magic Probe (STLINK/V2) v1.7.1-194-g8089e05-dirty', 'hwid': 'USB VID:PID=1D50:6018 LOCATION=20-2'}

So identifying by usb description is not working. The usb descriptor id is a constant in the blackmagic probe firmware, and should be a good option to filter on for auto-detection unless the descriptors change in a new release of that firmware.

Steps to Reproduce

  1. Plug in a BMP (I’m using a blue pill clone, but should be the same with a real one)
  2. Create any new project with the blackmagic debugger and attempt to download using it without specifying upload_port
  3. It hangs on upload because it’s trying to use the uart port for gdb.
  4. Specify the upload_port, and it works

Additional info

I’m working on making a PR and testing linux because I’m curious if there’s a difference there. According to the pyserial docs: https://pyserial.readthedocs.io/en/latest/tools.html#serial.tools.list_ports.ListPortInfo it should always give the usb descriptor, not the individual interface descriptors for that “description” field in which case GDB filtering may have been broken on all non-windows platforms for a while.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jcwcommented, Jun 18, 2022

Yep, latest now works for upload and monitor - i.e. port specs not needed when a single BMP is present \o/ (I’m not set up for debugging, can’t check that right now)

0reactions
ivankravetscommented, Jun 18, 2022

Fixed. Could you re-run pio upgrade --dev. Does it work well for uploading, debugging, and device monitoring?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Black Magic Probe V2.3 - 1BitSquared
Black Magic Probe V2.3 (BMP) designed by 1BitSquared is a JTAG and SWD Adapter with a built in GDB server used for programming...
Read more >
Black Magic Probe - JeeLabs
The Black Magic Probe (BMP) is a great debugging tool for ARM Cortex µCs. This is a description of how to create one...
Read more >
Black Magic Open Source Debug Probe for ARM with Eclipse ...
The probe comes as a very small board (35x15mm), and the kit included the 10pin SWD cable and a 4pin UART cable. The...
Read more >
Embedded Debugging with the Black Magic Probe
As is common with UART protocols, the target and the debug probe must use the same bit rate within a narrow margin. Since...
Read more >
Faster picoprobe ... much faster ... - Raspberry Pi Forums
I haven't done the UART bit yet (pins 4 and 5) so if you rely on that this ... Yes, the Black Magic...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found