diff --git a/tasmota/tasmota_support/support_esp32.ino b/tasmota/tasmota_support/support_esp32.ino index d6c8ccc7ec60..5a3891663309 100644 --- a/tasmota/tasmota_support/support_esp32.ino +++ b/tasmota/tasmota_support/support_esp32.ino @@ -36,10 +36,6 @@ #define ESP32_ARCH "" #endif -// Handle 20k of NVM - -#include - // See libraries\ESP32\examples\ResetReason.ino #if ESP_IDF_VERSION_MAJOR > 3 // IDF 4+ #include "esp_chip_info.h" @@ -64,18 +60,17 @@ #include "rom/rtc.h" #endif -#if ESP_IDF_VERSION_MAJOR >= 5 - #include "esp_chip_info.h" -#endif - // Set the Stacksize for Arduino core. Default is 8192, some builds may need a bigger one size_t getArduinoLoopTaskStackSize(void) { - return SET_ESP32_STACK_SIZE; + return SET_ESP32_STACK_SIZE; } - #include +// Handle 20k of NVM + +#include + bool NvmLoad(const char *sNvsName, const char *sName, void *pSettings, unsigned nSettingsLen) { nvs_handle_t handle; esp_err_t result = nvs_open(sNvsName, NVS_READONLY, &handle); @@ -593,6 +588,32 @@ bool UsePSRAM(void) { return FoundPSRAM() && can_use_psram; } +/* + * ESP32 v1 and v2 needs some special patches to use PSRAM. + * Standard Tasmota 32 do not include those patches. + * If using ESP32 v1, please add: `-mfix-esp32-psram-cache-issue -lc-psram-workaround -lm-psram-workaround` + * + * This function returns true if the chip supports PSRAM natively (v3) or if the + * patches are present. + */ +bool CanUsePSRAM(void) { + if (!FoundPSRAM()) return false; +#ifdef HAS_PSRAM_FIX + return true; +#endif +#ifdef CONFIG_IDF_TARGET_ESP32 + esp_chip_info_t chip_info; + esp_chip_info(&chip_info); + uint32_t chip_revision = chip_info.revision; + // idf5 efuse_hal_chip_revision(void) + if (chip_revision < 100) { chip_revision *= 100; } // Make