Merge branch 'bugfix/backport_some_ble_bugs_20231020_v5.1' into 'release/v5.1'

Fixed some BLE bugs 20231020 (backport v5.1)

See merge request espressif/esp-idf!26604
This commit is contained in:
Wang Meng Yang 2023-11-14 15:35:55 +08:00
commit c46775031e
11 changed files with 54 additions and 4 deletions

View File

@ -205,6 +205,11 @@ menu "HCI UART(H4) Options"
help help
UART Baudrate for HCI. Please use standard baudrate. UART Baudrate for HCI. Please use standard baudrate.
config BTDM_CTRL_HCI_UART_FLOW_CTRL_EN
bool "Enable UART flow control"
depends on BTDM_CTRL_HCI_MODE_UART_H4
default y
endmenu endmenu
menu "MODEM SLEEP Options" menu "MODEM SLEEP Options"

View File

@ -220,6 +220,8 @@ extern void bredr_sco_datapath_set(uint8_t data_path);
extern void btdm_controller_scan_duplicate_list_clear(void); extern void btdm_controller_scan_duplicate_list_clear(void);
/* Shutdown */ /* Shutdown */
extern void esp_bt_controller_shutdown(void); extern void esp_bt_controller_shutdown(void);
extern void sdk_config_set_bt_pll_track_enable(bool enable);
extern void sdk_config_set_uart_flow_ctrl_enable(bool enable);
extern char _bss_start_btdm; extern char _bss_start_btdm;
extern char _bss_end_btdm; extern char _bss_end_btdm;
@ -1526,6 +1528,12 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE); btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE);
#endif #endif
#if CONFIG_BTDM_CTRL_HCI_UART_FLOW_CTRL_EN
sdk_config_set_uart_flow_ctrl_enable(true);
#else
sdk_config_set_uart_flow_ctrl_enable(false);
#endif
#ifdef CONFIG_PM_ENABLE #ifdef CONFIG_PM_ENABLE
if (!s_btdm_allow_light_sleep) { if (!s_btdm_allow_light_sleep) {
if ((err = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "btLS", &s_light_sleep_pm_lock)) != ESP_OK) { if ((err = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "btLS", &s_light_sleep_pm_lock)) != ESP_OK) {
@ -1677,6 +1685,8 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
btdm_controller_enable_sleep(true); btdm_controller_enable_sleep(true);
} }
sdk_config_set_bt_pll_track_enable(true);
// inititalize bluetooth baseband // inititalize bluetooth baseband
btdm_check_and_init_bb(); btdm_check_and_init_bb();

@ -1 +1 @@
Subproject commit 0cfac1b21ebc995e8e9aa040ab1ab29deee4f580 Subproject commit 7fb979154bec81163d55aa4e3134425aea0d52ab

View File

