Build STM32 firmware with CMake
Learn how STM32 firmware is built by putting the pieces together yourself. You’ll start with CMake and the Arm GNU toolchain, then explore startup, memory layout, CMSIS, and the STM32 HAL. As the build takes shape, you’ll move from compiling code to flashing a working application on a board.
By the end, you’ll have a working LED blink and understand the compiler, startup, linker, and vendor support that went into building it.
Why use CMake?
STM32CubeIDE offers a convenient way to develop and debug firmware. This course takes a command-line route so you can see how sources, compiler settings, startup code, and the linker work together. It also gives you a build you can run outside an IDE, including in CI.
This isn’t about avoiding ST’s tools. It’s about learning the build well enough to use those tools confidently—and to investigate problems when a generated project doesn’t work as expected.
Lessons
Take them in order- How STM32 Firmware Goes from Source to BoardSee how an STM32 project goes from board configuration to running firmware, and why we'll learn its CMake build step by step.Start here
- A Minimal Cross-Compiled CMake Project for STM32Create a minimal CMake project that cross-compiles C for an STM32 and inspect the object file it produces.
- What Runs Before main() on an STM32?Explore the Cortex-M reset path by compiling a small startup routine alongside C code.
- Link STM32 Firmware into Flash and RAMUse a linker script to turn Cortex-M object files into an ELF and inspect its memory layout.
- Add CMSIS and the STM32 HAL to a CMake ProjectBuild an STM32L433 ELF with the complete device startup, CMSIS, and only the HAL sources needed for initialization.
- Blink the LED and Flash the STM32 BoardConfigure PB13 as a GPIO output, build a blinking STM32L433 program, and flash it through ST-LINK.