From bc255151a899a5f0da48cca5d8248e8e68994f22 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 2 Apr 2025 22:52:57 +0200 Subject: [PATCH] Reduce stack --- README.md | 14 +++++++------- platformio.ini | 9 +-------- sdkconfig.defaults | 11 +++++++++++ src/Config.h | 2 +- src/main.cpp | 2 +- src/networkDevices/NetworkDevice.cpp | 3 ++- src/networkDevices/WifiDevice.h | 1 - 7 files changed, 23 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 50dd063..01ba2b9 100644 --- a/README.md +++ b/README.md @@ -186,12 +186,12 @@ ESP32 devices have a limited amount of free RAM available.

On version >=9.10 of Nuki Hub with only a Nuki Lock connected the expected free amount of RAM/Heap available is around: -- ESP32: 40.000 bytes -- ESP32 with PSRAM: 90.000 bytes + PSRAM -- ESP32-C3: 45.000 bytes -- ESP32-C6: 170.000 bytes -- ESP32-S3 90.000 bytes -- ESP32-S3 with PSRAM: 130.000 bytes + PSRAM +- ESP32: 70.000 bytes +- ESP32 with PSRAM: 110.000 bytes + PSRAM +- ESP32-C3: 90.000 bytes +- ESP32-C6: 200.000 bytes +- ESP32-S3 130.000 bytes +- ESP32-S3 with PSRAM: 180.000 bytes + PSRAM This free amount of RAM can be reduced (temporarily) by certain actions (such as changing Nuki device config) or continuously when enabling the following: - Connecting both a Nuki opener and a Nuki lock to Nuki Hub @@ -709,7 +709,7 @@ Please follow the instructions for the [First time installation](#first-time-ins ## MQTT Encryption (optional) The communication via MQTT can be SSL encrypted.
-Note: MQTT SSL requires a significant amount of RAM and will not work in most cases on low RAM devices (ESP32 without PSRAM or ESP32-C3) +Note: MQTT SSL requires a significant amount of RAM and might not work on low RAM devices (ESP32 without PSRAM or ESP32-C3) To enable SSL encryption, supply the necessary information in the MQTT Configuration page.

diff --git a/platformio.ini b/platformio.ini index 6ea5182..0ba52dd 100644 --- a/platformio.ini +++ b/platformio.ini @@ -43,14 +43,7 @@ build_flags = -DNUKI_NO_WDT_RESET -DNUKI_MUTEX_RECURSIVE -DNUKI_64BIT_TIME - -DETH_SPI_SUPPORTS_NO_IRQ - -DEMC_RX_BUFFER_SIZE=1440 - -DEMC_TX_BUFFER_SIZE=1440 - -DEMC_MIN_FREE_MEMORY=8192 - -DEMC_TASK_STACK_SIZE=10240 - -DEMC_USE_MEMPOOL=1 - -DEMC_NUM_POOL_ELEMENTS=64 - -DEMC_SIZE_POOL_ELEMENTS=256 + -DETH_SPI_SUPPORTS_NO_IRQ -Wno-ignored-qualifiers -Wno-missing-field-initializers -Wno-type-limits diff --git a/sdkconfig.defaults b/sdkconfig.defaults index 2cb66bd..b7bf4b8 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -6,6 +6,17 @@ CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=y CONFIG_SPIFFS_GC_MAX_RUNS=512 CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=3072 +# REDUCE RAM USAGE +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y +CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y +CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=n +CONFIG_ESP32_REV_MIN=3 +CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=n +CONFIG_SPI_MASTER_ISR_IN_IRAM=n +CONFIG_SPI_SLAVE_ISR_IN_IRAM=n +CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=0 +CONFIG_HEAP_PLACE_FUNCTION_INTO_FLASH=y + # ARDUINO CONFIG_AUTOSTART_ARDUINO=y CONFIG_FREERTOS_HZ=1000 diff --git a/src/Config.h b/src/Config.h index e8c976a..5649086 100644 --- a/src/Config.h +++ b/src/Config.h @@ -5,7 +5,7 @@ #define NUKI_HUB_VERSION "9.10" #define NUKI_HUB_VERSION_INT (uint32_t)910 #define NUKI_HUB_BUILD "unknownbuildnr" -#define NUKI_HUB_DATE "2025-04-01" +#define NUKI_HUB_DATE "2025-04-02" #define GITHUB_LATEST_RELEASE_URL (char*)"https://github.com/technyon/nuki_hub/releases/latest" #define GITHUB_OTA_MANIFEST_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/manifest.json" diff --git a/src/main.cpp b/src/main.cpp index dd18e90..3bc5efd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,7 +14,7 @@ #include "esp_core_dump.h" #include "FS.h" #include "SPIFFS.h" -#include +//#include #ifdef CONFIG_SOC_SPIRAM_SUPPORTED #include "esp_psram.h" #endif diff --git a/src/networkDevices/NetworkDevice.cpp b/src/networkDevices/NetworkDevice.cpp index d4eedae..447a17c 100644 --- a/src/networkDevices/NetworkDevice.cpp +++ b/src/networkDevices/NetworkDevice.cpp @@ -16,7 +16,8 @@ void NetworkDevice::init() #ifdef CONFIG_SOC_SPIRAM_SUPPORTED if(esp_psram_get_size() > 0) { - _mqttInternal = true; + //_mqttInternal = true; + _mqttInternal = false; } #endif diff --git a/src/networkDevices/WifiDevice.h b/src/networkDevices/WifiDevice.h index a469318..9c29c08 100644 --- a/src/networkDevices/WifiDevice.h +++ b/src/networkDevices/WifiDevice.h @@ -5,7 +5,6 @@ #include "IPConfiguration.h" #include "esp_wifi.h" #include -#include class WifiDevice : public NetworkDevice {