← Back to the chapter · Previous detail · Next detail →
Technical detail · Firmware Architecture Patterns
Target measurements and update recovery
Heap memory is the pool used for allocations at run time. DNS translates a server name to an address. A memory watermark records an extreme, but its meaning depends on the API. For example, ESP-IDF’s heap low watermark is the smallest amount of free heap since boot. A falling value shows that less free heap remained at some point; it does not directly report peak bytes used. A stack high-water mark records an extreme of task stack use or remaining space; check the API meaning and units. Use it to decide whether a task has enough room under the tested load; repeat the measurement when its work or stack allocation changes. On an ESP32 or STM32 target, useful under-the-hood evidence includes maximum loop duration, watchdog reset reason, heap-watermark trend, queue depth, stack high-water mark, publish retry count, and the specific fault that forced a state transition. On a Nordic nRF52840 or other low-power node, include wake reason, radio association time, sample-to-publish duration, and current profile. On a Linux gateway, include service restart behavior, systemd unit state, persistent queue size, and what happens when DNS or the broker is unavailable.
A settings schema describes the stored configuration format; migration converts old settings when a new version needs a different format. An image slot is a place to store a firmware version. Bootloader confirmation marks the new image as accepted after it starts successfully; rollback returns to a usable earlier image if the new one is not confirmed or fails under the chosen policy. A failed settings conversion can also prevent recovery, so test it with the rollback path. Architecture also shapes update safety. If configuration migration, OTA download, bootloader confirmation, and rollback policy are hidden inside unrelated application code, a partial update can leave the prototype in an unclear state. Separate the update boundary early enough that later OTA work can check image slot, firmware version, schema migration, rollback trigger, and safe fallback behavior without untangling every driver and publisher.