Integration with external tools ¶
STM32CubeIDE for Visual Studio Code (VS Code) provides a flexible environment for embedded development on STM32 microcontrollers. To enhance the development workflow, integrate external tools within the integrated development environment (IDE). This section describes how to increase productivity and streamline embedded projects.
Overview ¶
Integrating external tools enables the following:
Automate build, test, and deployment processes
Use specialized utilities with the development environment
Customize the workflow for project-specific requirements
Maintain a consistent toolchain across teams
Common types of external tools include the following:
Command-line utilities, for example, compilers, linters, formatters
Debugging and profiling tools
Code generators and static analyzers
Version control and continuous integration or continuous (CI/CD) scripts
Prerequisites ¶
Before integrating external tools, ensure the following:
STM32CubeIDE for VS Code installed as an extension
The external tools are installed and accessible through the system PATH or known locations
Basic familiarity with VS Code tasks and launch configurations
Configuring external tools in VS Code ¶
Use tasks to automate xxternal commands. The VS Code task system enables running external commands and scripts directly from the IDE.
Creating a task
Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P).
Select Tasks: Configure Task.
Choose Create tasks.json file from template if prompted.
Select Others to create a custom task.
Example: Running a code formatter
Add the following to the .vscode/tasks.json file:
{
"version": "2.0.0",
"tasks": [
{
"label": "Run Code Formatter",
"type": "shell",
"command": "external-formatter-tool --fix",
"args": [
"${file}"
],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always"
},
"problemMatcher": []
}
]
}
This task runs the external formatter on the currently opened file.
Configuring debugging with external debuggers ¶
STM32CubeIDE supports debugging through various probes and debuggers. To integrate an external debugger, modify or create a
launch.json
configuration in the
.vscode
folder and specify the debugger executable and parameters.
Example: Using an external GDB server
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug with External GDB Server",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/your_project.elf",
"miDebuggerServerAddress": "localhost:3333",
"miDebuggerPath": "/usr/bin/arm-none-eabi-gdb",
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"externalConsole": false
}
]
}
Adjust paths and addresses according to the setup.
Integrate code generation tools or other utilities by adding them as tasks or by using VS Code extensions that facilitate their use.
Tip
Tips for effective integration
Use variables:
Use VS Code variables like
${workspaceFolder},
${file}, and
${env:PATH}
to make configurations portable.
Group tasks: Organize related tasks into groups for easy access.
Use problem matchers: Configure problem matchers to parse tool output and highlight errors or warnings in the editor.
Document configurations: Keep the .vscode folder under version control and document custom tasks and launch configurations for team collaboration.