From 1256e6fd6b80f71a636ee7550cb136476c412358 Mon Sep 17 00:00:00 2001 From: Zim Kalinowski Date: Wed, 27 Sep 2023 12:24:50 +0200 Subject: [PATCH 1/2] fix(examples): Reverted: Fix example build errors caused by the deep_sleep funcs are returnable This reverts commit d521b7d52a0f6df19b6aa0826747d2c367660c49. --- .../blecent_throughput/components/cmd_system/cmd_system.c | 1 - .../system/console/advanced/components/cmd_system/cmd_system.c | 1 - 2 files changed, 2 deletions(-) diff --git a/examples/bluetooth/nimble/throughput_app/blecent_throughput/components/cmd_system/cmd_system.c b/examples/bluetooth/nimble/throughput_app/blecent_throughput/components/cmd_system/cmd_system.c index 060cd61c31..43b3ca3d33 100644 --- a/examples/bluetooth/nimble/throughput_app/blecent_throughput/components/cmd_system/cmd_system.c +++ b/examples/bluetooth/nimble/throughput_app/blecent_throughput/components/cmd_system/cmd_system.c @@ -225,7 +225,6 @@ static int deep_sleep(int argc, char **argv) rtc_gpio_isolate(GPIO_NUM_12); #endif esp_deep_sleep_start(); - return 1; } static void register_deep_sleep(void) diff --git a/examples/system/console/advanced/components/cmd_system/cmd_system.c b/examples/system/console/advanced/components/cmd_system/cmd_system.c index fcb9624488..58b94a5970 100644 --- a/examples/system/console/advanced/components/cmd_system/cmd_system.c +++ b/examples/system/console/advanced/components/cmd_system/cmd_system.c @@ -273,7 +273,6 @@ static int deep_sleep(int argc, char **argv) #endif //CONFIG_IDF_TARGET_ESP32 esp_deep_sleep_start(); - return 1; } static void register_deep_sleep(void) From 1c21f071396dbff68e11cb9234b0cb3e32438e15 Mon Sep 17 00:00:00 2001 From: Zim Kalinowski Date: Wed, 27 Sep 2023 12:25:13 +0200 Subject: [PATCH 2/2] fix(app_update): Reverted: Fix CI test_switch_ota by increasing deepsleep This reverts commit 7ac7d43541cf0c390a445fc73bb32421d1fef31b. --- .../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, 15 insertions(+), 23 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 bbeb036c12..0d965b53f9 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-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 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_deep_sleep(20000); - TEST_FAIL_MESSAGE("Should never be reachable except when sleep is rejected, abort"); + esp_sleep_enable_timer_wakeup(2000); + esp_deep_sleep_start(); } /* @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 085f9a2f83..9d8caefddc 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-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -439,12 +439,9 @@ esp_err_t esp_sleep_pd_config(esp_sleep_pd_domain_t domain, /** * @brief Enter deep sleep with the configured wakeup options * - * @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. + * This function does not return. */ -void esp_deep_sleep_start(void); +void esp_deep_sleep_start(void) __attribute__((__noreturn__)); /** * @brief Enter light sleep with the configured wakeup options @@ -468,14 +465,9 @@ 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); +void esp_deep_sleep(uint64_t time_in_us) __attribute__((__noreturn__)); /** diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index 02da90a5ed..24a23d41de 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -873,15 +873,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_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) { - ; - } + ESP_EARLY_LOGW(TAG, "Deep sleep request is rejected"); } - // Never returns here, except that the sleep is rejected. + + // 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 esp_ipc_isr_release_other_cpu(); portEXIT_CRITICAL(&spinlock_rtc_deep_sleep); }