diff --git a/components/bt/controller/esp32h4/Kconfig.in b/components/bt/controller/esp32h4/Kconfig.in index c87c4e186e..bd11cf72a8 100644 --- a/components/bt/controller/esp32h4/Kconfig.in +++ b/components/bt/controller/esp32h4/Kconfig.in @@ -1,191 +1 @@ -choice - prompt "Bluetooth controller mode (BR/EDR/BLE/DUALMODE)" - help - Specify the bluetooth controller mode (BR/EDR, BLE or dual mode). - - config BTDM_CTRL_MODE_BLE_ONLY - bool "BLE Only" - depends on SOC_BLE_SUPPORTED - - config BTDM_CTRL_MODE_BR_EDR_ONLY - bool "BR/EDR Only" - depends on SOC_BT_CLASSIC_SUPPORTED - - config BTDM_CTRL_MODE_BTDM - bool "Bluetooth Dual Mode" - depends on SOC_BLE_SUPPORTED && SOC_BT_CLASSIC_SUPPORTED -endchoice - -choice BT_CTRL_PINNED_TO_CORE_CHOICE - prompt "The cpu core which bluetooth controller run" - depends on !FREERTOS_UNICORE - help - Specify the cpu core to run bluetooth controller. - Can not specify no-affinity. - - config BT_CTRL_PINNED_TO_CORE_CHOICE_0 - bool "Core 0 (PRO CPU)" - config BT_CTRL_PINNED_TO_CORE_CHOICE_1 - bool "Core 1 (APP CPU)" - depends on !FREERTOS_UNICORE -endchoice - -config BT_CTRL_PINNED_TO_CORE - int - default 0 if BT_CTRL_PINNED_TO_CORE_CHOICE_0 - default 1 if BT_CTRL_PINNED_TO_CORE_CHOICE_1 - default 0 - -config BT_CTRL_TASK_STACK_SIZE - int "Controller task stack size" - default 5120 if BLE_MESH - default 4096 - help - This configures stack size of NimBLE controller task - -config BT_CTRL_SLEEP_ENABLE - bool "Enable Bluetooth Controller sleep" - default n - help - Enable Bluetooth Controller sleep - -menu "Bluetooth controller HCI" - config BT_CTRL_HCI_CMD_NUM - int "HCI CMD buffer number" - range 1 255 - default 5 - - choice BT_CTRL_HCI_INTERFACE - prompt "HCI mode" - default BT_CTRL_HCI_INTERFACE_USE_RAM - - config BT_CTRL_HCI_INTERFACE_USE_RAM - bool "VHCI" - help - Use RAM as HCI interface - config BT_CTRL_HCI_INTERFACE_USE_UART - bool "UART(H4)" - help - Use UART as HCI interface - endchoice - - choice BT_CTRL_UART_HCI_MODE_CHOICE - prompt "UART HCI mode" - depends on BT_CTRL_HCI_INTERFACE_USE_UART - default BT_CTRL_UART_HCI_NO_DMA_MODE - help - Specify UART HCI mode: DMA or No DMA - - config BT_CTRL_UART_HCI_DMA_MODE - bool "UHCI(UART with DMA)(EXPERIMENTAL)" - help - UART HCI Mode with DMA functionality. - - config BT_CTRL_UART_HCI_NO_DMA_MODE - bool "UART(NO DMA)" - help - UART HCI Mode without DMA functionality. - endchoice - - config BT_CTRL_HCI_UART_PORT - int "HCI UART port" - depends on BT_CTRL_HCI_INTERFACE_USE_UART - default 1 - help - Set the port number of HCI UART - - config BT_CTRL_HCI_UART_FLOWCTRL - bool "HCI uart Hardware Flow ctrl" - depends on BT_CTRL_HCI_INTERFACE_USE_UART - default n - - config BT_CTRL_HCI_UART_TX_PIN - int "HCI uart Tx gpio" - depends on BT_CTRL_HCI_INTERFACE_USE_UART - default 19 - - config BT_CTRL_HCI_UART_RX_PIN - int "HCI uart Rx gpio" - depends on BT_CTRL_HCI_INTERFACE_USE_UART - default 10 - - config BT_CTRL_HCI_UART_RTS_PIN - int "HCI uart RTS gpio" - depends on BT_CTRL_HCI_UART_FLOWCTRL - default 4 - - config BT_CTRL_HCI_UART_CTS_PIN - int "HCI uart CTS gpio" - depends on BT_CTRL_HCI_UART_FLOWCTRL - default 5 - - config BT_CTRL_HCI_UART_BAUD - int "HCI uart baudrate" - depends on BT_CTRL_HCI_INTERFACE_USE_UART - default 921600 - help - HCI uart baud rate 115200 ~ 1000000 - - choice BT_CTRL_HCI_UART_PARITY - prompt "select uart parity" - depends on BT_CTRL_HCI_INTERFACE_USE_UART - default BT_CTRL_HCI_UART_UART_PARITY_DISABLE - - config BT_CTRL_HCI_UART_UART_PARITY_DISABLE - bool "PARITY_DISABLE" - help - UART_PARITY_DISABLE - config BT_CTRL_HCI_UART_UART_PARITY_EVEN - bool "PARITY_EVEN" - help - UART_PARITY_EVEN - config BT_CTRL_HCI_UART_UART_PARITY_ODD - bool "PARITY_ODD" - help - UART_PARITY_ODD - endchoice - - config BT_CTRL_HCI_UART_RX_BUFFER_SIZE - int "The size of rx ring buffer memory" - depends on BT_CTRL_UART_HCI_NO_DMA_MODE - default 512 - help - The size of rx ring buffer memory - - config BT_CTRL_HCI_UART_TX_BUFFER_SIZE - int "The size of tx ring buffer memory" - depends on BT_CTRL_UART_HCI_NO_DMA_MODE - default 256 - help - The size of tx ring buffer memory - - config BT_CTRL_HCI_TRANS_TASK_STACK_SIZE - int "HCI transport task stack size" - depends on !BT_CTRL_HCI_INTERFACE_USE_RAM - default 1024 - help - This configures stack size of hci transport task - - config BT_CTRL_HCI_TRANS_RX_MEM_NUM - int "The amount of rx memory received at the same time" - depends on BT_CTRL_UART_HCI_DMA_MODE - default 3 - help - The amount of rx memory received at the same time - - config BT_CTRL_HCI_LLDESCS_POOL_NUM - int "The amount of lldecs memory for driver dma mode" - depends on BT_CTRL_UART_HCI_DMA_MODE - default 20 - help - The amount of lldecs memory for driver dma mode -endmenu - -menu "BLE Controller Settings" - depends on BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM - source "$IDF_PATH/components/bt/controller/$IDF_TARGET/Kconfig.ble.in" -endmenu - -config BT_DUAL_MODE_ARCH - bool - default y +source "$IDF_PATH/components/bt/porting_btdm/Kconfig.in" diff --git a/components/bt/controller/esp32h4/ble.c b/components/bt/controller/esp32h4/ble.c index 6c3880b982..834d5561e5 100644 --- a/components/bt/controller/esp32h4/ble.c +++ b/components/bt/controller/esp32h4/ble.c @@ -500,14 +500,10 @@ static void IRAM_ATTR osi_assert_wrapper(const uint32_t ln, const char *fn, static uint32_t IRAM_ATTR osi_random_wrapper(void) { - static bool first = true; + //TODO: use esp_ramdom + // return esp_ramdom(); - if (first) { - first = false; - srand(esp_random()); - } - - return rand(); + return btdm_osal_rand(); } static int esp_ecc_gen_key_pair(uint8_t *pub, uint8_t *priv) @@ -534,12 +530,6 @@ static int esp_ecc_aes_cmac(const uint8_t *key, const uint8_t *in, size_t len, u return ble_sm_ecc_aes_cmac(key, in, len, out); } -static int ble_hci_unregistered_hook(void*, void*) -{ - ESP_LOGD(NIMBLE_PORT_LOG_TAG,"%s ble hci rx_evt is not registered.",__func__); - return 0; -} - #if CONFIG_FREERTOS_USE_TICKLESS_IDLE esp_err_t sleep_modem_ble_mac_modem_state_init(void) { @@ -766,6 +756,9 @@ esp_err_t esp_ble_controller_deinit(void) r_ble_controller_deinit(); + extern int esp_ble_unregister_bb_funcs(void); + esp_ble_unregister_bb_funcs(); + #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED esp_bt_controller_log_deinit(); #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED @@ -782,52 +775,6 @@ esp_err_t esp_ble_controller_deinit(void) return ESP_OK; } -static -esp_err_t esp_ble_controller_enable(esp_bt_mode_t mode) -{ - esp_err_t ret = ESP_OK; - - // if (mode != ESP_BT_MODE_BLE) { - // ESP_LOGW(NIMBLE_PORT_LOG_TAG, "invalid controller mode"); - // return ESP_FAIL; - // } - if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_INITED) { - ESP_LOGW(NIMBLE_PORT_LOG_TAG, "invalid controller state"); - return ESP_FAIL; - } - // esp_btbb_enable(); -// #if CONFIG_SW_COEXIST_ENABLE -// coex_enable(); -// #endif // CONFIG_SW_COEXIST_ENABLE - - -// ******************************* BTDM TODO ***************************************************** - ret = ble_stack_enable(); - printf("ble_stack_enable:%d\n", ret); - if (ret) { - goto error; - } - - int btdm_task_enable(void); - ret = btdm_task_enable(); - printf("btdm_task_enable:%d\n", ret); - if (ret) { - goto error; - } - -// ************************************************************************************************* - - // if (ble_controller_enable(mode) != 0) { - // ret = ESP_FAIL; - // goto error; - // } - ble_controller_status = ESP_BT_CONTROLLER_STATUS_ENABLED; - return ESP_OK; - -error: - return ret; -} - esp_err_t esp_ble_controller_disable(void) { if (ble_controller_status < ESP_BT_CONTROLLER_STATUS_ENABLED) { @@ -1181,8 +1128,6 @@ exit: return 0; #endif // CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS - // Calculation successful, return 0 - return 0; } #endif // CONFIG_BT_NIMBLE_ENABLED @@ -1611,7 +1556,7 @@ int ble_stack_enable(void) #if CONFIG_BT_LE_ERROR_SIM_ENABLED rc = conn_errorSim_enable(); if (rc) { - ESP_LOGW(conn_errorSim_enable, "conn_errorSim_enable failed %d", rc); + ESP_LOGW(NIMBLE_PORT_LOG_TAG, "conn_errorSim_enable failed %d", rc); return rc; } #endif // CONFIG_BT_LE_ERROR_SIM_ENABLED diff --git a/components/bt/controller/lib_esp32h4/esp32h4-bt-lib b/components/bt/controller/lib_esp32h4/esp32h4-bt-lib index 9a0df711be..a1060f7620 160000 --- a/components/bt/controller/lib_esp32h4/esp32h4-bt-lib +++ b/components/bt/controller/lib_esp32h4/esp32h4-bt-lib @@ -1 +1 @@ -Subproject commit 9a0df711bea1a4b6eab6868ed95648c242744162 +Subproject commit a1060f7620c9c6d7950dd1508ec3add56db650e1 diff --git a/components/bt/host/nimble/port/include/esp_nimble_mem.h b/components/bt/host/nimble/port/include/esp_nimble_mem.h index 09fb1f982f..dd60c741cf 100644 --- a/components/bt/host/nimble/port/include/esp_nimble_mem.h +++ b/components/bt/host/nimble/port/include/esp_nimble_mem.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -13,14 +13,14 @@ extern "C" { #endif -void *bt_osi_mem_malloc(size_t size); +void *nimble_mem_malloc(size_t size); -void *bt_osi_mem_calloc(size_t n, size_t size); +void *nimble_mem_calloc(size_t n, size_t size); -void bt_osi_mem_free(void *ptr); +void nimble_mem_free(void *ptr); #if CONFIG_BT_LE_USED_MEM_STATISTICS_ENABLED -size_t bt_osi_mem_used_size_get(void); +size_t nimble_mem_used_size_get(void); #endif // CONFIG_BT_LE_USED_MEM_STATISTICS_ENABLED #if CONFIG_BT_NIMBLE_MEM_DEBUG @@ -109,7 +109,7 @@ void *nimble_mem_dbg_realloc(void *ptr, size_t new_size, const char *func, int l ({ \ void *p; \ do { \ - p = bt_osi_mem_malloc(size); \ + p = nimble_mem_malloc(size); \ nimble_mem_dbg_record(p, size, __func__, __LINE__); \ } while (0); \ p; \ @@ -119,7 +119,7 @@ void *nimble_mem_dbg_realloc(void *ptr, size_t new_size, const char *func, int l ({ \ void *p; \ do { \ - p = bt_osi_mem_calloc(count, size); \ + p = nimble_mem_calloc(count, size); \ nimble_mem_dbg_record(p, (count) * (size), __func__, __LINE__); \ } while (0); \ p; \ @@ -135,18 +135,18 @@ void *nimble_mem_dbg_realloc(void *ptr, size_t new_size, const char *func, int l }) #define nimble_platform_mem_free(ptr) \ -do { \ - void *tmp_ptr = (void *)(ptr); \ +do { \ + void *tmp_ptr = (void *)(ptr); \ nimble_mem_dbg_clean(tmp_ptr, __func__, __LINE__); \ - bt_osi_mem_free(tmp_ptr); \ + nimble_mem_free(tmp_ptr); \ } while (0) #else -#define nimble_platform_mem_malloc bt_osi_mem_malloc -#define nimble_platform_mem_calloc bt_osi_mem_calloc +#define nimble_platform_mem_malloc nimble_mem_malloc +#define nimble_platform_mem_calloc nimble_mem_calloc #define nimble_platform_mem_realloc realloc -#define nimble_platform_mem_free bt_osi_mem_free +#define nimble_platform_mem_free nimble_mem_free #endif // CONFIG_BT_NIMBLE_MEM_DEBUG diff --git a/components/bt/host/nimble/port/src/esp_nimble_mem.c b/components/bt/host/nimble/port/src/esp_nimble_mem.c index d4a72b2a41..3e1ed6f46a 100644 --- a/components/bt/host/nimble/port/src/esp_nimble_mem.c +++ b/components/bt/host/nimble/port/src/esp_nimble_mem.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -255,7 +255,7 @@ void *nimble_mem_dbg_realloc(void *ptr, size_t new_size, const char *func, int l #if !CONFIG_BT_NIMBLE_LOW_SPEED_MODE IRAM_ATTR #endif -void *bt_osi_mem_malloc(size_t size) +void *nimble_mem_malloc(size_t size) { void *mem = NULL; #ifdef CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL @@ -286,7 +286,7 @@ void *bt_osi_mem_malloc(size_t size) #if !CONFIG_BT_NIMBLE_LOW_SPEED_MODE IRAM_ATTR #endif -void *bt_osi_mem_calloc(size_t n, size_t size) +void *nimble_mem_calloc(size_t n, size_t size) { void *mem = NULL; #ifdef CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL @@ -309,7 +309,7 @@ void *bt_osi_mem_calloc(size_t n, size_t size) #if !CONFIG_BT_NIMBLE_LOW_SPEED_MODE IRAM_ATTR #endif -void bt_osi_mem_free(void *ptr) +void nimble_mem_free(void *ptr) { #if CONFIG_BT_LE_USED_MEM_STATISTICS_ENABLED if (ptr) { @@ -325,7 +325,7 @@ void bt_osi_mem_free(void *ptr) #if CONFIG_BT_LE_USED_MEM_STATISTICS_ENABLED size_t -bt_osi_mem_used_size_get(void) +nimble_mem_used_size_get(void) { return host_mem_used_size; } @@ -333,7 +333,7 @@ bt_osi_mem_used_size_get(void) #if CONFIG_BT_NIMBLE_ENABLED uint32_t esp_host_used_heap_size_get(void) { - return bt_osi_mem_used_size_get(); + return nimble_mem_used_size_get(); } #endif // CONFIG_BT_NIMBLE_ENABLED #endif // CONFIG_BT_LE_USED_MEM_STATISTICS_ENABLED diff --git a/components/bt/include/esp32h4/include/esp_bt.h b/components/bt/include/esp32h4/include/esp_bt.h index 6f639c25d8..931f4c98a0 100644 --- a/components/bt/include/esp32h4/include/esp_bt.h +++ b/components/bt/include/esp32h4/include/esp_bt.h @@ -17,7 +17,6 @@ #include "btdm_user_cfg.h" #if CONFIG_BTDM_CTRL_MODE_BLE_ONLY || CONFIG_BTDM_CTRL_MODE_BTDM -// #include "nimble/nimble_npl.h" #include "ble_user_cfg.h" #endif /* CONFIG_BTDM_CTRL_MODE_BLE_ONLY || CONFIG_BTDM_CTRL_MODE_BTDM */ @@ -29,57 +28,8 @@ extern "C" { #endif -#define ESP_BT_HCI_TL_MAGIC_VALUE 0xfadebead -#define ESP_BT_HCI_TL_VERSION 0x00010000 - /** - * @brief Bluetooth audio data transport path - */ -typedef enum { - ESP_SCO_DATA_PATH_HCI = 0, /*!< data over HCI transport */ - ESP_SCO_DATA_PATH_PCM = 1, /*!< data over PCM interface */ -} esp_sco_data_path_t; - -/** - * @brief Type of controller HCI transport layer - */ -typedef enum { - ESP_BT_CTRL_HCI_TL_UART = 0, /*!< HCI UART h4 transport layer */ - ESP_BT_CTRL_HCI_TL_VHCI = 1, /*!< VHCI interface */ -} esp_bt_ctrl_hci_tl_t; - -#define ESP_BT_HCI_TL_STATUS_OK (0) /*!< HCI_TL Tx/Rx operation status OK */ - -/** - * @brief callback function for HCI Transport Layer send/receive operations - */ -typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status); - -#if CONFIG_BT_CTRL_HCI_MODE_CHOICE_VHCI -#define CFG_HCI_TL_TYPE 1 -#else -#define CFG_HCI_TL_TYPE 0 -#endif - -/** - * @brief Controller HCI transport layer function structure - * This structure shall be registered when HCI transport layer is UART - */ -typedef struct { - uint32_t _magic; /* Magic number */ - uint32_t _version; /* version number of the defined structure */ - uint32_t _reserved; /* reserved for future use */ - int (* _open)(void); /* hci tl open */ - void (* _close)(void); /* hci tl close */ - void (* _finish_transfers)(void); /* hci tl finish transfers */ - void (* _recv)(uint8_t *buf, uint32_t len, esp_bt_hci_tl_callback_t callback, void* arg); /* hci tl recv */ - void (* _send)(uint8_t *buf, uint32_t len, esp_bt_hci_tl_callback_t callback, void* arg); /* hci tl send */ - bool (* _flow_off)(void); /* hci tl flow off */ - void (* _flow_on)(void); /* hci tl flow on */ -} esp_bt_hci_tl_t; - -/** - * @brief Bluetooth mode for controller enable/disable + * @brief Bluetooth mode for controller enable/disable. */ typedef enum { ESP_BT_MODE_IDLE = 0x00, /*!< Bluetooth is not running */ @@ -162,14 +112,6 @@ typedef enum { ESP_BLE_ENHANCED_PWR_TYPE_MAX, } esp_ble_enhanced_power_type_t; -/** - * @brief Address type and address value. - */ -typedef struct { - uint8_t type; /*!< Type of the Bluetooth address (public, random, etc.) */ - uint8_t val[6]; /*!< Array containing the 6-byte Bluetooth address value */ -} esp_ble_addr_t; - /** * @brief Select buffers */ @@ -179,40 +121,13 @@ typedef enum { } esp_ble_log_buf_t; /** - * @brief Set BLE TX power - * Connection Tx power should only be set after connection created. - * @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc - * @param power_level: Power level(index) corresponding to absolute value(dbm) - * @return ESP_OK - success, other - failed + * @brief Address type and address value. */ -esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level); + typedef struct { + uint8_t type; /*!< Type of the Bluetooth address (public, random, etc.) */ + uint8_t val[6]; /*!< Array containing the 6-byte Bluetooth address value */ +} esp_ble_addr_t; -/** - * @brief Get BLE TX power - * Connection Tx power should only be get after connection created. - * @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc - * @return >= 0 - Power level, < 0 - Invalid - */ -esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type); - -/** - * @brief ENHANCED API for Setting BLE TX power - * Connection Tx power should only be set after connection created. - * @param power_type : The enhanced type of which tx power, could set Advertising/Connection/Default and etc - * @param handle : The handle of Advertising or Connection and the value 0 for other enhanced power types. - * @param power_level: Power level(index) corresponding to absolute value(dbm) - * @return ESP_OK - success, other - failed - */ -esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle, esp_power_level_t power_level); - -/** - * @brief ENHANCED API of Getting BLE TX power - * Connection Tx power should only be get after connection created. - * @param power_type : The enhanced type of which tx power, could set Advertising/Connection/Default and etc - * @param handle : The handle of Advertising or Connection and the value 0 for other enhanced power types. - * @return >= 0 - Power level, < 0 - Invalid - */ -esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle); #define BLE_CONFIG_VERSION 0x20241029 #define BLE_CONFIG_MAGIC 0x5A5AA5A5 @@ -223,17 +138,20 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po /* Types definition ************************************************************************ */ +/** + * @brief BTDM controller common configuration options + */ typedef struct { - uint32_t version; + uint32_t version; /*!< Version number of the defined structure */ uint16_t task_stack_size; /*!< Size of Bluetooth controller task stack */ uint8_t task_prio; /*!< Priority of the Bluetooth controller task */ uint8_t task_run_cpu; /*!< CPU number on which the Bluetooth controller task runs */ uint8_t hci_cmd_num; /*!< HCI command buffer number */ uint8_t hci_conn_num; /*!< HCI level connection number */ - uint8_t sleep_en; - uint8_t version_num; + uint8_t sleep_en; /*!< Enable sleep functionality */ + uint8_t version_num; /*!< Hardware version number of this chip */ uint8_t bluetooth_mode; /*!< Controller mode: BR/EDR, BLE or Dual Mode */ - uint32_t magic; + uint32_t magic; /*!< Magic number for configuration validation */ }esp_btdm_controller_config_t; /** @@ -286,26 +204,26 @@ typedef struct { uint8_t main_xtal_freq; /*!< Main crystal frequency */ uint8_t ignore_wl_for_direct_adv; /*!< Ignore the white list for directed advertising */ uint8_t enable_pcl; /*!< Enable power control */ - uint8_t csa2_select; - uint8_t enable_csr; - int8_t backoff_rssi; - bool iso_enabled; - bool iso_bqb_test; - bool iso_fra_unseg; - bool iso_nsfc_en; - uint8_t iso_nsfc_num; - uint8_t iso_buf_count; - uint16_t iso_buf_size; - uint8_t iso_big_count; - uint16_t iso_bis_count; - uint8_t iso_bis_per_big; - uint8_t iso_cig_count; - uint16_t iso_cis_count; - uint8_t iso_cis_per_cig; + uint8_t csa2_select; /*!< Select CSA2 */ + uint8_t enable_csr; /*!< Enable connection subrate */ + int8_t backoff_rssi; /*!< Set the lowest rssi threshold for backoff */ + bool iso_enabled; /*!< Enable ISO */ + bool iso_bqb_test; /*!< Enable ISO BQB test */ + bool iso_fra_unseg; /*!< Enable ISO FRA unsegmented */ + bool iso_nsfc_en; /*!< Enable ISO NSCF */ + uint8_t iso_nsfc_num; /*!< Number of ISO NSCF */ + uint8_t iso_buf_count; /*!< Number of ISO buffer */ + uint16_t iso_buf_size; /*!< Size of ISO buffer */ + uint8_t iso_big_count; /*!< Number of ISO big */ + uint16_t iso_bis_count; /*!< Number of ISO bis */ + uint8_t iso_bis_per_big; /*!< Number of ISO bis per big */ + uint8_t iso_cig_count; /*!< Number of ISO cig */ + uint16_t iso_cis_count; /*!< Number of ISO cis */ + uint8_t iso_cis_per_cig; /*!< Number of ISO cis per cig */ uint32_t config_magic; /*!< Configuration magic value */ - } ble; /* Bluetooth LE controller configuration options */ + } ble; /*!< Bluetooth LE controller configuration options */ - esp_btdm_controller_config_t btdm; /*!< BTDM controller common configuration options */ /*!< BTDM controller common configuration options */ + esp_btdm_controller_config_t btdm; /*!< BTDM controller common configuration options */ } esp_bt_controller_config_t; #if defined(CONFIG_BTDM_CTRL_MODE_BLE_ONLY) @@ -316,28 +234,6 @@ typedef struct { #define BTDM_CONTROLLER_MODE_EFF ESP_BT_MODE_BTDM #endif -#if defined(CONFIG_BT_CTRL_BR_EDR_TEST_MODE_EN) -#define BT_CTRL_BR_EDR_TEST_MODE_EN 1 -#else -#define BT_CTRL_BR_EDR_TEST_MODE_EN 0 -#endif - -#ifndef CONFIG_BT_CTRL_BR_EDR_DTM_EN_EFF -#define CONFIG_BT_CTRL_BR_EDR_DTM_EN_EFF false -#endif - -#if defined(CONFIG_BT_CTRL_BR_EDR_TX_CCA_ENABLED) - #define BT_CTRL_BR_EDR_TX_CCA_ENABLED (CONFIG_BT_CTRL_BR_EDR_TX_CCA_ENABLED) -#else - #define BT_CTRL_BR_EDR_TX_CCA_ENABLED (0) -#endif - -#if defined(CONFIG_BT_CTRL_BR_EDR_CCA_RSSI_THRESH) - #define BT_CTRL_BR_EDR_CCA_RSSI_THRESH (CONFIG_BT_CTRL_BR_EDR_CCA_RSSI_THRESH) -#else - #define BT_CTRL_BR_EDR_CCA_RSSI_THRESH (50) -#endif - #if defined(CONFIG_BT_LE_ISO_SUPPORT) #define DEFAULT_BT_LE_ISO_ENABLED 1 #if defined(CONFIG_BT_LE_ISO_FRA_UNSEG) @@ -450,6 +346,41 @@ typedef struct { }, \ } +/** + * @brief Set BLE TX power + * Connection Tx power should only be set after connection created. + * @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc + * @param power_level: Power level(index) corresponding to absolute value(dbm) + * @return ESP_OK - success, other - failed + */ +esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level); + +/** + * @brief Get BLE TX power + * Connection Tx power should only be get after connection created. + * @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc + * @return >= 0 - Power level, < 0 - Invalid + */ +esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type); + +/** + * @brief ENHANCED API for Setting BLE TX power + * Connection Tx power should only be set after connection created. + * @param power_type : The enhanced type of which tx power, could set Advertising/Connection/Default and etc + * @param handle : The handle of Advertising or Connection and the value 0 for other enhanced power types. + * @param power_level: Power level(index) corresponding to absolute value(dbm) + * @return ESP_OK - success, other - failed + */ +esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle, esp_power_level_t power_level); + +/** + * @brief ENHANCED API of Getting BLE TX power + * Connection Tx power should only be get after connection created. + * @param power_type : The enhanced type of which tx power, could set Advertising/Connection/Default and etc + * @param handle : The handle of Advertising or Connection and the value 0 for other enhanced power types. + * @return >= 0 - Power level, < 0 - Invalid + */ +esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle); /** * @brief Initialize BT controller to allocate task and other resource. @@ -466,14 +397,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg); */ esp_bt_controller_status_t esp_bt_controller_get_status(void); -/** - * @brief Get BLE TX power - * Connection Tx power should only be get after connection created. - * @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc - * @return >= 0 - Power level, < 0 - Invalid - */ -esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type); - /** * @brief De-initialize BT controller to free resource and delete task. * You should stop advertising and scanning, as well as @@ -502,13 +425,6 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode); */ esp_err_t esp_bt_controller_disable(void); -/** - * @brief Get BT controller is initialised/de-initialised/enabled/disabled - * @return status value - */ -esp_bt_controller_status_t esp_bt_controller_get_status(void); - - /** @brief esp_vhci_host_callback * used for vhci call host function to notify what host need to do */ diff --git a/components/bt/include/esp32h4/include/esp_bt_vs.h b/components/bt/include/esp32h4/include/esp_bt_vs.h index 3cbed92583..87945a04f2 100644 --- a/components/bt/include/esp32h4/include/esp_bt_vs.h +++ b/components/bt/include/esp32h4/include/esp_bt_vs.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/components/bt/porting/include/bt_osi_mem.h b/components/bt/porting/include/bt_osi_mem.h index 3725afc4db..c0aa125a40 100644 --- a/components/bt/porting/include/bt_osi_mem.h +++ b/components/bt/porting/include/bt_osi_mem.h @@ -11,6 +11,10 @@ #include "esp_heap_caps.h" +void *bt_osi_mem_malloc(size_t size); + +void bt_osi_mem_free(void *ptr); + void *bt_osi_mem_malloc_internal(size_t size); void *bt_osi_mem_calloc_internal(size_t n, size_t size); diff --git a/components/bt/porting/mem/bt_osi_mem.c b/components/bt/porting/mem/bt_osi_mem.c index c80bb01458..537dc8def1 100644 --- a/components/bt/porting/mem/bt_osi_mem.c +++ b/components/bt/porting/mem/bt_osi_mem.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -77,6 +77,37 @@ bt_osi_mem_free_internal(void *ptr) } } +void * +bt_osi_mem_malloc(size_t size) +{ + void *mem_ptr; + +#if CONFIG_BT_LE_MEM_CHECK_ENABLED + if (mem_count_limit) { + if (curr_mem_count > mem_count_limit) { + return NULL; + } + curr_mem_count ++; + } +#endif // CONFIG_BT_LE_MEM_CHECK_ENABLED + + mem_ptr = heap_caps_malloc(size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT); + +#if CONFIG_BT_LE_USED_MEM_STATISTICS_ENABLED + if (mem_ptr) { + controller_mem_used_size += heap_caps_get_allocated_size(mem_ptr); + } +#endif // CONFIG_BT_LE_USED_MEM_STATISTICS_ENABLED + + return mem_ptr; +} + +void +bt_osi_mem_free(void *ptr) +{ + bt_osi_mem_free_internal(ptr); +} + #if CONFIG_BT_LE_MEM_CHECK_ENABLED void bt_osi_mem_count_limit_set(uint16_t count_limit) { diff --git a/components/bt/porting/mem/os_mempool.c b/components/bt/porting/mem/os_mempool.c index 6893ec4a0e..6f8314c69d 100644 --- a/components/bt/porting/mem/os_mempool.c +++ b/components/bt/porting/mem/os_mempool.c @@ -513,9 +513,11 @@ os_memblock_get(struct os_mempool *mp) // Should not happen OS_ENTER_CRITICAL(sr); mp->mp_num_free++; +#if MYNEWT_VAL(MP_BLOCK_REUSED) if (mp->mp_flags & OS_MEMPOOL_F_REUSED) { mp->mp_alloc_blocks--; } +#endif OS_EXIT_CRITICAL(sr); } } else if (block) { diff --git a/components/bt/porting/mem/os_msys_init.c b/components/bt/porting/mem/os_msys_init.c index 5465e41e53..c4574ca5ae 100644 --- a/components/bt/porting/mem/os_msys_init.c +++ b/components/bt/porting/mem/os_msys_init.c @@ -12,7 +12,6 @@ #include "mem_api.h" #include "bt_osi_mem.h" #include "esp_err.h" -#include "esp_nimble_mem.h" #if CONFIG_BT_NIMBLE_ENABLED #include "syscfg/syscfg.h" @@ -122,11 +121,13 @@ ble_os_msys_ensure_ctx(void) return 0; } - os_msys_ctx = nimble_platform_mem_calloc(1, sizeof(*os_msys_ctx)); + os_msys_ctx = bt_osi_mem_malloc(sizeof(*os_msys_ctx)); if(!os_msys_ctx) { return -1; } + memset(os_msys_ctx, 0, sizeof(*os_msys_ctx)); + return 0; } #endif // !CONFIG_BT_LE_MSYS_INIT_IN_CONTROLLER && CONFIG_BT_NIMBLE_STATIC_TO_DYNAMIC @@ -230,9 +231,9 @@ os_msys_buf_alloc(void) #if CONFIG_BT_NIMBLE_STATIC_TO_DYNAMIC #if OS_MSYS_1_BLOCK_COUNT > 0 if (!os_msys_ctx->init_1_data) { - os_msys_ctx->init_1_data = nimble_platform_mem_calloc(1, (sizeof(os_membuf_t) * SYSINIT_MSYS_1_MEMPOOL_SIZE)); + os_msys_ctx->init_1_data = bt_osi_mem_malloc((sizeof(os_membuf_t) * SYSINIT_MSYS_1_MEMPOOL_SIZE)); if(!os_msys_ctx->init_1_data){ - nimble_platform_mem_free(os_msys_ctx); + bt_osi_mem_free(os_msys_ctx); os_msys_ctx = NULL; return ESP_FAIL; } @@ -241,13 +242,13 @@ os_msys_buf_alloc(void) #if OS_MSYS_2_BLOCK_COUNT > 0 if (!os_msys_ctx->init_2_data) { - os_msys_ctx->init_2_data = nimble_platform_mem_calloc(1, (sizeof(os_membuf_t) * SYSINIT_MSYS_2_MEMPOOL_SIZE)); + os_msys_ctx->init_2_data = bt_osi_mem_malloc((sizeof(os_membuf_t) * SYSINIT_MSYS_2_MEMPOOL_SIZE)); if(!os_msys_ctx->init_2_data) { #if OS_MSYS_1_BLOCK_COUNT > 0 - nimble_platform_mem_free(os_msys_ctx->init_1_data); + bt_osi_mem_free(os_msys_ctx->init_1_data); os_msys_ctx->init_1_data = NULL; #endif - nimble_platform_mem_free(os_msys_ctx); + bt_osi_mem_free(os_msys_ctx); os_msys_ctx = NULL; return ESP_FAIL; } @@ -256,17 +257,17 @@ os_msys_buf_alloc(void) #endif #else #if OS_MSYS_1_BLOCK_COUNT > 0 - os_msys_init_1_data = (os_membuf_t *)nimble_platform_mem_calloc(1, (sizeof(os_membuf_t) * SYSINIT_MSYS_1_MEMPOOL_SIZE)); + os_msys_init_1_data = (os_membuf_t *)bt_osi_mem_malloc((sizeof(os_membuf_t) * SYSINIT_MSYS_1_MEMPOOL_SIZE)); if (!os_msys_init_1_data) { return ESP_ERR_NO_MEM; } #endif #if OS_MSYS_2_BLOCK_COUNT > 0 - os_msys_init_2_data = (os_membuf_t *)nimble_platform_mem_calloc(1, (sizeof(os_membuf_t) * SYSINIT_MSYS_2_MEMPOOL_SIZE)); + os_msys_init_2_data = (os_membuf_t *)bt_osi_mem_malloc((sizeof(os_membuf_t) * SYSINIT_MSYS_2_MEMPOOL_SIZE)); if (!os_msys_init_2_data) { #if OS_MSYS_1_BLOCK_COUNT > 0 - nimble_platform_mem_free(os_msys_init_1_data); + bt_osi_mem_free(os_msys_init_1_data); os_msys_init_1_data = NULL; #endif return ESP_ERR_NO_MEM; @@ -284,32 +285,32 @@ os_msys_buf_free(void) if (os_msys_ctx) { #if OS_MSYS_1_BLOCK_COUNT > 0 if (os_msys_ctx->init_1_data) { - nimble_platform_mem_free(os_msys_ctx->init_1_data); + bt_osi_mem_free(os_msys_ctx->init_1_data); os_msys_ctx->init_1_data = NULL; } os_mempool_unregister(&os_msys_ctx->init_1_mempool); #endif #if OS_MSYS_2_BLOCK_COUNT > 0 if (os_msys_ctx->init_2_data) { - nimble_platform_mem_free(os_msys_ctx->init_2_data); + bt_osi_mem_free(os_msys_ctx->init_2_data); os_msys_ctx->init_2_data = NULL; } os_mempool_unregister(&os_msys_ctx->init_2_mempool); #endif - nimble_platform_mem_free(os_msys_ctx); + bt_osi_mem_free(os_msys_ctx); os_msys_ctx = NULL; } #else #if OS_MSYS_1_BLOCK_COUNT > 0 - nimble_platform_mem_free(os_msys_init_1_data); + bt_osi_mem_free(os_msys_init_1_data); os_msys_init_1_data = NULL; os_mempool_unregister(&os_msys_init_1_mempool); #endif #if OS_MSYS_2_BLOCK_COUNT > 0 - nimble_platform_mem_free(os_msys_init_2_data); + bt_osi_mem_free(os_msys_init_2_data); os_msys_init_2_data = NULL; os_mempool_unregister(&os_msys_init_1_mempool); #endif diff --git a/components/bt/porting/npl/freertos/src/npl_os_freertos.c b/components/bt/porting/npl/freertos/src/npl_os_freertos.c index 4871af528c..d4b8fc883c 100644 --- a/components/bt/porting/npl/freertos/src/npl_os_freertos.c +++ b/components/bt/porting/npl/freertos/src/npl_os_freertos.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -323,8 +323,7 @@ IRAM_ATTR npl_freertos_eventq_remove(struct ble_npl_eventq *evq, portYIELD_FROM_ISR(); } } else { - portMUX_TYPE ble_npl_mut = portMUX_INITIALIZER_UNLOCKED; - portENTER_CRITICAL(&ble_npl_mut); + portENTER_CRITICAL(&ble_port_mutex); count = uxQueueMessagesWaiting(eventq->q); for (i = 0; i < count; i++) { @@ -339,7 +338,7 @@ IRAM_ATTR npl_freertos_eventq_remove(struct ble_npl_eventq *evq, BLE_LL_ASSERT(ret == pdPASS); } - portEXIT_CRITICAL(&ble_npl_mut); + portEXIT_CRITICAL(&ble_port_mutex); } event->queued = 0; diff --git a/components/bt/porting/transport/driver/uart/hci_driver_uart.c b/components/bt/porting/transport/driver/uart/hci_driver_uart.c index e78f5d2767..af51c49660 100644 --- a/components/bt/porting/transport/driver/uart/hci_driver_uart.c +++ b/components/bt/porting/transport/driver/uart/hci_driver_uart.c @@ -102,6 +102,7 @@ hci_driver_uart_rx_task(void *p) xQueueReceive(s_hci_driver_uart_env.rx_event_queue, &uart_event, portMAX_DELAY); data = s_hci_driver_uart_env.rx_data; while (true) { + // TODO: read_len maybe -1, need to handle it read_len = uart_read_bytes(port, data, CONFIG_BT_LE_HCI_RX_PROC_DATA_LEN, 0); if (read_len == 0) { break; diff --git a/components/bt/porting_btdm/Kconfig.in b/components/bt/porting_btdm/Kconfig.in new file mode 100644 index 0000000000..ee74529f8e --- /dev/null +++ b/components/bt/porting_btdm/Kconfig.in @@ -0,0 +1,50 @@ +source "$IDF_PATH/components/bt/porting_btdm/controller/btdm_common/Kconfig.in" + +choice BT_CTRL_PINNED_TO_CORE_CHOICE + prompt "The cpu core which bluetooth controller run" + depends on !FREERTOS_UNICORE + help + Specify the cpu core to run bluetooth controller. + Can not specify no-affinity. + + config BT_CTRL_PINNED_TO_CORE_CHOICE_0 + bool "Core 0 (PRO CPU)" + config BT_CTRL_PINNED_TO_CORE_CHOICE_1 + bool "Core 1 (APP CPU)" + depends on !FREERTOS_UNICORE +endchoice + +config BT_CTRL_PINNED_TO_CORE + int + default 0 if BT_CTRL_PINNED_TO_CORE_CHOICE_0 + default 1 if BT_CTRL_PINNED_TO_CORE_CHOICE_1 + default 0 + +config BT_CTRL_TASK_STACK_SIZE + int "Controller task stack size" + default 5120 if BLE_MESH + default 4096 + help + This configures stack size of NimBLE controller task + +config BT_CTRL_SLEEP_ENABLE + bool "Enable Bluetooth Controller sleep" + default n + help + Enable Bluetooth Controller sleep + +config BT_DUAL_MODE_ARCH + bool + default y + +source "$IDF_PATH/components/bt/porting_btdm/transport/Kconfig.in" + +menu "BLE Controller Options" + depends on SOC_BLE_SUPPORTED + source "$IDF_PATH/components/bt/porting_btdm/controller/ble/Kconfig.in" +endmenu + +menu "BREDR Controller Options" + depends on SOC_BT_CLASSIC_SUPPORTED + source "$IDF_PATH/components/bt/porting_btdm/controller/bredr/Kconfig.in" +endmenu diff --git a/components/bt/controller/esp32h4/Kconfig.ble.in b/components/bt/porting_btdm/controller/ble/Kconfig.in similarity index 96% rename from components/bt/controller/esp32h4/Kconfig.ble.in rename to components/bt/porting_btdm/controller/ble/Kconfig.in index 4ab95400b3..5fb4d0f6ea 100644 --- a/components/bt/controller/esp32h4/Kconfig.ble.in +++ b/components/bt/porting_btdm/controller/ble/Kconfig.in @@ -93,6 +93,30 @@ config BT_LE_POWER_CONTROL_ENABLED help Set this option to enable the Power Control feature on controller +config BT_LE_SUBRATE_ENABLED + bool "Enable BLE connection subrating" + depends on BT_LE_50_FEATURE_SUPPORT && SOC_BLE_SUBRATE_SUPPORTED + default n + help + Set this option to enable the Connection Subrating feature on controller + +config BT_LE_CTE_FEATURE_ENABLED + bool "Enable Bluetooth LE Direction Finding (AoA/AoD)" + depends on BT_LE_50_FEATURE_SUPPORT && SOC_BLE_CTE_SUPPORTED + default n + help + Enable this option to activate Bluetooth LE Direction Finding (AoA/AoD) feature. + Note: + This feature allows devices to determine the direction of a Bluetooth CTE signal, + enabling Angle of Arrival (AoA) and Angle of Departure (AoD) functionality. + +config BT_LE_PERIODIC_ADV_WITH_RESPONSE_ENABLED + bool "Enable BLE periodic advertising with response" + depends on BT_LE_50_FEATURE_SUPPORT && SOC_BLE_PERIODIC_ADV_WITH_RESPONSE + default n + help + This enables BLE periodic advertising with response feature + menuconfig BT_LE_ISO_SUPPORT bool "Enable BLE ISO feature" default n @@ -733,7 +757,3 @@ 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_LE_ERROR_SIM_ENABLED - bool "Enable controller features for internal testing" - default n diff --git a/components/bt/porting_btdm/controller/ble/include/os/os_mempool.h b/components/bt/porting_btdm/controller/ble/include/os/os_mempool.h index 05da058d1f..491bf8bb97 100644 --- a/components/bt/porting_btdm/controller/ble/include/os/os_mempool.h +++ b/components/bt/porting_btdm/controller/ble/include/os/os_mempool.h @@ -34,8 +34,10 @@ #define _OS_MEMPOOL_H_ #include -#include "os/os.h" + +#include "os/os_error.h" #include "os/queue.h" +#include "btdm_mempool.h" #ifdef __cplusplus extern "C" { @@ -76,10 +78,11 @@ struct os_mempool { SLIST_HEAD(,os_memblock); /** Name for memory block */ const char *name; - /** The number of allocated blocks. */ - uint32_t mp_alloc_blocks; }; +static_assert(sizeof(struct os_mempool) == sizeof(struct btdm_mempool), + "Error: size of os_mempool"); + /** * Indicates an extended mempool. Address can be safely cast to * (struct os_mempool_ext *). diff --git a/components/bt/porting_btdm/controller/bredr/Kconfig.in b/components/bt/porting_btdm/controller/bredr/Kconfig.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/bt/porting_btdm/controller/btdm_common/Kconfig.in b/components/bt/porting_btdm/controller/btdm_common/Kconfig.in new file mode 100644 index 0000000000..202eea1601 --- /dev/null +++ b/components/bt/porting_btdm/controller/btdm_common/Kconfig.in @@ -0,0 +1,17 @@ +choice BTDM_CTRL_MODE + prompt "Bluetooth Controller Mode (BLE/BREDR/DualMode)" + help + Specify the bluetooth controller mode (BR/EDR, BLE or dual mode). + + config BTDM_CTRL_MODE_BLE_ONLY + bool "BLE Only" + depends on SOC_BLE_SUPPORTED + + config BTDM_CTRL_MODE_BR_EDR_ONLY + bool "BR/EDR Only" + depends on SOC_BT_CLASSIC_SUPPORTED + + config BTDM_CTRL_MODE_BTDM + bool "Bluetooth Dual Mode" + depends on SOC_BLE_SUPPORTED && SOC_BT_CLASSIC_SUPPORTED +endchoice diff --git a/components/bt/porting_btdm/controller/btdm_common/src/btdm_lp.c b/components/bt/porting_btdm/controller/btdm_common/src/btdm_lp.c index 60c86ef6d7..dab55b0a6b 100644 --- a/components/bt/porting_btdm/controller/btdm_common/src/btdm_lp.c +++ b/components/bt/porting_btdm/controller/btdm_common/src/btdm_lp.c @@ -190,7 +190,7 @@ btdm_lp_wake_up_cb(void *arg) s_bt_active = true; } -#ifdef CONFIG_FREERTOS_USE_TICKLESS_IDLE +#if UC_BT_CTRL_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE static esp_err_t btdm_lp_modem_retention_create(void) { @@ -204,10 +204,12 @@ btdm_lp_modem_retention_create(void) } #if UC_BT_CTRL_BR_EDR_IS_ENABLE + // TODO: check the return value sleep_modem_bredr_mac_modem_state_init(); #endif // UC_BT_CTRL_BR_EDR_IS_ENABLE #if UC_BT_CTRL_BLE_IS_ENABLE + // TODO: check the return value sleep_modem_ble_mac_modem_state_init(); #endif // UC_BT_CTRL_BLE_IS_ENABLE return err; @@ -235,7 +237,7 @@ btdm_lp_modem_state_deinit(void) assert(err == ESP_OK); } } -#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE +#endif // UC_BT_CTRL_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE /* *************************************************************************************************** @@ -250,7 +252,7 @@ btdm_lp_enable_clock(esp_btdm_controller_config_t *cfg) modem_clock_module_mac_reset(PERIPH_BT_MODULE); // TODO: set the clock ion modem_clock_module_enable REG_WRITE(MODEM_SYSCON_CLK_CONF_POWER_ST_REG, 0XFFFFFFFF); - // btdm_lp_timer_clk_init(cfg); + btdm_lp_timer_clk_init(cfg); } void @@ -333,6 +335,9 @@ btdm_lp_reset(bool enable_stage) #endif // CONFIG_PM_ENABLE esp_phy_enable(PHY_MODEM_BT); + // TODO: Need to be deleted. + void phy_set_rfpll_xpd(bool en); + phy_set_rfpll_xpd(0); esp_btbb_enable(); s_bt_active = true; } else { diff --git a/components/bt/porting_btdm/controller/btdm_common/src/btdm_osal_freertos.c b/components/bt/porting_btdm/controller/btdm_common/src/btdm_osal_freertos.c index 3f21fb5fd8..0d0c18ad5a 100644 --- a/components/bt/porting_btdm/controller/btdm_common/src/btdm_osal_freertos.c +++ b/components/bt/porting_btdm/controller/btdm_common/src/btdm_osal_freertos.c @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include #include +#include #include #include "btdm_osal_freertos.h" #include "btdm_mempool.h" @@ -258,8 +259,10 @@ wr_btdm_osal_eventq_remove(struct btdm_osal_eventq *evq, struct btdm_osal_event portYIELD_FROM_ISR(); } } else { - portMUX_TYPE btdm_osal_mut = portMUX_INITIALIZER_UNLOCKED; - portENTER_CRITICAL(&btdm_osal_mut); + /* RISK: For multi-core, this mutex can't protect the queue from being changed by other cores + * with wr_btdm_osal_eventq_put(). The count maybe less than the actual. + */ + portENTER_CRITICAL(&s_btsm_osal_intr_mutex); count = uxQueueMessagesWaiting(eventq->q); for (i = 0; i < count; i++) { @@ -274,7 +277,7 @@ wr_btdm_osal_eventq_remove(struct btdm_osal_eventq *evq, struct btdm_osal_event BTDM_OSAL_ASSERT(ret == pdPASS); } - portEXIT_CRITICAL(&btdm_osal_mut); + portEXIT_CRITICAL(&s_btsm_osal_intr_mutex); } event->queued = 0; @@ -1152,6 +1155,10 @@ wr_btdm_osal_mmgmt_block_malloc(uint32_t size) // TODO: Only ble controller uses this function addr = btdm_osal_malloc(size + 4, BTDM_OSAL_MALLOC_F_INTERNAL); + if (!addr) { + return NULL; + } + *addr = (5 << 29) | ((size + 4) >> 2); return (void *)((uint32_t)addr + 4); @@ -1201,133 +1208,24 @@ wr_btdm_osal_srand(uint32_t seed) int wr_btdm_osal_rand(void) { + // TODO: use esp_random // return (int)esp_random(); + + static bool first = true; + + if (first) { + uint8_t mac[6]; + uint32_t seed; + + first = false; + btdm_osal_read_efuse_mac(mac); + seed = (mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | mac[5]; + srand(seed); + } + return rand(); } -/* - *************************************************************************************************** - * BTDM OSAL ISO Mutex (TODO: should be deleted) - *************************************************************************************************** - */ -btdm_osal_error_t -wr_btdm_osal_iso_mutex_init(struct btdm_osal_mutex *mu) -{ - struct btdm_osal_mutex_freertos *mutex; - -#if BTDM_MEMPOOL_ALLOC - if (!btdm_memblock_from(&s_btdm_osal_mutex_pool, mu->mutex)) { - mu->mutex = btdm_memblock_get(&s_btdm_osal_mutex_pool); - mutex = (struct btdm_osal_mutex_freertos *)mu->mutex; - - if (!mutex) { - return BTDM_OSAL_INVALID_PARM; - } - - memset(mutex, 0, sizeof(*mutex)); - mutex->handle = xSemaphoreCreateMutex(); - BTDM_OSAL_ASSERT(mutex->handle); - } -#else - if (!mu->mutex) { - mu->mutex = malloc(sizeof(struct btdm_osal_mutex_freertos)); - mutex = (struct btdm_osal_mutex_freertos *)mu->mutex; - - if (!mutex) { - return BTDM_OSAL_INVALID_PARM; - } - - memset(mutex, 0, sizeof(*mutex)); - mutex->handle = xSemaphoreCreateMutex(); - BTDM_OSAL_ASSERT(mutex->handle); - } -#endif - - return BTDM_OSAL_OK; -} - -btdm_osal_error_t -wr_btdm_osal_iso_mutex_deinit(struct btdm_osal_mutex *mu) -{ - struct btdm_osal_mutex_freertos *mutex; - - BTDM_OSAL_ASSERT(mu); - - mutex = (struct btdm_osal_mutex_freertos *)mu->mutex; - if (!mutex) { - return BTDM_OSAL_INVALID_PARM; - } - - BTDM_OSAL_ASSERT(mutex->handle); - vSemaphoreDelete(mutex->handle); - -#if BTDM_MEMPOOL_ALLOC - btdm_memblock_put(&s_btdm_osal_mutex_pool, mutex); -#else - free((void *)mutex); -#endif - mu->mutex = NULL; - - return BTDM_OSAL_OK; -} - -btdm_osal_error_t IRAM_ATTR -wr_btdm_osal_iso_mutex_pend(struct btdm_osal_mutex *mu, btdm_osal_time_t timeout) -{ - struct btdm_osal_mutex_freertos *mutex; - BaseType_t woken; - BaseType_t ret; - - mutex = (struct btdm_osal_mutex_freertos *)mu->mutex; - if (!mutex) { - return BTDM_OSAL_INVALID_PARM; - } - - BTDM_OSAL_ASSERT(mutex->handle); - - if (in_isr()) { - (void)timeout; - ret = xSemaphoreTakeFromISR(mutex->handle, &woken); - if (woken == pdTRUE) { - portYIELD_FROM_ISR(); - } - } else { - ret = xSemaphoreTake(mutex->handle, timeout); - } - - return ret == pdPASS ? BTDM_OSAL_OK : BTDM_OSAL_TIMEOUT; -} - -btdm_osal_error_t IRAM_ATTR -wr_btdm_osal_iso_mutex_release(struct btdm_osal_mutex *mu) -{ - struct btdm_osal_mutex_freertos *mutex; - BaseType_t woken; - BaseType_t ret; - - BTDM_OSAL_ASSERT(mu); - - mutex = (struct btdm_osal_mutex_freertos *)mu->mutex; - if (!mutex) { - return BTDM_OSAL_INVALID_PARM; - } - - BTDM_OSAL_ASSERT(mutex->handle); - - if (in_isr()) { - ret = xSemaphoreGiveFromISR(mutex->handle, &woken); - if (woken == pdTRUE) { - portYIELD_FROM_ISR(); - } - } else { - ret = xSemaphoreGive(mutex->handle); - } - - BTDM_OSAL_ASSERT(ret == pdPASS); - - return BTDM_OSAL_OK; -} - /* *************************************************************************************************** * BTDM OSAL Initialization @@ -1397,9 +1295,9 @@ btdm_osal_elem_mempool_init(btdm_osal_elem_num_t *elem_num) if (!s_btdm_osal_sem_buf) { return -7; } - rc = - btdm_mempool_init(&s_btdm_osal_sem_pool, elem_num->sem_count, sizeof(struct btdm_osal_sem_freertos), - s_btdm_osal_sem_buf, "s_btdm_osal_sem_pool"); + rc = btdm_mempool_init(&s_btdm_osal_sem_pool, elem_num->sem_count, + sizeof(struct btdm_osal_sem_freertos), + s_btdm_osal_sem_buf, "s_btdm_osal_sem_pool"); if (rc) { return -8; } diff --git a/components/bt/porting_btdm/transport/Kconfig.in b/components/bt/porting_btdm/transport/Kconfig.in new file mode 100644 index 0000000000..f9360b1c32 --- /dev/null +++ b/components/bt/porting_btdm/transport/Kconfig.in @@ -0,0 +1,131 @@ +menu "Bluetooth controller HCI" + config BT_CTRL_HCI_CMD_NUM + int "HCI CMD buffer number" + range 1 255 + default 5 + + choice BT_CTRL_HCI_INTERFACE + prompt "HCI mode" + default BT_CTRL_HCI_INTERFACE_USE_RAM + + config BT_CTRL_HCI_INTERFACE_USE_RAM + bool "VHCI" + help + Use RAM as HCI interface + config BT_CTRL_HCI_INTERFACE_USE_UART + bool "UART(H4)" + help + Use UART as HCI interface + endchoice + + choice BT_CTRL_UART_HCI_MODE_CHOICE + prompt "UART HCI mode" + depends on BT_CTRL_HCI_INTERFACE_USE_UART + default BT_CTRL_UART_HCI_NO_DMA_MODE + help + Specify UART HCI mode: DMA or No DMA + + config BT_CTRL_UART_HCI_DMA_MODE + bool "UHCI(UART with DMA)(EXPERIMENTAL)" + help + UART HCI Mode with DMA functionality. + + config BT_CTRL_UART_HCI_NO_DMA_MODE + bool "UART(NO DMA)" + help + UART HCI Mode without DMA functionality. + endchoice + + config BT_CTRL_HCI_UART_PORT + int "HCI UART port" + depends on BT_CTRL_HCI_INTERFACE_USE_UART + default 1 + help + Set the port number of HCI UART + + config BT_CTRL_HCI_UART_FLOWCTRL + bool "HCI uart Hardware Flow ctrl" + depends on BT_CTRL_HCI_INTERFACE_USE_UART + default n + + config BT_CTRL_HCI_UART_TX_PIN + int "HCI uart Tx gpio" + depends on BT_CTRL_HCI_INTERFACE_USE_UART + default 19 + + config BT_CTRL_HCI_UART_RX_PIN + int "HCI uart Rx gpio" + depends on BT_CTRL_HCI_INTERFACE_USE_UART + default 10 + + config BT_CTRL_HCI_UART_RTS_PIN + int "HCI uart RTS gpio" + depends on BT_CTRL_HCI_UART_FLOWCTRL + default 4 + + config BT_CTRL_HCI_UART_CTS_PIN + int "HCI uart CTS gpio" + depends on BT_CTRL_HCI_UART_FLOWCTRL + default 5 + + config BT_CTRL_HCI_UART_BAUD + int "HCI uart baudrate" + depends on BT_CTRL_HCI_INTERFACE_USE_UART + default 921600 + help + HCI uart baud rate 115200 ~ 1000000 + + choice BT_CTRL_HCI_UART_PARITY + prompt "select uart parity" + depends on BT_CTRL_HCI_INTERFACE_USE_UART + default BT_CTRL_HCI_UART_UART_PARITY_DISABLE + + config BT_CTRL_HCI_UART_UART_PARITY_DISABLE + bool "PARITY_DISABLE" + help + UART_PARITY_DISABLE + config BT_CTRL_HCI_UART_UART_PARITY_EVEN + bool "PARITY_EVEN" + help + UART_PARITY_EVEN + config BT_CTRL_HCI_UART_UART_PARITY_ODD + bool "PARITY_ODD" + help + UART_PARITY_ODD + endchoice + + config BT_CTRL_HCI_UART_RX_BUFFER_SIZE + int "The size of rx ring buffer memory" + depends on BT_CTRL_UART_HCI_NO_DMA_MODE + default 512 + help + The size of rx ring buffer memory + + config BT_CTRL_HCI_UART_TX_BUFFER_SIZE + int "The size of tx ring buffer memory" + depends on BT_CTRL_UART_HCI_NO_DMA_MODE + default 256 + help + The size of tx ring buffer memory + + config BT_CTRL_HCI_TRANS_TASK_STACK_SIZE + int "HCI transport task stack size" + depends on !BT_CTRL_HCI_INTERFACE_USE_RAM + default 1024 + help + This configures stack size of hci transport task + + config BT_CTRL_HCI_TRANS_RX_MEM_NUM + int "The amount of rx memory received at the same time" + depends on BT_CTRL_UART_HCI_DMA_MODE + default 3 + help + The amount of rx memory received at the same time + + config BT_CTRL_HCI_LLDESCS_POOL_NUM + int "The amount of lldecs memory for driver dma mode" + depends on BT_CTRL_UART_HCI_DMA_MODE + default 20 + help + The amount of lldecs memory for driver dma mode +endmenu diff --git a/components/bt/porting_btdm/transport/driver/common/hci_driver_h4.c b/components/bt/porting_btdm/transport/driver/common/hci_driver_h4.c index 4515d1504c..b0e01a3b16 100644 --- a/components/bt/porting_btdm/transport/driver/common/hci_driver_h4.c +++ b/components/bt/porting_btdm/transport/driver/common/hci_driver_h4.c @@ -56,7 +56,6 @@ hci_h4_frame_start(struct hci_h4_sm *rxs, uint8_t pkt_type) switch (rxs->pkt_type) { case HCI_H4_CMD: - case HCI_H4_SYNC: rxs->min_len = 3; break; case HCI_H4_ACL: @@ -130,20 +129,20 @@ hci_h4_sm_w4_header(struct hci_h4_sm *h4sm, struct hci_h4_input_buffer *ib) conn_handle = btdm_get_le16(&h4sm->hdr[0]) & HCI_INTERNAL_CONN_MASK; #if UC_BT_CTRL_BLE_IS_ENABLE if (HCI_INTERNAL_CONN_IS_BLE(conn_handle)) { - assert(h4sm->allocs && h4sm->allocs->acl); h4sm->om = h4sm->allocs->acl(); if (!h4sm->om) { return -1; } - ble_mbuf_append(h4sm->om, h4sm->hdr, h4sm->len); + if (ble_mbuf_append(h4sm->om, h4sm->hdr, h4sm->len)) { + return -1; + } h4sm->exp_len = btdm_get_le16(&h4sm->hdr[2]) + 4; break; } #endif // UC_BT_CTRL_BLE_IS_ENABLE #if UC_BT_CTRL_BR_EDR_IS_ENABLE if (HCI_INTERNAL_CONN_IS_BREDR(conn_handle)) { - assert(h4sm->allocs && h4sm->allocs->bredr_acl); h4sm->exp_len = btdm_get_le16(&h4sm->hdr[2]) + 4; h4sm->pkt = h4sm->allocs->bredr_acl(conn_handle); if (!h4sm->pkt) { @@ -152,9 +151,9 @@ hci_h4_sm_w4_header(struct hci_h4_sm *h4sm, struct hci_h4_input_buffer *ib) memcpy(h4sm->pkt->data, h4sm->hdr, h4sm->len); break; } + return -1; case HCI_H4_SYNC: conn_handle = btdm_get_le16(&h4sm->hdr[0]) & HCI_INTERNAL_CONN_MASK; - assert(h4sm->allocs && h4sm->allocs->sync); h4sm->exp_len = h4sm->hdr[2] + 3; h4sm->pkt = h4sm->allocs->sync(conn_handle); if (!h4sm->pkt) { @@ -198,7 +197,6 @@ hci_h4_sm_w4_header(struct hci_h4_sm *h4sm, struct hci_h4_input_buffer *ib) #endif // !CONFIG_BT_CONTROLLER_ENABLED #if CONFIG_BT_LE_ISO_SUPPORT case HCI_H4_ISO: - assert(h4sm->allocs && h4sm->allocs->iso); h4sm->exp_len = (btdm_get_le16(&h4sm->hdr[2]) & 0x7fff) + 4; h4sm->buf = h4sm->allocs->iso(h4sm->exp_len); if (!h4sm->buf) { @@ -209,8 +207,7 @@ hci_h4_sm_w4_header(struct hci_h4_sm *h4sm, struct hci_h4_input_buffer *ib) break; #endif // CONFIG_BT_LE_ISO_SUPPORT default: - assert(0); - break; + return -2; } return 0; @@ -223,23 +220,21 @@ hci_h4_sm_w4_payload(struct hci_h4_sm *h4sm, uint16_t len; len = min(ib->len, h4sm->exp_len - h4sm->len); - - switch (h4sm->pkt_type) { case HCI_H4_CMD: - case HCI_H4_SYNC: if (h4sm->pkt) { memcpy(&h4sm->pkt->data[h4sm->len], ib->buf, len); } break; - case HCI_H4_EVT: +#if !CONFIG_BT_CONTROLLER_ENABLED + case HCI_H4_EVT: +#endif // !CONFIG_BT_CONTROLLER_ENABLED case HCI_H4_ISO: if (h4sm->buf) { memcpy(&h4sm->buf[h4sm->len], ib->buf, len); } break; case HCI_H4_ACL: - HCI_TRANS_ASSERT(h4sm->om, h4sm->pkt_type, len); uint16_t conn_handle = btdm_get_le16(&h4sm->hdr[0]) & HCI_INTERNAL_CONN_MASK; #if UC_BT_CTRL_BR_EDR_IS_ENABLE if (HCI_INTERNAL_CONN_IS_BREDR(conn_handle)) { @@ -253,8 +248,8 @@ hci_h4_sm_w4_payload(struct hci_h4_sm *h4sm, int rc = ble_mbuf_append(h4sm->om, ib->buf, len); if (rc) { /* Some data may already be appended so need to adjust h4sm only by - * the size of appended data. - */ + * the size of appended data. + */ len = BLE_MBUF_PKTLEN(h4sm->om) - mbuf_len; h4sm->len += len; hci_h4_ib_consume(ib, len); @@ -264,8 +259,7 @@ hci_h4_sm_w4_payload(struct hci_h4_sm *h4sm, break; #endif // UC_BT_CTRL_BLE_IS_ENABLE default: - assert(0); - break; + return -2; } h4sm->len += len; @@ -281,7 +275,6 @@ hci_h4_sm_completed(struct hci_h4_sm *h4sm) int rc; uint8_t data_source = 0xFF; - HCI_TRANS_ASSERT(h4sm->frame_cb, 0, 0); switch (h4sm->pkt_type) { #if CONFIG_BT_CONTROLLER_ENABLED case HCI_H4_ACL: @@ -306,23 +299,18 @@ hci_h4_sm_completed(struct hci_h4_sm *h4sm) #endif // UC_BT_CTRL_BR_EDR_IS_ENABLE break; case HCI_H4_CMD: - case HCI_H4_SYNC: case HCI_H4_ISO: if (h4sm->buf) { switch(h4sm->pkt_type) { case HCI_H4_CMD: data_source = HCI_DRIVER_CMD; break; - case HCI_H4_SYNC: - data_source = HCI_DRIVER_BREDR_SYNC; - break; case HCI_H4_ISO: data_source = HCI_DRIVER_LE_ISO; break; } rc = h4sm->frame_cb(h4sm->pkt_type, (void *)h4sm->buf, h4sm->len, data_source); - HCI_TRANS_ASSERT(rc == 0, rc, 0); h4sm->buf = NULL; } break; @@ -330,7 +318,6 @@ hci_h4_sm_completed(struct hci_h4_sm *h4sm) case HCI_H4_CMD: case HCI_H4_EVT: if (h4sm->buf) { - assert(h4sm->frame_cb); rc = h4sm->frame_cb(h4sm->pkt_type, h4sm->buf); if (rc != 0) { ble_transport_free(h4sm->buf); @@ -341,7 +328,6 @@ hci_h4_sm_completed(struct hci_h4_sm *h4sm) case HCI_H4_ACL: case HCI_H4_ISO: if (h4sm->om) { - assert(h4sm->frame_cb); rc = h4sm->frame_cb(h4sm->pkt_type, h4sm->om); if (rc != 0) { os_mbuf_free_chain(h4sm->om); @@ -416,7 +402,6 @@ hci_h4_sm_free_buf(struct hci_h4_sm *h4sm) return 0; } - int hci_h4_sm_rx(struct hci_h4_sm *h4sm, const uint8_t *buf, uint16_t len) { @@ -439,18 +424,18 @@ hci_h4_sm_rx(struct hci_h4_sm *h4sm, const uint8_t *buf, uint16_t len) /* no break */ case HCI_H4_SM_W4_HEADER: rc = hci_h4_sm_w4_header(h4sm, &ib); - assert(rc >= 0); if (rc) { break; } + h4sm->state = HCI_H4_SM_W4_PAYLOAD; /* no break */ case HCI_H4_SM_W4_PAYLOAD: rc = hci_h4_sm_w4_payload(h4sm, &ib); - assert(rc >= 0); if (rc) { break; } + h4sm->state = HCI_H4_SM_COMPLETED; /* no break */ case HCI_H4_SM_COMPLETED: @@ -462,6 +447,11 @@ hci_h4_sm_rx(struct hci_h4_sm *h4sm, const uint8_t *buf, uint16_t len) } } + if (rc < 0) { + hci_h4_sm_free_buf(h4sm); + h4sm->state = HCI_H4_SM_W4_PKT_TYPE; + return -1; + } /* Calculate consumed bytes * * Note: we should always consume some bytes unless there is an oom error. diff --git a/components/bt/porting_btdm/transport/driver/uart/hci_driver_uart.c b/components/bt/porting_btdm/transport/driver/uart/hci_driver_uart.c index f608604df6..c297b24665 100644 --- a/components/bt/porting_btdm/transport/driver/uart/hci_driver_uart.c +++ b/components/bt/porting_btdm/transport/driver/uart/hci_driver_uart.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -61,7 +61,7 @@ hci_driver_uart_tx(hci_driver_data_type_t data_type, uint8_t *data, uint32_t len data_source = HCI_DRIVER_LE_ISO; } } -#if UC_BTDM_CTRL_BR_EDR_IS_ENABLE +#if UC_BT_CTRL_BR_EDR_IS_ENABLE else if (dir == HCI_DRIVER_DIR_BREDRC2H) { if (data_type == HCI_DRIVER_TYPE_ACL) { data_source = HCI_DRIVER_BREDR_ACL; @@ -71,7 +71,7 @@ hci_driver_uart_tx(hci_driver_data_type_t data_type, uint8_t *data, uint32_t len data_source = HCI_DRIVER_BREDR_EVT; } } -#endif // UC_BTDM_CTRL_BR_EDR_IS_ENABLE +#endif // UC_BT_CTRL_BR_EDR_IS_ENABLE else { assert(0); } @@ -158,19 +158,19 @@ hci_driver_uart_task_create(void) { /* !TODO: Set the core id by menuconfig */ xTaskCreatePinnedToCore(hci_driver_uart_tx_task, "hci_driver_uart_tx_task", - UC_BTDM_CTRL_HCI_TRANS_TASK_STACK_SIZE, NULL, + UC_BT_CTRL_HCI_TRANS_TASK_STACK_SIZE, NULL, ESP_TASK_BT_CONTROLLER_PRIO, &s_hci_driver_uart_env.tx_task_handler, 0); assert(s_hci_driver_uart_env.tx_task_handler); xTaskCreatePinnedToCore(hci_driver_uart_rx_task, "hci_driver_uart_rx_task", - UC_BTDM_CTRL_HCI_TRANS_TASK_STACK_SIZE, NULL, + UC_BT_CTRL_HCI_TRANS_TASK_STACK_SIZE, NULL, ESP_TASK_BT_CONTROLLER_PRIO, &s_hci_driver_uart_env.rx_task_handler, 0); assert(s_hci_driver_uart_env.rx_task_handler); ESP_LOGI(TAG, "hci transport task create successfully, prio:%d, stack size: %ld", - ESP_TASK_BT_CONTROLLER_PRIO, UC_BTDM_CTRL_HCI_TRANS_TASK_STACK_SIZE); + ESP_TASK_BT_CONTROLLER_PRIO, UC_BT_CTRL_HCI_TRANS_TASK_STACK_SIZE); return 0; } @@ -228,8 +228,8 @@ hci_driver_uart_init(hci_driver_forward_fn *cb) hci_driver_uart_config(s_hci_driver_uart_env.hci_uart_params); /* Currently, the queue size is set to 1. It will be considered as semaphore. */ ESP_ERROR_CHECK(uart_driver_install(s_hci_driver_uart_env.hci_uart_params->hci_uart_port, - UC_BTDM_CTRL_HCI_UART_RX_BUFFER_SIZE, - UC_BTDM_CTRL_HCI_UART_TX_BUFFER_SIZE, + UC_BT_CTRL_HCI_UART_RX_BUFFER_SIZE, + UC_BT_CTRL_HCI_UART_TX_BUFFER_SIZE, 1, &s_hci_driver_uart_env.rx_event_queue, 0)); @@ -254,8 +254,8 @@ hci_driver_uart_reconfig_pin(int tx_pin, int rx_pin, int cts_pin, int rts_pin) hci_driver_uart_pin_update(tx_pin, rx_pin, cts_pin, rts_pin); /* Currently, the queue size is set to 1. It will be considered as semaphore. */ ESP_ERROR_CHECK(uart_driver_install(s_hci_driver_uart_env.hci_uart_params->hci_uart_port, - UC_BTDM_CTRL_HCI_UART_RX_BUFFER_SIZE, - UC_BTDM_CTRL_HCI_UART_TX_BUFFER_SIZE, + UC_BT_CTRL_HCI_UART_RX_BUFFER_SIZE, + UC_BT_CTRL_HCI_UART_TX_BUFFER_SIZE, 1, &s_hci_driver_uart_env.rx_event_queue, 0)); rc = hci_driver_uart_task_create(); diff --git a/components/bt/porting_btdm/transport/driver/uart/hci_driver_uart.h b/components/bt/porting_btdm/transport/driver/uart/hci_driver_uart.h index 5d5345c3da..a653a12864 100644 --- a/components/bt/porting_btdm/transport/driver/uart/hci_driver_uart.h +++ b/components/bt/porting_btdm/transport/driver/uart/hci_driver_uart.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -33,16 +33,16 @@ typedef struct hci_driver_uart_params_config } hci_driver_uart_params_config_t; #define BT_HCI_DRIVER_UART_CONFIG_DEFAULT() { \ - .hci_uart_port = UC_BTDM_CTRL_HCI_UART_PORT, \ - .hci_uart_baud = UC_BTDM_CTRL_HCI_UART_BAUD, \ - .hci_uart_tx_pin = UC_BTDM_CTRL_HCI_UART_TX_PIN , \ - .hci_uart_rx_pin = UC_BTDM_CTRL_HCI_UART_RX_PIN, \ - .hci_uart_cts_pin = UC_BTDM_CTRL_HCI_UART_CTS_PIN, \ - .hci_uart_rts_pin = UC_BTDM_CTRL_HCI_UART_RTS_PIN, \ - .hci_uart_data_bits = UC_BTDM_CTRL_HCI_UART_DATA_BITS, \ - .hci_uart_stop_bits = UC_BTDM_CTRL_HCI_UART_STOP_BITS, \ - .hci_uart_flow_ctrl = UC_BTDM_CTRL_HCI_UART_FLOW_CTRL, \ - .hci_uart_parity = UC_BTDM_CTRL_HCI_UART_PARITY, \ + .hci_uart_port = UC_BT_CTRL_HCI_UART_PORT, \ + .hci_uart_baud = UC_BT_CTRL_HCI_UART_BAUD, \ + .hci_uart_tx_pin = UC_BT_CTRL_HCI_UART_TX_PIN , \ + .hci_uart_rx_pin = UC_BT_CTRL_HCI_UART_RX_PIN, \ + .hci_uart_cts_pin = UC_BT_CTRL_HCI_UART_CTS_PIN, \ + .hci_uart_rts_pin = UC_BT_CTRL_HCI_UART_RTS_PIN, \ + .hci_uart_data_bits = UC_BT_CTRL_HCI_UART_DATA_BITS, \ + .hci_uart_stop_bits = UC_BT_CTRL_HCI_UART_STOP_BITS, \ + .hci_uart_flow_ctrl = UC_BT_CTRL_HCI_UART_FLOW_CTRL, \ + .hci_uart_parity = UC_BT_CTRL_HCI_UART_PARITY, \ } /** diff --git a/components/bt/porting_btdm/transport/driver/vhci/hci_driver_nimble.c b/components/bt/porting_btdm/transport/driver/vhci/hci_driver_nimble.c index 80adca189d..149be16e1d 100644 --- a/components/bt/porting_btdm/transport/driver/vhci/hci_driver_nimble.c +++ b/components/bt/porting_btdm/transport/driver/vhci/hci_driver_nimble.c @@ -68,7 +68,7 @@ hci_driver_ops_t hci_driver_vhci_ops = { /* Special APIs used by host to send message. */ int -hci_driver_host_cmd_tx(uint8_t *data, uint32_t length) +hci_driver_host_cmd_tx(uint8_t *data) { #if 0 hci_driver_packet_t *pkt = NULL; @@ -83,7 +83,7 @@ hci_driver_host_cmd_tx(uint8_t *data, uint32_t length) r_ble_hci_trans_buf_free(data); return s_hci_driver_vhci_env.forward_cb(HCI_DRIVER_TYPE_CMD, (uint8_t *)pkt, pkt_len, HCI_DRIVER_DIR_H2C, HCI_DRIVER_CMD); #else - return s_hci_driver_vhci_env.forward_cb(HCI_DRIVER_TYPE_CMD, data, length, HCI_DRIVER_DIR_H2C, HCI_DRIVER_CMD); + return s_hci_driver_vhci_env.forward_cb(HCI_DRIVER_TYPE_CMD, data, 0, HCI_DRIVER_DIR_H2C, HCI_DRIVER_CMD); #endif } diff --git a/components/bt/porting_btdm/transport/driver/vhci/hci_driver_standard.c b/components/bt/porting_btdm/transport/driver/vhci/hci_driver_standard.c index 41426e9a60..22d4b687cd 100644 --- a/components/bt/porting_btdm/transport/driver/vhci/hci_driver_standard.c +++ b/components/bt/porting_btdm/transport/driver/vhci/hci_driver_standard.c @@ -61,6 +61,7 @@ hci_driver_vhci_host_recv_with_type(uint8_t data_type, uint8_t *data, uint16_t l return -1; } +#if 0 static void hci_driver_vhci_host_send_available(void) { @@ -71,6 +72,7 @@ hci_driver_vhci_host_send_available(void) host_recv_cb->notify_host_send_available(); } } +#endif static int hci_driver_vhci_controller_tx(hci_driver_data_type_t data_type, uint8_t *data, uint32_t length, hci_driver_direction_t dir) diff --git a/components/bt/porting_btdm/transport/include/esp_hci_driver.h b/components/bt/porting_btdm/transport/include/esp_hci_driver.h index 08ef8d3b35..7f8586e8ef 100644 --- a/components/bt/porting_btdm/transport/include/esp_hci_driver.h +++ b/components/bt/porting_btdm/transport/include/esp_hci_driver.h @@ -78,10 +78,9 @@ int hci_driver_host_callback_register(hci_driver_host_recv_fn *callback); /** * @brief Called to send HCI commands form host to controller. * @param data Point to the commands data - * @param length Length of data * @return int 0 on success, non-zero error code on failure. */ -int hci_driver_host_cmd_tx(uint8_t *data, uint32_t length); +int hci_driver_host_cmd_tx(uint8_t *data); /** * @brief Called to send HCI ACL form host to controller. diff --git a/components/esp_coex/Kconfig b/components/esp_coex/Kconfig index bc37b3820b..2fdb5cdb3f 100644 --- a/components/esp_coex/Kconfig +++ b/components/esp_coex/Kconfig @@ -3,6 +3,7 @@ menu "Wireless Coexistence" config ESP_COEX_ENABLED bool + default n if IDF_TARGET_ESP32H4 #TODO: enable coexistence for ESP32H4 default y if (!SOC_WIRELESS_HOST_SUPPORTED) if(ESP_COEX_ENABLED) diff --git a/components/esp_hw_support/modem/port/esp32h4/modem_clock_impl.c b/components/esp_hw_support/modem/port/esp32h4/modem_clock_impl.c index fa79beef17..fd06a20173 100644 --- a/components/esp_hw_support/modem/port/esp32h4/modem_clock_impl.c +++ b/components/esp_hw_support/modem/port/esp32h4/modem_clock_impl.c @@ -225,7 +225,7 @@ IRAM_ATTR uint8_t *modem_clock_domain_icg_config(void) static DRAM_ATTR uint8_t icg_config_default[MODEM_CLOCK_DOMAIN_MAX] = { [MODEM_CLOCK_DOMAIN_MODEM_APB] = ICG_NOGATING_ACTIVE | ICG_NOGATING_MODEM, [MODEM_CLOCK_DOMAIN_MODEM_PERIPH] = ICG_NOGATING_ACTIVE, - // [MODEM_CLOCK_DOMAIN_BT] = ICG_NOGATING_ACTIVE, + [MODEM_CLOCK_DOMAIN_BT] = ICG_NOGATING_ACTIVE, [MODEM_CLOCK_DOMAIN_MODEM_FE] = ICG_NOGATING_ACTIVE | ICG_NOGATING_MODEM, [MODEM_CLOCK_DOMAIN_IEEE802154] = ICG_NOGATING_ACTIVE, [MODEM_CLOCK_DOMAIN_LP_APB] = ICG_NOGATING_ACTIVE | ICG_NOGATING_MODEM, diff --git a/docs/doxygen/Doxyfile_esp32h4 b/docs/doxygen/Doxyfile_esp32h4 index e3083020b6..4de8000e1c 100644 --- a/docs/doxygen/Doxyfile_esp32h4 +++ b/docs/doxygen/Doxyfile_esp32h4 @@ -1,4 +1,6 @@ INPUT += \ + $(PROJECT_PATH)/components/bt/include/$(IDF_TARGET)/include/esp_bt.h \ + $(PROJECT_PATH)/components/bt/include/$(IDF_TARGET)/include/esp_bt_vs.h \ $(PROJECT_PATH)/components/esp_phy/include/esp_phy_init.h \ $(PROJECT_PATH)/components/esp_phy/include/esp_phy_cert_test.h \ $(PROJECT_PATH)/components/esp_driver_touch_sens/hw_ver3/include/driver/touch_version_types.h \ diff --git a/docs/en/api-guides/performance/speed.rst b/docs/en/api-guides/performance/speed.rst index cc00a20423..883aa764a1 100644 --- a/docs/en/api-guides/performance/speed.rst +++ b/docs/en/api-guides/performance/speed.rst @@ -3,7 +3,7 @@ Speed Optimization :link_to_translation:`zh_CN:[中文]` -{IDF_TARGET_CONTROLLER_CORE_CONFIG:default="CONFIG_BT_CTRL_PINNED_TO_CORE", esp32="CONFIG_BTDM_CTRL_PINNED_TO_CORE_CHOICE", esp32s3="CONFIG_BT_CTRL_PINNED_TO_CORE_CHOICE"} +{IDF_TARGET_CONTROLLER_CORE_CONFIG:default="CONFIG_BT_CTRL_PINNED_TO_CORE_CHOICE", esp32="CONFIG_BTDM_CTRL_PINNED_TO_CORE_CHOICE", esp32s3="CONFIG_BT_CTRL_PINNED_TO_CORE_CHOICE"} {IDF_TARGET_RF_TYPE:default="Wi-Fi/Bluetooth", esp32s2="Wi-Fi", esp32c6="Wi-Fi/Bluetooth/802.15.4", esp32c61="Wi-Fi/Bluetooth", esp32h2="Bluetooth/802.15.4", esp32h21="Bluetooth/802.15.4", esp32h4="Bluetooth/802.15.4", esp32c5="Wi-Fi/Bluetooth/802.15.4"} Overview diff --git a/docs/en/api-reference/bluetooth/bt_vhci.rst b/docs/en/api-reference/bluetooth/bt_vhci.rst index 0e117eda49..20f9e96604 100644 --- a/docs/en/api-reference/bluetooth/bt_vhci.rst +++ b/docs/en/api-reference/bluetooth/bt_vhci.rst @@ -40,7 +40,7 @@ The following HCI VS commands are exclusively for Espressif's Bluetooth Host (ES .. doxygendefine:: ESP_BT_VS_SET_LE_VENDOR_EVTS_MASK_OCF -.. only:: esp32c5 or esp32c6 or esp32h2 or esp32c61 +.. only:: esp32c5 or esp32c6 or esp32h2 or esp32c61 or esp32h4 or esp32s31 .. doxygendefine:: ESP_BT_VS_CONFIG_DUP_EXC_LIST_OCF .. doxygendefine:: ESP_BT_VS_SET_ADV_REPORT_FLOW_CTRL_OCF @@ -82,7 +82,7 @@ The following HCI VS events are exclusively for Espressif's Bluetooth Host (ESP- .. doxygendefine:: ESP_BT_VS_LE_ADV_LOST_EVT_SUBCODE -.. only:: esp32c6 or esp32h2 or esp32c5 or esp32c61 +.. only:: esp32c6 or esp32h2 or esp32c5 or esp32c61 or esp32h4 or esp32s31 .. doxygendefine:: ESP_BT_VS_LE_CONN_SCAN_REQ_RXED_EVT_SUBCODE .. doxygendefine:: ESP_BT_VS_LE_CHAN_UPDATE_COMP_EVT_SUBCODE @@ -206,7 +206,7 @@ The following HCI VS debugging commands are implemented in Bluetooth Low Energy .. doxygendefine:: ESP_BT_VS_CFG_TEST_RELATED_SUBCMD_MAX -.. only:: esp32c6 or esp32h2 or esp32c5 or esp32c61 +.. only:: esp32c6 or esp32h2 or esp32c5 or esp32c61 or esp32h4 or esp32s31 .. doxygendefine:: ESP_BT_VS_CFG_TEST_RELATED_OCF .. doxygendefine:: ESP_BT_VS_CFG_TEST_ENABLE_SUBCMD @@ -272,7 +272,7 @@ The following HCI VS debugging commands are implemented in Bluetooth Low Energy -.. only:: esp32 or esp32c5 or esp32c6 or esp32c61 or esp32h2 +.. only:: esp32 or esp32c5 or esp32c6 or esp32c61 or esp32h2 or esp32h4 or esp32s31 HCI VS Events for Espressif's Internal-Use Debugging ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -286,6 +286,6 @@ The following HCI VS debugging commands are implemented in Bluetooth Low Energy .. doxygendefine:: ESP_BT_VS_CH_CLASSIFICATION_REPORTING_MODE_EVT_SUBCODE - .. only:: esp32c5 or esp32c6 or esp32c61 or esp32h2 + .. only:: esp32c5 or esp32c6 or esp32c61 or esp32h2 or esp32h4 or esp32s31 .. doxygendefine:: ESP_BT_VS_LE_RUNNING_STATUS_EVT_SUBCODE diff --git a/docs/zh_CN/api-guides/performance/speed.rst b/docs/zh_CN/api-guides/performance/speed.rst index a49bd3ecb8..8c6823d1b5 100644 --- a/docs/zh_CN/api-guides/performance/speed.rst +++ b/docs/zh_CN/api-guides/performance/speed.rst @@ -3,7 +3,7 @@ :link_to_translation:`en:[English]` -{IDF_TARGET_CONTROLLER_CORE_CONFIG:default="CONFIG_BT_CTRL_PINNED_TO_CORE", esp32="CONFIG_BTDM_CTRL_PINNED_TO_CORE_CHOICE", esp32s3="CONFIG_BT_CTRL_PINNED_TO_CORE_CHOICE"} +{IDF_TARGET_CONTROLLER_CORE_CONFIG:default="CONFIG_BT_CTRL_PINNED_TO_CORE_CHOICE", esp32="CONFIG_BTDM_CTRL_PINNED_TO_CORE_CHOICE", esp32s3="CONFIG_BT_CTRL_PINNED_TO_CORE_CHOICE"} {IDF_TARGET_RF_TYPE:default="Wi-Fi/蓝牙", esp32s2="Wi-Fi", esp32c6="Wi-Fi/蓝牙/802.15.4", esp32c61="Wi-Fi/蓝牙", esp32h2="蓝牙/802.15.4", esp32h21="蓝牙/802.15.4", esp32h4="蓝牙/802.15.4", esp32c5="Wi-Fi/蓝牙/802.15.4"} 概述 diff --git a/examples/bluetooth/bluedroid/ble/gatt_server/sdkconfig.defaults.esp32h4 b/examples/bluetooth/bluedroid/ble/gatt_server/sdkconfig.defaults.esp32h4 new file mode 100644 index 0000000000..ace272433e --- /dev/null +++ b/examples/bluetooth/bluedroid/ble/gatt_server/sdkconfig.defaults.esp32h4 @@ -0,0 +1,3 @@ +# Override some defaults so BT stack is enabled +# by default in this example +CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y diff --git a/examples/bluetooth/bluedroid/ble_50/ble50_security_server/sdkconfig.defaults.esp32h4 b/examples/bluetooth/bluedroid/ble_50/ble50_security_server/sdkconfig.defaults.esp32h4 new file mode 100644 index 0000000000..63128cc627 --- /dev/null +++ b/examples/bluetooth/bluedroid/ble_50/ble50_security_server/sdkconfig.defaults.esp32h4 @@ -0,0 +1,4 @@ +# This file was generated using idf.py save-defconfig. It can be edited manually. +# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration +# +CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y diff --git a/examples/bluetooth/esp_hid_device/main/esp_hid_device_main.c b/examples/bluetooth/esp_hid_device/main/esp_hid_device_main.c index 4da5f37f67..d0081b843b 100644 --- a/examples/bluetooth/esp_hid_device/main/esp_hid_device_main.c +++ b/examples/bluetooth/esp_hid_device/main/esp_hid_device_main.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -966,9 +966,6 @@ void app_main(void) ble_hs_cfg.store_status_cb = ble_store_util_status_rr; /* Starting nimble task after gatts is initialized*/ - ret = esp_nimble_enable(ble_hid_device_host_task); - if (ret) { - ESP_LOGE(TAG, "esp_nimble_enable failed: %d", ret); - } + nimble_port_freertos_init(ble_hid_device_host_task); #endif } diff --git a/examples/bluetooth/esp_hid_host/main/esp_hid_host_main.c b/examples/bluetooth/esp_hid_host/main/esp_hid_host_main.c index 8934b60c1a..ab9d8aa21e 100644 --- a/examples/bluetooth/esp_hid_host/main/esp_hid_host_main.c +++ b/examples/bluetooth/esp_hid_host/main/esp_hid_host_main.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -238,10 +238,7 @@ void app_main(void) ble_hs_cfg.store_status_cb = ble_store_util_status_rr; /* Starting nimble task after gatts is initialized*/ - ret = esp_nimble_enable(ble_hid_host_task); - if (ret) { - ESP_LOGE(TAG, "esp_nimble_enable failed: %d", ret); - } + nimble_port_freertos_init(ble_hid_host_task); vTaskDelay(200); diff --git a/examples/bluetooth/nimble/blecent/main/main.c b/examples/bluetooth/nimble/blecent/main/main.c index 1f11f9f2bd..ad4611a413 100644 --- a/examples/bluetooth/nimble/blecent/main/main.c +++ b/examples/bluetooth/nimble/blecent/main/main.c @@ -50,6 +50,8 @@ #define TEST_CI_ADDRESS_CHIP_OFFSET (7) #elif CONFIG_IDF_TARGET_ESP32C61 #define TEST_CI_ADDRESS_CHIP_OFFSET (8) +#elif CONFIG_IDF_TARGET_ESP32H4 +#define TEST_CI_ADDRESS_CHIP_OFFSET (9) #endif #endif diff --git a/examples/bluetooth/nimble/hci/main/main.c b/examples/bluetooth/nimble/hci/main/main.c index 11647e5a30..c198c3a960 100644 --- a/examples/bluetooth/nimble/hci/main/main.c +++ b/examples/bluetooth/nimble/hci/main/main.c @@ -9,12 +9,14 @@ #include "esp_bt.h" -#ifndef CONFIG_BT_LE_HCI_INTERFACE_USE_UART +#if !CONFIG_BT_LE_HCI_INTERFACE_USE_UART && !CONFIG_BT_CTRL_HCI_INTERFACE_USE_UART #error "Please Enable Uart for HCI" #endif + #if (CONFIG_ENABLE_DTM_CONFIGURATION_COMMAND) #include "dtm_configuration_command.h" #endif // CONFIG_ENABLE_DTM_CONFIGURATION_COMMAND + #define TAG "BLE_HCI" void diff --git a/examples/bluetooth/nimble/hci/sdkconfig.defaults b/examples/bluetooth/nimble/hci/sdkconfig.defaults index 4bf1aa850d..0ab205764c 100644 --- a/examples/bluetooth/nimble/hci/sdkconfig.defaults +++ b/examples/bluetooth/nimble/hci/sdkconfig.defaults @@ -3,7 +3,3 @@ # CONFIG_BT_ENABLED=y CONFIG_BT_CONTROLLER_ONLY=y -CONFIG_BT_LE_HCI_INTERFACE_USE_UART=y -CONFIG_BT_LE_HCI_UART_TX_PIN=8 -CONFIG_BT_LE_HCI_UART_RX_PIN=9 -CONFIG_BT_LE_HCI_UART_BAUD=115200 diff --git a/examples/bluetooth/nimble/hci/sdkconfig.defaults.esp32c2 b/examples/bluetooth/nimble/hci/sdkconfig.defaults.esp32c2 new file mode 100644 index 0000000000..a263772188 --- /dev/null +++ b/examples/bluetooth/nimble/hci/sdkconfig.defaults.esp32c2 @@ -0,0 +1,6 @@ +# Override some defaults so BT stack is enabled +# by default in this example +CONFIG_BT_LE_HCI_INTERFACE_USE_UART=y +CONFIG_BT_LE_HCI_UART_TX_PIN=8 +CONFIG_BT_LE_HCI_UART_RX_PIN=9 +CONFIG_BT_LE_HCI_UART_BAUD=115200 diff --git a/examples/bluetooth/nimble/hci/sdkconfig.defaults.esp32c5 b/examples/bluetooth/nimble/hci/sdkconfig.defaults.esp32c5 new file mode 100644 index 0000000000..a263772188 --- /dev/null +++ b/examples/bluetooth/nimble/hci/sdkconfig.defaults.esp32c5 @@ -0,0 +1,6 @@ +# Override some defaults so BT stack is enabled +# by default in this example +CONFIG_BT_LE_HCI_INTERFACE_USE_UART=y +CONFIG_BT_LE_HCI_UART_TX_PIN=8 +CONFIG_BT_LE_HCI_UART_RX_PIN=9 +CONFIG_BT_LE_HCI_UART_BAUD=115200 diff --git a/examples/bluetooth/nimble/hci/sdkconfig.defaults.esp32c6 b/examples/bluetooth/nimble/hci/sdkconfig.defaults.esp32c6 new file mode 100644 index 0000000000..a263772188 --- /dev/null +++ b/examples/bluetooth/nimble/hci/sdkconfig.defaults.esp32c6 @@ -0,0 +1,6 @@ +# Override some defaults so BT stack is enabled +# by default in this example +CONFIG_BT_LE_HCI_INTERFACE_USE_UART=y +CONFIG_BT_LE_HCI_UART_TX_PIN=8 +CONFIG_BT_LE_HCI_UART_RX_PIN=9 +CONFIG_BT_LE_HCI_UART_BAUD=115200 diff --git a/examples/bluetooth/nimble/hci/sdkconfig.defaults.esp32c61 b/examples/bluetooth/nimble/hci/sdkconfig.defaults.esp32c61 new file mode 100644 index 0000000000..a263772188 --- /dev/null +++ b/examples/bluetooth/nimble/hci/sdkconfig.defaults.esp32c61 @@ -0,0 +1,6 @@ +# Override some defaults so BT stack is enabled +# by default in this example +CONFIG_BT_LE_HCI_INTERFACE_USE_UART=y +CONFIG_BT_LE_HCI_UART_TX_PIN=8 +CONFIG_BT_LE_HCI_UART_RX_PIN=9 +CONFIG_BT_LE_HCI_UART_BAUD=115200 diff --git a/examples/bluetooth/nimble/hci/sdkconfig.defaults.esp32h2 b/examples/bluetooth/nimble/hci/sdkconfig.defaults.esp32h2 new file mode 100644 index 0000000000..a263772188 --- /dev/null +++ b/examples/bluetooth/nimble/hci/sdkconfig.defaults.esp32h2 @@ -0,0 +1,6 @@ +# Override some defaults so BT stack is enabled +# by default in this example +CONFIG_BT_LE_HCI_INTERFACE_USE_UART=y +CONFIG_BT_LE_HCI_UART_TX_PIN=8 +CONFIG_BT_LE_HCI_UART_RX_PIN=9 +CONFIG_BT_LE_HCI_UART_BAUD=115200 diff --git a/examples/bluetooth/nimble/hci/sdkconfig.defaults.esp32h4 b/examples/bluetooth/nimble/hci/sdkconfig.defaults.esp32h4 new file mode 100644 index 0000000000..60e1a079af --- /dev/null +++ b/examples/bluetooth/nimble/hci/sdkconfig.defaults.esp32h4 @@ -0,0 +1,6 @@ +# Override some defaults so BT stack is enabled +# by default in this example +CONFIG_BT_CTRL_HCI_INTERFACE_USE_UART=y +CONFIG_BT_CTRL_HCI_UART_TX_PIN=8 +CONFIG_BT_CTRL_HCI_UART_RX_PIN=9 +CONFIG_BT_CTRL_HCI_UART_BAUD=115200 diff --git a/examples/bluetooth/nimble/power_save/main/main.c b/examples/bluetooth/nimble/power_save/main/main.c index d6be92b779..b86f2deed4 100644 --- a/examples/bluetooth/nimble/power_save/main/main.c +++ b/examples/bluetooth/nimble/power_save/main/main.c @@ -36,6 +36,8 @@ #define TEST_CI_ADDRESS_CHIP_OFFSET (7) #elif CONFIG_IDF_TARGET_ESP32C61 #define TEST_CI_ADDRESS_CHIP_OFFSET (8) +#elif CONFIG_IDF_TARGET_ESP32H4 +#define TEST_CI_ADDRESS_CHIP_OFFSET (9) #endif #endif diff --git a/examples/bluetooth/nimble/throughput_app/bleprph_throughput/main/main.c b/examples/bluetooth/nimble/throughput_app/bleprph_throughput/main/main.c index 27d95cc72d..05ab145ee7 100644 --- a/examples/bluetooth/nimble/throughput_app/bleprph_throughput/main/main.c +++ b/examples/bluetooth/nimble/throughput_app/bleprph_throughput/main/main.c @@ -16,6 +16,7 @@ #include "services/gap/ble_svc_gap.h" #include "gatts_sens.h" #include "../src/ble_hs_hci_priv.h" +#include "esp_timer.h" #if CONFIG_EXAMPLE_EXTENDED_ADV static uint8_t ext_adv_pattern[] = {