Firmware

Choosing between bare-metal and an RTOS for your next project

Most embedded projects do not need a real-time OS. Here is how to decide whether one would actually help yours — and what you give up if you add one.

Pogot Studio Engineering · 2025-11-14 · 7 min read

Choosing between bare-metal and an RTOS for your next project

When starting a new microcontroller project, one of the first architectural decisions is whether to write bare-metal code (a main loop with interrupts) or use a Real-Time Operating System (RTOS) like FreeRTOS, Zephyr, or ThreadX.

1. The Bare-Metal Approach

Bare-metal programming means running directly on hardware without an OS abstraction layer. Everything happens in main() or interrupt service routines (ISRs).

Advantages

  • Determinism and simplicity: You know exactly what code executes at any microsecond.
  • Minimal RAM/Flash footprint: No task stacks or RTOS kernel overhead (saving 5KB–20KB RAM).
  • Easier debugging: No task switching state to inspect in GDB or J-Link.

When bare-metal shines

When your MCU handles single-purpose control loops (e.g. power converters, motor drives, basic UART/SPI bridges) or battery-powered sensor nodes that spend 99% of time in deep sleep.


2. When to transition to an RTOS

As embedded applications grow, managing state machines in a single main loop becomes messy. An RTOS provides preemptive multitasking, queues, semaphores, and timers.

Key triggers for an RTOS

  1. Multiple communication stacks: E.g., running BLE + Wi-Fi + USB concurrently while reading sensors.
  2. Strict multi-rate timing: Tasks requiring independent 1ms, 10ms, and 100ms periodic execution.
  3. Complex blocking I/O: Reading flash storage or waiting for network responses without stalling control loops.

Summary Checklist

CriteriaBare-metalRTOS
RAM available< 16 KB> 32 KB
ConcurrencySequential / ISRsMulti-threaded
Development SpeedFast initiallyScales better on large teams
Power ManagementManual sleep enterBuilt-in tickless idle