Embedded Systems · 2025
ESP32 Deterministic Control Firmware
Firmware rewrite for a jitter-sensitive control loop: fixed-period scheduling, ring-buffered I/O and watchdog recovery.
Context
Original firmware used delay-based timing and blocking writes. Loop period varied by tens of milliseconds under load, producing visible actuator jitter.
Method
Control loop moved onto a fixed-period FreeRTOS task with absolute deadlines. Peripheral I/O became interrupt-driven into ring buffers consumed by the task. Blocking paths were removed from the critical section.
A hardware watchdog with staged recovery handles lock-ups: first task restart, then full reset with a persistent fault counter.
Outcome
Loop period variance collapsed to single-digit microseconds. Sustained operation over multi-hour soak tests showed no deadline misses and clean watchdog behaviour on induced faults.
Notes
Deadline compliance depends on keeping the ISR budget small; that constraint is documented in the source headers.