Skip to content

Add support for custom gdbHost in jlink servertype#1174

Open
sigurdal wants to merge 1 commit intoMarus:masterfrom
sigurdal:jlink_wsl
Open

Add support for custom gdbHost in jlink servertype#1174
sigurdal wants to merge 1 commit intoMarus:masterfrom
sigurdal:jlink_wsl

Conversation

@sigurdal
Copy link

@sigurdal sigurdal commented Dec 8, 2025

This adds support for specifying the host for GDB when running with "servertype": "jlink".

This is to allow running the build environment and GDB runs in WSL, while having JLinkGDBServerCL run in Windows and thus avoiding mapping the USB device into WSL.

If not set, it defaults to localhost to maintain backwards compatibility.

In my setup I have the following lines in settings.json:

{
    "cortex-debug.JLinkGDBServerPath": "/mnt/c/Program Files/SEGGER/JLink/JLinkGDBServerCL.exe",
    "cortex-debug.gdbPath": "/path/to/bin/arm-none-eabi-gdb"
}

And add the following lines to launch.json:

"gdbHost": "172.X.Y.1",
"serverArgs": [
    "-nolocalhostonly",
],

But as the WSL IP might change, it can be automatically updated, for example by using the augustocdias.tasks-shell-input extension and:

"configurations": [
    {
        "name": "Debug with J-Link",
        "gdbHost": "${input:wslHostIp}",
        "serverArgs": [
            "-nolocalhostonly",
        ],
        ...
    }
],
"inputs": [
    {
        "id": "wslHostIp",
        "type": "command",
        "command": "shellCommand.execute",
        "args": {
            "command": "ip route show | grep -i default | awk '{ print $3}'",
            "cwd": "${workspaceFolder}",
            "useSingleResult": true
        },
    }
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant