Skip to content

Commit ce4e012

Browse files
feat(ble): use new section for ble sleep on ESP32-C2
1 parent 09467ba commit ce4e012

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

components/bt/controller/esp32c2/Kconfig.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,11 @@ config BT_LE_PLACE_CONN_RELATED_INTO_IRAM
682682
depends on BT_CTRL_RUN_IN_FLASH_ONLY
683683
default n
684684

685+
config BT_LE_PLACE_SLEEP_RELATED_INTO_IRAM
686+
bool
687+
depends on BT_CTRL_RUN_IN_FLASH_ONLY && BT_LE_SLEEP_ENABLE
688+
default y
689+
685690
config BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
686691
bool "Enable enhanced Access Address check in CONNECT_IND"
687692
default n

components/bt/controller/esp32c2/bt.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -592,13 +592,6 @@ static int esp_intr_free_wrapper(void **ret_handle)
592592
return rc;
593593
}
594594

595-
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
596-
void sleep_modem_light_sleep_overhead_set(uint32_t overhead)
597-
{
598-
esp_ble_set_wakeup_overhead(overhead);
599-
}
600-
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
601-
602595
modem_clock_lpclk_src_t esp_bt_get_lpclk_src(void)
603596
{
604597
return s_bt_lpclk_src;
@@ -613,7 +606,7 @@ void esp_bt_set_lpclk_src(modem_clock_lpclk_src_t clk_src)
613606
s_bt_lpclk_src = clk_src;
614607
}
615608

616-
IRAM_ATTR void controller_sleep_cb(uint32_t enable_tick, void *arg)
609+
void controller_sleep_cb(uint32_t enable_tick, void *arg)
617610
{
618611
if (!s_ble_active) {
619612
return;
@@ -626,7 +619,7 @@ IRAM_ATTR void controller_sleep_cb(uint32_t enable_tick, void *arg)
626619
s_ble_active = false;
627620
}
628621

629-
IRAM_ATTR void controller_wakeup_cb(void *arg)
622+
void controller_wakeup_cb(void *arg)
630623
{
631624
if (s_ble_active) {
632625
return;
@@ -666,7 +659,7 @@ esp_err_t controller_sleep_init(modem_clock_lpclk_src_t slow_clk_src)
666659
esp_sleep_enable_bt_wakeup();
667660
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Enable light sleep, the wake up source is BLE timer");
668661

669-
rc = esp_pm_register_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set);
662+
rc = esp_pm_register_inform_out_light_sleep_overhead_callback(esp_ble_set_wakeup_overhead);
670663
if (rc != ESP_OK) {
671664
goto error;
672665
}
@@ -676,7 +669,7 @@ esp_err_t controller_sleep_init(modem_clock_lpclk_src_t slow_clk_src)
676669
error:
677670
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
678671
esp_sleep_disable_bt_wakeup();
679-
esp_pm_unregister_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set);
672+
esp_pm_unregister_inform_out_light_sleep_overhead_callback(esp_ble_set_wakeup_overhead);
680673
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
681674
/*lock should release first and then delete*/
682675
if (s_pm_lock != NULL) {
@@ -693,7 +686,7 @@ void controller_sleep_deinit(void)
693686
r_ble_rtc_wake_up_state_clr();
694687
esp_sleep_disable_bt_wakeup();
695688
esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_AUTO);
696-
esp_pm_unregister_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set);
689+
esp_pm_unregister_inform_out_light_sleep_overhead_callback(esp_ble_set_wakeup_overhead);
697690
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
698691
#ifdef CONFIG_PM_ENABLE
699692
/*lock should release first and then delete*/

components/bt/linker_esp32c2.lf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ entries:
1010
entries:
1111
.conn_iram1+
1212

13+
[sections:bt_sleep_iram_text]
14+
entries:
15+
.sleep_iram1+
16+
1317
[sections:bt_bss]
1418
entries:
1519
.bss+
@@ -39,6 +43,10 @@ entries:
3943
else:
4044
bt_conn_iram_text -> flash_text
4145
bt_isr_iram_text -> flash_text
46+
if BT_LE_PLACE_SLEEP_RELATED_INTO_IRAM = y:
47+
bt_sleep_iram_text -> iram0_bt_text
48+
else:
49+
bt_sleep_iram_text -> flash_text
4250
else:
4351
bt_iram_text -> iram0_bt_text
4452
bt_bss -> dram0_bt_bss
@@ -47,6 +55,7 @@ entries:
4755

4856
bt_conn_iram_text -> iram0_bt_text
4957
bt_isr_iram_text -> iram0_bt_text
58+
bt_sleep_iram_text -> iram0_bt_text
5059

5160
# For the following fragments, order matters for
5261
# 'ALIGN(4) ALIGN(4, post) SURROUND(sym)', which generates:

0 commit comments

Comments
 (0)