Reliability is not a checkbox you add at the end of a firmware project. It is an outcome of dozens of small, deliberate choices across power, boot, timing, logging, update strategy, and validation. If you are building embedded systems that live in the real world rather than a lab bench, the stakes are simple: you either engineer for failure up front, or you pay for failure in the field.

This playbook is a practical checklist I use to keep firmware systems stable over time. It is not theory. It is a set of design decisions, tradeoffs, and tests that reduce support load, prevent brick states, and keep systems recoverable under ugly conditions.

1. Power and Reset Behavior Must Be Deterministic

The majority of firmware failures I see originate in power and reset chaos. A clean power cycle on the bench is not representative of brownouts, noisy supplies, or users repeatedly power cycling in frustration.

Focus areas:

  • Brownout detection: Enable BOR and set thresholds appropriate to your MCU and supply. If the supply is unstable, do not run in the gray zone.
  • Reset reason logging: Always capture reset_cause in a persistent register or small flash area. It tells you if the system is bouncing due to watchdog, power, or external reset.
  • Startup sequencing: Delay peripheral initialization until power rails and clocks are fully stable. Avoid racing early I2C or SPI transactions.

Actionable check: simulate rapid on-off cycling and verify the system returns to a valid known state every time, with clear reset reason telemetry.

2. Boot Strategy: Make Recovery Easy, Not Optional

Every device eventually needs a recovery path. Assume failures: corrupted firmware, partial updates, or a bad configuration. Recovery must be a first-class state, not a hidden escape hatch.

Baseline requirements:

  • Fail-safe boot: Keep a bootloader that can verify firmware integrity and reject corrupt images.
  • Dual image or A/B: If flash allows it, store a known-good and allow rollback.
  • Watchdog-aware boot: If you reset during boot twice, do not keep looping. Drop to safe mode.

Actionable check: corrupt the application image and confirm the device still boots to a recovery mode and accepts an update.

3. Watchdogs Are Only Useful When You Feed Them Carefully

A watchdog that never triggers is useless. A watchdog that triggers all the time is also useless. The goal is a watchdog that recovers from real deadlocks without masking logic errors.

Best practices:

  • Feed from a heartbeat task: Do not feed the watchdog from the main loop or ISR. Use a scheduled task that only feeds when critical subsystems are alive.
  • Include liveness checks: Require a few flags or counters from key subsystems before feeding.
  • Log pre-reset state: Store minimal “last known state” to nonvolatile memory for post-mortem.

Actionable check: intentionally hang the scheduler or lock a mutex and confirm watchdog recovery is clean and logged.

4. Logging Must Survive Crashes

Logs are useless if they vanish after a reset. Persist just enough data to understand failure patterns without filling flash.

Minimum viable logging:

  • Ring buffer in RAM: Useful during development.
  • Crash snapshot to NVM: Store a small crash record: reset reason, last state, error code, and a few counters.
  • Rate limiting: Protect flash from wear by limiting persistent logs.

Actionable check: trigger a crash, reboot, and verify that the crash record is still readable and explains the failure.

5. Updates Must Be Atomic and Verifiable

If your update process can leave a device bricked after a power loss, it will happen in the field. Update logic must be atomic and always revertible.

Checklist:

  • Checksum or signature validation: Validate before switching to new firmware.
  • Staged update: Download to a staging area and only then switch.
  • Rollback window: Require the new firmware to “confirm” itself before you delete the old one.

Actionable check: interrupt power mid-update and verify the system boots a valid image without manual intervention.

6. Timing and Scheduling: Avoid Jitter-Driven Bugs

Hard-to-reproduce bugs usually come from timing assumptions. Interrupt load and scheduling jitter change in real conditions.

Tactics:

  • Budget CPU headroom: Aim for 30 percent free CPU, not 5 percent.
  • Instrument latency: Measure ISR and task latencies under load.
  • Stress test with worst-case I/O: Max out BLE, UART, sensors, and storage simultaneously.

Actionable check: enable synthetic load and verify task deadlines are still met.

7. Configuration Robustness

Config corruption is common when users can update settings or when storage is noisy. Make config resilient by default.

Suggestions:

  • Versioned configs: Include versioning and migration.
  • Defaults baked in: If config is missing or corrupt, recover automatically.
  • Checksums: Detect corruption and fall back.

Actionable check: corrupt config bytes and confirm the device falls back to defaults without crashing.

8. Telemetry Is Not Optional

If you cannot measure the system in the field, you cannot improve it. Even a minimal telemetry channel is better than zero visibility.

Minimum telemetry signals:

  • Reset reason and boot counts
  • Error counters for key subsystems
  • Update success and rollback events

Actionable check: review telemetry after a stress test and confirm it reflects what you observed.

9. Validate Under Real-World Conditions

Bench tests are necessary but not sufficient. Real-world conditions are noisy and chaotic.

Test scenarios:

  • Low voltage and brownouts
  • Temperature extremes
  • RF interference
  • Long idle periods
  • Power cycling by impatient users

Actionable check: set a 72-hour soak test with random power cycles and log stability metrics.

10. Keep the System Simple

The most reliable systems are boring. If a feature adds complexity without clear value, cut it or gate it behind a stable platform.

Questions to ask:

  • Can this be removed or deferred?
  • Does this introduce a new failure mode?
  • Is the benefit worth the added surface area?

Actionable check: do a failure mode review once per release and remove any feature that adds risk without proportional value.


Summary Checklist

If you do nothing else, implement these:

  1. Brownout detection and reset reason logging
  2. Boot recovery path and firmware integrity checks
  3. Watchdog driven by real system liveness
  4. Crash snapshot persisted to NVM
  5. Atomic updates with rollback

This set alone removes most catastrophic failures and makes the rest diagnosable.

If you want, I can share a reference implementation of a minimal bootloader state machine and a lightweight crash logger that works on most Cortex-M targets.

Comments are powered by GitHub Discussions.