Skip to content

Commit 1d73929

Browse files
feat(ble/controller): Reduce bin size and IRAM for BLE rom code
1 parent 644e38f commit 1d73929

File tree

13 files changed

+199
-105
lines changed

13 files changed

+199
-105
lines changed

components/bt/controller/esp32c3/Kconfig.in

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ config BT_CTRL_DFT_TX_POWER_LEVEL_EFF
231231

232232
config BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP
233233
bool "BLE adv report flow control supported"
234-
depends on (!BT_CTRL_RUN_IN_FLASH_ONLY) || (BT_CTRL_RUN_IN_FLASH_ONLY && BT_CTRL_BLE_SCAN)
234+
depends on BT_CTRL_BLE_SCAN
235235
default y
236236
help
237237
The function is mainly used to enable flow control for advertising reports. When it is enabled,
@@ -530,30 +530,31 @@ config BT_CTRL_RUN_IN_FLASH_ONLY
530530
impact on Bluetooth performance.
531531

532532
config BT_CTRL_DTM_ENABLE
533-
depends on BT_CTRL_RUN_IN_FLASH_ONLY
534533
bool "Enable direct test mode feature"
535-
default n
534+
default y
536535

537536
config BT_CTRL_BLE_MASTER
538-
depends on BT_CTRL_RUN_IN_FLASH_ONLY
539-
bool "Enable BLE master role feature"
537+
bool "Enable BLE connection feature"
540538
default y
539+
help
540+
If this option is disabled, it is not recommended to use connectable ADV.
541541

542542
config BT_CTRL_BLE_TEST
543-
depends on BT_CTRL_RUN_IN_FLASH_ONLY
544-
bool "Enable BLE QA test feature"
543+
bool "Enable BLE QA test feature (Not Used)"
545544
default n
546545

547546
config BT_CTRL_BLE_SCAN
548-
depends on BT_CTRL_RUN_IN_FLASH_ONLY
549547
bool "Enable BLE scan feature"
550548
default y
551549

552550
config BT_CTRL_BLE_SECURITY_ENABLE
553-
depends on BT_CTRL_RUN_IN_FLASH_ONLY
554551
bool "Enable BLE security feature"
555552
default y
556553

554+
config BT_CTRL_BLE_ADV
555+
bool "Enable BLE ADV feature"
556+
default y
557+
557558
config BT_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
558559
bool "Enable enhanced Access Address check in CONNECT_IND"
559560
default n

components/bt/controller/esp32c3/bt.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,17 @@ extern void advFilter_stack_enableDupExcListVsCmd(bool en);
312312
extern void chanSel_stack_enableSetCsaVsCmd(bool en);
313313
#endif // (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED)
314314

315+
extern void ble_dtm_funcs_reset(void);
316+
extern void ble_scan_funcs_reset(void);
317+
extern void ble_42_adv_funcs_reset(void);
318+
extern void ble_init_funcs_reset(void);
319+
extern void ble_con_funcs_reset(void);
320+
extern void ble_cca_funcs_reset(void);
321+
extern void ble_ext_adv_funcs_reset(void);
322+
extern void ble_ext_scan_funcs_reset(void);
323+
extern void ble_base_funcs_reset(void);
324+
extern void ble_enc_funcs_reset(void);
325+
315326
extern uint32_t _bt_bss_start;
316327
extern uint32_t _bt_bss_end;
317328
extern uint32_t _bt_controller_bss_start;
@@ -1265,6 +1276,46 @@ static void btdm_funcs_table_ready_wrapper(void)
12651276
#if BLE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED
12661277
btdm_aa_check_enhance_enable();
12671278
#endif
1279+
#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
1280+
// do nothing
1281+
#else
1282+
ESP_LOGI(BT_LOG_TAG, "Feature Config, ADV:%d, BLE_50:%d, DTM:%d, SCAN:%d, CCA:%d, SMP:%d, CONNECT:%d",
1283+
BT_CTRL_BLE_ADV, BT_CTRL_50_FEATURE_SUPPORT, BT_CTRL_DTM_ENABLE, BT_CTRL_BLE_SCAN,
1284+
BT_BLE_CCA_MODE, BLE_SECURITY_ENABLE, BT_CTRL_BLE_MASTER);
1285+
1286+
ble_base_funcs_reset();
1287+
#if CONFIG_BT_CTRL_BLE_ADV
1288+
ble_42_adv_funcs_reset();
1289+
#if (BT_CTRL_50_FEATURE_SUPPORT == 1)
1290+
ble_ext_adv_funcs_reset();
1291+
#endif //
1292+
#endif // CONFIG_BT_CTRL_BLE_ADV
1293+
1294+
#if CONFIG_BT_CTRL_DTM_ENABLE
1295+
ble_dtm_funcs_reset();
1296+
#endif // CONFIG_BT_CTRL_DTM_ENABLE
1297+
1298+
#if CONFIG_BT_CTRL_BLE_SCAN
1299+
ble_scan_funcs_reset();
1300+
#if (BT_CTRL_50_FEATURE_SUPPORT == 1)
1301+
ble_ext_scan_funcs_reset();
1302+
#endif // (BT_CTRL_50_FEATURE_SUPPORT == 1)
1303+
#endif // CONFIG_BT_CTRL_BLE_SCAN
1304+
1305+
#if (BT_BLE_CCA_MODE != 0)
1306+
ble_cca_funcs_reset();
1307+
#endif // (BT_BLE_CCA_MODE != 0)
1308+
1309+
#if CONFIG_BT_CTRL_BLE_SECURITY_ENABLE
1310+
ble_enc_funcs_reset();
1311+
#endif // CONFIG_BT_CTRL_BLE_SECURITY_ENABLE
1312+
1313+
#if CONFIG_BT_CTRL_BLE_MASTER
1314+
ble_init_funcs_reset();
1315+
ble_con_funcs_reset();
1316+
#endif // CONFIG_BT_CTRL_BLE_MASTER
1317+
1318+
#endif // CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
12681319
}
12691320

