Porting FreeRTOS to STM32 From Scratch
A low-level STM32 RTOS path for developers who already understand the CMake workflow, startup code, linker scripts, interrupts, timers, and small firmware boundaries, and now want to see what an RTOS port actually connects.
AdvancedDifficulty
12Articles
STM32L433Primary hardware
12 lessons, in order
01
Why Port FreeRTOS Yourself?
Understand why manually porting FreeRTOS to STM32 is useful when you want to learn the scheduler, interrupt, stack, and build-system boundaries instead of treating the RTOS as generated project code.
02
Preparing an STM32 CMake Project for FreeRTOS
Prepare an existing STM32 CMake project for FreeRTOS by choosing source layout, configuration locations, include boundaries, and build ownership before adding kernel files.
03
Adding FreeRTOS Source Files to the Build
Add the FreeRTOS kernel, Cortex-M portable layer, heap implementation, and include paths to an STM32 CMake project without hiding what each file contributes.
04
Understanding the FreeRTOS Portable Layer
Understand what the FreeRTOS portable layer does on STM32, including stack setup, scheduler startup, critical sections, and Cortex-M exception-based context switching.
05
Configuring FreeRTOSConfig.h for STM32
Configure the FreeRTOSConfig.h settings needed for first STM32 scheduler bring-up, including tick rate, CPU clock assumptions, priorities, assertions, allocation, and minimal kernel features.
06
Setting Up the SysTick Timer for the RTOS Tick
Connect the FreeRTOS scheduler tick to the Cortex-M SysTick timer on STM32 and understand how tick rate, CPU clock, interrupt priority, and delay timing fit together.
07
Wiring PendSV and SVC for Context Switching
Wire the Cortex-M PendSV and SVC exception handlers used by the FreeRTOS port so the scheduler can start the first task and switch task contexts on STM32.
08
Creating the First FreeRTOS Tasks on STM32
Create minimal FreeRTOS tasks on STM32, start the scheduler, and verify that task switching is working without adding unnecessary application complexity.
09
Debugging the FreeRTOS Scheduler Bring-Up
Debug common FreeRTOS scheduler bring-up failures on STM32, including failed task creation, default handler traps, missing ticks, stack problems, priority mistakes, and assertions.
10
Using Queues and Delays Without Breaking Timing
Use FreeRTOS queues and delays on STM32 while keeping timing, blocking behavior, queue capacity, and ISR boundaries explicit.
11
Moving Peripheral Work into FreeRTOS Tasks
Move STM32 peripheral work into FreeRTOS tasks without turning every driver into an RTOS dependency or hiding timing and interrupt boundaries.
12
When to Use Bare Metal, HAL, or FreeRTOS on STM32
Choose between a simple bare-metal loop, STM32 HAL callbacks, project-specific drivers, and FreeRTOS tasks based on timing, complexity, concurrency, debugging cost, and firmware structure.