From a7b87fe83230ad881d8362a43f8f6fc7db1b2571 Mon Sep 17 00:00:00 2001 From: Zhou Xiao Date: Fri, 19 Sep 2025 11:22:44 +0800 Subject: [PATCH 1/9] change(ble): [AUTO_MR] Update lib_esp32h2 to 390a8efd --- components/bt/controller/lib_esp32h2/esp32h2-bt-lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/controller/lib_esp32h2/esp32h2-bt-lib b/components/bt/controller/lib_esp32h2/esp32h2-bt-lib index 0783414092..a8a87adbd0 160000 --- a/components/bt/controller/lib_esp32h2/esp32h2-bt-lib +++ b/components/bt/controller/lib_esp32h2/esp32h2-bt-lib @@ -1 +1 @@ -Subproject commit 07834140920ccf33cbca4b9c0655256efe389ed7 +Subproject commit a8a87adbd005ffaed05051b9a1b1809bfbdc700d From b75f8627976253b118b8c2b0844bc5e35bcef6c4 Mon Sep 17 00:00:00 2001 From: Zhou Xiao Date: Fri, 19 Sep 2025 11:22:44 +0800 Subject: [PATCH 2/9] change(ble): [AUTO_MR] Update lib_esp32c5 to 390a8efd --- components/bt/controller/lib_esp32c5/esp32c5-bt-lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/controller/lib_esp32c5/esp32c5-bt-lib b/components/bt/controller/lib_esp32c5/esp32c5-bt-lib index 805de93b59..cb38f41eb8 160000 --- a/components/bt/controller/lib_esp32c5/esp32c5-bt-lib +++ b/components/bt/controller/lib_esp32c5/esp32c5-bt-lib @@ -1 +1 @@ -Subproject commit 805de93b59d7d37b5cde1c53dd1d4c6de60108ce +Subproject commit cb38f41eb89dc3f4473fff7c9bc7129cee466af1 From 26dcd595997195109c39cb36d7c803bfbc02384e Mon Sep 17 00:00:00 2001 From: Zhou Xiao Date: Fri, 19 Sep 2025 11:22:44 +0800 Subject: [PATCH 3/9] change(ble): [AUTO_MR] Update lib_esp32c6 to 390a8efd --- components/bt/controller/lib_esp32c6/esp32c6-bt-lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/controller/lib_esp32c6/esp32c6-bt-lib b/components/bt/controller/lib_esp32c6/esp32c6-bt-lib index 9d2f7a02d1..56d7454a97 160000 --- a/components/bt/controller/lib_esp32c6/esp32c6-bt-lib +++ b/components/bt/controller/lib_esp32c6/esp32c6-bt-lib @@ -1 +1 @@ -Subproject commit 9d2f7a02d1073a2835cf71d9a9231759324f0338 +Subproject commit 56d7454a97d4d5bce43ee611e69d293c269f5d4a From a56e7df7107c267b9e52ba340b83f64367d9571e Mon Sep 17 00:00:00 2001 From: Zhou Xiao Date: Fri, 19 Sep 2025 11:22:44 +0800 Subject: [PATCH 4/9] change(ble): [AUTO_MR] Update lib_esp32c2 to 58398575 --- components/bt/controller/lib_esp32c2/esp32c2-bt-lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/controller/lib_esp32c2/esp32c2-bt-lib b/components/bt/controller/lib_esp32c2/esp32c2-bt-lib index c5a5ba3f0a..2045454453 160000 --- a/components/bt/controller/lib_esp32c2/esp32c2-bt-lib +++ b/components/bt/controller/lib_esp32c2/esp32c2-bt-lib @@ -1 +1 @@ -Subproject commit c5a5ba3f0ae2bb056384a140ad809ee5d4e78491 +Subproject commit 204545445378b2704e3311911373aac326892597 From 09a3b29d01fad2cda730caab0e73c61d5a727670 Mon Sep 17 00:00:00 2001 From: Zhou Xiao Date: Fri, 19 Sep 2025 11:22:47 +0800 Subject: [PATCH 5/9] change(ble): [AUTO_MR] updated rom linker script for ESP32-C2 --- components/esp_rom/esp32c2/ld/esp32c2.rom.ble-eco4.ld | 8 ++++---- components/esp_rom/esp32c2/ld/esp32c2.rom.ble.ld | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/esp_rom/esp32c2/ld/esp32c2.rom.ble-eco4.ld b/components/esp_rom/esp32c2/ld/esp32c2.rom.ble-eco4.ld index 93df187382..59bd96d5c5 100644 --- a/components/esp_rom/esp32c2/ld/esp32c2.rom.ble-eco4.ld +++ b/components/esp_rom/esp32c2/ld/esp32c2.rom.ble-eco4.ld @@ -459,7 +459,7 @@ r_ble_ll_resolv_list_clr = 0x4000117c; r_ble_ll_resolv_list_find = 0x40001180; r_ble_ll_resolv_list_read_size = 0x40001184; r_ble_ll_resolv_list_reset = 0x40001188; -r_ble_ll_resolv_list_rmv = 0x4000118c; +//r_ble_ll_resolv_list_rmv = 0x4000118c; r_ble_ll_resolv_local_addr_rd = 0x40001190; r_ble_ll_resolv_peer_addr_rd = 0x40001194; r_ble_ll_resolv_peer_rpa_any = 0x40001198; @@ -503,7 +503,7 @@ r_ble_ll_scan_have_rxd_scan_rsp = 0x4000122c; r_ble_ll_scan_init = 0x40001230; r_ble_ll_scan_initiator_start = 0x40001234; r_ble_ll_scan_is_inside_window = 0x40001238; -r_ble_ll_scan_move_window_to = 0x4000123c; +//r_ble_ll_scan_move_window_to = 0x4000123c; r_ble_ll_scan_npl_reset = 0x40001240; r_ble_ll_scan_parse_auxptr = 0x40001244; r_ble_ll_scan_parse_ext_hdr = 0x40001248; @@ -601,9 +601,9 @@ r_ble_ll_utils_csa2_prng = 0x400013b8; r_ble_ll_utils_remapped_channel = 0x400013bc; r_ble_ll_whitelist_add = 0x400013c0; r_ble_ll_whitelist_chg_allowed = 0x400013c4; -r_ble_ll_whitelist_clear = 0x400013c8; +//r_ble_ll_whitelist_clear = 0x400013c8; r_ble_ll_whitelist_read_size = 0x400013cc; -r_ble_ll_whitelist_rmv = 0x400013d0; +//r_ble_ll_whitelist_rmv = 0x400013d0; r_ble_ll_whitelist_search = 0x400013d4; r_ble_ll_write_rf_path_compensation = 0x400013d8; r_ble_lll_adv_aux_scannable_pdu_payload_len = 0x400013dc; diff --git a/components/esp_rom/esp32c2/ld/esp32c2.rom.ble.ld b/components/esp_rom/esp32c2/ld/esp32c2.rom.ble.ld index edde433afe..a0d2795b4d 100644 --- a/components/esp_rom/esp32c2/ld/esp32c2.rom.ble.ld +++ b/components/esp_rom/esp32c2/ld/esp32c2.rom.ble.ld @@ -408,7 +408,7 @@ r_ble_ll_scan_get_peer_rpa = 0x40001228; r_ble_ll_scan_have_rxd_scan_rsp = 0x4000122c; r_ble_ll_scan_initiator_start = 0x40001234; r_ble_ll_scan_is_inside_window = 0x40001238; -r_ble_ll_scan_move_window_to = 0x4000123c; +//r_ble_ll_scan_move_window_to = 0x4000123c; r_ble_ll_scan_npl_reset = 0x40001240; r_ble_ll_scan_parse_auxptr = 0x40001244; r_ble_ll_scan_parse_ext_hdr = 0x40001248; From 6ae338de342d589608bea850d1f2b82d9afb3b70 Mon Sep 17 00:00:00 2001 From: cjin Date: Fri, 19 Sep 2025 16:47:18 +0800 Subject: [PATCH 6/9] feat(ble): get wakeup cause when wake up on ESP32-C2 --- components/bt/controller/esp32c2/bt.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/components/bt/controller/esp32c2/bt.c b/components/bt/controller/esp32c2/bt.c index 42ae0b1062..120083000b 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -130,6 +130,15 @@ enum { }; #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED +typedef union { + struct { + uint32_t rtc_freq:20; + uint32_t rsv:11; + uint32_t bt_wakeup:1; + }; + uint32_t val; +} bt_wakeup_params_t; + /* External functions or variables ************************************************************************ */ @@ -220,6 +229,9 @@ static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void); #endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE #endif /* !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */ #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED +#if CONFIG_FREERTOS_USE_TICKLESS_IDLE +static bool esp_bt_check_wakeup_by_bt(void); +#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE /* Local variable definition *************************************************************************** */ @@ -712,6 +724,7 @@ void controller_sleep_cb(uint32_t enable_tick, void *arg) void controller_wakeup_cb(void *arg) { + bt_wakeup_params_t *params; if (s_ble_active) { return; } @@ -721,15 +734,25 @@ void controller_wakeup_cb(void *arg) esp_pm_get_configuration(&pm_config); assert(esp_rom_get_cpu_ticks_per_us() == pm_config.max_freq_mhz); #endif //CONFIG_PM_ENABLE + params = (bt_wakeup_params_t *)arg; esp_phy_enable(PHY_MODEM_BT); if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_RC_SLOW) { - uint32_t *clk_freq = (uint32_t *)arg; - *clk_freq = esp_clk_tree_lp_slow_get_freq_hz(ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED) / 5; + params->rtc_freq = esp_clk_tree_lp_slow_get_freq_hz(ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED) / 5; } +#if CONFIG_FREERTOS_USE_TICKLESS_IDLE + params->bt_wakeup = esp_bt_check_wakeup_by_bt(); +#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE // need to check if need to call pm lock here s_ble_active = true; } +#if CONFIG_FREERTOS_USE_TICKLESS_IDLE +static bool esp_bt_check_wakeup_by_bt(void) +{ + return (esp_sleep_get_wakeup_causes() & ESP_SLEEP_WAKEUP_BT); +} +#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE + esp_err_t controller_sleep_init(modem_clock_lpclk_src_t slow_clk_src) { esp_err_t rc = 0; From 622b7cf425021bc24efe4ba57683620930ec3425 Mon Sep 17 00:00:00 2001 From: cjin Date: Fri, 19 Sep 2025 16:47:35 +0800 Subject: [PATCH 7/9] feat(ble): get wakeup cause when wake up on ESP32-C6 --- components/bt/controller/esp32c6/bt.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/components/bt/controller/esp32c6/bt.c b/components/bt/controller/esp32c6/bt.c index fdb38fa979..351474d6dc 100644 --- a/components/bt/controller/esp32c6/bt.c +++ b/components/bt/controller/esp32c6/bt.c @@ -125,6 +125,15 @@ enum { }; #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED +typedef union { + struct { + uint32_t rtc_freq:20; + uint32_t rsv:11; + uint32_t bt_wakeup:1; + }; + uint32_t val; +} bt_wakeup_params_t; + /* External functions or variables ************************************************************************ */ @@ -221,6 +230,9 @@ static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void); #endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE #endif /* !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */ #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED +#if CONFIG_FREERTOS_USE_TICKLESS_IDLE +static bool esp_bt_check_wakeup_by_bt(void); +#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE /* Local variable definition *************************************************************************** */ @@ -759,6 +771,7 @@ IRAM_ATTR void controller_sleep_cb(uint32_t enable_tick, void *arg) IRAM_ATTR void controller_wakeup_cb(void *arg) { + bt_wakeup_params_t *params; if (s_ble_active) { return; } @@ -769,15 +782,23 @@ IRAM_ATTR void controller_wakeup_cb(void *arg) assert(esp_rom_get_cpu_ticks_per_us() == pm_config.max_freq_mhz); r_ble_rtc_wake_up_state_clr(); #endif //CONFIG_PM_ENABLE + params = (bt_wakeup_params_t *)arg; esp_phy_enable(PHY_MODEM_BT); if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_RC_SLOW) { - uint32_t *clk_freq = (uint32_t *)arg; - *clk_freq = esp_clk_tree_lp_slow_get_freq_hz(ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED) / 5; + params->rtc_freq = esp_clk_tree_lp_slow_get_freq_hz(ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED) / 5; } +#if CONFIG_FREERTOS_USE_TICKLESS_IDLE + params->bt_wakeup = esp_bt_check_wakeup_by_bt(); +#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE s_ble_active = true; } #if CONFIG_FREERTOS_USE_TICKLESS_IDLE +static bool esp_bt_check_wakeup_by_bt(void) +{ + return (esp_sleep_get_wakeup_causes() & ESP_SLEEP_WAKEUP_BT); +} + static esp_err_t sleep_modem_ble_mac_retention_init(void *arg) { uint8_t size; From 470e02ea6b7f457fbbfa3f062c58b9cb25653dcb Mon Sep 17 00:00:00 2001 From: cjin Date: Fri, 19 Sep 2025 16:47:45 +0800 Subject: [PATCH 8/9] feat(ble): get wakeup cause when wake up on ESP32-C5 --- components/bt/controller/esp32c5/bt.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/components/bt/controller/esp32c5/bt.c b/components/bt/controller/esp32c5/bt.c index e0dedbc49f..93c983b5b9 100644 --- a/components/bt/controller/esp32c5/bt.c +++ b/components/bt/controller/esp32c5/bt.c @@ -117,6 +117,16 @@ enum { BLE_LOG_INTERFACE_FLAG_END, }; #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED + +typedef union { + struct { + uint32_t rtc_freq:20; + uint32_t rsv:11; + uint32_t bt_wakeup:1; + }; + uint32_t val; +} bt_wakeup_params_t; + /* External functions or variables ************************************************************************ */ @@ -205,6 +215,9 @@ static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void); #endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE #endif /* !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */ #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED +#if CONFIG_FREERTOS_USE_TICKLESS_IDLE +static bool esp_bt_check_wakeup_by_bt(void); +#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE /* Local variable definition *************************************************************************** */ @@ -698,6 +711,7 @@ IRAM_ATTR void controller_sleep_cb(uint32_t enable_tick, void *arg) IRAM_ATTR void controller_wakeup_cb(void *arg) { + bt_wakeup_params_t *params; if (s_ble_active) { return; } @@ -708,15 +722,23 @@ IRAM_ATTR void controller_wakeup_cb(void *arg) assert(esp_rom_get_cpu_ticks_per_us() == pm_config.max_freq_mhz); r_ble_rtc_wake_up_state_clr(); #endif //CONFIG_PM_ENABLE + params = (bt_wakeup_params_t *)arg; esp_phy_enable(PHY_MODEM_BT); if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_RC_SLOW) { - uint32_t *clk_freq = (uint32_t *)arg; - *clk_freq = esp_clk_tree_lp_slow_get_freq_hz(ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED) / 5; + params->rtc_freq = esp_clk_tree_lp_slow_get_freq_hz(ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED) / 5; } +#if CONFIG_FREERTOS_USE_TICKLESS_IDLE + params->bt_wakeup = esp_bt_check_wakeup_by_bt(); +#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE s_ble_active = true; } #if CONFIG_FREERTOS_USE_TICKLESS_IDLE +static bool esp_bt_check_wakeup_by_bt(void) +{ + return (esp_sleep_get_wakeup_causes() & ESP_SLEEP_WAKEUP_BT); +} + static esp_err_t sleep_modem_ble_mac_retention_init(void *arg) { uint8_t size; From 41ecf44cb3c960ea2c3b261652a939918fb3ba9a Mon Sep 17 00:00:00 2001 From: cjin Date: Fri, 19 Sep 2025 16:47:57 +0800 Subject: [PATCH 9/9] feat(ble): get wakeup cause when wake up on ESP32-H2 --- components/bt/controller/esp32h2/bt.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/components/bt/controller/esp32h2/bt.c b/components/bt/controller/esp32h2/bt.c index 306587b9e5..8533a1aa99 100644 --- a/components/bt/controller/esp32h2/bt.c +++ b/components/bt/controller/esp32h2/bt.c @@ -117,6 +117,15 @@ enum { BLE_LOG_INTERFACE_FLAG_END, }; #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED + +typedef union { + struct { + uint32_t rtc_freq:20; + uint32_t rsv:11; + uint32_t bt_wakeup:1; + }; + uint32_t val; +} bt_wakeup_params_t; /* External functions or variables ************************************************************************ */ @@ -214,6 +223,9 @@ static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void); #endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE #endif /* !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */ #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED +#if CONFIG_FREERTOS_USE_TICKLESS_IDLE +static bool esp_bt_check_wakeup_by_bt(void); +#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE /* Local variable definition *************************************************************************** */ @@ -727,6 +739,7 @@ IRAM_ATTR void controller_sleep_cb(uint32_t enable_tick, void *arg) IRAM_ATTR void controller_wakeup_cb(void *arg) { + bt_wakeup_params_t *params; if (s_ble_active) { return; } @@ -737,15 +750,23 @@ IRAM_ATTR void controller_wakeup_cb(void *arg) assert(esp_rom_get_cpu_ticks_per_us() == pm_config.max_freq_mhz); r_ble_rtc_wake_up_state_clr(); #endif //CONFIG_PM_ENABLE + params = (bt_wakeup_params_t *)arg; esp_phy_enable(PHY_MODEM_BT); if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_RC_SLOW) { - uint32_t *clk_freq = (uint32_t *)arg; - *clk_freq = esp_clk_tree_lp_slow_get_freq_hz(ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED) / 5; + params->rtc_freq = esp_clk_tree_lp_slow_get_freq_hz(ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED) / 5; } +#if CONFIG_FREERTOS_USE_TICKLESS_IDLE + params->bt_wakeup = esp_bt_check_wakeup_by_bt(); +#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE s_ble_active = true; } #ifdef CONFIG_FREERTOS_USE_TICKLESS_IDLE +static bool esp_bt_check_wakeup_by_bt(void) +{ + return (esp_sleep_get_wakeup_causes() & ESP_SLEEP_WAKEUP_BT); +} + static esp_err_t sleep_modem_ble_mac_retention_init(void *arg) { uint8_t size;