cortex-debug: Failed to launch OpenOCD GDB Server: Timeout.

I am trying to use this extension to debug a LPC4337 board via OpenOCD. However I have no luck yet getting it working.

From the same directory using the command line I can start an openOCD session and fire up GDB which works fine.

This is my launch.json configuration:

 "configurations": [
        {
            "showDevDebugOutput": true,
            "type": "cortex-debug",
            "request": "attach",
            "servertype": "openocd",
            "cwd": "${workspaceRoot}",
            "executable": "./build/blinky_m4",
            "name": "Cortex Debug",
            "device": "LPC43xx",
            "configFiles": [
                "interface/ftdi/jtag-lock-pick_tiny_2.cfg",
                "./lpc4337_jtag.cfg"
            ],
        }
    ]

VSCode gives me the following error when I try to run the debugger: Failed to launch OpenOCD GDB Server: Timeout.

And in the developer console I see this output:

[marus25.cortex-debug]Cannot read property 'getTime' of null
e.$onExtensionRuntimeError @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3227
/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3227 TypeError: Cannot read property 'getTime' of null 
at Object.endSession (../out/src/reporting.js:94:52)
at CortexDebugExtension.debugSessionTerminated (../out/src/frontend/extension.js:299:29)

The extension crashes on this line, reporting.ts:105:

    const time = (endTime.getTime() - sessionStart.getTime()) / 1000;

Since sessionStart is null (Is that a situation that should be possible?). I am not sure what that means, I guess it wasn’t able to successfully start a debugging session?

What I can see is that OpenOCD does start properly (the led on my jtag device starts blinking and OpenOCD is briefly in my process list), but GDB does not appear in my process list. Am I missing something? I am willing to investigate further but I don’t really know where to start since there is so little feedback/output. Any suggestions are appreciated.

MacOS 10.13.6 VSCode 1.26.1 OpenOCD 0.10 GDB: GNU gdb (GNU Tools for Arm Embedded Processors 7-2018-q2-update) 8.1.0.20180315-git

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 16

Most upvoted comments

I have a similar error as @busticated mentioned. It turns out that 18.04 Ubuntu does not have the GDB executable arm-none-eabi-gdb, so the extention hangs on debug. (https://askubuntu.com/questions/1031103/how-to-install-gdb-arm-none-eabi-on-ubuntu-18-04/1033056) My workaround was:

  1. Apt install package: gdb-multiarch (Since normal GDB doesn’t support ARM)
  2. Add symbolic link
$ sudo ln -s /usr/bin/gdb-multiarch /usr/bin/arm-none-eabi-gdb

OR edit launch.json to point to the gdb-multiarch

        {
            "name": "Cortex Debug OpenOCD",
            "cwd": "${workspaceRoot}",
            "executable": "./build/aero2_firmware.elf",
            "request": "attach",
            "type": "cortex-debug",
            "servertype": "openocd",
             ........
            "showDevDebugOutput": false,
            "gdbpath": "/usr/bin/gdb-multiarch"
        },
  1. Try to debug again And that seemed to work for me but now I’ve got a new issue during debug where when the execution is broken at a breakpoint, I can change my tabs or view to anything else. It immediately snaps back to the line of code where it paused.

@dhinault,

I installed the GNU MCU eclipse toolchain and Openocd as explained on the site and used these versions in the settings of cortex-debug via file > preferences> settings/Extensions/cortex-debug For the arm toolchain path I’ve thefollowing: { "terminal.integrated.rendererType": "dom", "cortex-debug.openocdPath": "/home/democles/opt/gnu-mcu-eclipse/openocd/0.10.0-10-20181020-0522/bin/openocd", "cortex-debug.enableTelemetry": false, "cortex-debug.stutilPath": "/home/democles/.platformio/packages/tool-stlink/bin/st-util", "cortex-debug.armToolchainPath": "/home/democles/opt/gnu-mcu-eclipse/arm-none-eabi-gcc/8.2.1-1.1-20190102-1122/bin", "workbench.iconTheme": "vscode-icons", "workbench.colorTheme": "Solarized Dark", } my launch.json file looks like: { "cwd": "${workspaceRoot}", "executable": "${workspaceRoot}/.pioenvs/genericSTM32F103C8/firmware.elf", "name": "Debug Microcontroller", "request": "launch", "type": "cortex-debug", "servertype": "openocd", "device": "STM32F103C8", "configFiles": ["/home/democles/opt/gnu-mcu-eclipse/openocd/0.10.0-10-20181020-0522/scripts/interface/stlink-v2.cfg","/home/democles/opt/gnu-mcu-eclipse/openocd/0.10.0-10-20181020-0522/scripts/target/stm32f1x.cfg"] } Hope this helps you