0

I am attempting to launch a debug session in vs code in wpl2 on a nrf52 platform. I get the pyocd-gdbserver exited with code 1. Normally I just use segger jlink gdb server in windows. I am new to pyocd and wsl2. Here is my launch.json:

    "configurations": [
            {
                "name": "C++ Launch",
                "type": "cppdbg",
                "request": "launch",
                "program": "${workspaceRoot}/build/zephyr/zephyr.elf",
                "args": [],
                "stopAtEntry": true,
                "cwd": "${workspaceRoot}",
                "environment": [],
                "externalConsole": false,
                "debugServerArgs": "",
                "serverLaunchTimeout": 20000,
                "filterStderr": true,
                "filterStdout": false,
                "serverStarted": "GDB\\ server\\ started",
                "setupCommands": [
                    { "text": "-target-select remote localhost:3333", "description": "connect to target", "ignoreFailures": false },
                    { "text": "-file-exec-and-symbols ${workspaceRoot}/build/zephyr/zephyr.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",
                    "MIDebuggerPath": "/usr/bin/gdb",
                    "debugServerPath": "pyocd-gdbserver"
                }
            }
        ]
    }

Pressing launch showed the somewhat cryptic message: 1: (132) Starting: "pyocd-gdbserver" 1: (1798) "pyocd-gdbserver" exited with code 1 (0x1). 1: (1803) <-logout 1: (20150) <-logout 1: (20153) Send Event AD7MessageEvent

I'm not sure if I can use pyocd in place of gdb server.

embdev
  • 1
  • 1
  • I was able to get gdb running like this: Install JLink in windows and in WSL. Start gdb server on the windows side: JLinkRemoteServer.exe Now the gdb server is waiting for a connection. From windows command line type hostname. This is the name of the computer. Now type ping insert_hostname_here -4. This will give you the ip address of the hostname. From WSL command line type: gdb zephyr.elf in gdb type: target remote windows_hostname:2331 You are now connected to the jlink gdb server. – embdev Aug 22 '23 at 23:07
  • I was able to get vs code debugging working like this: follow the directions in the link below: https://nnfw.readthedocs.io/en/stable/howto/how-to-remote-debugging-with-visual-studio-code.html need to replace in launch.json: "executable": "${workspaceRoot}/build/zephyr/zephyr.elf", "target": ":2331", Note replace ip address with the virtual ip address from gdbserver. – embdev Aug 22 '23 at 23:10
  • After getting debugging working in both gdb and in vs code it is now broken again presumably from the dynamic nature of using a virtual adapter in WSL2. It is quite confusing so I am doing research into how to find the correct virtual address of the windows gdbserver from WSL2. I am an EE not a networking expert. I feel like I was lucky to get it working but now it is broken again. Let me know if these experiments are helping anyone or if you have insight into the networking problem. – embdev Aug 22 '23 at 23:14
  • I am able to debug in vs code at home but in the office it is not working. For whatever reason the ip address when running ping hostname -4 from windows is correct at home, but in the office it doesn't work. There are a lot of strange problems with networking in WSL2 that will probably be fixed over time but for now it is a bit fraught with peril. Example: I can't ping google if I ever lose network connection due to Palo Alto global protect VPN adding routes that need to be deleted in order to restore connection to the internet from WSL2. Debugging is working for now. – embdev Aug 23 '23 at 23:27
  • I ended up the first part of this using this guide to setup debugging (thanks to the author): – embdev Aug 23 '23 at 23:30
  • https://nnfw.readthedocs.io/en/stable/howto/how-to-remote-debugging-with-visual-studio-code.html – embdev Aug 23 '23 at 23:31

0 Answers0