Merge branch 'change/ble_update_lib_20250414_v5.3' into 'release/v5.3'

change(ble): [AUTO_MR] 20250414 - Update ESP BLE Controller Lib (v5.3)

See merge request espressif/esp-idf!38493
This commit is contained in:
Island
2025-04-18 11:07:12 +08:00
13 changed files with 67 additions and 25 deletions

View File

@ -9,7 +9,6 @@ config BT_ALARM_MAX_NUM
config BT_BLE_LOG_SPI_OUT_ENABLED
bool "Output ble logs to SPI bus (Experimental)"
default n
select SPI_MASTER_IN_IRAM
help
Output ble logs to SPI bus

View File

@ -140,14 +140,16 @@ static int spi_out_init_trans(spi_out_trans_cb_t **trans_cb, uint16_t buf_size)
if (!(*trans_cb)) {
return -1;
}
memset(*trans_cb, 0, sizeof(spi_out_trans_cb_t));
uint8_t *buf = (uint8_t *)heap_caps_malloc((size_t)buf_size, MALLOC_CAP_DMA);
if (!buf) {
free(*trans_cb);
*trans_cb = NULL;
return -1;
}
// Initialization
memset(*trans_cb, 0, sizeof(spi_out_trans_cb_t));
(*trans_cb)->buf_size = buf_size;
(*trans_cb)->trans.tx_buffer = buf;
return 0;
@ -158,8 +160,13 @@ static void spi_out_deinit_trans(spi_out_trans_cb_t **trans_cb)
if (!(*trans_cb)) {
return;
}
if ((*trans_cb)->trans.tx_buffer) {
// Do not free buffer until recycled
while ((*trans_cb)->flag == SPI_OUT_TRANS_CB_FLAG_IN_QUEUE) {}
free((uint8_t *)(*trans_cb)->trans.tx_buffer);
(*trans_cb)->trans.tx_buffer = NULL;
}
free((uint8_t *)(*trans_cb)->trans.tx_buffer);
free(*trans_cb);
*trans_cb = NULL;
return;
@ -174,7 +181,7 @@ IRAM_ATTR static void spi_out_tx_done_cb(spi_transaction_t *ret_trans)
IRAM_ATTR static inline int spi_out_append_trans(spi_out_trans_cb_t *trans_cb)
{
if (trans_cb->flag != SPI_OUT_TRANS_CB_FLAG_NEED_QUEUE) {
if (trans_cb->flag != SPI_OUT_TRANS_CB_FLAG_NEED_QUEUE || !trans_cb->length) {
return -1;
}
@ -185,6 +192,8 @@ IRAM_ATTR static inline int spi_out_append_trans(spi_out_trans_cb_t *trans_cb)
trans_cb->flag = SPI_OUT_TRANS_CB_FLAG_IN_QUEUE;
return 0;
} else {
trans_cb->length = 0;
trans_cb->flag = SPI_OUT_TRANS_CB_FLAG_AVAILABLE;
return -1;
}
}
@ -224,6 +233,7 @@ static void spi_out_log_cb_deinit(spi_out_log_cb_t **log_cb)
}
}
free(*log_cb);
*log_cb = NULL;
return;
}
@ -578,7 +588,7 @@ static void spi_out_ts_sync_deinit(void)
}
// CRITICAL: This function is called in ESP Timer task
IRAM_ATTR static void esp_timer_cb_ts_sync(void)
static void esp_timer_cb_ts_sync(void)
{
// Initialize variables
uint32_t lc_ts = 0;
@ -627,7 +637,9 @@ int ble_log_spi_out_init(void)
.quadwp_io_num = -1,
.quadhd_io_num = -1,
.max_transfer_sz = SPI_OUT_MAX_TRANSFER_SIZE,
#if CONFIG_SPI_MASTER_ISR_IN_IRAM
.intr_flags = ESP_INTR_FLAG_IRAM
#endif // CONFIG_SPI_MASTER_ISR_IN_IRAM
};
spi_device_interface_config_t dev_config = {
.clock_speed_hz = SPI_MASTER_FREQ_20M,
@ -782,7 +794,7 @@ IRAM_ATTR void ble_log_spi_out_ll_log_ev_proc(void)
}
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_LL_ENABLED
IRAM_ATTR int ble_log_spi_out_write(uint8_t source, const uint8_t *addr, uint16_t len)
int ble_log_spi_out_write(uint8_t source, const uint8_t *addr, uint16_t len)
{
if (!ul_log_inited) {
return -1;
@ -798,7 +810,7 @@ IRAM_ATTR int ble_log_spi_out_write(uint8_t source, const uint8_t *addr, uint16_
return ret;
}
IRAM_ATTR int ble_log_spi_out_printf(uint8_t source, const char *format, ...)
int ble_log_spi_out_printf(uint8_t source, const char *format, ...)
{
if (!ul_log_inited) {
return -1;
@ -845,7 +857,7 @@ IRAM_ATTR int ble_log_spi_out_printf(uint8_t source, const char *format, ...)
return ret;
}
IRAM_ATTR int ble_log_spi_out_printf_enh(uint8_t source, uint8_t level, const char *tag, const char *format, ...)
int ble_log_spi_out_printf_enh(uint8_t source, uint8_t level, const char *tag, const char *format, ...)
{
if (!ul_log_inited) {
return -1;
@ -897,7 +909,7 @@ IRAM_ATTR int ble_log_spi_out_printf_enh(uint8_t source, uint8_t level, const ch
return ret;
}
IRAM_ATTR int ble_log_spi_out_write_with_ts(uint8_t source, const uint8_t *addr, uint16_t len)
int ble_log_spi_out_write_with_ts(uint8_t source, const uint8_t *addr, uint16_t len)
{
if (!ul_log_inited) {
return -1;

View File

@ -682,6 +682,11 @@ config BT_LE_PLACE_CONN_RELATED_INTO_IRAM
depends on BT_CTRL_RUN_IN_FLASH_ONLY
default n
config BT_LE_PLACE_SLEEP_RELATED_INTO_IRAM
bool
depends on BT_CTRL_RUN_IN_FLASH_ONLY && BT_LE_SLEEP_ENABLE
default y
config BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
bool "Enable enhanced Access Address check in CONNECT_IND"
default n

View File

@ -592,13 +592,6 @@ static int esp_intr_free_wrapper(void **ret_handle)
return rc;
}
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
void sleep_modem_light_sleep_overhead_set(uint32_t overhead)
{
esp_ble_set_wakeup_overhead(overhead);
}
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
modem_clock_lpclk_src_t esp_bt_get_lpclk_src(void)
{
return s_bt_lpclk_src;
@ -613,7 +606,7 @@ void esp_bt_set_lpclk_src(modem_clock_lpclk_src_t clk_src)
s_bt_lpclk_src = clk_src;
}
IRAM_ATTR void controller_sleep_cb(uint32_t enable_tick, void *arg)
void controller_sleep_cb(uint32_t enable_tick, void *arg)
{
if (!s_ble_active) {
return;
@ -626,7 +619,7 @@ IRAM_ATTR void controller_sleep_cb(uint32_t enable_tick, void *arg)
s_ble_active = false;
}
IRAM_ATTR void controller_wakeup_cb(void *arg)
void controller_wakeup_cb(void *arg)
{
if (s_ble_active) {
return;
@ -666,7 +659,7 @@ esp_err_t controller_sleep_init(modem_clock_lpclk_src_t slow_clk_src)
esp_sleep_enable_bt_wakeup();
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Enable light sleep, the wake up source is BLE timer");
rc = esp_pm_register_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set);
rc = esp_pm_register_inform_out_light_sleep_overhead_callback(esp_ble_set_wakeup_overhead);
if (rc != ESP_OK) {
goto error;
}
@ -676,7 +669,7 @@ esp_err_t controller_sleep_init(modem_clock_lpclk_src_t slow_clk_src)
error:
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
esp_sleep_disable_bt_wakeup();
esp_pm_unregister_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set);
esp_pm_unregister_inform_out_light_sleep_overhead_callback(esp_ble_set_wakeup_overhead);
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
/*lock should release first and then delete*/
if (s_pm_lock != NULL) {
@ -693,7 +686,7 @@ void controller_sleep_deinit(void)
r_ble_rtc_wake_up_state_clr();
esp_sleep_disable_bt_wakeup();
esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_AUTO);
esp_pm_unregister_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set);
esp_pm_unregister_inform_out_light_sleep_overhead_callback(esp_ble_set_wakeup_overhead);
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
#ifdef CONFIG_PM_ENABLE
/*lock should release first and then delete*/

View File

@ -818,3 +818,7 @@ config BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX
When this option is enabled, auxiliary packets will be present in the events of
'Non-Connectable and Non-Scannable' regardless of whether the advertising length is 0.
If this option is not enabled, auxiliary packets will only be present when the advertising length is not 0.
config BT_LE_RXBUF_OPT_ENABLED
bool "Enable rxbuf optimization feature"
default y

View File

@ -47,6 +47,9 @@ void adv_stack_enableScanReqRxdVsEvent(bool en);
void conn_stack_enableChanMapUpdCompVsEvent(bool en);
void sleep_stack_enableWakeupVsEvent(bool en);
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
#if CONFIG_BT_LE_RXBUF_OPT_ENABLED
extern void mmgmt_enableRxbufOptFeature(void);
#endif // CONFIG_BT_LE_RXBUF_OPT_ENABLED
/* Local functions definition
***************************************************************************
@ -143,6 +146,10 @@ int ble_stack_enable(void)
ble_stack_enableVsEvents(true);
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
#if CONFIG_BT_LE_RXBUF_OPT_ENABLED
mmgmt_enableRxbufOptFeature();
#endif // CONFIG_BT_LE_RXBUF_OPT_ENABLED
return 0;
}

View File

@ -822,3 +822,7 @@ config BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX
When this option is enabled, auxiliary packets will be present in the events of
'Non-Connectable and Non-Scannable' regardless of whether the advertising length is 0.
If this option is not enabled, auxiliary packets will only be present when the advertising length is not 0.
config BT_LE_RXBUF_OPT_ENABLED
bool "Enable rxbuf optimization feature"
default y

View File

@ -44,6 +44,9 @@ void adv_stack_enableScanReqRxdVsEvent(bool en);
void conn_stack_enableChanMapUpdCompVsEvent(bool en);
void sleep_stack_enableWakeupVsEvent(bool en);
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
#if CONFIG_BT_LE_RXBUF_OPT_ENABLED
extern void mmgmt_enableRxbufOptFeature(void);
#endif // CONFIG_BT_LE_RXBUF_OPT_ENABLED
/* Local functions definition
***************************************************************************
@ -137,6 +140,10 @@ int ble_stack_enable(void)
ble_stack_enableVsEvents(true);
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
#if CONFIG_BT_LE_RXBUF_OPT_ENABLED
mmgmt_enableRxbufOptFeature();
#endif // CONFIG_BT_LE_RXBUF_OPT_ENABLED
return 0;
}

View File

@ -10,6 +10,10 @@ entries:
entries:
.conn_iram1+
[sections:bt_sleep_iram_text]
entries:
.sleep_iram1+
[sections:bt_bss]
entries:
.bss+
@ -39,6 +43,10 @@ entries:
else:
bt_conn_iram_text -> flash_text
bt_isr_iram_text -> flash_text
if BT_LE_PLACE_SLEEP_RELATED_INTO_IRAM = y:
bt_sleep_iram_text -> iram0_bt_text
else:
bt_sleep_iram_text -> flash_text
else:
bt_iram_text -> iram0_bt_text
bt_bss -> dram0_bt_bss
@ -47,6 +55,7 @@ entries:
bt_conn_iram_text -> iram0_bt_text
bt_isr_iram_text -> iram0_bt_text
bt_sleep_iram_text -> iram0_bt_text
# For the following fragments, order matters for
# 'ALIGN(4) ALIGN(4, post) SURROUND(sym)', which generates:

View File

@ -110,7 +110,9 @@ IRAM_ATTR npl_freertos_event_init(struct ble_npl_event *ev, ble_npl_event_fn *fn
void
IRAM_ATTR npl_freertos_event_deinit(struct ble_npl_event *ev)
{
BLE_LL_ASSERT(ev->event);
if (!ev->event) {
return;
}
#if OS_MEM_ALLOC
os_memblock_put(&ble_freertos_ev_pool,ev->event);
#else