oxidecomputer / hubris

A lightweight, memory-protected, message-passing kernel for deeply embedded systems.
Mozilla Public License 2.0
3.02k stars 175 forks source link

Implement persistent data for Cosmo `hf` slot selection #1860

Closed mkeeter closed 2 months ago

mkeeter commented 2 months ago

Staged on top of #1853

This PR implement persistent storage in host flash for Cosmo, using the same strategy as Gimlet: reserve sector 0 and tile it with a small data payload, using a CRC to ensure validity and a monotonic counter to find the newest payload.

This only works because the AMD boot sequence ignores sector 0 (other than word 0, which must be all 1s).

RawPersistentData is moved to drv-hf-api and renamed HfRawPersistentData for consistency. In addition, it now implements cmp, making a few operations cleaner.

The new code in drv-cosmo-hf is mostly copypasta from drv-gimlet-hf, but with a few tweaks (both virtual devices are on the same flash chip, the QSPI driver has a slightly different API, etc).