Problem using Particle Debugger and an Atmel-ICE at the same time

I’m using a Particle Debugger to debug my Boron application. Or at least I was, until it stopped working.

It was working an hour ago, and I didn’t change the code substantially in any way.

Steps for me to recreate the error:

  • With everything powered down, plug in the ribbon cable from the Particle debugger to the Boron
  • Power up the PCBA that the Boron is on
  • Plug in my Boron and plug in the USB micro from Boron to my PC - PC detects Boron
  • Plug in my Particle debugger to my PC - PC detects Particle debugger
  • Use “Flash application for debug (local)” command in Particle Workbench
  • Compiles fine
  • Flashes fines (via usb micro)
  • Debug console dumps a bunch of stuff, and after a few seconds I get this error message:

image

Failed to launch GDB: Remote communication error. Target disconnected.: (undocumented errno 10061). (from target-select extended-remote localhost:50000)

I enabled the "showDevDebugOutput": "raw" option in launch.json and here is the detailed text that is output to the DEBUG CONSOLE window during the event:

Cortex-Debug: VSCode debugger extension version 1.6.10 git(0458417). Usage info: https://github.com/Marus/cortex-debug#usage
Reading symbols from C:/Users/Boompy/.particle/toolchains/gcc-arm/10.2.1/bin/arm-none-eabi-objdump.exe --syms -C -h -w c:/PARTICLE_LOCAL/LinkApp/target/4.0.1/boron/LinkApp.elf
Reading symbols from c:/users/boompy/.particle/toolchains/gcc-arm/10.2.1/bin/arm-none-eabi-nm.exe --defined-only -S -l -C -p c:/PARTICLE_LOCAL/LinkApp/target/4.0.1/boron/LinkApp.elf
Launching GDB: "C:\\Users\\Boompy\\.particle\\toolchains\\gcc-arm\\10.2.1\\bin\\arm-none-eabi-gdb.exe" -q --interpreter=mi2
1-gdb-version
Launching gdb-server: "C:\\Users\\Boompy\\.particle\\toolchains\\openocd\\0.11.0-particle.4\\bin\\openocd.exe" -c "gdb_port 50000" -c "tcl_port 50001" -c "telnet_port 50002" -s "C:\\Users\\Boompy\\.particle\\toolchains\\openocd\\0.11.0-particle.4\\share\\openocd\\scripts" -f "c:/Users/Boompy/.vscode/extensions/marus25.cortex-debug-1.6.10/support/openocd-helpers.tcl" -f "interface\\cmsis-dap.cfg" -f "target\\nrf52-particle.cfg" -c "CDRTOSConfigure FreeRTOS"
    Please check TERMINAL tab (gdb-server) for output from C:\Users\Boompy\.particle\toolchains\openocd\0.11.0-particle.4\bin\openocd.exe
Finished reading symbols from objdump: Time: 144 ms
C:\Users\Boompy\.particle\toolchains\gcc-arm\10.2.1\bin\arm-none-eabi-gdb.exe: warning: Couldn't determine a path for the index cache directory.
-> =thread-group-added,id="i1"
-> ~"GNU gdb (GNU Arm Embedded Toolchain 10-2020-q4-major) 10.1.90.20201028-git\n"
-> ~"Copyright (C) 2020 Free Software Foundation, Inc.\n"
-> ~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law."
-> ~"\nType \"show copying\" and \"show warranty\" for details.\n"
-> ~"This GDB was configured as \"--host=i686-w64-mingw32 --target=arm-none-eabi\".\n"
-> ~"Type \"show configuration\" for configuration details.\n"
-> ~"For bug reporting instructions, please see:\n"
-> ~"<https://www.gnu.org/software/gdb/bugs/>.\n"
-> ~"Find the GDB manual and other documentation resources online at:\n    <http://www.gnu.org/software/gdb/documentation/>."
-> ~"\n\n"
-> ~"For help, type \"help\".\n"
-> ~"Type \"apropos word\" to search for commands related to \"word\".\n"
-> 1^done
2-gdb-set mi-async on
Finished reading symbols from nm: Time: 168 ms
-> 2^done
3-interpreter-exec console "set print demangle on"
-> 3^done
4-interpreter-exec console "set print asm-demangle on"
-> =cmd-param-changed,param="print asm-demangle",value="on"
-> 4^done
5-enable-pretty-printing
-> 5^done
6-interpreter-exec console "source c:/Users/Boompy/.vscode/extensions/marus25.cortex-debug-1.6.10/support/gdbsupport.init"
-> 6^done
7-interpreter-exec console "source c:/Users/Boompy/.vscode/extensions/marus25.cortex-debug-1.6.10/support/gdb-swo.init"
-> =cmd-param-changed,param="language",value="c"
-> =cmd-param-changed,param="language",value="auto"
-> 7^done
8-file-exec-and-symbols "c:/PARTICLE_LOCAL/LinkApp/target/4.0.1/boron/LinkApp.elf"
-> 8^done
9-target-select extended-remote localhost:50000
-> 9^error,msg="Remote communication error.  Target disconnected.: (undocumented errno 10061)."
10-interpreter-exec console "monitor halt"
Failed to launch GDB: Remote communication error.  Target disconnected.: (undocumented errno 10061). (from target-select extended-remote localhost:50000)

