How to use ST-Link to debug sketches running on Opta

So I couldn't get the mbed software debugging to work but I was able to connect the ST -LINK to the Opta and get it to hardware debug.

  1. Add connection to the Opta PCB:

  2. Make sure that the pcb interconnect is plugged correctly when reassembling. I found it was easy to misalign this and cause it to fail.

  3. Set the programmer to "STMicroelectronicsSTLINK" under Tools>Programmer. If you're using the PlatformIO VS Code plugin (highly recommend. It's brilliant), open the project's platformio.ini and add

debug_tool = stlink
upload_protocol = stlink
debug_build_flags = -O0 -g -ggdb

to the [env:opta] section.

  1. Debug!
    -With ArduinoIDE, starting debugging and uploading can be painful. Only one IDE window can be open at a time. For the very first debug session, you'll have to click the Debug button. This should open the Debug pane and should show "Opta (stlink)" in the dropdown. Make sure the debugger is not running, set Opta to Upload mode, by double tapping the Reset button, Upload (not Debug) via USB in DFU mode, once finished, click the "Start Debugging" green triangle. This won't reset the Opta, so press the Reset button on the Opta if you wish to reset. It will pause on the reset, so make sure you click Continue. Note that Variables might get optimized out even with "Optimize for Debugging" turned on.
    -With PlatformIO, everything pretty much works as expected. Open Debug pane and click Start Debug triangle. It will pause on the very first instruction and you can step through even the library code. Variables won't be optimized out. Debugging with PlatformIO is so much better.

If anyone knows anyone at Finder- kindly light a fire under their bum to get them to add a proper external debug port!

1 Like

Well. Apparently this is just a standard 10-pin SWD connector-

Hi @nopenoway thank you for the information.
May I ask you how did you get the pinout of the "connector"? I tried to look on schematics but (at least the one I found [https://docs.arduino.cc/resources/schematics/AFX00001-AFX00002-AFX00003-schematics.pdf]) it is almost useless...
I see you used ST-LINK. Any specific version (ie V2, V3...)?
Thanks!
/r0b

Thanks for sharing this! Do you maybe have some details on (non-destructively) opening the package of the Opta?

1 Like