diff --git a/components/bt/CMakeLists.txt b/components/bt/CMakeLists.txt index 31981a3807..53557c7cda 100644 --- a/components/bt/CMakeLists.txt +++ b/components/bt/CMakeLists.txt @@ -32,13 +32,14 @@ if(CONFIG_BT_ENABLED) list(APPEND priv_include_dirs common/btc/include - common/include) + common/include + porting/mem/ + ) list(APPEND include_dirs common/api/include/api common/btc/profile/esp/blufi/include common/btc/profile/esp/include - porting/mem/ - ) + ) list(APPEND srcs "common/btc/core/btc_alarm.c" @@ -467,9 +468,7 @@ if(CONFIG_BT_ENABLED) - if(CONFIG_IDF_TARGET_ESP32C2 OR CONFIG_IDF_TARGET_ESP32H2) - - if(CONFIG_BT_CONTROLLER_ENABLED) + if(CONFIG_BT_LE_CONTROLLER_NPL_OS_PORTING_SUPPORT) list(APPEND srcs "porting/npl/freertos/src/npl_os_freertos.c" "porting/nimble/src/os_msys_init.c" @@ -477,40 +476,38 @@ if(CONFIG_BT_ENABLED) list(APPEND include_dirs porting/include - porting/mem/ porting/nimble/include porting/npl/freertos/include porting/transport/include ) - endif() - if(CONFIG_BT_LE_HCI_INTERFACE_USE_UART) - list(APPEND srcs - "porting/transport/uart/hci_uart.c" - ) - endif() + if(CONFIG_BT_LE_HCI_INTERFACE_USE_UART) + list(APPEND srcs + "porting/transport/uart/hci_uart.c" + ) + endif() + endif() - if(NOT (CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS OR CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS)) - list(APPEND include_dirs + if(NOT (CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS OR CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS)) + list(APPEND include_dirs porting/ext/tinycrypt/include - ) - list(APPEND srcs "porting/ext/tinycrypt/src/utils.c" - "porting/ext/tinycrypt/src/sha256.c" - "porting/ext/tinycrypt/src/ecc.c" - "porting/ext/tinycrypt/src/ctr_prng.c" - "porting/ext/tinycrypt/src/ctr_mode.c" - "porting/ext/tinycrypt/src/aes_decrypt.c" - "porting/ext/tinycrypt/src/aes_encrypt.c" - "porting/ext/tinycrypt/src/ccm_mode.c" - "porting/ext/tinycrypt/src/ecc_dsa.c" - "porting/ext/tinycrypt/src/cmac_mode.c" - "porting/ext/tinycrypt/src/ecc_dh.c" - "porting/ext/tinycrypt/src/hmac_prng.c" - "porting/ext/tinycrypt/src/ecc_platform_specific.c" - "porting/ext/tinycrypt/src/hmac.c" - "porting/ext/tinycrypt/src/cbc_mode.c") - endif() + ) + list(APPEND srcs "porting/ext/tinycrypt/src/utils.c" + "porting/ext/tinycrypt/src/sha256.c" + "porting/ext/tinycrypt/src/ecc.c" + "porting/ext/tinycrypt/src/ctr_prng.c" + "porting/ext/tinycrypt/src/ctr_mode.c" + "porting/ext/tinycrypt/src/aes_decrypt.c" + "porting/ext/tinycrypt/src/aes_encrypt.c" + "porting/ext/tinycrypt/src/ccm_mode.c" + "porting/ext/tinycrypt/src/ecc_dsa.c" + "porting/ext/tinycrypt/src/cmac_mode.c" + "porting/ext/tinycrypt/src/ecc_dh.c" + "porting/ext/tinycrypt/src/hmac_prng.c" + "porting/ext/tinycrypt/src/ecc_platform_specific.c" + "porting/ext/tinycrypt/src/hmac.c" + "porting/ext/tinycrypt/src/cbc_mode.c") endif() if(CONFIG_BT_NIMBLE_ENABLED) @@ -601,7 +598,7 @@ if(CONFIG_BT_ENABLED) host/nimble/port/include ) - if(NOT((CONFIG_IDF_TARGET_ESP32C2 OR CONFIG_IDF_TARGET_ESP32H2) AND CONFIG_BT_CONTROLLER_ENABLED)) + if(NOT CONFIG_BT_LE_CONTROLLER_NPL_OS_PORTING_SUPPORT) list(APPEND srcs "host/nimble/nimble/porting/nimble/src/endian.c" "host/nimble/nimble/porting/nimble/src/os_mempool.c" @@ -626,8 +623,6 @@ if(CONFIG_BT_ENABLED) ) endif() - - list(APPEND srcs "common/btc/profile/esp/blufi/nimble_host/esp_blufi.c") diff --git a/components/bt/controller/esp32c2/Kconfig.in b/components/bt/controller/esp32c2/Kconfig.in index a7b8c5c466..6cb2bddd4b 100644 --- a/components/bt/controller/esp32c2/Kconfig.in +++ b/components/bt/controller/esp32c2/Kconfig.in @@ -8,11 +8,11 @@ menu "HCI Config" config BT_LE_HCI_INTERFACE_USE_RAM bool "ram" help - Use RAM as HCI interface + Use RAM as HCI interface config BT_LE_HCI_INTERFACE_USE_UART bool "uart" help - Use UART as HCI interface + Use UART as HCI interface endchoice config BT_LE_HCI_UART_PORT @@ -52,7 +52,7 @@ menu "HCI Config" depends on BT_LE_HCI_INTERFACE_USE_UART default 921600 help - HCI uart baud rate 115200 ~ 1000000 + HCI uart baud rate 115200 ~ 1000000 choice BT_LE_HCI_UART_PARITY prompt "select uart parity" @@ -62,15 +62,15 @@ menu "HCI Config" config BT_LE_HCI_UART_UART_PARITY_DISABLE bool "PARITY_DISABLE" help - UART_PARITY_DISABLE + UART_PARITY_DISABLE config BT_LE_HCI_UART_UART_PARITY_EVEN bool "PARITY_EVEN" help - UART_PARITY_EVEN + UART_PARITY_EVEN config BT_LE_HCI_UART_UART_PARITY_ODD bool "PARITY_ODD" help - UART_PARITY_ODD + UART_PARITY_ODD endchoice config BT_LE_HCI_UART_TASK_STACK_SIZE @@ -78,29 +78,36 @@ menu "HCI Config" depends on BT_LE_HCI_INTERFACE_USE_UART default 1000 help - Set the size of uart task stack + Set the size of uart task stack endmenu +config BT_LE_CONTROLLER_NPL_OS_PORTING_SUPPORT + bool + default y + help + Enable NPL porting for controller. + + menuconfig BT_LE_50_FEATURE_SUPPORT bool "Enable BLE 5 feature" depends on !BT_NIMBLE_ENABLED default y help - Enable BLE 5 feature + 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 + 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 + Enable coded-PHY config BT_LE_EXT_ADV bool "Enable extended advertising" @@ -114,8 +121,7 @@ if BT_LE_EXT_ADV config BT_LE_MAX_EXT_ADV_INSTANCES int "Maximum number of extended advertising instances." range 0 4 - default 1 if BT_LE_EXT_ADV - default 0 + default 1 depends on BT_LE_EXT_ADV help Change this option to set maximum number of extended advertising @@ -126,8 +132,7 @@ if BT_LE_EXT_ADV config BT_LE_EXT_ADV_MAX_SIZE int "Maximum length of the advertising data." range 0 1650 - default 1650 if BT_LE_EXT_ADV - default 0 + default 1650 depends on BT_LE_EXT_ADV help Defines the length of the extended adv data. The value should not @@ -145,7 +150,7 @@ if BT_LE_EXT_ADV depends on BT_LE_ENABLE_PERIODIC_ADV default y help - This enables controller transfer periodic sync events to host + This enables controller transfer periodic sync events to host endif @@ -165,7 +170,7 @@ 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 if BT_LE_50_FEATURE_SUPPORT + default 5 help Set this option to set the upper limit for number of periodic advertiser list. @@ -182,22 +187,22 @@ menu "Memory Settings" count. config BT_LE_MSYS_1_BLOCK_SIZE - int "MSYS_1 Block Size" + int "MSYS_1 Block Size" default 256 help - Dynamic memory size of block 1 + Dynamic memory size of block 1 config BT_LE_MSYS_2_BLOCK_COUNT - int "MSYS_2 Block Count" + int "MSYS_2 Block Count" default 24 help - Dynamic memory count + Dynamic memory count config BT_LE_MSYS_2_BLOCK_SIZE - int "MSYS_2 Block Size" + int "MSYS_2 Block Size" default 320 help - Dynamic memory size of block 2 + Dynamic memory size of block 2 config BT_LE_ACL_BUF_COUNT int "ACL Buffer count" @@ -245,21 +250,21 @@ config BT_LE_CONTROLLER_TASK_STACK_SIZE default 5120 if BLE_MESH default 4096 help - This configures stack size of NimBLE controller task + This configures stack size of NimBLE controller task config BT_LE_LL_RESOLV_LIST_SIZE int "BLE LL Resolving list size" range 1 5 default 4 help - Configure the size of resolving list used in link layer. + Configure the size of resolving list used in link layer. menuconfig BT_LE_SECURITY_ENABLE bool "Enable BLE SM feature" depends on !BT_NIMBLE_ENABLED default y help - Enable BLE sm feature + Enable BLE sm feature config BT_LE_SM_LEGACY bool "Security manager legacy pairing" @@ -289,7 +294,7 @@ config BT_LE_LL_CFG_FEAT_LE_ENCRYPTION depends on BT_LE_SECURITY_ENABLE default y help - Enable encryption connection + Enable encryption connection config BT_LE_CRYPTO_STACK_MBEDTLS bool "Override TinyCrypt with mbedTLS for crypto computations" @@ -308,21 +313,21 @@ config BT_LE_WHITELIST_SIZE depends on !BT_NIMBLE_ENABLED help - BLE list size + BLE list size config BT_LE_LL_DUP_SCAN_LIST_COUNT int "BLE duplicate scan list count" range 1 100 default 20 help - config the max count of duplicate scan list + config the max count of duplicate scan list config BT_LE_LL_SCA int "BLE Sleep clock accuracy" range 0 500 default 60 help - Sleep clock accuracy of our device (in ppm) + Sleep clock accuracy of our device (in ppm) config BT_LE_MAX_CONNECTIONS int "Maximum number of concurrent connections" @@ -341,23 +346,23 @@ choice BT_LE_COEX_PHY_CODED_TX_RX_TLIM default BT_LE_COEX_PHY_CODED_TX_RX_TLIM_DIS depends on !BT_NIMBLE_ENABLED help - When using PHY-Coded in BLE connection, limitation on max tx/rx time can be applied to - better avoid dramatic performance deterioration of Wi-Fi. + When using PHY-Coded in BLE connection, limitation on max tx/rx time can be applied to + better avoid dramatic performance deterioration of Wi-Fi. - config BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EN - bool "Force Enable" - help - Always enable the limitation on max tx/rx time for Coded-PHY connection + config BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EN + bool "Force Enable" + help + Always enable the limitation on max tx/rx time for Coded-PHY connection - config BT_LE_COEX_PHY_CODED_TX_RX_TLIM_DIS - bool "Force Disable" - help - Disable the limitation on max tx/rx time for Coded-PHY connection + config BT_LE_COEX_PHY_CODED_TX_RX_TLIM_DIS + bool "Force Disable" + help + Disable the limitation on max tx/rx time for Coded-PHY connection endchoice config BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF int - default 0 if !BT_NIMBLE_ENABLED + depends on !BT_NIMBLE_ENABLED default 1 if BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EN default 0 if BT_LE_COEX_PHY_CODED_TX_RX_TLIM_DIS diff --git a/components/bt/controller/esp32h2/Kconfig.in b/components/bt/controller/esp32h2/Kconfig.in index d855b791d5..2fed02bfba 100644 --- a/components/bt/controller/esp32h2/Kconfig.in +++ b/components/bt/controller/esp32h2/Kconfig.in @@ -8,11 +8,11 @@ menu "HCI Config" config BT_LE_HCI_INTERFACE_USE_RAM bool "ram" help - Use RAM as HCI interface + Use RAM as HCI interface config BT_LE_HCI_INTERFACE_USE_UART bool "uart" help - Use UART as HCI interface + Use UART as HCI interface endchoice config BT_LE_HCI_UART_PORT @@ -52,7 +52,7 @@ menu "HCI Config" depends on BT_LE_HCI_INTERFACE_USE_UART default 921600 help - HCI uart baud rate 115200 ~ 1000000 + HCI uart baud rate 115200 ~ 1000000 choice BT_LE_HCI_UART_PARITY prompt "select uart parity" @@ -62,15 +62,15 @@ menu "HCI Config" config BT_LE_HCI_UART_UART_PARITY_DISABLE bool "PARITY_DISABLE" help - UART_PARITY_DISABLE + UART_PARITY_DISABLE config BT_LE_HCI_UART_UART_PARITY_EVEN bool "PARITY_EVEN" help - UART_PARITY_EVEN + UART_PARITY_EVEN config BT_LE_HCI_UART_UART_PARITY_ODD bool "PARITY_ODD" help - UART_PARITY_ODD + UART_PARITY_ODD endchoice config BT_LE_HCI_UART_TASK_STACK_SIZE @@ -78,29 +78,36 @@ menu "HCI Config" depends on BT_LE_HCI_INTERFACE_USE_UART default 1000 help - Set the size of uart task stack + Set the size of uart task stack endmenu +config BT_LE_CONTROLLER_NPL_OS_PORTING_SUPPORT + bool + default y + help + Enable NPL porting for controller. + + menuconfig BT_LE_50_FEATURE_SUPPORT bool "Enable BLE 5 feature" depends on !BT_NIMBLE_ENABLED default y help - Enable BLE 5 feature + 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 + 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 + Enable coded-PHY config BT_LE_EXT_ADV bool "Enable extended advertising" @@ -114,8 +121,7 @@ if BT_LE_EXT_ADV config BT_LE_MAX_EXT_ADV_INSTANCES int "Maximum number of extended advertising instances." range 0 4 - default 1 if BT_LE_EXT_ADV - default 0 + default 1 depends on BT_LE_EXT_ADV help Change this option to set maximum number of extended advertising @@ -126,8 +132,7 @@ if BT_LE_EXT_ADV config BT_LE_EXT_ADV_MAX_SIZE int "Maximum length of the advertising data." range 0 1650 - default 1650 if BT_LE_EXT_ADV - default 0 + default 1650 depends on BT_LE_EXT_ADV help Defines the length of the extended adv data. The value should not @@ -145,7 +150,7 @@ if BT_LE_EXT_ADV depends on BT_LE_ENABLE_PERIODIC_ADV default y help - This enables controller transfer periodic sync events to host + This enables controller transfer periodic sync events to host endif @@ -165,7 +170,7 @@ 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 if BT_LE_50_FEATURE_SUPPORT + default 5 help Set this option to set the upper limit for number of periodic advertiser list. @@ -182,22 +187,22 @@ menu "Memory Settings" count. config BT_LE_MSYS_1_BLOCK_SIZE - int "MSYS_1 Block Size" + int "MSYS_1 Block Size" default 256 help - Dynamic memory size of block 1 + Dynamic memory size of block 1 config BT_LE_MSYS_2_BLOCK_COUNT - int "MSYS_2 Block Count" + int "MSYS_2 Block Count" default 24 help - Dynamic memory count + Dynamic memory count config BT_LE_MSYS_2_BLOCK_SIZE - int "MSYS_2 Block Size" + int "MSYS_2 Block Size" default 320 help - Dynamic memory size of block 2 + Dynamic memory size of block 2 config BT_LE_ACL_BUF_COUNT int "ACL Buffer count" @@ -245,21 +250,21 @@ config BT_LE_CONTROLLER_TASK_STACK_SIZE default 5120 if BLE_MESH default 4096 help - This configures stack size of NimBLE controller task + This configures stack size of NimBLE controller task config BT_LE_LL_RESOLV_LIST_SIZE int "BLE LL Resolving list size" range 1 5 default 4 help - Configure the size of resolving list used in link layer. + Configure the size of resolving list used in link layer. menuconfig BT_LE_SECURITY_ENABLE bool "Enable BLE SM feature" depends on !BT_NIMBLE_ENABLED default y help - Enable BLE sm feature + Enable BLE sm feature config BT_LE_SM_LEGACY bool "Security manager legacy pairing" @@ -289,7 +294,7 @@ config BT_LE_LL_CFG_FEAT_LE_ENCRYPTION depends on BT_LE_SECURITY_ENABLE default y help - Enable encryption connection + Enable encryption connection config BT_LE_CRYPTO_STACK_MBEDTLS bool "Override TinyCrypt with mbedTLS for crypto computations" @@ -308,21 +313,21 @@ config BT_LE_WHITELIST_SIZE depends on !BT_NIMBLE_ENABLED help - BLE list size + BLE list size config BT_LE_LL_DUP_SCAN_LIST_COUNT int "BLE duplicate scan list count" range 1 100 default 20 help - config the max count of duplicate scan list + config the max count of duplicate scan list config BT_LE_LL_SCA int "BLE Sleep clock accuracy" range 0 500 default 60 help - Sleep clock accuracy of our device (in ppm) + Sleep clock accuracy of our device (in ppm) config BT_LE_MAX_CONNECTIONS int "Maximum number of concurrent connections" @@ -341,23 +346,23 @@ choice BT_LE_COEX_PHY_CODED_TX_RX_TLIM default BT_LE_COEX_PHY_CODED_TX_RX_TLIM_DIS depends on !BT_NIMBLE_ENABLED help - When using PHY-Coded in BLE connection, limitation on max tx/rx time can be applied to - better avoid dramatic performance deterioration of Wi-Fi. + When using PHY-Coded in BLE connection, limitation on max tx/rx time can be applied to + better avoid dramatic performance deterioration of Wi-Fi. - config BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EN - bool "Force Enable" - help - Always enable the limitation on max tx/rx time for Coded-PHY connection + config BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EN + bool "Force Enable" + help + Always enable the limitation on max tx/rx time for Coded-PHY connection - config BT_LE_COEX_PHY_CODED_TX_RX_TLIM_DIS - bool "Force Disable" - help - Disable the limitation on max tx/rx time for Coded-PHY connection + config BT_LE_COEX_PHY_CODED_TX_RX_TLIM_DIS + bool "Force Disable" + help + Disable the limitation on max tx/rx time for Coded-PHY connection endchoice config BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF int - default 0 if !BT_NIMBLE_ENABLED + depends on !BT_NIMBLE_ENABLED default 1 if BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EN default 0 if BT_LE_COEX_PHY_CODED_TX_RX_TLIM_DIS diff --git a/components/bt/porting/nimble/include/nimble/nimble_port.h b/components/bt/porting/nimble/include/nimble/nimble_port.h index e2c8fecc38..3da976fc8a 100644 --- a/components/bt/porting/nimble/include/nimble/nimble_port.h +++ b/components/bt/porting/nimble/include/nimble/nimble_port.h @@ -20,6 +20,7 @@ #ifndef _NIMBLE_PORT_H #define _NIMBLE_PORT_H +#include "esp_err.h" #include "nimble/nimble_npl.h" #define NIMBLE_CORE (CONFIG_BT_NIMBLE_PINNED_TO_CORE < portNUM_PROCESSORS ? CONFIG_BT_NIMBLE_PINNED_TO_CORE : tskNO_AFFINITY) @@ -42,7 +43,6 @@ int nimble_port_stop(void); struct ble_npl_eventq *nimble_port_get_dflt_eventq(void); -struct ble_hs_cfg; esp_err_t esp_nimble_init(); esp_err_t esp_nimble_enable(void *host_task);