ChebbiOS

Modern Embedded Architecture

Moving beyond the Super Loop: RTOS, HALs, and the separation of concerns.

The days of writing everything in a single main.c file are over. Modern embedded systems are expected to handle Wifi, Bluetooth BLE, complex sensors, and OTA updates simultaneously. This requires a robust architecture.


1. The Evolution

The Super Loop
Bare Metal

while(1) { check_sensor(); update_led(); }

Simple, deterministic, but blocks easily. Impossible to scale.

STANDARD
RTOS
FreeRTOS / Zephyr

Preemptive multitasking. Tasks (Threads) communicate via Queues and Semaphores.

Embedded Linux
Yocto / Buildroot

Full OS. Memory management (Scaling), Filesystems, Drivers. High overhead but immense power.

2. Decoupling Hardware (HAL)

A modern firmware architecture separates the Business Logic from the Hardware.

  • Application Layer: "Send telemetry every 5 minutes." (Doesn't care if it's Wifi or LoRa).
  • HAL (Hardware Abstraction Layer): standard interfaces like network_send() or gpio_set().
  • BSP (Board Support Package): The dirty code that actually toggles the registers for a specific STM32 or ESP32 chip.
Business Logic (Pure C/C++/Rust)
Interface (HAL Traits / Virtual Functions)
Driver: STM32
Driver: NRF52

3. Modern Event-Driven Design

Instead of polling ("Are we there yet?"), modern systems are Interrupt Driven.

  • Interrupt (ISR): The hardware wakes up the CPU. "Hey, Data arrived!"
  • Deferred Work: Do NOT process data in the ISR. Flag a semaphore or send a message to a Queue.
  • Event Loop: The main thread wakes up, processes the message, and goes back to sleep (Low Power).

Connect & Discuss

Have questions about systems engineering, or found a bug in the code? Reach out!

Feedback

This blog is a static site, but I'd love to hear your thoughts. You can discuss this post by sending me an email or reaching out on social media.

Send Feedback