Enable the on-demand mOTA context for every classic ESP32 build
Move OTA_HEAP_CONTEXT from two hand-edited envs to a pre-script gated on build.mcu == "esp32", so every classic ESP32 image gets it and none can drift. S2/S3/C-series and nRF52 keep the .bss singleton: they have no equivalent static-DRAM ceiling, so there a guaranteed-present workspace is the better trade for what is ultimately a recovery path. It has to be a build flag rather than a header default, because OTA_HEAP_CONTEXT must hold the same value in every translation unit that sees OtaContext.h - OtaContext.cpp included - and a header test on CONFIG_IDF_TARGET_ESP32 would depend on include order relative to sdkconfig.h. The script defers to OTA_SHARED_COMPANION_QUEUE where a Full Companion recipe already owns the storage. Fix a gap this exposes in the roles that now use it. Only CLI entry points acquire the context, so once it was released, a repeater with the temporary radio profile up would no longer serve or announce its own firmware - LoRa OTA would look enabled and silently do nothing. ota_service_temp_radio_context() holds the workspace for exactly the temp-radio window and hands it back outside it, which is where the saving was coming from anyway. Wired into the repeater, room server and sensor loops; the Companion keeps its own acquire-on-host-demand policy, since its context is borrowed from the offline message queue and must not be taken speculatively. Static DRAM, classic ESP32 (bytes occupied of a 124,580 region): Heltec_v2_repeater 108,332 -> 70,732 Heltec_v2_room_server 83,716 -> 68,300 Heltec_v2_companion_radio_ble 123,236 -> 107,772 (was failing on main) Tbeam_SX1262_repeater 86,932 -> 71,468 Tbeam_SX1262_repeater_observer_mqtt 121,132 -> 83,532 (was failing)
This commit is contained in:
1 parent
f6bc7a194a
commit
f0c4c6af00
8 files changed
+86
-6
No files matched your search
@@ -681,6 +681,22 @@ uint8_t ota_hop_limit();
|
||||
void ota_set_context_storage(void* owner, OtaContext* (*acquire)(void*),
|
||||
void (*release)(void*));
|
||||
void ota_release_context_if_idle(bool temporary_radio_active);
|
||||
|
||||
// Loop helper for roles whose LoRa OTA only runs under the temporary radio
|
||||
// profile (repeater, room server, sensor). Nothing else acquires the context
|
||||
// on their behalf: without this, serving and announcing would stop the moment
|
||||
// the context was released, because only CLI entry points acquire. Holding it
|
||||
// for the temp-radio window keeps behaviour identical to a permanent context,
|
||||
// and the node is outside that window nearly all the time, which is where the
|
||||
// saving comes from. Not for the Companion, whose context is borrowed from the
|
||||
// offline message queue and must only be taken on explicit host demand.
|
||||
inline void ota_service_temp_radio_context(bool temporary_radio_active) {
|
||||
if (temporary_radio_active) {
|
||||
ota_acquire_context(nullptr, 0); // failure is reported at the CLI entry points
|
||||
} else {
|
||||
ota_release_context_if_idle(false);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace ota
|
||||
|
||||
Reference in new issue
Block a user