From 0b9f01ac201bb4bca413d5f207aaf0222802072b Mon Sep 17 00:00:00 2001 From: Guillaume Souchere Date: Thu, 1 Feb 2024 11:28:28 +0100 Subject: [PATCH] feat(soc): Add soc_caps macros for sleep support - modify console example to use the new SOC_LIGHT_SLEEP_SUPPORTED and SOC_DEEP_SLEEP_SUPPORTED macros when registering sleep commands - remove exclusion of esp32p4 in basic and advanced example in .build-test-rules.yml - replace exclusion of esp32p4 for deep and light sleep tests with newly introduced macro - remove the temporary disable check for esp32p4 and uses the SOC_LIGHT_SLEEP_SUPPORTED maccro instead. --- .../main/test_esp_timer_light_sleep.c | 5 +++-- .../soc/esp32/include/soc/Kconfig.soc_caps.in | 8 ++++++++ components/soc/esp32/include/soc/soc_caps.h | 2 ++ .../esp32c2/include/soc/Kconfig.soc_caps.in | 8 ++++++++ components/soc/esp32c2/include/soc/soc_caps.h | 2 ++ .../esp32c3/include/soc/Kconfig.soc_caps.in | 8 ++++++++ components/soc/esp32c3/include/soc/soc_caps.h | 2 ++ .../soc/esp32c5/beta3/include/soc/soc_caps.h | 2 ++ .../esp32c6/include/soc/Kconfig.soc_caps.in | 8 ++++++++ components/soc/esp32c6/include/soc/soc_caps.h | 2 ++ .../esp32h2/include/soc/Kconfig.soc_caps.in | 8 ++++++++ components/soc/esp32h2/include/soc/soc_caps.h | 2 ++ components/soc/esp32p4/include/soc/soc_caps.h | 2 ++ .../esp32s2/include/soc/Kconfig.soc_caps.in | 8 ++++++++ components/soc/esp32s2/include/soc/soc_caps.h | 2 ++ .../esp32s3/include/soc/Kconfig.soc_caps.in | 8 ++++++++ components/soc/esp32s3/include/soc/soc_caps.h | 2 ++ examples/system/.build-test-rules.yml | 20 +++---------------- examples/system/console/advanced/README.md | 4 ++-- .../components/cmd_system/cmd_system.c | 9 ++++++++- .../components/cmd_system/cmd_system.h | 3 ++- .../components/cmd_system/cmd_system_sleep.c | 16 +++------------ .../advanced/main/console_example_main.c | 7 ++++++- .../main/console_usb_example_main.c | 13 +++++++++--- examples/system/console/basic/README.md | 4 ++-- .../console/basic/main/console_example_main.c | 7 ++++++- 26 files changed, 119 insertions(+), 43 deletions(-) diff --git a/components/esp_timer/test_apps/main/test_esp_timer_light_sleep.c b/components/esp_timer/test_apps/main/test_esp_timer_light_sleep.c index bf17e569cc..45214f8749 100644 --- a/components/esp_timer/test_apps/main/test_esp_timer_light_sleep.c +++ b/components/esp_timer/test_apps/main/test_esp_timer_light_sleep.c @@ -12,8 +12,9 @@ #include "unity.h" #include "esp_rom_sys.h" #include "esp_sleep.h" +#include "soc/soc_caps.h" -#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32P4) // TODO Light Sleep support - IDF-7528 +#if SOC_LIGHT_SLEEP_SUPPORTED static void timer_cb1(void *arg) { @@ -53,4 +54,4 @@ TEST_CASE("Test the periodic timer does not handle lost events during light slee TEST_ESP_OK(esp_timer_delete(periodic_timer)); } -#endif //#!TEMPORARY_DISABLED_FOR_TARGETS(ESP32P4) +#endif // SOC_SLEEP_SUPPORTED diff --git a/components/soc/esp32/include/soc/Kconfig.soc_caps.in b/components/soc/esp32/include/soc/Kconfig.soc_caps.in index 804f62849c..17a8c7a764 100644 --- a/components/soc/esp32/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32/include/soc/Kconfig.soc_caps.in @@ -171,6 +171,14 @@ config SOC_RNG_SUPPORTED bool default y +config SOC_LIGHT_SLEEP_SUPPORTED + bool + default y + +config SOC_DEEP_SLEEP_SUPPORTED + bool + default y + config SOC_DPORT_WORKAROUND_DIS_INTERRUPT_LVL int default 5 diff --git a/components/soc/esp32/include/soc/soc_caps.h b/components/soc/esp32/include/soc/soc_caps.h index 1f709bb405..c21ec808c1 100644 --- a/components/soc/esp32/include/soc/soc_caps.h +++ b/components/soc/esp32/include/soc/soc_caps.h @@ -100,6 +100,8 @@ #define SOC_WDT_SUPPORTED 1 #define SOC_SPI_FLASH_SUPPORTED 1 #define SOC_RNG_SUPPORTED 1 +#define SOC_LIGHT_SLEEP_SUPPORTED 1 +#define SOC_DEEP_SLEEP_SUPPORTED 1 #if SOC_CAPS_ECO_VER < 200 #define SOC_DPORT_WORKAROUND 1 diff --git a/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in index 5cdbff97b5..ef10645ba4 100644 --- a/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in @@ -115,6 +115,14 @@ config SOC_RNG_SUPPORTED bool default y +config SOC_LIGHT_SLEEP_SUPPORTED + bool + default y + +config SOC_DEEP_SLEEP_SUPPORTED + bool + default y + config SOC_XTAL_SUPPORT_26M bool default y diff --git a/components/soc/esp32c2/include/soc/soc_caps.h b/components/soc/esp32c2/include/soc/soc_caps.h index 9f3fb8adb8..a747103a6d 100644 --- a/components/soc/esp32c2/include/soc/soc_caps.h +++ b/components/soc/esp32c2/include/soc/soc_caps.h @@ -45,6 +45,8 @@ #define SOC_WDT_SUPPORTED 1 #define SOC_SPI_FLASH_SUPPORTED 1 #define SOC_RNG_SUPPORTED 1 +#define SOC_LIGHT_SLEEP_SUPPORTED 1 +#define SOC_DEEP_SLEEP_SUPPORTED 1 /*-------------------------- XTAL CAPS ---------------------------------------*/ #define SOC_XTAL_SUPPORT_26M 1 diff --git a/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in index 3e6ef40233..e1748306ae 100644 --- a/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in @@ -167,6 +167,14 @@ config SOC_RNG_SUPPORTED bool default y +config SOC_LIGHT_SLEEP_SUPPORTED + bool + default y + +config SOC_DEEP_SLEEP_SUPPORTED + bool + default y + config SOC_XTAL_SUPPORT_40M bool default y diff --git a/components/soc/esp32c3/include/soc/soc_caps.h b/components/soc/esp32c3/include/soc/soc_caps.h index 0d8d988c7e..eac769cf65 100644 --- a/components/soc/esp32c3/include/soc/soc_caps.h +++ b/components/soc/esp32c3/include/soc/soc_caps.h @@ -61,6 +61,8 @@ #define SOC_WDT_SUPPORTED 1 #define SOC_SPI_FLASH_SUPPORTED 1 #define SOC_RNG_SUPPORTED 1 +#define SOC_LIGHT_SLEEP_SUPPORTED 1 +#define SOC_DEEP_SLEEP_SUPPORTED 1 /*-------------------------- XTAL CAPS ---------------------------------------*/ #define SOC_XTAL_SUPPORT_40M 1 diff --git a/components/soc/esp32c5/beta3/include/soc/soc_caps.h b/components/soc/esp32c5/beta3/include/soc/soc_caps.h index 9451ddbdc8..df6b6db7a2 100644 --- a/components/soc/esp32c5/beta3/include/soc/soc_caps.h +++ b/components/soc/esp32c5/beta3/include/soc/soc_caps.h @@ -72,6 +72,8 @@ // #define SOC_ECDSA_SUPPORTED 1 // TODO: [ESP32C5] IDF-8618 // #define SOC_KEY_MANAGER_SUPPORTED 1 // TODO: [ESP32C5] IDF-8621 // #define SOC_HUK_SUPPORTED 1 // TODO: [ESP32C5] IDF-8617 +// #define SOC_LIGHT_SLEEP_SUPPORTED 1 // TODO: [ESP32C5] IDF-8640 +// #define SOC_DEEP_SLEEP_SUPPORTED 1 // TODO: [ESP32C5] IDF-8638 /*-------------------------- XTAL CAPS ---------------------------------------*/ #define SOC_XTAL_SUPPORT_40M 1 diff --git a/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in index 78d8f97b3c..7a850a958e 100644 --- a/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in @@ -223,6 +223,14 @@ config SOC_RNG_SUPPORTED bool default y +config SOC_LIGHT_SLEEP_SUPPORTED + bool + default y + +config SOC_DEEP_SLEEP_SUPPORTED + bool + default y + config SOC_XTAL_SUPPORT_40M bool default y diff --git a/components/soc/esp32c6/include/soc/soc_caps.h b/components/soc/esp32c6/include/soc/soc_caps.h index d1f1b49c30..f5846a5eac 100644 --- a/components/soc/esp32c6/include/soc/soc_caps.h +++ b/components/soc/esp32c6/include/soc/soc_caps.h @@ -72,6 +72,8 @@ #define SOC_WDT_SUPPORTED 1 #define SOC_SPI_FLASH_SUPPORTED 1 #define SOC_RNG_SUPPORTED 1 +#define SOC_LIGHT_SLEEP_SUPPORTED 1 +#define SOC_DEEP_SLEEP_SUPPORTED 1 /*-------------------------- XTAL CAPS ---------------------------------------*/ #define SOC_XTAL_SUPPORT_40M 1 diff --git a/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in index c8014abbff..df97f79675 100644 --- a/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in @@ -211,6 +211,14 @@ config SOC_RNG_SUPPORTED bool default y +config SOC_LIGHT_SLEEP_SUPPORTED + bool + default y + +config SOC_DEEP_SLEEP_SUPPORTED + bool + default y + config SOC_XTAL_SUPPORT_32M bool default y diff --git a/components/soc/esp32h2/include/soc/soc_caps.h b/components/soc/esp32h2/include/soc/soc_caps.h index 122a2d4eb9..215f4f01ae 100644 --- a/components/soc/esp32h2/include/soc/soc_caps.h +++ b/components/soc/esp32h2/include/soc/soc_caps.h @@ -69,6 +69,8 @@ #define SOC_WDT_SUPPORTED 1 #define SOC_SPI_FLASH_SUPPORTED 1 #define SOC_RNG_SUPPORTED 1 +#define SOC_LIGHT_SLEEP_SUPPORTED 1 +#define SOC_DEEP_SLEEP_SUPPORTED 1 /*-------------------------- XTAL CAPS ---------------------------------------*/ #define SOC_XTAL_SUPPORT_32M 1 diff --git a/components/soc/esp32p4/include/soc/soc_caps.h b/components/soc/esp32p4/include/soc/soc_caps.h index 59bf132dac..9fd1a1855b 100644 --- a/components/soc/esp32p4/include/soc/soc_caps.h +++ b/components/soc/esp32p4/include/soc/soc_caps.h @@ -86,6 +86,8 @@ // #define SOC_RNG_SUPPORTED 1 //TODO: IDF-6522 #define SOC_MULTI_USAGE_LDO_SUPPORTED 1 // #define SOC_PPA_SUPPORTED 1 //TODO: IDF-6878 +// #define SOC_LIGHT_SLEEP_SUPPORTED 1 //TODO: IDF-7528 +// #define SOC_DEEP_SLEEP_SUPPORTED 1 //TODO: IDF-7529 /*-------------------------- XTAL CAPS ---------------------------------------*/ #define SOC_XTAL_SUPPORT_40M 1 diff --git a/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in index e611214dd1..542fdb2c12 100644 --- a/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in @@ -195,6 +195,14 @@ config SOC_RNG_SUPPORTED bool default y +config SOC_LIGHT_SLEEP_SUPPORTED + bool + default y + +config SOC_DEEP_SLEEP_SUPPORTED + bool + default y + config SOC_XTAL_SUPPORT_40M bool default y diff --git a/components/soc/esp32s2/include/soc/soc_caps.h b/components/soc/esp32s2/include/soc/soc_caps.h index d27ce9eebf..91cf9d5c61 100644 --- a/components/soc/esp32s2/include/soc/soc_caps.h +++ b/components/soc/esp32s2/include/soc/soc_caps.h @@ -85,6 +85,8 @@ #define SOC_WDT_SUPPORTED 1 #define SOC_SPI_FLASH_SUPPORTED 1 #define SOC_RNG_SUPPORTED 1 +#define SOC_LIGHT_SLEEP_SUPPORTED 1 +#define SOC_DEEP_SLEEP_SUPPORTED 1 /*-------------------------- XTAL CAPS ---------------------------------------*/ #define SOC_XTAL_SUPPORT_40M 1 diff --git a/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in b/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in index 0b2ce61815..577409091f 100644 --- a/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in @@ -235,6 +235,14 @@ config SOC_RNG_SUPPORTED bool default y +config SOC_LIGHT_SLEEP_SUPPORTED + bool + default y + +config SOC_DEEP_SLEEP_SUPPORTED + bool + default y + config SOC_XTAL_SUPPORT_40M bool default y diff --git a/components/soc/esp32s3/include/soc/soc_caps.h b/components/soc/esp32s3/include/soc/soc_caps.h index 4a8d731fe7..dd3b5d9254 100644 --- a/components/soc/esp32s3/include/soc/soc_caps.h +++ b/components/soc/esp32s3/include/soc/soc_caps.h @@ -75,6 +75,8 @@ #define SOC_WDT_SUPPORTED 1 #define SOC_SPI_FLASH_SUPPORTED 1 #define SOC_RNG_SUPPORTED 1 +#define SOC_LIGHT_SLEEP_SUPPORTED 1 +#define SOC_DEEP_SLEEP_SUPPORTED 1 /*-------------------------- XTAL CAPS ---------------------------------------*/ #define SOC_XTAL_SUPPORT_40M 1 diff --git a/examples/system/.build-test-rules.yml b/examples/system/.build-test-rules.yml index 85ed27d783..b63b089727 100644 --- a/examples/system/.build-test-rules.yml +++ b/examples/system/.build-test-rules.yml @@ -11,10 +11,6 @@ examples/system/base_mac_address: - esp_hw_support examples/system/console/advanced: - disable: - - if: IDF_TARGET == "esp32p4" - temporary: true - reason: not supported on p4 # TODO: IDF-8078 disable_test: - if: IDF_TARGET not in ["esp32", "esp32c3"] reason: Sufficient to run this app on one chip with each architecture @@ -30,10 +26,6 @@ examples/system/console/advanced_usb_cdc: - vfs examples/system/console/basic: - disable: - - if: IDF_TARGET == "esp32p4" - temporary: true - reason: not supported on p4 # TODO: IDF-8078 disable_test: - if: IDF_TARGET not in ["esp32", "esp32c3"] reason: Sufficient to run this app on one chip with each architecture @@ -43,9 +35,7 @@ examples/system/console/basic: examples/system/deep_sleep: disable: - - if: IDF_TARGET in ["esp32p4"] - temporary: true - reason: target(s) is not supported yet # TODO: IDF-7529 + - if: SOC_DEEP_SLEEP_SUPPORTED != 1 examples/system/deep_sleep_wake_stub: disable: @@ -63,9 +53,7 @@ examples/system/efuse: examples/system/esp_timer: disable: - - if: IDF_TARGET in ["esp32p4"] - temporary: true - reason: Light Sleep support TBD # TODO: IDF-7528 + - if: SOC_LIGHT_SLEEP_SUPPORTED != 1 depends_components: - esp_timer @@ -134,9 +122,7 @@ examples/system/ipc/ipc_isr/xtensa: examples/system/light_sleep: disable: - - if: IDF_TARGET in ["esp32p4"] - temporary: true - reason: target(s) is not supported yet + - if: SOC_LIGHT_SLEEP_SUPPORTED != 1 examples/system/ota/advanced_https_ota: disable: diff --git a/examples/system/console/advanced/README.md b/examples/system/console/advanced/README.md index d1727552df..8226a000f4 100644 --- a/examples/system/console/advanced/README.md +++ b/examples/system/console/advanced/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | # Console Example 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 01b3cf9180..761053ff98 100644 --- a/examples/system/console/advanced/components/cmd_system/cmd_system.c +++ b/examples/system/console/advanced/components/cmd_system/cmd_system.c @@ -14,5 +14,12 @@ void register_system(void) { register_system_common(); - register_system_sleep(); + +#if SOC_LIGHT_SLEEP_SUPPORTED + register_system_light_sleep(); +#endif + +#if SOC_DEEP_SLEEP_SUPPORTED + register_system_deep_sleep(); +#endif } diff --git a/examples/system/console/advanced/components/cmd_system/cmd_system.h b/examples/system/console/advanced/components/cmd_system/cmd_system.h index 52bcfb9c46..dbf4cd8422 100644 --- a/examples/system/console/advanced/components/cmd_system/cmd_system.h +++ b/examples/system/console/advanced/components/cmd_system/cmd_system.h @@ -19,7 +19,8 @@ void register_system(void); void register_system_common(void); // Register deep and light sleep functions -void register_system_sleep(void); +void register_system_deep_sleep(void); +void register_system_light_sleep(void); #ifdef __cplusplus } diff --git a/examples/system/console/advanced/components/cmd_system/cmd_system_sleep.c b/examples/system/console/advanced/components/cmd_system/cmd_system_sleep.c index 0dd3ef9a18..3f90d3e663 100644 --- a/examples/system/console/advanced/components/cmd_system/cmd_system_sleep.c +++ b/examples/system/console/advanced/components/cmd_system/cmd_system_sleep.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -29,16 +29,6 @@ static const char *TAG = "cmd_system_sleep"; -static void register_deep_sleep(void); -static void register_light_sleep(void); - -void register_system_sleep(void) -{ - register_deep_sleep(); - register_light_sleep(); -} - - /** 'deep_sleep' command puts the chip into deep sleep mode */ static struct { @@ -95,7 +85,7 @@ static int deep_sleep(int argc, char **argv) return 1; } -static void register_deep_sleep(void) +void register_system_deep_sleep(void) { int num_args = 1; deep_sleep_args.wakeup_time = @@ -196,7 +186,7 @@ static int light_sleep(int argc, char **argv) return 0; } -static void register_light_sleep(void) +void register_system_light_sleep(void) { light_sleep_args.wakeup_time = arg_int0("t", "time", "", "Wake up time, ms"); diff --git a/examples/system/console/advanced/main/console_example_main.c b/examples/system/console/advanced/main/console_example_main.c index 3151803fd9..6b63324b7c 100644 --- a/examples/system/console/advanced/main/console_example_main.c +++ b/examples/system/console/advanced/main/console_example_main.c @@ -168,7 +168,12 @@ void app_main(void) /* Register commands */ esp_console_register_help_command(); register_system_common(); - register_system_sleep(); +#if SOC_LIGHT_SLEEP_SUPPORTED + register_system_light_sleep(); +#endif +#if SOC_DEEP_SLEEP_SUPPORTED + register_system_deep_sleep(); +#endif #if SOC_WIFI_SUPPORTED register_wifi(); #endif diff --git a/examples/system/console/advanced_usb_cdc/main/console_usb_example_main.c b/examples/system/console/advanced_usb_cdc/main/console_usb_example_main.c index b81b2a911c..64dd2cb132 100644 --- a/examples/system/console/advanced_usb_cdc/main/console_usb_example_main.c +++ b/examples/system/console/advanced_usb_cdc/main/console_usb_example_main.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -95,9 +95,16 @@ void app_main(void) /* Register commands */ esp_console_register_help_command(); register_system_common(); - register_system_sleep(); - register_nvs(); +#if SOC_LIGHT_SLEEP_SUPPORTED + register_system_light_sleep(); +#endif +#if SOC_DEEP_SLEEP_SUPPORTED + register_system_deep_sleep(); +#endif +#if SOC_WIFI_SUPPORTED register_wifi(); +#endif + register_nvs(); /* Prompt to be printed before each line. * This can be customized, made dynamic, etc. diff --git a/examples/system/console/basic/README.md b/examples/system/console/basic/README.md index f4d5eb110a..a26e757de2 100644 --- a/examples/system/console/basic/README.md +++ b/examples/system/console/basic/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | # Basic Console Example (`esp_console_repl`) diff --git a/examples/system/console/basic/main/console_example_main.c b/examples/system/console/basic/main/console_example_main.c index 5ff13f33a2..c0bacf0b1d 100644 --- a/examples/system/console/basic/main/console_example_main.c +++ b/examples/system/console/basic/main/console_example_main.c @@ -91,7 +91,12 @@ void app_main(void) /* Register commands */ esp_console_register_help_command(); register_system_common(); - register_system_sleep(); +#if SOC_LIGHT_SLEEP_SUPPORTED + register_system_light_sleep(); +#endif +#if SOC_DEEP_SLEEP_SUPPORTED + register_system_deep_sleep(); +#endif #if SOC_WIFI_SUPPORTED register_wifi(); #endif