Skip to content

Commit 148aa32

Browse files
committed
Merge branch 'feat/optimzie_ble_ctrl_memory' into 'master'
ble: support only legacy adv and slave function on esp32c2 Closes BLERP-675 See merge request espressif/esp-idf!30186
2 parents 7cbbabb + c31a06d commit 148aa32

File tree

7 files changed

+81
-14
lines changed

7 files changed

+81
-14
lines changed

components/bt/CMakeLists.txt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -847,17 +847,8 @@ if(CONFIG_BT_ENABLED)
847847
target_link_directories(${COMPONENT_LIB} INTERFACE
848848
"${CMAKE_CURRENT_LIST_DIR}/controller/lib_esp32c3_family/esp32s3")
849849
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app)
850-
elseif(CONFIG_IDF_TARGET_ESP32C2 AND CONFIG_BT_CONTROLLER_ENABLED)
851-
add_prebuilt_library(libble_app "controller/lib_esp32c2/esp32c2-bt-lib/libble_app.a")
852-
target_link_libraries(${COMPONENT_LIB} PRIVATE libble_app)
853-
elseif(CONFIG_IDF_TARGET_ESP32C6 AND CONFIG_BT_CONTROLLER_ENABLED)
854-
add_prebuilt_library(libble_app "controller/lib_esp32c6/esp32c6-bt-lib/libble_app.a")
855-
target_link_libraries(${COMPONENT_LIB} PRIVATE libble_app)
856-
elseif(CONFIG_IDF_TARGET_ESP32H2 AND CONFIG_BT_CONTROLLER_ENABLED)
857-
add_prebuilt_library(libble_app "controller/lib_esp32h2/esp32h2-bt-lib/libble_app.a")
858-
target_link_libraries(${COMPONENT_LIB} PRIVATE libble_app)
859-
elseif(CONFIG_IDF_TARGET_ESP32C5 AND CONFIG_BT_CONTROLLER_ENABLED)
860-
add_prebuilt_library(libble_app "controller/lib_esp32c5/esp32c5-bt-lib/libble_app.a")
850+
elseif(CONFIG_BT_CONTROLLER_ENABLED)
851+
add_prebuilt_library(libble_app "controller/lib_${target}/${target}-bt-lib/libble_app.a")
861852
target_link_libraries(${COMPONENT_LIB} PRIVATE libble_app)
862853
endif()
863854

components/bt/controller/esp32c2/Kconfig.in

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ config BT_LE_USE_ESP_TIMER
450450

451451
config BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP
452452
bool "BLE adv report flow control supported"
453+
depends on BT_LE_ROLE_OBSERVER_ENABLE
453454
default y
454455
help
455456
The function is mainly used to enable flow control for advertising reports. When it is enabled,
@@ -498,3 +499,31 @@ config BT_LE_CCA_RSSI_THRESH
498499
default 20
499500
help
500501
Power threshold of CCA in unit of -1 dBm.
502+
503+
config BT_LE_ROLE_CENTROL_ENABLE
504+
bool "Enable BLE Centrol role function"
505+
depends on !BT_NIMBLE_ENABLED
506+
default y
507+
help
508+
Enable centrol role function.
509+
510+
config BT_LE_ROLE_PERIPHERAL_ENABLE
511+
bool "Enable BLE Peripheral role function"
512+
depends on !BT_NIMBLE_ENABLED
513+
default y
514+
help
515+
Enable Peripheral role function.
516+
517+
config BT_LE_ROLE_BROADCASTER_ENABLE
518+
bool "Enable BLE Broadcaster role function"
519+
depends on !BT_NIMBLE_ENABLED
520+
default y
521+
help
522+
Enable broadcaster role function.
523+
524+
config BT_LE_ROLE_OBSERVER_ENABLE
525+
bool "Enable BLE Observer role function"
526+
depends on !BT_NIMBLE_ENABLED
527+
default y
528+
help
529+
Enable observer role function.

components/bt/controller/esp32c2/bt.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,15 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
652652
return ret;
653653
}
654654

655+
#if DEFAULT_BT_LE_50_FEATURE_SUPPORT || DEFAULT_BT_LE_ROLE_CENTROL || DEFAULT_BT_LE_ROLE_OBSERVER
656+
extern int esp_ble_rom_func_ptr_init_all(void);
657+
esp_ble_rom_func_ptr_init_all();
658+
#else
659+
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Init only legacy adv and slave function");
660+
extern int esp_ble_rom_func_ptr_init_legacy_adv_and_slave(void);
661+
esp_ble_rom_func_ptr_init_legacy_adv_and_slave();
662+
#endif
663+
655664
/* Initialize the function pointers for OS porting */
656665
npl_freertos_funcs_init();
657666
struct npl_funcs_t *p_npl_funcs = npl_freertos_funcs_get();

