deep sleep: add option to delay CPU startup
When ESP32 wakes up from deep sleep, flash is accessed an approximately 900us after power on. Some flash chips need more time to become ready. This change adds a menuconfig option to add some delay to the default deep sleep wake stub. Fixes https://github.com/espressif/esp-idf/issues/117
This commit is contained in:
parent
3b854fe46a
commit
eac80b0651
2 changed files with 26 additions and 0 deletions
|
@ -452,6 +452,25 @@ config ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL
|
||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
|
|
||||||
|
config ESP32_DEEP_SLEEP_WAKEUP_DELAY
|
||||||
|
int "Extra delay in deep sleep wake stub (in us)"
|
||||||
|
default 0
|
||||||
|
range 0 5000
|
||||||
|
help
|
||||||
|
When ESP32 exits deep sleep, the CPU and the flash chip are powered on
|
||||||
|
at the same time. CPU will run deep sleep stub first, and then
|
||||||
|
proceed to load code from flash. Some flash chips need sufficient
|
||||||
|
time to pass between power on and first read operation. By default,
|
||||||
|
without any extra delay, this time is approximately 900us.
|
||||||
|
|
||||||
|
If you are using a flash chip which needs more than 900us to become
|
||||||
|
ready after power on, set this parameter to add extra delay
|
||||||
|
to the default deep sleep stub.
|
||||||
|
|
||||||
|
If you are seeing "flash read err, 1000" message printed to the
|
||||||
|
console after deep sleep reset, try increasing this value.
|
||||||
|
|
||||||
|
|
||||||
config ESP32_PHY_AUTO_INIT
|
config ESP32_PHY_AUTO_INIT
|
||||||
bool "Initialize PHY in startup code"
|
bool "Initialize PHY in startup code"
|
||||||
default y
|
default y
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "driver/rtc_io.h"
|
#include "driver/rtc_io.h"
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
/* Updating RTC_MEMORY_CRC_REG register via set_rtc_memory_crc()
|
/* Updating RTC_MEMORY_CRC_REG register via set_rtc_memory_crc()
|
||||||
is not thread-safe. */
|
is not thread-safe. */
|
||||||
|
@ -66,6 +67,12 @@ void RTC_IRAM_ATTR esp_default_wake_deep_sleep(void) {
|
||||||
/* Clear MMU for CPU 0 */
|
/* Clear MMU for CPU 0 */
|
||||||
REG_SET_BIT(DPORT_PRO_CACHE_CTRL1_REG, DPORT_PRO_CACHE_MMU_IA_CLR);
|
REG_SET_BIT(DPORT_PRO_CACHE_CTRL1_REG, DPORT_PRO_CACHE_MMU_IA_CLR);
|
||||||
REG_CLR_BIT(DPORT_PRO_CACHE_CTRL1_REG, DPORT_PRO_CACHE_MMU_IA_CLR);
|
REG_CLR_BIT(DPORT_PRO_CACHE_CTRL1_REG, DPORT_PRO_CACHE_MMU_IA_CLR);
|
||||||
|
#if CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY > 0
|
||||||
|
// ROM code has not started yet, so we need to set delay factor
|
||||||
|
// used by ets_delay_us first.
|
||||||
|
ets_update_cpu_frequency(ets_get_detected_xtal_freq() / 1000000);
|
||||||
|
ets_delay_us(CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void __attribute__((weak, alias("esp_default_wake_deep_sleep"))) esp_wake_deep_sleep(void);
|
void __attribute__((weak, alias("esp_default_wake_deep_sleep"))) esp_wake_deep_sleep(void);
|
||||||
|
|
Loading…
Reference in a new issue