In platform.py
, just replace the _add_default_debug_tools
method with this exact code.
def _add_default_debug_tools(self, board):
debug = board.manifest.get("debug", {})
upload_protocols = board.manifest.get("upload", {}).get(
"protocols", [])
if "tools" not in debug:
debug["tools"] = {}
if "jlink" in upload_protocols and "jlink" not in debug["tools"]:
assert debug.get("jlink_device"), (
"Missed J-Link Device ID for %s" % board.id)
debug["tools"]["jlink"] = {
"server": {
"package": "tool-jlink",
"arguments": [
"-singlerun",
"-if", "SWD",
"-select", "USB",
"-device", debug.get("jlink_device"),
"-port", "2331"
],
"executable": ("JLinkGDBServerCL.exe"
if IS_WINDOWS else
"JLinkGDBServer")
}
}
# blackmagic always possible
debug["tools"]["blackmagic"] = {
"hwids": [["0x1d50", "0x6018"]],
"require_debug_port": True
}
board.manifest["debug"] = debug
return board
Then when I have
[env:teensy41]
platform = teensy
framework = arduino
board = teensy41
upload_protocol = blackmagic
debug_tool = blackmagic
; specify COM port of Blackmagic debug probe (for GDB)
debug_port = COM3
And use the PIO Core CLI to start debugging from the command line
PS C:\Users\Max\Desktop\arduino-blink> pio debug --interface=gdb -- -x .pioinit
Preparing firmware for debugging...
Processing teensy41 (platform: symlink://C:\Users\Max\Desktop\teensy; framework: arduino; board: teensy41)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/teensy/teensy41.html
PLATFORM: Teensy (4.17.0) > Teensy 4.1
HARDWARE: IMXRT1062 600MHz, 512KB RAM, 7.75MB Flash
DEBUG: Current (blackmagic) External (blackmagic, jlink)
PACKAGES:
- framework-arduinoteensy @ 1.157.220801 (1.57)
- tool-teensy @ 1.159.0 (1.59)
- toolchain-gccarmnoneeabi @ 1.50401.190816 (5.4.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 92 compatible libraries
Scanning dependencies...
No dependencies
Building in debug mode
Compiling .pio\build\teensy41\src\Blink.cpp.o
...
Archiving .pio\build\teensy41\libFrameworkArduino.a
Linking .pio\build\teensy41\firmware.elf
Checking size .pio\build\teensy41\firmware.elf
Calculating size .pio\build\teensy41\firmware.elf
Building .pio\build\teensy41\firmware.hex
teensy_size: Memory Usage on Teensy 4.1:
teensy_size: FLASH: code:8708, data:3992, headers:8800 free for files:8104964
teensy_size: RAM1: variables:4512, code:6272, padding:26496 free for local variables:487008
teensy_size: RAM2: variables:12384 free for malloc/new:511904
============ [SUCCESS] Took 4.58 seconds ============
Reading symbols from C:\Users\Max\Desktop\arduino-blink\.pio\build\teensy41\firmware.elf...done.
PlatformIO Unified Debugger -> https://bit.ly/pio-debug
PlatformIO: debug_tool = blackmagic
PlatformIO: Initializing remote target...
.pioinit:19: Error in sourced command file:
(gdb) COM3: No such file or directory.
It definitely looks like it tries to access a COM port here, but I don’t have a BMP.