From f36d81a62cae5c956e539a4da3323320c1c97824 Mon Sep 17 00:00:00 2001 From: Chen Jian Hua Date: Thu, 31 Oct 2024 15:33:34 +0800 Subject: [PATCH 1/3] fix(bt): Update bt lib for ESP32(a2a7457) - Fixed assert in ke_mem.c at line 409 when controller reset - Added config for BLE instant passed workaround - Fixed connection can't be established when initiating and advertising coexist (cherry picked from commit 2b28133ace9ff00592ef0a34d5b17913569cafb3) Co-authored-by: chenjianhua --- components/bt/controller/esp32/Kconfig.in | 17 +++++++++++++++++ components/bt/controller/lib_esp32 | 2 +- components/bt/include/esp32/include/esp_bt.h | 19 ++++++++++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/components/bt/controller/esp32/Kconfig.in b/components/bt/controller/esp32/Kconfig.in index 1d7572cb08..7de2ac7c8c 100644 --- a/components/bt/controller/esp32/Kconfig.in +++ b/components/bt/controller/esp32/Kconfig.in @@ -440,6 +440,23 @@ config BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD If you set `BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD` to a small value or printf every adv lost event, it may cause adv packets lost more. +menu "BLE disconnect when instant passed" + config BTDM_BLE_LLCP_CONN_UPDATE + bool "BLE ACL connection update procedure" + depends on (BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM) + default n + help + If this option is enabled, Controller will terminate the connection + when instant passed during connection update procedure. + + config BTDM_BLE_LLCP_CHAN_MAP_UPDATE + bool "BLE ACL channel map update procedure" + depends on (BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM) + default n + help + If this option is enabled, Controller will terminate the connection + when instant passed in channel map update procedure. +endmenu config BTDM_RESERVE_DRAM hex diff --git a/components/bt/controller/lib_esp32 b/components/bt/controller/lib_esp32 index f5114d2a70..c3f6258cfb 160000 --- a/components/bt/controller/lib_esp32 +++ b/components/bt/controller/lib_esp32 @@ -1 +1 @@ -Subproject commit f5114d2a70e33a352adc5a3ad5d44c8537aa13da +Subproject commit c3f6258cfbd776d51e30bd6168f42b0cf5d73ea8 diff --git a/components/bt/include/esp32/include/esp_bt.h b/components/bt/include/esp32/include/esp_bt.h index 16b2898e7d..da551ce5b1 100644 --- a/components/bt/include/esp32/include/esp_bt.h +++ b/components/bt/include/esp32/include/esp_bt.h @@ -55,7 +55,7 @@ extern "C" { * * @note Please do not modify this value. */ -#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20240722 +#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20240926 /** * @brief Bluetooth Controller mode @@ -178,6 +178,21 @@ the adv packet will be discarded until the memory is restored. */ #else #define BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX 0 #endif + +#ifdef CONFIG_BTDM_BLE_LLCP_CONN_UPDATE +#define BTDM_BLE_LLCP_CONN_UPDATE (1<<0) +#else +#define BTDM_BLE_LLCP_CONN_UPDATE (0<<0) +#endif + +#ifdef CONFIG_BTDM_BLE_LLCP_CHAN_MAP_UPDATE +#define BTDM_BLE_LLCP_CHAN_MAP_UPDATE (1<<1) +#else +#define BTDM_BLE_LLCP_CHAN_MAP_UPDATE (0<<1) +#endif + +#define BTDM_BLE_LLCP_DISC_FLAG (BTDM_BLE_LLCP_CONN_UPDATE | BTDM_BLE_LLCP_CHAN_MAP_UPDATE) + /** * @brief Default Bluetooth Controller configuration */ @@ -206,6 +221,7 @@ the adv packet will be discarded until the memory is restored. */ .hli = BTDM_CTRL_HLI, \ .dup_list_refresh_period = SCAN_DUPL_CACHE_REFRESH_PERIOD, \ .ble_scan_backoff = BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \ + .ble_llcp_disc_flag = BTDM_BLE_LLCP_DISC_FLAG, \ .magic = ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL, \ } @@ -258,6 +274,7 @@ typedef struct { bool hli; /*!< True if using high level interrupt; false otherwise. Configurable in menuconfig */ uint16_t dup_list_refresh_period; /*!< Scan duplicate filtering list refresh period in seconds. Configurable in menuconfig */ bool ble_scan_backoff; /*!< True if BLE scan backoff is enabled; false otherwise. Configurable in menuconfig */ + uint8_t ble_llcp_disc_flag; /*!< BLE disconnect flag when instant passed. Configurable in menuconfig */ uint32_t magic; /*!< Magic number */ } esp_bt_controller_config_t; From 90a723f7b5a1ba005a1b49786fe5eb56d61d40f0 Mon Sep 17 00:00:00 2001 From: zhanghaipeng Date: Wed, 16 Oct 2024 20:49:57 +0800 Subject: [PATCH 2/3] fix(bt/ble): Update esp32 libbtdm_app.a (17db8bd) - Added a verification step for the Access Address within the CONNECT_IND PDU --- components/bt/controller/esp32/Kconfig.in | 9 +++++++++ components/bt/controller/lib_esp32 | 2 +- components/bt/include/esp32/include/esp_bt.h | 10 +++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/components/bt/controller/esp32/Kconfig.in b/components/bt/controller/esp32/Kconfig.in index 7de2ac7c8c..8855fb062f 100644 --- a/components/bt/controller/esp32/Kconfig.in +++ b/components/bt/controller/esp32/Kconfig.in @@ -406,6 +406,15 @@ config BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX 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_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS + bool "Enable enhanced Access Address check in CONNECT_IND" + default n + help + Enabling this option will add stricter verification of the Access Address in the CONNECT_IND PDU. + This improves security by ensuring that only connection requests with valid Access Addresses are accepted. + If disabled, only basic checks are applied, improving compatibility. + + 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) diff --git a/components/bt/controller/lib_esp32 b/components/bt/controller/lib_esp32 index c3f6258cfb..171c4a7653 160000 --- a/components/bt/controller/lib_esp32 +++ b/components/bt/controller/lib_esp32 @@ -1 +1 @@ -Subproject commit c3f6258cfbd776d51e30bd6168f42b0cf5d73ea8 +Subproject commit 171c4a7653d2ef56edecaa832bdd4faedd403d77 diff --git a/components/bt/include/esp32/include/esp_bt.h b/components/bt/include/esp32/include/esp_bt.h index da551ce5b1..84d07ad148 100644 --- a/components/bt/include/esp32/include/esp_bt.h +++ b/components/bt/include/esp32/include/esp_bt.h @@ -55,7 +55,7 @@ extern "C" { * * @note Please do not modify this value. */ -#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20240926 +#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20241015 /** * @brief Bluetooth Controller mode @@ -193,6 +193,12 @@ the adv packet will be discarded until the memory is restored. */ #define BTDM_BLE_LLCP_DISC_FLAG (BTDM_BLE_LLCP_CONN_UPDATE | BTDM_BLE_LLCP_CHAN_MAP_UPDATE) +#ifdef CONFIG_BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS +#define BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED CONFIG_BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS +#else +#define BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED 0 +#endif + /** * @brief Default Bluetooth Controller configuration */ @@ -222,6 +228,7 @@ the adv packet will be discarded until the memory is restored. */ .dup_list_refresh_period = SCAN_DUPL_CACHE_REFRESH_PERIOD, \ .ble_scan_backoff = BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \ .ble_llcp_disc_flag = BTDM_BLE_LLCP_DISC_FLAG, \ + .ble_aa_check = BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED, \ .magic = ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL, \ } @@ -275,6 +282,7 @@ typedef struct { uint16_t dup_list_refresh_period; /*!< Scan duplicate filtering list refresh period in seconds. Configurable in menuconfig */ bool ble_scan_backoff; /*!< True if BLE scan backoff is enabled; false otherwise. Configurable in menuconfig */ uint8_t ble_llcp_disc_flag; /*!< BLE disconnect flag when instant passed. Configurable in menuconfig */ + bool ble_aa_check; /*!< True if adds a verification step for the Access Address within the CONNECT_IND PDU; false otherwise. Configurable in menuconfig */ uint32_t magic; /*!< Magic number */ } esp_bt_controller_config_t; From 0448a53c66b5ec7e0ace0e04b36da4beac7c9af3 Mon Sep 17 00:00:00 2001 From: gongyantao Date: Fri, 25 Oct 2024 11:16:11 +0800 Subject: [PATCH 3/3] fix(bt): fix some issues in bt controller 1: Store local device name into NVDS when handling hci_wr_local_name_cmd. 2: Set default device name during link manager initialization. 3: Set the QoS value to the minimum value if the calculated QoS is less than the minumum. --- components/bt/controller/lib_esp32 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/controller/lib_esp32 b/components/bt/controller/lib_esp32 index 171c4a7653..5c4a62c1d4 160000 --- a/components/bt/controller/lib_esp32 +++ b/components/bt/controller/lib_esp32 @@ -1 +1 @@ -Subproject commit 171c4a7653d2ef56edecaa832bdd4faedd403d77 +Subproject commit 5c4a62c1d4577d1352d28708c790ba2b4f741842