Skip to content

Commit e770372

Browse files
committed
Merge branch 'ble_dev/support_esp32c61_ble_light_sleep' into 'master'
feat(ble): support ble light sleep on esp32c61 Closes BLERP-1070 See merge request espressif/esp-idf!33818
2 parents afffd0d + b564181 commit e770372

File tree

9 files changed

+69
-15
lines changed

9 files changed

+69
-15
lines changed

components/bt/controller/esp32c6/bt.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,9 @@
4343
#include "esp_private/periph_ctrl.h"
4444
#include "bt_osi_mem.h"
4545

46-
#if SOC_PM_RETENTION_HAS_CLOCK_BUG
47-
#include "esp_private/sleep_retention.h"
48-
#endif // SOC_PM_RETENTION_HAS_CLOCK_BUG
49-
5046
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
5147
#include "esp_private/sleep_modem.h"
48+
#include "esp_private/sleep_retention.h"
5249
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
5350

5451
#include "freertos/FreeRTOS.h"
@@ -643,11 +640,15 @@ esp_err_t controller_sleep_init(void)
643640
goto error;
644641
}
645642
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
646-
#if CONFIG_BT_LE_SLEEP_ENABLE && !CONFIG_MAC_BB_PD
643+
#if CONFIG_BT_LE_SLEEP_ENABLE && SOC_PM_RETENTION_HAS_CLOCK_BUG && !CONFIG_MAC_BB_PD
647644
#error "CONFIG_MAC_BB_PD required for BLE light sleep to run properly"
648-
#endif // CONFIG_BT_LE_SLEEP_ENABLE && !CONFIG_MAC_BB_PD
645+
#endif // CONFIG_BT_LE_SLEEP_ENABLE && SOC_PM_RETENTION_HAS_CLOCK_BUG && !CONFIG_MAC_BB_PD
649646
/* Create a new regdma link for BLE related register restoration */
647+
#if SOC_PM_RETENTION_HAS_CLOCK_BUG
650648
rc = sleep_modem_ble_mac_modem_state_init(1);
649+
#else
650+
rc = sleep_modem_ble_mac_modem_state_init(0);
651+
#endif // SOC_PM_RETENTION_HAS_CLOCK_BUG
651652
assert(rc == 0);
652653
esp_sleep_enable_bt_wakeup();
653654
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Enable light sleep, the wake up source is BLE timer");

components/soc/esp32c61/include/soc/Kconfig.soc_caps.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,10 @@ config SOC_PM_SUPPORT_BEACON_WAKEUP
827827
bool
828828
default y
829829

830+
config SOC_PM_SUPPORT_BT_WAKEUP
831+
bool
832+
default y
833+
830834
config SOC_PM_SUPPORT_EXT1_WAKEUP
831835
bool
832836
default y

components/soc/esp32c61/include/soc/soc_caps.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@
418418
/*-------------------------- Power Management CAPS ----------------------------*/
419419
#define SOC_PM_SUPPORT_WIFI_WAKEUP (1)
420420
#define SOC_PM_SUPPORT_BEACON_WAKEUP (1)
421-
// #define SOC_PM_SUPPORT_BT_WAKEUP (1)
421+
#define SOC_PM_SUPPORT_BT_WAKEUP (1)
422422
#define SOC_PM_SUPPORT_EXT1_WAKEUP (1)
423423
#define SOC_PM_SUPPORT_EXT1_WAKEUP_MODE_PER_PIN (1) /*!<Supports one bit per pin to configure the EXT1 trigger level */
424424
#define SOC_PM_SUPPORT_CPU_PD (1)

examples/bluetooth/.build-test-rules.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,6 @@ examples/bluetooth/nimble/blecent:
200200
<<: *bt_default_depends
201201
disable:
202202
- if: SOC_BLE_SUPPORTED != 1
203-
disable_test:
204-
- if: IDF_TARGET in ["esp32c61"]
205-
temporary: true
206-
reason: Not supported yet
207203
depends_components:
208204
- bt
209205
- esp_phy
@@ -252,7 +248,6 @@ examples/bluetooth/nimble/power_save:
252248
<<: *bt_default_depends
253249
disable:
254250
- if: SOC_BLE_SUPPORTED != 1
255-
- if: IDF_TARGET in ["esp32c61"]
256251
depends_components:
257252
- bt
258253
- esp_phy

examples/bluetooth/nimble/power_save/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-H2 | ESP32-S3 |
2-
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- |
1+
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-S3 |
2+
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- |
33

44
Bluetooth Power Save Example
55
=================================
@@ -24,6 +24,8 @@ This example contains some build configurations. For each configuration, a few c
2424
- `sdkconfig.26m.esp32c2`: ESP32C2 uses main XTAL as low power clock in light sleep enabled.
2525
- `sdkconfig.defaults.esp32c5`: ESP32C5 uses 32kHz XTAL as low power clock in light sleep enabled.
2626
- `sdkconfig.48m.esp32c5`: ESP32C5 uses main XTAL as low power clock in light sleep enabled.
27+
- `sdkconfig.defaults.esp32c61`: ESP32C61 uses 32kHz XTAL as low power clock in light sleep enabled.
28+
- `sdkconfig.40m.esp32c61`: ESP32C61 uses main XTAL as low power clock in light sleep enabled.
2729

2830
## How to use example
2931

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
CONFIG_IDF_TARGET="esp32c61"
2+
3+
# Bluetooth Low Power Config
4+
CONFIG_BT_LE_SLEEP_ENABLE=y
5+
CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL=y
6+
7+
#
8+
# Power Management
9+
#
10+
CONFIG_PM_ENABLE=y
11+
CONFIG_PM_DFS_INIT_AUTO=y
12+
CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP=y
13+
# end of Power Management
14+
15+
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y
16+
17+
#
18+
# Sleep Config
19+
#
20+
CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y
21+
CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y
22+
# end of Sleep Config
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
CONFIG_IDF_TARGET="esp32c61"
2+
3+
# Bluetooth Low Power Config
4+
CONFIG_BT_LE_SLEEP_ENABLE=y
5+
CONFIG_BT_LE_LP_CLK_SRC_DEFAULT=y
6+
7+
#
8+
# Power Management
9+
#
10+
CONFIG_PM_ENABLE=y
11+
CONFIG_PM_DFS_INIT_AUTO=y
12+
CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP=y
13+
CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP=y
14+
# end of Power Management
15+
16+
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y
17+
18+
#
19+
# Sleep Config
20+
#
21+
CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y
22+
CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y
23+
# end of Sleep Config
24+
25+
#
26+
# RTC Clock Config
27+
#
28+
CONFIG_RTC_CLK_SRC_EXT_CRYS=y
29+
# end of RTC Clock Config

examples/bluetooth/nimble/pytest_nimble_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
@pytest.mark.esp32c3
1515
@pytest.mark.esp32s3
1616
@pytest.mark.esp32c5
17+
@pytest.mark.esp32c61
1718
@pytest.mark.esp32
1819
@pytest.mark.wifi_two_dut
1920
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)