From c96bdd6eeb65e67a837faafaf395a8695d3bef32 Mon Sep 17 00:00:00 2001 From: mikecarper Date: Tue, 11 Aug 2026 16:54:49 -0700 Subject: [PATCH] Size-optimize nRF52 LoRa OTA builds --- build.sh | 19 +++++++++++++++++++ docs/ota_easy.md | 5 +++++ docs/ota_protocol.md | 5 +++++ 3 files changed, 29 insertions(+) diff --git a/build.sh b/build.sh index 0ac16701d..5e9e3bf30 100755 --- a/build.sh +++ b/build.sh @@ -2184,6 +2184,24 @@ apply_repeater_neighbor_capacity() { export PLATFORMIO_BUILD_FLAGS="${PLATFORMIO_BUILD_FLAGS} -DMAX_NEIGHBOURS=${max_neighbours}" } +apply_nrf52_lora_ota_size_profile() { + local env_name=$1 + + if [ "${PIO_ENV_PLATFORM_BY_NAME[$env_name]:-}" != "NRF52_PLATFORM" ] \ + || ! is_lora_ota_build "$env_name" \ + || ! is_lora_ota_only_target "$env_name"; then + return 0 + fi + + # The Adafruit nRF52 platform defaults release builds to -Ofast. Once the + # runtime software Ed25519 fallback is linked alongside CC310, that setting + # fully expands repeated Curve25519 arithmetic and wastes tens of kilobytes. + # Keep hardware crypto, RNG mixing, the software fallback, and board features; + # only select the size optimizer for the constrained self-updatable image. + append_platformio_build_unflags "-Ofast" + export PLATFORMIO_BUILD_FLAGS="${PLATFORMIO_BUILD_FLAGS} -Os" +} + apply_lora_ota_no_external_sensors_profile() { local env_name=$1 @@ -2712,6 +2730,7 @@ build_firmware() { apply_esp32_lora_ota_size_profile "$env_name" apply_esp32_full_size_profile "$env_name" apply_repeater_neighbor_capacity "$env_name" + apply_nrf52_lora_ota_size_profile "$env_name" apply_lora_ota_no_external_sensors_profile "$env_name" apply_radio_overrides apply_firmware_profile_overrides diff --git a/docs/ota_easy.md b/docs/ota_easy.md index fbf2a8220..d9e572b2f 100644 --- a/docs/ota_easy.md +++ b/docs/ota_easy.md @@ -65,6 +65,11 @@ browser WiFi uploader (`start ota`) and use a 254-entry neighbor table. RP2040 a currently have a safe self-apply path, but current repeater firmware can still relay OTA packets opaquely during TempRadio. +nRF52 `-ota-` siblings are compiled with size optimization instead of the Adafruit platform's default +speed optimization. This prevents the retained software Ed25519 fallback from expanding beyond the fixed +in-place workspace; CC310 hardware crypto, hardware RNG mixing, telemetry history, and board-native features +remain enabled. + ESP32 `*-full-ota-*` artifacts retain all compiled features and enable LoRa OTA for every FULL role, including room servers, sensors, observers, and bridges. A FULL image requires its expanded partition table: install the matching merged image over USB once before installing later non-merged FULL updates over LoRa. diff --git a/docs/ota_protocol.md b/docs/ota_protocol.md index b3ceae380..ac4f2a69a 100644 --- a/docs/ota_protocol.md +++ b/docs/ota_protocol.md @@ -126,6 +126,11 @@ board-native telemetry remain enabled. ESP32 siblings retain the compact browser full 254-entry neighbor table. RP2040 and STM32 targets are not offered because those platforms do not yet have a safe bootloader/apply path. +nRF52 LoRa-OTA siblings use size optimization rather than the Adafruit platform's default `-Ofast`. This +keeps the runtime software Ed25519 fallback from being expanded into tens of kilobytes of repeated curve +arithmetic while retaining CC310 hardware crypto, hardware RNG mixing, telemetry history, and board-native +features. + Two WiFi-heavy non-companion profiles need additional reductions to remain portable. MQTT observer builds keep MQTT/TLS, onboard GPS, and their WiFi pull-updater, but omit WebConfig, SNMP, debug logging, display support, and optional external sensor drivers. Their compact CLI keeps observer controls plus the radio,