Power-Loss Protection for Embedded Linux Devices

Power-Loss Protection for Embedded Linux Devices#

Embedded controller beside a power supply, capacitor bank, and oscilloscope on a bench

AI-generated engineering illustration.

Define What Must Survive A Cut#

For most embedded Linux appliances, start by defining the smallest set of state the system must preserve when external power disappears. Keep bootable software separate from mutable data. Use an application commit strategy whose durability assumptions you can test on the actual storage. Add power-fail detection and hold-up when the outcome depends on completing writes before the rails leave their operating range.

A device can boot successfully and still lose information it told a user it had saved. Put both conditions in the requirements. For example, specify that the device should restart without a service visit and that every acknowledged configuration change must survive. For buffered telemetry, the product may instead permit a documented loss window. The policy determines how much energy, storage, and software work the design requires.

Follow A Write To The Physical Device#

Application code, filesystem, block layer, storage controller, and flash media all contribute to durability. A journal can help restore filesystem consistency after an interruption. That property does not establish when the application data became persistent. In ext4’s ordered mode, data ordering and metadata journaling still leave application commit semantics to the program and storage stack. A database has its own transaction and synchronization settings. Confirm them against the behavior the product promises.

For small configuration files, a typical starting pattern is to write a replacement on the same filesystem, synchronize the file, and rename it into place. On Linux, persisting the updated directory entry may also require synchronizing the parent directory. Check each return value and keep a startup rule for missing, stale, or invalid state. Use the embedded storage selection guide to compare the physical media behind those operations.

If the storage part or board is sold with power-loss protection, ask what the claim covers. Clarify whether it protects internal flash mapping metadata, in-flight user data, or both. Check the exact part number, firmware, and supported operating conditions. Run durability tests again when the supplier substitutes a storage part. A successful flush request relies on the rest of the stack honoring it.

Budget Energy From The Detection Point#

Give the software a meaningful warning before a rail goes out of spec. Use the actual power tree, including the load that remains during shutdown and the rail limits for the processor and storage. Treat reset thresholds, supervisor delay, regulator dropout, conversion efficiency, capacitor tolerance, temperature and aging as part of the budget. A warning connected to Linux is only useful if the path can run soon enough under the workload the device is carrying.

For an initial estimate, a capacitor discharging from Vhigh to Vlow has ideal available energy of ½ × C × (Vhigh² − Vlow²). A hypothetical 10 mF capacitor falling from 12 V to 9 V has 0.315 J of ideal stored energy over that range. At an illustrative constant input load of 5 W, that is about 63 ms before practical losses and tolerances. It is a sizing example. Measure the actual available time at the rails and compare it with the worst observed commit time.

Where the product needs a guaranteed outcome, consider hardware that can stop or isolate nonessential loads as part of its approved design. Plan the remaining time around a short, bounded sequence. Stop accepting new critical writes, complete the transaction or flush that matters, and enter a defined state. Starting a normal system shutdown and hoping every service exits within the window gives little evidence about the storage endpoint.

Keep A Boot Path And A Way Back#

Exercise any A/B or rescue arrangement with cuts during download, installation, and the first health check on a new image. Choose which component decides a boot has succeeded and how it records that result. A boot counter can provide a mechanism to try another path, but the behavior depends on its configured backend and bootloader scripts. The secure boot and OTA recovery guide covers authenticated updates and the release policy around rollback.

Bring the supply back slowly and with repeated interruptions. A device may encounter brownouts that restart part of the power tree without providing a clean reset to every peripheral. Review precharge or recharge time, reset signals, and when the software can safely accept new transactions. Verify that a second cut immediately after startup does not create a new failure mode. If the device has a separate service processor, also check that the two sides agree which boot or session is current.

Use Power-Cut Tests That Reveal Lost Writes#

Cut point Check after restart
While idle and while logs are rotating Boot path, valid configuration, and understandable diagnostics
Before and after application acknowledgement Last acknowledged state, transaction identifiers, and permitted loss window
During an update and first attempted boot Valid boot selection, health confirmation, and remote service access
Repeated ramp or short interruptions Reset and storage state, behavior after a second cut, and absence of restart loops

Use a controllable supply or suitable fixture on the isolated design bench with the intended storage devices. Capture the input, relevant rails, power-fail indication, and application progress markers. Check the recovered data from outside the application where practical. Track cut timing, board and storage revisions, workload and outcome. Randomize the phase across multiple runs so a single clean shutdown path does not dominate the sample. Keep failure records that reproduce the conditions.

Also test a nearly full data partition and an aged or representative used storage device. Storage latency can change under writeback, garbage collection, or simultaneous activity, and the design should have a policy for the case where a commit cannot finish in time. Where maintenance writes are comparable to the appliance workload, add the cut test to factory image and provisioning acceptance. For devices that buffer data while offline, the industrial Linux gateway selection guide provides context for choosing what must be recovered from logs and queues after restart.

Agree on a way to detect silent loss. For example, have a separate recorder capture the last transaction the device acknowledged before the power cut. Compare that transaction with the recovered database or file after reboot. A health check alone can miss a durability failure.

FAQ#

Does a read-only root filesystem solve power loss?

It can reduce risks to the system image. Configuration, databases, an update slot, and boot metadata can still be writable. Test each writable path against the recovery requirements for the product.

How much hold-up time should I design for?

Measure the bounded sequence on the real stack across supply, temperature, storage state, and workload. Add a design margin derived from those conditions and verify with cuts on the intended hardware.

Source Notes#

Reviewed November 23, 2026. Primary references include the Linux kernel ext4 General Information documentation, Linux fsync manual, SQLite Atomic Commit and Powersafe Overwrite documentation, and U-Boot Boot Count Limit documentation. The capacitor example is illustrative and calculated from the stated assumptions. It is not a device measurement.