Skip to content

Commit 7d751dc

Browse files
committed
Merge branch 'feat/optimize_ble_config_reduce_bin' into 'master'
Feat/optimize bluedroid host config and reduce bin size Closes BLERP-1520 See merge request espressif/esp-idf!36599
2 parents e21e3f4 + 69acda1 commit 7d751dc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1404
-1085
lines changed

components/bt/common/btc/core/btc_task.c

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -389,6 +389,7 @@ static void btc_deinit_mem(void) {
389389
}
390390

391391
#if (BLE_42_FEATURE_SUPPORT == TRUE)
392+
#if (BLE_42_ADV_EN == TRUE)
392393
if (gl_bta_adv_data_ptr) {
393394
osi_free(gl_bta_adv_data_ptr);
394395
gl_bta_adv_data_ptr = NULL;
@@ -398,6 +399,7 @@ static void btc_deinit_mem(void) {
398399
osi_free(gl_bta_scan_rsp_data_ptr);
399400
gl_bta_scan_rsp_data_ptr = NULL;
400401
}
402+
#endif // #if (BLE_42_ADV_EN == TRUE)
401403
#endif // BLE_42_FEATURE_SUPPORT
402404

403405
#if GATTS_INCLUDED == TRUE && GATT_DYNAMIC_MEMORY == TRUE
@@ -452,6 +454,7 @@ static bt_status_t btc_init_mem(void) {
452454

453455
#if BTC_DYNAMIC_MEMORY == TRUE
454456
#if (BLE_42_FEATURE_SUPPORT == TRUE)
457+
#if (BLE_42_ADV_EN == TRUE)
455458
if ((gl_bta_adv_data_ptr = (tBTA_BLE_ADV_DATA *)osi_malloc(sizeof(tBTA_BLE_ADV_DATA))) == NULL) {
456459
goto error_exit;
457460
}
@@ -461,6 +464,7 @@ static bt_status_t btc_init_mem(void) {
461464
goto error_exit;
462465
}
463466
memset((void *)gl_bta_scan_rsp_data_ptr, 0, sizeof(tBTA_BLE_ADV_DATA));
467+
#endif // #if (BLE_42_ADV_EN == TRUE)
464468
#endif // (BLE_42_FEATURE_SUPPORT == TRUE)
465469
#endif // BTC_DYNAMIC_MEMORY == TRUE
466470

@@ -530,9 +534,6 @@ bt_status_t btc_init(void)
530534
btc_gap_ble_init();
531535
#endif ///BLE_INCLUDED == TRUE
532536

533-
#if SCAN_QUEUE_CONGEST_CHECK
534-
btc_adv_list_init();
535-
#endif
536537
/* TODO: initial the profile_tab */
537538
return BT_STATUS_SUCCESS;
538539
}
@@ -548,18 +549,6 @@ void btc_deinit(void)
548549
#if (BLE_INCLUDED == TRUE)
549550
btc_gap_ble_deinit();
550551
#endif ///BLE_INCLUDED == TRUE
551-
#if SCAN_QUEUE_CONGEST_CHECK
552-
btc_adv_list_deinit();
553-
#endif
554-
}
555-
556-
bool btc_check_queue_is_congest(void)
557-
{
558-
if (osi_thread_queue_wait_size(btc_thread, 0) >= BT_QUEUE_CONGEST_SIZE) {
559-
return true;
560-
}
561-
562-
return false;
563552
}
564553

565554
int get_btc_work_queue_size(void)

components/bt/common/btc/include/btc/btc_task.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ bt_status_t btc_inter_profile_call(btc_msg_t *msg);
146146

147147
bt_status_t btc_init(void);
148148
void btc_deinit(void);
149-
bool btc_check_queue_is_congest(void);
150149
int get_btc_work_queue_size(void);
151150

