Skip to content

Commit

Permalink
Merge branch 'espressif:release/v5.1' into release/v5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason2866 authored Nov 30, 2024
2 parents 57d5119 + 024c6de commit cca1b35
Show file tree
Hide file tree
Showing 196 changed files with 9,146 additions and 5,700 deletions.
21 changes: 18 additions & 3 deletions components/bt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ if(CONFIG_BT_ENABLED)
elseif(CONFIG_IDF_TARGET_ESP32C2)
list(APPEND srcs "controller/esp32c2/bt.c")
list(APPEND include_dirs include/esp32c2/include)
if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY)
list(APPEND srcs "controller/esp32c2/dummy.c")
endif()
set(ldscripts "linker_esp32c2.lf")

elseif(CONFIG_IDF_TARGET_ESP32C6)
Expand Down Expand Up @@ -781,16 +784,28 @@ if(CONFIG_BT_ENABLED)
elseif(CONFIG_IDF_TARGET_ESP32C3)
target_link_directories(${COMPONENT_LIB} INTERFACE
"${CMAKE_CURRENT_LIST_DIR}/controller/lib_esp32c3_family/esp32c3")
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app)
if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY)
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app_flash)
else()
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app)
endif()
elseif(CONFIG_IDF_TARGET_ESP32S3)
target_link_directories(${COMPONENT_LIB} INTERFACE
"${CMAKE_CURRENT_LIST_DIR}/controller/lib_esp32c3_family/esp32s3")
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app)
if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY)
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app_flash)
else()
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app)
endif()
elseif(CONFIG_BT_CONTROLLER_ENABLED)
if(CONFIG_IDF_TARGET_ESP32C6)
add_prebuilt_library(libble_app "controller/lib_${target}/${target}-bt-lib/esp32c6/libble_app.a")
else()
add_prebuilt_library(libble_app "controller/lib_${target}/${target}-bt-lib/libble_app.a")
if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY)
add_prebuilt_library(libble_app "controller/lib_${target}/${target}-bt-lib/libble_app_flash.a")
else()
add_prebuilt_library(libble_app "controller/lib_${target}/${target}-bt-lib/libble_app.a")
endif()
endif()
target_link_libraries(${COMPONENT_LIB} PRIVATE libble_app)
endif()
Expand Down
26 changes: 26 additions & 0 deletions components/bt/controller/esp32/Kconfig.in
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,15 @@ config BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
minimize collision of scan request PDUs from nultiple scanners. If scan backoff is disabled, in active
scanning, scan request PDU will be sent every time when HW receives scannable ADV PDU.

config BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
bool "Enable enhanced Access Address check in CONNECT_IND"
default n
help
Enabling this option will add stricter verification of the Access Address in the CONNECT_IND PDU.
This improves security by ensuring that only connection requests with valid Access Addresses are accepted.
If disabled, only basic checks are applied, improving compatibility.


config BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP
bool "BLE adv report flow control supported"
depends on (BTDM_CTRL_MODE_BTDM || BTDM_CTRL_MODE_BLE_ONLY)
Expand Down Expand Up @@ -440,6 +449,23 @@ config BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD
If you set `BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD` to a small value or printf every adv lost event, it
may cause adv packets lost more.

menu "BLE disconnect when instant passed"
config BTDM_BLE_LLCP_CONN_UPDATE
bool "BLE ACL connection update procedure"
depends on (BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM)
default n
help
If this option is enabled, Controller will terminate the connection
when instant passed during connection update procedure.

config BTDM_BLE_LLCP_CHAN_MAP_UPDATE
bool "BLE ACL channel map update procedure"
depends on (BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM)
default n
help
If this option is enabled, Controller will terminate the connection
when instant passed in channel map update procedure.
endmenu

config BTDM_RESERVE_DRAM
hex
Expand Down
178 changes: 110 additions & 68 deletions components/bt/controller/esp32c2/Kconfig.in
Original file line number Diff line number Diff line change
Expand Up @@ -109,85 +109,99 @@ menuconfig BT_LE_50_FEATURE_SUPPORT
help
Enable BLE 5 feature

config BT_LE_LL_CFG_FEAT_LE_2M_PHY
bool "Enable 2M Phy"
depends on BT_LE_50_FEATURE_SUPPORT
default y
help
Enable 2M-PHY

config BT_LE_LL_CFG_FEAT_LE_CODED_PHY
bool "Enable coded Phy"
depends on BT_LE_50_FEATURE_SUPPORT
default y
help
Enable coded-PHY

config BT_LE_EXT_ADV
bool "Enable extended advertising"
depends on BT_LE_50_FEATURE_SUPPORT
default y
help
Enable this option to do extended advertising. Extended advertising
will be supported from BLE 5.0 onwards.

