Skip to content

Instantly share code, notes, and snippets.

@janjongboom
Created June 18, 2018 03:23
Show Gist options
  • Save janjongboom/51f2edbee8c965741465fa5feefe4cf1 to your computer and use it in GitHub Desktop.
Save janjongboom/51f2edbee8c965741465fa5feefe4cf1 to your computer and use it in GitHub Desktop.
DISCO_F413ZH debugging with OpenOCD and Visual Studio Code
  1. Download OpenOCD.

  2. Place the folder in ~/openocd - so that the scripts is directly under ~/openocd/scripts.

  3. Add it to your PATH via:

    ln -s ~/openocd/bin/openocd /usr/local/bin/openocd

  4. Make sure no applications are bound to port 3333.

  5. Place launch.json and tasks.json in your .vscode folder.

    Note: Set the right path in debugServerArgs.

{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/BUILD/DISCO_F413ZH/GCC_ARM/${workspaceRootFolderName}.elf",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": false,
"debugServerArgs": "-f /Users/janjon01/openocd/scripts/board/st_nucleo_f4.cfg -f /Users/janjon01/openocd/scripts/interface/stlink-v2-1.cfg -c init -c \"reset init\"",
"serverLaunchTimeout": 20000,
"filterStderr": true,
"filterStdout": false,
"serverStarted": "target halted due to debug-request, current mode: Thread",
"preLaunchTask": "mbed",
"setupCommands": [
{ "text": "-target-select remote localhost:3333", "description": "connect to target", "ignoreFailures": false },
{ "text": "-file-exec-and-symbols ${workspaceRoot}/BUILD/DISCO_F413ZH/GCC_ARM/${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 }
],
"logging": {
"moduleLoad": true,
"trace": true,
"engineLogging": true,
"programOutput": true,
"exceptions": true
},
"linux": {
"MIMode": "gdb",
"MIDebuggerPath": "/usr/bin/arm-none-eabi-gdb",
"debugServerPath": "openocd"
},
"osx": {
"MIMode": "gdb",
"MIDebuggerPath": "/usr/local/bin/arm-none-eabi-gdb",
"debugServerPath": "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" },
{ "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 }
]
}
}
]
}
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"name": "mbed",
"isShellCommand": true,
"showOutput": "always",
"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}/mbed-os"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
},
"args": ["compile", "--profile=debug"],
"linux": {
"command": "mbed"
},
"osx": {
"command": "mbed"
},
"windows": {
"command": "mbed.exe"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment