SWAN STLINK Debugging

After following the SWAN getting started tutorials for vscode and stink upload, i add a breakpoint to my code and was disappointed when nothing hayppen!

I searched this forum and found nothing to get breakpoints and watches working.

After a little digging on the net, i landed on the STM32 section of the platformio docs, i found the solution is very simple to get full stlink debugging for the SWAN projects.

the platformio.ini file suggested in the SWAN getting started (Swan Quickstart - Blues Developers) is;

[env:bw_swan_r5]
platform = ststm32
board = bw_swan_r5
upload_protocol = stlink
framework = arduino
build_flags = -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
monitor_speed = 115200
lib_deps =
  Wire
  blues/Blues Wireless Notecard@^1.5.1

if would suggest using;

[env:bw_swan_r5]
platform = ststm32
board = bw_swan_r5
framework = arduino
build_flags = -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
monitor_speed = 115200

;upload_protocol = dfu

upload_protocol = stlink
debug_tool = stlink

lib_deps = 
	Wire
	blues/Blues Wireless Notecard@^1.5.1
	blues/Blues Wireless Notecard Pseudo Sensor@^1.1.0

ie just add the line

debug_tool = stlink

To launch your project in full debug mode, hit F5 any open source code window/tab. If your code needs recompile (with debugging) it will happen first, then your will launch into a full debug session.

hope this helps other save some time getting started with full debugging!

Note i have dfu upload commented out. And can switch quickly to dfu, uncommenting the dfu upload and commented out the stlink lines;

upload_protocol = dfu

;upload_protocol = stlink
;debug_tool = stlink
2 Likes

Thanks for posting this! I’ve found this to be an incredibly valuable way to debug on STM32 with PlatformIO :+1: