First project creation ¶
There are several ways to get started. Go to the chapter that best matches your use case:
Quick path selection ¶
|
Starting point |
Recommended path |
Expected result |
First check |
|---|---|---|---|
|
No existing project |
New CMake project is generated |
Project folder opens in Visual Studio Code |
|
|
Existing STM32CubeMX project |
Existing configuration is imported |
Project setup is completed successfully |
|
|
Existing STM32CubeMX2 project |
Existing configuration is imported |
Project setup is completed successfully |
|
|
STM32Cube firmware example |
Example is extracted and configured |
Project folder opens in Visual Studio Code |
|
|
STM32CubeIDE for Eclipse project conversion |
STM32CubeIDE for Eclipse project is imported and configured |
Project folder opens in Visual Studio Code |
|
|
STM32 CMake project |
STM32 CMake project |
Project setup is completed successfully |
Use the path above first, then continue with the related procedure.
Creating an empty project gives developers full control and flexibility. Developers can customize the environment, avoid unnecessary components, and optimize workflows. This approach is ideal for learning, experimentation, and creating scalable, maintainable code. It also fosters a deeper understanding of project setup.
Importing a project from STM32CubeMX provides a quick and efficient way to start development with preconfigured peripherals, clock settings, and middleware. This method ensures best practices, enhances code reliability, and integrates seamlessly with STM32CubeIDE for Visual Studio Code to simplify debugging and project management.
Importing a project from STM32CubeMX2 provides a quick and efficient way to start development with preconfigured peripherals, clock settings, and middleware. This method ensures best practices, enhances code reliability, and integrates seamlessly with STM32CubeIDE for Visual Studio Code to simplify debugging and project management.
Importing an example project from STM32Cube Embedded Software into Visual Studio Code provides a quick start with preconfigured functional applications including settings, peripherals, and middleware. These projects save time, follow best practices, and serve as valuable learning tools. Developers can focus on application-specific features and accelerate development.
Importing a project from STM32CubeIDE for Eclipse provides a quick start into Visual Studio Code from an existing Eclipse project.
Importing an STM32 CMake project from a community repository or other source into Visual Studio Code provides a streamlined way to start development with preconfigured build settings.
Create empty project ¶
- Step 1: Initiate project creation
-
First, open the STM32CubeIDE for Visual Studio Code extension by clicking the STM32CubeIDE for VS Code butterfly icon in the Activity Bar. Click the “Create empty project” button to start setting up a new project.
- Step 2: Name the project
-
Enter a name for the project.
- Step 3: Select project type
-
Choose whether the project targets a device or a board. This selection determines the specific hardware configuration for the project.
- Step 4: Choose the target
-
Select the correct target from the drop-down menu. This configures the project for the specific STM32 device or board.
- Step 5: Define project location
-
Select the directory where the project files will be saved.
- Step 6: Select toolchain
-
Select the toolchain to use. The toolchain determines the set of tools and libraries for building and managing the project. By default, GCC is selected. After selecting the toolchain, click “Create project” to continue.
- Step 7: Open project
-
- Visual Studio Code prompts you to choose how to open the new project. The options are:
-
Open in this window. Reuses the current instance of Visual Studio Code.
Open new window. Opens a new instance of Visual Studio Code.
Add to workspace. Adds the project to the current instance of Visual Studio Code (multiple projects in parallel).
- Step 8: Select CMake preset
-
Select the CMake preset (Debug or Release) and build configuration for the project.
By following these steps, you create an empty project in the STM32CubeIDE for Visual Studio Code extension, ready for development.
Import STM32CubeMX project ¶
- Step 1: Initiate project creation
-
Open STM32CubeMX standalone and click File > New Project to start setting up a new project.
- Step 2: Choose the target
-
Choose whether the project targets an MCU/MPU or a board. After selecting the device, click Start Project.
- Step 3: Select toolchain
-
Enter a project name and select CMake as the toolchain/IDE.
To open in Visual Studio Code, see the Open in VS Code.
Import STM32CubeMX2 project ¶
- Step 1: Initiate project creation
-
Choose whether the project targets an MCU/MPU or a board. After selecting the device, click Start Project.
- Step 2: Generate the Project
-
Select CMake as the format.
To open in Visual Studio Code, see the Open in VS Code.
Import example project ¶
- Step 1: Get the examples catalog
-
First, open the STM32CubeIDE for Visual Studio Code extension by clicking the STM32CubeIDE for VS Code butterfly icon in the Activity Bar. Click the “Import STM32Cube Example(s)” button to get the examples catalog.
- Step 2: Look at available resources
-
Make the one(s) of your choice local.
Step 3: Point your local folder hosting examples
Step 4: Select example to import
- Step 5: Select folder for extraction
-
Select the folder where the project is exported for use in Visual Studio Code.
Convert STM32CubeIDE for Eclipse project ¶
- Step 1: Get STM32CubeIDE for Eclipse to CMake converter
-
First, open the STM32CubeIDE for Visual Studio Code extension by clicking the STM32CubeIDE for VS Code butterfly icon in the Activity Bar. Click the “Convert Eclipse STM32CubeIDE project” button.
Step 2: Promote source and destination folders
Open in VS Code ¶
- Step 1: Open folder
-
Open the newly created project in Visual Studio Code. Go to File and select Open Folder….
Tip
The selected folder must contain the top-level CMakeLists.txt file as a direct child.
- Step 2: Select configure preset
-
After opening the project, select a configure preset. In this guide, “Debug” is selected.
- Step 3: Setup the STM32Cube project
-
Accept the notification.
Tip
If notification missed or not popping up, to make CMake aware of the project, go to the STM32CubeIDE for Visual Studio Code extension and click Set Up STM32Cube project(s).
- Step 4: Project Configuration
-
Select the board or device, toolchain and project to target. Because this guide uses a single-core board, select the main project. After making selections, click Save and close.
Tip
Step 4 is optional If the project is already correctly set up, this step can be skipped. Starting from STM32CubeMX or STM32CubeMX2 setup is done under the hood.
The output log should look similar to the following:
If the output log matches, the project is ready to build. Refer to the Build guide for instructions.