Skip to content

Commit 93651dd

Browse files
committed
Merge branch 'change/ble_update_lib_20250212_v5.4' into 'release/v5.4'
change(ble): [AUTO_MR] 20250212 - Update ESP BLE Controller Lib (v5.4) See merge request espressif/esp-idf!37044
2 parents c7e8b68 + 8e5aee2 commit 93651dd

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
@@ -889,6 +889,9 @@ if(CONFIG_BT_ENABLED)
889889
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app)
890890
endif()
891891
elseif(CONFIG_BT_CONTROLLER_ENABLED)
892+
if(CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE)
893+
target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=esp_panic_handler")
894+
endif()
892895
if(CONFIG_IDF_TARGET_ESP32C6)
893896
add_prebuilt_library(libble_app
894897
"${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
@@ -349,6 +349,36 @@ config BT_LE_LOG_HCI_BUF_SIZE
349349
help
350350
Configure the size of the BLE HCI LOG buffer.
351351

352+
config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
353+
bool "Enable wrap panic handler"
354+
depends on BT_LE_CONTROLLER_LOG_ENABLED
355+
default n
356+
help
357+
Wrap esp_panic_handler to get controller logs when PC pointer exception crashes.
358+
359+
config BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
360+
bool "Enable esp_task_wdt_isr_user_handler implementation"
361+
depends on BT_LE_CONTROLLER_LOG_ENABLED
362+
default n
363+
help
364+
Implement esp_task_wdt_isr_user_handler to get controller logs when task wdt issue is triggered.
365+
366+
config BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL
367+
int "The output level of controller log"
368+
depends on BT_LE_CONTROLLER_LOG_ENABLED
369+
range 0 5
370+
default 1
371+
help
372+
The output level of controller log.
373+
374+
config BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH
375+
hex "The switch of module log output"
376+
depends on BT_LE_CONTROLLER_LOG_ENABLED
377+
range 0 0xFFFFFFFF
378+
default 0xFFFFFFFF
379+
help
380+
The switch of module log output, this is an unsigned 32-bit hexadecimal value.
381+
352382
config BT_LE_LL_RESOLV_LIST_SIZE
353383
int "BLE LL Resolving list size"
354384
range 1 5
@@ -495,6 +525,7 @@ config BT_LE_USE_ESP_TIMER
495525
help
496526
Set this option to use Esp Timer which has higher priority timer
497527
instead of FreeRTOS timer
528+
498529
config BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP
499530
bool "BLE adv report flow control supported"
500531
default y
@@ -679,3 +710,48 @@ config BT_CTRL_RUN_IN_FLASH_ONLY
679710
Move most IRAM into flash. This will increase the usage of flash and reduce ble performance.
680711
Because the code is moved to the flash, the execution speed of the code is reduced.
681712
To have a small impact on performance, you need to enable flash suspend (SPI_FLASH_AUTO_SUSPEND).
713+
714+
menu "BLE disconnects when Instant Passed (0x28) occurs"
715+
config BT_LE_CTRL_LLCP_CONN_UPDATE
716+
bool "BLE ACL connection update procedure"
717+
default n
718+
help
719+
If this option is enabled, Controller will terminate the connection
720+
when Instant Passed (0x28) error occurs during connection update procedure.
721+
722+
config BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE
723+
bool "BLE ACL channel map update procedure"
724+
default n
725+
help
726+
If this option is enabled, Controller will terminate the connection
727+
when Instant Passed (0x28) error occurs in channel map update procedure.
728+
729+
config BT_LE_CTRL_LLCP_PHY_UPDATE
730+
bool "BLE ACL PHY update procedure"
731+
default n
732+
help
733+
If this option is enabled, Controller will terminate the connection
734+
when Instant Passed (0x28) error occurs in PHY update procedure.
735+
endmenu
736+
737+
config BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
738+
int "The value of upperlimitmax during scan backoff procedure"
739+
range 1 256
740+
default 32
741+
help
742+
The value of upperlimitmax needs to be a power of 2.
743+
744+
config BT_LE_CTRL_CHAN_ASS_EN
745+
bool "Enable channel assessment"
746+
default n
747+
help
748+
If this option is enabled, The Controller will records the communication quality
749+
for each channel and then start a timer to check and update the channel map every 4 seconds.
750+
751+
config BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX
752+
bool "Enable aux packet when ext adv data length is zero"
753+
default y
754+
help
755+
When this option is enabled, auxiliary packets will be present in the events of
756+
'Non-Connectable and Non-Scannable' regardless of whether the advertising length is 0.
757+
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
@@ -110,6 +110,8 @@ extern int r_ble_log_deinit_async(void);
110110
extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
111111
extern void r_ble_log_async_output_dump_all(bool output);
112112
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
113+
extern int r_ble_log_ctrl_level_and_mod(uint8_t log_level, uint32_t mod_switch);
114+
extern int r_ble_ctrl_mod_type(uint16_t mod, uint32_t mod_type_switch);
113115
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
114116
extern int r_ble_controller_deinit(void);
115117
extern int r_ble_controller_enable(uint8_t mode);
@@ -249,10 +251,14 @@ esp_err_t esp_bt_controller_log_init(uint8_t log_output_mode)
249251
}
250252

251253
ret = r_ble_log_init_async(bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size);
254+
if (ret != ESP_OK) {
255+
return ret;
256+
}
257+
258+
ret = r_ble_log_ctrl_level_and_mod(CONFIG_BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL, CONFIG_BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH);
252259
if (ret == ESP_OK) {
253260
log_is_inited = true;
254261
}
255-
256262
return ret;
257263
}
258264

@@ -383,6 +389,22 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
383389
assert(err == ESP_OK);
384390
}
385391
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
392+
393+
#if CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
394+
void esp_task_wdt_isr_user_handler(void)
395+
{
396+
esp_ble_controller_log_dump_all(true);
397+
}
398+
#endif // CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
399+
400+
#if CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
401+
void __real_esp_panic_handler(void *info);
402+
void __wrap_esp_panic_handler (void *info)
403+
{
404+
esp_ble_controller_log_dump_all(true);
405+
__real_esp_panic_handler(info);
406+
}
407+
#endif // CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
386408
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
387409

388410
/* 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)