Merge branch 'bugfix/fix_some_ble_bugs_cjh_v4.4' into 'release/v4.4'

Fixed some BT and BLE bugs 2404 (backport v4.4)

See merge request espressif/esp-idf!30261
release/v4.4
Jiang Jiang Jian 2024-04-22 10:43:57 +08:00
commit a4eb486982
11 zmienionych plików z 166 dodań i 30 usunięć

Wyświetl plik

@ -172,7 +172,7 @@ config BTDM_CTRL_PINNED_TO_CORE
choice BTDM_CTRL_HCI_MODE_CHOICE
prompt "HCI mode"
help
Speicify HCI mode as VHCI or UART(H4)
Specify HCI mode as VHCI or UART(H4)
config BTDM_CTRL_HCI_MODE_VHCI
bool "VHCI"
@ -398,6 +398,14 @@ config BTDM_CTRL_FULL_SCAN_SUPPORTED
The full scan function is mainly used to provide BLE scan performance.
This is required for scenes with high scan performance requirements, such as BLE Mesh scenes.
config BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
bool "Disable active scan backoff"
default n
help
Disable active scan backoff. The bluetooth spec requires that scanners should run a backoff procedure to
minimize collision of scan request PDUs from nultiple scanners. If scan backoff is disabled, in active
scanning, scan request PDU will be sent every time when HW receives scannable ADV PDU.
config BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP
bool "BLE adv report flow control supported"
depends on (BTDM_CTRL_MODE_BTDM || BTDM_CTRL_MODE_BLE_ONLY)

Wyświetl plik

@ -23,7 +23,7 @@ config BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB
default 0
help
BLE ACL buffer have two methods to be allocated. One is persistent allocating
(alloate when controller initialise, never free until controller de-initialise)
(allocate when controller initialise, never free until controller de-initialise)
another is dynamically allocating (allocate before TX and free after TX).
choice BT_CTRL_PINNED_TO_CORE_CHOICE
@ -72,11 +72,11 @@ config BT_CTRL_HCI_TL
HCI mode as VHCI or UART(H4)
config BT_CTRL_ADV_DUP_FILT_MAX
int "The maxinum number of 5.0 extend duplicate scan filter"
int "The maximum number of 5.0 extend duplicate scan filter"
range 1 500
default 30
help
The maxinum number of suplicate scan filter
The maximum number of suplicate scan filter
choice BT_BLE_CCA_MODE
prompt "BLE CCA mode"
@ -475,3 +475,17 @@ config BT_BLE_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_CTRL_CHAN_ASS_EN
bool "Enable channel assessment"
default y
help
If this option is enabled, The Controller will records the communication quality
for each channel and then start a timer to check and update the channel map every 4 seconds.
config BT_CTRL_LE_PING_EN
bool "Enable LE Ping procedure"
default y
help
If this option is disabled, The Controller will not start the LE authenticated payload timer.
This option is used for some compatibility problems related to LE ping procedure.

Wyświetl plik

