From a6467d76837316ab78e57fc1dbee329be86a8081 Mon Sep 17 00:00:00 2001 From: ninh Date: Wed, 2 Sep 2020 17:10:54 +0800 Subject: [PATCH] fix reboot or crash when enable lightsleep on esp32s2 --- components/esp32s2/CMakeLists.txt | 5 +++++ components/esp32s2/sleep_modes.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/components/esp32s2/CMakeLists.txt b/components/esp32s2/CMakeLists.txt index b4b4865a41..73f9a2ed86 100644 --- a/components/esp32s2/CMakeLists.txt +++ b/components/esp32s2/CMakeLists.txt @@ -86,3 +86,8 @@ else() PROPERTIES COMPILE_FLAGS -fno-stack-protector) endif() + +if(NOT CMAKE_BUILD_EARLY_EXPANSION) + set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/sleep_modes.c" PROPERTIES + COMPILE_FLAGS "-fno-jump-tables -fno-tree-switch-conversion") +endif() \ No newline at end of file diff --git a/components/esp32s2/sleep_modes.c b/components/esp32s2/sleep_modes.c index 6be663e4c3..b74b95342b 100644 --- a/components/esp32s2/sleep_modes.c +++ b/components/esp32s2/sleep_modes.c @@ -49,10 +49,10 @@ // Extra time it takes to enter and exit light sleep and deep sleep // For deep sleep, this is until the wake stub runs (not the app). #ifdef CONFIG_ESP32S2_RTC_CLK_SRC_EXT_CRYS -#define LIGHT_SLEEP_TIME_OVERHEAD_US (650 + 30 * 240 / CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ) +#define LIGHT_SLEEP_TIME_OVERHEAD_US (1650 + 30 * 240 / CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ) #define DEEP_SLEEP_TIME_OVERHEAD_US (650 + 100 * 240 / CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ) #else -#define LIGHT_SLEEP_TIME_OVERHEAD_US (250 + 30 * 240 / CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ) +#define LIGHT_SLEEP_TIME_OVERHEAD_US (1250 + 30 * 240 / CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ) #define DEEP_SLEEP_TIME_OVERHEAD_US (250 + 100 * 240 / CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ) #endif // CONFIG_ESP32S2_RTC_CLK_SRC_EXT_CRYS