here is my launch.json file:

{
    "version": "0.1.0",
    "configurations": [
        {
            "type": "cortex-debug",
            "request": "attach",
            "servertype": "openocd",
            "name": "Particle Debugger",
            "showDevDebugOutput": "raw",
            "cwd": "${workspaceRoot}",
            "rtos": "FreeRTOS",
            "armToolchainPath": "${command:particle.getDebuggerCompilerDir}",
            "executable": "${command:particle.getDebuggerExecutable}",
            "serverpath": "${command:particle.getDebuggerOpenocdPath}",
            "preLaunchTask": "Particle: Flash application for debug (local)",
            "searchDir": [
                "${command:particle.getDebuggerSearchDir}"
            ],
            "configFiles": [
                "${command:particle.getDebuggerConfigFiles}"
            ],
            "postAttachCommands": [
                "${command:particle.getDebuggerPostAttachCommands}"
            ],
            "particle": {
                "version": "1.0.1",
                "debugger": "particle-debugger"
            }

        },
        {
            "type": "cortex-debug",
            "request": "attach",
            "servertype": "openocd",
            "name": "Particle Programmer Shield",
            "cwd": "${workspaceRoot}",
            "rtos": "FreeRTOS",
            "armToolchainPath": "${command:particle.getDebuggerCompilerDir}",
            "executable": "${command:particle.getDebuggerExecutable}",
            "serverpath": "${command:particle.getDebuggerOpenocdPath}",
            "preLaunchTask": "Particle: Flash application for debug (local)",
            "searchDir": [
                "${command:particle.getDebuggerSearchDir}"
            ],
            "configFiles": [
                "${command:particle.getDebuggerConfigFiles}"
            ],
            "postAttachCommands": [
                "${command:particle.getDebuggerPostAttachCommands}"
            ],
            "particle": {
                "version": "1.0.1",
                "debugger": "particle-programmer-shield"
            }
        },
        {
            "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}",
            "preLaunchTask": "Particle: Flash application for debug (local)",
            "searchDir": [
                "${command:particle.getDebuggerSearchDir}"
            ],
            "configFiles": [
                "${command:particle.getDebuggerConfigFiles}"
            ],
            "postAttachCommands": [
                "${command:particle.getDebuggerPostAttachCommands}"
            ],
            "particle": {
                "version": "1.0.1",
                "debugger": "generic-cmsis-dap"
            }
        },
        {
            "type": "cortex-debug",
            "request": "attach",
            "servertype": "openocd",
            "name": "[outdated] Particle Debugger",
            "cwd": "${workspaceRoot}",
            "armToolchainPath": "${command:particle.getDebuggerCompilerDir}",
            "executable": "${command:particle.getDebuggerExecutable}",
            "serverpath": "${command:particle.getDebuggerOpenocdPath}",
            "preLaunchTask": "Particle: Flash application for debug (local)",
            "searchDir": [
                "${command:particle.getDebuggerSearchDir}"
            ],
            "configFiles": [
                "${command:particle.getDebuggerConfigFiles}"
            ],
            "postAttachCommands": [
                "${command:particle.getDebuggerPostAttachCommands}"
            ],
            "particle": {
                "version": "1.0.0",
                "debugger": "particle-debugger"
            }
        },
        {
            "type": "cortex-debug",
            "request": "attach",
            "servertype": "openocd",
            "name": "[outdated] Particle Programmer Shield",
            "cwd": "${workspaceRoot}",
            "armToolchainPath": "${command:particle.getDebuggerCompilerDir}",
            "executable": "${command:particle.getDebuggerExecutable}",
            "serverpath": "${command:particle.getDebuggerOpenocdPath}",
            "preLaunchTask": "Particle: Flash application for debug (local)",
            "searchDir": [
                "${command:particle.getDebuggerSearchDir}"
            ],
            "configFiles": [
                "${command:particle.getDebuggerConfigFiles}"
            ],
            "postAttachCommands": [
                "${command:particle.getDebuggerPostAttachCommands}"
            ],
            "particle": {
                "version": "1.0.0",
                "debugger": "particle-programmer-shield"
            }
        },
        {
            "type": "cortex-debug",
            "request": "attach",
            "servertype": "openocd",
            "name": "[outdated] Generic DAPLink Compatible Debugger",
            "cwd": "${workspaceRoot}",
            "armToolchainPath": "${command:particle.getDebuggerCompilerDir}",
            "executable": "${command:particle.getDebuggerExecutable}",
            "serverpath": "${command:particle.getDebuggerOpenocdPath}",
            "preLaunchTask": "Particle: Flash application for debug (local)",
            "searchDir": [
                "${command:particle.getDebuggerSearchDir}"
            ],
            "configFiles": [
                "${command:particle.getDebuggerConfigFiles}"
            ],
            "postAttachCommands": [
                "${command:particle.getDebuggerPostAttachCommands}"
            ],
            "particle": {
                "version": "1.0.0",
                "debugger": "generic-cmsis-dap"
            }
        },
        {
            "type": "cortex-debug",
            "request": "attach",
            "name": "[outdated] 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": [
                "${command:particle.getDebuggerSearchDir}"
            ],
            "configFiles": [
                "interface/cmsis-dap.cfg",
                "target/stm32f2x.cfg"
            ],
            "postAttachCommands": [
                "monitor reset halt"
            ],
            "windows": {
                "configFiles": [
                    "interface\\cmsis-dap.cfg",
                    "target\\stm32f2x.cfg"
                ]
            }
        },
        {
            "type": "cortex-debug",
            "request": "attach",
            "name": "[outdated] Particle Debugger (argon, boron / bsom / b5som, xenon, tracker)",
            "servertype": "openocd",
            "interface": "swd",
            "device": "nRF52840_xxAA",
            "cwd": "${workspaceRoot}",
            "executable": "${command:particle.getDebuggerExecutable}",
            "preLaunchTask": "Particle: Flash application for debug (local)",
            "armToolchainPath": "${command:particle.getDebuggerCompilerDir}",
            "svdFile": "${command:particle.getDebuggerSVDFile}",
            "searchDir": [
                "${command:particle.getDebuggerSearchDir}"
            ],
            "configFiles": [
                "interface/cmsis-dap.cfg",
                "target/nrf52-particle.cfg"
            ],
            "postAttachCommands": [
                "monitor reset halt"
            ],
            "windows": {
                "configFiles": [
                    "interface\\cmsis-dap.cfg",
                    "target\\nrf52-particle.cfg"
                ]
            }
        },
        {
            "type": "cortex-debug",
            "request": "attach",
            "name": "[outdated] Particle Programmer Shield v1.0 (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": [
                "${command:particle.getDebuggerSearchDir}"
            ],
            "configFiles": [
                "interface/particle-ftdi.cfg",
                "target/stm32f2x.cfg"
            ],
            "postAttachCommands": [
                "monitor reset halt"
            ],
            "windows": {
                "configFiles": [
                    "interface\\particle-ftdi.cfg",
                    "target\\stm32f2x.cfg"
                ]
            }
        }
    ]
}

