Optimize the Cmake file structure, support esp32c2.

Follow Kconfig to update the nimble config macro name.
This commit is contained in:
Geng Yuchao
2022-06-03 21:57:44 +08:00
parent 50b762af1f
commit a692abd423
3 changed files with 112 additions and 106 deletions

View File

@@ -1,45 +1,34 @@
if(CONFIG_BT_ENABLED) if(CONFIG_BT_ENABLED)
if(CONFIG_IDF_TARGET_ESP32)
set(srcs "controller/esp32/bt.c"
"controller/esp32/hli_api.c"
"controller/esp32/hli_vectors.S")
elseif(CONFIG_IDF_TARGET_ESP32C3)
set(srcs "controller/esp32c3/bt.c")
elseif(CONFIG_IDF_TARGET_ESP32S3)
set(srcs "controller/esp32s3/bt.c")
elseif(CONFIG_IDF_TARGET_ESP32H2)
set(srcs "controller/esp32h2/bt.c")
endif()
if(CONFIG_NIMBLE_USE_UART_HCI) set(srcs "")
set(srcs set(include_dirs "")
"porting/nimble/src/hal_uart.c"
)
else()
endif()
set(include_dirs common/osi/include)
if(CONFIG_IDF_TARGET_ESP32) if(CONFIG_IDF_TARGET_ESP32)
list(APPEND include_dirs include/esp32/include) list(APPEND srcs "controller/esp32/bt.c"
"controller/esp32/hli_api.c"
"controller/esp32/hli_vectors.S")
list(APPEND include_dirs include/esp32/include)
elseif(CONFIG_IDF_TARGET_ESP32C3) elseif(CONFIG_IDF_TARGET_ESP32C3)
list(APPEND include_dirs include/esp32c3/include) list(APPEND srcs "controller/esp32c3/bt.c")
list(APPEND include_dirs include/esp32c3/include)
elseif(CONFIG_IDF_TARGET_ESP32S3) elseif(CONFIG_IDF_TARGET_ESP32S3)
list(APPEND include_dirs include/esp32s3/include) list(APPEND srcs "controller/esp32s3/bt.c")
list(APPEND include_dirs include/esp32s3/include)
elseif(CONFIG_IDF_TARGET_ESP32H2) elseif(CONFIG_IDF_TARGET_ESP32H2)
if(CONFIG_BT_BLUEDROID_ENABLED) list(APPEND srcs "controller/esp32h2/bt.c")
list(APPEND include_dirs list(APPEND include_dirs include/esp32h2/include)
host/nimble/nimble/porting/nimble/include
host/nimble/nimble/nimble/include elseif(CONFIG_IDF_TARGET_ESP32C2)
host/nimble/nimble/porting/npl/freertos/include list(APPEND srcs "controller/esp32c2/bt.c")
host/nimble/nimble/nimble/transport/ram/include list(APPEND include_dirs include/esp32c2/include)
host/nimble/port/include
include/esp32h2/include)
else()
list(APPEND include_dirs include/esp32h2/include)
endif()
endif() endif()
# Common
list(APPEND include_dirs common/osi/include)
list(APPEND priv_include_dirs list(APPEND priv_include_dirs
common/btc/include common/btc/include
common/include) common/include)
@@ -48,6 +37,7 @@ if(CONFIG_BT_ENABLED)
common/btc/profile/esp/blufi/include common/btc/profile/esp/blufi/include
common/btc/profile/esp/include) common/btc/profile/esp/include)
list(APPEND srcs "common/btc/core/btc_alarm.c" list(APPEND srcs "common/btc/core/btc_alarm.c"
"common/api/esp_blufi_api.c" "common/api/esp_blufi_api.c"
"common/btc/core/btc_manage.c" "common/btc/core/btc_manage.c"
@@ -68,6 +58,7 @@ if(CONFIG_BT_ENABLED)
"common/osi/osi.c" "common/osi/osi.c"
"common/osi/semaphore.c") "common/osi/semaphore.c")
# Host Bluedroid
if(CONFIG_BT_BLUEDROID_ENABLED) if(CONFIG_BT_BLUEDROID_ENABLED)
list(APPEND priv_include_dirs list(APPEND priv_include_dirs
@@ -361,16 +352,15 @@ if(CONFIG_BT_ENABLED)
"host/bluedroid/stack/smp/smp_l2c.c" "host/bluedroid/stack/smp/smp_l2c.c"
"host/bluedroid/stack/smp/smp_main.c" "host/bluedroid/stack/smp/smp_main.c"
"host/bluedroid/stack/smp/smp_utils.c") "host/bluedroid/stack/smp/smp_utils.c")
if(CONFIG_IDF_TARGET_ESP32H2) if(CONFIG_IDF_TARGET_ESP32H2 OR CONFIG_IDF_TARGET_ESP32C2)
if(CONFIG_BT_BLUEDROID_ENABLED)
list(APPEND srcs list(APPEND srcs
"host/nimble/nimble/porting/npl/freertos/src/npl_os_freertos.c" "host/nimble/nimble/porting/npl/freertos/src/npl_os_freertos.c"
"host/nimble/nimble/porting/nimble/src/os_msys_init.c" "host/nimble/nimble/porting/nimble/src/os_msys_init.c"
"host/nimble/port/src/esp_nimble_mem.c") "host/nimble/port/src/esp_nimble_mem.c")
endif() endif()
endif()
list(APPEND srcs "common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c")
list(APPEND srcs "common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c")
if(CONFIG_BLE_MESH) if(CONFIG_BLE_MESH)
list(APPEND srcs "esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c") list(APPEND srcs "esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c")
endif() endif()
@@ -475,12 +465,73 @@ endif()
"esp_ble_mesh/mesh_models/server/time_scene_server.c") "esp_ble_mesh/mesh_models/server/time_scene_server.c")
endif() endif()
# Nimble
# Nimble common
if(CONFIG_BT_NIMBLE_ENABLED OR
(CONFIG_BT_CONTROLLER_ENABLED AND (CONFIG_IDF_TARGET_ESP32C2 OR CONFIG_IDF_TARGET_ESP32H2)))
list(APPEND srcs
"host/nimble/nimble/porting/npl/freertos/src/nimble_port_freertos.c"
"host/nimble/nimble/porting/npl/freertos/src/npl_os_freertos.c"
"host/nimble/nimble/porting/nimble/src/os_cputime_pwr2.c"
"host/nimble/nimble/porting/nimble/src/hal_timer.c"
"host/nimble/nimble/porting/nimble/src/os_msys_init.c"
"host/nimble/nimble/porting/nimble/src/nimble_port.c"
"host/nimble/port/src/esp_nimble_mem.c"
"host/nimble/esp-hci/src/esp_nimble_hci.c"
"host/nimble/nimble/porting/nimble/src/os_cputime.c"
)
list(APPEND include_dirs
host/nimble/nimble/porting/nimble/include
host/nimble/port/include
host/nimble/nimble/nimble/include
host/nimble/nimble/porting/npl/freertos/include
host/nimble/esp-hci/include
)
if(NOT CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS)
list(APPEND include_dirs
host/nimble/nimble/ext/tinycrypt/include)
list(APPEND srcs "host/nimble/nimble/ext/tinycrypt/src/utils.c"
"host/nimble/nimble/ext/tinycrypt/src/sha256.c"
"host/nimble/nimble/ext/tinycrypt/src/ecc.c"
"host/nimble/nimble/ext/tinycrypt/src/ctr_prng.c"
"host/nimble/nimble/ext/tinycrypt/src/ctr_mode.c"
"host/nimble/nimble/ext/tinycrypt/src/aes_decrypt.c"
"host/nimble/nimble/ext/tinycrypt/src/aes_encrypt.c"
"host/nimble/nimble/ext/tinycrypt/src/ccm_mode.c"
"host/nimble/nimble/ext/tinycrypt/src/ecc_dsa.c"
"host/nimble/nimble/ext/tinycrypt/src/cmac_mode.c"
"host/nimble/nimble/ext/tinycrypt/src/ecc_dh.c"
"host/nimble/nimble/ext/tinycrypt/src/hmac_prng.c"
"host/nimble/nimble/ext/tinycrypt/src/ecc_platform_specific.c"
"host/nimble/nimble/ext/tinycrypt/src/hmac.c"
"host/nimble/nimble/ext/tinycrypt/src/cbc_mode.c")
endif()
if(CONFIG_BT_LE_HCI_INTERFACE_USE_UART)
list(APPEND srcs
"host/nimble/nimble/porting/nimble/src/hal_uart.c"
)
list(APPEND include_dirs
host/nimble/nimble/nimble/transport/uart/include
)
else()
list(APPEND include_dirs
host/nimble/nimble/nimble/transport/ram/include
)
endif()
endif()
if(CONFIG_BT_NIMBLE_ENABLED) if(CONFIG_BT_NIMBLE_ENABLED)
list(APPEND include_dirs list(APPEND include_dirs
host/nimble/nimble/porting/nimble/include
host/nimble/port/include
host/nimble/nimble/nimble/include
host/nimble/nimble/nimble/host/include host/nimble/nimble/nimble/host/include
host/nimble/nimble/nimble/host/services/ans/include host/nimble/nimble/nimble/host/services/ans/include
host/nimble/nimble/nimble/host/services/bas/include host/nimble/nimble/nimble/host/services/bas/include
@@ -494,31 +545,7 @@ endif()
host/nimble/nimble/nimble/host/util/include host/nimble/nimble/nimble/host/util/include
host/nimble/nimble/nimble/host/store/ram/include host/nimble/nimble/nimble/host/store/ram/include
host/nimble/nimble/nimble/host/store/config/include host/nimble/nimble/nimble/host/store/config/include
host/nimble/nimble/porting/npl/freertos/include )
host/nimble/nimble/nimble/transport/ram/include
host/nimble/esp-hci/include)
if(NOT CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS)
list(APPEND include_dirs
host/nimble/nimble/ext/tinycrypt/include)
list(APPEND srcs "host/nimble/nimble/ext/tinycrypt/src/utils.c"
"host/nimble/nimble/ext/tinycrypt/src/sha256.c"
"host/nimble/nimble/ext/tinycrypt/src/ecc.c"
"host/nimble/nimble/ext/tinycrypt/src/ctr_prng.c"
"host/nimble/nimble/ext/tinycrypt/src/ctr_mode.c"
"host/nimble/nimble/ext/tinycrypt/src/aes_decrypt.c"
"host/nimble/nimble/ext/tinycrypt/src/aes_encrypt.c"
"host/nimble/nimble/ext/tinycrypt/src/ccm_mode.c"
"host/nimble/nimble/ext/tinycrypt/src/ecc_dsa.c"
"host/nimble/nimble/ext/tinycrypt/src/cmac_mode.c"
"host/nimble/nimble/ext/tinycrypt/src/ecc_dh.c"
"host/nimble/nimble/ext/tinycrypt/src/hmac_prng.c"
"host/nimble/nimble/ext/tinycrypt/src/ecc_platform_specific.c"
"host/nimble/nimble/ext/tinycrypt/src/hmac.c"
"host/nimble/nimble/ext/tinycrypt/src/cbc_mode.c")
endif()
list(APPEND srcs "host/nimble/nimble/nimble/host/util/src/addr.c" list(APPEND srcs "host/nimble/nimble/nimble/host/util/src/addr.c"
"host/nimble/nimble/nimble/host/services/gatt/src/ble_svc_gatt.c" "host/nimble/nimble/nimble/host/services/gatt/src/ble_svc_gatt.c"
@@ -577,15 +604,7 @@ endif()
"host/nimble/nimble/nimble/host/store/ram/src/ble_store_ram.c" "host/nimble/nimble/nimble/host/store/ram/src/ble_store_ram.c"
"host/nimble/nimble/nimble/host/store/config/src/ble_store_config.c" "host/nimble/nimble/nimble/host/store/config/src/ble_store_config.c"
"host/nimble/nimble/nimble/host/store/config/src/ble_store_nvs.c" "host/nimble/nimble/nimble/host/store/config/src/ble_store_nvs.c"
"host/nimble/nimble/porting/npl/freertos/src/nimble_port_freertos.c" )
"host/nimble/nimble/porting/npl/freertos/src/npl_os_freertos.c"
"host/nimble/nimble/porting/nimble/src/os_cputime_pwr2.c"
"host/nimble/nimble/porting/nimble/src/hal_timer.c"
"host/nimble/nimble/porting/nimble/src/os_msys_init.c"
"host/nimble/nimble/porting/nimble/src/nimble_port.c"
"host/nimble/port/src/esp_nimble_mem.c"
"host/nimble/esp-hci/src/esp_nimble_hci.c"
"host/nimble/nimble/porting/nimble/src/os_cputime.c")
if(CONFIG_IDF_TARGET_ESP32) if(CONFIG_IDF_TARGET_ESP32)
list(APPEND srcs list(APPEND srcs
@@ -608,8 +627,9 @@ endif()
endif() endif()
list(APPEND srcs list(APPEND srcs
"common/btc/profile/esp/blufi/nimble_host/esp_blufi.c") "common/btc/profile/esp/blufi/nimble_host/esp_blufi.c")
if(CONFIG_BLE_MESH) if(CONFIG_BLE_MESH)
list(APPEND srcs "esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c") list(APPEND srcs "esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c")
endif() endif()
@@ -681,7 +701,10 @@ if(CONFIG_BT_ENABLED)
"-L${CMAKE_CURRENT_LIST_DIR}/controller/lib_esp32c3_family/esp32s3") "-L${CMAKE_CURRENT_LIST_DIR}/controller/lib_esp32c3_family/esp32s3")
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app) target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app)
elseif(CONFIG_IDF_TARGET_ESP32H2) elseif(CONFIG_IDF_TARGET_ESP32H2)
add_prebuilt_library(nimblelib "controller/lib_esp32h2/esp32h2-bt-lib/libcontroller_5p0_seq.a") add_prebuilt_library(nimblelib "controller/lib_esp32h2/esp32h2-bt-lib/libble_app.a")
target_link_libraries(${COMPONENT_LIB} PRIVATE nimblelib)
elseif(CONFIG_IDF_TARGET_ESP32C2)
add_prebuilt_library(nimblelib "controller/lib_esp32c2/esp32c2-bt-lib/libble_app.a")
target_link_libraries(${COMPONENT_LIB} PRIVATE nimblelib) target_link_libraries(${COMPONENT_LIB} PRIVATE nimblelib)
endif() endif()