if BT_LE_EXT_ADV
config BT_LE_MAX_EXT_ADV_INSTANCES
int "Maximum number of extended advertising instances."
range 0 4
default 1
depends on BT_LE_EXT_ADV
help
Change this option to set maximum number of extended advertising
instances. Minimum there is always one instance of
advertising. Enter how many more advertising instances you
want.
Each extended advertising instance will take about 0.5k DRAM.

config BT_LE_EXT_ADV_MAX_SIZE
int "Maximum length of the advertising data."
range 0 1650
default 1650
depends on BT_LE_EXT_ADV
if BT_LE_50_FEATURE_SUPPORT
config BT_LE_LL_CFG_FEAT_LE_2M_PHY
bool "Enable 2M Phy"
depends on BT_LE_50_FEATURE_SUPPORT
default y
help
Defines the length of the extended adv data. The value should not
exceed 1650.
Enable 2M-PHY

config BT_LE_ENABLE_PERIODIC_ADV
bool "Enable periodic advertisement."
config BT_LE_LL_CFG_FEAT_LE_CODED_PHY
bool "Enable coded Phy"
depends on BT_LE_50_FEATURE_SUPPORT
default y
depends on BT_LE_EXT_ADV
help
Enable this option to start periodic advertisement.
Enable coded-PHY

config BT_LE_PERIODIC_ADV_SYNC_TRANSFER
bool "Enable Transfer Sync Events"
depends on BT_LE_ENABLE_PERIODIC_ADV
config BT_LE_EXT_ADV
bool "Enable extended advertising"
depends on BT_LE_50_FEATURE_SUPPORT
default y
help
This enables controller transfer periodic sync events to host
Enable this option to do extended advertising. Extended advertising
will be supported from BLE 5.0 onwards.

if BT_LE_EXT_ADV
config BT_LE_MAX_EXT_ADV_INSTANCES
int "Maximum number of extended advertising instances."
range 0 4
default 1
depends on BT_LE_EXT_ADV
help
Change this option to set maximum number of extended advertising
instances. Minimum there is always one instance of
advertising. Enter how many more advertising instances you
want.
Each extended advertising instance will take about 0.5k DRAM.

config BT_LE_EXT_ADV_MAX_SIZE
int "Maximum length of the advertising data."
range 0 1650
default 1650
depends on BT_LE_EXT_ADV
help
Defines the length of the extended adv data. The value should not
exceed 1650.

endif
config BT_LE_ENABLE_PERIODIC_ADV
bool "Enable periodic advertisement."
default y
depends on BT_LE_EXT_ADV
help
Enable this option to start periodic advertisement.

config BT_LE_MAX_PERIODIC_SYNCS
int "Maximum number of periodic advertising syncs"
depends on BT_LE_50_FEATURE_SUPPORT && !BT_NIMBLE_ENABLED
config BT_LE_PERIODIC_ADV_SYNC_TRANSFER
bool "Enable Transfer Sync Events"
depends on BT_LE_ENABLE_PERIODIC_ADV
default y
help
This enables controller transfer periodic sync events to host
endif

range 0 3
default 1 if BT_LE_ENABLE_PERIODIC_ADV
default 0
help
Set this option to set the upper limit for number of periodic sync
connections. This should be less than maximum connections allowed by
controller.
config BT_LE_EXT_SCAN
bool "Enable extended scanning"
depends on BT_LE_50_FEATURE_SUPPORT && BT_LE_ROLE_OBSERVER_ENABLE
default y
help
Enable this option to do extended scanning.

config BT_LE_MAX_PERIODIC_ADVERTISER_LIST
int "Maximum number of periodic advertiser list"
depends on BT_LE_50_FEATURE_SUPPORT && !BT_NIMBLE_ENABLED
range 1 5
default 5
help
Set this option to set the upper limit for number of periodic advertiser list.
config BT_LE_ENABLE_PERIODIC_SYNC
bool "Enable periodic sync"
default y
depends on BT_LE_EXT_SCAN
help
Enable this option to receive periodic advertisement.

if BT_LE_ENABLE_PERIODIC_SYNC
config BT_LE_MAX_PERIODIC_SYNCS
int "Maximum number of periodic advertising syncs"
range 0 3
default 1 if BT_LE_ENABLE_PERIODIC_ADV
default 0
help
Set this option to set the upper limit for number of periodic sync
connections. This should be less than maximum connections allowed by
controller.

config BT_LE_MAX_PERIODIC_ADVERTISER_LIST
int "Maximum number of periodic advertiser list"
range 1 5
default 5
help
Set this option to set the upper limit for number of periodic advertiser list.
endif
endif