EDIT

OK, I figured it out at least partially.

The problem only presents itself when I have my other debugger plugged in at the same time - and Atmel ICE.

I am trying to debug the Boron at the same time as another custom board (using the Atmel ICE) but it appears that the Particle Debugger can’t attach/launch to Boron when the Atmel-ICE is plugged in.

If I start a debug session on the Boron with Atmel-ICE unplugged, the Particle Debugger successfully and repeatably establishes the debug session.

If I then plug in the Atmel-ICE once the Particle debug session is underway, I can also successfully start a debug session with my SAMG55 micro via the Atmel-ICE.

So the questions has become: Is there a way to get Workbench/VSCode to successfully launch/attach while I have my other debugger plugged in (i.e. tell Workbench to use a different set of ports to launch the debug session)

I think 10061 is connection refused. Could there be an old process hanging around still connected to port 50000? Have you tried rebooting the PC?

Restarting my computer didn’t seem to help but I shut it down for a day started it back up and now it seems to work

1 Like

That’s very strange. I have seen similar problems when the ground connection between systems is not right, but that seems a bit unlikely here. How is the Boron being powered when you use the debugger?

I have the Boron mounted on a custom PCB which is being powered by a series of step down converters being fed from a battery (so no ground loop to the computer - only ground connection between boron and computer is through the USB-micro on the Boron and the debugger).

1 Like

OK, I figured it out at least partially.

The problem only presents itself when I have my other debugger plugged in at the same time - and Atmel ICE.

I am trying to debug the Boron at the same time as another custom board (using the Atmel ICE) but it appears that the Particle Debugger can’t attach/launch to Boron when the Atmel-ICE is plugged in.

If I start a debug session on the Boron with Atmel-ICE unplugged, the Particle Debugger successfully and repeatably establishes the debug session.

If I then plug in the Atmel-ICE once the Particle debug session is underway, I can also successfully start a debug session with my SAMG55 micro via the Atmel-ICE.