View File

@@ -7,7 +7,9 @@
#include <assert.h> #include <assert.h>
#include "sysinit/sysinit.h" #include "sysinit/sysinit.h"
#include "nimble/hci_common.h" #include "nimble/hci_common.h"
#if CONFIG_BT_NIMBLE_ENABLED
#include "host/ble_hs.h" #include "host/ble_hs.h"
#endif //CONFIG_BT_NIMBLE_ENABLED
#include "nimble/nimble_port.h" #include "nimble/nimble_port.h"
#include "nimble/nimble_port_freertos.h" #include "nimble/nimble_port_freertos.h"
#include "esp_nimble_hci.h" #include "esp_nimble_hci.h"

View File

@@ -22,12 +22,6 @@
#define IRAM_ATTR_64MCPU IRAM_ATTR #define IRAM_ATTR_64MCPU IRAM_ATTR
#endif #endif
#ifdef CONFIG_BT_NIMBLE_RUN_QA_TEST
#define RUN_QA_TEST_N (CONFIG_BT_NIMBLE_RUN_QA_TEST)
#else
#define RUN_QA_TEST_N (0)
#endif
#define BLE_LL_CTRL_PROC_TIMEOUT_MS_N (40000) /* ms */ #define BLE_LL_CTRL_PROC_TIMEOUT_MS_N (40000) /* ms */
#define BLE_LL_CFG_NUM_HCI_CMD_PKTS_N (1) #define BLE_LL_CFG_NUM_HCI_CMD_PKTS_N (1)
@@ -54,14 +48,10 @@
#define BLE_LL_TX_PWR_DBM_N (0) #define BLE_LL_TX_PWR_DBM_N (0)
#define BLE_LL_SYNC_CNT_N (7) #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3
#define BLE_LL_SYNC_LIST_CNT_N (7)
#ifndef CONFIG_BT_NIMBLE_CONTROLLER_ENABLED
#define NIMBLE_CFG_CONTROLLER 0 #define NIMBLE_CFG_CONTROLLER 0
#else #else
#define NIMBLE_CFG_CONTROLLER CONFIG_BT_NIMBLE_CONTROLLER_ENABLED #define NIMBLE_CFG_CONTROLLER CONFIG_BT_CONTROLLER_ENABLED
#endif #endif
/*** kernel/os */ /*** kernel/os */
@@ -144,6 +134,11 @@
#define MYNEWT_VAL_BLE_MAX_PERIODIC_SYNCS (CONFIG_BT_NIMBLE_MAX_PERIODIC_SYNCS) #define MYNEWT_VAL_BLE_MAX_PERIODIC_SYNCS (CONFIG_BT_NIMBLE_MAX_PERIODIC_SYNCS)
#endif #endif
#ifndef CONFIG_BT_NIMBLE_MAX_PERIODIC_ADVERTISER_LIST
#define MYNEWT_VAL_BLE_MAX_PERIODIC_ADVERTISER_LIST (0)
#else
#define MYNEWT_VAL_BLE_MAX_PERIODIC_ADVERTISER_LIST (CONFIG_BT_NIMBLE_MAX_PERIODIC_ADVERTISER_LIST)
#endif
#ifndef CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES #ifndef CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES
#define MYNEWT_VAL_BLE_MULTI_ADV_INSTANCES (1) #define MYNEWT_VAL_BLE_MULTI_ADV_INSTANCES (1)
@@ -193,7 +188,7 @@
/*** @apache-mynewt-nimble/nimble/controller */ /*** @apache-mynewt-nimble/nimble/controller */
/*** @apache-mynewt-nimble/nimble/controller */ /*** @apache-mynewt-nimble/nimble/controller */
#ifndef MYNEWT_VAL_BLE_CONTROLLER #ifndef MYNEWT_VAL_BLE_CONTROLLER
#if CONFIG_IDF_TARGET_ESP32H2 #if NIMBLE_CFG_CONTROLLER
#define MYNEWT_VAL_BLE_CONTROLLER (1) #define MYNEWT_VAL_BLE_CONTROLLER (1)
#else #else
#define MYNEWT_VAL_BLE_CONTROLLER (0) #define MYNEWT_VAL_BLE_CONTROLLER (0)
@@ -284,10 +279,6 @@
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_ENCRYPTION (CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_ENCRYPTION) #define MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_ENCRYPTION (CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_ENCRYPTION)
#endif #endif
#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_PING
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_PING (MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_ENCRYPTION)
#endif
/* Value copied from BLE_LL_OUR_SCA */ /* Value copied from BLE_LL_OUR_SCA */
#ifndef MYNEWT_VAL_BLE_LL_SCA #ifndef MYNEWT_VAL_BLE_LL_SCA
#define MYNEWT_VAL_BLE_LL_SCA (60) #define MYNEWT_VAL_BLE_LL_SCA (60)
@@ -330,11 +321,7 @@
#endif #endif
#ifndef MYNEWT_VAL_BLE_HCI_UART_PARITY #ifndef MYNEWT_VAL_BLE_HCI_UART_PARITY
#if CONFIG_IDF_TARGET_ESP32H2 #define MYNEWT_VAL_BLE_HCI_UART_PARITY (0) // HAL_UART_PARITY_NONE
#define MYNEWT_VAL_BLE_HCI_UART_PARITY 0
#else
#define MYNEWT_VAL_BLE_HCI_UART_PARITY (HAL_UART_PARITY_NONE)
#endif
#endif #endif
#ifndef CONFIG_BT_NIMBLE_HCI_UART_PORT #ifndef CONFIG_BT_NIMBLE_HCI_UART_PORT
@@ -360,12 +347,6 @@
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_EXT_ADV (MYNEWT_VAL_BLE_EXT_ADV) #define MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_EXT_ADV (MYNEWT_VAL_BLE_EXT_ADV)
#endif #endif
#if MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_EXT_ADV
#define BLE_LL_SCAN_PHY_NUMBER_N (2)
#else
#define BLE_LL_SCAN_PHY_NUMBER_N (1)
#endif
/* Value copied from BLE_PERIODIC_ADV */ /* Value copied from BLE_PERIODIC_ADV */
#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_PERIODIC_ADV #ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_PERIODIC_ADV
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_PERIODIC_ADV (CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV) #define MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_PERIODIC_ADV (CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV)
@@ -431,7 +412,7 @@
#endif #endif
#ifndef MYNEWT_VAL_BLE_LL_RESOLV_LIST_SIZE #ifndef MYNEWT_VAL_BLE_LL_RESOLV_LIST_SIZE
#define MYNEWT_VAL_BLE_LL_RESOLV_LIST_SIZE (CONFIG_BT_NIMBLE_LL_RESOLV_LIST_SIZE) #define MYNEWT_VAL_BLE_LL_RESOLV_LIST_SIZE (4)
#endif #endif
#ifndef MYNEWT_VAL_BLE_LL_RNG_BUFSIZE #ifndef MYNEWT_VAL_BLE_LL_RNG_BUFSIZE