F0045 fls-2¶
Rule: The flash peripheral has one owner.
| Code | F0045 (stable, never reused) |
| Id | fls-2 |
| Category | fls |
| Source | spirit_level |
| Fix | by hand |
Level per tier¶
| Tier | Level | Reason |
|---|---|---|
| small | off | |
| small-workspace | off | |
| medium | off | |
| big | off | |
| ai | off | |
| embedded | deny |
bedrock error: More than one owner of the flash peripheral (updater and settings each take FLASH) |
| ui | off | |
| egui | off | |
| units-strict | off | |
| units-paranoid | off |
Why¶
Two independent pieces of code — a firmware updater and a settings store, most often — each taking their own FLASH peripheral handle instead of sharing one owner.
Flash programming on most of these parts is a shared, stateful peripheral (one set of control registers, one busy flag); two independent owners racing an erase and a write against each other corrupts whichever one loses, and because both "succeed" from their own point of view, the corruption surfaces later, far from the code that caused it.
Example¶
Embedded_bedrock TPL-24: the updater and the settings store both wanting FLASH directly is exactly the shape this check exists for.
How to fix¶
Give flash access to one owner (a flash-manager task, or the updater and settings sharing a single handle behind a mutex) and route every consumer through it.
How it is checked¶
src mid: the firmware model should show exactly one place that owns the FLASH peripheral singleton; any second independent acquisition is the finding.
Source¶
Ported from embedded_bedrock's firmware check catalogue, FLS-2 (book/checks.md, detail in book/checks/fls.md). Found on: embedded_bedrock TPL-24.
Configure¶
Allow one finding in the code with // spirit-level: allow(fls-2) <reason> (waivers); the code works there too, as in [lints.F0045].