This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

cortex-debug / gdb

Hi,

I want to use Zephyr OS with openthread (I use Linux as a dev platform) and I thus have tried to modify the socket echo server to my needs (I am a noob with zephyr, nordic and openthread... so i'm sorry for my dumb question in advance).

In order to test the app, I wanted to use the cortex-debug extension on visual studio code. I have the following configuration for the extension:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "cortex-debug",
            "request": "launch",
            "serverpath": "/opt/SEGGER/JLink_V650b/JLinkGDBServerCLExe",
            "servertype": "jlink",
            "cwd": "${workspaceFolder}",
            "executable": "PATH_TO_MY_BUILD_DIT/zephyr/zephyr.elf",
            "name": "Debug J-Link",
            "device": "nRF52840_xxAA",
            "svdFile": "../nRF5SDKforThreadandZigbeev3209fade31/modules/nrfx/mdk/nrf52840.svd",
            "interface": "swd",
            "runToMain": true,
            "ipAddress": null,
            "serialNumber": null
        }
    ]
}

in the main.c main() function, I have the following lines :

max1726x = device_get_binding("max1726x");
if (!max1726x) {
	LOG_ERR("Device not found.\n");
	return;
}

When I try to put the breakpoint at the first line, the debugger stops at the next. No matter what I try, it seems impossible to stop at the wanted line.

In order to find the issue I have try to run gdb in a shell (with west debug --runner jlink), and the breakpoint cannot be set at the wanted line (it is put at the next as well), which seems to show that vscode is not the issue.

Since it looked like an optimization error, I have try to set the optimization level to CONFIG_DEBUG_OPTIMIZATIONS, which doesn't change anything. If I try the CONFIG_NO_OPTIMIZATION, openthread won't compile (which is kind of sad).

So I tried the Ozone debugger from JLINK (without re-compiling, by providing the same options and the same .elf file) and it works perfectly...

In order to ease the development I would have wanted to use only vscode and I'm still eager to make it work with cortex-debug... So do you have any advice?

Thx in advance,

Arnaud

Related