Skip to content

Commit cd6038b

Browse files
fix(ble): fixed occasional assert issue in scan and connection scenarios on ESP32-C6
1 parent 3cfd4d0 commit cd6038b

File tree

4 files changed

+59
-6
lines changed

4 files changed

+59
-6
lines changed

components/bt/controller/esp32c6/Kconfig.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,3 +839,10 @@ config BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX
839839
config BT_LE_RXBUF_OPT_ENABLED
840840
bool "Enable rxbuf optimization feature"
841841
default y
842+
843+
config BT_LE_CTRL_FAST_CONN_DATA_TX_EN
844+
bool "Enable fast sending of connection data"
845+
default y
846+
help
847+
If this option is enabled, The Controller will continue to
848+
Send an empty PDU after sending valid connection data within an interval.

components/bt/controller/esp32c6/bt.c

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858

5959
#include "hal/efuse_hal.h"
6060
#include "soc/rtc.h"
61+
#include "modem/modem_syscon_struct.h"
6162

6263
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
6364
#include "ble_log/ble_log_spi_out.h"
@@ -70,7 +71,7 @@
7071
#define OSI_COEX_VERSION 0x00010006
7172
#define OSI_COEX_MAGIC_VALUE 0xFADEBEAD
7273

73-
#define EXT_FUNC_VERSION 0x20240422
74+
#define EXT_FUNC_VERSION 0x20250415
7475
#define EXT_FUNC_MAGIC_VALUE 0xA5A5A5A5
7576

7677
#define BT_ASSERT_PRINT ets_printf
@@ -101,7 +102,9 @@ struct ext_funcs_t {
101102
int (* _ecc_gen_key_pair)(uint8_t *public, uint8_t *priv);
102103
int (* _ecc_gen_dh_key)(const uint8_t *remote_pub_key_x, const uint8_t *remote_pub_key_y,
103104
const uint8_t *local_priv_key, uint8_t *dhkey);
104-
void (* _esp_reset_rpa_moudle)(void);
105+
#if CONFIG_IDF_TARGET_ESP32C6
106+
void (* _esp_reset_modem)(uint8_t mdl_opts, uint8_t start);
107+
#endif // CONFIG_IDF_TARGET_ESP32C6
105108
uint32_t magic;
106109
};
107110