12701321
bool bt_async_wakeup_request(void)

components/bt/include/esp32c3/include/esp_bt.h

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ extern "C" {
3030
*
3131
* @note Please do not modify this value
3232
*/
33-
#define ESP_BT_CTRL_CONFIG_VERSION 0x02502230
33+
#define ESP_BT_CTRL_CONFIG_VERSION 0x02505080
3434

3535
/**
3636
* @brief Internal use only
@@ -268,7 +268,7 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);
268268
#define BT_CTRL_RUN_IN_FLASH_ONLY (0)
269269
#endif
270270

271-
#if (BT_CTRL_RUN_IN_FLASH_ONLY == 1)
271+
272272

273273
#if defined(CONFIG_BT_CTRL_DTM_ENABLE)
274274
#define BT_CTRL_DTM_ENABLE CONFIG_BT_CTRL_DTM_ENABLE
@@ -288,34 +288,23 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);
288288
#define BT_CTRL_BLE_TEST (0)
289289
#endif
290290

291-
#if defined (CONFIG_BT_NIMBLE_SECURITY_ENABLE) || defined (CONFIG_BT_BLE_SMP_ENABLE)
292-
#ifdef CONFIG_BT_NIMBLE_SECURITY_ENABLE
293-
#define BLE_SECURITY_ENABLE (CONFIG_BT_NIMBLE_SECURITY_ENABLE)
294-
#endif //CONFIG_BT_NIMBLE_SECURITY_ENABLE
295-
#ifdef CONFIG_BT_BLE_SMP_ENABLE
296-
#define BLE_SECURITY_ENABLE (CONFIG_BT_BLE_SMP_ENABLE)
297-
#endif //CONFIG_BT_BLE_SMP_ENABLE
298-
#else
299291
#if defined (CONFIG_BT_CTRL_BLE_SECURITY_ENABLE)
300292
#define BLE_SECURITY_ENABLE (CONFIG_BT_CTRL_BLE_SECURITY_ENABLE)
301293
#else
302294
#define BLE_SECURITY_ENABLE (0)
303295
#endif
304-
#endif // (CONFIG_BT_NIMBLE_SECURITY_ENABLE) || (CONFIG_BT_BLE_SMP_ENABLE)
305296

306297
#if defined (CONFIG_BT_CTRL_BLE_SCAN)
307298
#define BT_CTRL_BLE_SCAN CONFIG_BT_CTRL_BLE_SCAN
308299
#else
309300
#define BT_CTRL_BLE_SCAN (0)
310301
#endif
311302

303+
#if defined (CONFIG_BT_CTRL_BLE_ADV)
304+
#define BT_CTRL_BLE_ADV CONFIG_BT_CTRL_BLE_ADV
312305
#else
313-
#define BT_CTRL_BLE_MASTER (1)
314-
#define BT_CTRL_DTM_ENABLE (1)
315-
#define BT_CTRL_BLE_TEST (1)
316-
#define BLE_SECURITY_ENABLE (1)
317-
#define BT_CTRL_BLE_SCAN (1)
318-
#endif // (BT_CTRL_RUN_IN_FLASH_ONLY == 1)
306+
#define BT_CTRL_BLE_ADV (0)
307+
#endif
319308

320309
#ifdef CONFIG_BT_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
321310
#define BLE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED CONFIG_BT_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
@@ -384,11 +373,12 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);
384373
.dtm_en = BT_CTRL_DTM_ENABLE, \
385374
.enc_en = BLE_SECURITY_ENABLE, \
386375
.qa_test = BT_CTRL_BLE_TEST, \
387-
.master_en = BT_CTRL_BLE_MASTER, \
376+
.connect_en = BT_CTRL_BLE_MASTER, \
388377
.scan_en = BT_CTRL_BLE_SCAN, \
389378
.ble_aa_check = BLE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED, \
390379
.ble_log_mode_en = BLE_LOG_MODE_EN, \
391380
.ble_log_level = BLE_LOG_LEVEL, \
381+
.adv_en = BT_CTRL_BLE_ADV, \
392382
}
393383

394384
#else
@@ -508,14 +498,15 @@ typedef struct {
508498
uint8_t ble_llcp_disc_flag; /*!< Flag indicating whether the Controller disconnects after Instant Passed (0x28) error occurs. Configurable in menuconfig.
509499
- The Controller does not disconnect after Instant Passed (0x28) by default. */
510500
bool run_in_flash; /*!< True if the Controller code is in flash (flash model); false otherwise (default). Configurable in menuconfig. */
511-
bool dtm_en; /*!< In the flash mode, True if the DTM feature is enabled; false otherwise (default). Configurable in menuconfig. */
512-
bool enc_en; /*!< In the flash mode, True if the encryption feature is enabled (default); false otherwise. Configurable in menuconfig. */
513-
bool qa_test; /*!< In the flash mode, True if the QA test feature is enabled; false otherwise (default). Configurable in menuconfig.*/
514-
bool master_en; /*!< In the flash mode, True if the master feature is enabled (default); false otherwise. Configurable in menuconfig.*/
515-
bool scan_en; /*!< In the flash mode, True if the scan feature is enabled (default); false otherwise. Configurable in menuconfig.*/
501+
bool dtm_en; /*!< True if the DTM feature is enabled; false otherwise (default). Configurable in menuconfig. */
502+
bool enc_en; /*!< True if the encryption feature is enabled (default); false otherwise. Configurable in menuconfig. */
503+
bool qa_test; /*!< True if the QA test feature is enabled; false otherwise (default). Configurable in menuconfig.*/
504+
bool connect_en; /*!< True if the connection feature is enabled (default); false otherwise. Configurable in menuconfig.*/
505+
bool scan_en; /*!< True if the scan feature is enabled (default); false otherwise. Configurable in menuconfig.*/
516506
bool ble_aa_check; /*!< True if adds a verification step for the Access Address within the CONNECT_IND PDU; false otherwise. Configurable in menuconfig */
517507
uint32_t ble_log_mode_en; /*!< BLE log mode enable */
518508
uint8_t ble_log_level; /*!< BLE log level */
509+
bool adv_en; /*!< True if the ADV feature is enabled (default); false otherwise. Configurable in menuconfig.*/
519510
} esp_bt_controller_config_t;
520511

