fix: NVS Generator. cosmetic: Changed CloudFlash page a bit

This commit is contained in:
2026-03-19 21:01:17 +02:00
parent 29bbaead86
commit d8ba64da55
3 changed files with 52 additions and 20 deletions

View File

@@ -177,17 +177,16 @@ def _build_page(entries: List[bytes], slot_counts: List[int], seq: int = 0) -> b
return page
def generate(serial_number: str, hw_family: str, hw_revision: str) -> bytes:
def generate(serial_number: str, hw_family: str, hw_revision: str, legacy: bool = False) -> bytes:
"""Generate a 0x5000-byte NVS partition binary for a Vesper device.
serial_number: full SN string e.g. 'BSVSPR-26C13X-STD01R-X7KQA'
hw_family: board family e.g. 'vesper-standard', 'vesper-plus'
hw_revision: hardware revision string e.g. '1.0'
Writes the schema keys expected by ConfigManager (struct DeviceConfig):
serial ← full serial number
hw_family ← board family (lowercase)
hw_revision ← hardware revision string
legacy: if True, writes old key names expected by legacy firmware (pre-new-schema):
device_uid, hw_type, hw_version
if False (default), writes new key names:
serial, hw_family, hw_revision
Returns raw bytes ready to flash at 0x9000.
"""
@@ -195,9 +194,14 @@ def generate(serial_number: str, hw_family: str, hw_revision: str) -> bytes:
# Build entries for namespace "device_id"
ns_entry, ns_span = _build_namespace_entry("device_id", ns_index)
uid_entry, uid_span = _build_string_entry(ns_index, "serial", serial_number)
hwt_entry, hwt_span = _build_string_entry(ns_index, "hw_family", hw_family.lower())
hwv_entry, hwv_span = _build_string_entry(ns_index, "hw_revision", hw_revision)
if legacy:
uid_entry, uid_span = _build_string_entry(ns_index, "device_uid", serial_number)
hwt_entry, hwt_span = _build_string_entry(ns_index, "hw_type", hw_family.lower())
hwv_entry, hwv_span = _build_string_entry(ns_index, "hw_version", hw_revision)
else:
uid_entry, uid_span = _build_string_entry(ns_index, "serial", serial_number)
hwt_entry, hwt_span = _build_string_entry(ns_index, "hw_family", hw_family.lower())
hwv_entry, hwv_span = _build_string_entry(ns_index, "hw_revision", hw_revision)
entries = [ns_entry, uid_entry, hwt_entry, hwv_entry]
spans = [ns_span, uid_span, hwt_span, hwv_span]