From 56afcb8fd9b3e76532a5af8ef17286de938bde2e Mon Sep 17 00:00:00 2001 From: mikecarper Date: Thu, 20 Aug 2026 00:16:43 -0700 Subject: [PATCH] Optimize constrained ESP32 build profiles --- build.sh | 44 ++++++++++++++++++--- variants/generic-e22/platformio.ini | 2 + variants/heltec_v2/platformio.ini | 1 + variants/lilygo_tbeam_SX1262/platformio.ini | 1 + variants/lilygo_tbeam_SX1276/platformio.ini | 1 + variants/lilygo_tlora_v2_1/platformio.ini | 2 + variants/meshadventurer/platformio.ini | 2 + 7 files changed, 47 insertions(+), 6 deletions(-) diff --git a/build.sh b/build.sh index 9041ede1..2bb45296 100755 --- a/build.sh +++ b/build.sh @@ -2115,9 +2115,9 @@ supports_esp32_full_build() { requires_esp32_full_cli_profile() { local env_name=$1 - # MQTT observers and ESP-NOW bridges previously depended on a reduced CLI to - # fit the legacy application slot. Always build those roles with the expanded - # FULL partition profile so no administration commands are removed. + # MQTT observers and ESP-NOW bridges do not fit their legacy application + # slots with the complete CLI. Always build those roles with the expanded + # FULL partition profile so no commands are removed. [ "${PIO_ENV_PLATFORM_BY_NAME[$env_name]:-}" = "ESP32_PLATFORM" ] \ && ! is_esp32_companion_build "$env_name" \ && { is_mqtt_bridge_target "$env_name" \ @@ -2145,9 +2145,11 @@ apply_esp32_lora_ota_size_profile() { # The no-external-sensors image is also the self-updatable field image. Keep # manual browser OTA available on every ESP32 family through the compact # uploader, the complete role CLI, and the full one-byte neighbor-index - # range. - append_platformio_build_unflags "-DDISABLE_WIFI_OTA=1 -DMAX_NEIGHBOURS=50 -DMAX_NEIGHBOURS=8" - export PLATFORMIO_BUILD_FLAGS="${PLATFORMIO_BUILD_FLAGS} -UDISABLE_WIFI_OTA -DLIGHTWEIGHT_WIFI_OTA=1 -DMAX_NEIGHBOURS=${ESP32_FULL_MAX_NEIGHBOURS}" + # range. MeshCore and this source-built dependency set do not use C++ + # exceptions, so omit their otherwise forced runtime tables instead of + # dropping WiFi OTA, LoRa OTA, USB seeding, or CLI commands. + append_platformio_build_unflags "-DDISABLE_WIFI_OTA=1 -DMAX_NEIGHBOURS=50 -DMAX_NEIGHBOURS=8 -fexceptions" + export PLATFORMIO_BUILD_FLAGS="${PLATFORMIO_BUILD_FLAGS} -UDISABLE_WIFI_OTA -DLIGHTWEIGHT_WIFI_OTA=1 -DMAX_NEIGHBOURS=${ESP32_FULL_MAX_NEIGHBOURS} -fno-exceptions" else append_platformio_build_unflags "-DLIGHTWEIGHT_WIFI_OTA=1" export PLATFORMIO_BUILD_FLAGS="${PLATFORMIO_BUILD_FLAGS} -ULIGHTWEIGHT_WIFI_OTA -DDISABLE_WIFI_OTA=1" @@ -2155,6 +2157,35 @@ apply_esp32_lora_ota_size_profile() { } +apply_esp32_constrained_companion_size_profile() { + local env_name=$1 + + if [ "${PIO_ENV_PLATFORM_BY_NAME[$env_name]:-}" != "ESP32_PLATFORM" ]; then + return 0 + fi + + # These 1.25 MiB companion images had only 22-66 KiB of measured app-slot + # headroom. MeshCore and their source-built dependencies do not use C++ + # exceptions, so omit the exception runtime instead of reducing contacts, + # queues, BLE, WiFi, GPS, display support, or CLI commands. Keep this scoped + # to measured constrained targets; expanded FULL builds do not need it. + case "${env_name,,}" in + station_g2_companion_radio_ble \ + |thinknode_m2_companion_radio_ble \ + |thinknode_m2_companion_radio_wifi \ + |lilygo_t3s3_sx1262_companion_radio_ble \ + |lilygo_t3s3_sx1262_companion_radio_ble_ps \ + |lilygo_t3s3_sx1276_companion_radio_ble \ + |nibble_zero_connect_companion_radio_ble_ \ + |nibble_zero_connect_companion_radio_wifi_ \ + |nibble_screen_connect_companion_radio_ble_ \ + |nibble_screen_connect_companion_radio_wifi_) + append_platformio_build_unflags "-fexceptions" + export PLATFORMIO_BUILD_FLAGS="${PLATFORMIO_BUILD_FLAGS} -fno-exceptions" + ;; + esac +} + apply_esp32_full_size_profile() { local env_name=$1 local max_neighbours=$ESP32_FULL_MAX_NEIGHBOURS @@ -2779,6 +2810,7 @@ build_firmware() { apply_companion_radio_full_profile "$env_name" "$pio_env_name" apply_nrf52_lora_ota_build_recipe "$env_name" "$pio_env_name" apply_esp32_lora_ota_size_profile "$env_name" + apply_esp32_constrained_companion_size_profile "$env_name" apply_esp32_full_size_profile "$env_name" apply_repeater_neighbor_capacity "$env_name" apply_nrf52_size_profile "$env_name" diff --git a/variants/generic-e22/platformio.ini b/variants/generic-e22/platformio.ini index 47d2ce55..e869eef8 100644 --- a/variants/generic-e22/platformio.ini +++ b/variants/generic-e22/platformio.ini @@ -90,6 +90,7 @@ build_flags = -D ADVERT_LON=0.0 -D ADMIN_PASSWORD='"password"' -D MAX_NEIGHBOURS=50 + -D FLOOD_CHANNEL_SCOPE_SLOTS=31 ; classic ESP32 DRAM cannot fit the default 255 with ESP-NOW -D WITH_ESPNOW_BRIDGE=1 -D DISABLE_LORA_OTA=1 ; ESP-NOW plus LoRa OTA overflows classic ESP32 DRAM ; -D BRIDGE_DEBUG=1 @@ -172,6 +173,7 @@ build_flags = -D ADVERT_LON=0.0 -D ADMIN_PASSWORD='"password"' -D MAX_NEIGHBOURS=50 + -D FLOOD_CHANNEL_SCOPE_SLOTS=31 ; classic ESP32 DRAM cannot fit the default 255 with ESP-NOW -D WITH_ESPNOW_BRIDGE=1 -D DISABLE_LORA_OTA=1 ; ESP-NOW plus LoRa OTA overflows classic ESP32 DRAM ; -D BRIDGE_DEBUG=1 diff --git a/variants/heltec_v2/platformio.ini b/variants/heltec_v2/platformio.ini index 8f572c84..198a1778 100644 --- a/variants/heltec_v2/platformio.ini +++ b/variants/heltec_v2/platformio.ini @@ -83,6 +83,7 @@ build_flags = -D ADVERT_LON=0.0 -D ADMIN_PASSWORD='"password"' -D MAX_NEIGHBOURS=50 + -D FLOOD_CHANNEL_SCOPE_SLOTS=31 ; classic ESP32 DRAM cannot fit the default 255 with ESP-NOW -D WITH_ESPNOW_BRIDGE=1 -D DISABLE_LORA_OTA=1 ; ESP-NOW plus LoRa OTA overflows classic ESP32 DRAM ; -D BRIDGE_DEBUG=1 diff --git a/variants/lilygo_tbeam_SX1262/platformio.ini b/variants/lilygo_tbeam_SX1262/platformio.ini index 20263afd..2f5d94e6 100644 --- a/variants/lilygo_tbeam_SX1262/platformio.ini +++ b/variants/lilygo_tbeam_SX1262/platformio.ini @@ -120,6 +120,7 @@ build_flags = -D ADVERT_LON=0.0 -D ADMIN_PASSWORD='"password"' -D MAX_NEIGHBOURS=50 + -D FLOOD_CHANNEL_SCOPE_SLOTS=31 ; classic ESP32 DRAM cannot fit the default 255 with ESP-NOW -D WITH_ESPNOW_BRIDGE=1 -D DISABLE_LORA_OTA=1 ; ESP-NOW plus LoRa OTA overflows this board's internal DRAM ; -D BRIDGE_DEBUG=1 diff --git a/variants/lilygo_tbeam_SX1276/platformio.ini b/variants/lilygo_tbeam_SX1276/platformio.ini index aad99a10..92ae1843 100644 --- a/variants/lilygo_tbeam_SX1276/platformio.ini +++ b/variants/lilygo_tbeam_SX1276/platformio.ini @@ -116,6 +116,7 @@ build_flags = -D ADMIN_PASSWORD='"password"' -D MAX_NEIGHBOURS=50 -D PERSISTANT_GPS=1 + -D FLOOD_CHANNEL_SCOPE_SLOTS=31 ; classic ESP32 DRAM cannot fit the default 255 with ESP-NOW -D WITH_ESPNOW_BRIDGE=1 -D DISABLE_LORA_OTA=1 ; ESP-NOW plus LoRa OTA overflows classic ESP32 DRAM ; -D BRIDGE_DEBUG=1 diff --git a/variants/lilygo_tlora_v2_1/platformio.ini b/variants/lilygo_tlora_v2_1/platformio.ini index ae617123..f2f2ebf0 100644 --- a/variants/lilygo_tlora_v2_1/platformio.ini +++ b/variants/lilygo_tlora_v2_1/platformio.ini @@ -294,6 +294,7 @@ build_flags = -D ADVERT_LON=0.0 -D ADMIN_PASSWORD='"password"' -D MAX_NEIGHBOURS=50 + -D FLOOD_CHANNEL_SCOPE_SLOTS=31 ; classic ESP32 DRAM cannot fit the default 255 with bridge logging -D WITH_RS232_BRIDGE=Serial2 -D WITH_RS232_BRIDGE_RX=34 -D WITH_RS232_BRIDGE_TX=25 @@ -319,6 +320,7 @@ build_flags = -D ADVERT_LON=0.0 -D ADMIN_PASSWORD='"password"' -D MAX_NEIGHBOURS=50 + -D FLOOD_CHANNEL_SCOPE_SLOTS=31 ; classic ESP32 DRAM cannot fit the default 255 with ESP-NOW -D WITH_ESPNOW_BRIDGE=1 -D DISABLE_LORA_OTA=1 ; ESP-NOW plus LoRa OTA overflows classic ESP32 DRAM ; -D BRIDGE_DEBUG=1 diff --git a/variants/meshadventurer/platformio.ini b/variants/meshadventurer/platformio.ini index 85216acd..7eb1b8e4 100644 --- a/variants/meshadventurer/platformio.ini +++ b/variants/meshadventurer/platformio.ini @@ -97,6 +97,7 @@ build_flags = -D ADVERT_LON=0.0 -D ADMIN_PASSWORD='"password"' -D MAX_NEIGHBOURS=50 + -D FLOOD_CHANNEL_SCOPE_SLOTS=31 ; classic ESP32 DRAM cannot fit the default 255 with ESP-NOW -D WITH_ESPNOW_BRIDGE=1 -D DISABLE_LORA_OTA=1 ; ESP-NOW plus LoRa OTA overflows classic ESP32 DRAM ; -D BRIDGE_DEBUG=1 @@ -168,6 +169,7 @@ build_flags = -D ADVERT_LON=0.0 -D ADMIN_PASSWORD='"password"' -D MAX_NEIGHBOURS=50 + -D FLOOD_CHANNEL_SCOPE_SLOTS=31 ; classic ESP32 DRAM cannot fit the default 255 with ESP-NOW -D WITH_ESPNOW_BRIDGE=1 -D DISABLE_LORA_OTA=1 ; ESP-NOW plus LoRa OTA overflows classic ESP32 DRAM ; -D BRIDGE_DEBUG=1