← Back to the chapter · Previous detail · Next detail →
Technical detail · Maintainable Firmware Practices
Retain evidence across a restart
Use low-cost signals first: reset reason registers, monotonically increasing boot counters, queue high-water marks, publish retry counters, last-fault enums, firmware semantic version, git SHA or build ID, configuration schema version, OTA image slot, rollback reason, and compact timing measurements. On an ESP32, that may include NVS keys, partition table, FreeRTOS stack high-water marks, and esp_reset_reason output. On Nordic or STM32 targets, it may include retained RAM flags, watchdog cause, flash-log sequence numbers, and power-profile notes from a shunt or power profiler.
- Timing boundary: avoid blocking sensor, control, watchdog, update, and local fallback work behind a network request, delay loop, or long synchronous flash write.
- Storage boundary: handle full queues, corrupt records, schema migration, flash wear, power loss during write, and replay after reconnect as first-class behavior.
- Update boundary: verify signed image, compatibility check, staged rollout, health check, rollback, boot-count limit, and preserved configuration before handoff.
- Support boundary: make field diagnosis possible with compact logs, counters, version reports, fault codes, and a local reset path that does not erase the only useful evidence.