Cannot Attach or Launch to MSOM with STLink-V3Minie Debugger

I am having trouble connecting to the m404 SOM using the stlink-v3 minie debugger from vscode particle workbench. I'm using the latest Macbook Pro as of this writing.
I am set up to use openOCD and gdb. When I try to run a debugging session it stops with a dialog stating:
OpenOCD: GDB Server Quit Unexpectedly. See gdb-server output in TERMINAL tab for more details.

My logs are as follows:
Terminal:
Open On-Chip Debugger 0.12.0
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select '.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
srst_only separate srst_nogate srst_open_drain connect_assert_srst

Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 100 kHz
Info : STLINK V3J15M7 (API v3) VID:PID 0483:3754
Info : Target voltage: 3.258964
Error: init mode failed (unable to connect to the target)

  • The terminal process "/opt/homebrew/bin/zsh '-l', '-c', '/opt/homebrew/bin/openocd -f interface/stlink.cfg -f /Users/tommygun/code/cpp/core/liberty-fw_/stm32l4r5_custom.cfg'" failed to launch (exit code: 1).
  • Terminal will be reused by tasks, press any key to close it.

My Debug Console output is:

Cortex-Debug: VSCode debugger extension version 1.12.1 git(652d042). Usage info: GitHub - Marus/cortex-debug: Visual Studio Code extension for enhancing debug capabilities for Cortex-M Microcontrollers
"configuration": {
"name": "Particle Debug (Auto OpenOCD)",
"cwd": "/Users/tommygun/code/cpp/core/liberty-fw_",
"executable": "/Users/tommygun/code/cpp/core/liberty-fw_/target/6.2.0/msom/liberty-fw_.elf",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
"device": "STM32L4x5",
"runToEntryPoint": "setup",
"gdbTarget": "localhost:3333",
"gdbPath": "/opt/homebrew/bin/arm-none-eabi-gdb",
"showDevDebugOutput": "raw",
"configFiles": [
"interface/stlink.cfg",
"openocd/target/stm32l4r5_custom.cfg"
],
"preLaunchTask": "OpenOCD",
"interface": "swd",
"svdFile": "/Users/tommygun/code/cpp/core/liberty-fw_/STM32L4x5.svd",
"postRestartCommands": [
"monitor reset halt"
],
"openOCDLaunchCommands": ,
"configurationTarget": 6,
"gdbServerConsolePort": 55878,
"pvtAvoidPorts": [],
"chainedConfigurations": {
"enabled": false
},
"debuggerArgs": [],
"swoConfig": {
"enabled": false,
"decoders": [],
"cpuFrequency": 0,
"swoFrequency": 0,
"source": "probe"
},
"rttConfig": {
"enabled": false,
"decoders": []
},
"graphConfig": [],
"preLaunchCommands": [],
"postLaunchCommands": [],
"preAttachCommands": [],
"postAttachCommands": [],
"preRestartCommands": [],
"preResetCommands": [],
"postResetCommands": [
"monitor reset halt"
],
"searchDir": [],
"toolchainPrefix": "arm-none-eabi",
"extensionPath": "/Users/tommygun/.vscode/extensions/marus25.cortex-debug-1.12.1",
"registerUseNaturalFormat": true,
"variableUseNaturalFormat": true,
"serverpath": "/Users/tommygun/.particle/toolchains/openocd/0.12.0-particle.2/bin/openocd",
"pvtVersion": "1.12.1",
"sessionId": "82793ef6-c66a-496f-b3ee-202bfa9a99a5",
"pvtShowDevDebugOutput": "raw"
}
Reading symbols from /opt/homebrew/bin/arm-none-eabi-objdump --syms -C -h -w /Users/tommygun/code/cpp/core/liberty-fw
/target/6.2.0/msom/liberty-fw
.elf
Reading symbols from /opt/homebrew/bin/arm-none-eabi-nm --defined-only -S -l -C -p /Users/tommygun/code/cpp/core/liberty-fw
/target/6.2.0/msom/liberty-fw
.elf
Launching GDB: /opt/homebrew/bin/arm-none-eabi-gdb -q --interpreter=mi2
1-gdb-version
Launching gdb-server: /Users/tommygun/.particle/toolchains/openocd/0.12.0-particle.2/bin/openocd -c "gdb_port 50000" -c "tcl_port 50001" -c "telnet_port 50002" -s /Users/tommygun/code/cpp/core/liberty-fw_ -f /Users/tommygun/.vscode/extensions/marus25.cortex-debug-1.12.1/support/openocd-helpers.tcl -f interface/stlink.cfg -f openocd/target/stm32l4r5_custom.cfg
Please check TERMINAL tab (gdb-server) for output from /Users/tommygun/.particle/toolchains/openocd/0.12.0-particle.2/bin/openocd
Finished reading symbols from objdump: Time: 24 ms
OpenOCD: GDB Server Quit Unexpectedly. See gdb-server output in TERMINAL tab for more details.

I noticed that a reset is Not asserted when trying to connect to the target (MSOM) and the application keeps on running and stays connected to the cloud.
The wiring from the debugger to the MSOM is using the testpoints on the back of the MSOM that particle uses to program and test the device in an SWD configuration (Reset, SWO, SWDIO, SWCLK,VCC, GND)

I've ran out of ideas of what could be the problem. I see that others on this forum state they have no problem using the particle debugger but they aren't in stock so can't eliminate that variable.
Does anyone have an idea what is going on?
My launch.json file is:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: Debug code with Visual Studio Code
"version": "0.2.0",
"configurations": [
{
"name": "Particle Debug (Auto OpenOCD)",
"cwd": "${workspaceFolder}",
"executable": "${workspaceFolder}/target/6.2.0/msom/liberty-fw_.elf",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
"device": "STM32L4x5",
"runToEntryPoint": "setup",
"gdbTarget": "localhost:3333",
"gdbPath": "/opt/homebrew/bin/arm-none-eabi-gdb",
"showDevDebugOutput": "raw",
"configFiles": [
"interface/stlink.cfg",
"openocd/target/stm32l4r5_custom.cfg"
],
"preLaunchTask": "OpenOCD",
"interface": "swd",
"svdFile": "${workspaceFolder}/STM32L4x5.svd",
"postRestartCommands": [
"monitor reset halt"
],
"openOCDLaunchCommands": ,
},
{
"type": "cortex-debug",
"request": "attach",
"interface": "swd",
"servertype": "openocd",
"name": "Particle Debugger",
"cwd": "${workspaceRoot}",
"rtos": "FreeRTOS",
"armToolchainPath": "${command:particle.getDebuggerCompilerDir}",
"executable": "${command:particle.getDebuggerExecutable}",
"serverpath": "${command:particle.getDebuggerOpenocdPath}",
"searchDir": [
"${command:particle.getDebuggerSearchDir}"
],
"configFiles": [
"${command:particle.getDebuggerConfigFiles}"
],
"postAttachCommands": [
"${command:particle.getDebuggerPostAttachCommands}"
],
"particle": {
"version": "1.1.0",
//"debugger": "particle-debugger"
"debugger": "stlink"
},
"chainedConfigurations": [
"delayMs:1000"
],
},
{
"type": "cortex-debug",
"request": "attach",
"servertype": "openocd",
"name": "Generic DAPLink Compatible Debugger",
"cwd": "${workspaceRoot}",
"rtos": "FreeRTOS",
"armToolchainPath": "${command:particle.getDebuggerCompilerDir}",
"executable": "${command:particle.getDebuggerExecutable}",
"serverpath": "${command:particle.getDebuggerOpenocdPath}",
"searchDir": [
"${command:particle.getDebuggerSearchDir}"
],
"configFiles": [
"interface/stlink.cfg",
"${workspaceFolder}/stm32l4r5_custom.cfg"
],
// "configCommands": [
// "adapter speed 100",
// "transport select swd"
// ],
"postAttachCommands": [
"${command:particle.getDebuggerPostAttachCommands}"
],
"particle": {
"version": "1.1.0",
"debugger": "generic-cmsis-dap"
}
}
]
}

And my tasks.json file is:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang build active file",
"command": "/usr/bin/clang",
"args": [
"-fcolor-diagnostics",
"-fansi-escape-codes",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
},
{
"label": "OpenOCD",
"type": "shell",
"command": "/opt/homebrew/bin/openocd",
"args": [
"-f", "interface/stlink.cfg",
"-f", "${workspaceFolder}/stm32l4r5_custom.cfg"
],
"isBackground": true,
"problemMatcher": {
"pattern": [
{
"regexp": ".",
"file": 1,
"location": 2,
"message": 3
}
],
"background": {
"activeOnStart": true,
"beginsPattern": "Listening on port 4444",
"endsPattern": "Info : Listening on port 3333"
}
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "dedicated"
}
},
],
"version": "2.0.0"
}

My custom cfg file is:

Custom STM32L4R5 target config for OpenOCD

source [find target/stm32l4x.cfg]

set _CPUTAPID 0x2ba01477

Optionally disable the IDCODE check if causing issues

NOTE: This bypasses safety checks; use only when debugging

adapter speed 100

#transport select swd

This might help with certain STM32 chips that go into low-power

reset_config srst_only srst_nogate connect_assert_srst connect_under_reset

Uncomment if OpenOCD still struggles

set WORKAREASIZE 0x4000

The M-SoM (also Photon 2 and P2) are Realtek RTL872x MCUs, not STM32.

The ST/LINK series can only be used with STM32 MCUs including Gen 2 devices such as the E-Series (except E404X), Electron, Photon 1, and P1.

You need to use a CMSIS/DAP debugger with the M-SoM.

So what debugger is compatible with the MSOM?

The Particle Debugger is no longer available, but there are many, many clone devices. Look for a "CMSIS-DAP debugger" that supports ARM Cortex-M. See the debugger instructions for how to connect it.

1 Like