Blackmagic Probe Autodetection Picks UART
See original GitHub issueConfiguration
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:
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
- Plug in a BMP (I’m using a blue pill clone, but should be the same with a real one)
- Create any new project with the blackmagic debugger and attempt to download using it without specifying
upload_port
- It hangs on upload because it’s trying to use the uart port for gdb.
- 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:
- Created 2 years ago
- Comments:10 (3 by maintainers)
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)
Fixed. Could you re-run
pio upgrade --dev
. Does it work well for uploading, debugging, and device monitoring?