Recover nRF OTA RAM without reducing catalog or staging capacity

This commit is contained in:
mikecarper committed 2026-10-17 15:50:17 -07:00
1 parent 5ee9ceeb20
commit 55960cebdc
4 files changed
+172 -12

No files matched your search

+15 -10
View File
@@ -324,15 +324,19 @@ public:
};
// A lightweight catalog entry: what we advertise per mota + how to load its ServeView on demand.
struct ServeEntry {
uint8_t mid[4];
uint32_t target_id, fw_version;
uint8_t codec_id, flags;
uint32_t have_count; // blocks we currently hold (== block_count when complete)
bool is_self; // true => entry is view0 (our own fw / RAM mota)
// Named fields only: this is not a wire/persistent layout. Group aligned
// values ahead of byte flags instead of paying three padding gaps per row.
MotaSource* src; // load from this external source ...
uint8_t src_idx; // ... at this index
MotaDesc desc; // cached region offsets for the source entry
uint32_t target_id, fw_version;
uint32_t have_count; // blocks we currently hold (== block_count when complete)
uint8_t mid[4];
uint8_t codec_id, flags;
bool is_self; // true => entry is view0 (our own fw / RAM mota)
uint8_t src_idx; // ... at this index
};
static_assert(sizeof(ServeEntry) <= sizeof(MotaDesc) + sizeof(MotaSource*) + 20u,
"OTA source catalog must not add per-entry alignment padding");
// Context for the source-payload reader trampoline.
struct SrcReadCtx { MotaSource* src; uint8_t idx; uint32_t payload_off; };
@@ -905,17 +909,18 @@ private:
struct Source {
uint8_t seeder[4];
uint8_t digest[4];
uint8_t n_motas;
uint32_t last_ms;
uint32_t have_mask;
uint32_t query_at;
uint32_t query_retry_at;
uint8_t n_motas;
bool have_catalog;
uint8_t have_total;
uint32_t have_mask;
bool query_pending;
bool query_owned;
uint8_t query_retries;
uint32_t query_at;
uint32_t query_retry_at;
};
static_assert(sizeof(Source) == 32u, "OTA source discovery rows must retain compact natural alignment");
Source _sources[OTA_MAX_SOURCES];
uint8_t _n_src = 0;
CatRow _catalog_inline[OTA_INLINE_CATALOG];
+17 -2
View File
@@ -126,7 +126,22 @@ class OtaStoreQspiNrf52 : public OtaStore {
static const uint32_t PAGE = 4096;
static const uint32_t PROGRAM = 256;
static const uint32_t MAX_FLASH = 16UL * 1024 * 1024;
static const uint32_t MAX_PAGES = MAX_FLASH / PAGE;
// Exact-board recipes already reject a different physical capacity before
// any page access. Track only that accepted geometry, without reducing the
// 16 MiB capability of generic builds or either staging page buffer.
#if defined(OTA_QSPI_EXPECTED_SIZE)
// Check the original constant before narrowing: 4 GiB + 2 MiB must not
// silently wrap into an apparently valid 2 MiB geometry.
static_assert((OTA_QSPI_EXPECTED_SIZE) >= (1ULL << 20) &&
(OTA_QSPI_EXPECTED_SIZE) <= MAX_FLASH &&
((OTA_QSPI_EXPECTED_SIZE) & ((OTA_QSPI_EXPECTED_SIZE) - 1ULL)) == 0ULL,
"expected QSPI capacity must match accepted 1..16 MiB JEDEC geometry");
static const uint32_t TRACKED_FLASH = OTA_QSPI_EXPECTED_SIZE;
#else
static const uint32_t TRACKED_FLASH = MAX_FLASH;
#endif
static const uint32_t MAX_PAGES = TRACKED_FLASH / PAGE;
static const uint32_t KNOWN_PAGE_BYTES = (MAX_PAGES + 7u) / 8u;
static const uint32_t INVALID_PAGE = 0xFFFFFFFFUL;
uint32_t _total = 0;
@@ -150,7 +165,7 @@ class OtaStoreQspiNrf52 : public OtaStore {
alignas(4) uint8_t _meta_page[PAGE];
alignas(4) uint8_t _data_page[PAGE];
alignas(4) uint8_t _bounce[PROGRAM];
uint8_t _known_pages[MAX_PAGES / 8];
uint8_t _known_pages[KNOWN_PAGE_BYTES ? KNOWN_PAGE_BYTES : 1u];
void fail(const char *message);
bool ensureFlash();