$ renode sim/equivalence.sh 1000
Can a verified kernel replace firmware logic on the device?
The decisions in open-source embedded Rust firmware (who may do what, which values are allowed, what state comes next) are moved into an h5i-app kernel and proved in Lean 4. Then the original firmware and the port run side by side on the target instruction set in Renode, on the same scripted input, and every difference a client or the device would observe is counted.
Overview
One row per firmware. Properties are the theorems gated by h5i app check (helper lemmas are not counted). The two equivalence columns are the share of scenarios in which the original firmware and the port behaved identically.
| Firmware | Device | Interface | Properties | Normal input | With malformed and edge-case input |
|---|
Normal input: only what the firmware's own client or UI sends, within the ranges it allows, plus ordinary device events; every difference counts except a short named list of cosmetic ones. Mixed input adds malformed requests and boundary values.
Verified properties
Every property gated by h5i app check: no sorry, no native_decide, standard axioms only. Choose one for its Lean statement, the kernel Rust beside the upstream Rust it ports, the extracted Lean and the proof. A property covers the kernel's decision function, not the I/O around it.
| Theorem | Type | Property | Status |
|---|
Equivalence in detail
Every scenario ends in one of three classes. Identical: same responses, same device state. Explained: the difference is traced to the input that caused it and to a named cause (a cosmetic response, the port refusing input the original accepts, or the original's behaviour on that input). Unexplained: anything else; a port is not done while it has one.
| Firmware | Input | Scenarios | Identical | Explained / cosmetic | Unexplained / other |
|---|
Mixed-input scenarios deliberately include malformed requests and boundary values, so their identical share mostly reflects how often the generator hits such input, not how often the firmwares disagree in normal use.
Method
Per firmware: audit the upstream source, port its decisions to an h5i-app kernel, prove properties of the kernel, make the rest of the port a drop-in for upstream's network path, then compare both on the target ISA.
- Two firmwares per project. The original is built from upstream's own source files, unmodified and SHA-256 pinned, with minimal stand-ins for the hardware items they name. The port runs the h5i-app kernel behind
h5i-app-embedded(its HTTP parser,h5i-app-h1, is itself verified). - Target instruction set. Both are built for the real target (Xtensa LX6/LX7, RV32IMC/IMAC, Cortex-M0+/M33) and run on Renode's CPU model with memory at the SoC's addresses. Renode has no ESP32/RP2040/RP2350 SoC models, so peripherals are modelled in a shared harness.
- Shared harness. A scripted socket at the
embedded_io_asyncboundary (requests arrive in random fragments), and shared models of flash (alignment and NOR semantics), clock, sensors and actuators. Wi-Fi, TCP and the HAL sit below the socket and are not emulated. - What is compared. What a client observes (status, body, the headers that matter, connection close) and device state (flash contents, outputs such as relays and motors, reboots), per scenario.
- Trusted. The I/O and encoding code around the kernel, the HAL, the device models and the Rust-to-Lean extraction. Their agreement with upstream is tested by the equivalence runs, not proved.
- Single-host simulation. One scenario is a fresh boot; a panic ends the scenario. Not a substitute for tests on hardware.