@ -674,6 +674,8 @@ typedef enum {
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_BEACON_TYPE, /*!< BLE mesh beacon AD type, the format is | Len | 0x2B | Beacon Type | Beacon Data | */ ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_BEACON_TYPE, /*!< BLE mesh beacon AD type, the format is | Len | 0x2B | Beacon Type | Beacon Data | */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROV_SRV_ADV, /*!< BLE mesh provisioning service uuid, the format is | 0x02 | 0x01 | flags | 0x03 | 0x03 | 0x1827 | .... |` */ ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROV_SRV_ADV, /*!< BLE mesh provisioning service uuid, the format is | 0x02 | 0x01 | flags | 0x03 | 0x03 | 0x1827 | .... |` */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROXY_SRV_ADV, /*!< BLE mesh adv with proxy service uuid, the format is | 0x02 | 0x01 | flags | 0x03 | 0x03 | 0x1828 | .... |` */ ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROXY_SRV_ADV, /*!< BLE mesh adv with proxy service uuid, the format is | 0x02 | 0x01 | flags | 0x03 | 0x03 | 0x1828 | .... |` */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROXY_SOLIC_ADV, /*!< BLE mesh adv with proxy service uuid, the format is | 0x02 | 0x01 | flags | 0x03 | 0x03 | 0x1859 | .... |` */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_URI_ADV, /*!< BLE mesh URI adv, the format is ...| Len | 0x24 | data |... */
} esp_ble_duplicate_exceptional_info_type_t; } esp_ble_duplicate_exceptional_info_type_t;
typedef enum { typedef enum {
@ -681,7 +683,9 @@ typedef enum {
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_LINK_ID_LIST = BLE_BIT(1), /*!< duplicate scan exceptional mesh link ID list */ ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_LINK_ID_LIST = BLE_BIT(1), /*!< duplicate scan exceptional mesh link ID list */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_BEACON_TYPE_LIST = BLE_BIT(2), /*!< duplicate scan exceptional mesh beacon type list */ ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_BEACON_TYPE_LIST = BLE_BIT(2), /*!< duplicate scan exceptional mesh beacon type list */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_PROV_SRV_ADV_LIST = BLE_BIT(3), /*!< duplicate scan exceptional mesh adv with provisioning service uuid */ ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_PROV_SRV_ADV_LIST = BLE_BIT(3), /*!< duplicate scan exceptional mesh adv with provisioning service uuid */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_PROXY_SRV_ADV_LIST = BLE_BIT(4), /*!< duplicate scan exceptional mesh adv with provisioning service uuid */ ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_PROXY_SRV_ADV_LIST = BLE_BIT(4), /*!< duplicate scan exceptional mesh adv with proxy service uuid */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_PROXY_SOLIC_ADV_LIST = BLE_BIT(5), /*!< duplicate scan exceptional mesh adv with proxy solicitation PDU uuid */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_URI_ADV_LIST = BLE_BIT(6), /*!< duplicate scan exceptional URI list */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ALL_LIST = 0xFFFF, /*!< duplicate scan exceptional all list */ ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ALL_LIST = 0xFFFF, /*!< duplicate scan exceptional all list */
} esp_duplicate_scan_exceptional_list_type_t; } esp_duplicate_scan_exceptional_list_type_t;

View File

@ -405,6 +405,7 @@ static void command_timed_out(void *context)
{ {
hci_cmd_metadata_t *metadata = (hci_cmd_metadata_t *)(wait_entry->data); hci_cmd_metadata_t *metadata = (hci_cmd_metadata_t *)(wait_entry->data);
HCI_TRACE_ERROR("%s hci layer timeout waiting for response to a command. opcode: 0x%x", __func__, metadata->opcode); HCI_TRACE_ERROR("%s hci layer timeout waiting for response to a command. opcode: 0x%x", __func__, metadata->opcode);
UNUSED(metadata);
} }
} }

View File