@ -64,6 +64,7 @@
// wakeup request sources
enum {
BTDM_ASYNC_WAKEUP_SRC_VHCI = 0,
BTDM_ASYNC_WAKEUP_REQ_COEX,
BTDM_ASYNC_WAKEUP_SRC_DISA,
BTDM_ASYNC_WAKEUP_SRC_TMR,
BTDM_ASYNC_WAKEUP_SRC_MAX,
@ -110,7 +111,7 @@ do{\
} while(0)
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
#define OSI_VERSION 0x00010007
#define OSI_VERSION 0x00010008
#define OSI_MAGIC_VALUE 0xFADEBEAD
/* Types definition
@ -185,8 +186,12 @@ struct osi_funcs_t {
void (* _btdm_sleep_exit_phase3)(void); /* called from task */
void (* _coex_wifi_sleep_set)(bool sleep);
int (* _coex_core_ble_conn_dyn_prio_get)(bool *low, bool *high);
int (* _coex_schm_register_btdm_callback)(void *callback);
void (* _coex_schm_status_bit_set)(uint32_t type, uint32_t status);
void (* _coex_schm_status_bit_clear)(uint32_t type, uint32_t status);
uint32_t (* _coex_schm_interval_get)(void);
uint8_t (* _coex_schm_curr_period_get)(void);
void *(* _coex_schm_curr_phase_get)(void);
void (* _interrupt_on)(int intr_num);
void (* _interrupt_off)(int intr_num);
void (* _esp_hw_power_down)(void);
@ -194,6 +199,8 @@ struct osi_funcs_t {
void (* _ets_backup_dma_copy)(uint32_t reg, uint32_t mem_addr, uint32_t num, bool to_rem);
void (* _ets_delay_us)(uint32_t us);
void (* _btdm_rom_table_ready)(void);
bool (* _coex_bt_wakeup_request)(void);
void (* _coex_bt_wakeup_request_end)(void);
};
@ -241,6 +248,7 @@ extern int ble_txpwr_get(int power_type);
extern uint16_t l2c_ble_link_get_tx_buf_num(void);
extern int coex_core_ble_conn_dyn_prio_get(bool *low, bool *high);
extern void coex_pti_v2(void);
extern int coex_schm_register_btdm_callback(void *callback);
extern bool btdm_deep_sleep_mem_init(void);
extern void btdm_deep_sleep_mem_deinit(void);
@ -307,14 +315,20 @@ static void btdm_sleep_enter_phase1_wrapper(uint32_t lpcycles);
static void btdm_sleep_enter_phase2_wrapper(void);
static void btdm_sleep_exit_phase3_wrapper(void);
static void coex_wifi_sleep_set_hook(bool sleep);
static int coex_schm_register_btdm_callback_wrapper(void *callback);
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status);
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status);
static uint32_t coex_schm_interval_get_wrapper(void);
static uint8_t coex_schm_curr_period_get_wrapper(void);
static void * coex_schm_curr_phase_get_wrapper(void);
static void interrupt_on_wrapper(int intr_num);
static void interrupt_off_wrapper(int intr_num);
static void btdm_hw_mac_power_up_wrapper(void);
static void btdm_hw_mac_power_down_wrapper(void);
static void btdm_backup_dma_copy_wrapper(uint32_t reg, uint32_t mem_addr, uint32_t num, bool to_mem);
static void btdm_funcs_table_ready_wrapper(void);
static bool coex_bt_wakeup_request(void);
static void coex_bt_wakeup_request_end(void);
static void btdm_slp_tmr_callback(void *arg);
@ -372,8 +386,12 @@ static const struct osi_funcs_t osi_funcs_ro = {
._btdm_sleep_exit_phase3 = btdm_sleep_exit_phase3_wrapper,
._coex_wifi_sleep_set = coex_wifi_sleep_set_hook,
._coex_core_ble_conn_dyn_prio_get = coex_core_ble_conn_dyn_prio_get,
._coex_schm_register_btdm_callback = coex_schm_register_btdm_callback_wrapper,
._coex_schm_status_bit_set = coex_schm_status_bit_set_wrapper,
._coex_schm_status_bit_clear = coex_schm_status_bit_clear_wrapper,
._coex_schm_interval_get = coex_schm_interval_get_wrapper,
._coex_schm_curr_period_get = coex_schm_curr_period_get_wrapper,
._coex_schm_curr_phase_get = coex_schm_curr_phase_get_wrapper,
._interrupt_on = interrupt_on_wrapper,
._interrupt_off = interrupt_off_wrapper,
._esp_hw_power_down = btdm_hw_mac_power_down_wrapper,
@ -381,6 +399,8 @@ static const struct osi_funcs_t osi_funcs_ro = {
._ets_backup_dma_copy = btdm_backup_dma_copy_wrapper,
._ets_delay_us = esp_rom_delay_us,
._btdm_rom_table_ready = btdm_funcs_table_ready_wrapper,
._coex_bt_wakeup_request = coex_bt_wakeup_request,
._coex_bt_wakeup_request_end = coex_bt_wakeup_request_end,
};
static DRAM_ATTR struct osi_funcs_t *osi_funcs_p;
@ -895,6 +915,22 @@ static bool async_wakeup_request(int event)
semphr_take_wrapper(s_wakeup_req_sem, OSI_FUNCS_TIME_BLOCKING);
}
break;
case BTDM_ASYNC_WAKEUP_REQ_COEX:
if (!btdm_power_state_active()) {
do_wakeup_request = true;
#if CONFIG_PM_ENABLE
if (s_lp_stat.pm_lock_released) {
esp_pm_lock_acquire(s_pm_lock);
s_lp_stat.pm_lock_released = 0;
}
#endif
btdm_wakeup_request();
if (s_lp_cntl.wakeup_timer_required && s_lp_stat.wakeup_timer_started) {
esp_timer_stop(s_btdm_slp_tmr);
s_lp_stat.wakeup_timer_started = 0;
}
}
default:
break;
}
@ -914,6 +950,9 @@ static void async_wakeup_request_end(int event)
case BTDM_ASYNC_WAKEUP_SRC_DISA:
allow_to_sleep = true;
break;
case BTDM_ASYNC_WAKEUP_REQ_COEX:
allow_to_sleep = false;
break;
default:
allow_to_sleep = true;
break;
@ -933,18 +972,25 @@ static void btdm_funcs_table_ready_wrapper(void)
#endif
}
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status)
bool bt_async_wakeup_request(void)
{
#if CONFIG_SW_COEXIST_ENABLE
coex_schm_status_bit_set(type, status);
#endif
return async_wakeup_request(BTDM_ASYNC_WAKEUP_SRC_VHCI);
}
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status)
void bt_wakeup_request_end(void)
{
#if CONFIG_SW_COEXIST_ENABLE
coex_schm_status_bit_clear(type, status);
#endif
async_wakeup_request_end(BTDM_ASYNC_WAKEUP_SRC_VHCI);
}
static bool coex_bt_wakeup_request(void)
{
return async_wakeup_request(BTDM_ASYNC_WAKEUP_REQ_COEX);
}
static void coex_bt_wakeup_request_end(void)
{
async_wakeup_request_end(BTDM_ASYNC_WAKEUP_REQ_COEX);
return;
}
bool esp_vhci_host_check_send_available(void)
@ -1739,4 +1785,55 @@ static void coex_wifi_sleep_set_hook(bool sleep)
{
}
static int coex_schm_register_btdm_callback_wrapper(void *callback)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_register_btdm_callback(callback);
#else
return 0;
#endif
}
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status)
{
#if CONFIG_SW_COEXIST_ENABLE
coex_schm_status_bit_clear(type, status);
#endif
}
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status)
{
#if CONFIG_SW_COEXIST_ENABLE
coex_schm_status_bit_set(type, status);
#endif
}
static uint32_t coex_schm_interval_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_interval_get();
#else
return 0;
#endif
}
static uint8_t coex_schm_curr_period_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_curr_period_get();
#else
return 1;
#endif
}
static void * coex_schm_curr_phase_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_curr_phase_get();
#else
return NULL;
#endif
}
#endif /* CONFIG_BT_ENABLED */

