diff --git a/examples/bluetooth/nimble/power_save/README.md b/examples/bluetooth/nimble/power_save/README.md index 87b49c31684..c042c1a7403 100644 --- a/examples/bluetooth/nimble/power_save/README.md +++ b/examples/bluetooth/nimble/power_save/README.md @@ -30,6 +30,8 @@ This example contains some build configurations. For each configuration, a few c - `sdkconfig.40m.esp32s31`: ESP32S31 uses main XTAL as low power clock in light sleep enabled. - `sdkconfig.defaults.esp32h4`: ESP32H4 uses 32kHz XTAL as low power clock in light sleep enabled. - `sdkconfig.32m.esp32h4`: ESP32H4 uses main XTAL as low power clock in light sleep enabled. +- `sdkconfig.defaults.esp32h21`: ESP32H21 uses 32kHz XTAL as low power clock in light sleep enabled. +- `sdkconfig.32m.esp32h21`: ESP32H21 uses main XTAL as low power clock in light sleep enabled. ## How to use example diff --git a/examples/bluetooth/nimble/power_save/main/Kconfig.projbuild b/examples/bluetooth/nimble/power_save/main/Kconfig.projbuild index 733f7c2804a..70dcff8042b 100644 --- a/examples/bluetooth/nimble/power_save/main/Kconfig.projbuild +++ b/examples/bluetooth/nimble/power_save/main/Kconfig.projbuild @@ -1,97 +1,5 @@ menu "Example Configuration" - choice EXAMPLE_MAX_CPU_FREQ - prompt "Maximum CPU frequency" - default EXAMPLE_MAX_CPU_FREQ_160 if !IDF_TARGET_ESP32H2 && !IDF_TARGET_ESP32C2 && \ - !IDF_TARGET_ESP32C5 && !IDF_TARGET_ESP32H4 && !IDF_TARGET_ESP32S31 - default EXAMPLE_MAX_CPU_FREQ_96 if IDF_TARGET_ESP32H2 || IDF_TARGET_ESP32H4 - default EXAMPLE_MAX_CPU_FREQ_120 if IDF_TARGET_ESP32C2 - default EXAMPLE_MAX_CPU_FREQ_240 if IDF_TARGET_ESP32C5 - default EXAMPLE_MAX_CPU_FREQ_320 if IDF_TARGET_ESP32S31 - depends on PM_ENABLE - help - Maximum CPU frequency to use for dynamic frequency scaling. - - config EXAMPLE_MAX_CPU_FREQ_80 - bool "80 MHz" - config EXAMPLE_MAX_CPU_FREQ_96 - bool "96 MHz" - depends on IDF_TARGET_ESP32H2 || IDF_TARGET_ESP32H4 - config EXAMPLE_MAX_CPU_FREQ_160 - bool "160 MHz" - config EXAMPLE_MAX_CPU_FREQ_120 - bool "120 MHz" - depends on IDF_TARGET_ESP32C2 - config EXAMPLE_MAX_CPU_FREQ_240 - bool "240 MHz" - depends on IDF_TARGET_ESP32 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C5 - config EXAMPLE_MAX_CPU_FREQ_320 - bool "320 MHz" - depends on IDF_TARGET_ESP32S31 - endchoice - - config EXAMPLE_MAX_CPU_FREQ_MHZ - int - default 80 if EXAMPLE_MAX_CPU_FREQ_80 - default 96 if EXAMPLE_MAX_CPU_FREQ_96 - default 120 if EXAMPLE_MAX_CPU_FREQ_120 - default 160 if EXAMPLE_MAX_CPU_FREQ_160 - default 240 if EXAMPLE_MAX_CPU_FREQ_240 - default 320 if EXAMPLE_MAX_CPU_FREQ_320 - - choice EXAMPLE_MIN_CPU_FREQ - prompt "Minimum CPU frequency" - default EXAMPLE_MIN_CPU_FREQ_40M if !IDF_TARGET_ESP32H2 && !IDF_TARGET_ESP32C2 && \ - !IDF_TARGET_ESP32C5 && !IDF_TARGET_ESP32H4 - default EXAMPLE_MIN_CPU_FREQ_48M if IDF_TARGET_ESP32C5 - default EXAMPLE_MIN_CPU_FREQ_32M if IDF_TARGET_ESP32H2 || IDF_TARGET_ESP32H4 - default EXAMPLE_MIN_CPU_FREQ_26M if IDF_TARGET_ESP32C2 - depends on PM_ENABLE - help - Minimum CPU frequency to use for dynamic frequency scaling. - Should be set to XTAL frequency or XTAL frequency divided by integer. - - config EXAMPLE_MIN_CPU_FREQ_80M - bool "80 MHz" - depends on !(IDF_TARGET_ESP32 && EXAMPLE_MAX_CPU_FREQ_240) - help - ESP32 does not support switching between 240M and 80M.The root cause - is that when switching between 240M and 80M, we need to disable - BBPLL and then re-enable it with a different frequency.Since the - Bluetooth baseband works from PLL frequency, it will temporarily - lose its 80 MHz clock, while the BBPLL is disabled. - config EXAMPLE_MIN_CPU_FREQ_48M - bool "48 MHz (use with 48MHz XTAL)" - depends on XTAL_FREQ_48 || XTAL_FREQ_AUTO - config EXAMPLE_MIN_CPU_FREQ_40M - bool "40 MHz (use with 40MHz XTAL)" - depends on XTAL_FREQ_40 || XTAL_FREQ_AUTO - config EXAMPLE_MIN_CPU_FREQ_32M - bool "32 MHz (use with 32MHz XTAL)" - depends on IDF_TARGET_ESP32H2 || IDF_TARGET_ESP32H4 - depends on XTAL_FREQ_32 || XTAL_FREQ_AUTO - config EXAMPLE_MIN_CPU_FREQ_26M - bool "26 MHz (use with 26MHz XTAL)" - depends on IDF_TARGET_ESP32C2 - depends on XTAL_FREQ_26 || XTAL_FREQ_AUTO - config EXAMPLE_MIN_CPU_FREQ_20M - bool "20 MHz (use with 40MHz XTAL)" - depends on XTAL_FREQ_40 || XTAL_FREQ_AUTO - config EXAMPLE_MIN_CPU_FREQ_10M - bool "10 MHz (use with 40MHz XTAL)" - depends on XTAL_FREQ_40 || XTAL_FREQ_AUTO - endchoice - - config EXAMPLE_MIN_CPU_FREQ_MHZ - int - default 80 if EXAMPLE_MIN_CPU_FREQ_80M - default 48 if EXAMPLE_MIN_CPU_FREQ_48M - default 40 if EXAMPLE_MIN_CPU_FREQ_40M - default 32 if EXAMPLE_MIN_CPU_FREQ_32M - default 26 if EXAMPLE_MIN_CPU_FREQ_26M - default 20 if EXAMPLE_MIN_CPU_FREQ_20M - default 10 if EXAMPLE_MIN_CPU_FREQ_10M - choice EXAMPLE_USE_IO_TYPE prompt "I/O Capability" default BLE_SM_IO_CAP_NO_IO diff --git a/examples/bluetooth/nimble/power_save/main/main.c b/examples/bluetooth/nimble/power_save/main/main.c index 1c9b2dd6a62..331db9171e8 100644 --- a/examples/bluetooth/nimble/power_save/main/main.c +++ b/examples/bluetooth/nimble/power_save/main/main.c @@ -573,8 +573,8 @@ app_main(void) // maximum and minimum frequencies are set in sdkconfig, // automatic light sleep is enabled if tickless idle support is enabled. esp_pm_config_t pm_config = { - .max_freq_mhz = CONFIG_EXAMPLE_MAX_CPU_FREQ_MHZ, - .min_freq_mhz = CONFIG_EXAMPLE_MIN_CPU_FREQ_MHZ, + .max_freq_mhz = CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ, + .min_freq_mhz = CONFIG_XTAL_FREQ, #if CONFIG_FREERTOS_USE_TICKLESS_IDLE .light_sleep_enable = true #endif diff --git a/examples/bluetooth/nimble/power_save/sdkconfig.32m.esp32h21 b/examples/bluetooth/nimble/power_save/sdkconfig.32m.esp32h21 new file mode 100644 index 00000000000..a2377a41e6b --- /dev/null +++ b/examples/bluetooth/nimble/power_save/sdkconfig.32m.esp32h21 @@ -0,0 +1,22 @@ +CONFIG_IDF_TARGET="esp32h21" + +# Bluetooth Low Power Config +CONFIG_BT_LE_SLEEP_ENABLE=y +CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL=y + +# +# Power Management +# +CONFIG_PM_ENABLE=y +CONFIG_PM_DFS_INIT_AUTO=y +CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP=y +CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP=y +# end of Power Management + +CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING=y + +# +# Sleep Config +# +CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y +# end of Sleep Config diff --git a/examples/bluetooth/nimble/power_save/sdkconfig.32m.esp32h4 b/examples/bluetooth/nimble/power_save/sdkconfig.32m.esp32h4 index d0b6997e04d..a40da6eaff3 100644 --- a/examples/bluetooth/nimble/power_save/sdkconfig.32m.esp32h4 +++ b/examples/bluetooth/nimble/power_save/sdkconfig.32m.esp32h4 @@ -18,6 +18,5 @@ CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING=y # # Sleep Config # -CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y # end of Sleep Config diff --git a/examples/bluetooth/nimble/power_save/sdkconfig.40m.esp32c61 b/examples/bluetooth/nimble/power_save/sdkconfig.40m.esp32c61 index 2d712debeb7..34fd71dd83b 100644 --- a/examples/bluetooth/nimble/power_save/sdkconfig.40m.esp32c61 +++ b/examples/bluetooth/nimble/power_save/sdkconfig.40m.esp32c61 @@ -18,6 +18,5 @@ CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING=y # # Sleep Config # -CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y # end of Sleep Config diff --git a/examples/bluetooth/nimble/power_save/sdkconfig.40m.esp32s31 b/examples/bluetooth/nimble/power_save/sdkconfig.40m.esp32s31 index c14fc0f2238..500d813cdc1 100644 --- a/examples/bluetooth/nimble/power_save/sdkconfig.40m.esp32s31 +++ b/examples/bluetooth/nimble/power_save/sdkconfig.40m.esp32s31 @@ -18,6 +18,5 @@ CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING=y # # Sleep Config # -CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y # end of Sleep Config diff --git a/examples/bluetooth/nimble/power_save/sdkconfig.48m.esp32c5 b/examples/bluetooth/nimble/power_save/sdkconfig.48m.esp32c5 index 42fde259685..f3f2dbe10ca 100644 --- a/examples/bluetooth/nimble/power_save/sdkconfig.48m.esp32c5 +++ b/examples/bluetooth/nimble/power_save/sdkconfig.48m.esp32c5 @@ -18,6 +18,5 @@ CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING=y # # Sleep Config # -CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y # end of Sleep Config diff --git a/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32c5 b/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32c5 index 59c24a69a86..943c1c203aa 100644 --- a/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32c5 +++ b/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32c5 @@ -19,7 +19,6 @@ CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING=y # # Sleep Config # -CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y # end of Sleep Config diff --git a/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32c61 b/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32c61 index 6e60a0026ca..cd0f68a6d24 100644 --- a/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32c61 +++ b/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32c61 @@ -19,7 +19,6 @@ CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING=y # # Sleep Config # -CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y # end of Sleep Config diff --git a/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32h21 b/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32h21 index 74563cdfda4..98c9bdaf88d 100644 --- a/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32h21 +++ b/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32h21 @@ -1,3 +1,5 @@ +CONFIG_IDF_TARGET="esp32h21" + # Bluetooth Low Power Config CONFIG_BT_LE_SLEEP_ENABLE=y CONFIG_BT_LE_LP_CLK_SRC_DEFAULT=y @@ -16,7 +18,6 @@ CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING=y # # Sleep Config # -CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y # end of Sleep Config diff --git a/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32h4 b/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32h4 index 81ae8488cf5..53e2401cef9 100644 --- a/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32h4 +++ b/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32h4 @@ -18,7 +18,6 @@ CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING=y # # Sleep Config # -CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y # end of Sleep Config diff --git a/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32s31 b/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32s31 index 8ec249419c3..bf31b24e7c2 100644 --- a/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32s31 +++ b/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32s31 @@ -19,7 +19,6 @@ CONFIG_ESP_MODEM_CLOCK_ENABLE_CHECKING=y # # Sleep Config # -CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y # end of Sleep Config