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:
{ "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 }, { "text": "-file-exec-and-symbols ${workspaceRoot}/pca10040/s132/armgcc/_build/nrf52832_xxaa.out", "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/arm-none-eabi-gdb", "debugServerPath": "/usr/local/bin/openocd" //"debugServerPath":"/opt/SEGGER/JLink/JLinkGDBServer" }, "osx": { "MIMode": "gdb", "MIDebuggerPath": "/usr/local/bin/arm-none-eabi-gdb", "debugServerPath": "/usr/local/Cellar/open-ocd/0.10.0/bin/openocd" }, "windows": { "preLaunchTask": "mbed", "MIMode": "gdb", "MIDebuggerPath": "C:\\Program Files (x86)\\GNU Tools ARM Embedded\\4.9 2015q3\\bin\\arm-none-eabi-gdb.exe", "debugServerPath": "openocd.exe", "setupCommands": [ { "text": "-environment-cd ${workspaceRoot}\\DISCO_F413ZH\\GCC_ARM\\BUILD" }, //what's this? { "text": "-target-select remote localhost:3333", "description": "connect to target", "ignoreFailures": false }, { "text": "-file-exec-and-symbols ${workspaceRootFolderName}.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 } ] } }, ] }