@@ -112,6 +115,11 @@ typedef void (*interface_func_t) (uint32_t len, const uint8_t *addr, uint32_t le
112115
/* External functions or variables
113116
************************************************************************
114117
*/
118+
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
119+
extern void coex_hw_timer_set(uint8_t idx,uint8_t src, uint8_t pti,uint32_t latency, uint32_t perioidc);
120+
extern void coex_hw_timer_enable(uint8_t idx);
121+
extern void coex_hw_timer_disable(uint8_t idx);
122+
#endif // CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
115123
extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs);
116124
extern int r_ble_controller_init(esp_bt_controller_config_t *cfg);
117125
extern void esp_ble_controller_info_capture(uint32_t cycle_times);
@@ -185,7 +193,9 @@ static int esp_intr_alloc_wrapper(int source, int flags, intr_handler_t handler,
185193
static int esp_intr_free_wrapper(void **ret_handle);
186194
static void osi_assert_wrapper(const uint32_t ln, const char *fn, uint32_t param1, uint32_t param2);
187195
static uint32_t osi_random_wrapper(void);
188-
static void esp_reset_rpa_moudle(void);
196+
#if CONFIG_IDF_TARGET_ESP32C6
197+
static void esp_reset_modem(uint8_t mdl_opts,uint8_t start);
198+
#endif // CONFIG_IDF_TARGET_ESP32C6
189199
static int esp_ecc_gen_key_pair(uint8_t *pub, uint8_t *priv);
190200
static int esp_ecc_gen_dh_key(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_key_y,
191201
const uint8_t *our_priv_key, uint8_t *out_dhkey);
@@ -463,15 +473,34 @@ struct ext_funcs_t ext_funcs_ro = {
463473
._os_random = osi_random_wrapper,
464474
._ecc_gen_key_pair = esp_ecc_gen_key_pair,
465475
._ecc_gen_dh_key = esp_ecc_gen_dh_key,
466-
._esp_reset_rpa_moudle = esp_reset_rpa_moudle,
476+
#if CONFIG_IDF_TARGET_ESP32C6
477+
._esp_reset_modem = esp_reset_modem,
478+
#endif // CONFIG_IDF_TARGET_ESP32C6
467479
.magic = EXT_FUNC_MAGIC_VALUE,
468480
};
469481

470-
static void IRAM_ATTR esp_reset_rpa_moudle(void)
482+
#if CONFIG_IDF_TARGET_ESP32C6
483+
static void IRAM_ATTR esp_reset_modem(uint8_t mdl_opts,uint8_t start)
471484
{
485+
if (mdl_opts == 0x05) {
486+
if (start) {
487+
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
488+
coex_hw_timer_set(0x04, 0x02, 15, 0, 5000);
489+
coex_hw_timer_enable(0x04);
490+
#endif // CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
491+
MODEM_SYSCON.modem_rst_conf.val |= (BIT(16) | BIT(18));
492+
MODEM_SYSCON.modem_rst_conf.val &= ~(BIT(16) | BIT(18));
493+
} else {
494+
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
495+
coex_hw_timer_disable(0x04);
496+
#endif // CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
497+
}
472498

499+
}
473500
}
474501

502+
#endif // CONFIG_IDF_TARGET_ESP32C6
503+
475504
static void IRAM_ATTR osi_assert_wrapper(const uint32_t ln, const char *fn,
476505
uint32_t param1, uint32_t param2)
477506
{

components/bt/controller/esp32c6/esp_bt_cfg.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ extern "C" {
195195
#define DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX (0)
196196
#endif
197197

198+
#if defined(CONFIG_BT_LE_CTRL_FAST_CONN_DATA_TX_EN)
199+
#define DEFAULT_BT_LE_CTRL_FAST_CONN_DATA_TX_EN (CONFIG_BT_LE_CTRL_FAST_CONN_DATA_TX_EN)
200+
#else
201+
#define DEFAULT_BT_LE_CTRL_FAST_CONN_DATA_TX_EN (0)
202+
#endif
203+
198204
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART
199205
#define HCI_UART_EN CONFIG_BT_LE_HCI_INTERFACE_USE_UART
200206
#else

components/bt/include/esp32c6/include/esp_bt.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type
156156
*/
157157
esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
158158

159-
#define CONFIG_VERSION 0x20250310
159+
#define CONFIG_VERSION 0x20250513
160160
#define CONFIG_MAGIC 0x5A5AA5A5
161161

162162
/**
@@ -226,6 +226,11 @@ typedef struct {
226226
- 1 - Enable */
227227
uint8_t vhci_enabled; /*!< VHCI mode is enabled */
228228
uint8_t ptr_check_enabled; /*!< Enable boundary check for internal memory. */
229+
uint8_t ble_adv_tx_options; /*!< The options for Extended advertising sending. */
230+
uint8_t skip_unnecessary_checks_en; /*!< The option to skip non-fatal state checks and perform extra handling for fatal checks. */
231+
uint8_t fast_conn_data_tx_en; /*!< The option for fast transmission of connection data
232+
- 0 - Disable
233+
- 1 - Enable (default) */
229234
uint32_t config_magic; /*!< Magic number for configuration validation */
230235
} esp_bt_controller_config_t;
231236

@@ -284,6 +289,9 @@ typedef struct {
284289
.ble_data_lenth_zero_aux = DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX, \
285290
.vhci_enabled = DEFAULT_BT_LE_VHCI_ENABLED, \
286291
.ptr_check_enabled = DEFAULT_BT_LE_PTR_CHECK_ENABLED, \
292+
.ble_adv_tx_options = 0, \
293+
.skip_unnecessary_checks_en = 0, \
294+
.fast_conn_data_tx_en = DEFAULT_BT_LE_CTRL_FAST_CONN_DATA_TX_EN, \
287295
.config_magic = CONFIG_MAGIC, \
288296
}
289297
#elif CONFIG_IDF_TARGET_ESP32C61
@@ -339,6 +347,9 @@ typedef struct {
339347
.ble_data_lenth_zero_aux = DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX, \
340348
.vhci_enabled = DEFAULT_BT_LE_VHCI_ENABLED, \
341349
.ptr_check_enabled = DEFAULT_BT_LE_PTR_CHECK_ENABLED, \
350+
.ble_adv_tx_options = 0, \
351+
.skip_unnecessary_checks_en = 0, \
352+
.fast_conn_data_tx_en = DEFAULT_BT_LE_CTRL_FAST_CONN_DATA_TX_EN, \
342353
.config_magic = CONFIG_MAGIC, \
343354
}
344355
#endif

0 commit comments

Comments
 (0)