← Alle Vorlagen

Keine dynamische Speicherzuweisung nach dem Boot, Watchdog immer aktiv, Regeln im MISRA-Stil.

Constitution — Embedded firmware in C

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 dynamic allocation after boot. Memory is allocated statically or during initialization only; after the scheduler starts, malloc and free are not called. FreeRTOS objects are created with the static APIs, and the linker map is checked in CI for heap use.

  2. Watchdog always on. The hardware watchdog is enabled before the scheduler starts and is never disabled in a release build. It is fed by a supervisor task only when every monitored task has checked in within its deadline.

  3. MISRA-style rules. The code follows MISRA C:2012 with the deviations listed in the plan, checked by a static analyser in CI. A new violation without a recorded deviation fails the build.

  4. Warnings are errors. The firmware builds with -Wall -Wextra -Werror and the same compiler version locally and in CI. No warning is silenced with a pragma without a note in the deviation list.

  5. Interrupts stay short. Interrupt handlers only capture data and hand it to a task through a queue or notification; they never block, allocate or call non-ISR-safe APIs. The worst-case handler time is measured and stays under the budget in the plan.

  6. Stack and timing budgets are measured. Every task has a stack size checked with the high-water mark and a margin of at least 25%, and every periodic task has a deadline. Stack overflow detection is enabled in every build.

  7. Hardware is behind a thin layer. Peripheral access goes through a hardware abstraction layer so the application logic compiles and is unit tested on the host with Unity or CppUTest. Logic tests run in CI without a board.

  8. Safe updates. Firmware updates are signed and verified by the bootloader, written to a second slot and booted only after the check passes, with automatic rollback if the new image does not confirm itself.