vscode debugging on linux

drahnr gravatar image

asked 2018-01-12 16:41:25 +0100

updated 2018-01-12 16:41:56 +0100

1: (276) LaunchOptions<LocalLaunchOptions xmlns='http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014'
    1: (294) LaunchOptions  ExePath='/home/f/Projects/area51/myapp/BUILD/myapp.elf'
    1: (294) LaunchOptions  WorkingDirectory='/home/f/Projects/area51/myapp'
    1: (294) LaunchOptions  ExeArguments=''
    1: (294) LaunchOptions MIMode='gdb'
    1: (294) LaunchOptions  MIDebuggerPath='/usr/bin/arm-none-eabi-gdb'
    1: (294) LaunchOptions  WaitDynamicLibLoad='false'
    1: (294) LaunchOptions  DebugServer='openocd'
    1: (294) LaunchOptions  DebugServerArgs='-f board/nordic_nrf52_dk.cfg -c "init" '
    1: (294) LaunchOptions  ServerStarted='GDB\ server\ started'
    1: (294) LaunchOptions  FilterStderr='true'
    1: (294) LaunchOptions  ServerLaunchTimeout='20000'
    1: (294) LaunchOptions>
1: (294) LaunchOptions    <SetupCommands>
1: (294) LaunchOptions        <Command IgnoreFailures='false' Description='connect to target'>-target-select remote localhost:3333</Command>
1: (294) LaunchOptions        <Command IgnoreFailures='false' Description='load file'>-file-exec-and-symbols /home/f/Projects/area51/myapp/BUILD/myapp.elf</Command>
1: (294) LaunchOptions        <Command IgnoreFailures='false' Description=''>-interpreter-exec console "monitor endian little"</Command>
1: (294) LaunchOptions        <Command IgnoreFailures='false' Description=''>-interpreter-exec console "monitor reset"</Command>
1: (294) LaunchOptions        <Command IgnoreFailures='false' Description=''>-interpreter-exec console "monitor halt"</Command>
1: (294) LaunchOptions        <Command IgnoreFailures='false' Description=''>-interpreter-exec console "monitor arm semihosting enable"</Command>
1: (294) LaunchOptions        <Command IgnoreFailures='false' Description='flash target'>-target-download</Command>
1: (294) LaunchOptions    </SetupCommands>
1: (294) LaunchOptions</LocalLaunchOptions>
1: (390) Starting: "openocd" -f board/nordic_nrf52_dk.cfg -c "init" 
1: (20406) <-logout
C disconnect: {"restart":false}

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/BUILD/${workspaceRootFolderName}.elf",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": false,
            "debugServerArgs": "",
            "serverLaunchTimeout": 20000,
            "filterStderr": true,
            "filterStdout": false,
            "serverStarted": "GDB\\ server\\ started",
            "preLaunchTask": "make",
            "setupCommands": [
                { "text": "-target-select remote localhost:3333", "description": "connect to target", "ignoreFailures": false },
                { "text": "-file-exec-and-symbols ${workspaceRoot}/BUILD/${workspaceRootFolderName}.elf", "description": "load file", "ignoreFailures": false},
                { "text": "-interpreter-exec console \"monitor endian little\"", "ignoreFailures": false },
                { "text": "-interpreter-exec console \"monitor reset\"", "ignoreFailures": false },
                { "text": "-interpreter-exec console \"monitor halt\"", "ignoreFailures": false },
                { "text": "-interpreter-exec console \"monitor arm semihosting enable\"", "ignoreFailures": false },
                { "text": "-target-download", "description": "flash target", "ignoreFailures": false }
            ],
            "logging": {
                "moduleLoad": true,
                "trace": true,
                "engineLogging": true,
                "programOutput": true,
                "exceptions": true
            },
            "linux": {
                "MIMode": "gdb",
                "MIDebuggerPath": "/usr/bin/arm-none-eabi-gdb",
                //"debugServerPath": "pyocd-gdbserver",
                //"debugServerArgs": " --port 3333 --target nrf52 --frequency 4000"

                "debugServerPath": "openocd",
                "debugServerArgs": "-f board/nordic_nrf52_dk.cfg -c \"init\" "
            }
        }
    ]
}

which always gives me the error that the debug server failed to launch, but..

"openocd" -f board/nordic_nrf52_dk.cfg -c "init"      
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
adapter speed: 10000 kHz
cortex_m reset_config sysresetreq
Info : No device selected, using first device.
Info : J-Trace Cortex-M Rev.3 compiled Nov 23 2017 16:43:50
Info : Hardware version: 3.10
Info : VTarget = 3.300 V
Info : clock speed 10000 kHz
Info : SWD DPIDR 0x2ba01477
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
// this is blocking input

works as expected (as far as I can tell).

What configuration is missing? What is the issue.

I am using a j-Trace from Segger.

The initial export was done with mbed export -i vscode_gcc_arm -m NRF52_DK --profile mbed-os/tools/profiles/debug.json

openocd yields 0.10.0

Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html

I am not tied to openocd, but neither does the pyocd-gdbserver work:

1: (140) LaunchOptions<LocalLaunchOptions xmlns='http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014'
    1: (148) LaunchOptions  ExePath='/home/f/Projects/area51/myapp/BUILD/myapp.elf'
    1: (148) LaunchOptions  WorkingDirectory='/home/f/Projects/area51/myapp'
    1: (148) LaunchOptions  ExeArguments=''
    1: (148) LaunchOptions MIMode='gdb'
    1: (148) LaunchOptions  MIDebuggerPath='/usr/bin/arm-none-eabi-gdb'
    1: (148) LaunchOptions  WaitDynamicLibLoad='false'
    1: (148) LaunchOptions  DebugServer='pyocd-gdbserver'
    1: (148) LaunchOptions  DebugServerArgs=''
    1: (148) LaunchOptions  ServerStarted='GDB\ server\ started'
    1: (148) LaunchOptions  FilterStderr='true'
    1: (148) LaunchOptions  ServerLaunchTimeout='20000'
    1: (148) LaunchOptions>
1: (148) LaunchOptions    <SetupCommands>
1: (148) LaunchOptions        <Command IgnoreFailures='false' Description='connect to target'>-target-select remote localhost:3333</Command>
1: (148) LaunchOptions        <Command IgnoreFailures='false' Description='load file'>-file-exec-and-symbols /home/f/Projects/area51/myapp/BUILD/myapp.elf</Command>
1: (148) LaunchOptions        <Command IgnoreFailures='false' Description=''>-interpreter-exec console "monitor endian little"</Command>
1: (148) LaunchOptions        <Command IgnoreFailures='false' Description=''>-interpreter-exec console "monitor reset"</Command>
1: (148) LaunchOptions        <Command IgnoreFailures='false' Description=''>-interpreter-exec console "monitor halt"</Command>
1: (148) LaunchOptions        <Command IgnoreFailures='false' Description=''>-interpreter-exec console "monitor arm semihosting enable"</Command>
1: (149) LaunchOptions        <Command IgnoreFailures='false' Description='flash target'>-target-download</Command>
1: (149) LaunchOptions    </SetupCommands>
1: (149) LaunchOptions</LocalLaunchOptions>
1: (200) Starting: "pyocd-gdbserver" 
1: (20208) <-logout
C disconnect: {"restart":false}

pyocd-gdbserver --version yields 0.8.0

edit retag flag offensive close delete report spam

Comments

Please correct me if I'm wrong but AFAIK VSCode is not officially supported IDE for nRF SDK. So don't expect there's a solution. You may consider VSCode community a better place to look for information how to add such support. Having said that I've been working on such integration and I've ran into bugs in VSCode C/C++ extension that make debugging embedded ARM binaries impossible on Linux and Mac. Quick look at VSCCPP github issue tracker will show you that's commonly reported problem (just look for arm-gdb).

Keton ( 2018-01-13 14:34:29 +0100 )editconvert to answer