Split firmware into tasks with FreeRTOS, so the urgent job always runs on time. Eight lessons on the STM32 or ESP32 you already own, from a jitter test to the same project on Zephyr.
A controller reads its sensor on time in one cycle and a few milliseconds late in the next, and the motor runs rough. An emergency button is read only when a long loop reaches it. Two tasks use one I2C bus at the same moment and both read wrong data, now and then. A device passes every test on the bench and resets by itself after three weeks in the field.
In this course you build firmware that keeps its timing under load. You give each job a task and a priority, pass data through queues, share a bus through a mutex, keep interrupts short, and reserve all memory when the program is built. Then you find planted bugs with a trace tool, and move a project to Zephyr with no change to its behaviour.
How each lesson goes
1Start from a faultThe LCD takes 4 ms more, and every job in the loop comes 4 ms later.
2See how the RTOS does itEach task is Ready, Running, Blocked or Suspended, and the scheduler picks.
3Build it from tasksThree tasks joined by queues of 16 places, each at its own pace.
4Prove it with a traceA record of which task ran when, taken while the system runs.
You will be able to
Measure jitter, and split firmware into tasks with priorities that meet their deadlines
Pass data with queues, share buses with mutexes, and keep interrupts short
Find deadlocks, priority inversion and stack overflows with trace tools, and move a design to Zephyr
New to this? Know C on a microcontroller and new to an RTOS? Start with lesson 1: measure the jitter of a loop and of a task.
You need An STM32 Blue Pill with an ST-Link, or an ESP32 DevKitC, with the LEDs, buttons, potentiometer, OLED and BME280 of the earlier courses.
The engineering behind it
Several jobs on one chip, each on time, without missing a sample.
A task does not get its priority, its queue or its stack because it sounds right. Each number comes from a deadline or a measurement.
13.1 msone pass of a plain loop; when the LCD takes 4 ms more, the sensor read comes every 17.1 msTiming
Shortest periodgets the highest priority: the LED every 1 ms above the sensor every 5 ms, above the report every 20 msPriority
16 placesin each queue of the pipeline at 100 Hz, so a slow display does not lose a sampleQueues
50 msof quiet on a pin before a software timer counts the press; each bounce starts the 50 ms againInterrupts
30 bytes freein a 60 byte heap, and a request for 20 fails, because no two free blocks lie side by sideMemory
A lock protects the data. Its order and its owner decide the timing.
With no lock
Damaged data
Two tasks on one bus mix their bytes
Both get garbage, now and then
No error message
The test: is the fault rare and impossible to repeat?
With a mutex
Safe, if used right
One task holds the bus at a time
Priority inheritance stops a high task waiting behind a low one
The same order of locks everywhere, or a deadlock
The test: does the high task still meet its deadline?
Why FreeRTOS, then Zephyr
Runs on your boardSTM32, ESP32, RP2040 and hundreds more.
Priority schedulingThe most urgent ready task runs, at once.
Queues and mutexesData between tasks with no half-written values.
Static memoryEvery object reserved when you build, nothing requested while it runs.
Trace toolsSystemView or Tracealyzer record each task, microsecond by microsecond.
Zephyr for a new chipDrivers, networking and over 600 boards; pins in a devicetree.
Honest limits. The timing stays in the firmware: one task reads the sensor on a strict schedule and another sends the readings on, so a slow write or a network stop does not cost a reading. The device keeps every event before it sends them onward.
Before you start
C on an STM32 or an ESP32
GPIO, interrupts, I2C and a UART on that chip
An STM32 Blue Pill with an ST-Link, or an ESP32 DevKitC
A logic analyzer or oscilloscope helps in lesson 1, but is optional
Production firmware runs dozens of concurrent tasks: reading sensors, driving actuators, handling communication, managing power, and responding to user input, all with deterministic timing. A bare-metal super loop can handle a few of these, but it breaks down when tasks have conflicting timing requirements. This course teaches you to build concurrent firmware correctly using a Real-Time Operating System (RTOS). Each lesson builds a working RTOS application on hardware you already own from earlier courses. #RTOS #FreeRTOS #EmbeddedSystems
Why RTOS?
Beyond Super-Loops
Bare-metal main loops work until they do not. When you need sensor reads every 10ms, display updates every 50ms, and serial logging every 100ms, all without blocking each other, you need an RTOS. This course teaches you when and why.
Synchronization Done Right
Priority inversion, deadlocks, race conditions, and starvation. These are not textbook concepts; they are bugs that ship in real products. Lesson 4 gives you the mental models and practical patterns to avoid them.
Debug the Invisible
RTOS bugs are timing bugs. You cannot find them with printf. Lesson 7 teaches you to use Tracealyzer and SystemView to visualize task execution, find priority inversions, and measure jitter. This lesson alone is worth bookmarking.
Portable Skills
FreeRTOS runs on STM32, ESP32, RP2040, and hundreds of other platforms. Zephyr adds Linux-like abstractions with devicetree. These skills transfer across every embedded job.
Course Structure
Each lesson follows a consistent cycle:
The Concurrency Problem
A real scenario where bare-metal falls short. Multiple tasks that must coexist with timing guarantees.
RTOS Theory
The kernel mechanism that solves this problem: how it works internally, its guarantees, and its costs.
FreeRTOS Implementation
Build the solution on real hardware. Write tasks, configure the kernel, and handle edge cases.
Test and Break It
Deliberately create failure conditions (deadlock, priority inversion, stack overflow) to understand the theory viscerally.
Design Patterns
Reusable patterns for production firmware. When to use each primitive, and when simpler solutions are better.
Lessons
Lesson 1: Real-Time Systems Concepts
Real-Time Systems Concepts. Define hard, soft, and firm real-time. Measure jitter in bare-metal loops vs RTOS tasks. Understand worst-case execution time, scheduling theory, and rate-monotonic analysis. Build a jitter measurement rig.
Build: Jitter measurement rig. Hardware: STM32 Blue Pill or ESP32 (from prior courses), LED.
Lesson 2: Tasks, Scheduling, and Context Switching
Tasks, Scheduling, and Context Switching. Explore task states, priority-based preemptive scheduling, time slicing, and the task control block. Understand stack allocation and context switch overhead. Build a priority-based traffic light controller.
Build: Traffic light controller. Parts: 3 LEDs (red, yellow, green), 2 push buttons.
Lesson 3: Queues and Inter-Task Communication
Queues and Inter-Task Communication. Implement message queues, stream buffers, and event groups for passing data between tasks. Producer-consumer patterns, queue sizing, and blocking vs non-blocking sends. Build a sensor data pipeline with filtering.
Build: Sensor data pipeline. Parts: Potentiometer, SSD1306 OLED (reuse from prior courses).
Lesson 4: Semaphores, Mutexes, and Synchronization
Semaphores, Mutexes, and Synchronization. Master binary and counting semaphores, mutexes with priority inheritance, and deadlock avoidance strategies. Build a multi-sensor I2C coordinator with mutex-protected bus access.
Build: Multi-sensor I2C coordinator. Parts: BME280 + one other I2C sensor (reuse from prior courses).
Lesson 5: Memory Management and Safety
Memory Management and Safety. Compare FreeRTOS heap allocation schemes (heap_1 through heap_5). Implement static allocation, memory pools, and stack watermarking. Explore MPU-based memory protection. Build a memory-safe command processor.
Build: Memory-safe command processor. Parts: Reuse existing.
Lesson 6: Software Timers and Interrupt Management
Software Timers and Interrupt Management. Configure software timers, deferred interrupt processing, and ISR-safe API calls. Understand critical sections, interrupt nesting, and the timer service task. Build a debounced multi-button input system.
Build: Debounced multi-button input system. Parts: 4 push buttons, LEDs.
Lesson 7: Debugging and Profiling RTOS Applications
Debugging and Profiling RTOS Applications. Use Tracealyzer or SystemView to visualize task execution in real-time. Measure CPU load, detect stack overflows, find priority inversions, and profile queue throughput. Receive intentionally buggy RTOS firmware and diagnose every issue.
Build: RTOS bug hunt (deadlock, priority inversion, stack overflow). Parts: Reuse existing.
Lesson 8: Zephyr RTOS Introduction
Zephyr RTOS Introduction. Set up the Zephyr build system with west. Learn devicetree, Kconfig, and Zephyr’s threading model. Port the traffic light controller from Lesson 2 to Zephyr and compare the two RTOS approaches.
Build: Traffic light controller on Zephyr. Parts: Same as Lesson 2.
Hardware
No new purchases needed. This course uses hardware from the ATmega328P, STM32, or ESP32 courses:
Part
Source
Used In
STM32 Blue Pill + ST-Link (or ESP32 DevKitC)
STM32 or ESP32 course
All lessons
LEDs (red, yellow, green) + resistors
ATmega328P course
Lessons 1, 2, 6, 8
Push buttons + 10K resistors
ATmega328P course
Lessons 2, 6, 8
Potentiometer
STM32 course
Lesson 3
SSD1306 OLED display
ATmega328P or STM32 course
Lesson 3
BME280 sensor
ATmega328P or STM32 course
Lesson 4
If you have completed any of the previous embedded courses, you already have everything.
Skill Progression
Skill
Lessons 1-2
Lessons 3-4
Lessons 5-6
Lessons 7-8
Kernel
Scheduler, task states, preemption
Queues, semaphores, mutexes
Heap schemes, timers, ISR integration
Trace tools, Zephyr kernel
Patterns
Task decomposition, priority assignment
Producer-consumer, resource sharing
Static allocation, deferred processing
Profiling, cross-RTOS portability
Debugging
Jitter measurement
Queue overflow detection
Stack watermarking, MPU faults
Tracealyzer, SystemView
Failure Modes
Missed deadlines, starvation
Deadlock, priority inversion
Heap fragmentation, stack overflow
All combined in bug hunt
Prerequisites
Complete at least one prior embedded course
You should be comfortable with:
Embedded C programming (registers, interrupts, peripheral drivers)
At least one microcontroller platform (STM32 recommended, ESP32 also works)
FreeRTOS basics from STM32 lesson 8 (this course goes much deeper)
Basic understanding of operating system concepts (processes, threads, scheduling)
Getting Started
Use your STM32 Blue Pill or ESP32 DevKitC from a previous course. Both run FreeRTOS.
Gather LEDs, buttons, and sensors from your existing parts kit. No new purchases needed.
Install Tracealyzer (free trial) or SEGGER SystemView (free) for lesson 7. Optional for earlier lessons.
Start with Lesson 1. The jitter measurement rig gives you an immediate, visceral understanding of why RTOS matters.
Break things deliberately. Each lesson includes a section where you intentionally create failure conditions. This is where the deepest learning happens.
Made by
Engineers and researchers who build what they teach.