Merge branch 'ble_dev/esp32c6_support_power_save_example' into 'master'

ble: support esp32c6 power save example

Closes EBLE50Y23-148

See merge request espressif/esp-idf!24385
This commit is contained in:
Island 2023-06-30 14:36:26 +08:00
commit 9b5f3c69a9
5 changed files with 98 additions and 17 deletions

View File

@ -620,7 +620,6 @@ void controller_sleep_deinit(void)
esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
{
uint8_t mac[6];
uint32_t chip_version;
esp_err_t ret = ESP_OK;
ble_npl_count_info_t npl_info;
@ -681,9 +680,9 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
#endif // CONFIG_BT_NIMBLE_ENABLED
/* Enable BT-related clocks */
modem_clock_module_enable(PERIPH_BT_MODULE);
chip_version = efuse_hal_chip_revision();
/* Select slow clock source for BT momdule */
#if CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL
uint32_t chip_version = efuse_hal_chip_revision();
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using main XTAL as clock source");
if (chip_version == 0) {
modem_clock_select_lp_clock_source(PERIPH_BT_MODULE, MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL, (400 - 1));

View File

@ -270,6 +270,6 @@ examples/bluetooth/nimble/hci:
examples/bluetooth/nimble/power_save:
enable:
- if: IDF_TARGET in ["esp32", "esp32c3", "esp32s3"]
- if: IDF_TARGET in ["esp32", "esp32c3", "esp32s3", "esp32c6"]
temporary: true
reason: the other targets are not tested yet

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32 | ESP32-C3 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- |
| Supported Targets | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- |
Bluetooth Power Save Example
=================================
@ -10,16 +10,20 @@ If the modem sleep mode is enabled, bluetooth will switch periodically between a
In sleep state, RF, PHY and BB are turned off in order to reduce power consumption.
This example contains five build configurations. For each configuration, a few configuration options are set:
- `sdkconfig.defaults.esp32`: ESP32 uses 32kHz XTAL as low power clock in light sleep enabled.
- `sdkconfig.40m.esp32c3`: ESP32C3 uses 32kHz XTAL as low power clock in light sleep enabled.
- `sdkconfig.esp32c3_40m`: ESP32C3 uses main XTAL as low power clock in light sleep enabled.
- `sdkconfig.defaults.esp32c3`: ESP32C3 uses 32kHz XTAL as low power clock in light sleep enabled.
- `sdkconfig.40m.esp32c3`: ESP32C3 uses main XTAL as low power clock in light sleep enabled.
- `sdkconfig.defaults.esp32c6`: ESP32C6 uses 32kHz XTAL as low power clock in light sleep enabled.
- `sdkconfig.40m.esp32c6`: ESP32C6 uses main XTAL as low power clock in light sleep enabled.
- `sdkconfig.defaults.esp32s3`: ESP32S3 uses 32kHz XTAL as low power clock in light sleep enabled.
- `sdkconfig.40m.esp32s3`: ESP32S3 uses main XTAL as low power clock in light sleep enabled.
## How to use example
### Hardware Required
This example should be able to run on any commonly available ESP32/ESP32-C3/ESP32-S3 development board.
This example should be able to run on any commonly available ESP32/ESP32-C3/ESP32-S3/ESP32-C6 development board.
### Configure the project
@ -33,9 +37,12 @@ idf.py menuconfig
- `Component config > Power Management > [*] Support for power management`
3. Configure FreeRTOS:
- `Component config > FreeRTOS > Kernel`
- `(1000) configTICK_RATE_HZ`
- `[*] configUSE_TICKLESS_IDLE`
- `(3) configEXPECTED_IDLE_TIME_BEFORE_SLEEP`
- `(1000) configTICK_RATE_HZ`
- `[*] configUSE_TICKLESS_IDLE`
- `(3) configEXPECTED_IDLE_TIME_BEFORE_SLEEP`
#### For ESP32/ESP32-C3/ESP32-S3 Chip:
4. Enable power down MAC and baseband:
- `Component config > PHY > [*] Power down MAC and baseband of Wi-Fi and Bluetooth when PHY is disabled`
5. Enable bluetooth modem sleep:
@ -47,6 +54,21 @@ idf.py menuconfig
7. Enable power up main XTAL during light sleep:
- `Component config > Bluetooth > Controller Options > MODEM SLEEP Options > [*] power up main XTAL during light sleep`
#### For ESP32-C6 Chip:
4. Enable bluetooth modem sleep:
- `Component config > Bluetooth > Controller Options`
- `[*] Enable BLE sleep`
5. Configure bluetooth low power clock:
- `Component config → Bluetooth → Controller Options → BLE low power clock source`
- Use main XTAL as low power clock source during light sleep:
- `(X) Use main XTAL as RTC clock source`
- Use RTC clock source as low power clock sourceduring light sleep:
- `(X) Use system RTC slow clock source`
6. Power down flash during light sleep:
* `Component config → Hardware Settings → Sleep Config`
* `[*] Power down flash in light sleep when there is no SPIRAM`
### Build and Flash
```
@ -101,12 +123,13 @@ I (463) NimBLE:
## Typical current consumption with management enabled
| | max current | modem sleep | light sleep (main XTAL)| light sleep (32KHz XTAL)|
|-------- | ----------- | ------------ | ---------------------- |------------------------ |
| ESP32 | 231 mA | 14.1 mA | X | 1.9 mA |
| ESP32C3 | 262 mA | 12 mA | 2.3 mA | 140 uA |
| ESP32S3 | 240 mA | 17.9 mA | 3.3 mA | 230 uA |
X: This feature is currently not supported.
| | max current | modem sleep | light sleep (main XTAL) | light sleep (32KHz XTAL) |
| ------------------------------------------- | ----------- | ----------- | ----------------------- | ------------------------ |
| ESP32 | 231 mA | 14.1 mA | X | 1.9 mA |
| ESP32C3 | 262 mA | 12 mA | 2.3 mA | 140 uA |
| ESP32S3 | 240 mA | 17.9 mA | 3.3 mA | 230 uA |
| ESP32C6 | 240 mA | 22 mA | 3.3 mA | 34 uA |
X: This feature is currently not supported.
## Example Breakdown

View File

@ -0,0 +1,25 @@
CONFIG_IDF_TARGET="esp32c6"
# Bluetooth Low Power Config
CONFIG_BT_LE_SLEEP_ENABLE=y
# CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER is not set
CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER=y
CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL=y
# CONFIG_BT_LE_LP_CLK_SRC_DEFAULT is not set
#
# 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 is not set
# end of Power Management
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y
#
# Sleep Config
#
CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y
# end of Sleep Config

View File

@ -0,0 +1,34 @@
CONFIG_IDF_TARGET="esp32c6"
# Bluetooth Low Power Config
CONFIG_BT_LE_SLEEP_ENABLE=y
# CONFIG_BT_LE_WAKEUP_SOURCE_CPU_RTC_TIMER is not set
CONFIG_BT_LE_WAKEUP_SOURCE_BLE_RTC_TIMER=y
# CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL is not set
CONFIG_BT_LE_LP_CLK_SRC_DEFAULT=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_FREERTOS_USE_TICKLESS_IDLE=y
#
# Sleep Config
#
CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y
# end of Sleep Config
#
# RTC Clock Config
#
# CONFIG_RTC_CLK_SRC_INT_RC is not set
CONFIG_RTC_CLK_SRC_EXT_CRYS=y
# CONFIG_RTC_CLK_SRC_EXT_OSC is not set
# CONFIG_RTC_CLK_SRC_INT_RC32K is not set
# end of RTC Clock Config