← Alle Vorlagen

no_std, keine Panics auf Produktionspfaden, Hardware hinter Traits.

Constitution — Embedded Rust

Version 1.0.0 · Ratified 2026-11-10

These principles hold for every spec, plan and task of the firmware. A spec may add rules; it never weakens these.

  1. no_std. The firmware is #![no_std] and uses core and, only where the plan allows, a fixed-size allocator or heapless collections. A dependency that pulls in std fails the build.

  2. No panics on production paths. Production code uses Result and never unwrap, expect, unchecked indexing or arithmetic that can overflow; Clippy denies unwrap_used and expect_used. The panic handler resets the device and records the reason.

  3. Hardware behind traits. Drivers are written against embedded-hal traits (I2C, SPI, digital pins, delays), not a specific HAL. The same driver runs on the target and on the host with embedded-hal-mock in tests.

  4. Unsafe is rare and justified. Each unsafe block has the smallest scope possible and a SAFETY note in the review describing the invariant. New unsafe code needs a second reviewer.

  5. Concurrency is checked by the compiler. Shared state between interrupts and tasks goes through RTIC resources, Embassy primitives or critical-section mutexes. No static mut is accessed outside them.

  6. Size and timing budgets. The flash and RAM use of each release build is reported by cargo size in CI and stays within the budget in the plan. The release profile fixes opt-level, LTO and codegen-units = 1.

  7. Tested on the host and on the board. Logic and drivers are tested on the host in CI; integration tests run on a reference board with probe-rs and defmt-test before each release.