152151
/**

components/bt/host/bluedroid/Kconfig.in

Lines changed: 96 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ config BT_BLE_ENABLED
229229
help
230230
This enables Bluetooth Low Energy
231231

232-
config BT_GATTS_ENABLE
232+
menuconfig BT_GATTS_ENABLE
233233
bool "Include GATT server module(GATTS)"
234234
depends on BT_BLE_ENABLED
235235
default y
@@ -241,8 +241,9 @@ config BT_GATTS_PPCP_CHAR_GAP
241241
depends on BT_GATTS_ENABLE
242242
default n
243243
help
244-
This enables "Peripheral Preferred Connection Parameters" characteristic (UUID: 0x2A04) in GAP service that has
245-
connection parameters like min/max connection interval, slave latency and supervision timeout multiplier
244+
This enables "Peripheral Preferred Connection Parameters" characteristic (UUID: 0x2A04)
245+
in GAP service that has connection parameters like min/max connection interval, slave
246+
latency and supervision timeout multiplier
246247

247248
config BT_BLE_BLUFI_ENABLE
248249
bool "Include blufi function"
@@ -318,7 +319,7 @@ config BT_GATTS_APPEARANCE_WRITABLE
318319
help
319320
Enabling this option allows remote GATT clients to write appearance
320321

321-
config BT_GATTC_ENABLE
322+
menuconfig BT_GATTC_ENABLE
322323
bool "Include GATT client module(GATTC)"
323324
depends on BT_BLE_ENABLED
324325
default y
@@ -356,7 +357,16 @@ config BT_GATTC_CONNECT_RETRY_COUNT
356357
help
357358
The number of attempts to reconnect if the connection establishment failed
358359

359-
config BT_BLE_SMP_ENABLE
360+
config BT_BLE_ESTAB_LINK_CONN_TOUT
361+
int "Timeout of BLE connection establishment"
362+
depends on BT_GATTC_ENABLE
363+
range 1 60
364+
default 30
365+
help
366+
Bluetooth Connection establishment maximum time, if connection time exceeds this value, the connection
367+
establishment fails, ESP_GATTC_OPEN_EVT or ESP_GATTS_OPEN_EVT is triggered.
368+
369+
menuconfig BT_BLE_SMP_ENABLE
360370
bool "Include BLE security module(SMP)"
361371
depends on BT_BLE_ENABLED
362372
default y
@@ -389,6 +399,23 @@ config BT_BLE_SMP_BOND_NVS_FLASH
389399
help
390400
This select can save SMP bonding keys to nvs flash
391401

402+
config BT_BLE_RPA_SUPPORTED
403+
bool "Update RPA to Controller"
404+
depends on (BT_BLE_SMP_ENABLE && ((BT_CONTROLLER_ENABLED && !SOC_BLE_DEVICE_PRIVACY_SUPPORTED) || BT_CONTROLLER_DISABLED)) # NOERROR
405+
default n if (BT_CONTROLLER_ENABLED && !SOC_BLE_DEVICE_PRIVACY_SUPPORTED)
406+
default y if BT_CONTROLLER_DISABLED
407+
help
408+
This enables controller RPA list function.
409+
For ESP32, ESP32 only support network privacy mode. If this option is enabled, ESP32 will only accept
410+
advertising packets from peer devices that contain private address, HW will not receive the advertising
411+
packets contain identity address after IRK changed. If this option is disabled, address resolution will
412+
be performed in the host, so the functions that require controller to resolve address in the white list
413+
cannot be used. This option is disabled by default on ESP32, please enable or disable this option according
414+
to your own needs.
415+
416+
For other BLE chips, devices support network privacy mode and device privacy mode,
417+
users can switch the two modes according to their own needs. So this option is enabled by default.
418+
392419
config BT_STACK_NO_LOG
393420
bool "Disable BT debug logs (minimize bin size)"
394421
depends on BT_BLUEDROID_ENABLED
@@ -1169,15 +1196,6 @@ config BT_BLE_DYNAMIC_ENV_MEMORY
11691196
help
11701197
This select can make the allocation of memory will become more flexible
11711198

1172-
config BT_BLE_HOST_QUEUE_CONG_CHECK
1173-
bool "BLE queue congestion check"
1174-
depends on BT_BLE_ENABLED
1175-
default n
1176-
help
1177-
When scanning and scan duplicate is not enabled, if there are a lot of adv packets around
1178-
or application layer handling adv packets is slow, it will cause the controller memory
1179-
to run out. if enabled, adv packets will be lost when host queue is congested.
1180-
11811199
config BT_SMP_ENABLE
11821200
bool
11831201
depends on BT_BLUEDROID_ENABLED
@@ -1202,15 +1220,6 @@ config BT_BLE_ACT_SCAN_REP_ADV_SCAN
12021220

12031221
# Memory reserved at start of DRAM for Bluetooth stack
12041222

1205-
config BT_BLE_ESTAB_LINK_CONN_TOUT
1206-
int "Timeout of BLE connection establishment"
1207-
depends on BT_BLE_ENABLED
1208-
range 1 60
1209-
default 30
1210-
help
1211-
Bluetooth Connection establishment maximum time, if connection time exceeds this value, the connection
1212-
establishment fails, ESP_GATTC_OPEN_EVT or ESP_GATTS_OPEN_EVT is triggered.
1213-
12141223
config BT_MAX_DEVICE_NAME_LEN
12151224
int "length of bluetooth device name"
12161225
depends on BT_BLUEDROID_ENABLED
@@ -1221,23 +1230,6 @@ config BT_MAX_DEVICE_NAME_LEN
12211230
the complete device name, then only the shortname will be displayed, the rest parts that can't fit in
12221231
will be truncated.
12231232

1224-
config BT_BLE_RPA_SUPPORTED
1225-
bool "Update RPA to Controller"
1226-
depends on (BT_BLUEDROID_ENABLED && ((BT_CONTROLLER_ENABLED && !SOC_BLE_DEVICE_PRIVACY_SUPPORTED) || BT_CONTROLLER_DISABLED)) # NOERROR
1227-
default n if (BT_CONTROLLER_ENABLED && !SOC_BLE_DEVICE_PRIVACY_SUPPORTED)
1228-
default y if BT_CONTROLLER_DISABLED
1229-
help
1230-
This enables controller RPA list function.
1231-
For ESP32, ESP32 only support network privacy mode. If this option is enabled, ESP32 will only accept
1232-
advertising packets from peer devices that contain private address, HW will not receive the advertising
1233-
packets contain identity address after IRK changed. If this option is disabled, address resolution will
1234-
be performed in the host, so the functions that require controller to resolve address in the white list
1235-
cannot be used. This option is disabled by default on ESP32, please enable or disable this option according
1236-
to your own needs.
1237-
1238-
For other BLE chips, devices support network privacy mode and device privacy mode,
1239-
users can switch the two modes according to their own needs. So this option is enabled by default.
1240-
12411233
config BT_BLE_RPA_TIMEOUT
12421234
int "Timeout of resolvable private address"
12431235
depends on BT_BLE_ENABLED
@@ -1247,7 +1239,7 @@ config BT_BLE_RPA_TIMEOUT
12471239
This set RPA timeout of Controller and Host.
12481240
Default is 900 s (15 minutes). Range is 1 s to 1 hour (3600 s).
12491241

1250-
config BT_BLE_50_FEATURES_SUPPORTED
1242+
menuconfig BT_BLE_50_FEATURES_SUPPORTED
12511243
bool "Enable BLE 5.0 features(please disable BLE 4.2 if enable BLE 5.0)"
12521244
depends on (BT_BLE_ENABLED && ((BT_CONTROLLER_ENABLED && SOC_BLE_50_SUPPORTED) || BT_CONTROLLER_DISABLED))
12531245
default y
@@ -1256,15 +1248,40 @@ config BT_BLE_50_FEATURES_SUPPORTED
12561248
This option is universally supported in chips that support BLE, except for ESP32.
12571249
BLE 4.2 and BLE 5.0 cannot be used simultaneously.
12581250

1251+
config BT_BLE_50_EXTEND_ADV_EN
1252+
bool "Enable BLE extend advertising"
1253+
depends on BT_BLE_50_FEATURES_SUPPORTED
1254+
default y
1255+
help
1256+
This enables BLE extend advertising
1257+
1258+
config BT_BLE_50_PERIODIC_ADV_EN
1259+
bool "Enable BLE periodic advertising"
1260+
depends on BT_BLE_50_FEATURES_SUPPORTED
1261+
default y
1262+
help
1263+
This enables BLE periodic advertising
12591264

1260-
config BT_BLE_42_FEATURES_SUPPORTED
1261-
bool "Enable BLE 4.2 features(please disable BLE 5.0 if enable BLE 4.2)"
1262-
depends on (BT_BLE_ENABLED && ((BT_CONTROLLER_ENABLED && SOC_BLE_50_SUPPORTED) || BT_CONTROLLER_DISABLED))
1263-
default n
1265+
config BT_BLE_50_EXTEND_SCAN_EN
1266+
bool "Enable BLE extend scan"
1267+
depends on BT_BLE_50_FEATURES_SUPPORTED
1268+
default y
12641269
help
1265-
This enables BLE 4.2 features.
1266-
This option is universally supported by all ESP chips with BLE capabilities.
1267-
BLE 4.2 and BLE 5.0 cannot be used simultaneously.
1270+
This enables BLE extend scan
1271+
1272+
config BT_BLE_50_EXTEND_SYNC_EN
1273+
bool "Enable BLE periodic advertising sync"
1274+
depends on BT_BLE_50_FEATURES_SUPPORTED
1275+
default y
1276+
help
1277+
This enables BLE periodic advertising sync
1278+
1279+
config BT_BLE_50_DTM_TEST_EN
1280+
bool "Enable BLE 5.0 DTM test"
1281+
depends on BT_BLE_50_FEATURES_SUPPORTED
1282+
default y
1283+
help
1284+
This enables BLE 5.0 direct test mode
12681285

12691286
config BT_BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER
12701287
bool "Enable BLE periodic advertising sync transfer feature"
@@ -1287,6 +1304,37 @@ config BT_BLE_FEAT_CREATE_SYNC_ENH
12871304
help
12881305
Enable the create sync enhancements
12891306

1307+
menuconfig BT_BLE_42_FEATURES_SUPPORTED
1308+
bool "Enable BLE 4.2 features(please disable BLE 5.0 if enable BLE 4.2)"
1309+
depends on BT_BLE_ENABLED
1310+
default y if IDF_TARGET_ESP32
1311+
default n
1312+
help
1313+
This enables BLE 4.2 features.
1314+
This option is universally supported by all ESP chips with BLE capabilities.
1315+
BLE 4.2 and BLE 5.0 cannot be used simultaneously.
1316+
1317+
config BT_BLE_42_DTM_TEST_EN
1318+
bool "Enable BLE 4.2 DTM test"
1319+
depends on BT_BLE_42_FEATURES_SUPPORTED
1320+
default y
1321+
help
1322+
This enables BLE 4.2 direct test mode
1323+
1324+
config BT_BLE_42_ADV_EN
1325+
bool "Enable BLE 4.2 advertising"
1326+
depends on BT_BLE_42_FEATURES_SUPPORTED
1327+
default y
1328+
help
1329+
This enables BLE v4.2 advertising
1330+
1331+
config BT_BLE_42_SCAN_EN
1332+
bool "Enable BLE 4.2 scan"
1333+
depends on BT_BLE_42_FEATURES_SUPPORTED
1334+
default y
1335+
help
1336+
This enables BLE v4.2 scan
1337+
12901338
config BT_BLE_HIGH_DUTY_ADV_INTERVAL
12911339
bool "Enable BLE high duty advertising interval feature"
12921340
depends on BT_BLE_ENABLED

0 commit comments

Comments
 (0)