From 84924e3980ab8acdbb2caa17cd81f1fdd788b601 Mon Sep 17 00:00:00 2001 From: zhaoweiliang Date: Tue, 27 Jan 2026 11:40:15 +0800 Subject: [PATCH] feat(ble): support adv fast tx feature on ESP32-C6 and ESP32-H2 --- components/bt/controller/esp32c6/Kconfig.in | 9 +++++++ components/bt/controller/esp32c6/ble.c | 27 +++++++++++++++++++-- components/bt/controller/esp32h2/Kconfig.in | 9 +++++++ components/bt/controller/esp32h2/ble.c | 27 +++++++++++++++++++-- components/bt/linker_esp_ble_controller.lf | 10 ++++++++ 5 files changed, 78 insertions(+), 4 deletions(-) diff --git a/components/bt/controller/esp32c6/Kconfig.in b/components/bt/controller/esp32c6/Kconfig.in index a2fb88293e..8b430c96a7 100644 --- a/components/bt/controller/esp32c6/Kconfig.in +++ b/components/bt/controller/esp32c6/Kconfig.in @@ -1000,3 +1000,12 @@ config BT_LE_CTRL_DL_ITVL_PHY_SYNC_EN When this option is enabled, the Controller automatically initiates a data length update Using the appropriate data length parameters When a PHY update or a connection interval update occurs. + +config BT_LE_CTRL_ADV_FAST_TX_EN + bool "Reduce adv enable-to-air latency (READ DOCS FIRST) (EXPERIMENTAL)" + default n + help + Reduce the latency between issuing the advertising enable command + and the actual on-air transmission by executing the advertising TX + path from IRAM. + Note: Enabling this option increases IRAM usage. diff --git a/components/bt/controller/esp32c6/ble.c b/components/bt/controller/esp32c6/ble.c index 7b5e76abe8..5052f6516c 100644 --- a/components/bt/controller/esp32c6/ble.c +++ b/components/bt/controller/esp32c6/ble.c @@ -80,6 +80,13 @@ int pawrSync_stack_enable(void); void pawrSync_stack_disable(void); #endif // DEFAULT_BT_LE_PAWR_SUPPORTED +#if CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN +int advFastTx_stack_initEnv(void); +void advFastTx_stack_deinitEnv(void); +int advFastTx_stack_enable(void); +void advFastTx_stack_disable(void); +#endif // CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN + #if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED) void adv_stack_enableClearLegacyAdvVsCmd(bool en); void scan_stack_enableAdvFlowCtrlVsCmd(bool en); @@ -211,12 +218,20 @@ int ble_stack_initEnv(void) return rc; } #endif // DEFAULT_BT_LE_PAWR_SUPPORTED - +#if CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN + rc = advFastTx_stack_initEnv(); + if (rc) { + return rc; + } +#endif // CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN return 0; } void ble_stack_deinitEnv(void) { +#if CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN + advFastTx_stack_deinitEnv(); +#endif // CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN #if DEFAULT_BT_LE_PAWR_SUPPORTED pawrSync_stack_deinitEnv(); pawrBcast_stack_deinitEnv(); @@ -302,7 +317,12 @@ int ble_stack_enable(void) return rc; } #endif // DEFAULT_BT_LE_PAWR_SUPPORTED - +#if CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN + rc = advFastTx_stack_enable(); + if (rc) { + return rc; + } +#endif // CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN #if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED) ble_stack_enableVsCmds(true); ble_stack_enableVsEvents(true); @@ -321,6 +341,9 @@ void ble_stack_disable(void) ble_stack_enableVsEvents(false); ble_stack_enableVsCmds(false); #endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED) +#if CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN + advFastTx_stack_disable(); +#endif // CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN #if DEFAULT_BT_LE_PAWR_SUPPORTED pawrSync_stack_disable(); pawrBcast_stack_disable(); diff --git a/components/bt/controller/esp32h2/Kconfig.in b/components/bt/controller/esp32h2/Kconfig.in index b613c6f27d..8f92508aba 100644 --- a/components/bt/controller/esp32h2/Kconfig.in +++ b/components/bt/controller/esp32h2/Kconfig.in @@ -1004,3 +1004,12 @@ config BT_LE_CTRL_DL_ITVL_PHY_SYNC_EN When this option is enabled, the Controller automatically initiates a data length update Using the appropriate data length parameters When a PHY update or a connection interval update occurs. + +config BT_LE_CTRL_ADV_FAST_TX_EN + bool "Reduce adv enable-to-air latency (READ DOCS FIRST) (EXPERIMENTAL)" + default n + help + Reduce the latency between issuing the advertising enable command + and the actual on-air transmission by executing the advertising TX + path from IRAM. + Note: Enabling this option increases IRAM usage. diff --git a/components/bt/controller/esp32h2/ble.c b/components/bt/controller/esp32h2/ble.c index 411c0a69f9..11d92f6112 100644 --- a/components/bt/controller/esp32h2/ble.c +++ b/components/bt/controller/esp32h2/ble.c @@ -75,6 +75,13 @@ int conn_errorSim_enable(void); void conn_errorSim_disable(void); #endif // CONFIG_BT_LE_ERROR_SIM_ENABLED +#if CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN +int advFastTx_stack_initEnv(void); +void advFastTx_stack_deinitEnv(void); +int advFastTx_stack_enable(void); +void advFastTx_stack_disable(void); +#endif // CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN + #if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED) void adv_stack_enableClearLegacyAdvVsCmd(bool en); void scan_stack_enableAdvFlowCtrlVsCmd(bool en); @@ -198,12 +205,20 @@ int ble_stack_initEnv(void) return rc; } #endif // DEFAULT_BT_LE_PAWR_SUPPORTED - +#if CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN + rc = advFastTx_stack_initEnv(); + if (rc) { + return rc; + } +#endif // CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN return 0; } void ble_stack_deinitEnv(void) { +#if CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN + advFastTx_stack_deinitEnv(); +#endif // CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN #if DEFAULT_BT_LE_PAWR_SUPPORTED pawrSync_stack_deinitEnv(); pawrBcast_stack_deinitEnv(); @@ -289,7 +304,12 @@ int ble_stack_enable(void) return rc; } #endif // DEFAULT_BT_LE_PAWR_SUPPORTED - +#if CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN + rc = advFastTx_stack_enable(); + if (rc) { + return rc; + } +#endif // CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN #if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED) ble_stack_enableVsCmds(true); ble_stack_enableVsEvents(true); @@ -308,6 +328,9 @@ void ble_stack_disable(void) ble_stack_enableVsEvents(false); ble_stack_enableVsCmds(false); #endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED) +#if CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN + advFastTx_stack_disable(); +#endif // CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN #if DEFAULT_BT_LE_PAWR_SUPPORTED pawrSync_stack_disable(); pawrBcast_stack_disable(); diff --git a/components/bt/linker_esp_ble_controller.lf b/components/bt/linker_esp_ble_controller.lf index 0af407f8eb..b9b9b124b9 100644 --- a/components/bt/linker_esp_ble_controller.lf +++ b/components/bt/linker_esp_ble_controller.lf @@ -6,17 +6,27 @@ entries: entries: .high_perf_code_iram1+ +[sections:adv_fast_execute_code_iram_text] +entries: + .adv_fast_execute_code_iram1+ + [scheme:bt_default] entries: bt_bss -> dram0_bss bt_common -> dram0_bss data -> dram0_data high_perf_iram_text -> iram0_text + if BT_CTRL_RUN_IN_FLASH_ONLY = y: bt_iram_text -> flash_text else: bt_iram_text -> iram0_text + if BT_LE_CTRL_ADV_FAST_TX_EN = y: + adv_fast_execute_code_iram_text -> iram0_text + else: + adv_fast_execute_code_iram_text -> flash_text + # For the following fragments, order matters for # 'ALIGN(4) ALIGN(4, post) SURROUND(sym)', which generates: #