components/bt/controller/esp32c2/esp_bt_cfg.h

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ extern "C" {
4646
#define DEFAULT_BT_LE_50_FEATURE_SUPPORT (0)
4747
#endif
4848

49+
#define DEFAULT_BT_LE_ROLE_OBSERVER MYNEWT_VAL(BLE_ROLE_OBSERVER)
50+
#define DEFAULT_BT_LE_ROLE_CENTROL MYNEWT_VAL(BLE_ROLE_CENTRAL)
51+
#define DEFAULT_BT_LE_ROLE_PERIPHERAL MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
52+
#define DEFAULT_BT_LE_ROLE_BROADCASTER MYNEWT_VAL(BLE_ROLE_BROADCASTER)
4953
#else
5054

5155
#if CONFIG_BT_LE_LL_CFG_FEAT_LE_CODED_PHY
@@ -57,13 +61,13 @@ extern "C" {
5761
#if defined(CONFIG_BT_LE_MAX_PERIODIC_ADVERTISER_LIST)
5862
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (CONFIG_BT_LE_MAX_PERIODIC_ADVERTISER_LIST)
5963
#else
60-
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (5)
64+
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (0)
6165
#endif
6266

6367
#if defined(CONFIG_BT_LE_MAX_PERIODIC_SYNCS)
6468
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (CONFIG_BT_LE_MAX_PERIODIC_SYNCS)
6569
#else
66-
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (1)
70+
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (0)
6771
#endif
6872

6973
#if defined(CONFIG_BT_LE_MAX_CONNECTIONS)
@@ -125,6 +129,29 @@ extern "C" {
125129
#define DEFAULT_BT_LE_50_FEATURE_SUPPORT (0)
126130
#endif
127131

132+
#if defined(CONFIG_BT_LE_ROLE_CENTROL_ENABLE)
133+
#define DEFAULT_BT_LE_ROLE_CENTROL (1)
134+
#else
135+
#define DEFAULT_BT_LE_ROLE_CENTROL (0)
136+
#endif
137+
138+
#if defined(CONFIG_BT_LE_ROLE_PERIPHERAL_ENABLE)
139+
#define DEFAULT_BT_LE_ROLE_PERIPHERAL (1)
140+
#else
141+
#define DEFAULT_BT_LE_ROLE_PERIPHERAL (0)
142+
#endif
143+
144+
#if defined(CONFIG_BT_LE_ROLE_BROADCASTER_ENABLE)
145+
#define DEFAULT_BT_LE_ROLE_BROADCASTER (1)
146+
#else
147+
#define DEFAULT_BT_LE_ROLE_BROADCASTER (0)
148+
#endif
149+
150+
#if defined(CONFIG_BT_LE_ROLE_OBSERVER_ENABLE)
151+
#define DEFAULT_BT_LE_ROLE_OBSERVER (1)
152+
#else
153+
#define DEFAULT_BT_LE_ROLE_OBSERVER (0)
154+
#endif
128155
#endif
129156

130157
#define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF

examples/bluetooth/blufi/sdkconfig.defaults.esp32c2

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,10 @@ CONFIG_BT_NIMBLE_BLUFI_ENABLE=y
99
# CONFIG_BT_BLE_50_FEATURES_SUPPORTED is not set
1010
CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y
1111
CONFIG_MBEDTLS_DHM_C=y
12+
# The config items for NIMBLE HOST
1213
CONFIG_BT_NIMBLE_ENABLED=y
14+
CONFIG_BT_NIMBLE_ROLE_CENTRAL=n
15+
CONFIG_BT_NIMBLE_ROLE_OBSERVER=n
16+
CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT=n
17+
CONFIG_BT_NIMBLE_SECURITY_ENABLE=n
18+
CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS=n

examples/bluetooth/blufi/sdkconfig.defaults.esp32c6

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,10 @@ CONFIG_BT_NIMBLE_BLUFI_ENABLE=y
99
# CONFIG_BT_BLE_50_FEATURES_SUPPORTED is not set
1010
CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y
1111
CONFIG_MBEDTLS_DHM_C=y
12+
# The config items for NIMBLE HOST
1213
CONFIG_BT_NIMBLE_ENABLED=y
14+
CONFIG_BT_NIMBLE_ROLE_CENTRAL=n
15+
CONFIG_BT_NIMBLE_ROLE_OBSERVER=n
1316
CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT=n
17+
CONFIG_BT_NIMBLE_SECURITY_ENABLE=n
18+
CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS=n

0 commit comments

Comments
 (0)