Skip to content

Add support for custom gdbHost in jlink servertype#1174

Closed
sigurdal wants to merge 1 commit into
Marus:masterfrom
sigurdal:jlink_wsl
Closed

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

Conversation

@sigurdal
Copy link
Copy Markdown

@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
        },
    }
]

@haneefdm
Copy link
Copy Markdown
Collaborator

haneefdm commented Mar 9, 2026

We don't have a good way to support WSL and how servers and ports are managed. The way that seems to work for most people is using USBIP. You can search issues for this. Also for JLink users, using their JLink server method is a generic, good way of supporting remote (from a WSL perspective, everything else is remote).

https://www.segger.com/products/debug-probes/j-link/tools/j-link-remote-server/

We are not going to do a partial fix. Something like this, even if done, should figure out if the session is in WSL-nat mode (doesn't apply for WSL mirrored mode, as that does not need any changes and will just work) and check /etc/resolve.conf. Have you tried WSL mirrored mode and what issues did you have?

So, I cannot accept this PR.

@sigurdal sigurdal closed this May 12, 2026
@sigurdal
Copy link
Copy Markdown
Author

This PR only enabled the option of using something else than localhost as the target when the servertype was set to jlink, with WSL as an example usage scenario where it could be useful.

As the PR cannot be accepted I have closed it.

@haneefdm
Copy link
Copy Markdown
Collaborator

Full wsl/docker/ssh support is coming, this part is already implemented/working. But in a new repo...

https://github.com/mcu-debug/mcu-debug
https://github.com/mcu-debug/mcu-debug/blob/756c2e7ca868f1e006183f62bbeddd43179884a7/TaskList.md?plain=1#L68

Not ready for even a beta release, complete rewrite.

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.

2 participants