From 3f17cc2ab80a408799ca793a83b16ff4dabea8f7 Mon Sep 17 00:00:00 2001 From: Li Shuai Date: Thu, 16 Sep 2021 16:35:03 +0800 Subject: [PATCH] light sleep: fix Flash leakage when its CS pin has no hardware pullup --- components/esp_system/Kconfig | 8 ++++++++ components/esp_system/sleep_modes.c | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/components/esp_system/Kconfig b/components/esp_system/Kconfig index cf26ebf951..b7f681e45c 100644 --- a/components/esp_system/Kconfig +++ b/components/esp_system/Kconfig @@ -109,6 +109,14 @@ menu "ESP System Settings" pull-up, you do not need to select this option, otherwise, you should enable this option. + config ESP_SYSTEM_FLASH_LEAKAGE_WORKAROUND + bool "Flash leakage current workaround in light sleep" + help + When the CS pin of Flash is not pulled up, the sleep current will + increase during light sleep. If the CS pin of Flash has an external + pull-up, you do not need to select this option, otherwise, you + should enable this option. + menu "Memory protection" config ESP_SYSTEM_MEMPROT_FEATURE diff --git a/components/esp_system/sleep_modes.c b/components/esp_system/sleep_modes.c index e0fc4df91a..7c185a7363 100644 --- a/components/esp_system/sleep_modes.c +++ b/components/esp_system/sleep_modes.c @@ -29,6 +29,7 @@ #include "soc/soc_caps.h" #include "driver/rtc_io.h" #include "hal/rtc_io_hal.h" +#include "bootloader_common.h" #include "driver/uart.h" @@ -424,6 +425,9 @@ void esp_sleep_config_gpio_isolate(void) #if CONFIG_ESP_SYSTEM_PSRAM_LEAKAGE_WORKAROUND && CONFIG_SPIRAM gpio_sleep_set_pull_mode(esp_spiram_get_cs_io(), GPIO_PULLUP_ONLY); #endif +#if CONFIG_ESP_SYSTEM_FLASH_LEAKAGE_WORKAROUND + gpio_sleep_set_pull_mode(bootloader_flash_get_cs_io(), GPIO_PULLUP_ONLY); +#endif } void esp_sleep_enable_gpio_switch(bool enable)