Ewance
← All challenges Software Engineer

Port a Drone Flight Controller from Bare-Metal to FreeRTOS

Duration
4 weeks
Level
Advanced
Type
Code
Team
1 to 5 people

The situation

The startup (around EUR 4M ARR, 280 drones deployed) has had 2 near-crash incidents traced to control-loop jitter and cannot ship the next product line without a real RTOS.

Your task

Port a Cortex-M7 flight controller from a bare-metal super-loop to FreeRTOS and prove the 1 kHz control-loop deadline is met under worst-case load.

The brief

What you do

  1. Take the existing bare-metal firmware (STM32H7, around 14,000 lines C).
  2. Identify the tasks (control loop 1 kHz, IMU read 2 kHz, GPS 10 Hz, telemetry 50 Hz, command parsing event-driven, logging background).
  3. Assign priorities, stack sizes, and synchronization primitives.
  4. Use Rate-Monotonic scheduling theory for the priority assignment and document the schedulability analysis.
  5. Port to FreeRTOS, validate on the hardware-in-the-loop rig (provided), measure worst-case execution time (WCET) per task with a logic analyzer + cycle-accurate counter.

You deliver

Source code, the schedulability analysis, and a 10-page writeup including measured vs theoretical jitter.

What you will practice

  • Apply Rate-Monotonic scheduling theory to a real embedded task set
  • Port bare-metal firmware to an RTOS without regressing real-time behavior
  • Measure worst-case execution time with cycle-accurate instrumentation
  • Choose synchronization primitives (mutex, semaphore, queue) appropriate to each task interaction

A suggested way in

  1. Liu & Layland's 1973 RMS paper is still the canonical reference for the priority assignment
  2. Priority inversion is the usual FreeRTOS bug — use mutexes with priority inheritance, not semaphores
  3. Measure WCET on the hardware, not the simulator — cache effects matter

Skills you will practice

Freertos, Rate monotonic scheduling, C programming, Wcet analysis, Arm cortex m, Real time systems

How it is assessed

  • Schedulability analysis30%

    Task priorities + WCET budgets validated against Rate-Monotonic bound.

  • RTOS port quality25%

    Synchronization primitives chosen correctly; no priority inversion under test.

  • Measurement rigor25%

    WCET measured with logic analyzer + cycle counter on real hardware.

  • Writeup clarity20%

    Analysis is reproducible by another firmware engineer with the writeup alone.

Resources

  • FreeRTOSTool

    Target RTOS for the port — widely deployed and well-documented.

  • CTool

    Implementation language for firmware.

  • STM32CubeIDETool

    Vendor IDE with HAL drivers and debugging support.

  • TracealyzerTool

    RTOS-aware trace visualization for jitter analysis.

  • Saleae LogicTool

    Logic analyzer for WCET measurement via GPIO instrumentation.

  • NotionTool

    Author schedulability analysis and writeup.

Sample Ewance certificate of completion, verified by LearnCoin
Sample certificate
Your proof

Finish it. Earn this.

A verified certificate with your name. Anyone can check it.

Time to practice.

Solve this challenge
Related challenges

More like this.