diff --git a/environments.ini b/environments.ini index 179992a..ac3c070 100644 --- a/environments.ini +++ b/environments.ini @@ -851,7 +851,8 @@ custom_hardware = M5 ATOM Lite custom_img = img/boards/m5atom-lite.webp [env:esp32doitv1-aithinker-r01-sx1278] -platform = espressif32@6.1.0 +platform = ${com.esp32_platform} +platform_packages = ${com.esp32_platform_packages} board = esp32doit-devkit-v1 board_build.partitions = min_spiffs.csv lib_deps = @@ -931,7 +932,8 @@ upload_flags = --port=8266 [env:esp32dev-rtl_433] -platform = espressif32@6.1.0 +platform = ${com.esp32_platform} +platform_packages = ${com.esp32_platform_packages} board = esp32dev board_build.partitions = min_spiffs.csv lib_deps = @@ -972,7 +974,8 @@ custom_description = Gateway using RTL_433_ESP library, need CC1101 custom_img = img/boards/esp32dev.jpg [env:esp32dev-rtl_433-fsk] -platform = espressif32@6.1.0 +platform = ${com.esp32_platform} +platform_packages = ${com.esp32_platform_packages} board = esp32dev board_build.partitions = min_spiffs.csv lib_deps = @@ -1017,7 +1020,8 @@ custom_description = Gateway using RTL_433_ESP library and RadioLib with FSK mod custom_img = img/boards/esp32dev.jpg [env:heltec-rtl_433] -platform = espressif32@6.1.0 +platform = ${com.esp32_platform} +platform_packages = ${com.esp32_platform_packages} board = heltec_wifi_lora_32_V2 ; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h board_build.partitions = min_spiffs.csv @@ -1047,7 +1051,8 @@ custom_hardware = ESP32 HELTEC LORA32 V2 custom_img = img/boards/heltec-wifi-lora-32.png [env:heltec-rtl_433-fsk] -platform = espressif32@6.1.0 +platform = ${com.esp32_platform} +platform_packages = ${com.esp32_platform_packages} board = heltec_wifi_lora_32_V2 ; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h board_build.partitions = min_spiffs.csv @@ -1107,7 +1112,8 @@ custom_hardware = ESP32 HELTEC LORA32 V2 custom_img = img/boards/heltec-wifi-lora-32.png [env:lilygo-rtl_433] -platform = espressif32@6.1.0 +platform = ${com.esp32_platform} +platform_packages = ${com.esp32_platform_packages} board = ttgo-lora32-v21 ; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h board_build.partitions = min_spiffs.csv @@ -1137,7 +1143,8 @@ custom_hardware = ESP32 LILYGO LoRa32 V2.1 custom_img = img/boards/lilygo-lora32-v21.jpg [env:lilygo-rtl_433-fsk] -platform = espressif32@6.1.0 +platform = ${com.esp32_platform} +platform_packages = ${com.esp32_platform_packages} board = ttgo-lora32-v21 ; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h board_build.partitions = min_spiffs.csv @@ -1295,7 +1302,8 @@ custom_hardware = ESP32 LILYGO LoRa32 V2.1 custom_img = img/boards/lilygo-lora32-v21.jpg [env:esp32dev-multi_receiver] -platform = espressif32@6.1.0 +platform = ${com.esp32_platform} +platform_packages = ${com.esp32_platform_packages} board = esp32dev board_build.partitions = min_spiffs.csv lib_deps = diff --git a/main/main.cpp b/main/main.cpp index 9bcb68e..3a40c4b 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -35,6 +35,10 @@ #include "TheengsCommon.h" #include "TheengsUtils.h" +#if defined(CONFIG_IDF_TARGET_ESP32) && !defined(ZgatewayBT) && !defined(USE_BLUFI) +# include "esp_bt.h" // esp_bt_mem_release() — BT DRAM reclaim in setup() +#endif + GatewayState gatewayState = GatewayState::WAITING_ONBOARDING; static GatewayState previousGatewayState = gatewayState; @@ -1340,6 +1344,23 @@ void setup() { Serial.begin(SERIAL_BAUD); Log.begin(LOG_LEVEL, &Serial); THEENGS_LOG_NOTICE(F(CR "************* WELCOME TO OpenMQTTGateway **************" CR)); +#if defined(CONFIG_IDF_TARGET_ESP32) && !defined(ZgatewayBT) && !defined(USE_BLUFI) + // Reclaim the Bluetooth controller's reserved DRAM on BT-less ESP32 builds. + // arduino-esp32 3.x releases only the BLE slice: esp32-hal-bt.c initialises + // _classicMemReleased = true whenever CONFIG_BT_CLASSIC_ENABLED is unset, + // which is the case for a BLE-only controller build — so its + // btMemRelease(BT_MODE_CLASSIC_BT) call short-circuits and ~33 KB of the + // 0xdb5c reservation is never returned to the heap. ESP32 has Classic BT + // hardware (CONFIG_SOC_BT_CLASSIC_SUPPORTED) and the DRAM is reserved + // regardless of the configured controller mode. arduino-esp32 2.x released + // the whole BTDM region unconditionally here. + // Safe no-op if the core ever releases it correctly, or if BT is later started. + { + uint32_t heapBeforeBtRelease = ESP.getFreeHeap(); + esp_bt_mem_release(ESP_BT_MODE_BTDM); + THEENGS_LOG_NOTICE(F("BT DRAM reclaimed: %d -> %d" CR), heapBeforeBtRelease, ESP.getFreeHeap()); + } +#endif #if defined(TRIGGER_GPIO) && !defined(ESPWifiManualSetup) pinMode(TRIGGER_GPIO, INPUT_PULLUP); checkButton();