From 89cd09ec260b1ffbd927e5da4c8203eeeb5dcd27 Mon Sep 17 00:00:00 2001 From: Zhao Wei Liang Date: Thu, 5 Feb 2026 15:13:37 +0800 Subject: [PATCH] feat(ble): add config for reserved controller memory on ESP32C6 and ESP32H2 (cherry picked from commit 4418d5da82df6fb4c726605265c8618baeca577b) Co-authored-by: cjin --- components/bt/controller/esp32c6/esp_bt_cfg.h | 14 ++++++++++++++ components/bt/controller/esp32h2/ble.c | 6 ++++++ components/bt/controller/esp32h2/esp_bt_cfg.h | 14 ++++++++++++++ components/bt/include/esp32c6/include/esp_bt.h | 14 ++++++++++---- components/bt/include/esp32h2/include/esp_bt.h | 8 ++++++-- 5 files changed, 50 insertions(+), 6 deletions(-) diff --git a/components/bt/controller/esp32c6/esp_bt_cfg.h b/components/bt/controller/esp32c6/esp_bt_cfg.h index 27371322ef5..2d6defed3de 100644 --- a/components/bt/controller/esp32c6/esp_bt_cfg.h +++ b/components/bt/controller/esp32c6/esp_bt_cfg.h @@ -295,6 +295,20 @@ extern "C" { #define DEFAULT_BT_LE_HCI_UART_PARITY (0) #endif +#ifdef CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN +#define DEFAULT_BT_LE_CTRL_ENH_MEM_RESV_ADV (1<<0) +#else +#define DEFAULT_BT_LE_CTRL_ENH_MEM_RESV_ADV (0) +#endif + +#define DEFAULT_BT_LE_CTRL_ENH_MEM_RESV_FLAGS DEFAULT_BT_LE_CTRL_ENH_MEM_RESV_ADV + +#ifdef CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN +#define DEFAULT_BT_LE_CTRL_RXBUF_MEM_RESV CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN +#else +#define DEFAULT_BT_LE_CTRL_RXBUF_MEM_RESV (0) +#endif + /* Unchanged configuration */ #define BLE_LL_CTRL_PROC_TIMEOUT_MS_N (40000) /* ms */ diff --git a/components/bt/controller/esp32h2/ble.c b/components/bt/controller/esp32h2/ble.c index 11d92f61121..bb1a0cdb9ad 100644 --- a/components/bt/controller/esp32h2/ble.c +++ b/components/bt/controller/esp32h2/ble.c @@ -120,6 +120,12 @@ void ble_stack_enableVsCmds(bool en) log_stack_enableLogsRelatedVsCmd(en); hci_stack_enableSetVsEvtMaskVsCmd(en); winWiden_stack_enableSetConstPeerScaVsCmd(en); +#if DEFAULT_BT_SCAN_ALLOW_ENH_ADI_FILTER + scan_stack_enableSetScanADIOnlyFilterVsCmd(en); +#endif // DEFAULT_BT_SCAN_ALLOW_ENH_ADI_FILTER +#if DEFAULT_BT_ADV_SEND_CONSTANT_DID + extAdv_stack_setExtAdvConstantDidVsCmd(en); +#endif // DEFAULT_BT_ADV_SEND_CONSTANT_DID } void ble_stack_enableVsEvents(bool en) diff --git a/components/bt/controller/esp32h2/esp_bt_cfg.h b/components/bt/controller/esp32h2/esp_bt_cfg.h index 401c36bc905..15d593dcd48 100644 --- a/components/bt/controller/esp32h2/esp_bt_cfg.h +++ b/components/bt/controller/esp32h2/esp_bt_cfg.h @@ -292,6 +292,20 @@ extern "C" { #define DEFAULT_BT_LE_HCI_UART_PARITY (0) #endif +#ifdef CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN +#define DEFAULT_BT_LE_CTRL_ENH_MEM_RESV_ADV (1<<0) +#else +#define DEFAULT_BT_LE_CTRL_ENH_MEM_RESV_ADV (0) +#endif + +#define DEFAULT_BT_LE_CTRL_ENH_MEM_RESV_FLAGS DEFAULT_BT_LE_CTRL_ENH_MEM_RESV_ADV + +#ifdef CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN +#define DEFAULT_BT_LE_CTRL_RXBUF_MEM_RESV CONFIG_BT_LE_CTRL_ADV_FAST_TX_EN +#else +#define DEFAULT_BT_LE_CTRL_RXBUF_MEM_RESV (0) +#endif + /* Unchanged configuration */ #define BLE_LL_CTRL_PROC_TIMEOUT_MS_N (40000) /* ms */ diff --git a/components/bt/include/esp32c6/include/esp_bt.h b/components/bt/include/esp32c6/include/esp_bt.h index 666c0e3b92c..40261bf4933 100644 --- a/components/bt/include/esp32c6/include/esp_bt.h +++ b/components/bt/include/esp32c6/include/esp_bt.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -156,7 +156,7 @@ esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type */ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle); -#define CONFIG_VERSION 0x20251211 +#define CONFIG_VERSION 0x20260123 #define CONFIG_MAGIC 0x5A5AA5A5 /** @@ -236,8 +236,10 @@ typedef struct { uint8_t conn_rsv_cnt; /*!< BLE conn state machine reserve count number */ uint8_t priority_level_cfg; /*!< The option for priority level configuration */ uint8_t slv_fst_rx_lat_en; /*!< The option for enabling slave fast PDU reception during latency. */ - uint8_t dl_itvl_phy_sync_en; /*!< The option for automatically initiate the data length update when phy update or connect interval update. */ - uint8_t scan_allow_adi_filter; /*!< The option for ext scan to allow PDU with specific adi. */ + uint8_t dl_itvl_phy_sync_en; /*!< The option for automatically initiate the data length update when phy update or connect interval update. */ + uint8_t scan_allow_adi_filter; /*!< The option for ext scan to allow PDU with specific adi. */ + uint8_t enhanced_mem_resv; /*!< The option masks the BLE events with all reserved memory. */ + uint8_t rxbuf_reserved; /*!< The option reserve all Rxbuffer memory at initialization. */ uint32_t config_magic; /*!< Magic number for configuration validation */ } esp_bt_controller_config_t; @@ -306,6 +308,8 @@ typedef struct { .slv_fst_rx_lat_en = DEFAULT_BT_LE_CTRL_SLV_FAST_RX_CONN_DATA_EN, \ .dl_itvl_phy_sync_en = DEFAULT_BT_LE_CTRL_DL_ITVL_PHY_SYNC_EN, \ .scan_allow_adi_filter = DEFAULT_BT_SCAN_ALLOW_ENH_ADI_FILTER, \ + .enhanced_mem_resv = DEFAULT_BT_LE_CTRL_ENH_MEM_RESV_ADV, \ + .rxbuf_reserved = DEFAULT_BT_LE_CTRL_RXBUF_MEM_RESV, \ .config_magic = CONFIG_MAGIC, \ } #elif CONFIG_IDF_TARGET_ESP32C61 @@ -370,6 +374,8 @@ typedef struct { .priority_level_cfg = BT_LL_CTRL_PRIO_LVL_CFG, \ .slv_fst_rx_lat_en = DEFAULT_BT_LE_CTRL_SLV_FAST_RX_CONN_DATA_EN, \ .dl_itvl_phy_sync_en = DEFAULT_BT_LE_CTRL_DL_ITVL_PHY_SYNC_EN, \ + .enhanced_mem_resv = DEFAULT_BT_LE_CTRL_ENH_MEM_RESV_ADV, \ + .rxbuf_reserved = DEFAULT_BT_LE_CTRL_RXBUF_MEM_RESV, \ .config_magic = CONFIG_MAGIC, \ } #endif diff --git a/components/bt/include/esp32h2/include/esp_bt.h b/components/bt/include/esp32h2/include/esp_bt.h index 374ca4e7ad6..9688e63e44c 100644 --- a/components/bt/include/esp32h2/include/esp_bt.h +++ b/components/bt/include/esp32h2/include/esp_bt.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -161,7 +161,7 @@ esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type */ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle); -#define CONFIG_VERSION 0x20251211 +#define CONFIG_VERSION 0x20260123 #define CONFIG_MAGIC 0x5A5AA5A5 /** @@ -240,6 +240,8 @@ typedef struct { uint8_t slv_fst_rx_lat_en; /*!< The option for enabling slave fast PDU reception during latency. */ uint8_t dl_itvl_phy_sync_en; /*!< The option for automatically initiate the data length update when phy update or connect interval update. */ uint8_t scan_allow_adi_filter; /*!< The option for ext scan to allow PDU with specific adi. */ + uint8_t enhanced_mem_resv; /*!< The option masks the BLE events with all reserved memory. */ + uint8_t rxbuf_reserved; /*!< The option reserve all Rxbuffer memory at initialization. */ uint32_t config_magic; /*!< Configuration magic value */ } esp_bt_controller_config_t; @@ -306,6 +308,8 @@ typedef struct { .slv_fst_rx_lat_en = DEFAULT_BT_LE_CTRL_SLV_FAST_RX_CONN_DATA_EN, \ .dl_itvl_phy_sync_en = DEFAULT_BT_LE_CTRL_DL_ITVL_PHY_SYNC_EN, \ .scan_allow_adi_filter = DEFAULT_BT_SCAN_ALLOW_ENH_ADI_FILTER, \ + .enhanced_mem_resv = DEFAULT_BT_LE_CTRL_ENH_MEM_RESV_ADV, \ + .rxbuf_reserved = DEFAULT_BT_LE_CTRL_RXBUF_MEM_RESV, \ .config_magic = CONFIG_MAGIC, \ }