← Back to the chapter · Previous detail · Next detail →

Technical detail · Maintainable Firmware Practices

Resource limits and retained state

Backoff means waiting longer between retry attempts, up to a chosen limit, instead of retrying continuously. A ring buffer is a fixed-size queue that reuses space as data is read; define what happens when it fills. A heap budget sets how much dynamic memory a feature may use, so a long run does not exhaust memory. Test each limit with the link down or the buffer full.

A message framing error means a parser cannot find a valid message boundary or structure. A UART framing error has a narrower hardware meaning: the receiver detects an invalid stop bit. Record which error occurred and how the parser or device recovers.

Make limits visible before the demo hides them. MQTT reconnects need backoff and a give-up state. BLE GATT notifications need connection state and queue pressure. A CAN or UART parser needs framing error behavior. A LittleFS log needs full-storage and power-loss handling. An OTA package needs signature or hash verification, compatibility checks, health confirmation, and rollback evidence. The prototype may not solve every production case, but it should state each current limit and the exact condition that would make the evidence stale.

A state enum is a named set of possible modes, such as normal or sensor missing. A watchdog window is the allowed time for software to service a timer before it triggers recovery. Set the window so valid work can finish but a stuck task is detected.

Keep the handoff record short enough to use. A useful record can be a table with source revision, board revision, firmware version, dependency lockfile, build command, configuration profile, normal run, fault run, known limits, and next change condition. This prevents a later pilot from depending on a prototype whose credentials, calibration, retry policy, or update state cannot be reconstructed.

← Back to the chapter · Previous detail · Next detail →