From 28aec9594a9931cf5995968706968a2a74d0a3b0 Mon Sep 17 00:00:00 2001 From: KonstantinKondrashov Date: Fri, 14 Jul 2023 15:05:44 +0800 Subject: [PATCH] fix(app_update): Fix CI test_switch_ota by increasing deepsleep It increases the deepsleep time from 2000 to 20000. 2000 is too small for esp32-s3 chip. --- .../app_update/test_apps/main/test_switch_ota.c | 6 +++--- components/esp_hw_support/include/esp_sleep.h | 16 ++++++++++++---- components/esp_hw_support/sleep_modes.c | 16 ++++++++-------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/components/app_update/test_apps/main/test_switch_ota.c b/components/app_update/test_apps/main/test_switch_ota.c index 0d965b53f9..bbeb036c12 100644 --- a/components/app_update/test_apps/main/test_switch_ota.c +++ b/components/app_update/test_apps/main/test_switch_ota.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -185,8 +185,8 @@ static void erase_ota_data(void) static void reboot_as_deep_sleep(void) { ESP_LOGI(TAG, "reboot as deep sleep"); - esp_sleep_enable_timer_wakeup(2000); - esp_deep_sleep_start(); + esp_deep_sleep(20000); + TEST_FAIL_MESSAGE("Should never be reachable except when sleep is rejected, abort"); } /* @brief Copies a current app to next partition (OTA0-15), after that ESP is rebooting and run this (the next) OTAx. diff --git a/components/esp_hw_support/include/esp_sleep.h b/components/esp_hw_support/include/esp_sleep.h index a836a399c2..a2f29a31f6 100644 --- a/components/esp_hw_support/include/esp_sleep.h +++ b/components/esp_hw_support/include/esp_sleep.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -415,9 +415,12 @@ esp_err_t esp_sleep_pd_config(esp_sleep_pd_domain_t domain, /** * @brief Enter deep sleep with the configured wakeup options * - * This function does not return. + * @note In general, the function does not return, but if the sleep is rejected, + * then it returns from it. + * + * The reason for the rejection can be such as a short sleep time. */ -void esp_deep_sleep_start(void) __attribute__((__noreturn__)); +void esp_deep_sleep_start(void); /** * @brief Enter light sleep with the configured wakeup options @@ -441,9 +444,14 @@ esp_err_t esp_light_sleep_start(void); * Call to this function is equivalent to a call to esp_deep_sleep_enable_timer_wakeup * followed by a call to esp_deep_sleep_start. * + * @note In general, the function does not return, but if the sleep is rejected, + * then it returns from it. + * + * The reason for the rejection can be such as a short sleep time. + * * @param time_in_us deep-sleep time, unit: microsecond */ -void esp_deep_sleep(uint64_t time_in_us) __attribute__((__noreturn__)); +void esp_deep_sleep(uint64_t time_in_us); /** diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index de0ae7203b..30d4b78571 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -856,15 +856,15 @@ void IRAM_ATTR esp_deep_sleep_start(void) // Enter sleep if (esp_sleep_start(force_pd_flags | pd_flags, ESP_SLEEP_MODE_DEEP_SLEEP) == ESP_ERR_SLEEP_REJECT) { - ESP_EARLY_LOGW(TAG, "Deep sleep request is rejected"); + ESP_EARLY_LOGE(TAG, "Deep sleep request is rejected"); + } else { + // Because RTC is in a slower clock domain than the CPU, it + // can take several CPU cycles for the sleep mode to start. + while (1) { + ; + } } - - // Because RTC is in a slower clock domain than the CPU, it - // can take several CPU cycles for the sleep mode to start. - while (1) { - ; - } - // Never returns here + // Never returns here, except that the sleep is rejected. esp_ipc_isr_release_other_cpu(); portEXIT_CRITICAL(&spinlock_rtc_deep_sleep); }