OpenOCD debugging in visual studio code

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
RuHe_1008296
Level 3
Level 3
5 replies posted 5 questions asked First reply posted

Hey 

I am working with the CY8CKIT-145-40XX board. I have tried using it in psoc creator and modustoolbox. I thought it would be fun to try to run the make build and debugging in vs code.  The makefile was easy, but are struggling getting the debugging up and running.  

My Process: 
I create a command file "openocd.tcl" containing the commands: 

set PSOC4_USE_ACQUIRE 1
source [find interface/kitprog3.cfg]
puts stderr {Started by GNU MCU Eclipse}
source [find target/psoc4.cfg]
psoc4.cpu configure -rtos auto -rtos-wipe-on-reset-halt 1
init; reset init

Copied from modustoolbox  openocd setup. 

 

in visual studio code I use the cortex-debug plugin with a launch setting as such: 

{
            "name": "openocd",
            "request": "launch",
            "type": "cortex-debug",
            "cwd": "${workspaceRoot}",
            "interface": "swd",
            "runToMain": true,
            "servertype": "openocd",
            "serverpath":"C:/Users/hteml/ModusToolbox/tools_2.3/openocd/bin/openocd.exe",
            "armToolchainPath":"C:/Users/hteml/ModusToolbox/tools_2.3/gcc/bin",
            "executable": "build/CY8CKIT-145-40XX/Debug/mtb-example-psoc4-spi-master.elf",
            "searchDir": [
                "C:/Users/hteml/ModusToolbox/tools_2.3/openocd/scripts"
            ],
            "preLaunchCommands": [
                "set mem inaccessible-by-default off"
            ],
            "configFiles": [
                "openocd.tcl"
            ],
            "showDevDebugOutput": false
}

 

To ensure that I did not mess someting up in the build I just opened the modustoolbox project in vs code. So the elf is compiled in modustoolbox. 

When running the debugger in modustoolbox i hit my breakpoint in main, but fore some reason this breakpoint is never hit in vs code setup.  

and I get: 

Info : SWD DPIDR 0x0bc11477
Error: Failed to read memory at 0x10000040
Info : SWD DPIDR 0x0bc11477
Error: Failed to read memory at 0x10000104

Any pointers to make this work is appreciated. 

 

0 Likes
1 Solution
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi @RuHe_1008296

ModusToolbox projects can be easily exported to VS Code by running the make vscode command. Please refer to Section 7.3 Export to VS Code in the ModusToolbox User Guide. This should generate all the VS Code specific files for you. 

Thanks and Regards,
Rakshith M B

View solution in original post

0 Likes
1 Reply
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi @RuHe_1008296

ModusToolbox projects can be easily exported to VS Code by running the make vscode command. Please refer to Section 7.3 Export to VS Code in the ModusToolbox User Guide. This should generate all the VS Code specific files for you. 

Thanks and Regards,
Rakshith M B
0 Likes