menu "Memory Settings"
depends on !BT_NIMBLE_ENABLED
Expand Down Expand Up @@ -522,6 +536,10 @@ config BT_LE_TX_CCA_ENABLED
help
Enable CCA feature to cancel sending the packet if the signal power is stronger than CCA threshold.

config BT_LE_DTM_ENABLED
bool "Enable Direct Test Mode (DTM) feature"
default n

config BT_LE_CCA_RSSI_THRESH
int "CCA RSSI threshold value"
depends on BT_LE_TX_CCA_ENABLED
Expand All @@ -530,6 +548,10 @@ config BT_LE_CCA_RSSI_THRESH
help
Power threshold of CCA in unit of -1 dBm.

config BT_LE_FEAT_LL_ENCRYPTION
bool "Enable controller ACL encryption"
default y

config BT_LE_ROLE_CENTROL_ENABLE
bool "Enable BLE Centrol role function"
depends on !BT_NIMBLE_ENABLED
Expand Down Expand Up @@ -616,3 +638,23 @@ config BT_LE_DFT_TX_POWER_LEVEL_DBM_EFF
default 18 if BT_LE_DFT_TX_POWER_LEVEL_P18
default 20 if BT_LE_DFT_TX_POWER_LEVEL_P20
default 0

config BT_CTRL_RUN_IN_FLASH_ONLY
bool "Reduce BLE IRAM usage (READ DOCS FIRST) (EXPERIMENTAL)"
default n
help
Move most IRAM into flash. This will increase the usage of flash and reduce ble performance.
Because the code is moved to the flash, the execution speed of the code is reduced.
To have a small impact on performance, you need to enable flash suspend (SPI_FLASH_AUTO_SUSPEND).

- Only one Tx-Rx can be performed in each connection interval. Therefore, reduce the connection interval
as much as possible to improve the throughput. If you want higher connection performance, you can
enable BT_LE_PLACE_CONN_RELATED_INTO_IRAM to put the connection-related code into iram.
- For HCI_LE_Extended_Create_Connection command, only 1M phy's connection parameters will be applied.
Other phys' will be ignored.
- For extended scanning, we may be unable to receive the extended adv with 300us MAFS.

config BT_LE_PLACE_CONN_RELATED_INTO_IRAM
bool "Place the connection-related code into IRAM"
depends on BT_CTRL_RUN_IN_FLASH_ONLY
default n
17 changes: 17 additions & 0 deletions components/bt/controller/esp32c2/bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ extern int ble_get_npl_element_info(esp_bt_controller_config_t *cfg, ble_npl_cou
extern void bt_track_pll_cap(void);
extern char *ble_controller_get_compile_version(void);
extern const char *r_ble_controller_get_rom_compile_version(void);
#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
extern void ble_ll_supported_features_init(void);
#endif //CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY

#if CONFIG_BT_RELEASE_IRAM
extern uint32_t _iram_bt_text_start;
extern uint32_t _bss_bt_end;
Expand Down Expand Up @@ -532,7 +536,12 @@ static int esp_ecc_gen_dh_key(const uint8_t *peer_pub_key_x, const uint8_t *peer

static int esp_intr_alloc_wrapper(int source, int flags, intr_handler_t handler, void *arg, void **ret_handle_in)
{
#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
int rc = esp_intr_alloc(source, flags, handler, arg, (intr_handle_t *)ret_handle_in);
#else
int rc = esp_intr_alloc(source, flags | ESP_INTR_FLAG_IRAM, handler, arg, (intr_handle_t *)ret_handle_in);
#endif

return rc;
}

Expand Down Expand Up @@ -741,6 +750,8 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
return ret;
}

/* If we place the ble code into flash, don't need to initialize ROM. */
#if !CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
#if DEFAULT_BT_LE_50_FEATURE_SUPPORT || DEFAULT_BT_LE_ROLE_CENTROL || DEFAULT_BT_LE_ROLE_OBSERVER
extern int esp_ble_rom_func_ptr_init_all(void);
esp_ble_rom_func_ptr_init_all();
Expand All @@ -749,6 +760,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
extern int esp_ble_rom_func_ptr_init_legacy_adv_and_slave(void);
esp_ble_rom_func_ptr_init_legacy_adv_and_slave();
#endif
#endif //!CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY

/* Initialize the function pointers for OS porting */
npl_freertos_funcs_init();
Expand Down Expand Up @@ -798,6 +810,11 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
#if CONFIG_SW_COEXIST_ENABLE
coex_init();
#endif

#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
ble_ll_supported_features_init();
#endif //CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY

ret = ble_controller_init(cfg);
if (ret != ESP_OK) {
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_init failed %d", ret);
Expand Down
Loading

0 comments on commit cca1b35

Please sign in to comment.