Skip to content

Commit 5abfc05

Browse files
committed
Merge branch 'change/ble_update_lib_20250212' into 'master'
change(ble): [AUTO_MR] 20250212 - Update ESP BLE Controller Lib Closes BLERP-1554, BLERP-1555, BLERP-1556, BLERP-1482, BLERP-1465, BLERP-1550, BLERP-1515, BLERP-1529, BLERP-1452, BLERP-1451, BLERP-1504, BLERP-1517, BLERP-1388, BLERP-1530, BLERP-1516, and BLERP-1512 See merge request espressif/esp-idf!36892
2 parents 472792e + 9b00d28 commit 5abfc05

File tree

18 files changed

+509
-24
lines changed

18 files changed

+509
-24
lines changed

components/bt/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,9 @@ if(CONFIG_BT_ENABLED)
904904
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app)
905905
endif()
906906
elseif(CONFIG_BT_CONTROLLER_ENABLED)
907+
if(CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE)
908+
target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=esp_panic_handler")
909+
endif()
907910
if(CONFIG_IDF_TARGET_ESP32C6)
908911
add_prebuilt_library(libble_app
909912
"${CMAKE_CURRENT_LIST_DIR}/controller/lib_esp32c6/esp32c6-bt-lib/esp32c6/libble_app.a")

components/bt/controller/esp32c2/Kconfig.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,19 @@ config BT_LE_LOG_HCI_BUF_SIZE
390390
help
391391
Configure the size of the BLE HCI LOG buffer.
392392

393+
config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
394+
bool "Enable wrap panic handler"
395+
depends on BT_LE_CONTROLLER_LOG_ENABLED
396+
default n
397+
help
398+
Wrap esp_panic_handler to get controller logs when PC pointer exception crashes.
399+
400+
config BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
401+
bool "Enable esp_task_wdt_isr_user_handler implementation"
402+
depends on BT_LE_CONTROLLER_LOG_ENABLED
403+
default n
404+
help
405+
Implement esp_task_wdt_isr_user_handler to get controller logs when task wdt issue is triggered.
393406
config BT_LE_LL_RESOLV_LIST_SIZE
394407
int "BLE LL Resolving list size"
395408
range 1 5

components/bt/controller/esp32c2/bt.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,21 @@ void esp_ble_controller_log_dump_all(bool output)
456456
portEXIT_CRITICAL_SAFE(&spinlock);
457457
}
458458
}
459+
#if CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
460+
void esp_task_wdt_isr_user_handler(void)
461+
{
462+
esp_ble_controller_log_dump_all(true);
463+
}
464+
#endif // CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
465+
466+
#if CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
467+
void __real_esp_panic_handler(void *info);
468+
void __wrap_esp_panic_handler (void *info)
469+
{
470+
esp_ble_controller_log_dump_all(true);
471+
__real_esp_panic_handler(info);
472+
}
473+
#endif // CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
459474
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
460475

461476
/* This variable tells if BLE is running */

components/bt/controller/esp32c5/Kconfig.in

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,36 @@ config BT_LE_LOG_HCI_BUF_SIZE
392392
help
393393
Configure the size of the BLE HCI LOG buffer.
394394

