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

Visual Studio Code development with gcc and openocd

Hello,

I'm migrating all my projects from Eclipse to VSCode. On Eclipse I used to debug using JLink tools, however I would like to have a more generic tool (not all the devkits I use are equipped with a jlink debugger). I found openocd together with arm-none-eabi-gdb to be a good choice since it supports a number of MCUs and devkits that I use often.

Now, I already made it work for a third party manufacturer's MCU (therefore the installed tools look ok) and I'm trying to do the same for the Nordic's ones but I'm facing problems.

First of all, if I launch openocd from a terminal with the proper parameters (the same used by VScode) everything looks ok. Here the console:

giova@ubuntu-giova:~$ openocd -f board/nordic_nrf52_dk.cfg -c init -c "reset init"
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
openocd.org/.../bugs.html
adapter speed: 10000 kHz
cortex_m reset_config sysresetreq
Info : No device selected, using first device.
Info : J-Link OB-SAM3U128-V2-NordicSemi compiled Jul 24 2017 17:30:12
Info : Hardware version: 1.00
Info : VTarget = 3.300 V
Info : Reduced speed from 10000 kHz to 1000 kHz (maximum).
Info : Reduced speed from 10000 kHz to 1000 kHz (maximum).
Info : clock speed 10000 kHz
Info : SWD DPIDR 0x2ba01477
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x000008e8 msp: 0x20000400

and if I run arm-none-eabi-gdb and then target remote localhost:3333 it connects to openocd without apparent errors.

However, when I launch the debug configuration from VScode, openocd starts properly (I see the same output of above) but then something goes wrong since gdb doesn't connect and the console tells is:

<-logout
Send Event AD7MessageEvent

Any idea on how to fix it? Unfortunately the console output is not really meaningful and I cannot say what component is complaining.

Davide

PS: my launch.json file is as follow:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Nordic",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/pca10040/s132/armgcc/_build/nrf52832_xxaa.out",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceRoot}/pca10040/s132/armgcc/",
"environment": [],
"externalConsole": false,
"debugServerArgs":"-f board/nordic_nrf52_dk.cfg -c init -c \"reset init\"",
"serverLaunchTimeout": 20000,
"filterStderr": false,
"filterStdout": false,
"serverStarted": "target halted due to debug-request, current mode: Thread",
"preLaunchTask": "build",
"setupCommands": [
{ "text": "-target-select remote localhost:3333", "description": "connect to target", "ignoreFailures": false },
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX