Skip to content

steami_config: Add persistent configuration module. #166

@nedseb

Description

@nedseb

Context

The STeaMi board needs persistent configuration that survives power cycles. Initially, calibration values were stored in RAM and lost on reboot.

The config zone is a 1 KB area in the STM32F103 internal flash (gap between bootloader and interface firmware at 0x0800BC00). It survives interface firmware updates and clear_flash operations.

Flash layout

0x08000000 - 0x0800BBFF : Bootloader (47 KB, never touched)
0x0800BC00 - 0x0800BFFF : Config zone (1 KB)
0x0800C000 - 0x0801FBFF : Interface firmware (79 KB)
0x0801FC00 - 0x0801FFFF : DAPLink settings (1 KB)

Implemented usages

Usage JSON key Status
Board revision rev Done (#169)
Board name name Done (#169)
Temperature calibration tc Done (#168)
Magnetometer calibration cal_mag Done (#170)
Accelerometer calibration cal_accel Done (#171)
Boot counter boot_count Done (#172)

API overview

from steami_config import SteamiConfig
from daplink_flash import DaplinkFlash

config = SteamiConfig(DaplinkFlash(I2C(1)))
config.load()

# Board info
config.board_revision       # -> 3
config.board_name           # -> "STeaMi-01"

# Temperature calibration
config.set_temperature_calibration("hts221", gain=1.0, offset=-0.5)
config.get_temperature_calibration("hts221")  # -> {"gain": 1.0, "offset": -0.5}
config.apply_temperature_calibration(hts221_instance)

config.save()

Dependencies

Sub-issues

All sub-issues are now closed and the steami_config module is shipped with examples for each use case (show_config, populate_demo_config, calibrate_temperature, calibrate_magnetometer, calibrate_accelerometer, boot_counter).

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions