From 9fdcd571d1f18a52052dd9820e76fd10be6bf78a Mon Sep 17 00:00:00 2001 From: Zhao Wei Liang Date: Thu, 5 Feb 2026 15:13:40 +0800 Subject: [PATCH] feat(ble): add config for reserved controller memory on ESP32C5 (cherry picked from commit 5307ec1f929cab08ce292d16af4a711b20f30e5d) Co-authored-by: cjin --- components/bt/controller/esp32c5/ble.c | 6 ++++++ components/bt/controller/esp32c5/esp_bt_cfg.h | 14 ++++++++++++++ components/bt/include/esp32c5/include/esp_bt.h | 8 ++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/components/bt/controller/esp32c5/ble.c b/components/bt/controller/esp32c5/ble.c index 50557cd5564..3b8aa469a65 100644 --- a/components/bt/controller/esp32c5/ble.c +++ b/components/bt/controller/esp32c5/ble.c @@ -122,6 +122,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/esp32c5/esp_bt_cfg.h b/components/bt/controller/esp32c5/esp_bt_cfg.h index a309a7fd540..5d547e6ac4c 100644 --- a/components/bt/controller/esp32c5/esp_bt_cfg.h +++ b/components/bt/controller/esp32c5/esp_bt_cfg.h @@ -300,6 +300,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/esp32c5/include/esp_bt.h b/components/bt/include/esp32c5/include/esp_bt.h index c1aa985641c..2f553231175 100644 --- a/components/bt/include/esp32c5/include/esp_bt.h +++ b/components/bt/include/esp32c5/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 */ @@ -159,7 +159,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 /** @@ -238,6 +238,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; /*!< Magic number for configuration validation */ } esp_bt_controller_config_t; @@ -303,6 +305,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, \ }