ARR-OTA All articles
Engineering Deep Dive

The 40KB Firmware Update: How Binary Diffing Slashes OTA Costs at Fleet Scale

ARR-OTA
The 40KB Firmware Update: How Binary Diffing Slashes OTA Costs at Fleet Scale

Photo: engineer analyzing code on multiple monitors data center, via as2.ftcdn.net

Do the arithmetic before you deploy. A 40MB firmware image pushed to one million devices is 40 terabytes of egress — before retries, before cellular devices that download the same image twice, before the long tail of flaky connections. At typical cloud egress rates, that single release can cost tens of thousands of dollars. Now imagine shipping weekly.

Delta updates change the math entirely. If a release touches 2% of the image, a well-constructed patch weighs roughly 40KB. The same fleet, the same release: 40 gigabytes instead of 40 terabytes. For devices on metered LTE or NB-IoT connections, it's not just cheaper — it's often the difference between an update that's feasible and one that's not.

How Binary Diffing Actually Works

A delta update is a patch file computed from two inputs: the firmware currently on the device (the source) and the image you want it running (the target). The patch describes the minimal set of transformations needed to turn one into the other.

At a high level, the process has three stages:

1. Matching. The diffing algorithm scans both binaries for shared blocks — byte sequences that appear in each. Embedded firmware is ideal for this: unchanged driver code, static lookup tables, and untouched libraries mean large runs of identical bytes survive between releases. Algorithms like bsdiff go further, using suffix sorting to find matches even when bytes have shifted positions in the image.

2. Encoding. Differences are recorded as a sequence of copy instructions ("take these bytes from the source") and insert instructions ("emit these new bytes"), plus optional extra data for address translation. Because compiled code shifts when anything upstream changes, sophisticated algorithms model these shifts rather than treating every relocation as fresh data.

3. Reconstruction. The device-side patcher reads the source image from flash, applies the instructions, and writes the target image — ideally directly into the inactive slot of an A/B partition scheme, leaving the running firmware untouched until the result is verified.

For compressed images, the picture gets murkier. Diffing a gzip or LZMA-compressed blob produces poor results because a single changed byte can alter the entire compressed stream. The fix is to decompress before diffing and ship a patch against the uncompressed image, then recompress on-device — or to build the firmware with compression-friendly section alignment in the first place.

The Savings, Quantified

Real-world results depend on release cadence and code churn, but the pattern is consistent:

The bandwidth savings cascade into other wins. Battery-powered devices spend less time on their radios. Cellular-connected fleets stay within data plans. Update campaigns that would take days of constrained-bandwidth distribution finish in hours. And for edge deployments in the field — agricultural sensors across the Midwest, utility meters, fleet telematics — every byte counts twice: once on the wire, once on the device's flash endurance.

Where Delta Updates Bite Back

Differential patching trades robustness for efficiency, and the trade has teeth.

Source verification is non-negotiable. A patch applies correctly only to the exact source image. If a device is running version 2.3.1 but your patch expects 2.3.0, the result is corruption. Every patch must be bound to a source hash, and the device must verify its current image against that hash before applying anything. Mismatch means falling back to a full download — so your OTA pipeline must always support both paths.

Rollback gets complicated. With A/B partitions, rollback is straightforward: the old slot still holds a complete, bootable image. But single-partition designs that patch in place lose the source during reconstruction — a power failure mid-patch can leave the device with neither image. If you're doing in-place delta patching, you need either a staged write to scratch space with journaling, or a minimal recovery image that can accept a full reflash. Better yet: make the dual-slot architecture a prerequisite.

Integrity checking must cover the output, not the input. Verifying the patch file's signature confirms what you shipped; it doesn't confirm what the device built. Always hash the reconstructed target image and compare it against the known-good digest before the new slot is marked bootable.

Fleet fragmentation multiplies patch count. If your fleet spans five firmware versions, each release means five distinct patches — or a policy that devices must be on a recent baseline before receiving deltas. Some teams enforce a "no more than N versions behind" rule and ship full images to stragglers.

A Practical Decision Framework

Delta updates earn their complexity when three conditions hold: your firmware is large relative to your connectivity, your fleet is large relative to your tolerance for cost, and your releases are frequent enough that consecutive images share substantial code. If any of those don't apply, a well-compressed full image with solid A/B rollback is simpler and perfectly adequate.

When the conditions do hold, start by measuring. Compute diffs between your last five release pairs and look at the ratio. Most teams discover their patch sizes justify the machinery within the first hour of analysis — and that the hard part isn't the diffing algorithm, but the source verification, fallback logic, and rollback guarantees around it.

Ship the small patch. But engineer it like the full image, because on the day something goes wrong, your devices will need a complete, trustworthy path back either way.

All Articles

Related Articles

No Way Back Is No Way to Ship: Building Rollback Into Your OTA Pipeline From Day One

No Way Back Is No Way to Ship: Building Rollback Into Your OTA Pipeline From Day One