Debug not working in Visual Studio Code

I'm currently setting up an environment in Visual Studio Code because the roadmap suggests going there.

I have experience with Segger and Nordic Segger and with Zephyr.

I have installed NCS 2.0.0 and Visual Studio Code 1.70.0. It's hard to find a complete guide how to setup the environment.
I'm using:
- Ubuntu 20.04 LTS.
- NCS 2.0.0
- NRF connect for desktop 3.11.1
- Visual Studio Code 1.70.0
- Toolchain Manager v1.1.3
- nrfutil version 5.2.0
- Zephyr SDK 0.14.2

I have used:
https://academy.nordicsemi.com/topic/exercise-1-1/
https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/gs_installing.html
https://www.zephyrproject.org/zephyr-developer-summit-getting-started-with-zephyr-rtos-videos/

I noticed that there are differences in configuration. What I also notice is that a lot of things change all the time. VScode plugins getting deprecated.
Environment variables no longer needed to be set.
This is one of the reasons I make a new post.

I also found:
RE: Building/Debugging with Zephyr SDK Toolchain in nRF Connect VS Code (Linux) 

But unfortunately it did not work for me. It also does not have all the information I need. Like where is settings.json located? Do I need to create it?
I have no experience at all in Visual Studio Code. But I managed to install it, configure it and make the flash button work.
I managed to get blinky working on the Nordic DK board.

Debug button does not work. I get the following error message:
GDB executable "arm-zephyr-eabi-gdb" was not found.
Please configure "cortex-debug.armToolchainPath" or "cortex-debug.gdbPath" correctly.

Then I have to choose between "cancel" and "open 'launch.json'". launch.json is not the same as settings.json.
When I look at the previous post, I changed launch.json into:

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: go.microsoft.com/.../
"version": "0.2.0",
"configurations": [
{
"type": "nrf-connect",
"request": "launch",
"name": "Launch nRF Connect application",
"config": ""
}

],
"cortex-debug.JLinkGDBServerPath": "/opt/SEGGER/JLink/JLinkGDBServerCLExe",
"cortex-debug.armToolchainPrefix": "arm-zephyr-eabi",
"cortex-debug.armToolchainPath": "~/zephyr-sdk-0.14.2/arm-zephyr-eabi/bin"
}

But that did not work.

I also tried creating .vscode/settings.json with the following contents:

{
"cortex-debug.JLinkGDBServerPath": "/opt/SEGGER/JLink/JLinkGDBServerCLExe",
"cortex-debug.armToolchainPrefix": "arm-zephyr-eabi",
"cortex-debug.armToolchainPath": "~/zephyr-sdk-0.14.2/arm-zephyr-eabi/bin"
}

But that also did not work.

The previous post also suggested to set the environment variable GNUARMEMB_TOOLCHAIN_PATH in .bashrc

export GNUARMEMB_TOOLCHAIN_PATH=/home/ephimee/ncs_v2.0.0/v2.0.0/zephyr/cmake/toolchain/gnuarmemb

But this also did not work.

I also tried opening VScode via Toolchain manager and without Toolchain manager in all scenarios. That did not make a difference either.
What I did notice is that sometimes GNUARMEMB_TOOLCHAIN_PATH is set to zephyr and sometimes set to gnuarmemb.
If I search on the internet there's no real answer where it has to be set to because both seem to work for some users?

