Back to Home

Xbuild MCU for VSCode and STM32

Xbuild MCU extension for VSCode replaces STM32CubeIDE in embedded development. Supports project auto-generation, import from CubeMX, Xmake build and debugging. Ideal for teams with Git submodules and templates.

CubeIDE Replacement: Xbuild MCU in VSCode
Advertisement 728x90

Xbuild MCU: VSCode Extension for STM32 Project Builds

Embedded developers working with STM32 often struggle with clunky Eclipse-based IDEs like STM32CubeIDE. Enter Xbuild MCU, a VSCode extension that handles project autogeneration, Xmake-based builds (powered by Lua), CubeMX imports, and Cortex-Debug integration. It lets you edit, compile, and flash all in one seamless environment—no more app-switching.

This extension targets mid-to-senior developers: it sticks to precise technical terms, supports GCC/G++, JLink, and Git submodules. It's battle-tested on real projects but still actively evolving.

Creating and Initial Project Setup

Open an empty folder in VSCode. The extension spots the missing xmake.lua and prompts you to generate it. Pick an MCU preset (like STM32F103) and set your paths:

Google AdInline article slot
  • JLINK_PATH: Path to JLink.exe (e.g., c:/Programs/JLink_V872a/JLink.exe).
  • STM32_SDK: Path to ARM GCC from STM32CubeIDE (e.g., c:/ST/STM32CubeIDE_1.19.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.14.3.rel1.win32_1.0.0.202510090749/tools).

In the MCU section, add your defines and include paths. Hit "Reset to STM32F103 Defaults" to kick things off, then tweak for your project. Values pull straight from CubeIDE.

CubeMX import: Point to your .ioc file. It copies startup files, linker scripts, and HAL drivers. Your main.c and custom code stay untouched—perfect for custom setups.

Managing Git Submodules and Templates

In VSCode User Settings, list your corporate submodules. The extension adds one-click buttons to add/remove them.

Google AdInline article slot

For project structure, drop a templates folder in the root (best as a Git submodule). Generation creates folders, files, and defines from the template, then cleans it up.

It auto-generates .vscode/launch.json for Cortex-Debug.

Building, Optimization, and Analysis

Supports Debug/Release configs with optimization levels (-O0, -O1, -Os, -O2, -O3). Post-build, it shows Flash/RAM usage in percentages, just like ESP-IDF.

Google AdInline article slot

Dropdown lists optimizations with descriptions:

  • -O0: No optimizations, ideal for debugging.
  • -O1: Minimal optimizations.
  • -O2: Aggressive speed boosts.
  • -O3: Max speed, but tricky for debugging.
  • -Os: Size-focused optimization.

Doxygen installed? It'll generate project docs automatically.

Key Highlights

  • Autogenerates xmake.lua and .vscode/launch.json to cut manual setup.
  • Imports CubeMX files without overwriting your code.
  • Seamless Git submodules and templates for team workflows.
  • Memory usage analysis after every build.
  • Built-in Doxygen support for docs.

Not a one-size-fits-all tool: built for specific needs but extensible via Lua scripts and templates. For STM32 dev in VSCode, it's a lean CubeIDE alternative.

— Editorial Team

Advertisement 728x90

Read Next