From 666c1894c5f51b754d8b84050c90c3bd0dcf0f7d Mon Sep 17 00:00:00 2001 From: zhiweijian Date: Wed, 22 Apr 2026 19:33:29 +0800 Subject: [PATCH] fix(ble/bluedroid): Fixed init crash when bluedroid BLE is enabled in BREDR only mode --- components/bt/host/bluedroid/Kconfig.in | 2 +- components/bt/host/bluedroid/device/controller.c | 9 +++++++-- components/bt/host/bluedroid/stack/btm/btm_ble_privacy.c | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/components/bt/host/bluedroid/Kconfig.in b/components/bt/host/bluedroid/Kconfig.in index 3fb9211179a..06c24f6d823 100644 --- a/components/bt/host/bluedroid/Kconfig.in +++ b/components/bt/host/bluedroid/Kconfig.in @@ -272,7 +272,7 @@ config BT_GOEPC_ENABLED config BT_BLE_ENABLED bool "Bluetooth Low Energy" - depends on BT_BLUEDROID_ENABLED + depends on BT_BLUEDROID_ENABLED && (!BTDM_CTRL_MODE_BR_EDR_ONLY) default y help This enables Bluetooth Low Energy diff --git a/components/bt/host/bluedroid/device/controller.c b/components/bt/host/bluedroid/device/controller.c index 0aa677fc558..d2076102e9b 100644 --- a/components/bt/host/bluedroid/device/controller.c +++ b/components/bt/host/bluedroid/device/controller.c @@ -234,7 +234,10 @@ static void start_up(void) #if (BLE_INCLUDED == TRUE) #if (CLASSIC_BT_INCLUDED) controller_param.ble_supported = controller_param.last_features_classic_page_index >= 1 && HCI_LE_HOST_SUPPORTED(controller_param.features_classic[1].as_array); -#else + if (!controller_param.ble_supported) { + LOG_ERROR("Controller does not support BLE, please disable host BLE"); + } + #else controller_param.ble_supported = true; #endif if (controller_param.ble_supported) { @@ -508,7 +511,9 @@ static uint16_t get_acl_packet_size_ble(void) static uint16_t get_ble_suggested_default_data_length(void) { assert(controller_param.readable); - assert(controller_param.ble_supported); + if (!controller_param.ble_supported) { + return 0; + } return controller_param.ble_suggested_default_data_length; } diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_privacy.c b/components/bt/host/bluedroid/stack/btm/btm_ble_privacy.c index 45f3af5bcd3..8bc6446f50c 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_privacy.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_privacy.c @@ -1201,6 +1201,10 @@ void btm_ble_resolving_list_cleanup(void) #if (CONTROLLER_RPA_LIST_ENABLE == TRUE) void btm_ble_add_default_entry_to_resolving_list(void) { + const controller_t *controller = controller_get_interface(); + if (!controller->supports_ble()) { + return; + } /* * Add local IRK entry with 00:00:00:00:00:00 address. This entry will * be used to generate RPA for non-directed advertising if own_addr_type