Arm Mbed and Pelion Device Management support forum

Visual Studio Code: Unable to start debugging. Debug server process failed to initialize

Hello.
My configuration is:

  • Development host: Xubuntu
  • Mbed-cli: version 1.10.2 with python 2.7.17
  • Compiler: gcc-arm-none-eabi version 9-2019-q4-major
  • Debug server: xPack OpenOCD 0.10.0+dev (2019-07-17-11:25)
  • Target: ST NUCLEO 466 RG

I have set up a test program mms2 and exported it to VSC with the command:

mbed export -i vscode_gcc_arm -m NUCLEO_466RG -t gcc_arm

I have then manually (!!!) edited tasks.json (incidentally, mbed exports version 0.1.0 which is deprecated: VSC complains saying “Task version 0.1.0 is deprecated. Please use 2.0.0”) to this:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "0.1.0",
    "name": "mbed",
    "isShellCommand": true,
    "showOutput": "always",
    "problemMatcher": {
        "owner": "cpp",
        "fileLocation": ["relative", "${workspaceRoot}/mbed-os"],
        "pattern": {
            "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
            "file": 1,
            "line": 2,
            "column": 3,
            "severity": 4,
            "message": 5
        }
    },
    //"args":  ["compile", "--profile=debug", "-t", "GCC_ARM", "-m", "YOUR_TARGET"],
    "args":  ["compile", "-j","8", "--profile=debug"],
    "linux": {
        "command": "mbed"
    },
    "osx": {
        "command": "mbed"
    },
    "windows": {
        "command": "mbed"
    }
}

according to the instructions found here.
Following the same instructions I have then manually (!!!) edited tasks.json to this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/BUILD/NUCLEO_F446RE/GCC_ARM-DEBUG/${workspaceRootFolderName}.elf",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": true,
            "serverLaunchTimeout": 20000,
            "filterStderr": true,
            "filterStdout": false,
            "serverStarted": "GDB\\ server\\ started",
            "preLaunchTask": "mbed",
            "setupCommands": [
                { "text": "-target-select remote localhost:3333", "description": "connect to target", "ignoreFailures": false},
                { "text": "-file-exec-and-symbols ${workspaceRoot}/BUILD/NUCLEO_F466RE/GCC_ARM-DEBUG/${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",
                "debugServerArgs": "-f /opt/xPacks/openocd/latest/scripts/interface/stlink.cfg -c \"transport select hla_swd\" -f /opt/xPacks/openocd/latest/scripts/target/stm32f4x.cfg -c init -c \"reset init\"",
                "MIDebuggerPath": "/opt/arm/latest/bin/arm-none-eabi-gdb",
                "debugServerPath": "/opt/xPacks/openocd/latest/bin/openocd"
            },
            "osx": {
                "MIMode": "gdb",
                "MIDebuggerPath": "arm-none-eabi-gdb",
                "debugServerPath": "pyocd-gdbserver"
            },
            "windows": {
                "preLaunchTask": "mbed",
                "MIMode": "gdb",
                "debugServerArgs": "-f \"C:\\opt\\OpenOCD\\latest\\scripts\\interface\\stlink.cfg\" -c \"transport select hla_swd\" -f \"C:\\opt\\OpenOCD\\latest\\scripts\\target\\stm32f4x.cfg\" -c init -c \"reset init\" ",
                "MIDebuggerPath": "C:/opt/GNU-Tools-Arm-Embedded/latest/bin/arm-none-eabi-gdb.exe",
                "debugServerPath": "C:/opt/openocd/latest/bin/openocd.exe",
                "setupCommands": [
                    { "text": "-environment-cd ${workspaceRoot}/BUILD/NUCLEO_F446RE/GCC_ARM-DEBUG/" },
                    { "text": "-target-select remote localhost:3333", "description": "connect to target", "ignoreFailures": false },
                    { "text": "-file-exec-and-symbols ${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 }
                ]
            }
        }
    ]
}

Now, when I click Start Debugging in VSC I get the following:

output

