Skip to content

Quick Start: STM32 Development in VS Code

We use Visual Studio Code (VS Code) to keep our C/C++ workflow lightweight, fast, and highly customizable compared to traditional IDEs.

1. Tooling Setup Checklist

Before pulling any project repositories, you need the base environment configured.

Install VS Code

Download and install Visual Studio Code for your operating system. It will serve as our primary editor for everything from firmware to DBC database management.

Install the STM32 Extension

To bridge VS Code with our STM32 hardware and build tools, we use a dedicated extension:

  1. Open VS Code and navigate to the Extensions view (Ctrl+Shift+X).
  2. Search for STM32CubeIDE for Visual Studio Code in the Marketplace.
  3. Click Install.
  4. Prerequisite: Ensure you also install the official C/C++ Extension Pack by Microsoft for standard IntelliSense, code navigation, and syntax highlighting.

Install the C/C++ Guard Extension

To add guards to header files (#pragma once style, but ISO standard), we use this extension with specific settings:

  1. Install the C/C++ Include Guard extension by Akira Miyakoda
  2. Right click on it and pick Settings and copy these settings Settings 1Settings 2

2. Project setup

DANGER

When opening an STM32 project for the first time, you will be asked to choose between a build or debug configuration. DO NOT CLICK ANYTHING UNTIL THAT WINDOW SHOWS UP AT THE TOP (can be set up later but it's easier this way). Choose debug. When prompted to configure CMake for an STM32Cube project in the bottom right, click Yes.

Example Video

3. Interface Overview

Once the tools are installed and you open one of our firmware repositories, VS Code adapts for embedded development. Here is how you will interact with the IDE daily:

UI Elements

  • STM32 Panel (Activity Bar): Look for the STM32 icon on the far left. Clicking this opens a dedicated view where you can manage build configurations, clean the project, and flash code directly to the microcontrollers via ST-Link. tutorial bar image
  • Explorer view: Your standard file tree. This is where you'll write the application logic, configure RTOS threads, and manage peripheral initializations.
  • Status Bar (Bottom): Provides quick-access buttons to Build, Flash, and Debug. It also displays your currently selected build target. status bar image
  • Run and Debug (Ctrl+Shift+D): Where you can enable/disable breakpoints and monitor register values or memory spaces while the board is running. You also have the (Live) Watch sections, where you can see the specific values/expressions you set while the debugger is connected.

Live Watch Config

TIP

To enable live watch, you have to create a launch.json file (from the debugging tab usually) and add the following to the array:

json
"liveWatch": {
   "enabled": true,
   "samplesPerSecond": "20"
}

4. Repo Layout

Our firmware repositories are typically structured around the specific hardware modules they control (e.g., the Power Distribution Module or the Accumulator BMS). A standard repo includes:

  • Core/: Contains the main application logic, ThreadX initializations, and our custom code.
  • Drivers/: ST's HAL libraries and low-level system files. The common library also sits here if necessary (most likely).
  • .github/: Contains workflows that reference ORG wide workflows. Copy from other repos, but they should be set up for you already.

Next Steps

Now that your editor is ready, proceed to the following tutorials to learn our standard practices for programming the racecar:

TIP

Always make sure you have the relevant Altium schematics open when assigning pins or writing new peripheral drivers.

Released under the MIT License.