Marus / cortex-debug

Visual Studio Code extension for enhancing debug capabilities for Cortex-M Microcontrollers
MIT License
1.02k stars 240 forks source link

Connection faild to remote JlinkGDBServer #347

Closed sinkyl closed 3 years ago

sinkyl commented 4 years ago

Hi,

I am able to debug locally but not remotely.

SETUP

Board:

RTOS:

Local setup:

Server setup:

LAUNCH.JSON

Local connection settings (working):

        {
            "name": "Client Debug nRF52840 J-Link",
            "type": "cortex-debug",
            "request": "launch",
            "interface": "swd",
            "cwd": "${workspaceFolder}",
            "executable": "pinnacle-100/build/${input:test-bench}/zephyr/zephyr.elf",
            "svdFile": "${env:HOME}/zephyrproject/modules/hal/nordic/nrfx/mdk/nrf52840.svd",
            "servertype": "jlink",
            "device": "nRF52840_xxAA",
            "targetId": "nrf52",
            "armToolchainPath": "${env:HOME}/gcc-arm-none-eabi/bin",
            "gdbTarget": "/usr/bin/gdb-multiarch",
            "runToMain": true
        },

For the remote connection settings, I have at least the local connection settings but I tried other parameters to connect to the remote server and it didn't worked. Remote settings:

            "name": "Server Debug nRF52840 J-Link",
            "type": "cortex-debug",
            "request": "launch",
            "interface": "swd",
            "cwd": "${workspaceFolder}",
            "executable": "pinnacle-100/build/${input:test-bench}/zephyr/zephyr.elf",
            "svdFile": "${env:HOME}/zephyrproject/modules/hal/nordic/nrfx/mdk/nrf52840.svd",
            "servertype": "jlink",
            "device": "nRF52840_xxAA",
            "targetId": "nrf52",
            "armToolchainPath": "${env:HOME}/gcc-arm-none-eabi/bin",
            "gdbTarget": "/usr/bin/gdb-multiarch",
            "runToMain": true,
            "debuggerArgs": [
                "file",
                "/home/sinan/projects/pinnacle-100/build/${input:test-bench}/zephyr/zephyr.elf"
            ]
  1. I select the Server debug

  2. Debug Console shows

    Reading symbols from '/path/to/elfprojectr/zephyr.elf'
    Finished reading symbols
    Please check OUTPUT tab (Adapter Output) for output from JLinkGDBServer
    Launching server: "JLinkGDBServer" "-if" "swd" "-port" "50000" "-swoport" "50001" "-telnetport" "50002" "-device" "nRF52840_xxAA"
  3. this shows img1

  4. After filing the ip and the port in time, this shows img2

  5. And the remote server shows img3

It connects to the server but don't keep it. I think it is waiting for some data as input but it doesn't get any then it close the socket.

I give a try with Native-Debug with the bellow settings, and it works, well not exactly the debug pointer was pointing in a thread. Better then nothing.

        {
            "type": "gdb",
            "request": "attach",
            "name": "Attach to gdbserver",
            "executable": "pinnacle-100/build/${input:test-bench}/zephyr/zephyr.elf",
            "target": "192.168.2.39:2331",
            "remote": true,
            "cwd": "${workspaceRoot}",
            "valuesFormatting": "parseText",
            "gdbpath": "${env:HOME}/gcc-arm-none-eabi/bin/arm-none-eabi-gdb"
        },

Any help to setup Cortex-Debug to connect remotely will be much appreciated. (lack of documentation)

sinkyl commented 4 years ago

Finally it did worked, there is no bug but lack of documentation. I am coming with a complete solution then I will close the "issue".