Help Debugging Photon with ST-Link/V2


#1

Looking for some guidance on using the debugging feature now provided with workbench.

I have OpenOCD installed, alpha 5 of particle workbench, and am using the ST-LINK/V2 with a photon, on a mac.

I have a clean project that is then compiled and flashed for debugging.

My launch file is as follows:

{
  "version": "0.1.0",
  "configurations": [
    {
      "cwd": "${workspaceRoot}",
      "executable": "./target/MY_FILE_NAME.elf",
      "name": "Debug Microcontroller",
      "request": "launch",
      "type": "cortex-debug",
      "servertype": "openocd",
      "device": "STM32F205RG",
      "interface": "swd",
      "configFiles":[
        "interface/stlink-v2.cfg",
        "target/stm32f2x.cfg"
      ],
    },
  ]
}

From there Debug -> Start Debugging

I get the following message in the Adapter Output window:

Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport “hla_swd”. To override use 'transport select '.
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
none separate
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v29 API v2 SWIM v7 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.211466
Info : stm32f2x.cpu: hardware has 6 breakpoints, 4 watchpoints

But receive the following message in the bottom right corner as a popup:
Debug adapter process has terminated unexpectedly (exit code: null)

The ST-Link is flashing Red/Green with a pause Green, this appears to be normal from the ST-Link documentation.

I was hoping to reference this link but it doesn’t exist any more:
https://docs.particle.io/faq/particle-tools/jtag/electron/#using-openocd
found the new location:
https://docs.particle.io/support/particle-tools-faq/jtag/

The server has started because I am unable to try debugging without stopping the running server (which I don’t know how to do without restarting, help here would be nice too)

Any tips on what I might be doing wrong are greatly appreciated.


#2

I’m not sure what’s failing, but this is the correct link to the old jtag instructions:

https://docs.particle.io/support/particle-tools-faq/jtag/


#3

Following some of the instructions in the jtag link I was able to determine a few things:

  1. Telnet is not installed by default on newer OSX versions (Mojave/High Sierra) Hoped this was the issue, but no such luck.
  2. Appears that the server is started and running, I am able to telnet to it an issue commands, so the ST-Link is operating and connected.

Has anyone used an ST-Link to debug in workbench yet?


#4

So another note on the topic:

I am able to manually start OpenOCD by navigating to the openocd folder:
/usr/local/Cellar/open-ocd/0.10.0/share/openocd/scripts
and then running:
openocd -f interface/cmsis-dap.cfg -f target/stm32f2x.cfg -c "gdb_port 3333"
(cmsis-dap can be replaced with stlink-v2 depending on adapter)

And then start GDB manually from the following location:
/Users/username/.particle/toolchains/gcc-arm/5.3.1/bin
by running:
./arm-none-eabi-gdb -ex "target remote localhost:3333"/Users/username/Documents/Firmware/Particle_Test/Test/target/Test.elf

When I do all of this, gdb can be used from the command line manually, certainly not ideal, or fun.

This demonstrates that OpenOCD, the appropriate adapter, and GDB are installed properly and working but there is something causing VS Code and the particle debugging process to think that the adapter is failing.