Skip to main content
  • embedded

Telemetry Core

Embedded telemetry platform designed for STM32 Cortex-M microcontrollers. The project currently runs as a FreeRTOS simulation on PC and implements an event-driven Producer-Consumer architecture for sensor acquisition, telemetry processing, task synchronization, event handling, and communication.

Architectural Overview

Telemetry Core is an embedded software platform designed for ARM Cortex-M4 microcontrollers, specifically the STM32 family. It features a host-based simulation capability using FreeRTOS, enabling developers to build, test, and debug real-time software on a PC before flashing to bare-metal target hardware.

The system uses an event-driven Producer-Consumer architecture to handle sensor acquisition, signal processing, task synchronization, and outbound telemetry transport. By decoupling data producers (such as sensor drivers or simulated acquisition tasks) from data consumers (such as telemetry encoders and communication bus drivers), the system maintains high responsiveness and deterministic execution under real-time constraints.

+-----------------------------------------------------------------------------------+
|                                 FREE-RTOS RUNTIME                                 |
|                                                                                   |
|  +--------------------+     +-------------------+     +------------------------+  |
|  |   Producer Tasks   |     |    FreeRTOS ITC   |     |     Consumer Tasks     |  |
|  |  (Sensors/Sim Tasks) ---->  (Queues/Events)  ---->  | (Telemetry/Comms Task) |  |
|  +--------------------+     +-------------------+     +------------------------+  |
|           |                                                       |               |
+-----------|-------------------------------------------------------|---------------+
            v                                                       v
+-----------------------------------------------------------------------------------+
|                        HARDWARE ABSTRACTION LAYER (HAL)                           |
|                                                                                   |
|  +-------------------------------------+   +-----------------------------------+  |
|  |   STM32 Cortex-M4 Target (Native)   |   |   PC Hosted Simulator (POSIX/Win) |  |
|  +-------------------------------------+   +-----------------------------------+  |
+-----------------------------------------------------------------------------------+

Component Architecture

The software architecture is divided into logical subsystems that isolate hardware dependencies, real-time operating system (RTOS) primitives, and core business logic.

1. Hardware Abstraction Layer (HAL) & Platform Emulation

To support dual-target builds (native STM32 hardware and PC host simulation), Telemetry Core encapsulates low-level hardware access behind C++ driver interfaces.

  • Target Execution: Drives physical STM32 peripherals (UART, SPI, I2C, ADC) utilizing ARM Cortex-M4 hardware facilities such as DMA controllers and nested vectored interrupt controllers (NVIC).
  • Simulation Execution: Wraps POSIX or Windows system threads via the FreeRTOS host simulator port, replacing hardware interrupts with software timer callbacks or simulated I/O threads.

2. Producer Subsystem (Sensor Acquisition)

The producer layer consists of periodic or event-triggered RTOS tasks responsible for sampling data:

  • Reads physical inputs (e.g., accelerometers, temperature sensors, system health monitors) or simulated signal generators.
  • Normalizes raw peripheral readings into strongly-typed C++ telemetry structures.
  • Timestamps and packages data frames into bounded event messages.

3. Inter-Task Communication (ITC) & Event Dispatching

Data flow between producers and consumers is mediated by FreeRTOS synchronization primitives:

  • Message Queues: Thread-safe, fixed-size FIFO queues (QueueHandle_t) pass telemetry structs by value or via immutable pointer references, avoiding dynamic memory allocation during continuous operations.
  • Event Groups & Semaphores: Signal critical system events (e.g., sensor failure, buffer threshold reached, payload ready) across task boundaries without polling overhead.

4. Consumer Subsystem (Telemetry Processing & Transmission)

Consumer tasks execute asynchronously based on queue availability:

  • Processing: Evaluates incoming payloads for threshold violations, delta compression, or binary serialization (e.g., COBS framing or structured binary protocol packaging).
  • Communication: Dispatches finalized telemetry packages across target transport channels (e.g., USART, CAN bus, or simulated socket/stdout streams on PC).

Key Engineering Decisions

Dual Target Build Pipeline via CMake

The build system relies on CMake to manage cross-compilation toolchains and native host builds.

  • When targeted at physical hardware, CMake configures the arm-none-eabi-gcc toolchain, configuring hardware floating-point unit (FPU) flags (-mfpu=fpv4-sp-d16 -mfloat-abi=hard) and linking vector tables for the ARM Cortex-M4 core.
  • When configured for host simulation, CMake switches to the host compiler (GCC/Clang/MSVC) and links the FreeRTOS POSIX/Win32 simulator port. This allows automated unit testing and validation of the telemetry pipeline on CI/CD runners without needing physical hardware boards attached.

Modern Embedded C++ Paradigm

Telemetry Core leverages modern C++ while adhering to strict embedded guidelines:

  • Zero Dynamic Allocation at Runtime: All RTOS tasks, queues, semaphores, and memory pools are pre-allocated statically or instantiated during the system initialization phase to prevent heap fragmentation and non-deterministic allocation delays.
  • RAII and Type Safety: Object-oriented wrappers around FreeRTOS primitives (such as Mutex locks and Task handles) utilize Resource Acquisition Is Initialization (RAII) to ensure exception-safe lock release and clear ownership semantics.

Concurrency and Real-Time Performance

The system relies on prioritized preemptive scheduling provided by FreeRTOS:

  1. Interrupt Handling (ISR) Strategy: Hardware interrupts perform minimal work (reading registers, clearing flags) before pushing payloads to queues using xQueueSendFromISR and immediately yielding execution via portYIELD_FROM_ISR if a higher-priority task was woken.
  2. Task Prioritization:
    • High Priority: Critical event handlers and hardware interrupt service routines.
    • Medium Priority: Sensor acquisition tasks operating on precise timer periods.
    • Low Priority: Telemetry packaging, outbound communication, and background diagnostics.
  3. Deterministic Memory Bounds: Queue capacities are fixed at compile time. If a queue fills, producers handle backpressure either by blocking for a defined timeout (tickstoWait) or by logging an overrun flag, ensuring system stability under high data rates.

Architectural Inferences & Technical Evaluation

Based on the project structure and specified technologies, several design strategies can be inferred:

  • Observability & Testing: The ability to run the exact same FreeRTOS task logic on a PC host drastically accelerates software-in-the-loop (SIL) testing. Developers can mock telemetry inputs, simulate edge cases (such as queue overflows), and inspect task execution without an hardware debugger (e.g., ST-Link/JTAG).
  • Maintainability & Portability: Isolating the FreeRTOS kernel calls and hardware register access behind C++ abstractions simplifies porting Telemetry Core to alternative STM32 series (e.g., STM32F4 to STM32H7) or different microcontroller architectures with minimal changes to core processing logic.