@ -1 +1 @@
Subproject commit 889c1149140d330ad173b863a91b667d9f62b853
Subproject commit 44341b15e58792946cc65ed8d4483929194d182f

@ -1 +1 @@
Subproject commit e5c0f7256ecf5b5f8eb28c1793051a6b88f95124
Subproject commit 76ed4114ee7d081435a3c65793b4c8eb1dfaf199

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -50,7 +50,7 @@ extern "C" {
#endif //CONFIG_BT_ENABLED
#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20221207
#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20240315
/**
* @brief Bluetooth mode for controller enable/disable
@ -167,6 +167,12 @@ the adv packet will be discarded until the memory is restored. */
#define BTDM_CONTROLLER_SCO_DATA_PATH_HCI 0 // SCO data is routed to HCI
#define BTDM_CONTROLLER_SCO_DATA_PATH_PCM 1 // SCO data path is PCM
#ifdef CONFIG_BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
#define BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX CONFIG_BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
#else
#define BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX 0
#endif
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() { \
.controller_task_stack_size = ESP_TASK_BT_CONTROLLER_STACK, \
.controller_task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
@ -190,6 +196,7 @@ the adv packet will be discarded until the memory is restored. */
.pcm_polar = CONFIG_BTDM_CTRL_PCM_POLAR_EFF, \
.hli = BTDM_CTRL_HLI, \
.dup_list_refresh_period = SCAN_DUPL_CACHE_REFRESH_PERIOD, \
.ble_scan_backoff = BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \
.magic = ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL, \
}
@ -233,6 +240,7 @@ typedef struct {
uint8_t pcm_polar; /*!< PCM polar trig (falling clk edge & rising clk edge) */
bool hli; /*!< Using high level interrupt or not */
uint16_t dup_list_refresh_period; /*!< Duplicate scan list refresh period */
bool ble_scan_backoff; /*!< BLE scan backoff */
uint32_t magic; /*!< Magic number */
} esp_bt_controller_config_t;

Wyświetl plik

@ -19,7 +19,7 @@ extern "C" {
#endif
#define ESP_BT_CTRL_CONFIG_MAGIC_VAL 0x5A5AA5A5
#define ESP_BT_CTRL_CONFIG_VERSION 0x02401120
#define ESP_BT_CTRL_CONFIG_VERSION 0x02404010
#define ESP_BT_HCI_TL_MAGIC_VALUE 0xfadebead
#define ESP_BT_HCI_TL_VERSION 0x00010000
@ -194,6 +194,18 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);
#define BT_BLE_ADV_DATA_LENGTH_ZERO_AUX (0)
#endif
#if defined(CONFIG_BT_CTRL_CHAN_ASS_EN)
#define BT_CTRL_CHAN_ASS_EN (CONFIG_BT_CTRL_CHAN_ASS_EN)
#else
#define BT_CTRL_CHAN_ASS_EN (0)
#endif
#if defined(CONFIG_BT_CTRL_LE_PING_EN)
#define BT_CTRL_LE_PING_EN (CONFIG_BT_CTRL_LE_PING_EN)
#else
#define BT_CTRL_LE_PING_EN (0)
#endif
#define AGC_RECORRECT_EN ((BT_CTRL_AGC_RECORRECT_EN << 0) | (BT_CTRL_CODED_AGC_RECORRECT <<1) | (BT_CTRL_AGC_RECORRECT_NEW << 2))
#define CFG_MASK_BIT_SCAN_DUPLICATE_OPTION (1<<0)
@ -241,6 +253,8 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);
.ble_50_feat_supp = BT_CTRL_50_FEATURE_SUPPORT, \
.ble_cca_mode = BT_BLE_CCA_MODE, \
.ble_data_lenth_zero_aux = BT_BLE_ADV_DATA_LENGTH_ZERO_AUX, \
.ble_chan_ass_en = BT_CTRL_CHAN_ASS_EN, \
.ble_ping_en = BT_CTRL_LE_PING_EN, \
}
#else
@ -312,7 +326,9 @@ typedef struct {
uint16_t dup_list_refresh_period; /*!< duplicate scan list refresh time */
bool ble_50_feat_supp; /*!< BLE 5.0 feature support */
uint8_t ble_cca_mode; /*!< BLE CCA mode */
uint8_t ble_data_lenth_zero_aux; /*!< Config ext adv aux option*/
uint8_t ble_data_lenth_zero_aux; /*!< Config ext adv aux option */
uint8_t ble_chan_ass_en; /*!< BLE channel assessment enable */
uint8_t ble_ping_en; /*!< BLE ping procedure enable */
} esp_bt_controller_config_t;
/**

Wyświetl plik

@ -65,7 +65,6 @@ r_lld_con_tx_prog_new_packet_coex = 0x40001b70;
r_lld_per_adv_dynamic_pti_get = 0x40001b78;
r_lld_per_adv_evt_start_chm_upd = 0x40001b7c;
r_lld_ext_scan_dynamic_pti_get = 0x40001b80;
r_lld_scan_try_sched = 0x40001b84;
r_lld_sync_insert = 0x40001b88;
r_sch_prog_ble_push = 0x40001b8c;
r_sch_prog_bt_push = 0x40001b90;

Wyświetl plik

@ -113,7 +113,6 @@ r_lld_con_start_eco = 0x40001d10;
r_lld_con_frm_isr_eco = 0x40001d14;
r_lld_con_tx_eco = 0x40001d18;
r_lld_scan_evt_start_cbk_eco = 0x40001d20;
r_lld_scan_start_eco = 0x40001d24;
r_lld_ext_scan_dynamic_pti_process_eco = 0x40001d28;
r_lld_scan_frm_eof_isr_eco = 0x40001d2c;
r_lld_sync_start_eco = 0x40001d30;
@ -138,15 +137,9 @@ r_sch_plan_conflict_check = 0x40001d7c;
r_rwble_isr_hw_fixed = 0x40001d80;
r_bt_bb_recorrect_is_dead = 0x40001d84;
r_bt_bb_restart_hw_recorrect = 0x40001d88;
r_btdm_task_post_impl = 0x40001d8c;
r_btdm_task_post_from_isr_impl = 0x40001d90;
r_btdm_vnd_offload_post_from_isr = 0x40001d94;
r_btdm_vnd_offload_post = 0x40001d98;
r_btdm_vnd_offload_process = 0x40001d9c;
r_ke_task_handler_pre = 0x40001da0;
r_ke_task_handler_end = 0x40001da4;
r_ke_task_handler_get_overwrite = 0x40001da8;
r_lld_scan_try_sched_eco = 0x40001dac;
r_lld_scan_frm_skip_isr_eco = 0x40001db0;
r_lld_ext_scan_dynamic_pti_reset = 0x40001db4;
r_llc_rem_phy_upd_proc_continue_eco = 0x40001db8;
@ -217,6 +210,8 @@ r_lld_adv_ext_chain_none_construct = 0x40001b50;
r_llc_llcp_send_eco = 0x40001cf4;
r_llc_llcp_channel_map_ind_ack = 0x40001d68;
r_rwble_isr = 0x40001464;
r_lld_scan_start_eco = 0x40001d24;
r_lld_scan_try_sched_eco = 0x40001dac;
*/

