Stlink-v2 electron debugging

Hi guys,

  • workbench 1.13.1
  • electron 2.0.0
  • simple app with the SPI driven ENC28J60 ethernet module
  • usb stlink-v2 clone connected (D6,D5,GND, 3.3V)
  • launch.json modified to use stlink-v2.cfg file
  • no breakpoints set

Everything works perfectly despite that when the app enters the main loop the debug console reports the following message: “jtag status contains invalid mode value - communication failure
Program stopped. 0x0800019c in ?? ()” However, the app does not stop in fact (it still responds to pings). After I hit continue the debug console complains that “target not halted; target stm32f2x.cpu was not halted when resume was requested”, which confirms that the app if fact didn’t stop. After 10-20 seconds the debug console reports the very same message.

The call stack when this happens looks like this:
??@0x0800019c (Unknown Source:0)
??@0xfffffffe (Unknown Source:0)

Adding/removing"rtos":“FreeRTOS” to/from launch.json does not change how the call stack looks like.

What I’ve managed to discover is that the reported situation is somehow related to the SPI bus. When the ethernet module packet loop call is removed from the main loop, the debug console no longer complains.

I no longer have any more ideas what’s the issue behind this behaviour. I hope someone more experienced with the debugging toolchain can point me in the right direction.

PS. My config section looks like this

            "type": "cortex-debug",
            "request": "attach",
            "name": "Particle Debugger (photon, p1, electron)",
            "servertype": "openocd",
            "interface": "swd",
            "device": "STM32F205RG",
            "cwd": "${workspaceRoot}",
            "executable": "${command:particle.getDebuggerExecutable}",
            "preLaunchTask": "Particle: Flash application for debug (local)",
            "armToolchainPath": "${command:particle.getDebuggerCompilerDir}",
            "svdFile": "${command:particle.getDebuggerSVDFile}",
            "searchDir": [
            "configFiles": [
            "postAttachCommands": [
                "monitor reset halt"

think the error is related to poor cabling. I noticed that disconnecting SWDIO or SWCLK gives exactly same effect as I described. I tried to lower adapter_khz parameter in target/stm32f2x.cfg file. It seems that after that change stlink disconnects less frequently.

PS. I upgraded stlink dongle firmware. No impact.