From a1ded5d39519b1cb0ddb5faeed16b98701410605 Mon Sep 17 00:00:00 2001 From: TD-er Date: Sun, 10 Nov 2024 14:42:00 +0100 Subject: [PATCH 1/5] [PSRAM] Free GPIO-16 and -17 on ESP32-classic when no PSRAM present --- src/src/ESPEasyCore/ESPEasy_setup.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/src/ESPEasyCore/ESPEasy_setup.cpp b/src/src/ESPEasyCore/ESPEasy_setup.cpp index 84a6384a30..5213ae3630 100644 --- a/src/src/ESPEasyCore/ESPEasy_setup.cpp +++ b/src/src/ESPEasyCore/ESPEasy_setup.cpp @@ -63,6 +63,8 @@ # include "hal/efuse_hal.h" #else #include +// IDF5.3 fix esp_gpio_reserve used in init PSRAM. +#include "esp_private/esp_gpio_reserve.h" #endif #endif @@ -150,6 +152,10 @@ void ESPEasy_setup() #endif uint32_t pkg_version = chip_ver & 0x7; if (pkg_version <= 3) { // D0WD, S0WD, D2WD + #if ESP_IDF_VERSION_MAJOR >= 5 + // Thanks Theo Arends from Tasmota + esp_gpio_revoke(BIT64(GPIO_NUM_16 | GPIO_NUM_17)); + #endif gpio_reset_pin(GPIO_NUM_16); gpio_reset_pin(GPIO_NUM_17); } From 3c0d965966a6c322032ccf7518fbf6f9776caaed Mon Sep 17 00:00:00 2001 From: TD-er Date: Sun, 10 Nov 2024 15:35:59 +0100 Subject: [PATCH 2/5] [PSRAM] Fix build on ESP-IDF 5.1 + add special case of ESP32-picoD4 --- src/src/ESPEasyCore/ESPEasy_setup.cpp | 43 +++++++++++++++++++----- src/src/Helpers/Hardware_device_info.cpp | 3 +- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/src/ESPEasyCore/ESPEasy_setup.cpp b/src/src/ESPEasyCore/ESPEasy_setup.cpp index 5213ae3630..2280620d51 100644 --- a/src/src/ESPEasyCore/ESPEasy_setup.cpp +++ b/src/src/ESPEasyCore/ESPEasy_setup.cpp @@ -62,9 +62,13 @@ # include "hal/efuse_ll.h" # include "hal/efuse_hal.h" #else -#include +# include +# include + +# if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 2, 0) // IDF5.3 fix esp_gpio_reserve used in init PSRAM. -#include "esp_private/esp_gpio_reserve.h" +# include "esp_private/esp_gpio_reserve.h" +# endif #endif #endif @@ -147,17 +151,38 @@ void ESPEasy_setup() // test if the CPU is not pico #if ESP_IDF_VERSION_MAJOR < 5 uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG); + uint32_t pkg_version = chip_ver & 0x7; #else + uint32_t pkg_version = bootloader_common_get_chip_ver_pkg(); uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_PACKAGE); #endif - uint32_t pkg_version = chip_ver & 0x7; - if (pkg_version <= 3) { // D0WD, S0WD, D2WD - #if ESP_IDF_VERSION_MAJOR >= 5 + if (pkg_version <= 7) { // D0WD, S0WD, D2WD + gpio_num_t PSRAM_CLK = GPIO_NUM_17; + gpio_num_t PSRAM_CS = GPIO_NUM_16; + switch (pkg_version) { + case EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5: + PSRAM_CLK = static_cast(CONFIG_D2WD_PSRAM_CLK_IO); + PSRAM_CS = static_cast(CONFIG_D2WD_PSRAM_CS_IO); + break; + case EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4: + case EFUSE_RD_CHIP_VER_PKG_ESP32PICOV302: + PSRAM_CLK = static_cast(GPIO_NUM_NC); + PSRAM_CS = static_cast(CONFIG_PICO_PSRAM_CS_IO); + break; + } + +#if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 2, 0) // Thanks Theo Arends from Tasmota - esp_gpio_revoke(BIT64(GPIO_NUM_16 | GPIO_NUM_17)); - #endif - gpio_reset_pin(GPIO_NUM_16); - gpio_reset_pin(GPIO_NUM_17); + if (PSRAM_CLK != GPIO_NUM_NC) { + esp_gpio_revoke(BIT64(PSRAM_CLK) | BIT64(PSRAM_CS)); + } else { + esp_gpio_revoke(BIT64(PSRAM_CS)); + } +#endif + if (PSRAM_CLK != GPIO_NUM_NC) { + gpio_reset_pin(PSRAM_CLK); + } + gpio_reset_pin(PSRAM_CS); } } #endif // if CONFIG_IDF_TARGET_ESP32 diff --git a/src/src/Helpers/Hardware_device_info.cpp b/src/src/Helpers/Hardware_device_info.cpp index 2c21db8967..4de0c6b145 100644 --- a/src/src/Helpers/Hardware_device_info.cpp +++ b/src/src/Helpers/Hardware_device_info.cpp @@ -503,10 +503,11 @@ const __FlashStringHelper* getChipModel() { */ # if ESP_IDF_VERSION_MAJOR < 5 uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG); + pkg_version = chip_ver & 0x7; # else // if ESP_IDF_VERSION_MAJOR < 5 uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_PACKAGE); # endif // if ESP_IDF_VERSION_MAJOR < 5 - pkg_version = chip_ver & 0x7; + // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HDW: ESP32 Model %d, Revision %d, Core %d, Package %d"), chip_info.model, chip_revision, // chip_info.cores, chip_ver); From c1e85e79898daf25cc754e4143cbd0215338b793 Mon Sep 17 00:00:00 2001 From: TD-er Date: Sun, 10 Nov 2024 15:45:04 +0100 Subject: [PATCH 3/5] [PSRAM] Cleanup code --- src/src/ESPEasyCore/ESPEasy_setup.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/src/ESPEasyCore/ESPEasy_setup.cpp b/src/src/ESPEasyCore/ESPEasy_setup.cpp index 2280620d51..4023e6387d 100644 --- a/src/src/ESPEasyCore/ESPEasy_setup.cpp +++ b/src/src/ESPEasyCore/ESPEasy_setup.cpp @@ -157,19 +157,19 @@ void ESPEasy_setup() uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_PACKAGE); #endif if (pkg_version <= 7) { // D0WD, S0WD, D2WD - gpio_num_t PSRAM_CLK = GPIO_NUM_17; - gpio_num_t PSRAM_CS = GPIO_NUM_16; - switch (pkg_version) { - case EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5: - PSRAM_CLK = static_cast(CONFIG_D2WD_PSRAM_CLK_IO); - PSRAM_CS = static_cast(CONFIG_D2WD_PSRAM_CS_IO); - break; - case EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4: - case EFUSE_RD_CHIP_VER_PKG_ESP32PICOV302: - PSRAM_CLK = static_cast(GPIO_NUM_NC); - PSRAM_CS = static_cast(CONFIG_PICO_PSRAM_CS_IO); - break; - } + gpio_num_t PSRAM_CLK = static_cast(CONFIG_D0WD_PSRAM_CLK_IO); + gpio_num_t PSRAM_CS = static_cast(CONFIG_D0WD_PSRAM_CS_IO); + switch (pkg_version) { + case EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5: + PSRAM_CLK = static_cast(CONFIG_D2WD_PSRAM_CLK_IO); + PSRAM_CS = static_cast(CONFIG_D2WD_PSRAM_CS_IO); + break; + case EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4: + case EFUSE_RD_CHIP_VER_PKG_ESP32PICOV302: + PSRAM_CLK = static_cast(GPIO_NUM_NC); + PSRAM_CS = static_cast(CONFIG_PICO_PSRAM_CS_IO); + break; + } #if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 2, 0) // Thanks Theo Arends from Tasmota From 79baa3eef651719ae866ef4d574679fb07645f97 Mon Sep 17 00:00:00 2001 From: TD-er Date: Sun, 10 Nov 2024 21:06:38 +0100 Subject: [PATCH 4/5] [PSRAM] Fix solo1 builds --- src/src/ESPEasyCore/ESPEasy_setup.cpp | 251 ++++++++++++++------------ 1 file changed, 136 insertions(+), 115 deletions(-) diff --git a/src/src/ESPEasyCore/ESPEasy_setup.cpp b/src/src/ESPEasyCore/ESPEasy_setup.cpp index 4023e6387d..907a3dd5c2 100644 --- a/src/src/ESPEasyCore/ESPEasy_setup.cpp +++ b/src/src/ESPEasyCore/ESPEasy_setup.cpp @@ -46,33 +46,34 @@ #ifdef ESP32 -#if ESP_IDF_VERSION_MAJOR < 5 -#include -#include -#include -#include -#else -#include -#include -#include -#endif - -#if CONFIG_IDF_TARGET_ESP32 -#if ESP_IDF_VERSION_MAJOR < 5 -# include "hal/efuse_ll.h" -# include "hal/efuse_hal.h" -#else -# include -# include - -# if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 2, 0) +# if ESP_IDF_VERSION_MAJOR < 5 +# include +# include +# include +# include +# else // if ESP_IDF_VERSION_MAJOR < 5 +# include +# include +# include +# endif // if ESP_IDF_VERSION_MAJOR < 5 + +# if CONFIG_IDF_TARGET_ESP32 +# if ESP_IDF_VERSION_MAJOR < 5 +# include "hal/efuse_ll.h" +# include "hal/efuse_hal.h" +# else // if ESP_IDF_VERSION_MAJOR < 5 +# include +# include + +# if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 2, 0) + // IDF5.3 fix esp_gpio_reserve used in init PSRAM. -# include "esp_private/esp_gpio_reserve.h" -# endif -#endif -#endif +# include "esp_private/esp_gpio_reserve.h" +# endif // if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 2, 0) +# endif // if ESP_IDF_VERSION_MAJOR < 5 +# endif // if CONFIG_IDF_TARGET_ESP32 -#endif +#endif // ifdef ESP32 #ifdef USE_RTOS_MULTITASKING @@ -81,9 +82,9 @@ void RTOS_TaskServers(void *parameter) while (true) { delay(100); web_server.handleClient(); - #if FEATURE_ESPEASY_P2P + # if FEATURE_ESPEASY_P2P checkUDP(); - #endif + # endif // if FEATURE_ESPEASY_P2P } } @@ -128,37 +129,41 @@ void sw_watchdog_callback(void *arg) void ESPEasy_setup() { #if defined(ESP8266_DISABLE_EXTRA4K) || defined(USE_SECOND_HEAP) -// disable_extra4k_at_link_time(); -#endif + + // disable_extra4k_at_link_time(); +#endif // if defined(ESP8266_DISABLE_EXTRA4K) || defined(USE_SECOND_HEAP) #ifdef PHASE_LOCKED_WAVEFORM enablePhaseLockedWaveform(); -#endif +#endif // ifdef PHASE_LOCKED_WAVEFORM #ifdef USE_SECOND_HEAP HeapSelectDram ephemeral; -#endif +#endif // ifdef USE_SECOND_HEAP #ifdef ESP32 -#ifdef DISABLE_ESP32_BROWNOUT - DisableBrownout(); // Workaround possible weak LDO resulting in brownout detection during Wifi connection -#endif // DISABLE_ESP32_BROWNOUT +# ifdef DISABLE_ESP32_BROWNOUT + DisableBrownout(); // Workaround possible weak LDO resulting in brownout detection during Wifi connection +# endif // DISABLE_ESP32_BROWNOUT -#ifdef BOARD_HAS_PSRAM +# ifdef BOARD_HAS_PSRAM psramInit(); -#endif +# endif // ifdef BOARD_HAS_PSRAM + +# if CONFIG_IDF_TARGET_ESP32 -#if CONFIG_IDF_TARGET_ESP32 // restore GPIO16/17 if no PSRAM is found if (!FoundPSRAM()) { // test if the CPU is not pico - #if ESP_IDF_VERSION_MAJOR < 5 - uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG); + # if ESP_IDF_VERSION_MAJOR < 5 + uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG); uint32_t pkg_version = chip_ver & 0x7; - #else + # else // if ESP_IDF_VERSION_MAJOR < 5 uint32_t pkg_version = bootloader_common_get_chip_ver_pkg(); - uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_PACKAGE); - #endif - if (pkg_version <= 7) { // D0WD, S0WD, D2WD + uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_PACKAGE); + # endif // if ESP_IDF_VERSION_MAJOR < 5 + + if (pkg_version <= 7) { // D0WD, S0WD, D2WD gpio_num_t PSRAM_CLK = static_cast(CONFIG_D0WD_PSRAM_CLK_IO); gpio_num_t PSRAM_CS = static_cast(CONFIG_D0WD_PSRAM_CS_IO); + switch (pkg_version) { case EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5: PSRAM_CLK = static_cast(CONFIG_D2WD_PSRAM_CLK_IO); @@ -171,21 +176,23 @@ void ESPEasy_setup() break; } -#if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 2, 0) +# if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 2, 0) + // Thanks Theo Arends from Tasmota if (PSRAM_CLK != GPIO_NUM_NC) { esp_gpio_revoke(BIT64(PSRAM_CLK) | BIT64(PSRAM_CS)); } else { esp_gpio_revoke(BIT64(PSRAM_CS)); } -#endif +# endif // if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 2, 0) + if (PSRAM_CLK != GPIO_NUM_NC) { gpio_reset_pin(PSRAM_CLK); } gpio_reset_pin(PSRAM_CS); } } -#endif // if CONFIG_IDF_TARGET_ESP32 +# endif // if CONFIG_IDF_TARGET_ESP32 initADC(); #endif // ESP32 #ifndef BUILD_NO_RAM_TRACKER @@ -193,27 +200,28 @@ void ESPEasy_setup() lowestRAM = FreeMem(); #endif // ifndef BUILD_NO_RAM_TRACKER -/* -#ifdef ESP32 -{ - ESPEasy_NVS_Helper preferences; - ResetFactoryDefaultPreference.init(preferences); -} -#endif -*/ + /* + #ifdef ESP32 + { + ESPEasy_NVS_Helper preferences; + ResetFactoryDefaultPreference.init(preferences); + } + #endif + */ #ifndef BUILD_NO_DEBUG -// checkAll_internalCommands(); -#endif + + // checkAll_internalCommands(); +#endif // ifndef BUILD_NO_DEBUG PluginSetup(); CPluginSetup(); - + initWiFi(); WiFiEventData.clearAll(); #ifndef BUILD_MINIMAL_OTA run_compiletime_checks(); -#endif +#endif // ifndef BUILD_MINIMAL_OTA #ifdef ESP8266 // ets_isr_attach(8, sw_watchdog_callback, nullptr); // Set a callback for feeding the watchdog. @@ -243,8 +251,9 @@ void ESPEasy_setup() initLog(); #ifndef BUILD_NO_RAM_TRACKER logMemUsageAfter(F("initLog()")); - #endif + #endif // ifndef BUILD_NO_RAM_TRACKER #ifdef BOARD_HAS_PSRAM + if (FoundPSRAM()) { if (UsePSRAM()) { addLog(LOG_LEVEL_INFO, F("Using PSRAM")); @@ -252,7 +261,7 @@ void ESPEasy_setup() addLog(LOG_LEVEL_ERROR, F("PSRAM found, unable to use")); } } - #endif + #endif // ifdef BOARD_HAS_PSRAM if (SpiffsSectors() < 32) { @@ -284,7 +293,7 @@ void ESPEasy_setup() readBootCause(); { - String log = F("INIT : "); + String log = F("INIT : "); log += getLastBootCauseString(); if (readFromRTC()) @@ -327,38 +336,39 @@ void ESPEasy_setup() } #ifndef BUILD_NO_RAM_TRACKER logMemUsageAfter(F("RTC init")); - #endif + #endif // ifndef BUILD_NO_RAM_TRACKER fileSystemCheck(); #ifndef BUILD_NO_RAM_TRACKER logMemUsageAfter(F("fileSystemCheck()")); - #endif + #endif // ifndef BUILD_NO_RAM_TRACKER // progMemMD5check(); LoadSettings(); #if FEATURE_DEFINE_SERIAL_CONSOLE_PORT ESPEasy_Console.reInit(); -#endif +#endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT #ifndef BUILD_NO_RAM_TRACKER logMemUsageAfter(F("LoadSettings()")); - #endif + #endif // ifndef BUILD_NO_RAM_TRACKER #ifdef ESP32 + // Configure dynamic frequency scaling: // maximum and minimum frequencies are set in sdkconfig, // automatic light sleep is enabled if tickless idle support is enabled. ESP_PM_CONFIG_T pm_config = { - .max_freq_mhz = getCPU_MaxFreqMHz(), - .min_freq_mhz = Settings.EcoPowerMode() ? getCPU_MinFreqMHz() : getCPU_MaxFreqMHz(), -#if CONFIG_FREERTOS_USE_TICKLESS_IDLE - .light_sleep_enable = Settings.EcoPowerMode() -#else - .light_sleep_enable = false -#endif + .max_freq_mhz = getCPU_MaxFreqMHz(), + .min_freq_mhz = Settings.EcoPowerMode() ? getCPU_MinFreqMHz() : getCPU_MaxFreqMHz(), +# if CONFIG_FREERTOS_USE_TICKLESS_IDLE + .light_sleep_enable = Settings.EcoPowerMode() +# else // if CONFIG_FREERTOS_USE_TICKLESS_IDLE + .light_sleep_enable = false +# endif // if CONFIG_FREERTOS_USE_TICKLESS_IDLE }; esp_pm_configure(&pm_config); -#endif +#endif // ifdef ESP32 #ifndef BUILD_NO_RAM_TRACKER @@ -367,7 +377,7 @@ void ESPEasy_setup() hardwareInit(); #ifndef BUILD_NO_RAM_TRACKER logMemUsageAfter(F("hardwareInit()")); - #endif + #endif // ifndef BUILD_NO_RAM_TRACKER node_time.restoreFromRTC(); @@ -381,10 +391,11 @@ void ESPEasy_setup() toDisable = disableController(toDisable); } #if FEATURE_NOTIFIER + if (toDisable != 0) { toDisable = disableNotification(toDisable); } - #endif + #endif // if FEATURE_NOTIFIER if (toDisable != 0) { toDisable = disableRules(toDisable); @@ -398,10 +409,11 @@ void ESPEasy_setup() toDisable = disableAllControllers(toDisable); } #if FEATURE_NOTIFIER + if (toDisable != 0) { toDisable = disableAllNotifications(toDisable); } -#endif +#endif // if FEATURE_NOTIFIER } #if FEATURE_ETHERNET @@ -409,7 +421,8 @@ void ESPEasy_setup() // This only works after LoadSettings(); // Do not call setNetworkMedium here as that may try to clean up settings. active_network_medium = Settings.NetworkMedium; - #else + #else // if FEATURE_ETHERNET + if (Settings.NetworkMedium == NetworkMedium_t::Ethernet) { Settings.NetworkMedium = NetworkMedium_t::WIFI; } @@ -418,6 +431,7 @@ void ESPEasy_setup() setNetworkMedium(Settings.NetworkMedium); bool initWiFi = active_network_medium == NetworkMedium_t::WIFI; + // FIXME TD-er: Must add another check for 'delayed start WiFi' for poorly designed ESP8266 nodes. @@ -425,6 +439,7 @@ void ESPEasy_setup() WiFi_AP_Candidates.clearCache(); WiFi_AP_Candidates.load_knownCredentials(); setSTA(true); + if (!WiFi_AP_Candidates.hasCandidates()) { WiFiEventData.wifiSetup = true; RTC.clearLastWiFi(); // Must scan all channels @@ -443,22 +458,24 @@ void ESPEasy_setup() WiFi_AP_Candidates.clearCache(); processScanDone(); WiFi_AP_Candidates.load_knownCredentials(); + if (!WiFi_AP_Candidates.hasCandidates()) { addLog(LOG_LEVEL_INFO, F("Setup: Scan all channels")); WifiScan(false); } -// setWifiMode(WIFI_OFF); + + // setWifiMode(WIFI_OFF); } #ifndef BUILD_NO_RAM_TRACKER logMemUsageAfter(F("WifiScan()")); - #endif + #endif // ifndef BUILD_NO_RAM_TRACKER // setWifiMode(WIFI_STA); checkRuleSets(); #ifndef BUILD_NO_RAM_TRACKER logMemUsageAfter(F("checkRuleSets()")); - #endif + #endif // ifndef BUILD_NO_RAM_TRACKER // if different version, eeprom settings structure has changed. Full Reset needed @@ -478,38 +495,40 @@ void ESPEasy_setup() initSerial(); #ifndef BUILD_NO_RAM_TRACKER logMemUsageAfter(F("initSerial()")); - #endif + #endif // ifndef BUILD_NO_RAM_TRACKER if (loglevelActiveFor(LOG_LEVEL_INFO)) { addLogMove(LOG_LEVEL_INFO, concat(F("INIT : Free RAM:"), FreeMem())); } -# ifndef BUILD_NO_DEBUG +#ifndef BUILD_NO_DEBUG + if (Settings.UseSerial && (Settings.SerialLogLevel >= LOG_LEVEL_DEBUG_MORE)) { ESPEasy_Console.setDebugOutput(true); } -#endif +#endif // ifndef BUILD_NO_DEBUG timermqtt_interval = 100; // Interval for checking MQTT timerAwakeFromDeepSleep = millis(); CPluginInit(); #ifndef BUILD_NO_RAM_TRACKER logMemUsageAfter(F("CPluginInit()")); - #endif + #endif // ifndef BUILD_NO_RAM_TRACKER #if FEATURE_NOTIFIER NPluginInit(); - #ifndef BUILD_NO_RAM_TRACKER + # ifndef BUILD_NO_RAM_TRACKER logMemUsageAfter(F("NPluginInit()")); - #endif + # endif // ifndef BUILD_NO_RAM_TRACKER #endif // if FEATURE_NOTIFIER PluginInit(); initSerial(); // Plugins may have altered serial, so re-init serial - + #ifndef BUILD_NO_RAM_TRACKER logMemUsageAfter(F("PluginInit()")); - #endif + #endif // ifndef BUILD_NO_RAM_TRACKER + if (loglevelActiveFor(LOG_LEVEL_INFO)) { String log; log.reserve(80); @@ -522,16 +541,16 @@ void ESPEasy_setup() addLogMove(LOG_LEVEL_INFO, log); } -/* - if ((getDeviceCount() + 1) >= PLUGIN_MAX) { - addLog(LOG_LEVEL_ERROR, concat(F("Programming error! - Increase PLUGIN_MAX ("), getDeviceCount()) + ')'); - } -*/ + /* + if ((getDeviceCount() + 1) >= PLUGIN_MAX) { + addLog(LOG_LEVEL_ERROR, concat(F("Programming error! - Increase PLUGIN_MAX ("), getDeviceCount()) + ')'); + } + */ clearAllCaches(); #ifndef BUILD_NO_RAM_TRACKER logMemUsageAfter(F("clearAllCaches()")); - #endif + #endif // ifndef BUILD_NO_RAM_TRACKER if (Settings.UseRules && isDeepSleepEnabled()) { @@ -546,48 +565,51 @@ void ESPEasy_setup() rulesProcessing(event); // TD-er: Process events in the setup() now. } #ifdef ESP32 + if (Settings.UseRules) { const uint32_t gpio_strap = GPIO_REG_READ(GPIO_STRAP_REG); -// BOOT_MODE_GET(); - // Event values: + // BOOT_MODE_GET(); + + // Event values: // ESP32 : GPIO-5, GPIO-15, GPIO-4, GPIO-2, GPIO-0, GPIO-12 // ESP32-C3: bit 0: GPIO2, bit 2: GPIO8, bit 3: GPIO9 // ESP32-S2: Unclear what bits represent which strapping state. // ESP32-S3: bit5 ~ bit2 correspond to strapping pins GPIO3, GPIO45, GPIO0, and GPIO46 respectively. String event = F("System#BootMode="); - event += bitRead(gpio_strap, 0); + event += bitRead(gpio_strap, 0); event += ','; - event += bitRead(gpio_strap, 1); + event += bitRead(gpio_strap, 1); event += ','; - event += bitRead(gpio_strap, 2); + event += bitRead(gpio_strap, 2); event += ','; - event += bitRead(gpio_strap, 3); + event += bitRead(gpio_strap, 3); event += ','; - event += bitRead(gpio_strap, 4); + event += bitRead(gpio_strap, 4); event += ','; - event += bitRead(gpio_strap, 5); + event += bitRead(gpio_strap, 5); rulesProcessing(event); } - #endif + #endif // ifdef ESP32 #if FEATURE_ETHERNET + if (Settings.ETH_Pin_power_rst != -1) { GPIO_Write(PLUGIN_GPIO, Settings.ETH_Pin_power_rst, 1); } - #endif + #endif // if FEATURE_ETHERNET NetworkConnectRelaxed(); #ifndef BUILD_NO_RAM_TRACKER logMemUsageAfter(F("NetworkConnectRelaxed()")); - #endif + #endif // ifndef BUILD_NO_RAM_TRACKER setWebserverRunning(true); #ifndef BUILD_NO_RAM_TRACKER logMemUsageAfter(F("setWebserverRunning()")); - #endif + #endif // ifndef BUILD_NO_RAM_TRACKER #if FEATURE_REPORTING @@ -596,16 +618,16 @@ void ESPEasy_setup() #if FEATURE_ARDUINO_OTA ArduinoOTAInit(); - #ifndef BUILD_NO_RAM_TRACKER + # ifndef BUILD_NO_RAM_TRACKER logMemUsageAfter(F("ArduinoOTAInit()")); - #endif + # endif // ifndef BUILD_NO_RAM_TRACKER #endif // if FEATURE_ARDUINO_OTA if (node_time.systemTimePresent()) { node_time.initTime(); #ifndef BUILD_NO_RAM_TRACKER logMemUsageAfter(F("node_time.initTime()")); - #endif + #endif // ifndef BUILD_NO_RAM_TRACKER } if (Settings.UseRules) @@ -614,13 +636,13 @@ void ESPEasy_setup() rulesProcessing(event); // TD-er: Process events in the setup() now. #ifndef BUILD_NO_RAM_TRACKER logMemUsageAfter(F("rulesProcessing(System#Boot)")); - #endif + #endif // ifndef BUILD_NO_RAM_TRACKER } writeDefaultCSS(); #ifndef BUILD_NO_RAM_TRACKER logMemUsageAfter(F("writeDefaultCSS()")); - #endif + #endif // ifndef BUILD_NO_RAM_TRACKER #ifdef USE_RTOS_MULTITASKING @@ -637,9 +659,9 @@ void ESPEasy_setup() RTOS_HandleSchedule, /* Function to implement the task */ "RTOS_HandleSchedule", /* Name of the task */ 16384, /* Stack size in words */ - nullptr, /* Task input parameter */ + nullptr, /* Task input parameter */ 1, /* Priority of the task */ - nullptr, /* Task handle. */ + nullptr, /* Task handle. */ 1); /* Core where the task should run */ } #endif // ifdef USE_RTOS_MULTITASKING @@ -655,6 +677,5 @@ void ESPEasy_setup() Scheduler.setIntervalTimerOverride(SchedulerIntervalTimer_e::TIMER_STATISTICS, 2222); #ifndef BUILD_NO_RAM_TRACKER logMemUsageAfter(F("Scheduler.setIntervalTimerOverride")); - #endif - + #endif // ifndef BUILD_NO_RAM_TRACKER } From d8efce5142198e11ebc79f798b325676684a4b6a Mon Sep 17 00:00:00 2001 From: TD-er Date: Sun, 10 Nov 2024 21:09:10 +0100 Subject: [PATCH 5/5] [PSRAM] Fix solo1 builds --- src/src/ESPEasyCore/ESPEasy_setup.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/src/ESPEasyCore/ESPEasy_setup.cpp b/src/src/ESPEasyCore/ESPEasy_setup.cpp index 907a3dd5c2..c825dec171 100644 --- a/src/src/ESPEasyCore/ESPEasy_setup.cpp +++ b/src/src/ESPEasyCore/ESPEasy_setup.cpp @@ -77,6 +77,7 @@ #ifdef USE_RTOS_MULTITASKING + void RTOS_TaskServers(void *parameter) { while (true) { @@ -113,7 +114,6 @@ void RTOS_HandleSchedule(void *parameter) #endif // ifdef USE_RTOS_MULTITASKING - /*********************************************************************************************\ * ISR call back function for handling the watchdog. \*********************************************************************************************/ @@ -161,10 +161,15 @@ void ESPEasy_setup() # endif // if ESP_IDF_VERSION_MAJOR < 5 if (pkg_version <= 7) { // D0WD, S0WD, D2WD +#ifdef CORE32SOLO1 + gpio_num_t PSRAM_CLK = GPIO_NUM_17; + gpio_num_t PSRAM_CS = GPIO_NUM_16; +#else gpio_num_t PSRAM_CLK = static_cast(CONFIG_D0WD_PSRAM_CLK_IO); gpio_num_t PSRAM_CS = static_cast(CONFIG_D0WD_PSRAM_CS_IO); - switch (pkg_version) { + switch (pkg_version) + { case EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5: PSRAM_CLK = static_cast(CONFIG_D2WD_PSRAM_CLK_IO); PSRAM_CS = static_cast(CONFIG_D2WD_PSRAM_CS_IO); @@ -175,7 +180,7 @@ void ESPEasy_setup() PSRAM_CS = static_cast(CONFIG_PICO_PSRAM_CS_IO); break; } - +#endif # if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 2, 0) // Thanks Theo Arends from Tasmota @@ -363,7 +368,7 @@ void ESPEasy_setup() .min_freq_mhz = Settings.EcoPowerMode() ? getCPU_MinFreqMHz() : getCPU_MaxFreqMHz(), # if CONFIG_FREERTOS_USE_TICKLESS_IDLE .light_sleep_enable = Settings.EcoPowerMode() -# else // if CONFIG_FREERTOS_USE_TICKLESS_IDLE +# else .light_sleep_enable = false # endif // if CONFIG_FREERTOS_USE_TICKLESS_IDLE }; @@ -518,7 +523,7 @@ void ESPEasy_setup() NPluginInit(); # ifndef BUILD_NO_RAM_TRACKER logMemUsageAfter(F("NPluginInit()")); - # endif // ifndef BUILD_NO_RAM_TRACKER + # endif #endif // if FEATURE_NOTIFIER PluginInit(); @@ -527,7 +532,7 @@ void ESPEasy_setup() #ifndef BUILD_NO_RAM_TRACKER logMemUsageAfter(F("PluginInit()")); - #endif // ifndef BUILD_NO_RAM_TRACKER + #endif if (loglevelActiveFor(LOG_LEVEL_INFO)) { String log; @@ -620,7 +625,7 @@ void ESPEasy_setup() ArduinoOTAInit(); # ifndef BUILD_NO_RAM_TRACKER logMemUsageAfter(F("ArduinoOTAInit()")); - # endif // ifndef BUILD_NO_RAM_TRACKER + # endif #endif // if FEATURE_ARDUINO_OTA if (node_time.systemTimePresent()) {