521512
/**

components/esp_rom/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ else() # Regular app build
222222
endif()
223223

224224
elseif(target STREQUAL "esp32c3")
225-
if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY AND NOT CONFIG_BT_CTRL_HCI_MODE_UART_H4)
225+
if(NOT CONFIG_BT_CTRL_HCI_MODE_UART_H4)
226226
if(NOT CONFIG_BT_CTRL_BLE_MASTER)
227227
rom_linker_script("ble_master")
228228
endif()
@@ -262,7 +262,7 @@ else() # Regular app build
262262
endif()
263263
endif()
264264
elseif(target STREQUAL "esp32s3")
265-
if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY AND NOT CONFIG_BT_CTRL_HCI_MODE_UART_H4)
265+
if(NOT CONFIG_BT_CTRL_HCI_MODE_UART_H4)
266266
if(NOT CONFIG_BT_CTRL_BLE_MASTER)
267267
rom_linker_script("ble_master")
268268
endif()

components/esp_rom/esp32c3/ld/esp32c3.rom.ble_50.ld

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ f_lld_per_adv_rep_ind_handler = 0;
6565
r_lld_sync_init = 0;
6666

6767
/* phy update*/
68-
r_phy_upd_proc_start = 0;
6968
f_llc_op_phy_upd_ind_handler = 0;
7069
f_ll_phy_req_handler = 0;
7170
f_ll_phy_rsp_handler = 0;

components/esp_rom/esp32c3/ld/esp32c3.rom.ble_smp.ld

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ r_rwip_crypt_evt_handler = 0;
3333
/* LE ping */
3434
f_ll_ping_req_handler = 0;
3535
f_ll_ping_rsp_handler = 0;
36-
r_llc_le_ping_set = 0;
37-
r_llc_le_ping_restart = 0;
3836
f_llc_op_le_ping_ind_handler = 0;
3937
f_llc_auth_payl_nearly_op_handler = 0;
4038
f_llc_auth_payl_real_to_handler = 0;

0 commit comments

Comments
 (0)