395+
config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
396+
bool "Enable wrap panic handler"
397+
depends on BT_LE_CONTROLLER_LOG_ENABLED
398+
default n
399+
help
400+
Wrap esp_panic_handler to get controller logs when PC pointer exception crashes.
401+
402+
config BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
403+
bool "Enable esp_task_wdt_isr_user_handler implementation"
404+
depends on BT_LE_CONTROLLER_LOG_ENABLED
405+
default n
406+
help
407+
Implement esp_task_wdt_isr_user_handler to get controller logs when task wdt issue is triggered.
408+
409+
config BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL
410+
int "The output level of controller log"
411+
depends on BT_LE_CONTROLLER_LOG_ENABLED
412+
range 0 5
413+
default 1
414+
help
415+
The output level of controller log.
416+
417+
config BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH
418+
hex "The switch of module log output"
419+
depends on BT_LE_CONTROLLER_LOG_ENABLED
420+
range 0 0xFFFFFFFF
421+
default 0xFFFFFFFF
422+
help
423+
The switch of module log output, this is an unsigned 32-bit hexadecimal value.
424+
395425
config BT_LE_LL_RESOLV_LIST_SIZE
396426
int "BLE LL Resolving list size"
397427
range 1 5
@@ -538,6 +568,7 @@ config BT_LE_USE_ESP_TIMER
538568
help
539569
Set this option to use Esp Timer which has higher priority timer
540570
instead of FreeRTOS timer
571+
541572
config BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP
542573
bool "BLE adv report flow control supported"
543574
default y
@@ -722,3 +753,48 @@ config BT_CTRL_RUN_IN_FLASH_ONLY
722753
Move most IRAM into flash. This will increase the usage of flash and reduce ble performance.
723754
Because the code is moved to the flash, the execution speed of the code is reduced.
724755
To have a small impact on performance, you need to enable flash suspend (SPI_FLASH_AUTO_SUSPEND).
756+
757+
menu "BLE disconnects when Instant Passed (0x28) occurs"
758+
config BT_LE_CTRL_LLCP_CONN_UPDATE
759+
bool "BLE ACL connection update procedure"
760+
default n
761+
help
762+
If this option is enabled, Controller will terminate the connection
763+
when Instant Passed (0x28) error occurs during connection update procedure.
764+
765+
config BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE
766+
bool "BLE ACL channel map update procedure"
767+
default n
768+
help
769+
If this option is enabled, Controller will terminate the connection
770+
when Instant Passed (0x28) error occurs in channel map update procedure.
771+
772+
config BT_LE_CTRL_LLCP_PHY_UPDATE
773+
bool "BLE ACL PHY update procedure"
774+
default n
775+
help
776+
If this option is enabled, Controller will terminate the connection
777+
when Instant Passed (0x28) error occurs in PHY update procedure.
778+
endmenu
779+
780+
config BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
781+
int "The value of upperlimitmax during scan backoff procedure"
782+
range 1 256
783+
default 32
784+
help
785+
The value of upperlimitmax needs to be a power of 2.
786+
787+
config BT_LE_CTRL_CHAN_ASS_EN
788+
bool "Enable channel assessment"
789+
default n
790+
help
791+
If this option is enabled, The Controller will records the communication quality
792+
for each channel and then start a timer to check and update the channel map every 4 seconds.
793+
794+
config BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX
795+
bool "Enable aux packet when ext adv data length is zero"
796+
default y
797+
help
798+
When this option is enabled, auxiliary packets will be present in the events of
799+
'Non-Connectable and Non-Scannable' regardless of whether the advertising length is 0.
800+
If this option is not enabled, auxiliary packets will only be present when the advertising length is not 0.

components/bt/controller/esp32c5/bt.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ extern int r_ble_log_deinit_async(void);
117117
extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
118118
extern void r_ble_log_async_output_dump_all(bool output);
119119
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
120+
extern int r_ble_log_ctrl_level_and_mod(uint8_t log_level, uint32_t mod_switch);
121+
extern int r_ble_ctrl_mod_type(uint16_t mod, uint32_t mod_type_switch);
120122
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
121123
extern int r_ble_controller_deinit(void);
122124
extern int r_ble_controller_enable(uint8_t mode);
@@ -266,10 +268,14 @@ esp_err_t esp_bt_controller_log_init(uint8_t log_output_mode)
266268
}
267269

268270
ret = r_ble_log_init_async(bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size);
271+
if (ret != ESP_OK) {
272+
return ret;
273+
}
274+
275+
ret = r_ble_log_ctrl_level_and_mod(CONFIG_BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL, CONFIG_BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH);
269276
if (ret == ESP_OK) {
270277
log_is_inited = true;
271278
}
272-
273279
return ret;
274280
}
275281