Wyświetl plik

@ -922,7 +922,7 @@ r_llc_init_term_proc = 0x40000f1c;
r_llc_iv_skd_rand_gen = 0x40000f20;
r_llc_le_ping_proc_continue = 0x40000f24;
r_llc_le_ping_proc_err_cb = 0x40000f28;
r_llc_le_ping_restart = 0x40000f2c;
/* r_llc_le_ping_restart = 0x40000f2c; */
r_llc_le_ping_set = 0x40000f30;
r_llc_ll_pause_enc_rsp_ack_handler = 0x40000f34;
r_llc_ll_reject_ind_ack_handler = 0x40000f38;

Wyświetl plik

@ -1195,7 +1195,7 @@ r_llc_init_term_proc = 0x40003d38;
r_llc_iv_skd_rand_gen = 0x40003d44;
r_llc_le_ping_proc_continue = 0x40003d50;
r_llc_le_ping_proc_err_cb = 0x40003d5c;
r_llc_le_ping_restart = 0x40003d68;
/* r_llc_le_ping_restart = 0x40003d68; */
r_llc_le_ping_set = 0x40003d74;
r_llc_ll_pause_enc_rsp_ack_handler = 0x40003d80;
r_llc_ll_reject_ind_ack_handler = 0x40003d8c;
@ -1609,7 +1609,6 @@ r_lld_con_tx_prog_new_packet_coex = 0x4000519c;
r_lld_per_adv_dynamic_pti_get = 0x400051b4;
r_lld_per_adv_evt_start_chm_upd = 0x400051c0;
r_lld_ext_scan_dynamic_pti_get = 0x400051cc;
r_lld_scan_try_sched = 0x400051d8;
r_lld_sync_insert = 0x400051e4;
r_sch_prog_ble_push = 0x400051f0;
r_sch_prog_bt_push = 0x400051fc;