VSCode
VSCode is an open-source, cross-platform code editor developed by Microsoft. This guide will walk you through the process of building, running, and debugging generated CMake projects in VSCode.
Building the Project
- Open the project directory in VSCode.
- Install all recommended extensions.
- Open the command palette and execute
CMake: Select Configure Preset
, then select an option (e.g.,gcc
). - Open the command palette again and execute
CMake: Select Build Preset
, then select an option (e.g.,MinSizeRel
). - Execute
CMake: Build
(or press F7) to build the project.
Running the Project
With OpenOCD
OpenOCD is an open-source tool that provides on-chip programming and debugging support. For most types of adapters (eg. CMSIS-DAP or ST-Link), OpenOCD is a good choice to drive them. However, a significant exclusion is J-Link adapter, which is recommended to use JLink GDB Server for better performance and advanced features.
- Edit
openocd.cfg
to configure OpenOCD, see Configure OpenOCD to learn more. The default configuration is for CMSIS-DAP debugger. - Open the command palette and execute
Tasks: Run Task
. - Choose
Download (OpenOCD)
to upload the program to the board.
Debugging
With OpenOCD
- Edit
openocd.cfg
to configure OpenOCD, see Configure OpenOCD to learn more. The default configuration is for CMSIS-DAP debugger. - Open the Run and Debug Panel.
- Select
Debug (OpenOCD)
.
With JLink
- Check the
.vscode/launch.json
file and correct the path ofserverpath
, eg.{
"servertype": "jlink",
"serverpath": "C:/Program Files/SEGGER/JLink/JLinkGDBServerCL.exe"
} - Open the Run and Debug Panel.
- Select
Debug (JLink)
.
Configure Peripheral View
SVD files for command devices are pre-configured. Peripheral registers can be viewed in the Run and Debug panel.
Some devices may require manual configuration, download the SVD file from the manufacturer's website and edit .vscode/launch.json
to use it.
{
"deviceName": "STM32F401CCUx",
"svdPath": "${workspaceFolder}/path/to/STM32F401CCUx.svd"
}