Building project mms2 (NUCLEO_F446RE, GCC_ARM)
Scan: mms2
Link: mms2
Elf2Bin: mms2
| Module           |     .text |    .data |     .bss |
|------------------|-----------|----------|----------|
| LedMan.o         |   282(+0) |    0(+0) |    0(+0) |
| LedThread.o      |   236(+0) |    0(+0) |  192(+0) |
| [fill]           |    80(+0) |    0(+0) |   23(+0) |
| [lib]/c.a        |  5072(+0) | 2108(+0) |   89(+0) |
| [lib]/gcc.a      |   760(+0) |    0(+0) |    0(+0) |
| [lib]/misc       |   180(+0) |    4(+0) |   28(+0) |
| main.o           |   186(+0) |    0(+0) |   37(+0) |
| mbed-os/drivers  |    68(+0) |    0(+0) |    0(+0) |
| mbed-os/hal      |  1720(+0) |    4(+0) |   66(+0) |
| mbed-os/platform |  5042(+0) |  260(+0) |  348(+0) |
| mbed-os/rtos     |  9542(+0) |  168(+0) | 6101(+0) |
| mbed-os/targets  |  7392(+0) |    8(+0) |  556(+0) |
| Subtotals        | 30560(+0) | 2552(+0) | 7440(+0) |
Total Static RAM memory (data + bss): 9992(+0) bytes
Total Flash memory (text + data): 33112(+0) bytes

Image: ./BUILD/NUCLEO_F446RE/GCC_ARM-DEBUG/mms2.bin
[mbed] Working path "/media/sf_Documents/mbed-cli/mms2" (program)
[mbed] Detected "NUCLEO_F446RE" connected to "/media/alberto/NODE_F446RE" and using com port "/dev/ttyACM0"

Debug Console

1: (427) LaunchOptions<LocalLaunchOptions xmlns='http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014'
1: (474) LaunchOptions  ExePath='/media/sf_Documents/mbed-cli/mms2/BUILD/NUCLEO_F446RE/GCC_ARM-DEBUG/mms2.elf'
1: (474) LaunchOptions  WorkingDirectory='/media/sf_Documents/mbed-cli/mms2'
1: (474) LaunchOptions  ExeArguments=''
1: (474) LaunchOptions  MIMode='gdb'
1: (474) LaunchOptions  MIDebuggerPath='/opt/arm/latest/bin/arm-none-eabi-gdb'
1: (474) LaunchOptions  WaitDynamicLibLoad='false'
1: (475) LaunchOptions  DebugServer='/opt/xPacks/openocd/latest/bin/openocd'
1: (475) LaunchOptions  DebugServerArgs='-f /opt/xPacks/openocd/latest/scripts/interface/stlink.cfg -c "transport select hla_swd" -f /opt/xPacks/openocd/latest/scripts/target/stm32f4x.cfg -c init -c "reset init"'
1: (475) LaunchOptions  ServerStarted='GDB\ server\ started'
1: (475) LaunchOptions  FilterStderr='true'
1: (475) LaunchOptions  ServerLaunchTimeout='20000'
1: (475) LaunchOptions  ExternalConsole='true'
1: (476) LaunchOptions>
1: (476) LaunchOptions    <SetupCommands>
1: (476) LaunchOptions        <Command IgnoreFailures='false' Description='connect to target'>-target-select remote localhost:3333</Command>
1: (476) LaunchOptions        <Command IgnoreFailures='false' Description='load file'>-file-exec-and-symbols /media/sf_Documents/mbed-cli/mms2/BUILD/NUCLEO_F466RE/GCC_ARM-DEBUG/mms2.elf</Command>
1: (476) LaunchOptions        <Command IgnoreFailures='false' Description=''>-interpreter-exec console "monitor endian little"</Command>
1: (476) LaunchOptions        <Command IgnoreFailures='false' Description=''>-interpreter-exec console "monitor reset"</Command>
1: (477) LaunchOptions        <Command IgnoreFailures='false' Description=''>-interpreter-exec console "monitor halt"</Command>
1: (477) LaunchOptions        <Command IgnoreFailures='false' Description=''>-interpreter-exec console "monitor arm semihosting enable"</Command>
1: (477) LaunchOptions        <Command IgnoreFailures='false' Description='flash target'>-target-download</Command>
1: (477) LaunchOptions    </SetupCommands>
1: (477) LaunchOptions</LocalLaunchOptions>
1: (735) Starting: "/opt/xPacks/openocd/latest/bin/openocd" -f /opt/xPacks/openocd/latest/scripts/interface/stlink.cfg -c "transport select hla_swd" -f /opt/xPacks/openocd/latest/scripts/target/stm32f4x.cfg -c init -c "reset init"
1: (20850) <-logout
1: (20883) Send Event AD7MessageEvent

and I get the Error dialog below

Screenshot_2020-04-19_17-43-59.png

Note that if I launch on a separate command line window the command

/opt/xPacks/openocd/latest/bin/openocd -f /opt/xPacks/openocd/latest/scripts/interface/stlink.cfg -c \"transport select hla_swd\" -f /opt/xPacks/openocd/latest/scripts/target/stm32f4x.cfg -c init -c \"reset init\"

the debugger comes up without any error.

Any clues on what I may be missing?

Thanks in advance

Alberto