STM32CubeIDE for Visual Studio Code Documentation

Table Of Contents

- STM32CubeIDE for Visual Studio Code
- Introduction
  - Overview
  - System requirements
  - Release note
- Basic Concepts
  - User interface
  - Command-line tools
  - Visual Studio Code extension packs
  - Bundles
  - CMake
  - Toolchains
  - STMicroelectronics Arm Clang Toolchain for STM32
- Getting Started
  - Installation
  - First project creation
- Workspace and extension workflow
  - Workspace overview
  - Extension commands
  - Project files
  - Multi-project workspaces
- Tutorials
  - Migrating from STM32CubeIDE for Visual Studio Code extension 2.x to 3.x
  - Dual-core STM32 projects
  - Power management
  - RTOS-based STM32 projects
  - Firmware security and integrity
- Development
  - Projects
  - Editing
  - Build
  - Debug
  - API manual
  - Integration with external tools
  - Testing and validation
- Troubleshooting
  - Frequently asked questions
  - Known issues
  - Support

### On this page

- Overview
- Prerequisites
- Configuring external tools in VS Code
- Configuring debugging with external debuggers

# 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

1. Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P).

2. Select Tasks: Configure Task.

3. Choose Create tasks.json file from template if prompted.

4. 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.