@ -807,6 +807,7 @@ void l2cble_process_sig_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len)
STREAM_TO_UINT16(mps, p); STREAM_TO_UINT16(mps, p);
STREAM_TO_UINT16(credits, p); STREAM_TO_UINT16(credits, p);
L2CAP_TRACE_DEBUG("%s spsm %x, scid %x", __func__, spsm, scid); L2CAP_TRACE_DEBUG("%s spsm %x, scid %x", __func__, spsm, scid);
UNUSED(spsm);
p_ccb = l2cu_find_ccb_by_remote_cid(p_lcb, scid); p_ccb = l2cu_find_ccb_by_remote_cid(p_lcb, scid);
if (p_ccb) { if (p_ccb) {

View File

@ -966,7 +966,9 @@ r_llc_loc_dl_upd_proc_continue = 0x40000f68;
r_llc_loc_encrypt_proc_continue = 0x40000f6c; r_llc_loc_encrypt_proc_continue = 0x40000f6c;
r_llc_loc_encrypt_proc_err_cb = 0x40000f70; r_llc_loc_encrypt_proc_err_cb = 0x40000f70;
r_llc_loc_feats_exch_proc_continue = 0x40000f74; r_llc_loc_feats_exch_proc_continue = 0x40000f74;
/*
r_llc_loc_phy_upd_proc_continue = 0x40000f78; r_llc_loc_phy_upd_proc_continue = 0x40000f78;
*/
r_llc_loc_phy_upd_proc_err_cb = 0x40000f7c; r_llc_loc_phy_upd_proc_err_cb = 0x40000f7c;
r_llc_msg_handler_tab_p_get = 0x40000f80; r_llc_msg_handler_tab_p_get = 0x40000f80;
r_llc_pref_param_compute = 0x40000f84; r_llc_pref_param_compute = 0x40000f84;
@ -1145,13 +1147,17 @@ r_lld_process_cca_data = 0x4000120c;
r_lld_ral_search = 0x40001210; r_lld_ral_search = 0x40001210;
r_lld_read_clock = 0x40001214; r_lld_read_clock = 0x40001214;
r_lld_res_list_add = 0x40001218; r_lld_res_list_add = 0x40001218;
/*
r_lld_res_list_clear = 0x4000121c; r_lld_res_list_clear = 0x4000121c;
*/
r_lld_res_list_is_empty = 0x40001220; r_lld_res_list_is_empty = 0x40001220;
r_lld_res_list_local_rpa_get = 0x40001224; r_lld_res_list_local_rpa_get = 0x40001224;
r_lld_res_list_peer_rpa_get = 0x40001228; r_lld_res_list_peer_rpa_get = 0x40001228;
r_lld_res_list_peer_update = 0x4000122c; r_lld_res_list_peer_update = 0x4000122c;
r_lld_res_list_priv_mode_update = 0x40001230; r_lld_res_list_priv_mode_update = 0x40001230;
/*
r_lld_res_list_rem = 0x40001234; r_lld_res_list_rem = 0x40001234;
*/
r_lld_reset_reg = 0x40001238; r_lld_reset_reg = 0x40001238;
r_lld_rpa_renew = 0x4000123c; r_lld_rpa_renew = 0x4000123c;
r_lld_rpa_renew_evt_canceled_cbk = 0x40001240; r_lld_rpa_renew_evt_canceled_cbk = 0x40001240;

View File

@ -1239,7 +1239,9 @@ r_llc_loc_dl_upd_proc_continue = 0x40003e1c;
r_llc_loc_encrypt_proc_continue = 0x40003e28; r_llc_loc_encrypt_proc_continue = 0x40003e28;
r_llc_loc_encrypt_proc_err_cb = 0x40003e34; r_llc_loc_encrypt_proc_err_cb = 0x40003e34;
r_llc_loc_feats_exch_proc_continue = 0x40003e40; r_llc_loc_feats_exch_proc_continue = 0x40003e40;
/*
r_llc_loc_phy_upd_proc_continue = 0x40003e4c; r_llc_loc_phy_upd_proc_continue = 0x40003e4c;
*/
r_llc_loc_phy_upd_proc_err_cb = 0x40003e58; r_llc_loc_phy_upd_proc_err_cb = 0x40003e58;
r_llc_msg_handler_tab_p_get = 0x40003e64; r_llc_msg_handler_tab_p_get = 0x40003e64;
r_llc_pref_param_compute = 0x40003e70; r_llc_pref_param_compute = 0x40003e70;
@ -1418,13 +1420,17 @@ r_lld_process_cca_data = 0x40004608;
r_lld_ral_search = 0x40004614; r_lld_ral_search = 0x40004614;
r_lld_read_clock = 0x40004620; r_lld_read_clock = 0x40004620;
r_lld_res_list_add = 0x4000462c; r_lld_res_list_add = 0x4000462c;
/*
r_lld_res_list_clear = 0x40004638; r_lld_res_list_clear = 0x40004638;
*/
r_lld_res_list_is_empty = 0x40004644; r_lld_res_list_is_empty = 0x40004644;
r_lld_res_list_local_rpa_get = 0x40004650; r_lld_res_list_local_rpa_get = 0x40004650;
r_lld_res_list_peer_rpa_get = 0x4000465c; r_lld_res_list_peer_rpa_get = 0x4000465c;
r_lld_res_list_peer_update = 0x40004668; r_lld_res_list_peer_update = 0x40004668;
r_lld_res_list_priv_mode_update = 0x40004674; r_lld_res_list_priv_mode_update = 0x40004674;
/*
r_lld_res_list_rem = 0x40004680; r_lld_res_list_rem = 0x40004680;
*/
r_lld_reset_reg = 0x4000468c; r_lld_reset_reg = 0x4000468c;
r_lld_rpa_renew = 0x40004698; r_lld_rpa_renew = 0x40004698;
r_lld_rpa_renew_evt_canceled_cbk = 0x400046a4; r_lld_rpa_renew_evt_canceled_cbk = 0x400046a4;

View File

@ -25,7 +25,7 @@ static void uart_gpio_reset(void)
periph_module_enable(PERIPH_UHCI0_MODULE); periph_module_enable(PERIPH_UHCI0_MODULE);
#ifdef CONFIG_BTDM_CTRL_HCI_UART_NO #ifdef CONFIG_BTDM_CTRL_HCI_UART_NO
ESP_LOGI(tag, "HCI UART%d Pin select: TX 5, RX 18, CTS 23, RTS 19", CONFIG_BTDM_CTRL_HCI_UART_NO); ESP_LOGI(tag, "HCI UART%d Pin select: TX 5, RX 18, CTS 23, RTS 19 Baudrate:%d", CONFIG_BTDM_CTRL_HCI_UART_NO, CONFIG_BTDM_CTRL_HCI_UART_BAUDRATE);
uart_set_pin(CONFIG_BTDM_CTRL_HCI_UART_NO, 5, 18, 19, 23); uart_set_pin(CONFIG_BTDM_CTRL_HCI_UART_NO, 5, 18, 19, 23);
#endif #endif

View File

@ -7,4 +7,10 @@ menu "Example Configuration"
help help
UART Baudrate for HCI. Please use standard baudrate. UART Baudrate for HCI. Please use standard baudrate.
config EXAMPLE_HCI_UART_FLOW_CTRL_ENABLE
bool "Enable HCI UART flow control"
default y
help
Enable/disable HCI UART flow control
endmenu endmenu

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Unlicense OR CC0-1.0 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */
@ -29,6 +29,12 @@ static const char *tag = "UHCI";
#define GPIO_OUTPUT_PIN_SEL ((1ULL<<GPIO_UART_TXD_OUT) | (1ULL<<GPIO_UART_RTS_OUT)) #define GPIO_OUTPUT_PIN_SEL ((1ULL<<GPIO_UART_TXD_OUT) | (1ULL<<GPIO_UART_RTS_OUT))
#define GPIO_INPUT_PIN_SEL ((1ULL<<GPIO_UART_RXD_IN) | (1ULL<<GPIO_UART_CTS_IN)) #define GPIO_INPUT_PIN_SEL ((1ULL<<GPIO_UART_RXD_IN) | (1ULL<<GPIO_UART_CTS_IN))
#ifdef CONFIG_EXAMPLE_HCI_UART_FLOW_CTRL_ENABLE
#define HCI_UART_FLOW_CTRL_ENABLE CONFIG_EXAMPLE_HCI_UART_FLOW_CTRL_ENABLE
#else
#define HCI_UART_FLOW_CTRL_ENABLE FALSE
#endif
// Operation functions for HCI UART Transport Layer // Operation functions for HCI UART Transport Layer
static bool hci_uart_tl_init(void); static bool hci_uart_tl_init(void);
static void hci_uart_tl_deinit(void); static void hci_uart_tl_deinit(void);
@ -203,7 +209,11 @@ void uhci_uart_install(void)
.data_bits = UART_DATA_8_BITS, .data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE, .parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1, .stop_bits = UART_STOP_BITS_1,
#if (HCI_UART_FLOW_CTRL_ENABLE == TRUE)
.flow_ctrl = UART_HW_FLOWCTRL_CTS_RTS, .flow_ctrl = UART_HW_FLOWCTRL_CTS_RTS,
#else
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
#endif
.rx_flow_ctrl_thresh = UART_RX_THRS, .rx_flow_ctrl_thresh = UART_RX_THRS,
.source_clk = UART_SCLK_DEFAULT, .source_clk = UART_SCLK_DEFAULT,
}; };
@ -284,4 +294,5 @@ void app_main(void)
"--Baudrate: %d", UART_HCI_NUM, "--Baudrate: %d", UART_HCI_NUM,
GPIO_UART_TXD_OUT, GPIO_UART_RXD_IN, GPIO_UART_RTS_OUT, GPIO_UART_CTS_IN, GPIO_UART_TXD_OUT, GPIO_UART_RXD_IN, GPIO_UART_RTS_OUT, GPIO_UART_CTS_IN,
CONFIG_EXAMPLE_HCI_UART_BAUDRATE); CONFIG_EXAMPLE_HCI_UART_BAUDRATE);
} }