cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a project with STM32 VS Code extension v2.0.0 or newer

B_Subramanian
ST Employee

Summary

This article is an introduction to STM32 MCU development through the VS Code IDE using the updated STM32 Visual Studio Code extension v2.0.0 or newer.

In this article, we cover the following:

  • Downloading the updated VS Code Extension
  • Creating a new project through the embedded CubeMX platform
  • Programming and debugging the application

Introduction

Many developers choose to use VS Code to create applications using STM32 microcontrollers. To improve the development experience using VS Code, ST has released a new and improved VS Code extension starting from v2.0.0. This extension serves as a single comprehensive pack, which provides a complete STM32 IDE experience from within VS Code. This article provides step-by-step instructions to get started with the new extension.

Prerequisites

Hardware

Software

1. Development

1.1 Setting up the STM32 VS Code extension

Download the STM32 VS Code extension. This is done through the VS Code application with your PC connected to the internet.

  1. In the VS Code application, open [Extensions] (Ctrl + Shift + X) and search for STM32CubeIDE for Visual Studio Code

B_Subramanian_0-1769802273168.png

 

  1. Install the [STM32 VS Code Extension]. It looks like this picture below.

B_Subramanian_1-1769802273170.png

 

1.2 Creating a new project using STM32CubeMX

There are two different ways to create a project, either from an empty project or by using STM32CubeMX. In this article, we explore using STM32CubeMX, as it gives you a quick way to configure your project and get started.

  1. Open STM32CubeMX from VS Code by selecting [Launch STM32CubeMX] located under "STM32Cube Key Actions".
    B_Subramanian_2-1769802273171.png

     

  2. From STM32CubeMX, start the project by selecting an MCU, a board, or an example. For the purposes of this article, start the project by selecting a board. Select [Access to Board Selector].

B_Subramanian_3-1769802273172.png

 

  1. Within the Board Selector, type NUCLEO-G071RB in the field "Commercial Part Number".

B_Subramanian_4-1769802273173.png

 

  1. Once the board is selected, select [Start Project].

B_Subramanian_5-1769802273186.png

 

  1. Select [Yes] when prompted with the choice to initialize peripherals with their default mode.

B_Subramanian_6-1769802273187.png

 

  1. In this article, we will be toggling the PA5 pin, which is connected to the on-board LED. This is already configured in STM32CubeMX, so no change is necessary. In general, the project can be configured at this point.

B_Subramanian_7-1769802273190.png

 

  1. When the project configuration is complete, select the "Project Manager" tab. Here, you can change the Project Name and change the Toolchain to CMake. Once that is complete, select the [Generate Code] button on the top right.

B_Subramanian_8-1769802273198.png

 

1.3 Importing your project in VS Code

  1. In VS Code, select File > Open Folder, and navigate to the project folder you created in CubeMX.

    B_Subramanian_9-1769802273201.png

     

  2. At the bottom right of your screen a popup appears, asking if you would like to configure the discovered CMake Project as a STM32Cube Project. Select [Yes].

B_Subramanian_10-1769802273202.png

Alternatively, you can select [Setup STM32Cube project(s)] under STM32Cube Key Actions.

B_Subramanian_11-1769802273203.png

  1. The "Project Setup" tab opens, allowing you to configure your CMake project as a STM32Cube project. Under Board/Device, you can enter the part number that you are working with. For this example, you can enter NUCLEO-G071RB.

B_Subramanian_12-1769802273204.png

Once you select [Configure], the screen should look as below.

B_Subramanian_13-1769802273206.png

 

  1. Next, you should see a pop-up for selecting a launch configuration. Here, select [Debug].

B_Subramanian_14-1769802273206.png

If you do not see the dropdown menu, you can set the "Configure Preset" from the CMake tab.

B_Subramanian_15-1769802273208.png

B_Subramanian_16-1769802273208.png

Once the project is configured as below, it is possible to change the code and build the project.

B_Subramanian_17-1769802273209.png

 

  1. In this article, we simply toggle the LED connected to PA5. To do this, add the following 2 lines of code to the while loop in main.c
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);

HAL_Delay(100);

Once these lines are added, the main.c file should look like this:

B_Subramanian_18-1769802273210.png

  1. Build the project by selecting the [Build] option in the bottom left of the screen.

B_Subramanian_19-1769802273212.png

  1. Once the project is built, place any desired breakpoints and select [Run and Debug] in the Run and Debug tab on the left toolbar.

B_Subramanian_20-1769802273213.png

  1. A dropdown menu appears and here it is possible to select the debugger. For this example, we choose [STM32Cube: STLink GDB Server].

B_Subramanian_21-1769802273213.png

  1. After making that selection, the application will begin to run and pause at the initial breakpoint. Use the toolbar on the top to continue execution, pause execution, step into/over instructions, and terminate or restart the debug session.

B_Subramanian_22-1769802273215.png

 

Conclusion

Now, you have created an application using the updated STM32 VS Code extension v2.0.0 or newer. The same process can be applied to various STM32 MCUs and Nucleo boards. From this point, you can configure more peripherals, add additional user code, and create a more complex custom application.

Related links

 

 

Version history
Last update:
‎2026-04-20 7:00 AM
Updated by: