Harden LoRa OTA and enable unattended targets

This commit is contained in:
mikecarper committed 2026-07-14 15:24:35 -07:00
1 parent 8599cf0acb
commit 11aa4bc191
17 files changed
+204 -86

No files matched your search

+7 -4
View File
@@ -67,8 +67,10 @@ bool ota_self_firmware(SelfFwInfo& out) {
// APP_BASE; find_self_firmware() picks the EndF whose stored body_len equals its offset (the running
// firmware's own trailer), ignoring any staged `.mota` (which carries its own embedded EndF) higher up.
bool ota_self_firmware(SelfFwInfo& out) {
const uint8_t* region = (const uint8_t*)(uintptr_t)MOTA_NRF52_APP_BASE;
uint32_t region_len = MOTA_NRF52_FS_START - MOTA_NRF52_APP_BASE;
const uint32_t app_base = mota_nrf52_app_base();
if (!mota_nrf52_layout_valid(app_base)) { out = SelfFwInfo(); return false; }
const uint8_t* region = (const uint8_t*)(uintptr_t)app_base;
uint32_t region_len = MOTA_NRF52_FS_START - app_base;
return find_self_firmware(region, region_len, out, /*verify_body=*/true);
}
#else
@@ -86,8 +88,9 @@ bool ota_self_read(uint32_t off, uint8_t* buf, uint32_t len) {
}
#elif defined(NRF52_PLATFORM)
bool ota_self_read(uint32_t off, uint8_t* buf, uint32_t len) {
if ((uint64_t)MOTA_NRF52_APP_BASE + off + len > MOTA_NRF52_FS_START) return false;
memcpy(buf, (const uint8_t*)(uintptr_t)(MOTA_NRF52_APP_BASE + off), len);
const uint32_t app_base = mota_nrf52_app_base();
if (!mota_nrf52_layout_valid(app_base) || (uint64_t)app_base + off + len > MOTA_NRF52_FS_START) return false;
memcpy(buf, (const uint8_t*)(uintptr_t)(app_base + off), len);
return true;
}
#else