I hope there are more suggestions?

  • Hi Philip,

    Have you downloaded the latest version of nRF Command Line Tools? Also, wat is your J-Link version? Could you also attach the Support Information [(Ctrl+Shift+P) and Generate Support Information]?

    Best Regards,

    Priyanka

  • Have you downloaded the latest version of nRF Command Line Tools?

    Yes, see previous post with version information.

    Also, wat is your J-Link version?

    What do you mean? How do I get this version?

    Could you also attach the Support Information [(Ctrl+Shift+P) and Generate Support Information]?

    I do not understand?

  • Hi Philip,

    It would be helpful to get the Support Information. Please open the VSCode and click (Ctrl+Shift+P) and select Generate Support Information.

    And please attach this here so that we can take a detailed look.

    -Priyanka

  • IMPORTANT: The data below could contain sensitive or confidential information about your environment.
    If you do not wish this to be seen by others, please make sure to remove it before sharing.
    
    For help and support, visit the Nordic DevZone at https://devzone.nordicsemi.com/.
    
    {
      "platform": {
        "os": "linux",
        "osVersion": "#138-Ubuntu SMP Wed Jun 22 15:00:31 UTC 2022",
        "osKernel": "5.4.0-122-generic",
        "vscode": "1.70.0",
        "electron": "18.3.5",
        "node": "v16.13.2"
      },
      "system": {
        "date": "2022-08-15T13:20:45.241Z",
        "vscodeRoot": "/usr/share/code/resources/app",
        "nrfConnectForDesktopInstalled": "unknown",
        "vscodeUptime": "56:39:49",
        "osUptime": "121:56:55",
        "cpu": {
          "model": "Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz",
          "speed": "800 MHz",
          "count": 4
        },
        "memory": {
          "total": "15.40 GB",
          "free": "0.19 GB"
        }
      },
      "workspace": {
        "name": "Untitled (Workspace)",
        "workspaceFile": "1657273842650",
        "folders": [
          "/home/ephimee/Projects/vcode/firstProject/hello_world",
          "/home/ephimee/Projects/vcode/secondProject/hello_world2",
          "/home/ephimee/Projects/vcode/thirdProject/thirdProjectApplicationName",
          "/home/ephimee/Projects/vcode/fourthProject/fourthProjectApplicationName",
          "/home/ephimee/Projects/vcode/button"
        ]
      },
      "extensions": {
        "internal": {
          "nordic-semiconductor.nrf-connect": {
            "version": "2022.7.242",
            "path": "/home/ephimee/.vscode/extensions/nordic-semiconductor.nrf-connect-2022.7.242-linux-x64",
            "isActive": true
          },
          "nordic-semiconductor.nrf-terminal": {
            "version": "2022.7.21",
            "path": "/home/ephimee/.vscode/extensions/nordic-semiconductor.nrf-terminal-2022.7.21",
            "isActive": true
          },
          "nordic-semiconductor.nrf-devicetree": {
            "version": "2022.7.36",
            "path": "/home/ephimee/.vscode/extensions/nordic-semiconductor.nrf-devicetree-2022.7.36",
            "isActive": true
          },
          "nordic-semiconductor.nrf-kconfig": {
            "version": "2022.7.24",
            "path": "/home/ephimee/.vscode/extensions/nordic-semiconductor.nrf-kconfig-2022.7.24",
            "isActive": true
          }
        },
        "external": {
          "marus25.cortex-debug": "1.4.4",
          "ms-vscode.cpptools": "1.11.5",
          "ms-vscode.js-debug": "1.70.0",
          "ms-vscode.js-debug-companion": "1.0.18",
          "ms-vscode.vscode-js-profile-table": "1.0.3",
          "trond-snekvik.gnu-mapfiles": "1.1.0",
          "twxs.cmake": "0.0.17"
        }
      },
      "tools": {
        "/home/ephimee/zephyr-sdk-0.14.2/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc": "0.14.2",
        "/opt/SEGGER/JLink/JLinkExe": "6.88a",
        "/usr/local/bin/nrfjprog": "10.17.2",
        "/home/ephimee/.local/bin/nrfutil": null,
        "/usr/bin/cmake": "3.24.0",
        "/home/ephimee/.local/bin/west": "0.13.1",
        "/usr/bin/python3": "3.8.10",
        "/usr/bin/ninja": "1.10.0",
        "/usr/bin/gperf": "3.1",
        "/usr/bin/dtc": "1.5.0",
        "gn": "Not found",
        "/usr/bin/git": "2.25.1"
      },
      "sdks": [
        {
          "version": "Zephyr 2.4.99",
          "path": "/home/ephimee/zephyrproject"
        }
      ],
      "toolchains": [],
      "connectedDevices": [
        {
          "serialNumber": "683245598"
        }
      ],
      "deviceProviders": [
        "nrfjprog"
      ],
      "config": {
        "nordic-semiconductor.nrf-connect": {
          "topdir": "/home/ephimee/ncs_v2.0.0/v2.0.0",
          "toolchain": {
            "path": "PATH"
          },
          "ozonePath": "",
          "applications": [
            "/home/ephimee/Projects/vcode/secondProject/hello_world2",
            "${workspaceFolder}",
            "/home/ephimee/Projects/vcode/thirdProject/thirdProjectApplicationName",
            "/home/ephimee/Projects/vcode/fourthProject/fourthProjectApplicationName",
            "/home/ephimee/Projects/vcode/button"
          ],
          "applicationOptions": {},
          "kconfig": {
            "interface": "kconfig"
          },
          "welcome": {
            "showOnStartup": true
          },
          "west": {
            "env": {
              "$base": "terminal"
            }
          },
          "boardRoots": [],
          "enableTelemetry": true,
          "taskBindings": {},
          "debugging": {
            "backend": "Cortex-Debug"
          },
          "activeAppFollowActiveEditor": true
        },
        "nordic-semiconductor.nrf-terminal": {
          "terminalMode": "character"
        },
        "marus25.cortex-debug": {
          "armToolchainPath": null,
          "armToolchainPrefix": "arm-none-eabi",
          "gdbPath": null,
          "objdumpPath": null,
          "JLinkGDBServerPath": null,
          "openocdPath": null,
          "pyocdPath": null,
          "PEGDBServerPath": null,
          "stutilPath": null,
          "stlinkPath": null,
          "stm32cubeprogrammer": null,
          "enableTelemetry": true,
          "flattenAnonymous": false,
          "registerUseNaturalFormat": true,
          "variableUseNaturalFormat": true,
          "dbgServerLogfile": null,
          "showRTOS": false,
          "showDevDebugOutput": "none"
        }
      },
      "environment": {
        "westExe": "west",
        "westEnv": {
          "ELECTRON_RUN_AS_NODE": "1",
          "HOME": "/home/ephimee",
          "PATH": "/home/ephimee/zephyr-sdk-0.14.2/arm-zephyr-eabi/bin:/tmp/.mount_nrfconxHQFxE:/tmp/.mount_nrfconxHQFxE/usr/sbin:/home/ephimee/.local/bin:/home/ephimee/ncs_v2.0.0/v2.0.0/zephyr/cmake/toolchain/gnuarmemb:/home/ephimee/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",
          "ZEPHYR_BASE": "/home/ephimee/ncs_v2.0.0/v2.0.0/zephyr",
          "GNUARMEMB_TOOLCHAIN_PATH": "/home/ephimee/ncs_v2.0.0/v2.0.0/zephyr/cmake/toolchain/gnuarmemb",
          "ZEPHYR_TOOLCHAIN_VARIANT": "zephyr",
          "USER": "ephimee"
        },
        "inherited": {
          "ELECTRON_RUN_AS_NODE": "1",
          "HOME": "/home/ephimee",
          "PATH": "/tmp/.mount_nrfconxHQFxE:/tmp/.mount_nrfconxHQFxE/usr/sbin:/home/ephimee/.local/bin:/home/ephimee/ncs_v2.0.0/v2.0.0/zephyr/cmake/toolchain/gnuarmemb:/home/ephimee/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",
          "GNUARMEMB_TOOLCHAIN_PATH": "/home/ephimee/ncs_v2.0.0/v2.0.0/zephyr/cmake/toolchain/gnuarmemb",
          "USER": "ephimee"
        },
        "toolchainPath": "PATH"
      },
      "terminal": {
        "shell": null,
        "defaultProfile": null
      }
    }
    
    
    

  • Hi Philip,

    Is it possible to attach the launch.json file which appears, before you make modifications to it?

    -Priyanka

Related