Is there a way to get Workbench/VSCode to successfully launch/attach while I have my other debugger plugged in?

1 Like

It sounds more like a software-side problem now. I would check if they are both trying to use the same port (50000 in the log above). You can change the port number in the scripts or command line that launches GDB.

I’m trying to figure out how to change the port number being used in VSCode to launch the openocd GDB server.

I think the list of possible launch environment attributes to list in launch.json are listed here on the official VS Code wiki and also here on github

I have tried some combinations of the following json keys in my launch.json file:

            "debugServer": 51000,
            "gdbTarget": "localhost:51000",
            "openOCDPreConfigLaunchCommands": ["gdb_port 51000",],
            "overrideAttachCommands": ["target-select extended-remote localhost:51000"],

Some of these settings definitely break the launch. None of them seem to work. I can’t figure out how to force VS Code to launch GDB server on different ports.

I changed the VS code debug launch verbosity setting to “vscode” as described

"showDevDebugOutput": "vscode",

Here is the output to the DEBUG CONSOLE and TERMINAL windows, respectively in VSCode when I try to launch the debug session while the Atmel-ICE is plugged in. Note that at this time Microchip Studio isn’t running (just the Atmel-ICE plugged into my PC’s USB port).

Cortex-Debug: VSCode debugger extension version 1.6.10 git(0458417). Usage info: https://github.com/Marus/cortex-debug#usage
"configuration": {
    "type": "cortex-debug",
    "request": "attach",
    "servertype": "openocd",
    "name": "Particle Debugger noflash",
    "showDevDebugOutput": "raw",
    "cwd": "C:\\PARTICLE_LOCAL\\LinkApp",
    "rtos": "FreeRTOS",
    "armToolchainPath": "C:\\Users\\Boompy\\.particle\\toolchains\\gcc-arm\\10.2.1\\bin",
    "executable": "c:/PARTICLE_LOCAL/LinkApp/target/4.0.1/boron/LinkApp.elf",
    "serverpath": "C:\\Users\\Boompy\\.particle\\toolchains\\openocd\\0.11.0-particle.4\\bin\\openocd.exe",
    "searchDir": [
        "C:\\Users\\Boompy\\.particle\\toolchains\\openocd\\0.11.0-particle.4\\share\\openocd\\scripts"
    ],
    "configFiles": [
        "interface\\cmsis-dap.cfg",
        "target\\nrf52-particle.cfg"
    ],
    "postAttachCommands": [
        "add-symbol-file C:/Users/Boompy/.particle/toolchains/deviceOS/4.0.1/build/target/system-part1/platform-13-m/system-part1.elf",
        "monitor reset halt"
    ],
    "particle": {
        "version": "1.0.1",
        "debugger": "particle-debugger"
    },
    "__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": [],
    "preRestartCommands": [],
    "postRestartCommands": [],
    "preResetCommands": [],
    "postResetCommands": [],
    "toolchainPath": "C:\\Users\\Boompy\\.particle\\toolchains\\gcc-arm\\10.2.1\\bin",
    "toolchainPrefix": "arm-none-eabi",
    "gdbPath": null,
    "objdumpPath": null,
    "extensionPath": "c:/Users/Boompy/.vscode/extensions/marus25.cortex-debug-1.6.10",
    "registerUseNaturalFormat": true,
    "variableUseNaturalFormat": true,
    "interface": "swd",
    "svdFile": "C:\\Users\\Boompy\\.particle\\toolchains\\openocd\\0.11.0-particle.4\\share\\openocd\\contrib\\svd\\nrf52840.svd",
    "device": "nRF52840_xxAA",
    "pvtVersion": "1.6.10",
    "__sessionId": "975e35d5-a77d-4809-84ff-11ecc06cd481"
}
Reading symbols from C:/Users/Boompy/.particle/toolchains/gcc-arm/10.2.1/bin/arm-none-eabi-objdump.exe --syms -C -h -w c:/PARTICLE_LOCAL/LinkApp/target/4.0.1/boron/LinkApp.elf
Reading symbols from c:/users/boompy/.particle/toolchains/gcc-arm/10.2.1/bin/arm-none-eabi-nm.exe --defined-only -S -l -C -p c:/PARTICLE_LOCAL/LinkApp/target/4.0.1/boron/LinkApp.elf
Launching GDB: "C:\\Users\\Boompy\\.particle\\toolchains\\gcc-arm\\10.2.1\\bin\\arm-none-eabi-gdb.exe" -q --interpreter=mi2
1-gdb-version
From client: initialize({"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"cortex-debug","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en","supportsProgressReporting":true,"supportsInvalidatedEvent":true,"supportsMemoryReferences":true,"supportsArgsCanBeInterpretedByShell":true,"supportsMemoryEvent":true,"supportsStartDebuggingRequest":true})
To client: {"seq":0,"type":"response","request_seq":1,"command":"initialize","success":true,"body":{"supportsHitConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsConditionalBreakpoints":true,"supportsLogPoints":true,"supportsFunctionBreakpoints":true,"supportsEvaluateForHovers":true,"supportsSetVariable":true,"supportsRestartRequest":true,"supportsGotoTargetsRequest":true,"supportSuspendDebuggee":true,"supportTerminateDebuggee":true,"supportsDataBreakpoints":true,"supportsDisassembleRequest":true,"supportsSteppingGranularity":true,"supportsInstructionBreakpoints":true,"supportsReadMemoryRequest":true,"supportsWriteMemoryRequest":true}}
From client: attach({"type":"cortex-debug","request":"attach","servertype":"openocd","name":"Particle Debugger noflash","showDevDebugOutput":"vscode","cwd":"C:\\PARTICLE_LOCAL\\LinkApp","rtos":"FreeRTOS","armToolchainPath":"C:\\Users\\Boompy\\.particle\\toolchains\\gcc-arm\\10.2.1\\bin","executable":"c:/PARTICLE_LOCAL/LinkApp/target/4.0.1/boron/LinkApp.elf","serverpath":"C:\\Users\\Boompy\\.particle\\toolchains\\openocd\\0.11.0-particle.4\\bin\\openocd.exe","searchDir":["C:\\Users\\Boompy\\.particle\\toolchains\\openocd\\0.11.0-particle.4\\share\\openocd\\scripts"],"configFiles":["interface\\cmsis-dap.cfg","target\\nrf52-particle.cfg"],"postAttachCommands":["add-symbol-file C:/Users/Boompy/.particle/toolchains/deviceOS/4.0.1/build/target/system-part1/platform-13-m/system-part1.elf","monitor reset halt"],"particle":{"version":"1.0.1","debugger":"particle-debugger"},"__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":[],"preRestartCommands":[],"postRestartCommands":[],"preResetCommands":[],"postResetCommands":[],"toolchainPath":"C:\\Users\\Boompy\\.particle\\toolchains\\gcc-arm\\10.2.1\\bin","toolchainPrefix":"arm-none-eabi","gdbPath":null,"objdumpPath":null,"extensionPath":"c:/[...]
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"Cortex-Debug: VSCode debugger extension version 1.6.10 git(0458417). Usage info: https://github.com/Marus/cortex-debug#usage"}}
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stderr","output":"\"configuration\": {\n    \"type\": \"cortex-debug\",\n    \"request\": \"attach\",\n    \"servertype\": \"openocd\",\n    \"name\": \"Particle Debugger noflash\",\n    \"showDevDebugOutput\": \"raw\",\n    \"cwd\": \"C:\\\\PARTICLE_LOCAL\\\\LinkApp\",\n    \"rtos\": \"FreeRTOS\",\n    \"armToolchainPath\": \"C:\\\\Users\\\\Boompy\\\\.particle\\\\toolchains\\\\gcc-arm\\\\10.2.1\\\\bin\",\n    \"executable\": \"c:/PARTICLE_LOCAL/LinkApp/target/4.0.1/boron/LinkApp.elf\",\n    \"serverpath\": \"C:\\\\Users\\\\Boompy\\\\.particle\\\\toolchains\\\\openocd\\\\0.11.0-particle.4\\\\bin\\\\openocd.exe\",\n    \"searchDir\": [\n        \"C:\\\\Users\\\\Boompy\\\\.particle\\\\toolchains\\\\openocd\\\\0.11.0-particle.4\\\\share\\\\openocd\\\\scripts\"\n    ],\n    \"configFiles\": [\n        \"interface\\\\cmsis-dap.cfg\",\n        \"target\\\\nrf52-particle.cfg\"\n    ],\n    \"postAttachCommands\": [\n        \"add-symbol-file C:/Users/Boompy/.particle/toolchains/deviceOS/4.0.1/build/target/system-part1/platform-13-m/system-part1.elf\",\n        \"monitor reset halt\"\n    ],\n    \"particle\": {\n        \"version\": \"1.0.1\",\n        \"debugger\": \"particle-debugger\"\n    },\n    \"__configurationTarget\": 6,\n    \"gdbServerConsolePort\": 55878,\n    \"pvtAvoidPorts\": [],\n    \"chainedConfigurations\": {\n        \"enabled\": false\n    },\n    \"debuggerArgs\": [],\n    \"swoConfig\": {\[...]
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stderr","output":"Reading symbols from C:/Users/Boompy/.particle/toolchains/gcc-arm/10.2.1/bin/arm-none-eabi-objdump.exe --syms -C -h -w c:/PARTICLE_LOCAL/LinkApp/target/4.0.1/boron/LinkApp.elf\n"}}
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stderr","output":"Reading symbols from c:/users/boompy/.particle/toolchains/gcc-arm/10.2.1/bin/arm-none-eabi-nm.exe --defined-only -S -l -C -p c:/PARTICLE_LOCAL/LinkApp/target/4.0.1/boron/LinkApp.elf\n"}}
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stderr","output":"Launching GDB: \"C:\\\\Users\\\\Boompy\\\\.particle\\\\toolchains\\\\gcc-arm\\\\10.2.1\\\\bin\\\\arm-none-eabi-gdb.exe\" -q --interpreter=mi2\n"}}
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stderr","output":"1-gdb-version\n"}}
To client: {"seq":0,"type":"event","event":"custom-event-ports-allocated","body":{"info":[50000,50001,50002,50003]}}
To client: {"seq":0,"type":"event","event":"custom-event-ports-done","body":{}}
Launching gdb-server: "C:\\Users\\Boompy\\.particle\\toolchains\\openocd\\0.11.0-particle.4\\bin\\openocd.exe" -c "gdb_port 50000" -c "tcl_port 50001" -c "telnet_port 50002" -s "C:\\Users\\Boompy\\.particle\\toolchains\\openocd\\0.11.0-particle.4\\share\\openocd\\scripts" -f "c:/Users/Boompy/.vscode/extensions/marus25.cortex-debug-1.6.10/support/openocd-helpers.tcl" -f "interface\\cmsis-dap.cfg" -f "target\\nrf52-particle.cfg" -c "CDRTOSConfigure FreeRTOS"
    Please check TERMINAL tab (gdb-server) for output from C:\Users\Boompy\.particle\toolchains\openocd\0.11.0-particle.4\bin\openocd.exe
