Electron Labs All articles
Design & Reliability

Retry Until It Works: How Defensive Firmware Conceals Hardware That Has No Margin Left

Electron Labs
Retry Until It Works: How Defensive Firmware Conceals Hardware That Has No Margin Left

Photo: embedded firmware engineer reviewing code on screen with microcontroller board connected, via www.nybg.org

There is a specific kind of product that never crashes and never quite works. It boots on the second attempt. Its radio associates after a retry. Its sensor reading is corrected by a calibration routine that runs every four hours because the offset drifts. Its watchdog fires roughly once a week on units in the field, and nobody has opened the log because the device recovers before the user notices.

Every one of those mechanisms is good engineering in isolation. Together they form an alibi.

The Case for Defensive Firmware

Start with the fair version of the argument. Embedded systems operate in environments nobody fully controls, with silicon that has documented deviations and sensors that are imperfect. A watchdog timer that resets a hung bus is not a cover-up; it is the correct response to a condition that cannot be prevented. Retries on a transient communication error are standard practice in every protocol stack ever written. Calibration routines compensate for component tolerances that would otherwise force expensive precision parts throughout a design.

Firmware exists, in part, to make imperfect hardware behave. That is legitimate and it is necessary.

The difficulty is that the boundary between compensating for the expected and concealing the unacceptable is not visible in the source code. It is only visible in a measurement that most teams never take.

Errata Sheets Are a Contract With the Future

Every complex integrated circuit ships with errata: documented deviations from specified behavior, each with a listed workaround. Reading a modern errata sheet is a sobering exercise. The list is long, the workarounds are specific, and each one is a small piece of permanent architecture.

Here is the honest reading of what those workarounds mean. A documented silicon defect that has a firmware workaround is a defect that will exist in every unit shipped for the life of the product, consuming processor cycles, flash space, and engineering attention. It is also a defect the next firmware engineer must understand before touching the driver, and often does not. Workarounds outlive their rationale. They are inherited the way a house inherits a strange light switch, by people who assume it must be there for a reason.

The failure mode is not the workaround. It is the workaround without a record of what it costs, what it assumes, and when it can be removed.

Three Symptoms of a Firmware Crutch

A design that is being propped up usually shows its condition in observable ways.

Retry counts that grow across revisions. The first build retries twice. The next retry limit is five. Then the timeout is extended. Each change is small and each change is defensible in isolation, and the trend line is a clear signal that the underlying physical margin is shrinking.

Calibration as a substitute for stability. Self-calibration is a legitimate technique. But a routine that runs more frequently over time, or that corrects a larger offset each cycle, is reporting on a hardware parameter that is drifting. The routine is not fixing the drift. It is hiding it.

Watchdog resets that are logged and never analyzed. Once a reset mechanism becomes routine, it stops being an event and becomes background. A weekly reset on a fleet of thousands is data. Treating it as noise is a decision, and usually an unexamined one.

Graceful Recovery Is Not the Same as Design Debt

The distinction is straightforward, though it is rarely stated this way. A recovery mechanism is legitimate when the underlying condition is rare, bounded, and understood. It becomes debt when the condition is frequent, unbounded, or unexplained and the mechanism exists to prevent anyone from having to find out which.

A system that recovers from an occasional transient fault with a logged, counted, reported event is well designed. A system that recovers constantly from an unexamined condition is not resilient; it is lucky, and its luck is not inheritable.

The uncomfortable part is that firmware makes this easy to conceal, because embedded systems often have no telemetry. If retry counts and reset causes are never transmitted anywhere, the design's true error rate is invisible to the people best positioned to act on it. The information exists in the device and dies there.

What to Do Instead

A few practices separate defensible recovery from concealed failure.

Make recovery observable. Log every retry, every watchdog reset, every calibration correction, with a cause code and a counter. Transmit them if the product has a channel. Read them if it does not.

Set an error budget and test against it. Decide in advance what rate of recovery events is acceptable, then measure it at temperature extremes, at supply extremes, and under the interference conditions the product will actually face. A design that only meets its error budget at twenty-five degrees Celsius has no error budget.

Require nominal performance without the crutch. For each defensive mechanism, ask what the hardware does when it is disabled. If the answer is unacceptable, the mechanism is covering for the design rather than protecting against the environment.

Document every workaround with a removal condition. Name the silicon revision it applies to, the assumption it depends on, and the circumstance under which it can be deleted. Workarounds without exit criteria never exit.

The Bill That Arrives Later

Software can absorb an astonishing amount of hardware inadequacy, and that is genuinely one of the strengths of embedded design. It is also why marginal hardware survives qualification. The device passes, because the firmware carried it.

What firmware cannot do is carry it forever. Process corners shift, second-source components arrive with different characteristics, suppliers revise silicon, and the field environment eventually includes something the bench did not simulate. The margin that was spent on retries in year one is not available in year four, and the failure that results will be attributed to the firmware release that finally ran out of room.

The honest position is that defensive firmware is a debt instrument. Used deliberately, with a term, an interest rate, and a repayment plan, it is sound practice. Used indefinitely and unexamined, it borrows against a design's margin and hands the bill to the customer.

All Articles

Related Articles

A Micron of Motion: How Fretting Corrosion Turns Dependable Connectors Into Intermittent Faults

A Micron of Motion: How Fretting Corrosion Turns Dependable Connectors Into Intermittent Faults

After the Ground Strap Comes Off: The ESD Discipline Gap Between Factory and Bench

After the Ground Strap Comes Off: The ESD Discipline Gap Between Factory and Bench

When the Part Disappears: Navigating the Engineering Crisis of Component Obsolescence

When the Part Disappears: Navigating the Engineering Crisis of Component Obsolescence