I have made a working blink sketch in mbed studio, which can be debugged. After exporting it with the following command: mbed export -i vscode_gcc_arm -m nucleo_f303re --profile debug
, I got a working project in vscode which can upload to the designated target. The problem I’m facing however is that I can’t debug the executing code.
My launch.json is as follows:
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/cmake_build/NUCLEO_F303RE/debug/GCC_ARM/${workspaceRootFolderName}.elf",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"targetArchitecture": "arm",
"externalConsole": false,
"debugServerArgs": "",
"serverLaunchTimeout": 20000,
"filterStderr": true,
"filterStdout": false,
"serverStarted": "GDB\\ server\\ started",
"preLaunchTask": "mbed",
"setupCommands": [
{
"text": "-target-select remote localhost:3333",
"description": "connect to target",
"ignoreFailures": false
},
{
"text": "-file-exec-and-symbols ${workspaceRoot}/cmake_build/NUCLEO_F303RE/debug/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": "arm-none-eabi-gdb",
"debugServerPath": "pyocd-gdbserver"
},
"osx": {
"MIMode": "gdb",
"MIDebuggerPath": "arm-none-eabi-gdb",
"debugServerPath": "pyocd-gdbserver"
},
"windows": {
"preLaunchTask": "mbedtools",
"MIMode": "gdb",
"MIDebuggerPath": "C:\\Program Files (x86)\\GNU Arm Embedded Toolchain\\10 2021.10\\bin\\arm-none-eabi-gdb.exe",
"debugServerPath": "C:\\Code\\C++\\mbed6venv\\Scripts\\pyocd-gdbserver.exe",
"setupCommands": [
{
"text": "-environment-cd ${workspaceRoot}/cmake_build/NUCLEO_F303RE/debug/GCC_ARM"
},
{
"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
}
]
}
},
{
"name": "Cortex",
"cwd": "${workspaceRoot}",
"executable": "./cmake_build/NUCLEO_F303RE/debug/GCC_ARM/${workspaceRootFolderName}.elf",
"request": "launch",
"type": "cortex-debug",
"servertype": "stlink",
"serverArgs": [
"-l 1",
"-s",
"-i 066EFF3035344E5043142257",
"-v"
],
"interface": "swd",
"device": "nucleo_f303re",
}
]
}
This launch.json uses the following tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"name": "mbedtools",
"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": [],
"linux": {
"command": "mbedtools"
},
"osx": {
"command": "mbedtools"
},
"windows": {
"command": "mbedtools"
},
"tasks": [
{
"label": "mbedtools",
"type": "shell",
"args": [
"compile", "--profile=debug", "-t", "GCC_ARM", "-m", "nucleo_f303re"
],
"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
}
},
"group": {
"_id": "build",
"isDefault": false
}
}
]
}
The only major change I made is that I changed the build system to the mbed build system instead of make.
Target is a pcb based on the nucleo_f303re