Finished reading symbols from objdump: Time: 63 ms
C:\Users\Boompy\.particle\toolchains\gcc-arm\10.2.1\bin\arm-none-eabi-gdb.exe: warning: Couldn't determine a path for the index cache directory.
-> =thread-group-added,id="i1"
-> ~"GNU gdb (GNU Arm Embedded Toolchain 10-2020-q4-major) 10.1.90.20201028-git\n"
-> ~"Copyright (C) 2020 Free Software Foundation, Inc.\n"
-> ~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law."
-> ~"\nType \"show copying\" and \"show warranty\" for details.\n"
-> ~"This GDB was configured as \"--host=i686-w64-mingw32 --target=arm-none-eabi\".\n"
-> ~"Type \"show configuration\" for configuration details.\n"
-> ~"For bug reporting instructions, please see:\n"
-> ~"<https://www.gnu.org/software/gdb/bugs/>.\n"
-> ~"Find the GDB manual and other documentation resources online at:\n    <http://www.gnu.org/software/gdb/documentation/>."
-> ~"\n\n"
-> ~"For help, type \"help\".\n"
-> ~"Type \"apropos word\" to search for commands related to \"word\".\n"
-> 1^done
2-gdb-set mi-async on
-> 2^done
3-interpreter-exec console "set print demangle on"
-> 3^done
4-interpreter-exec console "set print asm-demangle on"
-> =cmd-param-changed,param="print asm-demangle",value="on"
-> 4^done
5-enable-pretty-printing
-> 5^done
6-interpreter-exec console "source c:/Users/Boompy/.vscode/extensions/marus25.cortex-debug-1.6.10/support/gdbsupport.init"
-> 6^done
7-interpreter-exec console "source c:/Users/Boompy/.vscode/extensions/marus25.cortex-debug-1.6.10/support/gdb-swo.init"
Finished reading symbols from nm: Time: 140 ms
-> =cmd-param-changed,param="language",value="c"
-> =cmd-param-changed,param="language",value="auto"
-> 7^done
8-file-exec-and-symbols "c:/PARTICLE_LOCAL/LinkApp/target/4.0.1/boron/LinkApp.elf"
-> 8^done
To client: {"seq":0,"type":"event","event":"custom-event-post-start-server","body":{"info":{"type":"cortex-debug","request":"attach","servertype":"openocd","name":"Particle Debugger noflash","showDevDebugOutput":"raw","cwd":"C:\\PARTICLE_LOCAL\\LinkApp","rtos":"FreeRTOS","armToolchainPath":"C:\\Users\\Boompy\\.particle\\toolchains\\gcc-arm\\10.2.1\\bin","executable":"c:/PARTICLE_LOCAL/LinkApp/target/4.0.1/boron/LinkApp.elf","serverpath":"C:\\Users\\Boompy\\.particle\\toolchains\\openocd\\0.11.0-particle.4\\bin\\openocd.exe","searchDir":["C:\\Users\\Boompy\\.particle\\toolchains\\openocd\\0.11.0-particle.4\\share\\openocd\\scripts"],"configFiles":["interface\\cmsis-dap.cfg","target\\nrf52-particle.cfg"],"postAttachCommands":["add-symbol-file C:/Users/Boompy/.particle/toolchains/deviceOS/4.0.1/build/target/system-part1/platform-13-m/system-part1.elf","monitor reset halt"],"particle":{"version":"1.0.1","debugger":"particle-debugger"},"__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":[],"preRestartCommands":[],"postRestartCommands":[],"preResetCommands":[],"postResetCommands":[],"toolchainPath":"C:\\Users\\Boompy\\.particle\\toolchains\\gcc-arm\\10.2.1\\bin","toolchainPrefix":"a[...]
9-target-select extended-remote localhost:50000
-> 9^error,msg="Remote connection closed"
10-interpreter-exec console "monitor halt"
Failed to launch GDB: Remote connection closed (from target-select extended-remote localhost:50000)
To client: {"seq":0,"type":"response","request_seq":2,"command":"attach","success":false,"message":"Failed to launch GDB: Remote connection closed (from target-select extended-remote localhost:50000)","body":{"error":{"id":103,"format":"Failed to launch GDB: Remote connection closed (from target-select extended-remote localhost:50000)","showUser":true}}}

and here is the output of the TERMINAL:

[2023-03-06T20:36:38.061Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session connected. You can switch to "DEBUG CONSOLE" to see GDB interactions.
"C:\\Users\\Boompy\\.particle\\toolchains\\openocd\\0.11.0-particle.4\\bin\\openocd.exe" -c "gdb_port 50000" -c "tcl_port 50001" -c "telnet_port 50002" -s "C:\\Users\\Boompy\\.particle\\toolchains\\openocd\\0.11.0-particle.4\\share\\openocd\\scripts" -f "c:/Users/Boompy/.vscode/extensions/marus25.cortex-debug-1.6.10/support/openocd-helpers.tcl" -f "interface\\cmsis-dap.cfg" -f "target\\nrf52-particle.cfg" -c "CDRTOSConfigure FreeRTOS"
xPack OpenOCD x86_64 Open On-Chip Debugger 0.11.0+dev (2022-03-25-17:32)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
CDRTOSConfigure
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
DEPRECATED! use 'adapter speed' not 'adapter_khz'
c:/Users/Boompy/.vscode/extensions/marus25.cortex-debug-1.6.10/support/openocd-helpers.tcl: nrf52.cpu configure -rtos FreeRTOS
Info : Listening on port 50001 for tcl connections
Info : Listening on port 50002 for telnet connections
Info : CMSIS-DAP: SWD  supported
Info : CMSIS-DAP: JTAG supported
Info : CMSIS-DAP: FW Version = 1.0
Info : CMSIS-DAP: Serial# = J41800078599
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x2ba01477
Info : [nrf52.cpu] Cortex-M4 r0p1 processor detected
Info : [nrf52.cpu] target has 6 breakpoints, 4 watchpoints
Info : starting gdb server for nrf52.cpu on 50000
Info : Listening on port 50000 for gdb connections
Info : accepting 'gdb' connection on tcp/50000
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00400f98 msp: 0x20005838
Error: No symbols for FreeRTOS
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x10000060
Error: Couldn't read CONFIGID register
Error: auto_probe failed
Error: Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use 'gdb_memory_map disable'.
Error: attempted 'gdb' connection rejected
[2023-03-06T20:36:40.527Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session closed
GDB server session ended. This terminal will be reused, waiting for next session to start...

Based on the output of the TERMINAL, It looks like from what I can tell that VSCode is connecting to the Atmel-ICE instead of the Particle Debugger when I try to launch the debug session, and then trying to establish a debug session with the other MCU that I have the Atmel-ICE connected to…

Does anyone know how to set either of these programmers to operate on a custom port?

I'm not a user of VS code, but it looks like you are still launching Particle openOCD at gdb port 50000 in this command from your log. The port numbers have to match--the Particle side and the VS Code side. I'm not sure how they intend for you change that, but I'm sure you either pass a param or edit the script directly.

Well, VSCode is basically Particle Workbench, which is what this forum is all about! I think you are almost certainly correct - it involves some undocumented (or underdocumented) launch config parameter magic, or else it may involve editing the scripts that are bundled into particle workbench…

Any idea who to ping on either the Particle Workbench team or the Particle Debugger team to comment on how to configure Workbench to launch Particle Debugger gdb server and openocd on a specific port, or another workaround to avoid conflicts with other connected debuggers?

Maybe @rickkas7 or @ScruffR or @BDub or @nrobinson2000 know?

Bump. Anyone know how to fix this?

Maybe @Colleen can assist here?
thanks

Hi @jaza_tom ,

Thank you for the detailed explanation of what you’re trying to accomplish, what steps you tried and the logs you shared.
I spent some time trying to configure launch.json to launch openocd/GDBServer on a different port and then connect to GDB on that port, but it seems there are some limitations in the cortex-debug plugin we use internally in workbench that prevents this from working.

This configuration will instruct openocd/GDBserver to use port 51000:

"openOCDLaunchCommands": ["gdb_port 51000"],

This configuration should instruct GDB to connect on that port as well:

"overrideAttachCommands": ["target-select extended-remote localhost:51000"],

However, it appears that the cortex-debug plugin that workbench uses will only execute overrideAttachCommands after it is able to connect to the debug target. Unfortunately, it appears the attach sequence is hard coded to attempt to connect on port 50000 first, which will fail since the server is not listening on that port.
This is what it looks like in the DEBUG CONSOLE logs when attempting to do this:

9-target-select extended-remote localhost:50000
-> 9^error,msg="localhost:50000: Operation timed out."
10-interpreter-exec console "target-select extended-remote localhost:51000"
Failed to launch GDB: localhost:50000: Operation timed out. (from target-select extended-remote localhost:50000)

I think the same problem happens when trying preAttachCommands / preLaunchCommands as well, since the plugin must attach (ie connect) to the GDB server before executing those commands.

The only other workaround I came up with is to change the debug server type to external, specify the port to connect to, then manually launch your own GDB server instance.

To do this:

  1. Add this to launch.json:
"servertype": "external",
"gdbTarget": "localhost:51000",
  1. In a terminal window, manually start the server to connect to (note the changed -c "gdb_port 51000" parameter.
"C:\\Users\\Boompy\\.particle\\toolchains\\openocd\\0.11.0-particle.4\\bin\\openocd.exe" -c "gdb_port 51000" -c "tcl_port 50001" -c "telnet_port 50002" -s "C:\\Users\\Boompy\\.particle\\toolchains\\openocd\\0.11.0-particle.4\\share\\openocd\\scripts" -f "c:/Users/Boompy/.vscode/extensions/marus25.cortex-debug-1.6.10/support/openocd-helpers.tcl" -f "interface\\cmsis-dap.cfg" -f "target\\nrf52-particle.cfg" -c "CDRTOSConfigure FreeRTOS"
  1. Debug as normal. GDB should connect on the port specified in gdbTarget
-> ~"GNU gdb (GNU Arm Embedded Toolchain 10-2020-q4-major) 10.1.90.20201028-git\n"
-> ~"Copyright (C) 2020 Free Software Foundation, Inc.\n"
-> ~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law."
-> ~"\nType \"show copying\" and \"show warranty\" for details.\n"
-> ~"This GDB was configured as \"--host=x86_64-apple-darwin10 --target=arm-none-eabi\".\n"
-> ~"Type \"show configuration\" for configuration details.\n"
-> ~"For bug reporting instructions, please see:\n"
-> ~"<https://www.gnu.org/software/gdb/bugs/>.\n"
-> ~"Find the GDB manual and other documentation resources online at:\n    <http://www.gnu.org/software/gdb/documentation/>."
-> ~"\n\n"
-> ~"For help, type \"help\".\n"
-> ~"Type \"apropos word\" to search for commands related to \"word\".\n"
-> 1^done
2-gdb-set mi-async on
-> 2^done
3-interpreter-exec console "set print demangle on"
-> 3^done
4-interpreter-exec console "set print asm-demangle on"
-> =cmd-param-changed,param="print asm-demangle",value="on"
-> 4^done
5-enable-pretty-printing
-> 5^done
6-interpreter-exec console "source /Users/scottbrust/.vscode/extensions/marus25.cortex-debug-1.10.0/support/gdbsupport.init"
-> 6^done
7-interpreter-exec console "source /Users/scottbrust/.vscode/extensions/marus25.cortex-debug-1.10.0/support/gdb-swo.init"
-> =cmd-param-changed,param="language",value="c"
-> =cmd-param-changed,param="language",value="auto"
-> 7^done
8-file-exec-and-symbols "/Users/scottbrust/Downloads/waether-click/target/5.3.1/argon/waether-click.elf"
-> 8^done
9-target-select extended-remote localhost:51000      // <---- New port here

Its a little fiddly to have to manage the separate GDB server instance, buts its the best I could come up with right now. We may be able to launch the server ourselves as part of the preLaunchTasks to avoid having to debug in two steps, but that would require a workbench update.

The other option is to see if the Atmel IDE has some way to configure its GDB port. I haven’t used their IDE in a while, so I’m not sure if thats easier than this approach.

I hope this is helpful and apologies for the slow reply,

-Scott

3 Likes