The user asks: "Construct a mission-critical embedded Linux update service with dual A/B partitions: cryptographic signing, rollback safety, delta updates, fleet orchestration, and regulatory evidence."
We need to produce a design and possibly code snippets for an embedded Linux update service that meets these requirements. It's a complex system. The user likely expects a high-level architecture, component breakdown, maybe sample code or configuration. Let's break down requirements:
- Mission-critical: high reliability, safety, fault tolerance.
- Embedded Linux: target is an embedded Linux system.
- Dual A/B partitions: typical Android-style system partition A and B, allowing atomic updates and rollback.
- Cryptographic signing: update packages must be signed, verification.
- Rollback safety: ability to revert to previous version if update fails.
- Delta updates: not full image updates, but binary diffs to reduce size.
- Fleet orchestration: manage many devices, schedules, staged rollouts.
- Regulatory evidence: maintain audit logs, maybe for compliance.
We need to construct an update service. Likely we need to propose an architecture: bootloader (like U-Boot or barebox) with A/B support, an update agent on the device, a server-side component (orchestration, package repo, signing), possibly using RAUC (Robust Auto-Update Controller) or Mender or SWUpdate. These are existing open-source solutions that implement A/B updates, delta, signing, rollback. We could use them or design our own.
But the phrase "Construct a mission-critical embedded Linux update service" could be interpreted as "design the system". We could provide a detailed design and maybe sample configuration files. Since it's a text request, we should output a comprehensive answer covering all aspects: hardware/bootloader requirements, software components, update flow, security mechanisms, delta update generation and application, orchestration architecture, dashboard, evidence collection, and maybe a proof-of-concept code snippets for verification or config.
We need to be thorough. Also note: the developer message says no restrictions, but we should still be helpful and provide a design.
The user might want a plan to build such a service, maybe with open-source components. We could propose using RAUC as the update client, use a server with Hawkboard for fleet orchestration or custom. Use Ed25519 or RSA for signing. Use image-based updates with A/B. Delta updates: possibly use BSDiff or Courgette or bsdiff. Or use compressed diffs. But A/B updates often use full images; delta updates can be applied to each A/B partition.
Let's outline:
- System Overview
- Bootloader Configuration (A/B support, slot metadata)
- Update Client (RAUC or custom)
- Boot status tracking (success/failure)
- Atomic update with rollback if fails
- Verification (signature, hash)
- Delta update support
- Update Package Structure
- Manifest (JSON)
- Images (system, boot, rootfs, etc.)
- Deltas (optional)
- Cryptographic Signing
- Use asymmetric keys (Ed25519)
- Signing process on server
- Verification on device
- Rollback Safety
- Bootloader marks slot as good/bad based on health check
- Automatic rollback after failure
- Delta Updates
- Generate diffs (e.g., using bsdiff, xdelta3)
- Apply using appropriate algorithm
- Fleet Orchestration
- Server components: repository, database, API, UI
- Manage device groups, versions, rollout schedule
- Push updates or poll
- Canary releases
- Regulatory Evidence
- Auditable logs on device and server
- Immutable logs (using append-only or signed logs)
- TPM or secure element for evidence
- Compliance reporting
- Implementation Steps
- Choose bootloader (U-Boot with A/B)
- Install and configure RAUC
- Create update bundles
- Set up server (e.g., using RAUC's hawkeye or custom)
- Integrate with orchestration (maybe using Mender or custom)
- Sample Configuration
- raucb bundle creation
- Systemd service for rauc
- U-Boot environment variables
- Server API endpoints
- Security Hardening
- Secure storage of keys
- Network TLS
- Device authentication
- Testing and Validation
That seems comprehensive. We should also mention that "mission-critical" implies need for watchdog, health checks, maybe redundant storage, but we'll focus on update.
We could also suggest using the "Grub" bootloader? Typically embedded uses U-Boot or barebox.
Let's produce a well-structured answer with sections, diagrams maybe (text description). Since this is text, we can include pseudo-code, config snippets.
We need to be mindful that the user wants "Construct a mission-critical embedded Linux update service". Possibly they want a design document. We'll deliver.
Also mention regulatory evidence: maybe need to meet FDA, IEC 62304, etc. So logs must be tamper-evident. Could use hardware-backed signing of logs (TPM PCR). Could store logs in circular buffer and sign.
We can integrate with a secure element for key storage and evidence.
We should mention that delta updates require careful handling because A/B partitions are separate; applying delta to a partition requires reading current partition and applying patch; could be done offline in a temporary partition? Typically delta updates are applied to the inactive partition using the current active partition as base. That's feasible: boot into active, fetch delta, apply to inactive partition.
Alternatively, RAUC supports "raw" delta where it downloads full image if delta fails.
Now, for fleet orchestration: we could use an open-source tool like "Hawkbit" (Eclipse) which works with RAUC. Or we could design custom: a central server with a REST API to manage devices, assign updates, etc. Devices poll for updates.
We'll propose both: use existing open-source stack to accelerate.
Now, let's start writing. We'll produce answer with clear sections. We'll include code snippets for:
- U-Boot environment for A/B
- rauc.conf file for client
- Command to create a rauc bundle with signing
- Example systemd service for rauc
- Server side: simple flask or node server? Better to mention Hawkbit.
- Evidence: using auditd and TPM.
We'll also mention that for mission-critical, you might want to use a verified boot chain with signed bootloader and kernel, so we might need that as well. But the request is about update service, so we can include that as part of overall secure update.
We'll structure:
1. Architecture Overview (diagram description)
2. Bootloader Setup for A/B (U-Boot config, slots)
3. Update Agent (RAUC) (installation, config)
4. Cryptographic Signing (key management, bundle creation)
5. Rollback and Health Checks (bootloader status, watchdog)
6. Delta Updates (generation and application)
7. Fleet Orchestration (server design, device management)
8. Regulatory Evidence (audit log, TPM)
9. Security Hardening (TLS, device auth)
10. Implementation Steps and Testing
11. Sample Files (U-Boot, rauc.conf, etc.)
We can also provide a script to generate delta using xdelta3.
Make sure to cover all requested features.
Let's produce a detailed answer.
We'll use Markdown formatting.
We'll mention that RAUC supports A/B slots and can be extended for delta. Actually RAUC supports "image contains a hash" but delta not built-in; but there is a "redundant" update type. However, there is an extension for delta: RAUC's "image" can be a script that applies delta. But we can outline custom implementation: The client checks if a delta is available for its current version and hardware, applies it to the inactive partition. Or we can use the "rauc" combined with "rdiff". We can propose a method.
Alternatively, use "Mender" which supports delta updates out-of-the-box. But Mender uses its own partition layout (dual rootfs) and provides everything: client, server, orchestration. It's also open-source with commercial options. But the question might prefer designing a custom service. We can propose using Mender if simplicity desired, but also show how to build from scratch. Since the user says "Construct", they likely want a design, maybe code.
I'll propose both: either adopt an existing solution like Mender or RAUC+Hawkbit, or roll custom with the described components. Given mission-critical, maybe choose proven open-source.
I'll provide both: high-level design using Mender (since it handles many of these) and then a custom approach using RAUC.
But the user might want a specific implementation. We'll be general but thorough.
Let's craft.
Detailed sections:
Introduction: Need safe, reliable updates for embedded devices, especially regulated industries. Dual A/B partitions ensure that updates are atomic and allow rollback if failure.
System Architecture: Components: Bootloader, OS, Update Agent, Secure Storage, Fleet Manager.
We'll include a diagram (text: arrow from server to device).
Bootloader with A/B:
- U-Boot supports A/B via
upgrade-available and bootcount env variables. We'll set up two rootfs partitions (rootfs_a, rootfs_b) and one boot partition each? Typically separate /boot (kernel+dtb) also A/B? We can have separate boot partitions or use unified. We'll assume separate boot partitions: boot_a, boot_b.
- U-Boot environment stored in persistent storage (eMMC, etc.). We'll define variables: slot (active), slot_successful, etc.
- Use U-Boot's
run switch_root to boot appropriate slot.
- Show U-Boot script: check if
upgrade_available set, then try to boot other slot; if fails, set slot to previous after bootcount exhaust.
Update Agent:
- Use RAUC as daemon. It runs as systemd service. It reads a manifest from a signed bundle.
- RAUC will install to inactive slot. It also hooks into bootloader to mark slot good/bad.
- Configuration: rauc.conf defines slots, hook scripts for pre/post, network config, etc.
- RAUC supports bundle verification via public key.
- We'll configure RAUC to use a PKCS#11 token for key storage, but simpler: store public key in read-only partition.
Cryptographic Signing:
- Build process: assemble rootfs, kernel, dtb into images. Create a manifest (JSON) listing images and hashes.
- Sign the bundle using Ed25519 private key. The bundle is a tar archive with manifest, images, and signature.
- On device, RAUC verifies signature using embedded public key.
- Recommend using hardware-backed key on server (HSM).
Rollback Safety:
- Bootloader tracks boot attempts. U-Boot's bootcount: increment on each boot; if fails, decrement and fallback.
- RAUC marks slot as good after successful boot (via
rauc status mark-good). If health check fails, mark bad.
- After update, device reboots into new slot; if boot fails within a threshold, bootloader reverts to previous slot.
- Also RAUC can trigger rollback on failure during installation.
Delta Updates:
- Generate binary deltas between current and new rootfs for each board variant. Use xdelta3 or bsdiff.
- Store delta files alongside full images on server.
- Client: RAUC can be extended to use a "delta" image type: first apply delta to the inactive partition. The manifest can include delta with
type: delta and base reference to current version. Or RAUC can be configured to download delta and use a script to apply using xdelta3 in a pre-install hook.
- Process: Detects current version (from installed manifest), queries server for available delta for that version; if found, download delta; apply to inactive partition's base image (which must be the current active image). Then continue with installation (which may skip full image download). The delta applies only to rootfs; may also have delta for separate partitions.
- Need to verify delta integrity: sign delta or include hash.
Fleet Orchestration:
- Server: store bundles, deltas, metadata. Track devices, software versions, health status.
- Use an orchestration platform: either build custom or use Eclipse hawkbit with RAUC integration. Hawkbit provides device management, rollout groups, staged rollouts, action sequencing, reporting.
- Components: Repository (Nginx or object storage), Database (PostgreSQL), API (Java), UI (Angular), Message broker (RabbitMQ or MQTT) to push notifications to devices.
- Devices maintain unique identity (serial, certificate). They authenticate via mutual TLS.
- Orchestrator schedules updates per group, can specify canary percentage, schedule time, rollback on failure thresholds.
- UI shows fleet overview, update status, compliance evidence.
Regulatory Evidence:
- Need immutable audit trail: all update attempts, successes, failures, cryptographic evidence.
- On device: use TPM to measure boot chain and logs. RAUC can log events to syslog, forward to central server. Use a local append-only log (e.g., using
auditd or custom journald rotation with signed entries).
- Server collects logs, stores in WORM storage or blockchain? Simpler: store in database with cryptographic hash of each entry, and periodically sign hash chain (log sealing).
- Evidence includes: device ID, timestamps, bundle hash, signature verification result, health check outcome, rollback event.
- For regulatory compliance (e.g., FDA 21 CFR Part 11, EU MDR), logs must be tamper-evident, retained for defined period.
- Provide reporting interface to export audit trails.
Security Hardening:
- Bootloader and kernel signed with U-Boot verified boot (FIT images). Use RSA/ECDSA.
- Network: all communications TLS 1.3 with client certificates.
- Device authentication: each device has unique ID and certificate, stored in TPM or secure element.
- Update bundles delivered over HTTPS, with HSTS.
- Principle of least privilege: RAUC runs as non-root? Might need root for flashing. Use capabilities.
- Secure key storage: private keys on server in HSM; public key in read-only partition on device.
- Anti-rollback: maintain minimal version number in TPM to prevent downgrade to vulnerable versions.
Implementation Steps:
- Partition layout design: A/B rootfs, boot var, data.
- Build Yocto/Buildroot with U-Boot, kernel, RAUC.
- Sign bootloader and kernel with fitSigner.
- Configure U-Boot environment for A/B.
- Build initial production images with RAUC bundle.
- Set up server: storage, Hawkbit or custom API.
- Generate delta for each release.
- Integrate device agent: install rauc, configure.
- Test update and rollback scenarios.
- Enable audit logging and TPM integration.
- Develop orchestration UI and rules.
- Perform security review, penetration testing.
Sample Files:
- U-Boot environment script (boot.scr):
setenv bootargs console=${console} root=${devtype}${devnum}:${bootpart} rw rootwait
load ${devtype} ${devnum}:${bootpart} ${kernel_addr_r} /boot/${kernel_name}
load ${devtype} ${devnum}:${bootpart} ${fdt_addr_r} /boot/${fdt_name}
bootm ${kernel_addr_r} - ${fdt_addr_r}
But A/B: we'll set bootpart based on slot.
Better: U-Boot fdt selects active slot based on env slot. script:
setenv slot_rootfs rootfs_${slot}
setenv bootpart ${devtype}${devnum}:${slot_part}
We'll provide more detail.
[system]
compatible = "MyCompany,myboard"
slot_support = "redundant"
bootname = "default"
[slot.rootfs.0]
device = "/dev/disk/by-partlabel/rootfs_a"
type = "ext4"
bootname = "default"
rauc bundle --key=privkey.pem --cert=cert.pem mybundle.raucb mymanifest.yml rootfs.img boot.img
[Unit]
Description=RAUC Update Service
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=/usr/bin/rauc daemon
Restart=on-failure
[Install]
WantedBy=multi-user.target
- Server API (simplified Flask):
from flask import Flask, jsonify, request
app = Flask(__name__)
# Device registry: device_id -> info
devices = {}
@app.route('/api/v1/devices/<id>/check', methods=['GET'])
def check_update(id):
# Return latest available version, download URLs, hashes, etc.
pass
@app.route('/api/v1/devices/<id>/report', methods=['POST'])
def report(id):
# Receive status of update attempt
pass
- Evidence logging using auditd: add rule to audit RAUC exec.
Conclusion: With these components, we have a robust, secure update service meeting mission-critical requirements.
We might also mention fallback mechanisms: if update fails, device can stay on old slot and notify server.
We'll also talk about delta application details: Use a temporary overlay or loop device to apply delta to raw partition image. Since we are updating inactive partition, we can mount it, or use raw block device with xdelta3 output writing directly. Need to ensure atomic: apply in temp file then move? Actually writing directly to block device is fine; if interrupted, the partition may be corrupted, but we can bail and use full image fallback. So better to apply delta offline: copy inactive partition to a file, apply delta, then flash? That defeats delta benefit. Instead apply delta directly to the raw partition: xdelta3 -d -s old.img delta patch new.img; but we need old data from the partition itself (current rootfs). So we could read from the partition as source, write to the same partition? That's tricky because as we write, we might overwrite data needed. So proper way: apply delta to a temporary copy (like using a RAM buffer) but that requires full rootfs size in memory. For large partitions, not feasible. Alternative: use a rolling delta: apply chunks sequentially while reading source; but xdelta3 can output to a file while reading from a file, but you cannot have same file as source and destination. So you need to apply from source partition read-only? Actually you can read from the partition and write to the same partition? Not safe. The typical approach is to apply delta to a temporary file in RAM, then flash that file to the partition. That doubles memory or storage temporarily. Another approach: use a "recovery" partition: download delta, apply by reading from active partition and writing to inactive in chunks, with checksums. It's complex. Many commercial systems use full images because flash I/O is not that expensive compared to download. But delta beneficial for bandwidth-limited.
We could note that delta updates are optional and can be implemented using a tool like rdiff with a temporary buffer. Or use "binary delta" that can be applied in place if using copy-on-write? Not typical.
Maybe we can use "rom-prover" style? But we can say: For mission-critical, we may rely on full images for safety, and use delta only when size is critical. But requirement includes delta, so we must support.
One solution: The inactive partition is completely unused; we can write directly to it, we need the old data to compute differences. The old data is on the active partition. We can read blocks from active and write transformed blocks to inactive without storing entire image. For simple delta algorithms like bsdiff, they are not forward/backward patchable; they require the entire source file. But xdelta3 supports "delta mode" that can be applied using streaming? Actually xdelta3 can apply delta in a streaming fashion using a rolling window; but still needs random access? Let's research: xdelta3's algorithm uses a moving window and can decode with only forward streaming? It builds a dictionary from the source; it can read source sequentially, but may need to seek back if using copy commands? The delta format includes copy and add; copy commands specify position in source; they can be forward only if source is read sequentially? Actually copy commands may refer to positions before current offset, requiring seeks. So sequential streaming not possible unless delta is specifically designed as forward delta. There are "forward delta" formats but not common. So we need random access to source. We can keep the source partition mounted read-only. The inactive partition we can write. So we can open source as read-only file, seek as needed; write to target sequentially. That is fine: we are reading from active partition (source) and writing to inactive partition (target). So we can apply delta directly: open /dev/rootfs_active as source, open /dev/rootfs_inactive as target, then run xdelta3 patches with source file descriptor and target file descriptor. That's possible because we can seek source but write target sequentially. As long as target is separate block device, it's okay. So delta application can be done without extra storage, but requires careful handling of block device sizes and alignment. Also need to ensure that source partition is read-only (mounted as read-only or not mounted). That's doable: before applying delta, we ensure active partition is not mounted (or mounted read-only). But the device is running from the active partition; we cannot unmount it while running. However we can read from it while it's mounted? The active rootfs is mounted as rootfs, which is read-only if we use a read-only root? Typically rootfs may be read-write during normal operation, but we can remount read-only temporarily? That would break running system. So we cannot read from the active partition as a raw block device if it's the rootfs, because the kernel may have it open and we risk inconsistency. Better to boot from the active partition, but we need its raw data to compute delta. However the delta is generated on the server and includes the difference relative to the current version. The device knows its current version (from manifest stored in /usr/rauc or /manifest). It could also have a copy of the current rootfs image stored somewhere? Not feasible.
Alternatively, we could generate deltas based on known version numbers and assume the device has that exact version installed; we don't need to read the partition to apply delta. The delta is relative to the old version's image, which we know. The delta can be applied as a transform of the old image to the new image. If we have the old image file (the one that was installed), we could apply delta to that file and then write result to the partition. But the device does not have the old image file stored; the partition itself contains the old image's data. We could read from the partition block device, but need consistent snapshot. If the partition is mounted read-write, there could be changes. But we could quiesce the filesystem (remount read-only) during update? That's not possible because system is running. However, we could copy the active partition to a temporary file (maybe using dd) before applying delta? That requires large storage.
Maybe a simpler approach: For delta updates, we can use a "rootfs" that is split into multiple read-only SquashFS partitions (or overlayfs). In that case, the rootfs is read-only; we can remount it as read-only and not have writes. In many embedded systems, rootfs is read-only (squashfs) and a separate writable data partition. Then the active rootfs partition is read-only; we can safely read it as a block device even while it's mounted (since it's read-only). Then applying delta to the inactive partition directly from active is safe. So we recommend using read-only rootfs (squashfs) for A/B updates. That is common: redundant root partitions each contain a compressed read-only filesystem. Then the active rootfs is mounted read-only, we can read its blocks while system is running. Then apply delta to inactive partition using xdelta3 with source as /dev/rootfs_a (or B) and target as /dev/rootfs_b. That's efficient.
Thus we'll specify: use SquashFS (or ext4 read-only) for rootfs partitions, mounted read-only. Writable data resides elsewhere.
But if rootfs is read-only, how do we handle writes? Use overlayfs with a writable upperdir on data partition. That is typical for embedded. So we can adopt that.
Thus we can say: delta updates apply to the inactive rootfs partition as a raw block device, using the active partition as source. The active partition is read-only, so it's safe.
Now, for evidence: we need to log events. Could use systemd-journal with Persistent=yes, and then forward logs to server via TLS. Also use TPM to seal logs or sign each entry.
We could propose using tpm2-tools to quote PCR values and log.
Now, let's write answer.
We should also mention that "dual A/B partitions" typically means two complete sets of system partitions (boot, rootfs, etc.) plus a third small data partition? Or we can have A/B for rootfs only and separate boot. We'll assume both boot and rootfs have redundancy.
We'll include details for partition table:
- Partition 1: SPL (optional)
- Partition 2: U-Boot proper
- Partition 3: boot_a (FIT image for kernel+dtb)
- Partition 4: boot_b
- Partition 5: rootfs_a (SquashFS)
- Partition 6: rootfs_b
- Partition 7: data (ext4)
- Partition 8: reserved
Or use GPT with labels.
Now, let's produce the final answer.
We'll use headings, bullet points, code blocks.
We need to be thorough but not overly verbose. Provide enough details to construct.
I'll write now.
Mission‑Critical Embedded Linux Update Service with A/B Partitions
This design describes a complete, production‑grade update system for embedded Linux devices that must meet high reliability, security, and regulatory requirements. It combines dual A/B partitions, cryptographic signing, atomic rollback, delta updates, fleet orchestration, and tamper‑evident audit trails.
1. High‑Level Architecture
+----------------+ HTTPS/MQTT +-------------------------+
| Device Fleet | <------------------> | Orchestration Server |
| (Embedded Linux)| | (Hawkbit / Custom) |
+----------------+ +-------------------------+
^ ^
| |
| 1. Check for updates (poll) | 2. Generate signed bundles
| 2. Download bundle/delta | and manage devices
| 3. Install to inactive slot |
| 4. Reboot & mark slot good/bad |
v v
+----------------+ +-------------------------+
| Update Agent | | Repository / Storage |
| (RAUC) | | (HTTPS, S3, etc.) |
+----------------+ +-------------------------+
^
|
| TPM/HSM for key storage, secure boot
|
+-------------------+
| Bootloader (U‑Boot) with A/B logic
+-------------------+
Key components
| Layer | Technology (suggested) |
|---|
| Bootloader | U‑Boot (or barebox) with A/B slot support |
| OS / Rootfs | Read‑only SquashFS or ext4 (ro) + overlay writable data |
| Update Agent | RAUC (Robust Auto‑Update Controller) |
| Fleet Orchestration | Eclipse Hawkbit (or custom REST + MQTT) |
| Security | Ed25519 / RSA signatures, TPM 2.0, mutual TLS (mTLS) |
| Delta Engine | xdelta3 (streaming, raw‑block‑device application) |
| Evidence | Auditd / journald + TPM PCR quoting + immutable store |
2. Partition Layout (GPT)
| # | Label | Size (example) | Purpose |
|---|
| 1 | spl | 256 KiB | SPL (optional) |
| 2 | uboot | 2 MiB | U‑Boot proper |
| 3 | boot_a | 64 MiB | Kernel + DTB (FIT image) |
| 4 | boot_b | 64 MiB | Same |
| 5 | rootfs_a | 256 MiB‑ several GiB | Read‑only root filesystem (SquashFS) |
| 6 | rootfs_b | same as A | Redundant |
| 7 | data | remaining | Writable data (ext4, overlay upperdir) |
| 8 | persistent | 16 MiB | U‑Boot env, RAUC status (raw) |
Notes
- Bootloader and kernel are signed via U‑Boot’s FIT mechanism.
- Rootfs partitions are mounted read‑only; all writes go to the
data partition via overlayfs.
persistent stores U‑Boot environment and RAUC’s slot status files (or use a dedicated MTD).
3. Bootloader Configuration (U‑Boot)
A/B Logic
U‑Boot increments a bootcount on each boot. If the new slot fails to boot (fails health check), it rolls back.
# In U‑Boot environment (stored in persistent partition)
setenv bootcount 0
setenv upgrade_available 0 # set by RAUC after successful install
setenv slot rootfs_a # current active slot
setenv slot_part 5 # partition number of rootfs_a
setenv boot_part 3 # partition of boot_a/fit
# Script to select slot
if test "${upgrade_available}" = "1"; then
# Switch to the other slot
if test "${slot}" = "rootfs_a"; then
setenv slot rootfs_b
setenv slot_part 6
setenv boot_part 4
else
setenv slot rootfs_a
setenv slot_part 5
setenv boot_part 3
fi
fi
# Load FIT from the selected boot partition
load ${devtype} ${devnum}:${boot_part} ${kernel_addr_r} /boot/${kernel_name}
load ${devtype} ${devnum}:${boot_part} ${fdt_addr_r} /boot/${fdt_name}
bootm ${kernel_addr_r} - ${fdt_addr_r}
Bootcount & Rollback
U‑Boot’s bootcount feature (CONFIG_BOOTCOUNT_LIMIT) can be used to limit consecutive failed boots. After a successful boot, the application should clear upgrade_available and reset bootcount (e.g., via fw_setenv). If bootcount exceeds a threshold, U‑Boot automatically reverts to the previous slot.
Verified Boot
- Sign the FIT image (
kernel, dtb, optionally ramdisk) with a private key.
- Embed the public key in U‑Boot (
CONFIG_FIT_SIGNATURE).
- At boot, U‑Boot verifies the signature before launching.
4. Update Agent – RAUC
RAUC is a lightweight daemon that manages installation of signed bundles to the correct slots.
4.1 Installation & Systemd Service
# On device (Yocto recipe or apt)
opkg install rauc
# Enable and start
systemctl enable rauc
systemctl start rauc
Systemd unit (/etc/systemd/system/rauc.service):
[Unit]
Description=RAUC Update Service
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=/usr/bin/rauc daemon
Restart=on-failure
[Install]
WantedBy=multi-user.target
4.2 Configuration (/etc/rauc/rauc.conf)
[system]
compatible = "MyCompany,MyBoard"
# Use 'redundant' for A/B (each slot has a counterpart)
slot_support = "redundant"
bootname = "default"
# Optional: hook scripts
; pre_install = "/usr/lib/rauc/pre-install.sh"
; post_install = "/usr/lib/rauc/post-install.sh"
[slot.rootfs.0]
device = "/dev/disk/by-partlabel/rootfs_a"
type = "ext4"
bootname = "default"
[slot.rootfs.1]
device = "/dev/disk/by-partlabel/rootfs_b"
type = "ext4"
bootname = "default"
[slot.boot.0]
device = "/dev/disk/by-partlabel/boot_a"
type = "fit"
bootname = "default"
[slot.boot.1]
device = "/dev/disk/by-partlabel/boot_b"
type = "fit"
bootname = "default"
[slot.persistent]
device = "/dev/disk/by-label/persistent"
type = "ext4"
4.3 Trusted Keys
- Public signing key (
pubkey.pem) is stored in the read‑only part of the system (e.g., /etc/rauc/key.pem with immutable flag).
- The daemon verifies every bundle against this key before proceeding.
[trust]
store = "/etc/rauc/key.pem"
5. Cryptographic Signing & Bundle Creation
5.1 Build Process
- Build images (rootfs, kernel+dtb FIT).
- Create a manifest (
manifest.yml) that lists the slots and their targets.
Example manifest.yml:
bundle:
version: "1.2.3"
compatible: ["MyCompany,MyBoard"]
description: "Release 1.2.3"
images:
- name: "rootfs"
filename: "rootfs.img"
slot: "rootfs.0"
sha256: "<hash>"
- name: "boot"
filename: "fit.itb"
slot: "boot.0"
sha256: "<hash>"
- Sign the bundle (
rauc bundle) with the private key:
rauc bundle --key=privkey.pem --cert=cert.pem \
mybundle-1.2.3.raucb manifest.yml rootfs.img fit.itb
RAUC produces a .raucb file (signed tarball). The public key is embedded in the device so verification is offline.
5.2 Key Management
- Private keys live in an HSM or TPM‑backed keystore on the build server.
- For regulatory compliance, generate keys in a FIPS‑140‑2 validated module and protect them with hardware.
- Use a certificate signed by a CA to support key rotation; devices can include a root CA.
6. Rollback Safety
RAUC integrates with the bootloader to ensure atomic installation and automatic fallback.
Installation flow
- RAUC verifies the bundle’s signature and integrity.
- It writes images to the inactive slots only.
- After writing, it marks the new slot as “install‑ok” in the persistent storage (
/persistent/rauc/).
- Device is rebooted. U‑Boot (using
upgrade_available) boots the new slot.
- Once the system boots and
rauc status mark-good is called (usually by a startup script after health checks), the slot is marked “good”.
- If the system fails to boot (panic, watchdog timeout), U‑Boot will revert to the previous slot after
bootcount > limit. The old slot remains marked “good”.
- RAUC daemon on next start will handle any incomplete installation and may trigger a rollback command.
Health Check Hook
A custom script (e.g., /usr/lib/rauc/health-check.sh) is invoked after boot to validate the system (services running, sensors OK). It returns 0 on success; otherwise, rauc status mark-bad is called, forcing rollback on next boot.
7. Delta Updates
Delta updates reduce bandwidth by sending only the binary diff between the current installed version and the new one.
7.1 Delta Generation (Server‑side)
For each new release and each board variant:
# Assume current version = 1.2.2, new = 1.2.3.
# Both rootfs images are raw (ext4) or SquashFS blobs.
xdelta3 -e -s rootfs_1.2.2.img rootfs_1.2.3.img rootfs_1.2.2_to_1.2.3.xdelta
Add the delta file to the repository and record its base version in metadata.
7.2 Delta Application (Client)
RAUC can be extended to treat a delta as a special image type. Its post-install hook or a custom install script can perform the following steps:
- Detect current version from the manifest of the active slot (RAUC stores this in
/persistent/rauc/).
- Query the server for an available delta (
current_version → target_version). The server returns download URL and expected hash.
- Download the delta to a temporary location.
- Apply the delta directly to the inactive partition:
# Example: apply to rootfs_b (inactive) using rootfs_a (active) as source
xdelta3 -d -s /dev/disk/by-partlabel/rootfs_a \
/tmp/rootfs_delta.xdelta /dev/disk/by-partlabel/rootfs_b
- Verify the resulting partition (optional: compute hash and compare with target manifest).
- Continue with normal RAUC marking (no need to write full image).
If the delta fails to apply (e.g., mismatched base), RAUC falls back to downloading the full image (configurable).
Safety – The active rootfs is read‑only (SquashFS), so reading /dev/disk/by-partlabel/rootfs_a while the system runs is safe. No write operation occurs on the active slot.
Note: Delta application might be I/O‑heavy; schedule during idle periods (orchestrated by fleet manager).
8. Fleet Orchestration
A central server manages thousands of devices, controlling which updates are deployed, when, and to which groups.
8.1 Recommended Stack – Eclipse Hawkbit
Hawkbit is an open‑source device management platform that natively integrates with RAUC.
Features used
| Feature | Benefit |
|---|
| Device authentication (mTLS) | Each device has a unique certificate (issued by CA) |
| Target groups & filters | Group devices by model, firmware version, region, etc. |
| Rollout plan (staged) | Canary releases: 5% → 25% → 100% with automatic pause on failure |
| Action sequencing | Install → Reboot → Health check → Mark good/bad |
| Reporting & audit | Collections of status, logs, and evidence for compliance |
| API & UI | RESTful API and Angular UI for operators |
Deployment (simplified)
- Install Hawkbit (Docker compose or Kubernetes).
- Configure RAUC as the client using the Hawkbit “DDI” API.
- Devices register with Hawkbit (provide hardware info, current software version).
- Administrators create distributions (uploaded signed RAUC bundles) and rollout rules.
8.2 Custom Alternative
If full control is needed, a custom microservice can be built:
- API – Node.js/Go/Python Flask server with endpoints:
GET /devices/<id>/updates → returns available bundle/delta info.
POST /devices/<id>/reports → device sends status (started, succeeded, failed, logs).
- Database – PostgreSQL with tables:
devices, releases, updates, logs.
- Message broker – MQTT or AMQP for push notifications (optional).
- Storage – Nginx + S3 or GCS to host
.raucb files and deltas.
- UI – Minimal web dashboard to view fleet status and trigger rollouts.
All communication must use TLS 1.3 and mutual TLS for device authentication. The server signs each bundle with its private key; the device verifies with the stored CA root.
9. Regulatory Evidence (Audit Trail)
For medical, industrial, or aerospace applications, every update action must be tamper‑evident and retained.
9.1 On‑Device Evidence
- RAUC logs – RAUC writes detailed events to syslog/journal. Ensure they are persistent (
/var/log/journal/ on a persistent storage partition).
- Auditd – Configure Linux Audit to capture execve of
rauc, fw_setenv, etc. Example rule:
-w /usr/bin/rauc -p x -k rauc
-w /usr/sbin/fw_setenv -p x -k rauc
- TPM Integration – Use the TPM to seal critical values and produce quotes that include the current audit log hash.
- Compute a hash chain: after each RAUC event, append a signed (with TPM key) entry containing
(timestamp, bundle_hash, slot, result).
- Optionally store the hash chain in TPM NV index or extend PCRs.
- Secure timestamping – If required, contact an external Time Stamping Authority (TSA) to timestamp bundle signatures.
9.2 Server‑Side Evidence
- Immutable logs – Store all device reports in an append‑only database table or WORM storage.
- Log sealing – Periodically compute a Merkle tree of all entries and sign the root with an HSM‑protected key. Publishes the signed root to a public ledger (optional) for extra non‑repudiation.
- Compliance reports – Provide UI to export audit trails with digital signatures, meeting standards such as FDA 21 CFR Part 11, EU MDR, IEC 62304.
10. Security Hardening
| Aspect | Measures |
|---|
| Boot chain | U‑Boot & FIT signed; U‑Boot environment checksummed & signed (optional) |
| Network | mTLS for all HTTP/MQTT; disable ciphers < TLS 1.3; pin CA certificates |
| Key storage | Private keys in HSM; device public key in read‑only partition |
| Anti‑rollback | Store minimum allowed version in TPM; reject bundles with lower version |
| Runtime isolation | Run RAUC as non‑root where possible (requires CAP_SYS_ADMIN); use systemd sandboxing |
| Package integrity | SHA‑256 hashes in manifest; verify before install |
| Intrusion detection | Watchdog for unexpected reboots; send alerts after repeated failures |
| Least privilege | All services drop capabilities; use PrivateTmp, ProtectSystem etc. |
11. Implementation Roadmap
- Design partition table and flash layout for the target hardware.
- Build bootloader (U‑Boot) with:
- A/B support (
CONFIG_CMD_BOOTCOUNT, CONFIG_BOOTCOUNT_LIMIT).
- Verified boot (FIT signatures).
- Create OS image:
- Yocto/Buildroot with RAUC package.
- Rootfs as SquashFS (ro) + overlay for writable data.
- Sign initial images and generate first production RAUC bundle.
- Deploy server:
- Install Hawkbit (or custom).
- Configure TLS certificates (CA, server, device registration).
- Set up object storage for bundles/deltas.
- Integrate client:
- Install RAUC, configure
rauc.conf.
- Add public key, systemd service.
- Write health‑check script (
/usr/lib/rauc/health-check.sh).
- Enable auditd and optional TPM scripts.
- Test update cycles:
- Full image update → success → rollback simulation.
- Delta update → network loss → fallback to full.
- Staged rollout via Hawkbit.
- Security tests: invalid signature, replayed bundle, downgrade attack.
- Enable evidence collection:
- Configure auditd rules, forward logs to server via TLS.
- Implement TPM‐based log sealing.
- Operator training and documentation.
- Compliance validation (e.g., audit trail review, cryptographic verification).
12. Sample Configuration Files
12.1 U‑Boot Environment (boot.scr)
# -------------------------------------------------
# A/B boot logic
# -------------------------------------------------
# Variables set by the OS via fw_setenv:
# slot=rootfs_a|rootfs_b, bootcount, upgrade_available
# Determine which slot to boot
if test "${upgrade_available}" = "1"; then
if test "${slot}" = "rootfs_a"; then
setenv slot rootfs_b
else
setenv slot rootfs_a
fi
fi
# Partition mapping
if test "${slot}" = "rootfs_a"; then
setenv root_part 5
setenv boot_part 3
else
setenv root_part 6
setenv boot_part 4
fi
# Load FIT from the selected boot partition
load ${devtype} ${devnum}:${boot_part} ${kernel_addr_r} /boot/${kernel_name}
load ${devtype} ${devnum}:${boot_part} ${fdt_addr_r} /boot/${fdt_name}
# Kernel command line – root is always UUID or PARTUUID for stability
setenv bootargs console=${console} root=PARTUUID=${partuuid_of_rootfs} rw rootwait
bootm ${kernel_addr_r} - ${fdt_addr_r}
12.2 RAUC Configuration (rauc.conf)
(Already shown in section 4.2)
12.3 Bundle Manifest (manifest.yml)
(Already shown in section 5.1)
12.4 Health‑Check Script (/usr/lib/rauc/health-check.sh)
#!/bin/bash
# Return 0 if the system is healthy, non-zero otherwise.
# Example checks:
# 1. Critical service running
if ! systemctl is-active --quiet critical.service; then
echo "Critical service not running"
exit 1
fi
# 2. Disk space ok
if [ $(df /persistent | awk 'NR==2 {print $5}' | tr -d '%') -gt 90 ]; then
echo "Persistent storage >90% full"
exit 2
fi
# 3. Sensor sanity (custom)
if ! /usr/bin/check-sensors; then
echo "Sensors out of range"
exit 3
fi
exit 0
Make it executable (chmod +x). RAUC can be configured to run it after boot (via systemd rauc-installer.service or a custom unit that calls rauc status mark-good on success, otherwise rauc status mark-bad).
12.5 Simple Fleet Server API (Flask)
# app.py
from flask import Flask, jsonify, request
import sqlite3, os, hashlib, json, subprocess
app = Flask(__name__)
DB = 'fleet.db'
def get_db():
return sqlite3.connect(DB)
@app.route('/api/v1/devices/<device_id>/updates', methods=['GET'])
def check_update(device_id):
# Fetch latest release compatible with device
cur = get_db().cursor()
cur.execute('SELECT version, bundle_url, sha256 FROM releases ORDER BY date DESC LIMIT 1')
row = cur.fetchone()
if not row:
return jsonify({'error': 'no releases'}), 404
version, url, sha256 = row
# Also check for delta
cur.execute('SELECT delta_url, base_version FROM deltas WHERE base_version=? AND target_version=?',
(device_current_version(device_id), version))
delta = cur.fetchone()
resp = {'version': version, 'bundle': url, 'hash': sha256}
if delta:
resp['delta'] = delta[0]
resp['base'] = delta[1]
return jsonify(resp)
@app.route('/api/v1/devices/<device_id>/report', methods=['POST'])
def report(device_id):
data = request.json
# Expected: {event: "started|completed|failed", bundle: "...", details: "..."}
conn = get_db()
conn.execute('INSERT INTO events (device, time, event, bundle, details) VALUES (?, ?, ?, ?, ?)',
(device_id, subprocess.getoutput('date -u'), data['event'],
data.get('bundle',''), data.get('details','')))
conn.commit()
conn.close()
return jsonify({'status': 'ok'})
def device_current_version(device_id):
# In real system, query device last reported version
return "1.2.2"
if __name__ == '__main__':
app.run(ssl_context=('server.crt', 'server.key'), host='0.0.0.0', port=443)
The server must be mounted with mTLS and authenticate the device before answering.
13. Delta Application Details (Client‑Side)
Assume a device running RAUC daemon. A custom download hook (post-download) can be used to apply delta before installation.
/etc/rauc/post-download.sh (simplified):
#!/bin/bash
# Called by RAUC after bundle download but before install.
# Arguments: $1 = bundle path, $2 = slot configuration file, $3 = manifest JSON
# Determine current active slot
ACTIVE_SLOT=$(rauc status --output-format=json | jq -r '.status[0].slot')
# The bundle target slots are defined in manifest; find which is inactive
INACTIVE_SLOT=$(jq -r '.images[] | select(.slot != env.ACTIVE_SLOT) | .slot' "$3")
# Check if bundle contains a delta for the rootfs image
HAS_DELTA=$(jq -r '.images[] | select(.name=="rootfs" and .type=="delta") | .filename' "$3")
if [ -n "$HAS_DELTA" ]; then
# Extract delta and apply
mkdir -p /tmp/rauc
tar -xf "$1" "$HAS_DELTA" -C /tmp/rauc
DELTA_FILE="/tmp/rauc/$HAS_DELTA"
# Apply to the inactive rootfs block device
# Map slot → device (from rauc.conf)
INACTIVE_DEV=$(rauc info --slot "$INACTIVE_SLOT" | awk '/device/ {print $2}')
# Active device for source
ACTIVE_DEV=$(rauc info --slot "$ACTIVE_SLOT" | awk '/device/ {print $2}')
# Apply: source read‑only, target write only
xdelta3 -d -s "$ACTIVE_DEV" "$DELTA_FILE" "$INACTIVE_DEV"
if [ $? -ne 0 ]; then
echo "Delta apply failed, falling back to full image"
# RAUC will proceed to install the full rootfs image from the bundle
# (the full image is also present in the bundle)
fi
# At this point, the inactive partition contains the new rootfs
fi
exit 0
Make the script executable and reference it in rauc.conf:
[hook]
post-download = "/etc/rauc/post-download.sh"
Important: The active rootfs must be mounted read‑only. In an overlay setup, the underlying SquashFS partition is read‑only, so reading /dev/... is safe.
14. Evidence and Compliance Wrap‑Up
To satisfy regulations, the system must prove what was installed, when, and by whom.
- On‑device: each RAUC event writes a JSON line to
/var/log/rauc-evidence.log. A small daemon signs each line with the TPM’s EKF (Endorsement Key) and appends a signature. The log is rotated but old entries are kept in a compressed immutable archive on the data partition (or uploaded to server on each update).
- Server: upon receiving a report, the server stores the event, the bundle hash, and the device’s TPM quote (if submitted). The database uses append‑only tables (no UPDATE/DELETE) and all modifications are done via INSERT. Periodic log sealing (signing a Merkle root) provides a way to verify later that logs haven’t been tampered.
- Export: a UI page allows auditors to download a digitally signed audit report (PDF with embedded signature or a machine‑readable JSON with a signature).
15. Conclusion
By following this design, you obtain an embedded Linux update service that:
- Updates safely – atomic A/B, verified boot, rollback on failure.
- Reduces bandwidth – delta updates with fallback.
- Scales – orchestrate fleets with staged rollouts.
- Meets security – cryptographic signatures, TPM, mTLS.
- Provides evidence – tamper‑evident logs for regulators.
The solution leverages proven open‑source components (U‑Boot, RAUC, Hawkbit) while allowing custom extensions for delta handling and regulatory evidence. Implementation can start with a Yocto/Buildroot integration and a test deployment before scaling to production.