@@ -403,6 +409,22 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
403409
assert(err == ESP_OK);
404410
}
405411
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
412+
413+
#if CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
414+
void esp_task_wdt_isr_user_handler(void)
415+
{
416+
esp_ble_controller_log_dump_all(true);
417+
}
418+
#endif // CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
419+
420+
#if CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
421+
void __real_esp_panic_handler(void *info);
422+
void __wrap_esp_panic_handler (void *info)
423+
{
424+
esp_ble_controller_log_dump_all(true);
425+
__real_esp_panic_handler(info);
426+
}
427+
#endif // CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
406428
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
407429

408430
/* This variable tells if BLE is running */

components/bt/controller/esp32c5/esp_bt_cfg.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,44 @@ extern "C" {
154154
#define DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS (0)
155155
#endif
156156

157+
#ifdef CONFIG_BT_LE_CTRL_LLCP_CONN_UPDATE
158+
#define BT_CTRL_BLE_LLCP_CONN_UPDATE (1<<0)
159+
#else
160+
#define BT_CTRL_BLE_LLCP_CONN_UPDATE (0<<0)
161+
#endif
162+
163+
#ifdef CONFIG_BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE
164+
#define BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE (1<<1)
165+
#else
166+
#define BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE (0<<1)
167+
#endif
168+
169+
#ifdef CONFIG_BT_LE_CTRL_LLCP_PHY_UPDATE
170+
#define BT_CTRL_BLE_LLCP_PHY_UPDATE (1<<2)
171+
#else
172+
#define BT_CTRL_BLE_LLCP_PHY_UPDATE (0<<2)
173+
#endif
174+
175+
#define BT_LE_CTRL_LLCP_DISC_FLAG (BT_CTRL_BLE_LLCP_CONN_UPDATE | BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE | BT_CTRL_BLE_LLCP_PHY_UPDATE)
176+
177+
#ifdef CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
178+
#define BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX (CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX)
179+
#else
180+
#define BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX (256)
181+
#endif
182+
183+
#if defined(CONFIG_BT_LE_CTRL_CHAN_ASS_EN)
184+
#define DEFAULT_BT_LE_CTRL_CHAN_ASS_EN (CONFIG_BT_LE_CTRL_CHAN_ASS_EN)
185+
#else
186+
#define DEFAULT_BT_LE_CTRL_CHAN_ASS_EN (0)
187+
#endif
188+
189+
#if defined(CONFIG_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX)
190+
#define DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX (CONFIG_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX)
191+
#else
192+
#define DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX (0)
193+
#endif
194+
157195
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART
158196
#define HCI_UART_EN CONFIG_BT_LE_HCI_INTERFACE_USE_UART
159197
#else

components/bt/controller/esp32c6/Kconfig.in

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,36 @@ config BT_LE_LOG_HCI_BUF_SIZE
424424
help
425425
Configure the size of the BLE HCI LOG buffer.
426426

427+
config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
428+
bool "Enable wrap panic handler"
429+
depends on BT_LE_CONTROLLER_LOG_ENABLED
430+
default n
431+
help
432+
Wrap esp_panic_handler to get controller logs when PC pointer exception crashes.
433+
434+
config BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
435+
bool "Enable esp_task_wdt_isr_user_handler implementation"
436+
depends on BT_LE_CONTROLLER_LOG_ENABLED
437+
default n
438+
help
439+
Implement esp_task_wdt_isr_user_handler to get controller logs when task wdt issue is triggered.
440+
441+
config BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL
442+
int "The output level of controller log"
443+
depends on BT_LE_CONTROLLER_LOG_ENABLED
444+
range 0 5
445+
default 1
446+
help
447+
The output level of controller log.
448+
449+
config BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH
450+
hex "The switch of module log output"
451+
depends on BT_LE_CONTROLLER_LOG_ENABLED
452+
range 0 0xFFFFFFFF
453+
default 0xFFFFFFFF
454+
help
455+
The switch of module log output, this is an unsigned 32-bit hexadecimal value.
456+
427457
config BT_LE_LL_RESOLV_LIST_SIZE
428458
int "BLE LL Resolving list size"
429459
range 1 5
@@ -748,3 +778,48 @@ config BT_CTRL_RUN_IN_FLASH_ONLY
748778
Move most IRAM into flash. This will increase the usage of flash and reduce ble performance.
749779
Because the code is moved to the flash, the execution speed of the code is reduced.
750780
To have a small impact on performance, you need to enable flash suspend (SPI_FLASH_AUTO_SUSPEND).
781+
782+
menu "BLE disconnects when Instant Passed (0x28) occurs"
783+
config BT_LE_CTRL_LLCP_CONN_UPDATE
784+
bool "BLE ACL connection update procedure"
785+
default n
786+
help
787+
If this option is enabled, Controller will terminate the connection
788+
when Instant Passed (0x28) error occurs during connection update procedure.
789+
790+
config BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE
791+
bool "BLE ACL channel map update procedure"
792+
default n
793+
help
794+
If this option is enabled, Controller will terminate the connection
795+
when Instant Passed (0x28) error occurs in channel map update procedure.
796+
797+
config BT_LE_CTRL_LLCP_PHY_UPDATE
798+
bool "BLE ACL PHY update procedure"
799+
default n
800+
help
801+
If this option is enabled, Controller will terminate the connection
802+
when Instant Passed (0x28) error occurs in PHY update procedure.
803+
endmenu
804+
805+
config BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
806+
int "The value of upperlimitmax during scan backoff procedure"
807+
range 1 256
808+
default 32
809+
help
810+
The value of upperlimitmax needs to be a power of 2.
811+
812+
config BT_LE_CTRL_CHAN_ASS_EN
813+
bool "Enable channel assessment"
814+
default n
815+
help
816+
If this option is enabled, The Controller will records the communication quality
817+
for each channel and then start a timer to check and update the channel map every 4 seconds.
818+
819+
config BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX
820+
bool "Enable aux packet when ext adv data length is zero"
821+
default y
822+
help
823+
When this option is enabled, auxiliary packets will be present in the events of
824+
'Non-Connectable and Non-Scannable' regardless of whether the advertising length is 0.
825+
If this option is not enabled, auxiliary packets will only be present when the advertising length is not 0.

components/bt/controller/esp32c6/bt.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ extern int r_ble_log_deinit_async(void);
120120
extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
121121
extern void r_ble_log_async_output_dump_all(bool output);
122122
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
123+
extern int r_ble_log_ctrl_level_and_mod(uint8_t log_level, uint32_t mod_switch);
124+
extern int r_ble_ctrl_mod_type(uint16_t mod, uint32_t mod_type_switch);
123125
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
124126
extern int r_ble_controller_deinit(void);
125127
extern int r_ble_controller_enable(uint8_t mode);
@@ -269,10 +271,14 @@ esp_err_t esp_bt_controller_log_init(uint8_t log_output_mode)
269271
}
270272

271273
ret = r_ble_log_init_async(bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size);
274+
if (ret != ESP_OK) {
275+
return ret;
276+
}
277+
278+
ret = r_ble_log_ctrl_level_and_mod(CONFIG_BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL, CONFIG_BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH);
272279
if (ret == ESP_OK) {
273280
log_is_inited = true;
274281
}
275-
276282
return ret;
277283
}
278284

@@ -406,6 +412,22 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
406412
assert(err == ESP_OK);
407413
}
408414
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
415+
416+
#if CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
417+
void esp_task_wdt_isr_user_handler(void)
418+
{
419+
esp_ble_controller_log_dump_all(true);
420+
}
421+
#endif // CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
422+
423+
#if CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
424+
void __real_esp_panic_handler(void *info);
425+
void __wrap_esp_panic_handler (void *info)
426+
{
427+
esp_ble_controller_log_dump_all(true);
428+
__real_esp_panic_handler(info);
429+
}
430+
#endif // CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
409431
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
410432

411433
/* This variable tells if BLE is running */

0 commit comments

Comments
 (0)