diff --git a/components/bootloader_support/bootloader_flash/src/bootloader_flash.c b/components/bootloader_support/bootloader_flash/src/bootloader_flash.c index 06e9780c52..518d180e39 100644 --- a/components/bootloader_support/bootloader_flash/src/bootloader_flash.c +++ b/components/bootloader_support/bootloader_flash/src/bootloader_flash.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -647,7 +647,7 @@ void bootloader_spi_flash_reset(void) ******************************************************************************/ #define XMC_SUPPORT CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT -#define XMC_VENDOR_ID 0x20 +#define XMC_VENDOR_ID_1 0x20 #if BOOTLOADER_BUILD #define BOOTLOADER_FLASH_LOG(level, ...) ESP_EARLY_LOG##level(TAG, ##__VA_ARGS__) @@ -664,7 +664,7 @@ static IRAM_ATTR bool is_xmc_chip_strict(uint32_t rdid) uint32_t mfid = BYTESHIFT(rdid, 1); uint32_t cpid = BYTESHIFT(rdid, 0); - if (vendor_id != XMC_VENDOR_ID) { + if (vendor_id != XMC_VENDOR_ID_1) { return false; } @@ -697,7 +697,7 @@ esp_err_t IRAM_ATTR bootloader_flash_xmc_startup(void) // Check the Manufacturer ID in SFDP registers (JEDEC standard). If not XMC chip, no need to run the flow const int sfdp_mfid_addr = 0x10; uint8_t mf_id = (bootloader_flash_read_sfdp(sfdp_mfid_addr, 1) & 0xff); - if (mf_id != XMC_VENDOR_ID) { + if (mf_id != XMC_VENDOR_ID_1) { BOOTLOADER_FLASH_LOG(D, "non-XMC chip detected by SFDP Read (%02X), skip.", mf_id); return ESP_OK; } @@ -729,7 +729,7 @@ esp_err_t IRAM_ATTR bootloader_flash_xmc_startup(void) static IRAM_ATTR bool is_xmc_chip(uint32_t rdid) { uint32_t vendor_id = (rdid >> 16) & 0xFF; - return (vendor_id == XMC_VENDOR_ID); + return (vendor_id == XMC_VENDOR_ID_1); } esp_err_t IRAM_ATTR bootloader_flash_xmc_startup(void) diff --git a/components/bootloader_support/src/esp32h2/bootloader_esp32h2.c b/components/bootloader_support/src/esp32h2/bootloader_esp32h2.c index 022f796892..00bb6da929 100644 --- a/components/bootloader_support/src/esp32h2/bootloader_esp32h2.c +++ b/components/bootloader_support/src/esp32h2/bootloader_esp32h2.c @@ -88,6 +88,8 @@ static inline void bootloader_hardware_init(void) { /* Enable analog i2c master clock */ SET_PERI_REG_MASK(MODEM_LPCON_CLK_CONF_REG, MODEM_LPCON_CLK_I2C_MST_EN); + REGI2C_WRITE_MASK(I2C_BIAS, I2C_BIAS_DREG_0P8, 8); // fix low temp issue, need to increase this internal voltage + } static inline void bootloader_ana_reset_config(void) diff --git a/components/bt/CMakeLists.txt b/components/bt/CMakeLists.txt index d7bad30b16..72f9f9e8f4 100644 --- a/components/bt/CMakeLists.txt +++ b/components/bt/CMakeLists.txt @@ -24,6 +24,9 @@ if(CONFIG_BT_ENABLED) elseif(CONFIG_IDF_TARGET_ESP32C2) list(APPEND srcs "controller/esp32c2/bt.c") list(APPEND include_dirs include/esp32c2/include) + if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY) + list(APPEND srcs "controller/esp32c2/dummy.c") + endif() set(ldscripts "linker_esp32c2.lf") elseif(CONFIG_IDF_TARGET_ESP32C6) @@ -648,6 +651,7 @@ if(CONFIG_BT_ENABLED) "host/nimble/nimble/nimble/host/store/config/src/ble_store_nvs.c" "host/nimble/nimble/nimble/host/src/ble_gattc_cache.c" "host/nimble/nimble/nimble/host/src/ble_gattc_cache_conn.c" + "host/nimble/nimble/nimble/host/src/ble_eatt.c" ) if(CONFIG_BT_CONTROLLER_DISABLED AND CONFIG_BT_NIMBLE_TRANSPORT_UART) @@ -781,13 +785,29 @@ if(CONFIG_BT_ENABLED) elseif(CONFIG_IDF_TARGET_ESP32C3) target_link_directories(${COMPONENT_LIB} INTERFACE "${CMAKE_CURRENT_LIST_DIR}/controller/lib_esp32c3_family/esp32c3") - target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app) + if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY) + target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app_flash) + else() + target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app) + endif() elseif(CONFIG_IDF_TARGET_ESP32S3) target_link_directories(${COMPONENT_LIB} INTERFACE "${CMAKE_CURRENT_LIST_DIR}/controller/lib_esp32c3_family/esp32s3") - target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app) + if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY) + target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app_flash) + else() + target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app) + endif() elseif(CONFIG_BT_CONTROLLER_ENABLED) - add_prebuilt_library(libble_app "controller/lib_${target}/${target}-bt-lib/libble_app.a") + if(CONFIG_IDF_TARGET_ESP32C6) + add_prebuilt_library(libble_app "controller/lib_${target}/${target}-bt-lib/esp32c6/libble_app.a") + else() + if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY) + add_prebuilt_library(libble_app "controller/lib_${target}/${target}-bt-lib/libble_app_flash.a") + else() + add_prebuilt_library(libble_app "controller/lib_${target}/${target}-bt-lib/libble_app.a") + endif() + endif() target_link_libraries(${COMPONENT_LIB} PRIVATE libble_app) endif() diff --git a/components/bt/common/btc/core/btc_task.c b/components/bt/common/btc/core/btc_task.c index 9bfd6fa8f2..fffd231de2 100644 --- a/components/bt/common/btc/core/btc_task.c +++ b/components/bt/common/btc/core/btc_task.c @@ -225,8 +225,8 @@ static bt_status_t btc_task_post(btc_msg_t *msg, uint32_t timeout) /** * transfer an message to another module in the different task. * @param msg message - * @param arg paramter - * @param arg_len length of paramter + * @param arg parameter + * @param arg_len length of parameter * @param copy_func deep copy function * @param free_func deep free function * @return BT_STATUS_SUCCESS: success @@ -272,7 +272,7 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg } /** - * transfer an message to another module in tha same task. + * transfer an message to another module in the same task. * @param msg message * @return BT_STATUS_SUCCESS: success * others: fail @@ -310,7 +310,7 @@ static void btc_deinit_mem(void) { btc_profile_cb_tab = NULL; } -#if (BLE_INCLUDED == TRUE) +#if (BLE_42_FEATURE_SUPPORT == TRUE) if (gl_bta_adv_data_ptr) { osi_free(gl_bta_adv_data_ptr); gl_bta_adv_data_ptr = NULL; @@ -320,7 +320,7 @@ static void btc_deinit_mem(void) { osi_free(gl_bta_scan_rsp_data_ptr); gl_bta_scan_rsp_data_ptr = NULL; } -#endif ///BLE_INCLUDED == TRUE +#endif // BLE_42_FEATURE_SUPPORT #if GATTS_INCLUDED == TRUE && GATT_DYNAMIC_MEMORY == TRUE if (btc_creat_tab_env_ptr) { @@ -372,7 +372,8 @@ static bt_status_t btc_init_mem(void) { } memset((void *)btc_profile_cb_tab, 0, sizeof(void *) * BTC_PID_NUM); -#if (BLE_INCLUDED == TRUE) +#if BTC_DYNAMIC_MEMORY == TRUE +#if (BLE_42_FEATURE_SUPPORT == TRUE) if ((gl_bta_adv_data_ptr = (tBTA_BLE_ADV_DATA *)osi_malloc(sizeof(tBTA_BLE_ADV_DATA))) == NULL) { goto error_exit; } @@ -382,7 +383,8 @@ static bt_status_t btc_init_mem(void) { goto error_exit; } memset((void *)gl_bta_scan_rsp_data_ptr, 0, sizeof(tBTA_BLE_ADV_DATA)); -#endif ///BLE_INCLUDED == TRUE +#endif // (BLE_42_FEATURE_SUPPORT == TRUE) +#endif // BTC_DYNAMIC_MEMORY == TRUE #if GATTS_INCLUDED == TRUE && GATT_DYNAMIC_MEMORY == TRUE if ((btc_creat_tab_env_ptr = (esp_btc_creat_tab_t *)osi_malloc(sizeof(esp_btc_creat_tab_t))) == NULL) { diff --git a/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c b/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c index a0da30f43d..a40f417c2c 100644 --- a/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c +++ b/components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -160,20 +160,31 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) if (p_data->req_data.p_data->write_req.is_prep) { tBTA_GATT_STATUS status = GATT_SUCCESS; - if (blufi_env.prepare_buf == NULL) { - blufi_env.prepare_buf = osi_malloc(BLUFI_PREPAIR_BUF_MAX_SIZE); - blufi_env.prepare_len = 0; - if (blufi_env.prepare_buf == NULL) { - BLUFI_TRACE_ERROR("Blufi prep no mem\n"); - status = GATT_NO_RESOURCES; + do { + if (p_data->req_data.p_data->write_req.offset > BLUFI_PREPARE_BUF_MAX_SIZE) { + status = ESP_GATT_INVALID_OFFSET; + break; } - } else { - if (p_data->req_data.p_data->write_req.offset > BLUFI_PREPAIR_BUF_MAX_SIZE) { - status = GATT_INVALID_OFFSET; - } else if ((p_data->req_data.p_data->write_req.offset + p_data->req_data.p_data->write_req.len) > BLUFI_PREPAIR_BUF_MAX_SIZE) { - status = GATT_INVALID_ATTR_LEN; + + if ((p_data->req_data.p_data->write_req.offset + p_data->req_data.p_data->write_req.len) > BLUFI_PREPARE_BUF_MAX_SIZE) { + status = ESP_GATT_INVALID_ATTR_LEN; + break; } - } + + if (blufi_env.prepare_buf == NULL) { + if (p_data->req_data.p_data->write_req.offset != 0) { + status = GATT_INVALID_OFFSET; + break; + } + blufi_env.prepare_buf = osi_malloc(BLUFI_PREPARE_BUF_MAX_SIZE); + blufi_env.prepare_len = 0; + if (blufi_env.prepare_buf == NULL) { + BLUFI_TRACE_ERROR("Blufi prep no mem\n"); + status = GATT_NO_RESOURCES; + break; + } + } + } while (0); memset(&rsp, 0, sizeof(tGATTS_RSP)); rsp.attr_value.handle = p_data->req_data.p_data->write_req.handle; diff --git a/components/bt/common/btc/profile/esp/blufi/include/blufi_int.h b/components/bt/common/btc/profile/esp/blufi/include/blufi_int.h index e85ad73d86..a7f4f29288 100644 --- a/components/bt/common/btc/profile/esp/blufi/include/blufi_int.h +++ b/components/bt/common/btc/profile/esp/blufi/include/blufi_int.h @@ -36,7 +36,9 @@ typedef struct { UINT32 trans_id; UINT8 congest; UINT16 frag_size; +// Deprecated: This macro will be removed in the future #define BLUFI_PREPAIR_BUF_MAX_SIZE 1024 +#define BLUFI_PREPARE_BUF_MAX_SIZE 1024 uint8_t *prepare_buf; int prepare_len; /* Control reference */ diff --git a/components/bt/common/btc/profile/esp/blufi/include/esp_blufi.h b/components/bt/common/btc/profile/esp/blufi/include/esp_blufi.h index db2203b1e6..862f7bf02f 100644 --- a/components/bt/common/btc/profile/esp/blufi/include/esp_blufi.h +++ b/components/bt/common/btc/profile/esp/blufi/include/esp_blufi.h @@ -44,6 +44,7 @@ void esp_blufi_gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *a /* Initialise gatt server */ int esp_blufi_gatt_svr_init(void); +int esp_blufi_gatt_svr_deinit(void); void esp_blufi_btc_init(void); void esp_blufi_btc_deinit(void); #endif diff --git a/components/bt/common/btc/profile/esp/blufi/nimble_host/esp_blufi.c b/components/bt/common/btc/profile/esp/blufi/nimble_host/esp_blufi.c index fc484c872f..f8e743e28b 100644 --- a/components/bt/common/btc/profile/esp/blufi/nimble_host/esp_blufi.c +++ b/components/bt/common/btc/profile/esp/blufi/nimble_host/esp_blufi.c @@ -240,6 +240,32 @@ static void init_gatt_values(void) } +static void deinit_gatt_values(void) +{ + int i = 0; + const struct ble_gatt_svc_def *svc; + const struct ble_gatt_chr_def *chr; + const struct ble_gatt_dsc_def *dsc; + + for (svc = gatt_svr_svcs; svc && svc->uuid; svc++) { + for (chr = svc->characteristics; chr && chr->uuid; chr++) { + if (i < SERVER_MAX_VALUES && gatt_values[i].buf != NULL) { + os_mbuf_free(gatt_values[i].buf); /* Free the buffer */ + gatt_values[i].buf = NULL; /* Nullify the pointer to avoid dangling references */ + } + ++i; + + for (dsc = chr->descriptors; dsc && dsc->uuid; dsc++) { + if (i < SERVER_MAX_VALUES && gatt_values[i].buf != NULL) { + os_mbuf_free(gatt_values[i].buf); /* Free the buffer */ + gatt_values[i].buf = NULL; /* Nullify the pointer to avoid dangling references */ + } + ++i; + } + } + } +} + int esp_blufi_gatt_svr_init(void) { int rc; @@ -260,6 +286,18 @@ int esp_blufi_gatt_svr_init(void) return 0; } +int esp_blufi_gatt_svr_deinit(void) +{ + deinit_gatt_values(); + + ble_gatts_free_svcs(); + /* Deinitialize BLE GATT and GAP services */ + ble_svc_gatt_deinit(); + ble_svc_gap_deinit(); + + return 0; +} + static int esp_blufi_gap_event(struct ble_gap_event *event, void *arg) { @@ -442,8 +480,10 @@ uint8_t esp_blufi_init(void) void esp_blufi_deinit(void) { blufi_env.enabled = false; - btc_msg_t msg; esp_blufi_cb_param_t param; + btc_msg_t msg; + memset (&msg, 0x0, sizeof (msg)); + msg.sig = BTC_SIG_API_CB; msg.pid = BTC_PID_BLUFI; msg.act = ESP_BLUFI_EVENT_DEINIT_FINISH; param.deinit_finish.state = ESP_BLUFI_DEINIT_OK; diff --git a/components/bt/common/hci_log/bt_hci_log.c b/components/bt/common/hci_log/bt_hci_log.c index e35bf1a7a6..ac85179a70 100644 --- a/components/bt/common/hci_log/bt_hci_log.c +++ b/components/bt/common/hci_log/bt_hci_log.c @@ -305,19 +305,27 @@ void bt_hci_log_data_show(bt_hci_log_t *p_hci_log_ctl) osi_mutex_unlock(&mutex_lock); } +static bool enable_hci_log_flag = true; +void bt_hci_log_record_hci_enable(bool enable) +{ + enable_hci_log_flag = enable; +} esp_err_t IRAM_ATTR bt_hci_log_record_hci_data(uint8_t data_type, uint8_t *data, uint8_t data_len) { + if (!enable_hci_log_flag) return ESP_OK; return bt_hci_log_record_data(&g_bt_hci_log_data_ctl, NULL, data_type, data, data_len); } esp_err_t IRAM_ATTR bt_hci_log_record_custom_data(char *string, uint8_t *data, uint8_t data_len) { + if (!enable_hci_log_flag) return ESP_OK; return bt_hci_log_record_data(&g_bt_hci_log_data_ctl, string, HCI_LOG_DATA_TYPE_SELF_DEFINE, data, data_len); } esp_err_t IRAM_ATTR bt_hci_log_record_hci_adv(uint8_t data_type, uint8_t *data, uint8_t data_len) { + if (!enable_hci_log_flag) return ESP_OK; return bt_hci_log_record_data(&g_bt_hci_log_adv_ctl, NULL, data_type, data, data_len); } diff --git a/components/bt/common/include/bt_common.h b/components/bt/common/include/bt_common.h index f3c5ba0e0d..09e7fa50d0 100644 --- a/components/bt/common/include/bt_common.h +++ b/components/bt/common/include/bt_common.h @@ -46,6 +46,7 @@ #define OSI_INITIAL_TRACE_LEVEL UC_BT_LOG_OSI_TRACE_LEVEL #define BLUFI_INITIAL_TRACE_LEVEL UC_BT_LOG_BLUFI_TRACE_LEVEL +// MEMORY #if UC_BT_BLE_DYNAMIC_ENV_MEMORY #define BT_BLE_DYNAMIC_ENV_MEMORY TRUE #define BTC_DYNAMIC_MEMORY TRUE @@ -64,6 +65,19 @@ #define BT_BLE_DYNAMIC_ENV_MEMORY FALSE #endif +#if UC_HEAP_ALLOCATION_FROM_SPIRAM_FIRST +#define HEAP_ALLOCATION_FROM_SPIRAM_FIRST TRUE +#else +#define HEAP_ALLOCATION_FROM_SPIRAM_FIRST FALSE +#endif + +#if UC_BT_ABORT_WHEN_ALLOCATION_FAILS +#define HEAP_ALLOCATION_FAILS_ABORT TRUE +#else +#define HEAP_ALLOCATION_FAILS_ABORT FALSE +#endif + +// HCI LOG #if UC_BT_HCI_LOG_DEBUG_EN #define BT_HCI_LOG_INCLUDED UC_BT_HCI_LOG_DEBUG_EN #else diff --git a/components/bt/common/include/bt_user_config.h b/components/bt/common/include/bt_user_config.h index 7516304cf0..41277d1dbe 100644 --- a/components/bt/common/include/bt_user_config.h +++ b/components/bt/common/include/bt_user_config.h @@ -94,13 +94,26 @@ #define UC_BT_BLUFI_ENABLE FALSE #endif -//MEMORY DEBUG +//MEMORY #ifdef CONFIG_BT_BLUEDROID_MEM_DEBUG #define UC_BT_BLUEDROID_MEM_DEBUG TRUE #else #define UC_BT_BLUEDROID_MEM_DEBUG FALSE #endif +#ifdef CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST +#define UC_HEAP_ALLOCATION_FROM_SPIRAM_FIRST CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST +#else +#define UC_HEAP_ALLOCATION_FROM_SPIRAM_FIRST FALSE +#endif + +#ifdef CONFIG_BT_ABORT_WHEN_ALLOCATION_FAILS +#define UC_BT_ABORT_WHEN_ALLOCATION_FAILS CONFIG_BT_ABORT_WHEN_ALLOCATION_FAILS +#else +#define UC_BT_ABORT_WHEN_ALLOCATION_FAILS FALSE +#endif + +//HCI LOG #ifdef CONFIG_BT_HCI_LOG_DEBUG_EN #define UC_BT_HCI_LOG_DEBUG_EN TRUE #else diff --git a/components/bt/common/osi/allocator.c b/components/bt/common/osi/allocator.c index 4d10e10f47..86fb705b07 100644 --- a/components/bt/common/osi/allocator.c +++ b/components/bt/common/osi/allocator.c @@ -213,42 +213,30 @@ char *osi_strdup(const char *str) void *osi_malloc_func(size_t size) { -#if HEAP_MEMORY_DEBUG - void *p; -#if HEAP_ALLOCATION_FROM_SPIRAM_FIRST - p = heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL); -#else - p = malloc(size); -#endif /* #if HEAP_ALLOCATION_FROM_SPIRAM_FIRST */ - osi_mem_dbg_record(p, size, __func__, __LINE__); + void *p = osi_malloc_base(size); + + if (size != 0 && p == NULL) { + OSI_TRACE_ERROR("malloc failed (caller=%p size=%u)\n", __builtin_return_address(0), size); +#if HEAP_ALLOCATION_FAILS_ABORT + assert(0); +#endif + } + return p; -#else -#if HEAP_ALLOCATION_FROM_SPIRAM_FIRST - return heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL); -#else - return malloc(size); -#endif /* #if HEAP_ALLOCATION_FROM_SPIRAM_FIRST */ -#endif /* #if HEAP_MEMORY_DEBUG */ } void *osi_calloc_func(size_t size) { -#if HEAP_MEMORY_DEBUG - void *p; -#if HEAP_ALLOCATION_FROM_SPIRAM_FIRST - p = heap_caps_calloc_prefer(1, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL); -#else - p = calloc(1, size); -#endif /* #if HEAP_ALLOCATION_FROM_SPIRAM_FIRST */ - osi_mem_dbg_record(p, size, __func__, __LINE__); + void *p = osi_calloc_base(size); + + if (size != 0 && p == NULL) { + OSI_TRACE_ERROR("calloc failed (caller=%p size=%u)\n", __builtin_return_address(0), size); +#if HEAP_ALLOCATION_FAILS_ABORT + assert(0); +#endif + } + return p; -#else -#if HEAP_ALLOCATION_FROM_SPIRAM_FIRST - return heap_caps_calloc_prefer(1, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL); -#else - return calloc(1, size); -#endif /* #if HEAP_ALLOCATION_FROM_SPIRAM_FIRST */ -#endif /* #if HEAP_MEMORY_DEBUG */ } void osi_free_func(void *ptr) diff --git a/components/bt/common/osi/include/osi/allocator.h b/components/bt/common/osi/include/osi/allocator.h index 579f2b2bb6..d95040538d 100644 --- a/components/bt/common/osi/include/osi/allocator.h +++ b/components/bt/common/osi/include/osi/allocator.h @@ -29,6 +29,15 @@ void *osi_malloc_func(size_t size); void *osi_calloc_func(size_t size); void osi_free_func(void *ptr); +// Memory alloc function without print and assertion +#if HEAP_ALLOCATION_FROM_SPIRAM_FIRST +#define osi_malloc_base(size) heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL) +#define osi_calloc_base(size) heap_caps_calloc_prefer(1, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL) +#else +#define osi_malloc_base(size) malloc((size)) +#define osi_calloc_base(size) calloc(1, (size)) +#endif /* #if HEAP_ALLOCATION_FROM_SPIRAM_FIRST */ + #if HEAP_MEMORY_DEBUG void osi_mem_dbg_init(void); @@ -41,13 +50,10 @@ void osi_men_dbg_set_section_start(uint8_t index); void osi_men_dbg_set_section_end(uint8_t index); uint32_t osi_mem_dbg_get_max_size_section(uint8_t index); -#if HEAP_ALLOCATION_FROM_SPIRAM_FIRST #define osi_malloc(size) \ ({ \ void *p; \ - p = heap_caps_malloc_prefer(size, 2, \ - MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, \ - MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL); \ + p = osi_malloc_base(size); \ osi_mem_dbg_record(p, size, __func__, __LINE__); \ (void *)p; \ }) @@ -55,34 +61,11 @@ uint32_t osi_mem_dbg_get_max_size_section(uint8_t index); #define osi_calloc(size) \ ({ \ void *p; \ - p = heap_caps_calloc_prefer(1, size, 2, \ - MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, \ - MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL); \ - osi_mem_dbg_record(p, size, __func__, __LINE__); \ - (void *)p; \ -}) - -#else - -#define osi_malloc(size) \ -({ \ - void *p; \ - p = malloc((size)); \ + p = osi_calloc_base(size); \ osi_mem_dbg_record(p, size, __func__, __LINE__); \ (void *)p; \ }) -#define osi_calloc(size) \ -({ \ - void *p; \ - p = calloc(1, (size)); \ - osi_mem_dbg_record(p, size, __func__, __LINE__); \ - (void *)p; \ -}) - -#endif /* #if HEAP_ALLOCATION_FROM_SPIRAM_FIRST */ - - #if 0 #define osi_malloc(size) \ do { \ @@ -122,13 +105,9 @@ do { \ #else -#if HEAP_ALLOCATION_FROM_SPIRAM_FIRST -#define osi_malloc(size) heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL) -#define osi_calloc(size) heap_caps_calloc_prefer(1, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL) -#else -#define osi_malloc(size) malloc((size)) -#define osi_calloc(size) calloc(1, (size)) -#endif /* #if HEAP_ALLOCATION_FROM_SPIRAM_FIRST */ +// Memory alloc function with print and assertion when fails +#define osi_malloc(size) osi_malloc_func((size)) +#define osi_calloc(size) osi_calloc_func((size)) #define osi_free(p) free((p)) #endif /* HEAP_MEMORY_DEBUG */ diff --git a/components/bt/common/osi/thread.c b/components/bt/common/osi/thread.c index f53eadb665..91bc7906ce 100644 --- a/components/bt/common/osi/thread.c +++ b/components/bt/common/osi/thread.c @@ -271,10 +271,10 @@ osi_thread_t *osi_thread_create(const char *name, size_t stack_size, int priorit } for (int i = 0; i < thread->work_queue_num; i++) { - if (thread->work_queues[i]) { + if (thread->work_queues && thread->work_queues[i]) { osi_work_queue_delete(thread->work_queues[i]); + thread->work_queues[i] = NULL; } - thread->work_queues[i] = NULL; } if (thread->work_queues) { diff --git a/components/bt/controller/esp32/Kconfig.in b/components/bt/controller/esp32/Kconfig.in index 7254a6ae59..8855fb062f 100644 --- a/components/bt/controller/esp32/Kconfig.in +++ b/components/bt/controller/esp32/Kconfig.in @@ -262,10 +262,10 @@ menu "MODEM SLEEP Options" the bluetooth low power clock source. config BTDM_CTRL_LPCLK_SEL_EXT_32K_XTAL - bool "External 32kHz crystal" - depends on RTC_CLK_SRC_EXT_CRYS + bool "External 32kHz crystal/oscillator" + depends on RTC_CLK_SRC_EXT_CRYS || RTC_CLK_SRC_EXT_OSC help - External 32kHz crystal has a nominal frequency of 32.768kHz and provides good frequency + External 32kHz crystal/oscillator has a nominal frequency of 32.768kHz and provides good frequency stability. If used as Bluetooth low power clock, External 32kHz can support Bluetooth modem sleep to be used with both DFS and light sleep. endchoice @@ -406,6 +406,15 @@ config BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX minimize collision of scan request PDUs from nultiple scanners. If scan backoff is disabled, in active scanning, scan request PDU will be sent every time when HW receives scannable ADV PDU. +config BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS + bool "Enable enhanced Access Address check in CONNECT_IND" + default n + help + Enabling this option will add stricter verification of the Access Address in the CONNECT_IND PDU. + This improves security by ensuring that only connection requests with valid Access Addresses are accepted. + If disabled, only basic checks are applied, improving compatibility. + + config BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP bool "BLE adv report flow control supported" depends on (BTDM_CTRL_MODE_BTDM || BTDM_CTRL_MODE_BLE_ONLY) @@ -440,6 +449,23 @@ config BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD If you set `BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD` to a small value or printf every adv lost event, it may cause adv packets lost more. +menu "BLE disconnect when instant passed" + config BTDM_BLE_LLCP_CONN_UPDATE + bool "BLE ACL connection update procedure" + depends on (BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM) + default n + help + If this option is enabled, Controller will terminate the connection + when instant passed during connection update procedure. + + config BTDM_BLE_LLCP_CHAN_MAP_UPDATE + bool "BLE ACL channel map update procedure" + depends on (BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM) + default n + help + If this option is enabled, Controller will terminate the connection + when instant passed in channel map update procedure. +endmenu config BTDM_RESERVE_DRAM hex diff --git a/components/bt/controller/esp32/bt.c b/components/bt/controller/esp32/bt.c index 7523e5f47c..7a8ec6fcc4 100644 --- a/components/bt/controller/esp32/bt.c +++ b/components/bt/controller/esp32/bt.c @@ -92,6 +92,7 @@ do{\ #define OSI_VERSION 0x00010005 #define OSI_MAGIC_VALUE 0xFADEBEAD +#define BLE_CONTROLLER_MALLOC_CAPS (MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL) /* Types definition ************************************************************************ */ @@ -864,7 +865,21 @@ static int IRAM_ATTR cause_sw_intr_to_core_wrapper(int core_id, int intr_no) static void *malloc_internal_wrapper(size_t size) { - return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); + return heap_caps_malloc(size, BLE_CONTROLLER_MALLOC_CAPS); +} + +void *malloc_ble_controller_mem(size_t size) +{ + void *p = heap_caps_malloc(size, BLE_CONTROLLER_MALLOC_CAPS); + if(p == NULL) { + ESP_LOGE(BTDM_LOG_TAG, "Malloc failed"); + } + return p; +} + +uint32_t get_ble_controller_free_heap_size(void) +{ + return heap_caps_get_free_size(BLE_CONTROLLER_MALLOC_CAPS); } static int32_t IRAM_ATTR read_mac_wrapper(uint8_t mac[6]) @@ -1326,7 +1341,8 @@ static esp_err_t esp_bt_controller_rom_mem_release(esp_bt_mode_t mode) //already released if (!(mode & btdm_dram_available_region[0].mode)) { - return ESP_ERR_INVALID_STATE; + ESP_LOGW(BTDM_LOG_TAG, "%s already released, mode %d",__func__, mode); + return ESP_OK; } for (int i = 0; i < sizeof(btdm_dram_available_region)/sizeof(btdm_dram_available_region_t); i++) { @@ -1619,7 +1635,10 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) btdm_cfg_mask = btdm_config_mask_load(); - if (btdm_controller_init(btdm_cfg_mask, cfg) != 0) { + err = btdm_controller_init(btdm_cfg_mask, cfg); + + if (err != 0) { + ESP_LOGE(BTDM_LOG_TAG, "%s %d\n",__func__,err); err = ESP_ERR_NO_MEM; goto error; } @@ -1909,7 +1928,7 @@ esp_err_t esp_bredr_sco_datapath_set(esp_sco_data_path_t data_path) return ESP_OK; } -esp_err_t esp_ble_scan_dupilcate_list_flush(void) +esp_err_t esp_ble_scan_duplicate_list_flush(void) { if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED) { return ESP_ERR_INVALID_STATE; @@ -1918,6 +1937,11 @@ esp_err_t esp_ble_scan_dupilcate_list_flush(void) return ESP_OK; } +esp_err_t esp_ble_scan_dupilcate_list_flush(void) +{ + return esp_ble_scan_duplicate_list_flush(); +} + /** * This function re-write controller's function, * As coredump can not show parameters in function which is in a .a file. diff --git a/components/bt/controller/esp32c2/Kconfig.in b/components/bt/controller/esp32c2/Kconfig.in index d05401c186..ee1404b07f 100644 --- a/components/bt/controller/esp32c2/Kconfig.in +++ b/components/bt/controller/esp32c2/Kconfig.in @@ -109,85 +109,99 @@ menuconfig BT_LE_50_FEATURE_SUPPORT help Enable BLE 5 feature -config BT_LE_LL_CFG_FEAT_LE_2M_PHY - bool "Enable 2M Phy" - depends on BT_LE_50_FEATURE_SUPPORT - default y - help - Enable 2M-PHY - -config BT_LE_LL_CFG_FEAT_LE_CODED_PHY - bool "Enable coded Phy" - depends on BT_LE_50_FEATURE_SUPPORT - default y - help - Enable coded-PHY - -config BT_LE_EXT_ADV - bool "Enable extended advertising" - depends on BT_LE_50_FEATURE_SUPPORT - default y - help - Enable this option to do extended advertising. Extended advertising - will be supported from BLE 5.0 onwards. - -if BT_LE_EXT_ADV - config BT_LE_MAX_EXT_ADV_INSTANCES - int "Maximum number of extended advertising instances." - range 0 4 - default 1 - depends on BT_LE_EXT_ADV - help - Change this option to set maximum number of extended advertising - instances. Minimum there is always one instance of - advertising. Enter how many more advertising instances you - want. - Each extended advertising instance will take about 0.5k DRAM. - - config BT_LE_EXT_ADV_MAX_SIZE - int "Maximum length of the advertising data." - range 0 1650 - default 1650 - depends on BT_LE_EXT_ADV +if BT_LE_50_FEATURE_SUPPORT + config BT_LE_LL_CFG_FEAT_LE_2M_PHY + bool "Enable 2M Phy" + depends on BT_LE_50_FEATURE_SUPPORT + default y help - Defines the length of the extended adv data. The value should not - exceed 1650. + Enable 2M-PHY - config BT_LE_ENABLE_PERIODIC_ADV - bool "Enable periodic advertisement." + config BT_LE_LL_CFG_FEAT_LE_CODED_PHY + bool "Enable coded Phy" + depends on BT_LE_50_FEATURE_SUPPORT default y - depends on BT_LE_EXT_ADV help - Enable this option to start periodic advertisement. + Enable coded-PHY - config BT_LE_PERIODIC_ADV_SYNC_TRANSFER - bool "Enable Transfer Sync Events" - depends on BT_LE_ENABLE_PERIODIC_ADV + config BT_LE_EXT_ADV + bool "Enable extended advertising" + depends on BT_LE_50_FEATURE_SUPPORT default y help - This enables controller transfer periodic sync events to host + Enable this option to do extended advertising. Extended advertising + will be supported from BLE 5.0 onwards. + + if BT_LE_EXT_ADV + config BT_LE_MAX_EXT_ADV_INSTANCES + int "Maximum number of extended advertising instances." + range 0 4 + default 1 + depends on BT_LE_EXT_ADV + help + Change this option to set maximum number of extended advertising + instances. Minimum there is always one instance of + advertising. Enter how many more advertising instances you + want. + Each extended advertising instance will take about 0.5k DRAM. + + config BT_LE_EXT_ADV_MAX_SIZE + int "Maximum length of the advertising data." + range 0 1650 + default 1650 + depends on BT_LE_EXT_ADV + help + Defines the length of the extended adv data. The value should not + exceed 1650. -endif + config BT_LE_ENABLE_PERIODIC_ADV + bool "Enable periodic advertisement." + default y + depends on BT_LE_EXT_ADV + help + Enable this option to start periodic advertisement. -config BT_LE_MAX_PERIODIC_SYNCS - int "Maximum number of periodic advertising syncs" - depends on BT_LE_50_FEATURE_SUPPORT && !BT_NIMBLE_ENABLED + config BT_LE_PERIODIC_ADV_SYNC_TRANSFER + bool "Enable Transfer Sync Events" + depends on BT_LE_ENABLE_PERIODIC_ADV + default y + help + This enables controller transfer periodic sync events to host + endif - range 0 3 - default 1 if BT_LE_ENABLE_PERIODIC_ADV - default 0 - help - Set this option to set the upper limit for number of periodic sync - connections. This should be less than maximum connections allowed by - controller. + config BT_LE_EXT_SCAN + bool "Enable extended scanning" + depends on BT_LE_50_FEATURE_SUPPORT && BT_LE_ROLE_OBSERVER_ENABLE + default y + help + Enable this option to do extended scanning. -config BT_LE_MAX_PERIODIC_ADVERTISER_LIST - int "Maximum number of periodic advertiser list" - depends on BT_LE_50_FEATURE_SUPPORT && !BT_NIMBLE_ENABLED - range 1 5 - default 5 - help - Set this option to set the upper limit for number of periodic advertiser list. + config BT_LE_ENABLE_PERIODIC_SYNC + bool "Enable periodic sync" + default y + depends on BT_LE_EXT_SCAN + help + Enable this option to receive periodic advertisement. + + if BT_LE_ENABLE_PERIODIC_SYNC + config BT_LE_MAX_PERIODIC_SYNCS + int "Maximum number of periodic advertising syncs" + range 0 3 + default 1 if BT_LE_ENABLE_PERIODIC_ADV + default 0 + help + Set this option to set the upper limit for number of periodic sync + connections. This should be less than maximum connections allowed by + controller. + + config BT_LE_MAX_PERIODIC_ADVERTISER_LIST + int "Maximum number of periodic advertiser list" + range 1 5 + default 5 + help + Set this option to set the upper limit for number of periodic advertiser list. + endif +endif menu "Memory Settings" depends on !BT_NIMBLE_ENABLED @@ -522,6 +536,10 @@ config BT_LE_TX_CCA_ENABLED help Enable CCA feature to cancel sending the packet if the signal power is stronger than CCA threshold. +config BT_LE_DTM_ENABLED + bool "Enable Direct Test Mode (DTM) feature" + default n + config BT_LE_CCA_RSSI_THRESH int "CCA RSSI threshold value" depends on BT_LE_TX_CCA_ENABLED @@ -530,6 +548,10 @@ config BT_LE_CCA_RSSI_THRESH help Power threshold of CCA in unit of -1 dBm. +config BT_LE_FEAT_LL_ENCRYPTION + bool "Enable controller ACL encryption" + default y + config BT_LE_ROLE_CENTROL_ENABLE bool "Enable BLE Centrol role function" depends on !BT_NIMBLE_ENABLED @@ -616,3 +638,31 @@ config BT_LE_DFT_TX_POWER_LEVEL_DBM_EFF default 18 if BT_LE_DFT_TX_POWER_LEVEL_P18 default 20 if BT_LE_DFT_TX_POWER_LEVEL_P20 default 0 + +config BT_CTRL_RUN_IN_FLASH_ONLY + bool "Reduce BLE IRAM usage (READ DOCS FIRST) (EXPERIMENTAL)" + default n + help + Move most IRAM into flash. This will increase the usage of flash and reduce ble performance. + Because the code is moved to the flash, the execution speed of the code is reduced. + To have a small impact on performance, you need to enable flash suspend (SPI_FLASH_AUTO_SUSPEND). + + - Only one Tx-Rx can be performed in each connection interval. Therefore, reduce the connection interval + as much as possible to improve the throughput. If you want higher connection performance, you can + enable BT_LE_PLACE_CONN_RELATED_INTO_IRAM to put the connection-related code into iram. + - For HCI_LE_Extended_Create_Connection command, only 1M phy's connection parameters will be applied. + Other phys' will be ignored. + - For extended scanning, we may be unable to receive the extended adv with 300us MAFS. + +config BT_LE_PLACE_CONN_RELATED_INTO_IRAM + bool "Place the connection-related code into IRAM" + depends on BT_CTRL_RUN_IN_FLASH_ONLY + default n + +config BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS + bool "Enable enhanced Access Address check in CONNECT_IND" + default n + help + Enabling this option will add stricter verification of the Access Address in the CONNECT_IND PDU. + This improves security by ensuring that only connection requests with valid Access Addresses are accepted. + If disabled, only basic checks are applied, improving compatibility. diff --git a/components/bt/controller/esp32c2/bt.c b/components/bt/controller/esp32c2/bt.c index 3c5bf0b1b2..f42246b72c 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -47,6 +47,7 @@ #if CONFIG_FREERTOS_USE_TICKLESS_IDLE #include "esp_private/sleep_modem.h" #endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE +#include "esp_private/esp_modem_clock.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" @@ -73,11 +74,6 @@ #define EXT_FUNC_MAGIC_VALUE 0xA5A5A5A5 #define BT_ASSERT_PRINT ets_printf -typedef enum ble_rtc_slow_clk_src { - BT_SLOW_CLK_SRC_MAIN_XTAL, - BT_SLOW_CLK_SRC_32K_XTAL_ON_PIN0, -} ble_rtc_slow_clk_src_t; - /* Types definition ************************************************************************ */ @@ -158,6 +154,10 @@ extern int ble_get_npl_element_info(esp_bt_controller_config_t *cfg, ble_npl_cou extern void bt_track_pll_cap(void); extern char *ble_controller_get_compile_version(void); extern const char *r_ble_controller_get_rom_compile_version(void); +#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY +extern void ble_ll_supported_features_init(void); +#endif //CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY + #if CONFIG_BT_RELEASE_IRAM extern uint32_t _iram_bt_text_start; extern uint32_t _bss_bt_end; @@ -197,6 +197,9 @@ static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void); /* Local variable definition *************************************************************************** */ +#if (CONFIG_ESP32C2_REV_MIN_FULL < 200) && (!CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY) +void *g_ble_lll_rfmgmt_env_p; +#endif /* Static variable declare */ static DRAM_ATTR esp_bt_controller_status_t ble_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE; #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED @@ -440,9 +443,21 @@ static bool s_ble_active = false; static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock = NULL; #define BTDM_MIN_TIMER_UNCERTAINTY_US (200) #endif // CONFIG_PM_ENABLE +static DRAM_ATTR modem_clock_lpclk_src_t s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_INVALID; #define BLE_RTC_DELAY_US (1800) +#define BLE_CONTROLLER_MALLOC_CAPS (MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT|MALLOC_CAP_DMA) +void *malloc_ble_controller_mem(size_t size) +{ + return heap_caps_malloc(size, BLE_CONTROLLER_MALLOC_CAPS); +} + +uint32_t get_ble_controller_free_heap_size(void) +{ + return heap_caps_get_free_size(BLE_CONTROLLER_MALLOC_CAPS); +} + static const struct osi_coex_funcs_t s_osi_coex_funcs_ro = { ._magic = OSI_COEX_MAGIC_VALUE, ._version = OSI_COEX_VERSION, @@ -535,7 +550,12 @@ static int esp_ecc_gen_dh_key(const uint8_t *peer_pub_key_x, const uint8_t *peer static int esp_intr_alloc_wrapper(int source, int flags, intr_handler_t handler, void *arg, void **ret_handle_in) { +#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY + int rc = esp_intr_alloc(source, flags, handler, arg, (intr_handle_t *)ret_handle_in); +#else int rc = esp_intr_alloc(source, flags | ESP_INTR_FLAG_IRAM, handler, arg, (intr_handle_t *)ret_handle_in); +#endif + return rc; } @@ -554,6 +574,20 @@ void sleep_modem_light_sleep_overhead_set(uint32_t overhead) } #endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */ +modem_clock_lpclk_src_t esp_bt_get_lpclk_src(void) +{ + return s_bt_lpclk_src; +} + +void esp_bt_set_lpclk_src(modem_clock_lpclk_src_t clk_src) +{ + if (clk_src >= MODEM_CLOCK_LPCLK_SRC_MAX) { + return; + } + + s_bt_lpclk_src = clk_src; +} + IRAM_ATTR void controller_sleep_cb(uint32_t enable_tick, void *arg) { if (!s_ble_active) { @@ -580,7 +614,7 @@ IRAM_ATTR void controller_wakeup_cb(void *arg) s_ble_active = true; } -esp_err_t controller_sleep_init(ble_rtc_slow_clk_src_t slow_clk_src) +esp_err_t controller_sleep_init(modem_clock_lpclk_src_t slow_clk_src) { esp_err_t rc = 0; #ifdef CONFIG_BT_LE_SLEEP_ENABLE @@ -588,7 +622,7 @@ esp_err_t controller_sleep_init(ble_rtc_slow_clk_src_t slow_clk_src) r_ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0, 500 + BLE_RTC_DELAY_US); #ifdef CONFIG_PM_ENABLE - if (slow_clk_src == BT_SLOW_CLK_SRC_MAIN_XTAL) { + if (slow_clk_src == MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL) { esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_ON); } else { esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_AUTO); @@ -643,11 +677,11 @@ void controller_sleep_deinit(void) #endif //CONFIG_PM_ENABLE } -static void esp_bt_rtc_slow_clk_select(ble_rtc_slow_clk_src_t slow_clk_src) +static void esp_bt_rtc_slow_clk_select(modem_clock_lpclk_src_t slow_clk_src) { /* Select slow clock source for BT momdule */ switch (slow_clk_src) { - case BT_SLOW_CLK_SRC_MAIN_XTAL: + case MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL: ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using main XTAL as clock source"); SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_XTAL32K_S); SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 1, MODEM_CLKRST_LP_TIMER_SEL_XTAL_S); @@ -659,7 +693,7 @@ static void esp_bt_rtc_slow_clk_select(ble_rtc_slow_clk_src_t slow_clk_src) SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM, 249, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM_S); #endif // CONFIG_XTAL_FREQ_26 break; - case BT_SLOW_CLK_SRC_32K_XTAL_ON_PIN0: + case MODEM_CLOCK_LPCLK_SRC_EXT32K: ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using external 32.768 kHz XTAL as clock source"); SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 1, MODEM_CLKRST_LP_TIMER_SEL_XTAL32K_S); SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_XTAL_S); @@ -676,40 +710,39 @@ static void esp_bt_rtc_slow_clk_select(ble_rtc_slow_clk_src_t slow_clk_src) SET_PERI_REG_BITS(MODEM_CLKRST_ETM_CLK_CONF_REG, 1, 0, MODEM_CLKRST_ETM_CLK_SEL_S); } -static ble_rtc_slow_clk_src_t ble_rtc_clk_init(esp_bt_controller_config_t *cfg) +static modem_clock_lpclk_src_t ble_rtc_clk_init(esp_bt_controller_config_t *cfg) { - ble_rtc_slow_clk_src_t slow_clk_src; - + if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_INVALID) { #if CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL -#ifdef CONFIG_XTAL_FREQ_26 - cfg->rtc_freq = 40000; + s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL; #else - cfg->rtc_freq = 32000; -#endif // CONFIG_XTAL_FREQ_26 - slow_clk_src = BT_SLOW_CLK_SRC_MAIN_XTAL; -#else - if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_OSC_SLOW) { + if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_OSC_SLOW) { + s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_EXT32K; + } else { + ESP_LOGW(NIMBLE_PORT_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock"); + s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL; + } +#endif // CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL + } + + if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_EXT32K) { cfg->rtc_freq = 32768; - slow_clk_src = BT_SLOW_CLK_SRC_32K_XTAL_ON_PIN0; - } else { - ESP_LOGW(NIMBLE_PORT_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock"); + } else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL) { #ifdef CONFIG_XTAL_FREQ_26 cfg->rtc_freq = 40000; #else cfg->rtc_freq = 32000; #endif // CONFIG_XTAL_FREQ_26 - slow_clk_src = BT_SLOW_CLK_SRC_MAIN_XTAL; } -#endif /* CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL */ - esp_bt_rtc_slow_clk_select(slow_clk_src); - return slow_clk_src; + esp_bt_rtc_slow_clk_select(s_bt_lpclk_src); + return s_bt_lpclk_src; } esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) { esp_err_t ret = ESP_OK; ble_npl_count_info_t npl_info; - ble_rtc_slow_clk_src_t rtc_clk_src; + modem_clock_lpclk_src_t rtc_clk_src; uint8_t hci_transport_mode; memset(&npl_info, 0, sizeof(ble_npl_count_info_t)); @@ -731,6 +764,8 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) return ret; } + /* If we place the ble code into flash, don't need to initialize ROM. */ +#if !CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY #if DEFAULT_BT_LE_50_FEATURE_SUPPORT || DEFAULT_BT_LE_ROLE_CENTROL || DEFAULT_BT_LE_ROLE_OBSERVER extern int esp_ble_rom_func_ptr_init_all(void); esp_ble_rom_func_ptr_init_all(); @@ -739,6 +774,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) extern int esp_ble_rom_func_ptr_init_legacy_adv_and_slave(void); esp_ble_rom_func_ptr_init_legacy_adv_and_slave(); #endif +#endif //!CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY /* Initialize the function pointers for OS porting */ npl_freertos_funcs_init(); @@ -788,6 +824,11 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) #if CONFIG_SW_COEXIST_ENABLE coex_init(); #endif + +#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY + ble_ll_supported_features_init(); +#endif //CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY + ret = ble_controller_init(cfg); if (ret != ESP_OK) { ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_init failed %d", ret); diff --git a/components/bt/controller/esp32c2/dummy.c b/components/bt/controller/esp32c2/dummy.c new file mode 100644 index 0000000000..0621f547c2 --- /dev/null +++ b/components/bt/controller/esp32c2/dummy.c @@ -0,0 +1,320 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include "esp_bt_cfg.h" + +#define BLE_ERR_UNKNOWN_HCI_CMD (0x01) +/* LL Features */ +#define BLE_LL_FEAT_LE_ENCRYPTION (0x0000000001) +#define BLE_LL_FEAT_CONN_PARM_REQ (0x0000000002) +#define BLE_LL_FEAT_EXTENDED_REJ (0x0000000004) +#define BLE_LL_FEAT_PERIPH_INIT (0x0000000008) +#define BLE_LL_FEAT_LE_PING (0x0000000010) +#define BLE_LL_FEAT_DATA_LEN_EXT (0x0000000020) +#define BLE_LL_FEAT_LL_PRIVACY (0x0000000040) +#define BLE_LL_FEAT_EXT_SCAN_FILT (0x0000000080) +#define BLE_LL_FEAT_LE_2M_PHY (0x0000000100) +#define BLE_LL_FEAT_STABLE_MOD_ID_TX (0x0000000200) +#define BLE_LL_FEAT_STABLE_MOD_ID_RX (0x0000000400) +#define BLE_LL_FEAT_LE_CODED_PHY (0x0000000800) +#define BLE_LL_FEAT_EXT_ADV (0x0000001000) +#define BLE_LL_FEAT_PERIODIC_ADV (0x0000002000) +#define BLE_LL_FEAT_CSA2 (0x0000004000) +#define BLE_LL_FEAT_LE_POWER_CLASS_1 (0x0000008000) +#define BLE_LL_FEAT_MIN_USED_CHAN (0x0000010000) +#define BLE_LL_FEAT_CTE_REQ (0x0000020000) +#define BLE_LL_FEAT_CTE_RSP (0x0000040000) +#define BLE_LL_FEAT_CTE_TX (0x0000080000) +#define BLE_LL_FEAT_CTE_RX (0x0000100000) +#define BLE_LL_FEAT_CTE_AOD (0x0000200000) +#define BLE_LL_FEAT_CTE_AOA (0x0000400000) +#define BLE_LL_FEAT_CTE_RECV (0x0000800000) +#define BLE_LL_FEAT_SYNC_TRANS_SEND (0x0001000000) +#define BLE_LL_FEAT_SYNC_TRANS_RECV (0x0002000000) +#define BLE_LL_FEAT_SCA_UPDATE (0x0004000000) +#define BLE_LL_FEAT_REM_PKEY (0x0008000000) +#define BLE_LL_FEAT_CIS_CENTRAL (0x0010000000) +#define BLE_LL_FEAT_CIS_PERIPH (0x0020000000) +#define BLE_LL_FEAT_ISO_BROADCASTER (0x0040000000) +#define BLE_LL_FEAT_SYNC_RECV (0x0080000000) +#define BLE_LL_FEAT_CIS_HOST (0x0100000000) +#define BLE_LL_FEAT_POWER_CTRL_REQ (0x0200000000) +#define BLE_LL_FEAT_POWER_CHANGE_IND (0x0400000000) +#define BLE_LL_FEAT_PATH_LOSS_MON (0x0800000000) +#define BLE_LL_FEAT_PERIODIC_ADV_ADI (0x1000000000) +#define BLE_LL_FEAT_CONN_SUBRATING (0x2000000000) +#define BLE_LL_FEAT_CONN_SUBRATING_HOST (0x4000000000) +#define BLE_LL_FEAT_CHANNEL_CLASS (0x8000000000) + +uint64_t ble_ll_supported_features; + +void +ble_ll_supported_features_init(void) +{ + ble_ll_supported_features = BLE_LL_FEAT_EXTENDED_REJ; + ble_ll_supported_features |= BLE_LL_FEAT_DATA_LEN_EXT; + +#if DEFAULT_BT_LE_ROLE_CENTROL || DEFAULT_BT_LE_ROLE_PERIPHERAL + ble_ll_supported_features |= BLE_LL_FEAT_PERIPH_INIT; + ble_ll_supported_features |= BLE_LL_FEAT_CONN_PARM_REQ; +#endif + +#if CONFIG_BT_LE_FEAT_LL_ENCRYPTION + ble_ll_supported_features |= BLE_LL_FEAT_LE_ENCRYPTION; +#endif + + ble_ll_supported_features |= (BLE_LL_FEAT_LL_PRIVACY | BLE_LL_FEAT_EXT_SCAN_FILT); + ble_ll_supported_features |= BLE_LL_FEAT_LE_PING; + +#if DEFAULT_BT_LE_EXT_ADV + ble_ll_supported_features |= BLE_LL_FEAT_EXT_ADV; +#endif + +#if DEFAULT_BT_LE_PERIODIC_ADV + ble_ll_supported_features |= BLE_LL_FEAT_PERIODIC_ADV; + ble_ll_supported_features |= BLE_LL_FEAT_PERIODIC_ADV_ADI; +#endif + +#if DEFAULT_BT_LE_PAST + ble_ll_supported_features |= BLE_LL_FEAT_SYNC_TRANS_RECV; + ble_ll_supported_features |= BLE_LL_FEAT_SYNC_TRANS_SEND; +#endif + +#if DEGAULT_BT_LE_2M_PHY + ble_ll_supported_features |= BLE_LL_FEAT_LE_2M_PHY; +#endif + +#if DEGAULT_BT_LE_CODED_PHY + ble_ll_supported_features |= BLE_LL_FEAT_LE_CODED_PHY; +#endif + +#if DEFAULT_BT_LE_50_FEATURE_SUPPORT + ble_ll_supported_features |= BLE_LL_FEAT_CSA2; + ble_ll_supported_features |= BLE_LL_FEAT_SCA_UPDATE; + ble_ll_supported_features |= BLE_LL_FEAT_REM_PKEY; + ble_ll_supported_features |= BLE_LL_FEAT_CHANNEL_CLASS; +#endif +} + +#if !DEFAULT_BT_LE_ROLE_BROADCASTER +void r_ble_ll_adv_rpa_timeout(void) { } +void r_ble_lll_adv_halt(void) { } +void r_ble_lll_adv_event_rmvd_from_sched(void) { } +void r_ble_lll_adv_ext_event_rmvd_from_sched(void) { } +int r_ble_ll_adv_enabled(void) { return 0; } +int r_ble_ll_adv_can_chg_whitelist(void) { return 1; } +int r_ble_ll_adv_set_random_addr(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +void r_ble_ll_adv_reset(void) { } +void r_ble_ll_adv_init(void) { } +void r_ble_ll_adv_deinit(void) { } +int r_ble_ll_adv_env_init(void) { return 0; } +void r_ble_ll_adv_env_deinit(void) { } +int r_ble_lll_adv_rx_pkt_isr(void) { return -1; } +void r_ble_ll_adv_rx_pkt_in(void) { } +int r_ble_ll_adv_set_adv_params(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_adv_read_txpwr(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_hci_set_adv_data(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_hci_set_scan_rsp_data(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_hci_adv_set_enable(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_adv_vendor_hci_legacy_adv_clear(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_adv_set_data_related_addr_change(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +#endif // !DEFAULT_BT_LE_ROLE_BROADCASTER + +#if !DEFAULT_BT_LE_EXT_ADV +bool r_ble_ll_adv_ext_check_data_itvl(void) { return true; } +void r_ble_lll_adv_coex_dpc_update_on_aux_scheduled(void) { } +void r_ble_lll_adv_coex_dpc_calc_pti_update_itvl(void) { } +void r_ble_lll_adv_sec_done(void) { } +int r_ble_lll_adv_sec_schedule_next_aux(void) { return 0; } +void r_ble_lll_adv_sec_event_done(void) { } +int r_ble_lll_adv_secondary_tx_start_cb(void) { return 0; } +void r_ble_lll_adv_aux_schedule(void) { } +void r_ble_lll_adv_update_rsp_offset(void) { } +int r_ble_ll_adv_hci_set_random_addr(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_adv_ext_set_param(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_adv_ext_set_adv_data(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_adv_ext_set_scan_rsp(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_adv_ext_set_enable(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_adv_rd_max_adv_data_len(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_adv_rd_sup_adv_sets(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_adv_remove(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_adv_clear_all(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +#endif //!DEFAULT_BT_LE_EXT_ADV + +#if !DEFAULT_BT_LE_PERIODIC_ADV +void r_ble_ll_adv_sm_stop_periodic(void) { } +void r_ble_lll_adv_periodic_event_done(void) { } +int r_ble_lll_adv_sync_tx_start_cb(void) { return 0; } +void r_ble_lll_adv_sync_tx_end(void) { } +int r_ble_lll_adv_periodic_start(void) { return 0; } +void r_ble_lll_adv_periodic_rmvd_from_sched(void) { } +int r_ble_ll_adv_periodic_set_param(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_adv_periodic_set_data(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_adv_periodic_enable(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +#endif //!DEFAULT_BT_LE_PERIODIC_ADV + +#if !DEFAULT_BT_LE_ROLE_OBSERVER +void r_ble_lll_scan_halt(void) { } +void r_ble_ll_scan_end_adv_evt(void) { } +void r_ble_ll_scan_rx_pkt_in(void) { } +int r_ble_lll_scan_rx_pkt_isr(void) { return -1; } +int r_ble_ll_scan_env_init(void) { return 0; } +void r_ble_ll_scan_env_deinit(void) { } +void r_ble_ll_scan_init(void) { } +void r_ble_ll_scan_deinit(void) { } +void r_ble_ll_scan_reset(void) { } +int r_ble_ll_scan_can_chg_whitelist(void) { return 1; } +int r_ble_ll_scan_enabled(void) { return false; } +int r_ble_lll_scan_chk_resume(void) { return -1; } +int r_ble_ll_scan_set_scan_params(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_hci_scan_set_enable(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_scan_hci_update_adv_report_flow_ctrl(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_scan_hci_set_adv_report_flow_ctrl(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +#endif //!DEFAULT_BT_LE_ROLE_OBSERVER + +#if !DEFAULT_BT_LE_EXT_SCAN +void r_ble_lll_scan_duration_period_timers_restart(void) { } +void r_ble_lll_scan_duration_period_timers_stop(void) { } +int r_ble_ll_hci_send_legacy_ext_adv_report(void) { return -1; } +void r_ble_lll_sched_rmv_elem_type(void) { } +void r_ble_ll_scan_send_truncated(void) { } +void r_ble_ll_scan_aux_data_unref(void) { } +void r_ble_lll_scan_sched_remove(void) { } +void r_ble_lll_scan_aux_data_free(void) { } +void r_ble_lll_aux_scan_drop(void) { } +int r_ble_lll_sched_aux_scan(void) { return -1; } +int r_ble_lll_scan_rx_isr_on_aux(void) { return -1; } +void r_ble_lll_scan_period_timer_cb(void) { } +void r_ble_lll_scan_duration_timer_cb(void) { } +void r_ble_ll_scan_rx_pkt_in_on_aux(void) { } +int r_ble_ll_set_ext_scan_params(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_hci_ext_scan_set_enable(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +#endif //!DEFAULT_BT_LE_EXT_SCAN + +#if !DEFAULT_BT_LE_ROLE_CENTROL +void r_ble_ll_init_rx_pkt_in(void) { } +int r_ble_lll_init_rx_pkt_isr(void) { return -1; } +int r_ble_ll_conn_create(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_conn_create_cancel(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +#endif //!DEFAULT_BT_LE_ROLE_CENTROL + +#if !DEFAULT_BT_LE_ROLE_CENTROL || !DEFAULT_BT_LE_EXT_SCAN +int r_ble_ll_ext_conn_create(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +#endif //!DEFAULT_BT_LE_ROLE_CENTROL || !DEFAULT_BT_LE_EXT_SCAN + +#if !DEFAULT_BT_LE_ROLE_PERIPHERAL +int r_ble_ll_conn_slave_start(void) { return 0; } +#endif //!DEFAULT_BT_LE_ROLE_PERIPHERAL + +#if !DEFAULT_BT_LE_ROLE_CENTROL && !DEFAULT_BT_LE_ROLE_PERIPHERAL +void r_ble_ll_conn_rx_data_pdu(void) { } +int r_ble_lll_conn_rx_pkt_isr(void) { return -1; } +int r_ble_ll_hci_disconnect(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_conn_hci_rd_rem_ver_cmd(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_conn_hci_update(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_conn_hci_rd_chan_map(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_conn_hci_read_rem_features(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_conn_hci_param_rr(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_conn_hci_param_nrr(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +#endif //!DEFAULT_BT_LE_ROLE_CENTROL && !DEFAULT_BT_LE_ROLE_PERIPHERAL + +#if !CONFIG_BT_LE_FEAT_LL_ENCRYPTION +int r_ble_ll_conn_chk_phy_upd_start(void) { return -1; } +void r_ble_ll_hci_ev_encrypt_chg(void) { } +int r_ble_ll_ctrl_enc_allowed_pdu_rx(void) { return 1; } +int r_ble_ll_ctrl_enc_allowed_pdu_tx(void) { return 1; } +uint8_t r_ble_ll_ctrl_rx_start_enc_rsp(void) { return 0x07; } +uint8_t r_ble_ll_ctrl_rx_pause_enc_rsp(void) { return 0x07; } +int r_ble_ll_hci_le_encrypt(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +#endif //!CONFIG_BT_LE_FEAT_LL_ENCRYPTION + +#if !DEFAULT_BT_LE_ROLE_PERIPHERAL || !CONFIG_BT_LE_FEAT_LL_ENCRYPTION +uint8_t r_ble_ll_ctrl_rx_pause_enc_req(void) { return 0x07; } +uint8_t r_ble_ll_ctrl_rx_enc_req(void) { return 0x07; } +int r_ble_ll_conn_hci_le_ltk_reply(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_conn_hci_le_ltk_neg_reply(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +#endif //!DEFAULT_BT_LE_ROLE_PERIPHERAL || !CONFIG_BT_LE_FEAT_LL_ENCRYPTION + +#if !DEFAULT_BT_LE_ROLE_CENTROL || !CONFIG_BT_LE_FEAT_LL_ENCRYPTION +uint8_t r_ble_ll_ctrl_rx_start_enc_req(void) { return 0x07; } +void r_ble_ll_ctrl_rx_enc_rsp(void) { } +void r_ble_ll_ctrl_enc_req_make(void) { } +int r_ble_ll_conn_hci_le_start_encrypt(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +#endif //!DEFAULT_BT_LE_ROLE_CENTROL || !CONFIG_BT_LE_FEAT_LL_ENCRYPTION + +#if !DEGAULT_BT_LE_2M_PHY && !DEGAULT_BT_LE_CODED_PHY +void r_ble_ll_ctrl_phy_update_proc_complete(void) { } +void r_ble_ll_ctrl_phy_update_cancel(void) { } +uint8_t r_ble_ll_ctrl_rx_phy_update_ind(void) { return 0x07; } +uint8_t r_ble_ll_ctrl_rx_phy_rsp(void) { return 0x07; } +uint8_t r_ble_ll_ctrl_rx_phy_req(void) { return 0x07; } +void r_ble_ll_ctrl_phy_req_rsp_make(void) { } +#endif //DEGAULT_BT_LE_2M_PHY && DEGAULT_BT_LE_CODED_PHY + +#if !DEFAULT_BT_LE_PERIODIC_SYNC +void r_ble_lll_sync_halt(void) { } +void r_ble_lll_sync_rmvd_from_sched(void) { } +int r_ble_ll_sync_list_search(void) { return -1; } +uint8_t r_ble_ll_ctrl_rx_periodic_sync_ind(void) { return 0x07; } +void r_ble_ll_sync_rx_pkt_in(void) { } +int r_ble_lll_sync_rx_pkt_isr(void) { return -1; } +int r_ble_ll_sync_env_init(void) { return 0; } +void r_ble_ll_sync_env_deinit(void) { } +void r_ble_ll_sync_init(void) { } +void r_ble_ll_sync_deinit(void) { } +void r_ble_ll_sync_reset(void) { } +bool r_ble_ll_sync_enabled(void) { return false; } +int r_ble_ll_sync_create(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_sync_cancel(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_sync_terminate(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_sync_list_add(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_sync_list_remove(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_sync_list_clear(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_sync_list_size(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_sync_receive_enable(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +#endif //!DEFAULT_BT_LE_PERIODIC_SYNC + +#if !DEFAULT_BT_LE_PAST || !DEFAULT_BT_LE_PERIODIC_ADV +int r_ble_ll_adv_periodic_set_info_transfer(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +#endif //!DEFAULT_BT_LE_PAST || !DEFAULT_BT_LE_PERIODIC_ADV + +#if !DEFAULT_BT_LE_PAST || !DEFAULT_BT_LE_PERIODIC_SYNC +int r_ble_ll_sync_transfer(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_set_sync_transfer_params(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_set_default_sync_transfer_params(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +#endif //!DEFAULT_BT_LE_PAST || !DEFAULT_BT_LE_PERIODIC_SYNC + +#if !DEFAULT_BT_LE_50_FEATURE_SUPPORT +uint8_t r_ble_ll_ctrl_rx_channel_reporting_ind(void) { return 0x07; } +uint8_t r_ble_ll_ctrl_rx_channel_status_ind(void) { return 0x07; } +uint8_t r_ble_ll_ctrl_rx_sca_req(void) { return 0x07; } +uint8_t r_ble_ll_ctrl_rx_sca_rsp(void) { return 0x07; } +void r_ble_ll_ctrl_channel_class_reporting_make(void) { } +void r_ble_ll_ctrl_channel_class_enable_make(void) { } +void r_ble_ll_ctrl_sca_req_rsp_make(void) { } +int r_ble_ll_modify_sca(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_conn_req_peer_sca(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +#endif //!DEFAULT_BT_LE_50_FEATURE_SUPPORT + +#if !DEFAULT_BT_LE_50_FEATURE_SUPPORT +int r_ble_ll_conn_hci_le_rd_phy(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_hci_le_set_def_phy(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_ll_conn_hci_le_set_phy(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +#endif //!DEFAULT_BT_LE_50_FEATURE_SUPPORT + +#if !CONFIG_BT_LE_DTM_ENABLED +void r_ble_lll_dtm_rx_pkt_in(void) { } +int r_ble_lll_dtm_rx_isr_end(void) { return -1; } +void r_ble_lll_dtm_reset(void) { } +void r_ble_lll_dtm_init(void) { } +void r_ble_lll_dtm_deinit(void) { } +int r_ble_lll_dtm_env_init(void) { return 0; } +void r_ble_lll_dtm_env_deinit(void) { } +int r_ble_lll_hci_dtm_tx_test(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_lll_hci_dtm_rx_test(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_lll_dtm_end_test(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_lll_hci_dtm_rx_test_v2(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +int r_ble_lll_hci_dtm_tx_test_v2(void) { return BLE_ERR_UNKNOWN_HCI_CMD; } +#endif //!CONFIG_BT_LE_DTM_ENABLED diff --git a/components/bt/controller/esp32c2/esp_bt_cfg.h b/components/bt/controller/esp32c2/esp_bt_cfg.h index 456ddcf9a8..a78eca6ace 100644 --- a/components/bt/controller/esp32c2/esp_bt_cfg.h +++ b/components/bt/controller/esp32c2/esp_bt_cfg.h @@ -45,6 +45,14 @@ extern "C" { #define DEFAULT_BT_LE_50_FEATURE_SUPPORT (0) #endif + #define DEGAULT_BT_LE_2M_PHY (CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_2M_PHY) + #define DEGAULT_BT_LE_CODED_PHY (CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_CODED_PHY) + #define DEFAULT_BT_LE_EXT_ADV (CONFIG_BT_NIMBLE_EXT_ADV) + #define DEFAULT_BT_LE_PERIODIC_ADV (CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV) + #define DEFAULT_BT_LE_EXT_SCAN (CONFIG_BT_NIMBLE_EXT_SCAN) + #define DEFAULT_BT_LE_PERIODIC_SYNC (CONFIG_BT_NIMBLE_ENABLE_PERIODIC_SYNC) + #define DEFAULT_BT_LE_PAST (CONFIG_BT_NIMBLE_PERIODIC_ADV_SYNC_TRANSFER) + #define DEFAULT_BT_LE_ROLE_OBSERVER MYNEWT_VAL(BLE_ROLE_OBSERVER) #define DEFAULT_BT_LE_ROLE_CENTROL MYNEWT_VAL(BLE_ROLE_CENTRAL) #define DEFAULT_BT_LE_ROLE_PERIPHERAL MYNEWT_VAL(BLE_ROLE_PERIPHERAL) @@ -122,12 +130,55 @@ extern "C" { #else #define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT (8) #endif + #if defined(CONFIG_BT_LE_50_FEATURE_SUPPORT) #define DEFAULT_BT_LE_50_FEATURE_SUPPORT (1) #else #define DEFAULT_BT_LE_50_FEATURE_SUPPORT (0) #endif + #if defined(CONFIG_BT_LE_LL_CFG_FEAT_LE_2M_PHY) + #define DEGAULT_BT_LE_2M_PHY (CONFIG_BT_LE_LL_CFG_FEAT_LE_2M_PHY) + #else + #define DEGAULT_BT_LE_2M_PHY (0) + #endif + + #if defined(CONFIG_BT_LE_LL_CFG_FEAT_LE_CODED_PHY) + #define DEGAULT_BT_LE_CODED_PHY (CONFIG_BT_LE_LL_CFG_FEAT_LE_CODED_PHY) + #else + #define DEGAULT_BT_LE_CODED_PHY (0) + #endif + + #if defined(CONFIG_BT_LE_EXT_ADV) + #define DEFAULT_BT_LE_EXT_ADV (CONFIG_BT_LE_EXT_ADV) + #else + #define DEFAULT_BT_LE_EXT_ADV (0) + #endif + + #if defined(CONFIG_BT_LE_ENABLE_PERIODIC_ADV) + #define DEFAULT_BT_LE_PERIODIC_ADV (CONFIG_BT_LE_ENABLE_PERIODIC_ADV) + #else + #define DEFAULT_BT_LE_PERIODIC_ADV (0) + #endif + + #if defined(CONFIG_BT_LE_EXT_SCAN) + #define DEFAULT_BT_LE_EXT_SCAN (CONFIG_BT_LE_EXT_SCAN) + #else + #define DEFAULT_BT_LE_EXT_SCAN (0) + #endif + + #if defined(CONFIG_BT_LE_ENABLE_PERIODIC_SYNC) + #define DEFAULT_BT_LE_PERIODIC_SYNC (CONFIG_BT_LE_ENABLE_PERIODIC_SYNC) + #else + #define DEFAULT_BT_LE_PERIODIC_SYNC (0) + #endif + + #if defined(BT_LE_PERIODIC_ADV_SYNC_TRANSFER) + #define DEFAULT_BT_LE_PAST (BT_LE_PERIODIC_ADV_SYNC_TRANSFER) + #else + #define DEFAULT_BT_LE_PAST (0) + #endif + #if defined(CONFIG_BT_LE_ROLE_CENTROL_ENABLE) #define DEFAULT_BT_LE_ROLE_CENTROL (1) #else @@ -169,6 +220,12 @@ extern "C" { #define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF +#ifdef CONFIG_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS +#define DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS (CONFIG_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS) +#else +#define DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS (0) +#endif + #ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART #define HCI_UART_EN CONFIG_BT_LE_HCI_INTERFACE_USE_UART #else diff --git a/components/bt/controller/esp32c3/Kconfig.in b/components/bt/controller/esp32c3/Kconfig.in index 059e71dab8..d874a5612f 100644 --- a/components/bt/controller/esp32c3/Kconfig.in +++ b/components/bt/controller/esp32c3/Kconfig.in @@ -200,8 +200,8 @@ choice BT_CTRL_DFT_TX_POWER_LEVEL bool "+15dBm" config BT_CTRL_DFT_TX_POWER_LEVEL_P18 bool "+18dBm" - config BT_CTRL_DFT_TX_POWER_LEVEL_P21 - bool "+21dBm" + config BT_CTRL_DFT_TX_POWER_LEVEL_P20 + bool "+20dBm" endchoice config BT_CTRL_DFT_TX_POWER_LEVEL_EFF @@ -221,11 +221,12 @@ config BT_CTRL_DFT_TX_POWER_LEVEL_EFF default 12 if BT_CTRL_DFT_TX_POWER_LEVEL_P12 default 13 if BT_CTRL_DFT_TX_POWER_LEVEL_P15 default 14 if BT_CTRL_DFT_TX_POWER_LEVEL_P18 - default 15 if BT_CTRL_DFT_TX_POWER_LEVEL_P21 + default 15 if BT_CTRL_DFT_TX_POWER_LEVEL_P20 default 0 config BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP bool "BLE adv report flow control supported" + depends on (!BT_CTRL_RUN_IN_FLASH_ONLY) || (BT_CTRL_RUN_IN_FLASH_ONLY && BT_CTRL_BLE_SCAN) default y help The function is mainly used to enable flow control for advertising reports. When it is enabled, @@ -402,10 +403,10 @@ menu "MODEM SLEEP Options" bluetooth can work under light sleep enabled. Main crystal has a relatively better performance than other bluetooth low power clock sources. config BT_CTRL_LPCLK_SEL_EXT_32K_XTAL - bool "External 32kHz crystal" - depends on RTC_CLK_SRC_EXT_CRYS + bool "External 32kHz crystal/oscillator" + depends on RTC_CLK_SRC_EXT_CRYS || RTC_CLK_SRC_EXT_OSC help - External 32kHz crystal has a nominal frequency of 32.768kHz and provides good frequency + External 32kHz crystal/oscillator has a nominal frequency of 32.768kHz and provides good frequency stability. If used as Bluetooth low power clock, External 32kHz can support Bluetooth modem sleep to be used with both DFS and light sleep. @@ -489,3 +490,63 @@ config BT_CTRL_LE_PING_EN help If this option is disabled, The Controller will not start the LE authenticated payload timer. This option is used for some compatibility problems related to LE ping procedure. + +menu "BLE disconnect when instant passed" + config BT_CTRL_BLE_LLCP_CONN_UPDATE + bool "BLE ACL connection update procedure" + default n + help + If this option is enabled, Controller will terminate the connection + when instant passed during connection update procedure. + + config BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE + bool "BLE ACL channel map update procedure" + default n + help + If this option is enabled, Controller will terminate the connection + when instant passed in channel map update procedure. + + config BT_CTRL_BLE_LLCP_PHY_UPDATE + bool "BLE ACL PHY update procedure" + default n + help + If this option is enabled, Controller will terminate the connection + when instant passed in PHY update procedure. +endmenu +config BT_CTRL_RUN_IN_FLASH_ONLY + bool "Put all BLE Controller code in flash" + default n + help + If this option is enabled, all code for the Bluetooth controller will be moved from ROM and IRAM + to flash, saving over 20K bytes of memory. However, it will require more flash resources and the + performance of Bluetooth will decrease If this option is enabled, Bluetooth may not work properly + during erasing flash. It is recommended to turn on the auto suspend function of flash. After auto + suspend is turned on, Bluetooth interrupts can be executed normally during erasing flash, with less + impact on Bluetooth performance. + +config BT_CTRL_DTM_ENABLE + depends on BT_CTRL_RUN_IN_FLASH_ONLY + bool "Enable direct test mode feature" + default n + +config BT_CTRL_BLE_MASTER + depends on BT_CTRL_RUN_IN_FLASH_ONLY + bool "Enable BLE master role feature" + default y + +config BT_CTRL_BLE_TEST + depends on BT_CTRL_RUN_IN_FLASH_ONLY + bool "Enable BLE QA test feature" + default n + +config BT_CTRL_BLE_SCAN + depends on BT_CTRL_RUN_IN_FLASH_ONLY + bool "Enable BLE scan feature" + default y +config BT_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS + bool "Enable enhanced Access Address check in CONNECT_IND" + default n + help + Enabling this option will add stricter verification of the Access Address in the CONNECT_IND PDU. + This improves security by ensuring that only connection requests with valid Access Addresses are accepted. + If disabled, only basic checks are applied, improving compatibility. diff --git a/components/bt/controller/esp32c3/bt.c b/components/bt/controller/esp32c3/bt.c index 3f46e39c11..809560b4f5 100644 --- a/components/bt/controller/esp32c3/bt.c +++ b/components/bt/controller/esp32c3/bt.c @@ -118,6 +118,7 @@ do{\ #define BLE_PWR_HDL_INVL 0xFFFF +#define BLE_CONTROLLER_MALLOC_CAPS (MALLOC_CAP_INTERNAL|MALLOC_CAP_DMA) /* Types definition ************************************************************************ */ @@ -257,7 +258,6 @@ extern int API_vhci_host_register_callback(const vhci_host_callback_t *callback) extern int ble_txpwr_set(int power_type, uint16_t handle, int power_level); extern int ble_txpwr_get(int power_type, uint16_t handle); -extern uint16_t l2c_ble_link_get_tx_buf_num(void); extern void coex_pti_v2(void); extern bool btdm_deep_sleep_mem_init(void); @@ -273,6 +273,7 @@ extern void ets_backup_dma_copy(uint32_t reg, uint32_t mem_addr, uint32_t num, b #endif extern void btdm_cca_feature_enable(void); +extern void btdm_aa_check_enhance_enable(void); extern uint32_t _bt_bss_start; extern uint32_t _bt_bss_end; @@ -496,7 +497,11 @@ static int interrupt_alloc_wrapper(int cpu_id, int source, intr_handler_t handle { btdm_isr_alloc_t p; p.source = source; +#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY + p.flags = ESP_INTR_FLAG_LEVEL3; +#else p.flags = ESP_INTR_FLAG_LEVEL3 | ESP_INTR_FLAG_IRAM; +#endif p.fn = handler; p.arg = arg; p.handle = (intr_handle_t *)ret_handle; @@ -687,13 +692,27 @@ static bool IRAM_ATTR is_in_isr_wrapper(void) static void *malloc_internal_wrapper(size_t size) { - void *p = heap_caps_malloc(size, MALLOC_CAP_INTERNAL|MALLOC_CAP_DMA); + void *p = heap_caps_malloc(size, BLE_CONTROLLER_MALLOC_CAPS); + if(p == NULL) { + ESP_LOGE(BT_LOG_TAG, "Malloc failed"); + } + return p; +} + +void *malloc_ble_controller_mem(size_t size) +{ + void *p = heap_caps_malloc(size, BLE_CONTROLLER_MALLOC_CAPS); if(p == NULL) { ESP_LOGE(BT_LOG_TAG, "Malloc failed"); } return p; } +uint32_t get_ble_controller_free_heap_size(void) +{ + return heap_caps_get_free_size(BLE_CONTROLLER_MALLOC_CAPS); +} + static int IRAM_ATTR read_mac_wrapper(uint8_t mac[6]) { int ret = esp_read_mac(mac, ESP_MAC_BT); @@ -764,7 +783,8 @@ static void btdm_sleep_enter_phase1_wrapper(uint32_t lpcycles) // allow a maximum time uncertainty to be about 488ppm(1/2048) at least as clock drift // and set the timer in advance uint32_t uncertainty = (us_to_sleep >> 11); -#if CONFIG_FREERTOS_USE_TICKLESS_IDLE +#if CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP + // recalculate clock drift when Bluetooth using main XTAL during light sleep if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_RC_SLOW) { uncertainty = us_to_sleep * BTDM_RTC_SLOW_CLK_RC_DRIFT_PERCENT / 100; } @@ -943,6 +963,9 @@ static void btdm_funcs_table_ready_wrapper(void) #if BT_BLE_CCA_MODE == 2 btdm_cca_feature_enable(); #endif +#if BLE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED + btdm_aa_check_enhance_enable(); +#endif } bool bt_async_wakeup_request(void) @@ -1408,6 +1431,10 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) ESP_LOGI(BT_LOG_TAG, "BT controller compile version [%s]", btdm_controller_get_compile_version()); +#if (CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY) + ESP_LOGI(BT_LOG_TAG,"Put all controller code in flash"); +#endif + if ((err = btdm_low_power_mode_init(cfg)) != ESP_OK) { ESP_LOGE(BT_LOG_TAG, "Low power module initialization failed"); goto error; @@ -1420,7 +1447,10 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) periph_module_enable(PERIPH_BT_MODULE); periph_module_reset(PERIPH_BT_MODULE); - if (btdm_controller_init(cfg) != 0) { + err = btdm_controller_init(cfg); + + if (err != 0) { + ESP_LOGE(BT_LOG_TAG, "%s %d\n",__func__,err); err = ESP_ERR_NO_MEM; goto error; } @@ -1736,7 +1766,7 @@ esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type) handle = power_type; } - lvl = (esp_power_level_t)ble_txpwr_get(power_type, handle); + lvl = (esp_power_level_t)ble_txpwr_get(enh_pwr_type, handle); return lvl; } @@ -1848,11 +1878,6 @@ int IRAM_ATTR esp_bt_h4tl_eif_io_event_notify(int event) return btdm_hci_tl_io_event_post(event); } -uint16_t esp_bt_get_tx_buf_num(void) -{ - return l2c_ble_link_get_tx_buf_num(); -} - static void coex_wifi_sleep_set_hook(bool sleep) { diff --git a/components/bt/controller/esp32c6/Kconfig.in b/components/bt/controller/esp32c6/Kconfig.in index 07089db18e..421b4f5917 100644 --- a/components/bt/controller/esp32c6/Kconfig.in +++ b/components/bt/controller/esp32c6/Kconfig.in @@ -689,3 +689,11 @@ 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_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS + bool "Enable enhanced Access Address check in CONNECT_IND" + default n + help + Enabling this option will add stricter verification of the Access Address in the CONNECT_IND PDU. + This improves security by ensuring that only connection requests with valid Access Addresses are accepted. + If disabled, only basic checks are applied, improving compatibility. diff --git a/components/bt/controller/esp32c6/bt.c b/components/bt/controller/esp32c6/bt.c index 0894f13aac..a64f033abe 100644 --- a/components/bt/controller/esp32c6/bt.c +++ b/components/bt/controller/esp32c6/bt.c @@ -132,7 +132,7 @@ extern void r_ble_rtc_wake_up_state_clr(void); extern int os_msys_init(void); extern void os_msys_deinit(void); #if CONFIG_FREERTOS_USE_TICKLESS_IDLE -extern const sleep_retention_entries_config_t *esp_ble_mac_retention_link_get(uint8_t *size, uint8_t extra); +extern sleep_retention_entries_config_t *r_esp_ble_mac_retention_link_get(uint8_t *size, uint8_t extra); extern void r_esp_ble_set_wakeup_overhead(uint32_t overhead); #endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */ extern void r_esp_ble_change_rtc_freq(uint32_t freq); @@ -389,12 +389,22 @@ void esp_bt_read_ctrl_log_from_flash(bool output) static bool s_ble_active = false; #ifdef CONFIG_PM_ENABLE static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock = NULL; -#define BTDM_MIN_TIMER_UNCERTAINTY_US (200) #endif // CONFIG_PM_ENABLE - +static DRAM_ATTR modem_clock_lpclk_src_t s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_INVALID; #define BLE_RTC_DELAY_US_LIGHT_SLEEP (2500) #define BLE_RTC_DELAY_US_MODEM_SLEEP (500) +#define BLE_CONTROLLER_MALLOC_CAPS (MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT|MALLOC_CAP_DMA) +void *malloc_ble_controller_mem(size_t size) +{ + return heap_caps_malloc(size, BLE_CONTROLLER_MALLOC_CAPS); +} + +uint32_t get_ble_controller_free_heap_size(void) +{ + return heap_caps_get_free_size(BLE_CONTROLLER_MALLOC_CAPS); +} + static const struct osi_coex_funcs_t s_osi_coex_funcs_ro = { ._magic = OSI_COEX_MAGIC_VALUE, ._version = OSI_COEX_VERSION, @@ -534,6 +544,20 @@ void esp_bt_rtc_slow_clk_select(uint8_t slow_clk_src) } } +modem_clock_lpclk_src_t esp_bt_get_lpclk_src(void) +{ + return s_bt_lpclk_src; +} + +void esp_bt_set_lpclk_src(modem_clock_lpclk_src_t clk_src) +{ + if (clk_src >= MODEM_CLOCK_LPCLK_SRC_MAX) { + return; + } + + s_bt_lpclk_src = clk_src; +} + IRAM_ATTR void controller_sleep_cb(uint32_t enable_tick, void *arg) { if (!s_ble_active) { @@ -567,8 +591,8 @@ static esp_err_t sleep_modem_ble_mac_retention_init(void *arg) { uint8_t size; int extra = *(int *)arg; - const sleep_retention_entries_config_t *ble_mac_modem_config = esp_ble_mac_retention_link_get(&size, extra); - esp_err_t err = sleep_retention_entries_create(ble_mac_modem_config, size, REGDMA_LINK_PRI_5, SLEEP_RETENTION_MODULE_BLE_MAC); + sleep_retention_entries_config_t *ble_mac_modem_config = r_esp_ble_mac_retention_link_get(&size, extra); + esp_err_t err = sleep_retention_entries_create(ble_mac_modem_config, size, REGDMA_LINK_PRI_BT_MAC_BB, SLEEP_RETENTION_MODULE_BLE_MAC); if (err == ESP_OK) { ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Modem BLE MAC retention initialization"); } @@ -598,7 +622,7 @@ static void sleep_modem_ble_mac_modem_state_deinit(void) } } -void sleep_modem_light_sleep_overhead_set(uint32_t overhead) +void IRAM_ATTR sleep_modem_light_sleep_overhead_set(uint32_t overhead) { r_esp_ble_set_wakeup_overhead(overhead); } @@ -625,13 +649,16 @@ esp_err_t controller_sleep_init(void) if (rc != ESP_OK) { goto error; } -#if CONFIG_FREERTOS_USE_TICKLESS_IDLE -#if CONFIG_BT_LE_SLEEP_ENABLE && !CONFIG_MAC_BB_PD +#endif // CONFIG_PM_ENABLE +#if CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE +#if SOC_PM_RETENTION_HAS_CLOCK_BUG && !CONFIG_MAC_BB_PD #error "CONFIG_MAC_BB_PD required for BLE light sleep to run properly" -#endif // CONFIG_BT_LE_SLEEP_ENABLE && !CONFIG_MAC_BB_PD +#endif // SOC_PM_RETENTION_HAS_CLOCK_BUG && !CONFIG_MAC_BB_PD /* Create a new regdma link for BLE related register restoration */ rc = sleep_modem_ble_mac_modem_state_init(1); - assert(rc == 0); + if (rc != ESP_OK) { + goto error; + } esp_sleep_enable_bt_wakeup(); ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Enable light sleep, the wake up source is BLE timer"); @@ -644,19 +671,21 @@ esp_err_t controller_sleep_init(void) sleep_modem_register_mac_bb_module_prepare_callback(sleep_modem_mac_bb_power_down_prepare, sleep_modem_mac_bb_power_up_prepare); #endif // SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD -#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */ +#endif /* CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE */ return rc; +#ifdef CONFIG_PM_ENABLE error: - -#if CONFIG_FREERTOS_USE_TICKLESS_IDLE +#endif // CONFIG_PM_ENABLE +#if CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE #if SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD sleep_modem_unregister_mac_bb_module_prepare_callback(sleep_modem_mac_bb_power_down_prepare, sleep_modem_mac_bb_power_up_prepare); #endif // SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD esp_sleep_disable_bt_wakeup(); esp_pm_unregister_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set); -#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */ +#endif /* CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE */ +#ifdef CONFIG_PM_ENABLE /*lock should release first and then delete*/ if (s_pm_lock != NULL) { esp_pm_lock_delete(s_pm_lock); @@ -669,7 +698,7 @@ esp_err_t controller_sleep_init(void) void controller_sleep_deinit(void) { -#if CONFIG_FREERTOS_USE_TICKLESS_IDLE +#if CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE #if SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD sleep_modem_unregister_mac_bb_module_prepare_callback(sleep_modem_mac_bb_power_down_prepare, sleep_modem_mac_bb_power_up_prepare); @@ -678,7 +707,7 @@ void controller_sleep_deinit(void) esp_sleep_disable_bt_wakeup(); sleep_modem_ble_mac_modem_state_deinit(); esp_pm_unregister_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set); -#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */ +#endif /* CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE */ #ifdef CONFIG_PM_ENABLE /* lock should be released first */ esp_pm_lock_delete(s_pm_lock); @@ -757,12 +786,51 @@ void ble_controller_scan_duplicate_config(void) ble_vhci_disc_duplicate_set_max_cache_size(cache_size); } +static void ble_rtc_clk_init(esp_bt_controller_config_t *cfg) +{ + if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_INVALID) { +#if CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL + s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL; +#else +#if CONFIG_RTC_CLK_SRC_INT_RC + s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_RC_SLOW; +#elif CONFIG_RTC_CLK_SRC_EXT_CRYS + if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_XTAL32K) { + s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_XTAL32K; + } else { + ESP_LOGW(NIMBLE_PORT_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock"); + s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL; + } +#elif CONFIG_RTC_CLK_SRC_INT_RC32K + s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_RC32K; +#elif CONFIG_RTC_CLK_SRC_EXT_OSC + s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_EXT32K; +#else + ESP_LOGE(NIMBLE_PORT_LOG_TAG, "Unsupported clock source"); + assert(0); +#endif +#endif /* CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL */ + } + + if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL) { + cfg->rtc_freq = 100000; + } else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_XTAL32K) { + cfg->rtc_freq = 32768; + } else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_RC_SLOW) { + cfg->rtc_freq = 30000; + } else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_RC32K) { + cfg->rtc_freq = 32000; + } else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_EXT32K) { + cfg->rtc_freq = 32000; + } + esp_bt_rtc_slow_clk_select(s_bt_lpclk_src); +} + esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) { uint8_t mac[6]; esp_err_t ret = ESP_OK; ble_npl_count_info_t npl_info; - uint32_t slow_clk_freq = 0; uint8_t hci_transport_mode; memset(&npl_info, 0, sizeof(ble_npl_count_info_t)); @@ -814,33 +882,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) modem_clock_module_enable(PERIPH_BT_MODULE); modem_clock_module_mac_reset(PERIPH_BT_MODULE); /* Select slow clock source for BT momdule */ -#if CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL - esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL); - slow_clk_freq = 100000; -#else -#if CONFIG_RTC_CLK_SRC_INT_RC - esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_RC_SLOW); - slow_clk_freq = 30000; -#elif CONFIG_RTC_CLK_SRC_EXT_CRYS - if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_XTAL32K) { - esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_XTAL32K); - slow_clk_freq = 32768; - } else { - ESP_LOGW(NIMBLE_PORT_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock"); - esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL); - slow_clk_freq = 100000; - } -#elif CONFIG_RTC_CLK_SRC_INT_RC32K - esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_RC32K); - slow_clk_freq = 32000; -#elif CONFIG_RTC_CLK_SRC_EXT_OSC - esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_EXT32K); - slow_clk_freq = 32000; -#else - ESP_LOGE(NIMBLE_PORT_LOG_TAG, "Unsupported clock source"); - assert(0); -#endif -#endif /* CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL */ + ble_rtc_clk_init(cfg); esp_phy_modem_init(); if (ble_osi_coex_funcs_register((struct osi_coex_funcs_t *)&s_osi_coex_funcs_ro) != 0) { @@ -873,7 +915,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) } ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version()); - r_esp_ble_change_rtc_freq(slow_clk_freq); ble_controller_scan_duplicate_config(); diff --git a/components/bt/controller/esp32c6/esp_bt_cfg.h b/components/bt/controller/esp32c6/esp_bt_cfg.h index 4e24c18614..3634a40c3c 100644 --- a/components/bt/controller/esp32c6/esp_bt_cfg.h +++ b/components/bt/controller/esp32c6/esp_bt_cfg.h @@ -148,6 +148,12 @@ extern "C" { #define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF +#ifdef CONFIG_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS +#define DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS (CONFIG_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS) +#else +#define DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS (0) +#endif + #ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART #define HCI_UART_EN CONFIG_BT_LE_HCI_INTERFACE_USE_UART #else @@ -218,7 +224,6 @@ extern "C" { #define BLE_LL_TX_PWR_DBM_N (CONFIG_BT_LE_DFT_TX_POWER_LEVEL_DBM_EFF) - #define RUN_BQB_TEST (0) #define RUN_QA_TEST (0) #define NIMBLE_DISABLE_SCAN_BACKOFF (0) diff --git a/components/bt/controller/esp32h2/Kconfig.in b/components/bt/controller/esp32h2/Kconfig.in index d188d03230..4b281d029c 100644 --- a/components/bt/controller/esp32h2/Kconfig.in +++ b/components/bt/controller/esp32h2/Kconfig.in @@ -690,3 +690,11 @@ 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_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS + bool "Enable enhanced Access Address check in CONNECT_IND" + default n + help + Enabling this option will add stricter verification of the Access Address in the CONNECT_IND PDU. + This improves security by ensuring that only connection requests with valid Access Addresses are accepted. + If disabled, only basic checks are applied, improving compatibility. diff --git a/components/bt/controller/esp32h2/bt.c b/components/bt/controller/esp32h2/bt.c index 65c884bd68..c8805228d2 100644 --- a/components/bt/controller/esp32h2/bt.c +++ b/components/bt/controller/esp32h2/bt.c @@ -126,9 +126,12 @@ extern void r_ble_rtc_wake_up_state_clr(void); extern int os_msys_init(void); extern void os_msys_deinit(void); #if CONFIG_FREERTOS_USE_TICKLESS_IDLE -extern const sleep_retention_entries_config_t *esp_ble_mac_retention_link_get(uint8_t *size, uint8_t extra); +extern sleep_retention_entries_config_t *r_esp_ble_mac_retention_link_get(uint8_t *size, uint8_t extra); extern void r_esp_ble_set_wakeup_overhead(uint32_t overhead); #endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */ +#if CONFIG_PM_ENABLE +extern void r_esp_ble_stop_wakeup_timing(void); +#endif // CONFIG_PM_ENABLE extern void r_esp_ble_change_rtc_freq(uint32_t freq); extern int ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_key_y, @@ -382,8 +385,19 @@ void esp_bt_read_ctrl_log_from_flash(bool output) static bool s_ble_active = false; #ifdef CONFIG_PM_ENABLE static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock = NULL; -#define BTDM_MIN_TIMER_UNCERTAINTY_US (200) #endif // CONFIG_PM_ENABLE +static DRAM_ATTR modem_clock_lpclk_src_t s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_INVALID; + +#define BLE_CONTROLLER_MALLOC_CAPS (MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT|MALLOC_CAP_DMA) +void *malloc_ble_controller_mem(size_t size) +{ + return heap_caps_malloc(size, BLE_CONTROLLER_MALLOC_CAPS); +} + +uint32_t get_ble_controller_free_heap_size(void) +{ + return heap_caps_get_free_size(BLE_CONTROLLER_MALLOC_CAPS); +} #define BLE_RTC_DELAY_US_LIGHT_SLEEP (5100) #define BLE_RTC_DELAY_US_MODEM_SLEEP (1500) @@ -522,6 +536,20 @@ void esp_bt_rtc_slow_clk_select(uint8_t slow_clk_src) } } +modem_clock_lpclk_src_t esp_bt_get_lpclk_src(void) +{ + return s_bt_lpclk_src; +} + +void esp_bt_set_lpclk_src(modem_clock_lpclk_src_t clk_src) +{ + if (clk_src >= MODEM_CLOCK_LPCLK_SRC_MAX) { + return; + } + + s_bt_lpclk_src = clk_src; +} + IRAM_ATTR void controller_sleep_cb(uint32_t enable_tick, void *arg) { if (!s_ble_active) { @@ -555,8 +583,8 @@ static esp_err_t sleep_modem_ble_mac_retention_init(void *arg) { uint8_t size; int extra = *(int *)arg; - const sleep_retention_entries_config_t *ble_mac_modem_config = esp_ble_mac_retention_link_get(&size, extra); - esp_err_t err = sleep_retention_entries_create(ble_mac_modem_config, size, REGDMA_LINK_PRI_5, SLEEP_RETENTION_MODULE_BLE_MAC); + sleep_retention_entries_config_t *ble_mac_modem_config = r_esp_ble_mac_retention_link_get(&size, extra); + esp_err_t err = sleep_retention_entries_create(ble_mac_modem_config, size, REGDMA_LINK_PRI_BT_MAC_BB, SLEEP_RETENTION_MODULE_BLE_MAC); if (err == ESP_OK) { ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Modem BLE MAC retention initialization"); } @@ -586,7 +614,7 @@ static void sleep_modem_ble_mac_modem_state_deinit(void) } } -void sleep_modem_light_sleep_overhead_set(uint32_t overhead) +void IRAM_ATTR sleep_modem_light_sleep_overhead_set(uint32_t overhead) { r_esp_ble_set_wakeup_overhead(overhead); } @@ -613,10 +641,17 @@ esp_err_t controller_sleep_init(void) if (rc != ESP_OK) { goto error; } -#if CONFIG_FREERTOS_USE_TICKLESS_IDLE + rc = esp_deep_sleep_register_hook(&r_esp_ble_stop_wakeup_timing); + if (rc != ESP_OK) { + goto error; + } +#endif //CONFIG_PM_ENABLE +#if CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE /* Create a new regdma link for BLE related register restoration */ rc = sleep_modem_ble_mac_modem_state_init(0); - assert(rc == 0); + if (rc != ESP_OK) { + goto error; + } esp_sleep_enable_bt_wakeup(); ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Enable light sleep, the wake up source is BLE timer"); @@ -624,15 +659,18 @@ esp_err_t controller_sleep_init(void) if (rc != ESP_OK) { goto error; } -#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */ +#endif /* CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE */ return rc; +#ifdef CONFIG_PM_ENABLE error: - -#if CONFIG_FREERTOS_USE_TICKLESS_IDLE +#endif // CONFIG_PM_ENABLE +#if CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE esp_sleep_disable_bt_wakeup(); esp_pm_unregister_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set); -#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */ +#endif /* CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE */ +#ifdef CONFIG_PM_ENABLE + esp_deep_sleep_deregister_hook(&r_esp_ble_stop_wakeup_timing); /*lock should release first and then delete*/ if (s_pm_lock != NULL) { esp_pm_lock_delete(s_pm_lock); @@ -645,13 +683,14 @@ esp_err_t controller_sleep_init(void) void controller_sleep_deinit(void) { -#if CONFIG_FREERTOS_USE_TICKLESS_IDLE +#if CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE r_ble_rtc_wake_up_state_clr(); esp_sleep_disable_bt_wakeup(); sleep_modem_ble_mac_modem_state_deinit(); esp_pm_unregister_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set); -#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */ +#endif /* CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE */ #ifdef CONFIG_PM_ENABLE + esp_deep_sleep_deregister_hook(&r_esp_ble_stop_wakeup_timing); /* lock should be released first */ esp_pm_lock_delete(s_pm_lock); s_pm_lock = NULL; @@ -729,12 +768,51 @@ void ble_controller_scan_duplicate_config(void) ble_vhci_disc_duplicate_set_max_cache_size(cache_size); } +static void ble_rtc_clk_init(esp_bt_controller_config_t *cfg) +{ + if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_INVALID) { +#if CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL + s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL; +#else +#if CONFIG_RTC_CLK_SRC_INT_RC + s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_RC_SLOW; +#elif CONFIG_RTC_CLK_SRC_EXT_CRYS + if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_XTAL32K) { + s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_XTAL32K; + } else { + ESP_LOGW(NIMBLE_PORT_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock"); + s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL; + } +#elif CONFIG_RTC_CLK_SRC_INT_RC32K + s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_RC32K; +#elif CONFIG_RTC_CLK_SRC_EXT_OSC + s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_EXT32K; +#else + ESP_LOGE(NIMBLE_PORT_LOG_TAG, "Unsupported clock source"); + assert(0); +#endif +#endif /* CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL */ + } + + if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL) { + cfg->rtc_freq = 100000; + } else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_XTAL32K) { + cfg->rtc_freq = 32768; + } else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_RC_SLOW) { + cfg->rtc_freq = 30000; + } else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_RC32K) { + cfg->rtc_freq = 32000; + } else if (s_bt_lpclk_src == MODEM_CLOCK_LPCLK_SRC_EXT32K) { + cfg->rtc_freq = 32000; + } + esp_bt_rtc_slow_clk_select(s_bt_lpclk_src); +} + esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) { uint8_t mac[6]; esp_err_t ret = ESP_OK; ble_npl_count_info_t npl_info; - uint32_t slow_clk_freq = 0; uint8_t hci_transport_mode; memset(&npl_info, 0, sizeof(ble_npl_count_info_t)); @@ -786,33 +864,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) modem_clock_module_enable(PERIPH_BT_MODULE); modem_clock_module_mac_reset(PERIPH_BT_MODULE); /* Select slow clock source for BT momdule */ -#if CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL - esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL); - slow_clk_freq = 100000; -#else -#if CONFIG_RTC_CLK_SRC_INT_RC - esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_RC_SLOW); - slow_clk_freq = 30000; -#elif CONFIG_RTC_CLK_SRC_EXT_CRYS - if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_XTAL32K) { - esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_XTAL32K); - slow_clk_freq = 32768; - } else { - ESP_LOGW(NIMBLE_PORT_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock"); - esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL); - slow_clk_freq = 100000; - } -#elif CONFIG_RTC_CLK_SRC_INT_RC32K - esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_RC32K); - slow_clk_freq = 32000; -#elif CONFIG_RTC_CLK_SRC_EXT_OSC - esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_EXT32K); - slow_clk_freq = 32000; -#else - ESP_LOGE(NIMBLE_PORT_LOG_TAG, "Unsupported clock source"); - assert(0); -#endif -#endif /* CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL */ + ble_rtc_clk_init(cfg); if (ble_osi_coex_funcs_register((struct osi_coex_funcs_t *)&s_osi_coex_funcs_ro) != 0) { ESP_LOGW(NIMBLE_PORT_LOG_TAG, "osi coex funcs reg failed"); @@ -844,7 +896,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) } ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version()); - r_esp_ble_change_rtc_freq(slow_clk_freq); ble_controller_scan_duplicate_config(); diff --git a/components/bt/controller/esp32h2/esp_bt_cfg.h b/components/bt/controller/esp32h2/esp_bt_cfg.h index 22a09be3ad..3634a40c3c 100644 --- a/components/bt/controller/esp32h2/esp_bt_cfg.h +++ b/components/bt/controller/esp32h2/esp_bt_cfg.h @@ -148,6 +148,12 @@ extern "C" { #define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF +#ifdef CONFIG_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS +#define DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS (CONFIG_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS) +#else +#define DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS (0) +#endif + #ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART #define HCI_UART_EN CONFIG_BT_LE_HCI_INTERFACE_USE_UART #else diff --git a/components/bt/esp_ble_mesh/Kconfig.in b/components/bt/esp_ble_mesh/Kconfig.in index cb2a41a6b9..8f382b1e4f 100644 --- a/components/bt/esp_ble_mesh/Kconfig.in +++ b/components/bt/esp_ble_mesh/Kconfig.in @@ -9,6 +9,7 @@ if BLE_MESH config BLE_MESH_RANDOM_ADV_INTERVAL bool "Support using random adv interval for mesh packets" select BT_BLE_HIGH_DUTY_ADV_INTERVAL if BT_BLUEDROID_ENABLED + select BT_NIMBLE_HIGH_DUTY_ADV_ITVL if BT_NIMBLE_ENABLED default n help Enable this option to allow using random advertising interval diff --git a/components/bt/esp_ble_mesh/mesh_core/beacon.c b/components/bt/esp_ble_mesh/mesh_core/beacon.c index 981f88edcd..05f7ecc6f7 100644 --- a/components/bt/esp_ble_mesh/mesh_core/beacon.c +++ b/components/bt/esp_ble_mesh/mesh_core/beacon.c @@ -27,7 +27,12 @@ #else #define UNPROVISIONED_INTERVAL K_SECONDS(5) #endif + +#if CONFIG_BLE_MESH_BQB_TEST +#define PROVISIONED_INTERVAL K_SECONDS(3) +#else #define PROVISIONED_INTERVAL K_SECONDS(10) +#endif #define BEACON_TYPE_UNPROVISIONED 0x00 #define BEACON_TYPE_SECURE 0x01 diff --git a/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c b/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c index e85797b685..2328ac6a4a 100644 --- a/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c +++ b/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c @@ -1175,6 +1175,7 @@ uint16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn) int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, uint16_t service_uuid) { + tBTA_BLE_CONN_PARAMS conn_1m_param = {0}; uint8_t zero[6] = {0}; int i; @@ -1228,10 +1229,14 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, uint16_t service_uuid) * Slave_latency: 0x0 * Supervision_timeout: 1s */ - BTA_DmSetBlePrefConnParams(bt_mesh_gattc_info[i].addr.val, 0x18, 0x18, 0x00, 0x64); - - BTA_GATTC_Open(bt_mesh_gattc_if, bt_mesh_gattc_info[i].addr.val, - bt_mesh_gattc_info[i].addr.type, true, BTA_GATT_TRANSPORT_LE, FALSE); + conn_1m_param.interval_min = 0x18; + conn_1m_param.interval_max = 0x18; + conn_1m_param.latency = 0; + conn_1m_param.supervision_timeout = 0x64; + + BTA_GATTC_Enh_Open(bt_mesh_gattc_if, bt_mesh_gattc_info[i].addr.val, + bt_mesh_gattc_info[i].addr.type, true, BTA_GATT_TRANSPORT_LE, FALSE, BLE_ADDR_UNKNOWN_TYPE, + BTA_BLE_PHY_1M_MASK, &conn_1m_param, NULL, NULL); return 0; } diff --git a/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c b/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c index 1cbb569ee6..f626970e0a 100644 --- a/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c +++ b/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c @@ -1174,7 +1174,7 @@ static struct label *va_find(const uint8_t *label_uuid, return match; } -static uint8_t va_add(uint8_t *label_uuid, uint16_t *addr) +uint8_t va_add(uint8_t *label_uuid, uint16_t *addr) { struct label *update = NULL, *free_slot = NULL; @@ -1182,6 +1182,9 @@ static uint8_t va_add(uint8_t *label_uuid, uint16_t *addr) if (update) { update->ref++; va_store(update); + if (addr) { + *addr = update->addr; + } return STATUS_SUCCESS; } @@ -1201,7 +1204,7 @@ static uint8_t va_add(uint8_t *label_uuid, uint16_t *addr) return STATUS_SUCCESS; } -static uint8_t va_del(uint8_t *label_uuid, uint16_t *addr) +uint8_t va_del(uint8_t *label_uuid, uint16_t *addr) { struct label *update = NULL; diff --git a/components/bt/esp_ble_mesh/mesh_core/settings.c b/components/bt/esp_ble_mesh/mesh_core/settings.c index b93241a772..f5b661b2a1 100644 --- a/components/bt/esp_ble_mesh/mesh_core/settings.c +++ b/components/bt/esp_ble_mesh/mesh_core/settings.c @@ -1422,6 +1422,8 @@ int settings_core_commit(void) struct bt_mesh_hb_pub *hb_pub = NULL; struct bt_mesh_cfg_srv *cfg = NULL; + bt_mesh_atomic_set_bit(bt_mesh.flags, BLE_MESH_VALID); + hb_pub = bt_mesh_hb_pub_get(); if (hb_pub && hb_pub->dst != BLE_MESH_ADDR_UNASSIGNED && hb_pub->count && hb_pub->period) { @@ -1440,7 +1442,6 @@ int settings_core_commit(void) cfg->default_ttl = stored_cfg.cfg.default_ttl; } - bt_mesh_atomic_set_bit(bt_mesh.flags, BLE_MESH_VALID); bt_mesh_net_start(); } #endif /* CONFIG_BLE_MESH_NODE */ diff --git a/components/bt/host/bluedroid/Kconfig.in b/components/bt/host/bluedroid/Kconfig.in index bdcda374af..d1ca83c6aa 100644 --- a/components/bt/host/bluedroid/Kconfig.in +++ b/components/bt/host/bluedroid/Kconfig.in @@ -59,7 +59,7 @@ config BT_A2DP_ENABLE depends on BT_CLASSIC_ENABLED default n help - Advanced Audio Distrubution Profile + Advanced Audio Distribution Profile config BT_SPP_ENABLED bool "SPP" @@ -114,7 +114,7 @@ config BT_HFP_WBS_ENABLE default y help This enables Wide Band Speech. Should disable it when SCO data path is PCM. - Otherwise there will be no data transmited via GPIOs. + Otherwise there will be no data transmitted via GPIOs. menuconfig BT_HID_ENABLED @@ -305,6 +305,13 @@ config BT_BLE_SMP_ID_RESET_ENABLE of a previously paired peer to be used to determine whether a device with which it previously shared an IRK is within range. +config BT_BLE_SMP_BOND_NVS_FLASH + bool "Save SMP bonding keys to nvs flash" + depends on BT_BLE_SMP_ENABLE + default y + help + This select can save SMP bonding keys to nvs flash + config BT_STACK_NO_LOG bool "Disable BT debug logs (minimize bin size)" depends on BT_BLUEDROID_ENABLED @@ -1065,7 +1072,7 @@ config BT_ACL_CONNECTIONS is used. config BT_MULTI_CONNECTION_ENBALE - bool "Enable BLE multi-conections" + bool "Enable BLE multi-connections" depends on BT_BLE_ENABLED default y help @@ -1163,19 +1170,23 @@ config BT_BLE_RPA_TIMEOUT Default is 900 s (15 minutes). Range is 1 s to 1 hour (3600 s). config BT_BLE_50_FEATURES_SUPPORTED - bool "Enable BLE 5.0 features" + bool "Enable BLE 5.0 features(please disable BLE 4.2 if enable BLE 5.0)" depends on (BT_BLE_ENABLED && (IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3 || SOC_ESP_NIMBLE_CONTROLLER)) default y help Enabling this option activates BLE 5.0 features. This option is universally supported in chips that support BLE, except for ESP32. + BLE 4.2 and BLE 5.0 cannot be used simultaneously. + config BT_BLE_42_FEATURES_SUPPORTED - bool "Enable BLE 4.2 features" + bool "Enable BLE 4.2 features(please disable BLE 5.0 if enable BLE 4.2)" depends on (BT_BLE_ENABLED && (IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3 || SOC_ESP_NIMBLE_CONTROLLER)) default n help This enables BLE 4.2 features. + This option is universally supported by all ESP chips with BLE capabilities. + BLE 4.2 and BLE 5.0 cannot be used simultaneously. config BT_BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER bool "Enable BLE periodic advertising sync transfer feature" @@ -1204,3 +1215,10 @@ config BT_BLE_HIGH_DUTY_ADV_INTERVAL default n help This enable BLE high duty advertising interval feature + +config BT_ABORT_WHEN_ALLOCATION_FAILS + bool "Abort when memory allocation fails in BT/BLE stack" + depends on BT_BLUEDROID_ENABLED + default n + help + This enables abort when memory allocation fails diff --git a/components/bt/host/bluedroid/api/esp_bt_main.c b/components/bt/host/bluedroid/api/esp_bt_main.c index 2767e2e52e..01d9649844 100644 --- a/components/bt/host/bluedroid/api/esp_bt_main.c +++ b/components/bt/host/bluedroid/api/esp_bt_main.c @@ -213,3 +213,14 @@ esp_err_t esp_bluedroid_deinit(void) return ESP_OK; } + +#if defined(CONFIG_EXAMPLE_CI_ID) && defined(CONFIG_EXAMPLE_CI_PIPELINE_ID) +char *esp_bluedroid_get_example_name(void) +{ + static char example_name[ESP_BLE_ADV_NAME_LEN_MAX]; + memset(example_name, 0, sizeof(example_name)); + sprintf(example_name, "BE%02X_%05X_%02X", CONFIG_EXAMPLE_CI_ID & 0xFF, + CONFIG_EXAMPLE_CI_PIPELINE_ID & 0xFFFFF, CONFIG_IDF_FIRMWARE_CHIP_ID & 0xFF); + return example_name; +} +#endif diff --git a/components/bt/host/bluedroid/api/esp_gap_ble_api.c b/components/bt/host/bluedroid/api/esp_gap_ble_api.c index 4381161b91..5d932eb8ed 100644 --- a/components/bt/host/bluedroid/api/esp_gap_ble_api.c +++ b/components/bt/host/bluedroid/api/esp_gap_ble_api.c @@ -13,7 +13,7 @@ #include "btc/btc_manage.h" #include "btc_gap_ble.h" #include "btc/btc_ble_storage.h" - +#include "esp_random.h" esp_err_t esp_ble_gap_register_callback(esp_gap_ble_cb_t callback) { @@ -188,6 +188,25 @@ esp_err_t esp_ble_gap_set_pkt_data_len(esp_bd_addr_t remote_device, uint16_t tx_ return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } +esp_err_t esp_ble_gap_addr_create_static(esp_bd_addr_t rand_addr) +{ + // Static device address: First two bits are '11', rest is random + rand_addr[0] = 0xC0 | (esp_random() & 0x3F); + for (int i = 1; i < 6; i++) { + rand_addr[i] = esp_random() & 0xFF; // Randomize remaining bits + } + return ESP_OK; +} + +esp_err_t esp_ble_gap_addr_create_nrpa(esp_bd_addr_t rand_addr) +{ + // Non-resolvable private address: First two bits are '00', rest is random + rand_addr[0] = (esp_random() & 0x3F); + for (int i = 1; i < 6; i++) { + rand_addr[i] = esp_random() & 0xFF; // Randomize remaining bits + } + return ESP_OK; +} esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr) { @@ -469,21 +488,37 @@ esp_err_t esp_ble_gap_get_local_used_addr(esp_bd_addr_t local_used_addr, uint8_t return ESP_OK; } -uint8_t *esp_ble_resolve_adv_data( uint8_t *adv_data, uint8_t type, uint8_t *length) +uint8_t *esp_ble_resolve_adv_data_by_type( uint8_t *adv_data, uint16_t adv_data_len, esp_ble_adv_data_type type, uint8_t *length) { + if (length == NULL) { + return NULL; + } + if (((type < ESP_BLE_AD_TYPE_FLAG) || (type > ESP_BLE_AD_TYPE_128SERVICE_DATA)) && (type != ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE)) { - LOG_ERROR("the eir type not define, type = %x\n", type); + LOG_ERROR("The advertising data type is not defined, type = %x", type); + *length = 0; return NULL; } + if (adv_data_len == 0) { + *length = 0; + return NULL; + } if (adv_data == NULL) { - LOG_ERROR("Invalid p_eir data.\n"); + LOG_ERROR("Invalid advertising data."); + *length = 0; return NULL; } - return (BTM_CheckAdvData( adv_data, type, length)); + return (BTM_CheckAdvData( adv_data, adv_data_len, type, length)); +} + +uint8_t *esp_ble_resolve_adv_data( uint8_t *adv_data, uint8_t type, uint8_t *length) +{ + return esp_ble_resolve_adv_data_by_type( adv_data, ESP_BLE_ADV_DATA_LEN_MAX + ESP_BLE_SCAN_RSP_DATA_LEN_MAX, (esp_ble_adv_data_type) type, length); } + #if (BLE_42_FEATURE_SUPPORT == TRUE) esp_err_t esp_ble_gap_config_adv_data_raw(uint8_t *raw_data, uint32_t raw_data_len) { @@ -998,6 +1033,23 @@ esp_err_t esp_ble_gap_set_privacy_mode(esp_ble_addr_type_t addr_type, esp_bd_add == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } +esp_err_t esp_ble_gap_set_csa_support(uint8_t csa_select) +{ + btc_msg_t msg; + btc_ble_gap_args_t arg; + + ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_SET_CSA_SUPPORT; + + arg.set_csa_support.csa_select = csa_select; + + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL) + == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} + #if (BLE_50_FEATURE_SUPPORT == TRUE) esp_err_t esp_ble_gap_read_phy(esp_bd_addr_t bd_addr) diff --git a/components/bt/host/bluedroid/api/esp_gap_bt_api.c b/components/bt/host/bluedroid/api/esp_gap_bt_api.c index efed98b5d5..5a0efce975 100644 --- a/components/bt/host/bluedroid/api/esp_gap_bt_api.c +++ b/components/bt/host/bluedroid/api/esp_gap_bt_api.c @@ -180,6 +180,7 @@ esp_err_t esp_bt_gap_set_cod(esp_bt_cod_t cod, esp_bt_cod_mode_t mode) } switch (mode) { + case ESP_BT_SET_COD_RESERVED_2: case ESP_BT_SET_COD_MAJOR_MINOR: case ESP_BT_SET_COD_SERVICE_CLASS: case ESP_BT_CLR_COD_SERVICE_CLASS: diff --git a/components/bt/host/bluedroid/api/esp_gattc_api.c b/components/bt/host/bluedroid/api/esp_gattc_api.c index 5f078b2809..83481a85c6 100644 --- a/components/bt/host/bluedroid/api/esp_gattc_api.c +++ b/components/bt/host/bluedroid/api/esp_gattc_api.c @@ -67,46 +67,134 @@ esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gattc_if) return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } -#if (BLE_42_FEATURE_SUPPORT == TRUE) -esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, esp_ble_addr_type_t remote_addr_type, bool is_direct) + +esp_err_t esp_ble_gattc_enh_open(esp_gatt_if_t gattc_if, esp_ble_gatt_creat_conn_params_t *creat_conn_params) { btc_msg_t msg = {0}; btc_ble_gattc_args_t arg; + const esp_ble_conn_params_t *conn_params; ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); + if (!creat_conn_params) { + return ESP_ERR_INVALID_ARG; + } + msg.sig = BTC_SIG_API_CALL; msg.pid = BTC_PID_GATTC; msg.act = BTC_GATTC_ACT_OPEN; arg.open.gattc_if = gattc_if; - memcpy(arg.open.remote_bda, remote_bda, ESP_BD_ADDR_LEN); - arg.open.remote_addr_type = remote_addr_type; - arg.open.is_direct = is_direct; - arg.open.is_aux = false; + memcpy(arg.open.remote_bda, creat_conn_params->remote_bda, ESP_BD_ADDR_LEN); + arg.open.remote_addr_type = creat_conn_params->remote_addr_type; + arg.open.is_direct = creat_conn_params->is_direct; + arg.open.is_aux= creat_conn_params->is_aux; + arg.open.own_addr_type = creat_conn_params->own_addr_type; + arg.open.phy_mask = creat_conn_params->phy_mask; + + // If not aux open, shouldn't set 2M and coded PHY connection params + if (!creat_conn_params->is_aux && + ((creat_conn_params->phy_mask & ESP_BLE_PHY_2M_PREF_MASK) || + (creat_conn_params->phy_mask & ESP_BLE_PHY_CODED_PREF_MASK))) { + return ESP_ERR_INVALID_ARG; + } + + if (creat_conn_params->phy_mask & ESP_BLE_PHY_1M_PREF_MASK) { + if (!creat_conn_params->phy_1m_conn_params) { + return ESP_ERR_INVALID_ARG; + } + + conn_params = creat_conn_params->phy_1m_conn_params; + if (ESP_BLE_IS_VALID_PARAM(conn_params->interval_min, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->interval_max, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->supervision_timeout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) && + (conn_params->latency <= ESP_BLE_CONN_LATENCY_MAX) && + ((conn_params->supervision_timeout * 10) >= ((1 + conn_params->latency) * ((conn_params->interval_max * 5) >> 1))) && + (conn_params->interval_min <= conn_params->interval_max)) { + memcpy(&arg.open.phy_1m_conn_params, conn_params, sizeof(esp_ble_conn_params_t)); + } else { + LOG_ERROR("%s, invalid 1M PHY connection params: min_int = %d, max_int = %d, latency = %d, timeout = %d", __func__, + conn_params->interval_min, + conn_params->interval_max, + conn_params->latency, + conn_params->supervision_timeout); + return ESP_ERR_INVALID_ARG; + } + } + + if (creat_conn_params->phy_mask & ESP_BLE_PHY_2M_PREF_MASK) { + if (!creat_conn_params->phy_2m_conn_params) { + return ESP_ERR_INVALID_ARG; + } + + conn_params = creat_conn_params->phy_2m_conn_params; + if (ESP_BLE_IS_VALID_PARAM(conn_params->interval_min, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->interval_max, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->supervision_timeout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) && + (conn_params->latency <= ESP_BLE_CONN_LATENCY_MAX) && + ((conn_params->supervision_timeout * 10) >= ((1 + conn_params->latency) * ((conn_params->interval_max * 5) >> 1))) && + (conn_params->interval_min <= conn_params->interval_max)) { + memcpy(&arg.open.phy_2m_conn_params, conn_params, sizeof(esp_ble_conn_params_t)); + } else { + LOG_ERROR("%s, invalid 2M PHY connection params: min_int = %d, max_int = %d, latency = %d, timeout = %d", __func__, + conn_params->interval_min, + conn_params->interval_max, + conn_params->latency, + conn_params->supervision_timeout); + return ESP_ERR_INVALID_ARG; + } + } + + if (creat_conn_params->phy_mask & ESP_BLE_PHY_CODED_PREF_MASK) { + if (!creat_conn_params->phy_coded_conn_params) { + return ESP_ERR_INVALID_ARG; + } + + conn_params = creat_conn_params->phy_coded_conn_params; + if (ESP_BLE_IS_VALID_PARAM(conn_params->interval_min, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->interval_max, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->supervision_timeout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) && + (conn_params->latency <= ESP_BLE_CONN_LATENCY_MAX) && + ((conn_params->supervision_timeout * 10) >= ((1 + conn_params->latency) * ((conn_params->interval_max * 5) >> 1))) && + (conn_params->interval_min <= conn_params->interval_max)) { + memcpy(&arg.open.phy_coded_conn_params, conn_params, sizeof(esp_ble_conn_params_t)); + } else { + LOG_ERROR("%s, invalid Coded PHY connection params: min_int = %d, max_int = %d, latency = %d, timeout = %d", __func__, + conn_params->interval_min, + conn_params->interval_max, + conn_params->latency, + conn_params->supervision_timeout); + return ESP_ERR_INVALID_ARG; + } + } return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } + +#if (BLE_42_FEATURE_SUPPORT == TRUE) +esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, esp_ble_addr_type_t remote_addr_type, bool is_direct) +{ + esp_ble_gatt_creat_conn_params_t creat_conn_params = {0}; + memcpy(creat_conn_params.remote_bda, remote_bda, ESP_BD_ADDR_LEN); + creat_conn_params.remote_addr_type = remote_addr_type; + creat_conn_params.is_direct = is_direct; + creat_conn_params.is_aux = false; + creat_conn_params.own_addr_type = 0xff; //undefined, will use local value + creat_conn_params.phy_mask = 0x0; + return esp_ble_gattc_enh_open(gattc_if, &creat_conn_params); +} #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) #if (BLE_50_FEATURE_SUPPORT == TRUE) esp_err_t esp_ble_gattc_aux_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, esp_ble_addr_type_t remote_addr_type, bool is_direct) { - btc_msg_t msg; - btc_ble_gattc_args_t arg; - - ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); - - msg.sig = BTC_SIG_API_CALL; - msg.pid = BTC_PID_GATTC; - msg.act = BTC_GATTC_ACT_AUX_OPEN; - arg.open.gattc_if = gattc_if; - memcpy(arg.open.remote_bda, remote_bda, ESP_BD_ADDR_LEN); - arg.open.remote_addr_type = remote_addr_type; - arg.open.is_direct = is_direct; - arg.open.is_aux = true; - - return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); - + esp_ble_gatt_creat_conn_params_t creat_conn_params = {0}; + memcpy(creat_conn_params.remote_bda, remote_bda, ESP_BD_ADDR_LEN); + creat_conn_params.remote_addr_type = remote_addr_type; + creat_conn_params.is_direct = is_direct; + creat_conn_params.is_aux = true; + creat_conn_params.own_addr_type = 0xff; //undefined, will use local value + creat_conn_params.phy_mask = 0x0; + return esp_ble_gattc_enh_open(gattc_if, &creat_conn_params); } #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) @@ -363,10 +451,14 @@ esp_err_t esp_ble_gattc_read_char (esp_gatt_if_t gattc_if, } if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) { - LOG_DEBUG("%s, the l2cap chanel is congest.", __func__); + LOG_DEBUG("%s, the l2cap channel is congest.", __func__); return ESP_FAIL; } + if (handle == 0) { + return ESP_GATT_INVALID_HANDLE; + } + msg.sig = BTC_SIG_API_CALL; msg.pid = BTC_PID_GATTC; msg.act = BTC_GATTC_ACT_READ_CHAR; @@ -400,10 +492,14 @@ esp_err_t esp_ble_gattc_read_by_type (esp_gatt_if_t gattc_if, } if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) { - LOG_DEBUG("%s, the l2cap chanel is congest.", __func__); + LOG_DEBUG("%s, the l2cap channel is congest.", __func__); return ESP_FAIL; } + if (start_handle == 0 || end_handle == 0) { + return ESP_GATT_INVALID_HANDLE; + } + msg.sig = BTC_SIG_API_CALL; msg.pid = BTC_PID_GATTC; msg.act = BTC_GATTC_ACT_READ_BY_TYPE; @@ -432,7 +528,7 @@ esp_err_t esp_ble_gattc_read_multiple(esp_gatt_if_t gattc_if, } if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) { - LOG_DEBUG("%s, the l2cap chanel is congest.", __func__); + LOG_DEBUG("%s, the l2cap channel is congest.", __func__); return ESP_FAIL; } @@ -468,7 +564,7 @@ esp_err_t esp_ble_gattc_read_multiple_variable(esp_gatt_if_t gattc_if, } if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) { - LOG_DEBUG("%s, the l2cap chanel is congest.", __func__); + LOG_DEBUG("%s, the l2cap channel is congest.", __func__); return ESP_FAIL; } @@ -504,10 +600,14 @@ esp_err_t esp_ble_gattc_read_char_descr (esp_gatt_if_t gattc_if, } if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) { - LOG_DEBUG("%s, the l2cap chanel is congest.", __func__); + LOG_DEBUG("%s, the l2cap channel is congest.", __func__); return ESP_FAIL; } + if (handle == 0) { + return ESP_GATT_INVALID_HANDLE; + } + msg.sig = BTC_SIG_API_CALL; msg.pid = BTC_PID_GATTC; msg.act = BTC_GATTC_ACT_READ_CHAR_DESCR; @@ -537,10 +637,14 @@ esp_err_t esp_ble_gattc_write_char(esp_gatt_if_t gattc_if, } if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) { - LOG_DEBUG("%s, the l2cap chanel is congest.", __func__); + LOG_DEBUG("%s, the l2cap channel is congest.", __func__); return ESP_FAIL; } + if (handle == 0) { + return ESP_GATT_INVALID_HANDLE; + } + msg.sig = BTC_SIG_API_CALL; msg.pid = BTC_PID_GATTC; msg.act = BTC_GATTC_ACT_WRITE_CHAR; @@ -576,10 +680,14 @@ esp_err_t esp_ble_gattc_write_char_descr (esp_gatt_if_t gattc_if, } if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) { - LOG_DEBUG("%s, the l2cap chanel is congest.", __func__); + LOG_DEBUG("%s, the l2cap channel is congest.", __func__); return ESP_FAIL; } + if (handle == 0) { + return ESP_GATT_INVALID_HANDLE; + } + msg.sig = BTC_SIG_API_CALL; msg.pid = BTC_PID_GATTC; msg.act = BTC_GATTC_ACT_WRITE_CHAR_DESCR; @@ -615,10 +723,14 @@ esp_err_t esp_ble_gattc_prepare_write(esp_gatt_if_t gattc_if, } if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) { - LOG_DEBUG("%s, the l2cap chanel is congest.", __func__); + LOG_DEBUG("%s, the l2cap channel is congest.", __func__); return ESP_FAIL; } + if (handle == 0) { + return ESP_GATT_INVALID_HANDLE; + } + msg.sig = BTC_SIG_API_CALL; msg.pid = BTC_PID_GATTC; msg.act = BTC_GATTC_ACT_PREPARE_WRITE; @@ -652,10 +764,14 @@ esp_err_t esp_ble_gattc_prepare_write_char_descr(esp_gatt_if_t gattc_if, } if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) { - LOG_DEBUG("%s, the l2cap chanel is congest.", __func__); + LOG_DEBUG("%s, the l2cap channel is congest.", __func__); return ESP_FAIL; } + if (handle == 0) { + return ESP_GATT_INVALID_HANDLE; + } + msg.sig = BTC_SIG_API_CALL; msg.pid = BTC_PID_GATTC; msg.act = BTC_GATTC_ACT_PREPARE_WRITE_CHAR_DESCR; @@ -694,6 +810,10 @@ esp_err_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gattc_if, ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); + if (handle == 0) { + return ESP_GATT_INVALID_HANDLE; + } + msg.sig = BTC_SIG_API_CALL; msg.pid = BTC_PID_GATTC; msg.act = BTC_GATTC_ACT_REG_FOR_NOTIFY; @@ -712,6 +832,10 @@ esp_err_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gattc_if, ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); + if (handle == 0) { + return ESP_GATT_INVALID_HANDLE; + } + msg.sig = BTC_SIG_API_CALL; msg.pid = BTC_PID_GATTC; msg.act = BTC_GATTC_ACT_UNREG_FOR_NOTIFY; diff --git a/components/bt/host/bluedroid/api/esp_sdp_api.c b/components/bt/host/bluedroid/api/esp_sdp_api.c index c47c5ba50a..11e0e15340 100644 --- a/components/bt/host/bluedroid/api/esp_sdp_api.c +++ b/components/bt/host/bluedroid/api/esp_sdp_api.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -15,6 +15,24 @@ #if (defined BTC_SDP_INCLUDED && BTC_SDP_INCLUDED == TRUE) +static bool esp_sdp_record_integrity_check(esp_bluetooth_sdp_record_t *record) +{ + bool ret = true; + + if (record != NULL) { + if (record->hdr.service_name_length > ESP_SDP_SERVER_NAME_MAX || + strlen(record->hdr.service_name) + 1 != record->hdr.service_name_length) { + LOG_ERROR("Invalid server name!\n"); + ret = false; + } + } else { + LOG_ERROR("record is NULL!\n"); + ret = false; + } + + return ret; +} + esp_err_t esp_sdp_register_callback(esp_sdp_cb_t callback) { ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); @@ -85,9 +103,7 @@ esp_err_t esp_sdp_create_record(esp_bluetooth_sdp_record_t *record) { ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); - if (record == NULL || record->hdr.service_name_length > ESP_SDP_SERVER_NAME_MAX - || strlen(record->hdr.service_name)+1 != record->hdr.service_name_length) { - LOG_ERROR("Invalid server name!\n"); + if (!esp_sdp_record_integrity_check(record)) { return ESP_ERR_INVALID_ARG; } @@ -100,7 +116,7 @@ esp_err_t esp_sdp_create_record(esp_bluetooth_sdp_record_t *record) msg.act = BTC_SDP_ACT_CREATE_RECORD; memset(&arg, 0, sizeof(btc_sdp_args_t)); - arg.creat_record.record = (bluetooth_sdp_record *)record; + arg.create_record.record = (bluetooth_sdp_record *)record; /* Switch to BTC context */ stat = btc_transfer_context(&msg, &arg, sizeof(btc_sdp_args_t), diff --git a/components/bt/host/bluedroid/api/include/api/esp_bt_defs.h b/components/bt/host/bluedroid/api/include/api/esp_bt_defs.h index 182f87600d..bd2f6dc990 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_bt_defs.h +++ b/components/bt/host/bluedroid/api/include/api/esp_bt_defs.h @@ -110,6 +110,14 @@ typedef enum { ESP_BT_STATUS_HCI_CONN_TOUT_DUE_TO_MIC_FAILURE, ESP_BT_STATUS_HCI_CONN_FAILED_ESTABLISHMENT, ESP_BT_STATUS_HCI_MAC_CONNECTION_FAILED, + ESP_BT_STATUS_HCI_CCA_REJECTED, + ESP_BT_STATUS_HCI_TYPE0_SUBMAP_NOT_DEFINED, + ESP_BT_STATUS_HCI_UNKNOWN_ADV_ID, + ESP_BT_STATUS_HCI_LIMIT_REACHED, + ESP_BT_STATUS_HCI_OPT_CANCEL_BY_HOST, + ESP_BT_STATUS_HCI_PKT_TOO_LONG, + ESP_BT_STATUS_HCI_TOO_LATE, + ESP_BT_STATUS_HCI_TOO_EARLY, } esp_bt_status_t; @@ -137,6 +145,25 @@ typedef uint8_t esp_link_key[ESP_BT_OCTET16_LEN]; /* Link Key */ #define ESP_BLE_CONN_SUP_TOUT_MIN 0x000A /*!< relate to BTM_BLE_CONN_SUP_TOUT_MIN in stack/btm_ble_api.h */ #define ESP_BLE_CONN_SUP_TOUT_MAX 0x0C80 /*!< relate to ESP_BLE_CONN_SUP_TOUT_MAX in stack/btm_ble_api.h */ +#define ESP_BLE_PHY_1M_PREF_MASK (1 << 0) /*!< The Host prefers use the LE1M transmitter or receiver PHY */ +#define ESP_BLE_PHY_2M_PREF_MASK (1 << 1) /*!< The Host prefers use the LE2M transmitter or receiver PHY */ +#define ESP_BLE_PHY_CODED_PREF_MASK (1 << 2) /*!< The Host prefers use the LE CODED transmitter or receiver PHY */ +typedef uint8_t esp_ble_phy_mask_t; + +/** +* @brief create connection parameters +*/ +typedef struct { + uint16_t scan_interval; /*!< Initial scan interval, in units of 0.625ms, the range is 0x0004(2.5ms) to 0xFFFF(10.24s). */ + uint16_t scan_window; /*!< Initial scan window, in units of 0.625ms, the range is 0x0004(2.5ms) to 0xFFFF(10.24s). */ + uint16_t interval_min; /*!< Minimum connection interval, in units of 1.25ms, the range is 0x0006(7.5ms) to 0x0C80(4s). */ + uint16_t interval_max; /*!< Maximum connection interval, in units of 1.25ms, the range is 0x0006(7.5ms) to 0x0C80(4s). */ + uint16_t latency; /*!< Connection latency, the range is 0x0000(0) to 0x01F3(499). */ + uint16_t supervision_timeout; /*!< Connection supervision timeout, in units of 10ms, the range is from 0x000A(100ms) to 0x0C80(32s). */ + uint16_t min_ce_len; /*!< Minimum connection event length, in units of 0.625ms, setting to 0 for no preferred parameters. */ + uint16_t max_ce_len; /*!< Maximum connection event length, in units of 0.625ms, setting to 0 for no preferred parameters. */ +} esp_ble_conn_params_t; + /// Check the param is valid or not #define ESP_BLE_IS_VALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) ) @@ -201,6 +228,8 @@ typedef uint8_t esp_ble_key_mask_t; /* the key mask type */ #define ESP_BD_ADDR_STR "%02x:%02x:%02x:%02x:%02x:%02x" #define ESP_BD_ADDR_HEX(addr) addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] +#define ESP_BLE_ADV_NAME_LEN_MAX 29 + #ifdef __cplusplus } #endif diff --git a/components/bt/host/bluedroid/api/include/api/esp_bt_main.h b/components/bt/host/bluedroid/api/include/api/esp_bt_main.h index 409ee01fd4..7d6cda6c03 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_bt_main.h +++ b/components/bt/host/bluedroid/api/include/api/esp_bt_main.h @@ -69,6 +69,11 @@ esp_err_t esp_bluedroid_init(void); */ esp_err_t esp_bluedroid_deinit(void); +#if defined(CONFIG_EXAMPLE_CI_ID) && defined(CONFIG_EXAMPLE_CI_PIPELINE_ID) +// Only for internal used (CI example test) +char *esp_bluedroid_get_example_name(void); +#endif + #ifdef __cplusplus } #endif diff --git a/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h b/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h index 3731bdb1a4..5fd20de0a8 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h +++ b/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h @@ -229,6 +229,7 @@ typedef enum { ESP_GAP_BLE_ADD_DEV_TO_RESOLVING_LIST_COMPLETE_EVT, /*!< when add a device to the resolving list completes, the event comes*/ ESP_GAP_BLE_VENDOR_CMD_COMPLETE_EVT, /*!< When vendor hci command complete, the event comes */ ESP_GAP_BLE_SET_PRIVACY_MODE_COMPLETE_EVT, /*!< When set privacy mode complete, the event comes */ + ESP_GAP_BLE_SET_CSA_SUPPORT_COMPLETE_EVT, /*!< When set CSA support complete, the event comes */ ESP_GAP_BLE_EVT_MAX, /*!< when maximum advertising event complete, the event comes */ } esp_gap_ble_cb_event_t; @@ -1572,6 +1573,12 @@ typedef union { struct ble_set_privacy_mode_cmpl_evt_param { esp_bt_status_t status; /*!< Indicate privacy mode set operation success status */ } set_privacy_mode_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_PRIVACY_MODE_COMPLETE_EVT */ + /** + * @brief ESP_GAP_BLE_SET_CSA_SUPPORT_COMPLETE_EVT + */ + struct ble_set_csa_support_cmpl_evt_param { + esp_bt_status_t status; /*!< Indicate CSA support set operation success status */ + } set_csa_support_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_CSA_SUPPORT_COMPLETE_EVT */ } esp_ble_gap_cb_param_t; /** @@ -1709,13 +1716,13 @@ esp_err_t esp_ble_gap_set_pkt_data_len(esp_bd_addr_t remote_device, uint16_t tx_ * * @param[in] rand_addr: The address to be configured. Refer to the table below for possible address subtypes: * - * | address [47:46] | Address Type | - * |-----------------|--------------------------| - * | 0b00 | Non-Resolvable Private | - * | | Address | - * |-----------------|--------------------------| - * | 0b11 | Static Random Address | - * |-----------------|--------------------------| + * | address [47:46] | Address Type | Corresponding API | + * |-----------------|-----------------------------|----------------------------------------| + * | 0b00 | Non-Resolvable Private | esp_ble_gap_addr_create_nrpa | + * | | Address (NRPA) | | + * |-----------------|-----------------------------|----------------------------------------| + * | 0b11 | Static Random Address | esp_ble_gap_addr_create_static | + * |-----------------|-----------------------------|----------------------------------------| * * @return * - ESP_OK : success @@ -1724,6 +1731,22 @@ esp_err_t esp_ble_gap_set_pkt_data_len(esp_bd_addr_t remote_device, uint16_t tx_ */ esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr); +/** + * @brief Create a static device address + * @param[out] rand_addr: Pointer to the buffer where the static device address will be stored. + * @return - ESP_OK : Success + * - Other : Failed + */ +esp_err_t esp_ble_gap_addr_create_static(esp_bd_addr_t rand_addr); + +/** + * @brief Create a non-resolvable private address (NRPA) + * @param[out] rand_addr: Pointer to the buffer where the NRPA will be stored. + * @return - ESP_OK : Success + * - Other : Failed + */ +esp_err_t esp_ble_gap_addr_create_nrpa(esp_bd_addr_t rand_addr); + /** * @brief This function sets the length of time the Controller uses a Resolvable Private Address * before generating and starting to use a new resolvable private address. @@ -1772,7 +1795,6 @@ esp_err_t esp_ble_gap_add_device_to_resolving_list(esp_bd_addr_t peer_addr, uint */ esp_err_t esp_ble_gap_clear_rand_addr(void); - /** * @brief Enable/disable privacy (including address resolution) on the local device * @@ -1888,17 +1910,41 @@ esp_err_t esp_ble_gap_get_device_name(void); * */ esp_err_t esp_ble_gap_get_local_used_addr(esp_bd_addr_t local_used_addr, uint8_t * addr_type); + +/** + * @brief This function is called to get ADV data for a specific type. + * + * @note This is the recommended function to use for resolving ADV data by type. + * It improves upon the deprecated `esp_ble_resolve_adv_data` function by + * including an additional parameter to specify the length of the ADV data, + * thereby offering better safety and reliability. + * + * @param[in] adv_data - pointer of ADV data which to be resolved + * @param[in] adv_data_len - the length of ADV data which to be resolved. + * @param[in] type - finding ADV data type + * @param[out] length - return the length of ADV data not including type + * + * @return pointer of ADV data + * + */ +uint8_t *esp_ble_resolve_adv_data_by_type( uint8_t *adv_data, uint16_t adv_data_len, esp_ble_adv_data_type type, uint8_t *length); + /** * @brief This function is called to get ADV data for a specific type. * - * @param[in] adv_data - pointer of ADV data which to be resolved - * @param[in] type - finding ADV data type - * @param[out] length - return the length of ADV data not including type + * @note This function has been deprecated and will be removed in a future release. + * Please use `esp_ble_resolve_adv_data_by_type` instead, which provides + * better parameter validation and supports more accurate data resolution. + * + * @param[in] adv_data - pointer of ADV data which to be resolved + * @param[in] type - finding ADV data type + * @param[out] length - return the length of ADV data not including type * - * @return pointer of ADV data + * @return pointer of ADV data * */ uint8_t *esp_ble_resolve_adv_data(uint8_t *adv_data, uint8_t type, uint8_t *length); + #if (BLE_42_FEATURE_SUPPORT == TRUE) /** * @brief This function is called to set raw advertising data. User need to fill @@ -2087,7 +2133,6 @@ esp_err_t esp_ble_remove_bond_device(esp_bd_addr_t bd_addr); */ int esp_ble_get_bond_device_num(void); - /** * @brief Get the device from the security database list of peer device. * It will return the device bonded information immediately. @@ -2706,6 +2751,23 @@ esp_err_t esp_ble_gap_vendor_command_send(esp_ble_vendor_cmd_params_t *vendor_cm */ esp_err_t esp_ble_gap_set_privacy_mode(esp_ble_addr_type_t addr_type, esp_bd_addr_t addr, esp_ble_privacy_mode_t mode); +/** + * @brief This function is used to set which channel selection algorithm(CSA) is supported. + * + * @note - This function should only be used when there are BLE compatibility issues about channel hopping after connected. + * For example, if the peer device only supports CSA#1, this function can be called to make the Controller use CSA#1. + * - This function is not supported on ESP32. + * + * @param[in] csa_select: 0: Channel Selection Algorighm will be selected by Controller + * 1: Select the LE Channel Selection Algorighm #1 + * 2: Select the LE Channel Selection Algorighm #2 + * + * @return + * - ESP_OK : success + * - other : failed + */ +esp_err_t esp_ble_gap_set_csa_support(uint8_t csa_select); + #ifdef __cplusplus } #endif diff --git a/components/bt/host/bluedroid/api/include/api/esp_gap_bt_api.h b/components/bt/host/bluedroid/api/include/api/esp_gap_bt_api.h index dd5c6bf456..2ca2bca5af 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_gap_bt_api.h +++ b/components/bt/host/bluedroid/api/include/api/esp_gap_bt_api.h @@ -33,8 +33,9 @@ typedef enum { ESP_BT_SET_COD_MAJOR_MINOR = 0x01, /*!< overwrite major, minor class */ ESP_BT_SET_COD_SERVICE_CLASS = 0x02, /*!< set the bits in the input, the current bit will remain */ ESP_BT_CLR_COD_SERVICE_CLASS = 0x04, /*!< clear the bits in the input, others will remain */ - ESP_BT_SET_COD_ALL = 0x08, /*!< overwrite major, minor, set the bits in service class */ - ESP_BT_INIT_COD = 0x0a, /*!< overwrite major, minor, and service class */ + ESP_BT_SET_COD_ALL = 0x08, /*!< overwrite major, minor, set the bits in service class, reserved_2 remain unchanged */ + ESP_BT_INIT_COD = 0x0a, /*!< overwrite major, minor, and service class, reserved_2 remain unchanged */ + ESP_BT_SET_COD_RESERVED_2 = 0x10, /*!< overwrite the two least significant bits reserved_2 whose default value is 0b00; other values of reserved_2 are invalid according to Bluetooth Core Specification 5.4 */ } esp_bt_cod_mode_t; #define ESP_BT_GAP_AFH_CHANNELS_LEN 10 @@ -205,6 +206,28 @@ typedef enum { ESP_BT_COD_MAJOR_DEV_UNCATEGORIZED = 31, /*!< Uncategorized: device not specified */ } esp_bt_cod_major_dev_t; +/// Minor device class field of Class of Device for Peripheral Major Class +typedef enum { + ESP_BT_COD_MINOR_PERIPHERAL_KEYBOARD = 0x10, /*!< Keyboard */ + ESP_BT_COD_MINOR_PERIPHERAL_POINTING = 0x20, /*!< Pointing */ + ESP_BT_COD_MINOR_PERIPHERAL_COMBO = 0x30, /*!< Combo + ESP_BT_COD_MINOR_PERIPHERAL_KEYBOARD, ESP_BT_COD_MINOR_PERIPHERAL_POINTING + and ESP_BT_COD_MINOR_PERIPHERAL_COMBO can be OR'd with one of the + following values to identify a multifunctional device. e.g. + ESP_BT_COD_MINOR_PERIPHERAL_KEYBOARD | ESP_BT_COD_MINOR_PERIPHERAL_GAMEPAD + ESP_BT_COD_MINOR_PERIPHERAL_POINTING | ESP_BT_COD_MINOR_PERIPHERAL_SENSING_DEVICE + */ + ESP_BT_COD_MINOR_PERIPHERAL_JOYSTICK = 0x01, /*!< Joystick */ + ESP_BT_COD_MINOR_PERIPHERAL_GAMEPAD = 0x02, /*!< Gamepad */ + ESP_BT_COD_MINOR_PERIPHERAL_REMOTE_CONTROL = 0x03, /*!< Remote Control */ + ESP_BT_COD_MINOR_PERIPHERAL_SENSING_DEVICE = 0x04, /*!< Sensing Device */ + ESP_BT_COD_MINOR_PERIPHERAL_DIGITIZING_TABLET = 0x05, /*!< Digitizing Tablet */ + ESP_BT_COD_MINOR_PERIPHERAL_CARD_READER = 0x06, /*!< Card Reader */ + ESP_BT_COD_MINOR_PERIPHERAL_DIGITAL_PAN = 0x07, /*!< Digital Pan */ + ESP_BT_COD_MINOR_PERIPHERAL_HAND_SCANNER = 0x08, /*!< Hand Scanner */ + ESP_BT_COD_MINOR_PERIPHERAL_HAND_GESTURAL_INPUT = 0x09, /*!< Hand Gestural Input */ +} esp_bt_cod_minor_peripheral_t; + /// Bits of major device class field #define ESP_BT_COD_MAJOR_DEV_BIT_MASK (0x1f00) /*!< Major device bit mask */ #define ESP_BT_COD_MAJOR_DEV_BIT_OFFSET (8) /*!< Major device bit offset */ @@ -383,8 +406,9 @@ typedef union { * @brief ESP_BT_GAP_MODE_CHG_EVT */ struct mode_chg_param { - esp_bd_addr_t bda; /*!< remote bluetooth device address*/ - esp_bt_pm_mode_t mode; /*!< PM mode*/ + esp_bd_addr_t bda; /*!< remote bluetooth device address */ + esp_bt_pm_mode_t mode; /*!< PM mode */ + uint16_t interval; /*!< Number of baseband slots. unit is 0.625ms */ } mode_chg; /*!< mode change event parameter struct */ /** diff --git a/components/bt/host/bluedroid/api/include/api/esp_gatt_defs.h b/components/bt/host/bluedroid/api/include/api/esp_gatt_defs.h index 77f03e8bf3..f6beb5eaae 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_gatt_defs.h +++ b/components/bt/host/bluedroid/api/include/api/esp_gatt_defs.h @@ -682,6 +682,19 @@ typedef struct { esp_bt_uuid_t uuid; /*!< Included service UUID. */ } esp_gattc_incl_svc_elem_t; +/** @brief Represents a creat connection element. */ +typedef struct { + esp_bd_addr_t remote_bda; /*!< The Bluetooth address of the remote device */ + esp_ble_addr_type_t remote_addr_type; /*!< Address type of the remote device */ + bool is_direct; /*!< Direct connection or background auto connection(by now, background auto connection is not supported */ + bool is_aux; /*!< Set to true for BLE 5.0 or higher to enable auxiliary connections; set to false for BLE 4.2 or lower. */ + esp_ble_addr_type_t own_addr_type; /*!< Specifies the address type used in the connection request. Set to 0xFF if the address type is unknown. */ + esp_ble_phy_mask_t phy_mask; /*!< Indicates which PHY connection parameters will be used. When is_aux is false, only the connection params for 1M PHY can be specified */ + const esp_ble_conn_params_t *phy_1m_conn_params; /*!< Connection parameters for the LE 1M PHY */ + const esp_ble_conn_params_t *phy_2m_conn_params; /*!< Connection parameters for the LE 2M PHY */ + const esp_ble_conn_params_t *phy_coded_conn_params; /*!< Connection parameters for the LE Coded PHY */ +} esp_ble_gatt_creat_conn_params_t; + #ifdef __cplusplus } #endif diff --git a/components/bt/host/bluedroid/api/include/api/esp_gattc_api.h b/components/bt/host/bluedroid/api/include/api/esp_gattc_api.h index 0c274e2032..0f5b83d351 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_gattc_api.h +++ b/components/bt/host/bluedroid/api/include/api/esp_gattc_api.h @@ -15,415 +15,463 @@ extern "C" { #endif -/// GATT Client callback function events +/** + * @brief GATT Client callback function events + */ typedef enum { - ESP_GATTC_REG_EVT = 0, /*!< When GATT client is registered, the event comes */ - ESP_GATTC_UNREG_EVT = 1, /*!< When GATT client is unregistered, the event comes */ - ESP_GATTC_OPEN_EVT = 2, /*!< When GATT virtual connection is set up, the event comes */ - ESP_GATTC_READ_CHAR_EVT = 3, /*!< When GATT characteristic is read, the event comes */ - ESP_GATTC_WRITE_CHAR_EVT = 4, /*!< When GATT characteristic write operation completes, the event comes */ - ESP_GATTC_CLOSE_EVT = 5, /*!< When GATT virtual connection is closed, the event comes */ - ESP_GATTC_SEARCH_CMPL_EVT = 6, /*!< When GATT service discovery is completed, the event comes */ - ESP_GATTC_SEARCH_RES_EVT = 7, /*!< When GATT service discovery result is got, the event comes */ - ESP_GATTC_READ_DESCR_EVT = 8, /*!< When GATT characteristic descriptor read completes, the event comes */ - ESP_GATTC_WRITE_DESCR_EVT = 9, /*!< When GATT characteristic descriptor write completes, the event comes */ - ESP_GATTC_NOTIFY_EVT = 10, /*!< When GATT notification or indication arrives, the event comes */ - ESP_GATTC_PREP_WRITE_EVT = 11, /*!< When GATT prepare-write operation completes, the event comes */ - ESP_GATTC_EXEC_EVT = 12, /*!< When write execution completes, the event comes */ - ESP_GATTC_ACL_EVT = 13, /*!< When ACL connection is up, the event comes */ - ESP_GATTC_CANCEL_OPEN_EVT = 14, /*!< When GATT client ongoing connection is cancelled, the event comes */ - ESP_GATTC_SRVC_CHG_EVT = 15, /*!< When "service changed" occurs, the event comes */ - ESP_GATTC_ENC_CMPL_CB_EVT = 17, /*!< When encryption procedure completes, the event comes */ - ESP_GATTC_CFG_MTU_EVT = 18, /*!< When configuration of MTU completes, the event comes */ - ESP_GATTC_ADV_DATA_EVT = 19, /*!< When advertising of data, the event comes */ - ESP_GATTC_MULT_ADV_ENB_EVT = 20, /*!< When multi-advertising is enabled, the event comes */ - ESP_GATTC_MULT_ADV_UPD_EVT = 21, /*!< When multi-advertising parameters are updated, the event comes */ - ESP_GATTC_MULT_ADV_DATA_EVT = 22, /*!< When multi-advertising data arrives, the event comes */ - ESP_GATTC_MULT_ADV_DIS_EVT = 23, /*!< When multi-advertising is disabled, the event comes */ - ESP_GATTC_CONGEST_EVT = 24, /*!< When GATT connection congestion comes, the event comes */ - ESP_GATTC_BTH_SCAN_ENB_EVT = 25, /*!< When batch scan is enabled, the event comes */ - ESP_GATTC_BTH_SCAN_CFG_EVT = 26, /*!< When batch scan storage is configured, the event comes */ - ESP_GATTC_BTH_SCAN_RD_EVT = 27, /*!< When Batch scan read event is reported, the event comes */ - ESP_GATTC_BTH_SCAN_THR_EVT = 28, /*!< When Batch scan threshold is set, the event comes */ - ESP_GATTC_BTH_SCAN_PARAM_EVT = 29, /*!< When Batch scan parameters are set, the event comes */ - ESP_GATTC_BTH_SCAN_DIS_EVT = 30, /*!< When Batch scan is disabled, the event comes */ - ESP_GATTC_SCAN_FLT_CFG_EVT = 31, /*!< When Scan filter configuration completes, the event comes */ - ESP_GATTC_SCAN_FLT_PARAM_EVT = 32, /*!< When Scan filter parameters are set, the event comes */ - ESP_GATTC_SCAN_FLT_STATUS_EVT = 33, /*!< When Scan filter status is reported, the event comes */ - ESP_GATTC_ADV_VSC_EVT = 34, /*!< When advertising vendor spec content event is reported, the event comes */ - ESP_GATTC_REG_FOR_NOTIFY_EVT = 38, /*!< When register for notification of a service completes, the event comes */ - ESP_GATTC_UNREG_FOR_NOTIFY_EVT = 39, /*!< When unregister for notification of a service completes, the event comes */ - ESP_GATTC_CONNECT_EVT = 40, /*!< When the ble physical connection is set up, the event comes */ - ESP_GATTC_DISCONNECT_EVT = 41, /*!< When the ble physical connection disconnected, the event comes */ - ESP_GATTC_READ_MULTIPLE_EVT = 42, /*!< When the ble characteristic or descriptor multiple complete, the event comes */ - ESP_GATTC_QUEUE_FULL_EVT = 43, /*!< When the gattc command queue full, the event comes */ - ESP_GATTC_SET_ASSOC_EVT = 44, /*!< When the ble gattc set the associated address complete, the event comes */ - ESP_GATTC_GET_ADDR_LIST_EVT = 45, /*!< When the ble get gattc address list in cache finish, the event comes */ - ESP_GATTC_DIS_SRVC_CMPL_EVT = 46, /*!< When the ble discover service complete, the event comes */ - ESP_GATTC_READ_MULTI_VAR_EVT = 47, /*!< When read multiple variable characteristic complete, the event comes */ + ESP_GATTC_REG_EVT = 0, /*!< This event is triggered when a GATT Client application is registered using `esp_ble_gattc_app_register`. */ + ESP_GATTC_UNREG_EVT = 1, /*!< This event is triggered when a GATT Client application is unregistered using `esp_ble_gattc_app_unregister`. */ + ESP_GATTC_OPEN_EVT = 2, /*!< This event is triggered when a GATT virtual connection is set up using `esp_ble_gattc_open`. */ + ESP_GATTC_READ_CHAR_EVT = 3, /*!< This event is triggered upon the completion of a GATT characteristic read operation using `esp_ble_gattc_read_char`. */ + ESP_GATTC_WRITE_CHAR_EVT = 4, /*!< This event is triggered upon the completion of a GATT characteristic write operation using `esp_ble_gattc_write_char`. */ + ESP_GATTC_CLOSE_EVT = 5, /*!< This event is triggered when a GATT virtual connection is closed via `esp_ble_gattc_close`, or when the physical connection is terminated. */ + ESP_GATTC_SEARCH_CMPL_EVT = 6, /*!< This event is triggered upon the completion of a service discovery using `esp_ble_gattc_search_service`. */ + ESP_GATTC_SEARCH_RES_EVT = 7, /*!< This event is triggered each time a service result is obtained using `esp_ble_gattc_search_service`. */ + ESP_GATTC_READ_DESCR_EVT = 8, /*!< This event is triggered upon the completion of a GATT characteristic descriptor read operation using `esp_ble_gattc_read_char_descr`. */ + ESP_GATTC_WRITE_DESCR_EVT = 9, /*!< This event is triggered upon the completion of a GATT characteristic descriptor write operation using `esp_ble_gattc_write_char_descr`. */ + ESP_GATTC_NOTIFY_EVT = 10, /*!< This event is triggered when a GATT notification or indication is received from the Server. */ + ESP_GATTC_PREP_WRITE_EVT = 11, /*!< This event is triggered upon the completion of a GATT prepare-write operation using `esp_ble_gattc_prepare_write`. */ + ESP_GATTC_EXEC_EVT = 12, /*!< This event is triggered upon the completion of a GATT write execution using `esp_ble_gattc_execute_write` .*/ + ESP_GATTC_ACL_EVT = 13, /*!< Deprecated. */ + ESP_GATTC_CANCEL_OPEN_EVT = 14, /*!< Deprecated. */ + ESP_GATTC_SRVC_CHG_EVT = 15, /*!< This event is triggered when a service changed indication is received from the Server, indicating that the attribute database on the Server has been modified (e.g., services have been added, removed). */ + ESP_GATTC_ENC_CMPL_CB_EVT = 17, /*!< Deprecated. */ + ESP_GATTC_CFG_MTU_EVT = 18, /*!< This event is triggered upon the completion of the MTU configuration with `esp_ble_gattc_send_mtu_req`. */ + ESP_GATTC_ADV_DATA_EVT = 19, /*!< Deprecated. */ + ESP_GATTC_MULT_ADV_ENB_EVT = 20, /*!< Deprecated. */ + ESP_GATTC_MULT_ADV_UPD_EVT = 21, /*!< Deprecated. */ + ESP_GATTC_MULT_ADV_DATA_EVT = 22, /*!< Deprecated. */ + ESP_GATTC_MULT_ADV_DIS_EVT = 23, /*!< Deprecated. */ + ESP_GATTC_CONGEST_EVT = 24, /*!< This event is triggered when the GATT connection is congested. */ + ESP_GATTC_BTH_SCAN_ENB_EVT = 25, /*!< Deprecated. */ + ESP_GATTC_BTH_SCAN_CFG_EVT = 26, /*!< Deprecated. */ + ESP_GATTC_BTH_SCAN_RD_EVT = 27, /*!< Deprecated. */ + ESP_GATTC_BTH_SCAN_THR_EVT = 28, /*!< Deprecated. */ + ESP_GATTC_BTH_SCAN_PARAM_EVT = 29, /*!< Deprecated. */ + ESP_GATTC_BTH_SCAN_DIS_EVT = 30, /*!< Deprecated. */ + ESP_GATTC_SCAN_FLT_CFG_EVT = 31, /*!< Deprecated. */ + ESP_GATTC_SCAN_FLT_PARAM_EVT = 32, /*!< Deprecated. */ + ESP_GATTC_SCAN_FLT_STATUS_EVT = 33, /*!< Deprecated. */ + ESP_GATTC_ADV_VSC_EVT = 34, /*!< Deprecated. */ + ESP_GATTC_REG_FOR_NOTIFY_EVT = 38, /*!< This event is triggered upon the completion of a service notification registration using `esp_ble_gattc_register_for_notify`. */ + ESP_GATTC_UNREG_FOR_NOTIFY_EVT = 39, /*!< This event is triggered upon the completion of a service notification unregistration using `esp_ble_gattc_unregister_for_notify`. */ + ESP_GATTC_CONNECT_EVT = 40, /*!< This event is triggered when the physical connection is set up. */ + ESP_GATTC_DISCONNECT_EVT = 41, /*!< This event is triggered when the physical connection is terminated. */ + ESP_GATTC_READ_MULTIPLE_EVT = 42, /*!< This event is triggered when the multiple characteristic or descriptor values are retrieved using `esp_ble_gattc_read_multiple`. */ + ESP_GATTC_QUEUE_FULL_EVT = 43, /*!< This event is triggered when the GATTC command queue is full. */ + ESP_GATTC_SET_ASSOC_EVT = 44, /*!< This event is triggered when the association between the source and the remote address is added or deleted using `esp_ble_gattc_cache_assoc`. */ + ESP_GATTC_GET_ADDR_LIST_EVT = 45, /*!< This event is triggered when retrieving the address list from the GATTC cache is completed using `esp_ble_gattc_cache_get_addr_list`. */ + ESP_GATTC_DIS_SRVC_CMPL_EVT = 46, /*!< This event is triggered when the GATT service discovery is completed. */ + ESP_GATTC_READ_MULTI_VAR_EVT = 47, /*!< This event is triggered when multiple variable length characteristic values are retrieved using `esp_ble_gattc_read_multiple`. */ } esp_gattc_cb_event_t; /** - * @brief Gatt client callback parameters union + * @brief GATT Client callback parameters */ typedef union { + /** - * @brief ESP_GATTC_REG_EVT + * @brief Callback parameter for the event `ESP_GATTC_REG_EVT` */ struct gattc_reg_evt_param { esp_gatt_status_t status; /*!< Operation status */ - uint16_t app_id; /*!< Application id which input in register API */ - } reg; /*!< Gatt client callback param of ESP_GATTC_REG_EVT */ + uint16_t app_id; /*!< Application ID */ + } reg; /*!< Callback parameter for the event `ESP_GATTC_REG_EVT` */ /** - * @brief ESP_GATTC_OPEN_EVT + * @brief Callback parameter for the event `ESP_GATTC_OPEN_EVT`. */ struct gattc_open_evt_param { esp_gatt_status_t status; /*!< Operation status */ - uint16_t conn_id; /*!< Connection id */ - esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */ + uint16_t conn_id; /*!< Connection ID */ + esp_bd_addr_t remote_bda; /*!< Remote Bluetooth device address */ uint16_t mtu; /*!< MTU size */ - } open; /*!< Gatt client callback param of ESP_GATTC_OPEN_EVT */ + } open; /*!< Callback parameter for the event `ESP_GATTC_OPEN_EVT` */ /** - * @brief ESP_GATTC_CLOSE_EVT + * @brief Callback parameter for the event `ESP_GATTC_CLOSE_EVT` */ struct gattc_close_evt_param { esp_gatt_status_t status; /*!< Operation status */ - uint16_t conn_id; /*!< Connection id */ + uint16_t conn_id; /*!< Connection ID */ esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */ - esp_gatt_conn_reason_t reason; /*!< The reason of gatt connection close */ - } close; /*!< Gatt client callback param of ESP_GATTC_CLOSE_EVT */ + esp_gatt_conn_reason_t reason; /*!< The reason of GATT connection close */ + } close; /*!< Callback parameter for the event `ESP_GATTC_CLOSE_EVT` */ /** - * @brief ESP_GATTC_CFG_MTU_EVT + * @brief Callback parameter for the event `ESP_GATTC_CFG_MTU_EVT` */ struct gattc_cfg_mtu_evt_param { esp_gatt_status_t status; /*!< Operation status */ - uint16_t conn_id; /*!< Connection id */ + uint16_t conn_id; /*!< Connection ID */ uint16_t mtu; /*!< MTU size */ - } cfg_mtu; /*!< Gatt client callback param of ESP_GATTC_CFG_MTU_EVT */ + } cfg_mtu; /*!< Callback parameter for the event `ESP_GATTC_CFG_MTU_EVT` */ /** - * @brief ESP_GATTC_SEARCH_CMPL_EVT + * @brief Callback parameter for the event `ESP_GATTC_SEARCH_CMPL_EVT` */ struct gattc_search_cmpl_evt_param { esp_gatt_status_t status; /*!< Operation status */ - uint16_t conn_id; /*!< Connection id */ + uint16_t conn_id; /*!< Connection ID */ esp_service_source_t searched_service_source; /*!< The source of the service information */ - } search_cmpl; /*!< Gatt client callback param of ESP_GATTC_SEARCH_CMPL_EVT */ + } search_cmpl; /*!< Callback parameter for the event `ESP_GATTC_SEARCH_CMPL_EVT` */ /** - * @brief ESP_GATTC_SEARCH_RES_EVT + * @brief Callback parameter for the event `ESP_GATTC_SEARCH_RES_EVT` */ struct gattc_search_res_evt_param { - uint16_t conn_id; /*!< Connection id */ + uint16_t conn_id; /*!< Connection ID */ uint16_t start_handle; /*!< Service start handle */ uint16_t end_handle; /*!< Service end handle */ - esp_gatt_id_t srvc_id; /*!< Service id, include service uuid and other information */ - bool is_primary; /*!< True if this is the primary service */ - } search_res; /*!< Gatt client callback param of ESP_GATTC_SEARCH_RES_EVT */ + esp_gatt_id_t srvc_id; /*!< Service ID, including service UUID and other information */ + bool is_primary; /*!< True indicates a primary service, false otherwise */ + } search_res; /*!< Callback parameter for the event `ESP_GATTC_SEARCH_RES_EVT` */ /** - * @brief ESP_GATTC_READ_CHAR_EVT, ESP_GATTC_READ_DESCR_EVT, ESP_GATTC_READ_MULTIPLE_EVT, ESP_GATTC_READ_MULTI_VAR_EVT + * @brief Callback parameter for the events: `ESP_GATTC_READ_CHAR_EVT`, `ESP_GATTC_READ_DESCR_EVT`, + * `ESP_GATTC_READ_MULTIPLE_EVT`, `ESP_GATTC_READ_MULTI_VAR_EVT` */ struct gattc_read_char_evt_param { esp_gatt_status_t status; /*!< Operation status */ - uint16_t conn_id; /*!< Connection id */ + uint16_t conn_id; /*!< Connection ID */ uint16_t handle; /*!< Characteristic handle */ uint8_t *value; /*!< Characteristic value */ uint16_t value_len; /*!< Characteristic value length */ - } read; /*!< Gatt client callback param of ESP_GATTC_READ_CHAR_EVT */ + } read; /*!< Callback parameter for events: `ESP_GATTC_READ_CHAR_EVT`, `ESP_GATTC_READ_DESCR_EVT`, + `ESP_GATTC_READ_MULTIPLE_EVT`, `ESP_GATTC_READ_MULTI_VAR_EVT` */ /** - * @brief ESP_GATTC_WRITE_CHAR_EVT, ESP_GATTC_PREP_WRITE_EVT, ESP_GATTC_WRITE_DESCR_EVT + * @brief Callback parameter for the events: `ESP_GATTC_WRITE_CHAR_EVT`, `ESP_GATTC_PREP_WRITE_EVT`, `ESP_GATTC_WRITE_DESCR_EVT`. */ struct gattc_write_evt_param { esp_gatt_status_t status; /*!< Operation status */ - uint16_t conn_id; /*!< Connection id */ - uint16_t handle; /*!< The Characteristic or descriptor handle */ - uint16_t offset; /*!< The prepare write offset, this value is valid only when prepare write */ - } write; /*!< Gatt client callback param of ESP_GATTC_WRITE_DESCR_EVT */ + uint16_t conn_id; /*!< Connection ID */ + uint16_t handle; /*!< The characteristic or descriptor handle */ + uint16_t offset; /*!< The position offset to write. This value is valid only for prepare write operation. */ + } write; /*!< Callback parameter for the events: `ESP_GATTC_WRITE_CHAR_EVT`, `ESP_GATTC_PREP_WRITE_EVT`, `ESP_GATTC_WRITE_DESCR_EVT` */ /** - * @brief ESP_GATTC_EXEC_EVT + * @brief Callback parameter for the event `ESP_GATTC_EXEC_EVT` */ struct gattc_exec_cmpl_evt_param { esp_gatt_status_t status; /*!< Operation status */ - uint16_t conn_id; /*!< Connection id */ - } exec_cmpl; /*!< Gatt client callback param of ESP_GATTC_EXEC_EVT */ + uint16_t conn_id; /*!< Connection ID */ + } exec_cmpl; /*!< Callback parameter for the event `ESP_GATTC_EXEC_EVT` */ /** - * @brief ESP_GATTC_NOTIFY_EVT + * @brief Callback parameter for the event `ESP_GATTC_NOTIFY_EVT` */ struct gattc_notify_evt_param { - uint16_t conn_id; /*!< Connection id */ - esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */ - uint16_t handle; /*!< The Characteristic or descriptor handle */ - uint16_t value_len; /*!< Notify attribute value */ + uint16_t conn_id; /*!< Connection ID */ + esp_bd_addr_t remote_bda; /*!< Remote Bluetooth device address. */ + uint16_t handle; /*!< The characteristic or descriptor handle */ + uint16_t value_len; /*!< Notify attribute value length in bytes */ uint8_t *value; /*!< Notify attribute value */ - bool is_notify; /*!< True means notify, false means indicate */ - } notify; /*!< Gatt client callback param of ESP_GATTC_NOTIFY_EVT */ + bool is_notify; /*!< True means notification; false means indication */ + } notify; /*!< Callback parameter for the event `ESP_GATTC_NOTIFY_EVT` */ /** - * @brief ESP_GATTC_SRVC_CHG_EVT + * @brief Callback parameter for the event `ESP_GATTC_SRVC_CHG_EVT` */ struct gattc_srvc_chg_evt_param { - esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */ - } srvc_chg; /*!< Gatt client callback param of ESP_GATTC_SRVC_CHG_EVT */ + esp_bd_addr_t remote_bda; /*!< Remote Bluetooth device address */ + } srvc_chg; /*!< Callback parameter for the event `ESP_GATTC_SRVC_CHG_EVT` */ /** - * @brief ESP_GATTC_CONGEST_EVT + * @brief Callback parameter for the event `ESP_GATTC_CONGEST_EVT` */ struct gattc_congest_evt_param { - uint16_t conn_id; /*!< Connection id */ - bool congested; /*!< Congested or not */ - } congest; /*!< Gatt client callback param of ESP_GATTC_CONGEST_EVT */ + uint16_t conn_id; /*!< Connection ID */ + bool congested; /*!< True indicates that the connection is congested, false otherwise */ + } congest; /*!< Callback parameter for the event `ESP_GATTC_CONGEST_EVT` */ /** - * @brief ESP_GATTC_REG_FOR_NOTIFY_EVT + * @brief Callback parameter for the event `ESP_GATTC_REG_FOR_NOTIFY_EVT` */ struct gattc_reg_for_notify_evt_param { esp_gatt_status_t status; /*!< Operation status */ uint16_t handle; /*!< The characteristic or descriptor handle */ - } reg_for_notify; /*!< Gatt client callback param of ESP_GATTC_REG_FOR_NOTIFY_EVT */ + } reg_for_notify; /*!< Callback parameter for the event `ESP_GATTC_REG_FOR_NOTIFY_EVT` */ /** - * @brief ESP_GATTC_UNREG_FOR_NOTIFY_EVT + * @brief Callback parameter for the event `ESP_GATTC_UNREG_FOR_NOTIFY_EVT` */ struct gattc_unreg_for_notify_evt_param { esp_gatt_status_t status; /*!< Operation status */ uint16_t handle; /*!< The characteristic or descriptor handle */ - } unreg_for_notify; /*!< Gatt client callback param of ESP_GATTC_UNREG_FOR_NOTIFY_EVT */ + } unreg_for_notify; /*!< Callback parameter for the event `ESP_GATTC_UNREG_FOR_NOTIFY_EVT` */ /** - * @brief ESP_GATTC_CONNECT_EVT + * @brief Callback parameter for the event `ESP_GATTC_CONNECT_EVT` */ struct gattc_connect_evt_param { - uint16_t conn_id; /*!< Connection id */ - uint8_t link_role; /*!< Link role : master role = 0 ; slave role = 1*/ - esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */ - esp_gatt_conn_params_t conn_params; /*!< current connection parameters */ - esp_ble_addr_type_t ble_addr_type; /*!< Remote BLE device address type */ - uint16_t conn_handle; /*!< HCI connection handle */ - } connect; /*!< Gatt client callback param of ESP_GATTC_CONNECT_EVT */ + uint16_t conn_id; /*!< Connection ID */ + uint8_t link_role; /*!< Link role : master role = 0; slave role = 1 */ + esp_bd_addr_t remote_bda; /*!< Remote device address */ + esp_gatt_conn_params_t conn_params; /*!< Current connection parameters */ + esp_ble_addr_type_t ble_addr_type; /*!< Remote device address type */ + uint16_t conn_handle; /*!< HCI connection handle */ + } connect; /*!< Callback parameter for the event `ESP_GATTC_CONNECT_EVT` */ /** - * @brief ESP_GATTC_DISCONNECT_EVT + * @brief Callback parameter for the event `ESP_GATTC_DISCONNECT_EVT` */ struct gattc_disconnect_evt_param { - esp_gatt_conn_reason_t reason; /*!< disconnection reason */ - uint16_t conn_id; /*!< Connection id */ - esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */ - } disconnect; /*!< Gatt client callback param of ESP_GATTC_DISCONNECT_EVT */ + esp_gatt_conn_reason_t reason; /*!< Disconnection reason */ + uint16_t conn_id; /*!< Connection ID */ + esp_bd_addr_t remote_bda; /*!< Remote device address */ + } disconnect; /*!< Callback parameter for the event `ESP_GATTC_DISCONNECT_EVT` */ + /** - * @brief ESP_GATTC_SET_ASSOC_EVT + * @brief Callback parameter for the event `ESP_GATTC_SET_ASSOC_EVT` */ struct gattc_set_assoc_addr_cmp_evt_param { - esp_gatt_status_t status; /*!< Operation status */ - } set_assoc_cmp; /*!< Gatt client callback param of ESP_GATTC_SET_ASSOC_EVT */ + esp_gatt_status_t status; /*!< Operation status */ + } set_assoc_cmp; /*!< Callback parameter for the event `ESP_GATTC_SET_ASSOC_EVT` */ + /** - * @brief ESP_GATTC_GET_ADDR_LIST_EVT + * @brief Callback parameter for the event `ESP_GATTC_GET_ADDR_LIST_EVT` */ struct gattc_get_addr_list_evt_param { esp_gatt_status_t status; /*!< Operation status */ - uint8_t num_addr; /*!< The number of address in the gattc cache address list */ - esp_bd_addr_t *addr_list; /*!< The pointer to the address list which has been get from the gattc cache */ - } get_addr_list; /*!< Gatt client callback param of ESP_GATTC_GET_ADDR_LIST_EVT */ + uint8_t num_addr; /*!< The number of addresses in the local GATTC cache address list */ + esp_bd_addr_t *addr_list; /*!< The pointer to the address list which has been retrieved from the local GATTC cache */ + } get_addr_list; /*!< Callback parameter for the event `ESP_GATTC_GET_ADDR_LIST_EVT` */ /** - * @brief ESP_GATTC_QUEUE_FULL_EVT + * @brief Callback parameter for the event `ESP_GATTC_QUEUE_FULL_EVT` */ struct gattc_queue_full_evt_param { esp_gatt_status_t status; /*!< Operation status */ - uint16_t conn_id; /*!< Connection id */ - bool is_full; /*!< The gattc command queue is full or not */ - } queue_full; /*!< Gatt client callback param of ESP_GATTC_QUEUE_FULL_EVT */ + uint16_t conn_id; /*!< Connection ID */ + bool is_full; /*!< True indicates the GATTC command queue is full; false otherwise. */ + } queue_full; /*!< Callback parameter for the event `ESP_GATTC_QUEUE_FULL_EVT` */ /** - * @brief ESP_GATTC_DIS_SRVC_CMPL_EVT + * @brief Callback parameter for the event `ESP_GATTC_DIS_SRVC_CMPL_EVT` */ struct gattc_dis_srvc_cmpl_evt_param { esp_gatt_status_t status; /*!< Operation status */ - uint16_t conn_id; /*!< Connection id */ - } dis_srvc_cmpl; /*!< Gatt client callback param of ESP_GATTC_DIS_SRVC_CMPL_EVT */ + uint16_t conn_id; /*!< Connection ID */ + } dis_srvc_cmpl; /*!< Callback parameter for the event `ESP_GATTC_DIS_SRVC_CMPL_EVT` */ -} esp_ble_gattc_cb_param_t; /*!< GATT client callback parameter union type */ +} esp_ble_gattc_cb_param_t; /** * @brief GATT Client callback function type - * @param event : Event type - * @param gattc_if : GATT client access interface, normally - * different gattc_if correspond to different profile - * @param param : Point to callback parameter, currently is union type + * + * @param[in] event Event type + * @param[in] gattc_if GATT Client access interface + * @param[in] param The pointer to callback parameter */ typedef void (* esp_gattc_cb_t)(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param); /** - * @brief This function is called to register application callbacks - * with GATTC module. + * @brief Register GATT Client application callbacks * - * @param[in] callback : pointer to the application callback function. + * @param[in] callback The pointer to the application callback function * * @return - * - ESP_OK: success - * - other: failed - * + * - ESP_OK: Success + * - ESP_FAIL: Failure */ esp_err_t esp_ble_gattc_register_callback(esp_gattc_cb_t callback); /** - * @brief This function is called to get the current application callbacks - * with BTA GATTC module. + * @brief Get the current application callbacks * * @return - * - esp_gattC_cb_t : current callback - * + * - esp_gattc_cb_t: Current callback */ esp_gattc_cb_t esp_ble_gattc_get_callback(void); /** - * @brief This function is called to register application callbacks - * with GATTC module. + * @brief Register a GATT Client application * - * @param[in] app_id : Application Identify (UUID), for different application + * @param[in] app_id The UUID for different application * - * @return - * - ESP_OK: success - * - other: failed + * @note + * 1. This function triggers `ESP_GATTC_REG_EVT`. + * 2. The maximum number of applications is limited to 4. * + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_ARG: The input `app_id` exceeds `ESP_APP_ID_MAX` (0x7fff) defined in esp_bt_defs.h + * - ESP_FAIL: Failure due to other reasons */ esp_err_t esp_ble_gattc_app_register(uint16_t app_id); - /** - * @brief This function is called to unregister an application - * from the GATTC module. + * @brief Unregister a GATT Client application * - * @param[in] gattc_if: Gatt client access interface. + * @param[in] gattc_if GATT Client access interface * - * @note Before calling this API, ensure that all activities - * related to the application, such as connections, scans, ADV, - * are properly closed. + * @note This function triggers `ESP_GATTC_UNREG_EVT`. * * @return - * - ESP_OK: success - * - other: failed - * + * - ESP_OK: Success + * - ESP_FAIL: Failure */ esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gattc_if); -#if (BLE_42_FEATURE_SUPPORT == TRUE) /** - * @brief Open a direct connection or add a background auto connection + * @brief Create an ACL connection + * + * @note + * 1. Do not enable `BT_BLE_42_FEATURES_SUPPORTED` and `BT_BLE_50_FEATURES_SUPPORTED` in the menuconfig simultaneously. + * 1. The function always triggers `ESP_GATTC_CONNECT_EVT` and `ESP_GATTC_OPEN_EVT`. + * 2. When the device acts as GATT server, besides the above two events, this function triggers `ESP_GATTS_CONNECT_EVT` as well. + * 3. This function will establish an ACL connection as a Central and a virtual connection as a GATT Client. If the ACL connection already exists, it will create a virtual connection only. + * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] remote_bda: remote device bluetooth device address. - * @param[in] remote_addr_type: remote device bluetooth device the address type. - * @param[in] is_direct: direct connection or background auto connection(by now, background auto connection is not supported). + * @param[in] gattc_if: GATT client access interface. + * @param[in] esp_gatt_create_conn: Pointer to the structure containing connection parameters. * * @return - * - ESP_OK: success - * - other: failed + * - ESP_OK: Success + * - others: Operation failed + * + */ +esp_err_t esp_ble_gattc_enh_open(esp_gatt_if_t gattc_if, esp_ble_gatt_creat_conn_params_t *esp_gatt_create_conn); + +/** + * @brief Create an ACL connection when `BT_BLE_42_FEATURES_SUPPORTED` is enabled in the menuconfig + * + * @param[in] gattc_if GATT Client access interface + * @param[in] remote_bda Remote device address + * @param[in] remote_addr_type Remote device address type + * @param[in] is_direct `True` indicates a direct connection, while `False` indicates a background auto connection. By now, background auto connection is not supported, please always pass True to this parameter. + * + * @note + * 1. The function always triggers `ESP_GATTC_CONNECT_EVT` and `ESP_GATTC_OPEN_EVT`. + * 2. When the device acts as GATT server, besides the above two events, this function triggers `ESP_GATTS_CONNECT_EVT` as well. + * 3. This function will establish an ACL connection as a Central and a virtual connection as a GATT Client. If the ACL connection already exists, it will create a virtual connection only. * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure */ +#if (BLE_42_FEATURE_SUPPORT == TRUE) esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, esp_ble_addr_type_t remote_addr_type, bool is_direct); #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) +/** + * @brief Create an ACL connection when `BT_BLE_50_FEATURES_SUPPORTED` is enabled in the menuconfig + * + * @param[in] gattc_if GATT Client access interface + * @param[in] remote_bda Remote device address + * @param[in] remote_addr_type Remote device address type + * @param[in] is_direct `True` indicates a direct connection, while `False` indicates a background auto connection. By now, background auto connection is not supported, please always pass True to this parameter. + * + * @note + * 1. The function always triggers `ESP_GATTC_CONNECT_EVT` and `ESP_GATTC_OPEN_EVT`. + * 2. When the device acts as GATT server, besides the above two events, this function triggers `ESP_GATTS_CONNECT_EVT` as well. + * 3. This function will establish an ACL connection as a Central and a virtual connection as a GATT Client. If the ACL connection already exists, it will create a virtual connection only. + * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure + */ #if (BLE_50_FEATURE_SUPPORT == TRUE) esp_err_t esp_ble_gattc_aux_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, esp_ble_addr_type_t remote_addr_type, bool is_direct); #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) + /** - * @brief Close the virtual connection to the GATT server. gattc may have multiple virtual GATT server connections when multiple app_id registered, - * this API only close one virtual GATT server connection. if there exist other virtual GATT server connections, - * it does not disconnect the physical connection. - * if you want to disconnect the physical connection directly, you can use esp_ble_gap_disconnect(esp_bd_addr_t remote_device). + * @brief Close the virtual GATT Client connection * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] conn_id: connection ID to be closed. + * @param[in] gattc_if GATT Client access interface + * @param[in] conn_id Connection ID to be closed * - * @return - * - ESP_OK: success - * - other: failed + * @note + * 1. This function triggers `ESP_GATTC_CLOSE_EVT`. + * 2. There may be multiple virtual GATT server connections when multiple `app_id` got registered. + * 3. This API closes one virtual GATT server connection only, if there exist other virtual GATT server connections. It does not close the physical connection. + * 4. The API `esp_ble_gap_disconnect` can be used to disconnect the physical connection directly. + * 5. If there is only one virtual GATT connection left, this API will terminate the ACL connection in addition and triggers `ESP_GATTC_DISCONNECT_EVT`. Then there is no need to call `esp_ble_gap_disconnect` anymore. * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure */ -esp_err_t esp_ble_gattc_close (esp_gatt_if_t gattc_if, uint16_t conn_id); - +esp_err_t esp_ble_gattc_close(esp_gatt_if_t gattc_if, uint16_t conn_id); /** - * @brief Configure the MTU size in the GATT channel. This can be done - * only once per connection. Before using, use esp_ble_gatt_set_local_mtu() - * to configure the local MTU size. + * @brief Configure the MTU size in the GATT channel * * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] conn_id: connection ID. + * @param[in] gattc_if GATT Client access interface + * @param[in] conn_id Connection ID * - * @return - * - ESP_OK: success - * - other: failed + * @note + * 1. This function triggers `ESP_GATTC_CFG_MTU_EVT`. + * 2. You could call `esp_ble_gatt_set_local_mtu` to set the desired MTU size locally before this API. If not set, the GATT channel uses the default MTU size (23 bytes). * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure */ esp_err_t esp_ble_gattc_send_mtu_req (esp_gatt_if_t gattc_if, uint16_t conn_id); - /** - * @brief This function is called to get service from local cache. - * This function report service search result by a callback - * event, and followed by a service search complete event. - * Note: 128-bit base UUID will automatically be converted to a 16-bit UUID in the search results. Other types of UUID remain unchanged. + * @brief Search services from the local GATTC cache * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] conn_id: connection ID. - * @param[in] filter_uuid: a UUID of the service application is interested in. - * If Null, discover for all services. + * @param[in] gattc_if GATT Client access interface + * @param[in] conn_id Connection ID + * @param[in] filter_uuid A UUID of the intended service. If NULL is passed, this API will return all services. * - * @return - * - ESP_OK: success - * - other: failed + * @note + * 1. This function triggers `ESP_GATTC_SEARCH_RES_EVT` each time a service is retrieved. + * 2. This function triggers `ESP_GATTC_SEARCH_CMPL_EVT` when the search is completed. + * 3. The 128-bit base UUID will be converted to a 16-bit UUID automatically in the search results. Other types of UUID remain unchanged. * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure */ esp_err_t esp_ble_gattc_search_service(esp_gatt_if_t gattc_if, uint16_t conn_id, esp_bt_uuid_t *filter_uuid); /** - * @brief Find all the service with the given service uuid in the gattc cache, if the svc_uuid is NULL, find all the service. - * Note: It just get service from local cache, won't get from remote devices. If want to get it from remote device, need - * to used the esp_ble_gattc_cache_refresh, then call esp_ble_gattc_get_service again. + * @brief Get the service with the given service UUID in the local GATTC cache * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] conn_id: connection ID which identify the server. - * @param[in] svc_uuid: the pointer to the service uuid. - * @param[out] result: The pointer to the service which has been found in the gattc cache. - * @param[inout] count: input the number of service want to find, - * it will output the number of service has been found in the gattc cache with the given service uuid. - * @param[in] offset: Offset of the service position to get. + * @param[in] gattc_if GATT Client access interface + * @param[in] conn_id Connection ID + * @param[in] svc_uuid The pointer to the service UUID. If NULL is passed, the API will retrieve all services. + * @param[out] result The pointer to the service which has been found in the local GATTC cache + * @param[inout] count The number of services to retrieve. It will be updated with the actual number of services found. + * @param[in] offset The position offset to retrieve * - * @return - * - ESP_OK: success - * - other: failed + * @note + * 1. This API does not trigger any event. + * 2. `esp_ble_gattc_cache_refresh` can be used to discover services again. * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure */ esp_gatt_status_t esp_ble_gattc_get_service(esp_gatt_if_t gattc_if, uint16_t conn_id, esp_bt_uuid_t *svc_uuid, esp_gattc_service_elem_t *result, uint16_t *count, uint16_t offset); /** - * @brief Find all the characteristic with the given service in the gattc cache - * Note: It just get characteristic from local cache, won't get from remote devices. + * @brief Get all characteristics with the given handle range in the local GATTC cache * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] conn_id: connection ID which identify the server. - * @param[in] start_handle: the attribute start handle. - * @param[in] end_handle: the attribute end handle - * @param[out] result: The pointer to the characteristic in the service. - * @param[inout] count: input the number of characteristic want to find, - * it will output the number of characteristic has been found in the gattc cache with the given service. - * @param[in] offset: Offset of the characteristic position to get. + * @param[in] gattc_if GATT Client access interface + * @param[in] conn_id Connection ID + * @param[in] start_handle The attribute start handle + * @param[in] end_handle The attribute end handle + * @param[out] result The pointer to the characteristic in the service + * @param[inout] count The number of characteristics to retrieve. It will be updated with the actual number of characteristics found. + * @param[in] offset The position offset to retrieve * - * @return - * - ESP_OK: success - * - other: failed + * @note + * 1. This API does not trigger any event. + * 2. `start_handle` must be greater than 0, and smaller than `end_handle`. * + * @return + * - ESP_OK: Success + * - ESP_GATT_INVALID_HANDLE: Invalid GATT `start_handle` or `end_handle` + * - ESP_GATT_INVALID_PDU: NULL pointer to `result` or NULL pointer to `count` or the count value is 0 + * - ESP_FAIL: Failure due to other reasons */ esp_gatt_status_t esp_ble_gattc_get_all_char(esp_gatt_if_t gattc_if, uint16_t conn_id, @@ -433,21 +481,24 @@ esp_gatt_status_t esp_ble_gattc_get_all_char(esp_gatt_if_t gattc_if, uint16_t *count, uint16_t offset); /** - * @brief Find all the descriptor with the given characteristic in the gattc cache - * Note: It just get descriptor from local cache, won't get from remote devices. + * @brief Get all descriptors with the given characteristic in the local GATTC cache * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] conn_id: connection ID which identify the server. - * @param[in] char_handle: the given characteristic handle - * @param[out] result: The pointer to the descriptor in the characteristic. - * @param[inout] count: input the number of descriptor want to find, - * it will output the number of descriptor has been found in the gattc cache with the given characteristic. - * @param[in] offset: Offset of the descriptor position to get. + * @param[in] gattc_if GATT Client access interface + * @param[in] conn_id Connection ID which identifies the server + * @param[in] char_handle The given characteristic handle + * @param[out] result The pointer to the descriptor in the characteristic + * @param[inout] count The number of descriptors to retrieve. It will be updated with the actual number of descriptors found. + * @param[in] offset The position offset to retrieve * - * @return - * - ESP_OK: success - * - other: failed + * @note + * 1. This API does not trigger any event. + * 2. `char_handle` must be greater than 0. * + * @return + * - ESP_OK: Success + * - ESP_GATT_INVALID_HANDLE: Invalid GATT `char_handle` + * - ESP_GATT_INVALID_PDU: NULL pointer to `result` or NULL pointer to `count` or the count value is 0 + * - ESP_FAIL: Failure due to other reasons */ esp_gatt_status_t esp_ble_gattc_get_all_descr(esp_gatt_if_t gattc_if, uint16_t conn_id, @@ -455,24 +506,26 @@ esp_gatt_status_t esp_ble_gattc_get_all_descr(esp_gatt_if_t gattc_if, esp_gattc_descr_elem_t *result, uint16_t *count, uint16_t offset); - /** - * @brief Find the characteristic with the given characteristic uuid in the gattc cache - * Note: It just get characteristic from local cache, won't get from remote devices. + * @brief Get the characteristic with the given characteristic UUID in the local GATTC cache * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] conn_id: connection ID which identify the server. - * @param[in] start_handle: the attribute start handle - * @param[in] end_handle: the attribute end handle - * @param[in] char_uuid: the characteristic uuid - * @param[out] result: The pointer to the characteristic in the service. - * @param[inout] count: input the number of characteristic want to find, - * it will output the number of characteristic has been found in the gattc cache with the given service. + * @param[in] gattc_if GATT Client access interface + * @param[in] conn_id Connection ID + * @param[in] start_handle The attribute start handle + * @param[in] end_handle The attribute end handle + * @param[in] char_uuid The characteristic UUID + * @param[out] result The pointer to the characteristic in the service + * @param[inout] count The number of characteristics to retrieve. It will be updated with the actual number of characteristics found. * - * @return - * - ESP_OK: success - * - other: failed + * @note + * 1. This API does not trigger any event. + * 2. `start_handle` must be greater than 0, and smaller than `end_handle`. * + * @return + * - ESP_OK: Success + * - ESP_GATT_INVALID_HANDLE: Invalid GATT `start_handle` or `end_handle` + * - ESP_GATT_INVALID_PDU: NULL pointer to `result` or NULL pointer to `count` or the count value is 0 + * - ESP_FAIL: Failure due to other reasons */ esp_gatt_status_t esp_ble_gattc_get_char_by_uuid(esp_gatt_if_t gattc_if, uint16_t conn_id, @@ -483,23 +536,25 @@ esp_gatt_status_t esp_ble_gattc_get_char_by_uuid(esp_gatt_if_t gattc_if, uint16_t *count); /** - * @brief Find the descriptor with the given characteristic uuid in the gattc cache - * Note: It just get descriptor from local cache, won't get from remote devices. + * @brief Get the descriptor with the given characteristic UUID in the local GATTC cache * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] conn_id: connection ID which identify the server. - * @param[in] start_handle: the attribute start handle - * @param[in] end_handle: the attribute end handle - * @param[in] char_uuid: the characteristic uuid. - * @param[in] descr_uuid: the descriptor uuid. - * @param[out] result: The pointer to the descriptor in the given characteristic. - * @param[inout] count: input the number of descriptor want to find, - * it will output the number of descriptor has been found in the gattc cache with the given characteristic. + * @param[in] gattc_if GATT Client access interface + * @param[in] conn_id Connection ID + * @param[in] start_handle The attribute start handle + * @param[in] end_handle The attribute end handle + * @param[in] char_uuid The characteristic UUID + * @param[in] descr_uuid The descriptor UUID. + * @param[out] result The pointer to the descriptor in the given characteristic. + * @param[inout] count The number of descriptors want to retrieve. It will be updated with the actual number of descriptors found. * - * @return - * - ESP_OK: success - * - other: failed + * @note + * 1. This API does not trigger any event. + * 2. `start_handle` must be greater than 0, and smaller than `end_handle`. * + * @return + * - ESP_OK: Success + * - ESP_GATT_INVALID_PDU: NULL pointer to `result` or NULL pointer to `count` or the count value is 0 + * - ESP_FAIL: Failure due to other reasons */ esp_gatt_status_t esp_ble_gattc_get_descr_by_uuid(esp_gatt_if_t gattc_if, uint16_t conn_id, @@ -511,21 +566,24 @@ esp_gatt_status_t esp_ble_gattc_get_descr_by_uuid(esp_gatt_if_t gattc_if, uint16_t *count); /** - * @brief Find the descriptor with the given characteristic handle in the gattc cache - * Note: It just get descriptor from local cache, won't get from remote devices. + * @brief Get the descriptor with the given characteristic handle in the local GATTC cache * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] conn_id: connection ID which identify the server. - * @param[in] char_handle: the characteristic handle. - * @param[in] descr_uuid: the descriptor uuid. - * @param[out] result: The pointer to the descriptor in the given characteristic. - * @param[inout] count: input the number of descriptor want to find, - * it will output the number of descriptor has been found in the gattc cache with the given characteristic. + * @param[in] gattc_if GATT Client access interface + * @param[in] conn_id Connection ID which identifies the server + * @param[in] char_handle The characteristic handle + * @param[in] descr_uuid The descriptor UUID + * @param[out] result The pointer to the descriptor in the given characteristic + * @param[inout] count The number of descriptors want to retrieve. It will be updated with the actual number of descriptors found. * - * @return - * - ESP_OK: success - * - other: failed + * @note + * 1. This API does not trigger any event. + * 2. `char_handle` must be greater than 0. * + * @return + * - ESP_OK: Success + * - ESP_GATT_INVALID_HANDLE: Invalid GATT `char_handle` + * - ESP_GATT_INVALID_PDU: NULL pointer to `result` or NULL pointer to `count` or the count value is 0 + * - ESP_FAIL: Failure due to other reasons */ esp_gatt_status_t esp_ble_gattc_get_descr_by_char_handle(esp_gatt_if_t gattc_if, uint16_t conn_id, @@ -535,22 +593,24 @@ esp_gatt_status_t esp_ble_gattc_get_descr_by_char_handle(esp_gatt_if_t gattc_if, uint16_t *count); /** - * @brief Find the include service with the given service handle in the gattc cache - * Note: It just get include service from local cache, won't get from remote devices. + * @brief Get the included services with the given service handle in the local GATTC cache. * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] conn_id: connection ID which identify the server. - * @param[in] start_handle: the attribute start handle - * @param[in] end_handle: the attribute end handle - * @param[in] incl_uuid: the include service uuid - * @param[out] result: The pointer to the include service in the given service. - * @param[inout] count: input the number of include service want to find, - * it will output the number of include service has been found in the gattc cache with the given service. + * @param[in] gattc_if GATT Client access interface + * @param[in] conn_id Connection ID which identifies the server + * @param[in] start_handle The attribute start handle + * @param[in] end_handle The attribute end handle + * @param[in] incl_uuid The included service UUID + * @param[out] result The pointer to the included service with the given service handle. + * @param[inout] count The number of included services to retrieve. It will be updated with the actual number of included services found. * - * @return - * - ESP_OK: success - * - other: failed + * @note + * 1. This API does not trigger any event. + * 2. `start_handle` must be greater than 0, and smaller than `end_handle`. * + * @return + * - ESP_OK: Success + * - ESP_GATT_INVALID_PDU: NULL pointer to `result` or NULL pointer to `count` or the count value is 0 + * - ESP_FAIL: Failure due to other reasons */ esp_gatt_status_t esp_ble_gattc_get_include_service(esp_gatt_if_t gattc_if, uint16_t conn_id, @@ -560,23 +620,27 @@ esp_gatt_status_t esp_ble_gattc_get_include_service(esp_gatt_if_t gattc_if, esp_gattc_incl_svc_elem_t *result, uint16_t *count); - /** - * @brief Find the attribute count with the given service or characteristic in the gattc cache + * @brief Get the attribute count with the given service or characteristic in the local GATTC cache * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] conn_id: connection ID which identify the server. - * @param[in] type: the attribute type. - * @param[in] start_handle: the attribute start handle, if the type is ESP_GATT_DB_DESCRIPTOR, this parameter should be ignore - * @param[in] end_handle: the attribute end handle, if the type is ESP_GATT_DB_DESCRIPTOR, this parameter should be ignore - * @param[in] char_handle: the characteristic handle, this parameter valid when the type is ESP_GATT_DB_DESCRIPTOR. If the type - * isn't ESP_GATT_DB_DESCRIPTOR, this parameter should be ignore. - * @param[out] count: output the number of attribute has been found in the gattc cache with the given attribute type. + * @param[in] gattc_if GATT Client access interface + * @param[in] conn_id Connection ID + * @param[in] type The attribute type + * @param[in] start_handle The attribute start handle. If the type is `ESP_GATT_DB_DESCRIPTOR`, this parameter will be ignored. + * @param[in] end_handle The attribute end handle. If the type is `ESP_GATT_DB_DESCRIPTOR`, this parameter will be ignored. + * @param[in] char_handle The characteristic handle. This parameter is valid only if the type is `ESP_GATT_DB_DESCRIPTOR`. + * @param[out] count The number of attributes found in the local GATTC cache with the given attribute type * - * @return - * - ESP_OK: success - * - other: failed * + * @note + * 1. This API does not trigger any event. + * 2. `start_handle` must be greater than 0, and smaller than `end_handle` if the `type` is not `ESP_GATT_DB_DESCRIPTOR`. + * + * @return + * - ESP_OK: Success + * - ESP_GATT_INVALID_HANDLE: Invalid GATT `start_handle`, `end_handle` + * - ESP_GATT_INVALID_PDU: NULL pointer to `count` + * - ESP_FAIL: Failure due to other reasons */ esp_gatt_status_t esp_ble_gattc_get_attr_count(esp_gatt_if_t gattc_if, uint16_t conn_id, @@ -587,38 +651,47 @@ esp_gatt_status_t esp_ble_gattc_get_attr_count(esp_gatt_if_t gattc_if, uint16_t *count); /** - * @brief This function is called to get the GATT database. - * Note: It just get attribute data base from local cache, won't get from remote devices. + * @brief Get the GATT database elements + * + * @param[in] gattc_if GATT Client access interface + * @param[in] start_handle The attribute start handle + * @param[in] end_handle The attribute end handle + * @param[in] conn_id Connection ID + * @param[out] db The pointer to GATT database elements + * @param[inout] count The number of elements in the database to retrieve. It will be updated with the actual number of elements found. * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] start_handle: the attribute start handle - * @param[in] end_handle: the attribute end handle - * @param[in] conn_id: connection ID which identify the server. - * @param[in] db: output parameter which will contain the GATT database copy. - * Caller is responsible for freeing it. - * @param[in] count: number of elements in database. + * @note + * 1. This API does not trigger any event. + * 2. `start_handle` must be greater than 0, and smaller than `end_handle`. * * @return - * - ESP_OK: success - * - other: failed + * - ESP_OK: Success + * - ESP_GATT_INVALID_HANDLE: Invalid GATT `start_handle`, `end_handle` + * - ESP_GATT_INVALID_PDU: NULL pointer to `db` or NULL pointer to `count` or the count value is 0 + * - ESP_FAIL: Failure due to other reasons * */ esp_gatt_status_t esp_ble_gattc_get_db(esp_gatt_if_t gattc_if, uint16_t conn_id, uint16_t start_handle, uint16_t end_handle, esp_gattc_db_elem_t *db, uint16_t *count); /** - * @brief This function is called to read a service's characteristics of - * the given characteristic handle + * @brief Read the characteristics value of the given characteristic handle * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] conn_id : connection ID. - * @param[in] handle : characteristic handle to read. - * @param[in] auth_req : authenticate request type + * @param[in] gattc_if GATT Client access interface + * @param[in] conn_id Connection ID + * @param[in] handle Characteristic handle to read + * @param[in] auth_req Authenticate request type * - * @return - * - ESP_OK: success - * - other: failed + * @note + * 1. This function triggers `ESP_GATTC_READ_CHAR_EVT`. + * 2. This function should be called only after the connection has been established. + * 3. `handle` must be greater than 0. * + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_STATE: The connection has not been established. + * - ESP_GATT_INVALID_HANDLE: Invalid `handle` + * - ESP_FAIL: Failure due to other reasons */ esp_err_t esp_ble_gattc_read_char (esp_gatt_if_t gattc_if, uint16_t conn_id, @@ -626,20 +699,25 @@ esp_err_t esp_ble_gattc_read_char (esp_gatt_if_t gattc_if, esp_gatt_auth_req_t auth_req); /** - * @brief This function is called to read a service's characteristics of - * the given characteristic UUID + * @brief Read the characteristics value of the given characteristic UUID. * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] conn_id : connection ID. - * @param[in] start_handle : the attribute start handle. - * @param[in] end_handle : the attribute end handle - * @param[in] uuid : The UUID of attribute which will be read. - * @param[in] auth_req : authenticate request type + * @param[in] gattc_if GATT Client access interface. + * @param[in] conn_id Connection ID + * @param[in] start_handle The attribute start handle + * @param[in] end_handle The attribute end handle + * @param[in] uuid The pointer to UUID of attribute to read + * @param[in] auth_req Authenticate request type * - * @return - * - ESP_OK: success - * - other: failed + * @note + * 1. This function triggers `ESP_GATTC_READ_CHAR_EVT`. + * 2. This function should be called only after the connection has been established. + * 3. `start_handle` must be greater than 0, and smaller than `end_handle`. * + * @return + * - ESP_OK: Success + * - ESP_GATT_ILLEGAL_PARAMETER: NULL pointer to `uuid` + * - ESP_ERR_INVALID_STATE: The connection has not been established + * - ESP_FAIL: Failure due to other reasons */ esp_err_t esp_ble_gattc_read_by_type (esp_gatt_if_t gattc_if, uint16_t conn_id, @@ -649,75 +727,92 @@ esp_err_t esp_ble_gattc_read_by_type (esp_gatt_if_t gattc_if, esp_gatt_auth_req_t auth_req); /** - * @brief This function is called to read multiple characteristic or - * characteristic descriptors. + * @brief Read multiple characteristic or descriptor values * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] conn_id : connection ID. - * @param[in] read_multi : pointer to the read multiple parameter. - * @param[in] auth_req : authenticate request type + * @param[in] gattc_if GATT Client access interface + * @param[in] conn_id Connection ID which specifies the server + * @param[in] read_multi Pointer to `esp_gattc_multi_t` + * @param[in] auth_req Authenticate request type * - * @return - * - ESP_OK: success - * - other: failed + * @note + * 1. This function triggers `ESP_GATTC_READ_MULTIPLE_EVT`. + * 2. This function should be called only after the connection has been established. * + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_STATE: The connection has not been established + * - ESP_FAIL: Failure due to other reasons */ esp_err_t esp_ble_gattc_read_multiple(esp_gatt_if_t gattc_if, uint16_t conn_id, esp_gattc_multi_t *read_multi, esp_gatt_auth_req_t auth_req); /** - * @brief This function is called to read multiple variable length characteristic or - * characteristic descriptors. + * @brief Read multiple variable length characteristic values. * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] conn_id : connection ID. - * @param[in] read_multi : pointer to the read multiple parameter. - * @param[in] auth_req : authenticate request type + * @param[in] gattc_if GATT Client access interface + * @param[in] conn_id Connection ID + * @param[in] read_multi The pointer to the `esp_gattc_multi_t` + * @param[in] auth_req Authenticate request type * - * @return - * - ESP_OK: success - * - other: failed + * @note + * 1. This function triggers `ESP_GATTC_READ_MULTI_VAR_EVT`. + * 2. This function should be called only after the connection has been established. * + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_STATE: The connection has not been established. + * - ESP_FAIL: Failure due to other reasons */ esp_err_t esp_ble_gattc_read_multiple_variable(esp_gatt_if_t gattc_if, uint16_t conn_id, esp_gattc_multi_t *read_multi, esp_gatt_auth_req_t auth_req); /** - * @brief This function is called to read a characteristics descriptor. + * @brief Read a characteristics descriptor * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] conn_id : connection ID. - * @param[in] handle : descriptor handle to read. - * @param[in] auth_req : authenticate request type + * @param[in] gattc_if GATT Client access interface + * @param[in] conn_id Connection ID + * @param[in] handle Descriptor handle to read + * @param[in] auth_req Authenticate request type * - * @return - * - ESP_OK: success - * - other: failed + * @note + * 1. This function triggers `ESP_GATTC_READ_DESCR_EVT`. + * 2. This function should be called only after the connection has been established. + * 3. `handle` must be greater than 0. * + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_STATE: The connection has not been established. + * - ESP_GATT_INVALID_HANDLE:Invalid `handle` + * - ESP_FAIL: Failure due to other reasons */ esp_err_t esp_ble_gattc_read_char_descr (esp_gatt_if_t gattc_if, uint16_t conn_id, uint16_t handle, esp_gatt_auth_req_t auth_req); - /** - * @brief This function is called to write characteristic value. + * @brief Write the characteristic value of a given characteristic handle * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] conn_id : connection ID. - * @param[in] handle : characteristic handle to write. - * @param[in] value_len: length of the value to be written. - * @param[in] value : the value to be written. - * @param[in] write_type : the type of attribute write operation. - * @param[in] auth_req : authentication request. + * @param[in] gattc_if GATT Client access interface + * @param[in] conn_id Connection ID + * @param[in] handle The characteristic handle to write + * @param[in] value_len The length of the value to write in bytes + * @param[in] value The value to write + * @param[in] write_type The type of Attribute write operation + * @param[in] auth_req Authentication request type * - * @return - * - ESP_OK: success - * - other: failed + * @note + * 1. This function triggers `ESP_GATTC_WRITE_CHAR_EVT`. + * 2. This function should be called only after the connection has been established. + * 3. `handle` must be greater than 0. * + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_STATE: The connection has not been established. + * - ESP_GATT_INVALID_HANDLE:Invalid `handle` + * - ESP_FAIL: Failure due to other reasons */ esp_err_t esp_ble_gattc_write_char( esp_gatt_if_t gattc_if, uint16_t conn_id, @@ -727,22 +822,27 @@ esp_err_t esp_ble_gattc_write_char( esp_gatt_if_t gattc_if, esp_gatt_write_type_t write_type, esp_gatt_auth_req_t auth_req); - /** - * @brief This function is called to write characteristic descriptor value. + * @brief Write Characteristic descriptor value of a given descriptor handle * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] conn_id : connection ID - * @param[in] handle : descriptor handle to write. - * @param[in] value_len: length of the value to be written. - * @param[in] value : the value to be written. - * @param[in] write_type : the type of attribute write operation. - * @param[in] auth_req : authentication request. + * @param[in] gattc_if GATT Client access interface + * @param[in] conn_id Connection ID + * @param[in] handle The descriptor handle to write. + * @param[in] value_len The length of the value to write in bytes. + * @param[in] value The value to write + * @param[in] write_type The type of Attribute write operation + * @param[in] auth_req Authentication request type * - * @return - * - ESP_OK: success - * - other: failed + * @note + * 1. This function triggers `ESP_GATTC_WRITE_DESCR_EVT`. + * 2. This function should be called only after the connection has been established. + * 3. `handle` must be greater than 0. * + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_STATE: The connection has not been established. + * - ESP_GATT_INVALID_HANDLE:Invalid `handle` + * - ESP_FAIL: Failure due to other reasons */ esp_err_t esp_ble_gattc_write_char_descr (esp_gatt_if_t gattc_if, uint16_t conn_id, @@ -752,22 +852,29 @@ esp_err_t esp_ble_gattc_write_char_descr (esp_gatt_if_t gattc_if, esp_gatt_write_type_t write_type, esp_gatt_auth_req_t auth_req); - /** - * @brief This function is called to prepare write a characteristic value. - * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] conn_id : connection ID. - * @param[in] handle : characteristic handle to prepare write. - * @param[in] offset : offset of the write value. - * @param[in] value_len: length of the value to be written. - * @param[in] value : the value to be written. - * @param[in] auth_req : authentication request. + * @brief Prepare to write a characteristic value which is longer than the MTU size to a specified characteristic handle + * + * @param[in] gattc_if GATT Client access interface + * @param[in] conn_id Connection ID + * @param[in] handle Characteristic handle to prepare to write + * @param[in] offset The position offset to write + * @param[in] value_len The length of the value to write in bytes + * @param[in] value The value to write + * @param[in] auth_req Authentication request type + * + * @note + * 1. This function should be called only after the connection has been established. + * 2. After using this API, use `esp_ble_gattc_execute_write` to write. + * 3. This function triggers `ESP_GATTC_PREP_WRITE_EVT`. + * 4. If `value_len` is less than or equal to MTU size, it is recommended to `esp_ble_gattc_write_char` to write directly. + * 5. `handle` must be greater than 0. * * @return - * - ESP_OK: success - * - other: failed - * + * - ESP_OK: Success + * - ESP_ERR_INVALID_STATE: The connection has not been established. + * - ESP_GATT_INVALID_HANDLE:Invalid `handle` + * - ESP_FAIL: Failure due to other reasons */ esp_err_t esp_ble_gattc_prepare_write(esp_gatt_if_t gattc_if, uint16_t conn_id, @@ -777,22 +884,27 @@ esp_err_t esp_ble_gattc_prepare_write(esp_gatt_if_t gattc_if, uint8_t *value, esp_gatt_auth_req_t auth_req); - /** - * @brief This function is called to prepare write a characteristic descriptor value. + * @brief Prepare to write a characteristic descriptor value at a given handle * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] conn_id : connection ID. - * @param[in] handle : characteristic descriptor handle to prepare write. - * @param[in] offset : offset of the write value. - * @param[in] value_len: length of the value to be written. - * @param[in] value : the value to be written. - * @param[in] auth_req : authentication request. + * @param[in] gattc_if GATT Client access interface + * @param[in] conn_id Connection ID + * @param[in] handle Characteristic descriptor handle to prepare to write + * @param[in] offset The position offset to write + * @param[in] value_len The length of the value to write in bytes + * @param[in] value The value to write + * @param[in] auth_req Authentication request type * - * @return - * - ESP_OK: success - * - other: failed + * @note + * 1. This function triggers `ESP_GATTC_WRITE_CHAR_EVT`. + * 2. This function should be called only after the connection has been established. + * 3. `handle` must be greater than 0. * + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_STATE: The connection has not been established. + * - ESP_GATT_INVALID_HANDLE:Invalid `handle` + * - ESP_FAIL: Failure due to other reasons */ esp_err_t esp_ble_gattc_prepare_write_char_descr(esp_gatt_if_t gattc_if, uint16_t conn_id, @@ -802,112 +914,123 @@ esp_err_t esp_ble_gattc_prepare_write_char_descr(esp_gatt_if_t gattc_if, uint8_t *value, esp_gatt_auth_req_t auth_req); - /** - * @brief This function is called to execute write a prepare write sequence. + * @brief Execute a prepared writing sequence * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] conn_id : connection ID. - * @param[in] is_execute : execute or cancel. + * @param[in] gattc_if GATT Client access interface + * @param[in] conn_id Connection ID + * @param[in] is_execute True if it is to execute the writing sequence; false if it is to cancel the writing sequence. * - * @return - * - ESP_OK: success - * - other: failed + * @note This function triggers `ESP_GATTC_EXEC_EVT`. * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure */ esp_err_t esp_ble_gattc_execute_write (esp_gatt_if_t gattc_if, uint16_t conn_id, bool is_execute); - /** - * @brief This function is called to register for notification of a service. + * @brief Register to receive notification/indication of a characteristic. * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] server_bda : target GATT server. - * @param[in] handle : GATT characteristic handle. + * @param[in] gattc_if GATT Client access interface + * @param[in] server_bda Target GATT server device address + * @param[in] handle Target GATT characteristic handle * - * @return - * - ESP_OK: registration succeeds - * - other: failed + * @note + * 1. This function triggers `ESP_GATTC_REG_FOR_NOTIFY_EVT`. + * 2. You should call `esp_ble_gattc_write_char_descr()` after this API to write Client Characteristic Configuration (CCC) descriptor to the value of 1 (Enable Notification) or 2 (Enable Indication). + * 3. `handle` must be greater than 0. * + * @return + * - ESP_OK: Success + * - ESP_GATT_INVALID_HANDLE:Invalid `handle` + * - ESP_FAIL: Failure due to other reasons */ esp_err_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gattc_if, esp_bd_addr_t server_bda, uint16_t handle); - /** - * @brief This function is called to de-register for notification of a service. + * @brief Unregister the notification of a service. * - * @param[in] gattc_if: Gatt client access interface. - * @param[in] server_bda : target GATT server. - * @param[in] handle : GATT characteristic handle. + * @param[in] gattc_if GATT Client access interface + * @param[in] server_bda Target GATT server device address + * @param[in] handle Target GATT characteristic handle * + * @note + * 1. This function triggers `ESP_GATTC_UNREG_FOR_NOTIFY_EVT`. + * 2. You should call `esp_ble_gattc_write_char_descr()` after this API to write Client Characteristic Configuration (CCC) descriptor value to 0. + * 3. `handle` must be greater than 0 * @return - * - ESP_OK: unregister succeeds - * - other: failed - * + * - ESP_OK: Success + * - ESP_GATT_INVALID_HANDLE:Invalid `handle` + * - ESP_FAIL: Failure due to other reasons */ esp_err_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gattc_if, esp_bd_addr_t server_bda, uint16_t handle); - /** -* @brief Refresh the server cache store in the gattc stack of the remote device. If -* the device is connected, this API will restart the discovery of service information of the remote device -* -* @param[in] remote_bda: remote device BD address. -* -* @return -* - ESP_OK: success -* - other: failed -* -*/ + * @brief Refresh the cache of the remote device + * + * @param[in] remote_bda Remote device address + * + * @note + * 1. If the device is connected, this API will restart the discovery of service information of the remote device. + * 2. This function triggers `ESP_GATTC_DIS_SRVC_CMPL_EVT` only after the ACL connection is established. Otherwise, no events will be triggered. + * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure + */ esp_err_t esp_ble_gattc_cache_refresh(esp_bd_addr_t remote_bda); /** -* @brief Add or delete the associated address with the source address. -* Note: The role of this API is mainly when the client side has stored a server-side database, -* when it needs to connect another device, but the device's attribute database is the same -* as the server database stored on the client-side, calling this API can use the database -* that the device has stored used as the peer server database to reduce the attribute -* database search and discovery process and speed up the connection time. -* The associated address mains that device want to used the database has stored in the local cache. -* The source address mains that device want to share the database to the associated address device. -* -* @param[in] gattc_if: Gatt client access interface. -* @param[in] src_addr: the source address which provide the attribute table. -* @param[in] assoc_addr: the associated device address which went to share the attribute table with the source address. -* @param[in] is_assoc: true add the associated device address, false remove the associated device address. -* @return -* - ESP_OK: success -* - other: failed -* -*/ + * @brief Add or remove the association between the address in the local GATTC cache with the source address of the remote device + * + * @param[in] gattc_if GATT Client access interface + * @param[in] src_addr The source address intended to be associated to the `assoc_addr` which has been stored in the local GATTC cache + * @param[in] assoc_addr The associated device address intended to share the attribute table with the source address + * @param[in] is_assoc True if adding the association; false if removing the association. + * + * @note + * 1. This API is primarily used when the client has a stored server-side database (`assoc_addr`) and needs to connect to + * another device (`src_addr`) with the same attribute database. By invoking this API, the stored database is utilized + * as the peer server database, eliminating the need for attribute database search and discovery. This reduces + * processing time and accelerates the connection process. + * 2. The attribute table of a device with `assoc_addr` must be stored in the local GATTC cache first. + * Then, the attribute table of the device with `src_addr` must be the same as the one with `assoc_addr`. + * 3. This function triggers `ESP_GATTC_SET_ASSOC_EVT`. + * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure + */ esp_err_t esp_ble_gattc_cache_assoc(esp_gatt_if_t gattc_if, esp_bd_addr_t src_addr, esp_bd_addr_t assoc_addr, bool is_assoc); + /** -* @brief Get the address list which has store the attribute table in the gattc cache. There will -* callback ESP_GATTC_GET_ADDR_LIST_EVT event when get address list complete. -* -* @param[in] gattc_if: Gatt client access interface. -* @return -* - ESP_OK: success -* - other: failed -* -*/ + * @brief Get the address list stored in the local GATTC cache + * + * @param[in] gattc_if GATT Client access interface + * + * @note This function triggers `ESP_GATTC_GET_ADDR_LIST_EVT`. + * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure + */ esp_err_t esp_ble_gattc_cache_get_addr_list(esp_gatt_if_t gattc_if); /** -* @brief Clean the service cache of this device in the gattc stack, -* -* @param[in] remote_bda: remote device BD address. -* -* @return -* - ESP_OK: success -* - other: failed -* -*/ + * @brief Clean the service cache of the target device in the local GATTC cache + * + * @param[in] remote_bda Remote device address + * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure + */ esp_err_t esp_ble_gattc_cache_clean(esp_bd_addr_t remote_bda); #ifdef __cplusplus diff --git a/components/bt/host/bluedroid/api/include/api/esp_gatts_api.h b/components/bt/host/bluedroid/api/include/api/esp_gatts_api.h index 0eb7ddd98b..420cc80359 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_gatts_api.h +++ b/components/bt/host/bluedroid/api/include/api/esp_gatts_api.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -17,579 +17,604 @@ extern "C" { /// GATT Server callback function events typedef enum { - ESP_GATTS_REG_EVT = 0, /*!< When register application id, the event comes */ - ESP_GATTS_READ_EVT = 1, /*!< When gatt client request read operation, the event comes */ - ESP_GATTS_WRITE_EVT = 2, /*!< When gatt client request write operation, the event comes */ - ESP_GATTS_EXEC_WRITE_EVT = 3, /*!< When gatt client request execute write, the event comes */ - ESP_GATTS_MTU_EVT = 4, /*!< When set mtu complete, the event comes */ - ESP_GATTS_CONF_EVT = 5, /*!< When receive confirm, the event comes */ - ESP_GATTS_UNREG_EVT = 6, /*!< When unregister application id, the event comes */ - ESP_GATTS_CREATE_EVT = 7, /*!< When create service complete, the event comes */ - ESP_GATTS_ADD_INCL_SRVC_EVT = 8, /*!< When add included service complete, the event comes */ - ESP_GATTS_ADD_CHAR_EVT = 9, /*!< When add characteristic complete, the event comes */ - ESP_GATTS_ADD_CHAR_DESCR_EVT = 10, /*!< When add descriptor complete, the event comes */ - ESP_GATTS_DELETE_EVT = 11, /*!< When delete service complete, the event comes */ - ESP_GATTS_START_EVT = 12, /*!< When start service complete, the event comes */ - ESP_GATTS_STOP_EVT = 13, /*!< When stop service complete, the event comes */ - ESP_GATTS_CONNECT_EVT = 14, /*!< When gatt client connect, the event comes */ - ESP_GATTS_DISCONNECT_EVT = 15, /*!< When gatt client disconnect, the event comes */ - ESP_GATTS_OPEN_EVT = 16, /*!< When connect to peer, the event comes */ - ESP_GATTS_CANCEL_OPEN_EVT = 17, /*!< When disconnect from peer, the event comes */ - ESP_GATTS_CLOSE_EVT = 18, /*!< When gatt server close, the event comes */ - ESP_GATTS_LISTEN_EVT = 19, /*!< When gatt listen to be connected the event comes */ - ESP_GATTS_CONGEST_EVT = 20, /*!< When congest happen, the event comes */ + ESP_GATTS_REG_EVT = 0, /*!< This event is triggered when a GATT Server application is registered using `esp_ble_gatts_app_register`. */ + ESP_GATTS_READ_EVT = 1, /*!< This event is triggered when the read request from the Client is received. */ + ESP_GATTS_WRITE_EVT = 2, /*!< This event is triggered when the write request from the Client is received. */ + ESP_GATTS_EXEC_WRITE_EVT = 3, /*!< This event is triggered when the write execution request from the Client is received. */ + ESP_GATTS_MTU_EVT = 4, /*!< This event is triggered when the MTU configuration request from the Client is received. */ + ESP_GATTS_CONF_EVT = 5, /*!< This event is triggered when the confirmation from the Client is received. */ + ESP_GATTS_UNREG_EVT = 6, /*!< This event is triggered when a GATT Server application is unregistered using `esp_ble_gatts_app_unregister`. */ + ESP_GATTS_CREATE_EVT = 7, /*!< This event is triggered when a GATT Server service is created using `esp_ble_gatts_create_service`. */ + ESP_GATTS_ADD_INCL_SRVC_EVT = 8, /*!< This event is triggered when an included service is added using `esp_ble_gatts_add_included_service`. */ + ESP_GATTS_ADD_CHAR_EVT = 9, /*!< This event is triggered when a characteristic is added to the service using `esp_ble_gatts_add_char`. */ + ESP_GATTS_ADD_CHAR_DESCR_EVT = 10, /*!< This event is triggered when a characteristic descriptor is added to the service using `esp_ble_gatts_add_char_descr`. */ + ESP_GATTS_DELETE_EVT = 11, /*!< This event is triggered when the service is deleted using `esp_ble_gatts_delete_service`. */ + ESP_GATTS_START_EVT = 12, /*!< This event is triggered when the service is started using `esp_ble_gatts_start_service`. */ + ESP_GATTS_STOP_EVT = 13, /*!< This event is triggered when the service is stopped using `esp_ble_gatts_stop_service`. */ + ESP_GATTS_CONNECT_EVT = 14, /*!< This event is triggered when a physical connection is set up. */ + ESP_GATTS_DISCONNECT_EVT = 15, /*!< This event is triggered when a physical connection is terminated. */ + ESP_GATTS_OPEN_EVT = 16, /*!< This event is triggered when a virtual connection is created using `esp_ble_gatts_open`. */ + ESP_GATTS_CANCEL_OPEN_EVT = 17, /*!< Deprecated. */ + ESP_GATTS_CLOSE_EVT = 18, /*!< This event is triggered when a virtual connection is closed using `esp_ble_gatts_close`. */ + ESP_GATTS_LISTEN_EVT = 19, /*!< Deprecated. */ + ESP_GATTS_CONGEST_EVT = 20, /*!< This event is triggered when the GATT connection is congested. */ /* following is extra event */ - ESP_GATTS_RESPONSE_EVT = 21, /*!< When gatt send response complete, the event comes */ - ESP_GATTS_CREAT_ATTR_TAB_EVT = 22, /*!< When gatt create table complete, the event comes */ - ESP_GATTS_SET_ATTR_VAL_EVT = 23, /*!< When gatt set attr value complete, the event comes */ - ESP_GATTS_SEND_SERVICE_CHANGE_EVT = 24, /*!< When gatt send service change indication complete, the event comes */ + ESP_GATTS_RESPONSE_EVT = 21, /*!< This event is triggered when a response is sent to the request using `esp_ble_gatts_send_response`. */ + ESP_GATTS_CREAT_ATTR_TAB_EVT = 22, /*!< This event is triggered when a service attribute table is created using `esp_ble_gatts_create_attr_tab`. */ + ESP_GATTS_SET_ATTR_VAL_EVT = 23, /*!< This event is triggered when an attribute value is set using `esp_ble_gatts_set_attr_value`. */ + ESP_GATTS_SEND_SERVICE_CHANGE_EVT = 24, /*!< This event is triggered when a service change indication is sent using `esp_ble_gatts_send_service_change_indication`. */ } esp_gatts_cb_event_t; /** - * @brief Gatt server callback parameters union + * @brief GATT Server callback parameters */ typedef union { /** - * @brief ESP_GATTS_REG_EVT + * @brief Callback parameter for the event `ESP_GATTS_REG_EVT` */ struct gatts_reg_evt_param { esp_gatt_status_t status; /*!< Operation status */ - uint16_t app_id; /*!< Application id which input in register API */ - } reg; /*!< Gatt server callback param of ESP_GATTS_REG_EVT */ + uint16_t app_id; /*!< Application ID */ + } reg; /*!< Callback parameter for the event `ESP_GATTS_REG_EVT` */ /** - * @brief ESP_GATTS_READ_EVT + * @brief Callback parameter for the event `ESP_GATTS_READ_EVT` */ struct gatts_read_evt_param { - uint16_t conn_id; /*!< Connection id */ - uint32_t trans_id; /*!< Transfer id */ - esp_bd_addr_t bda; /*!< The bluetooth device address which been read */ + uint16_t conn_id; /*!< Connection ID */ + uint32_t trans_id; /*!< Transfer ID */ + esp_bd_addr_t bda; /*!< The device address to read */ uint16_t handle; /*!< The attribute handle */ - uint16_t offset; /*!< Offset of the value, if the value is too long */ - bool is_long; /*!< The value is too long or not */ - bool need_rsp; /*!< The read operation need to do response */ - } read; /*!< Gatt server callback param of ESP_GATTS_READ_EVT */ + uint16_t offset; /*!< The position offset to read. If the length of value is less than or equal to the MTU size, this value is 0. */ + bool is_long; /*!< True indicates that the length of value is greater than the MTU size; false otherwise. */ + bool need_rsp; /*!< True indicates that the `esp_ble_gatts_send_response` is required in the following step; false otherwise. */ + } read; /*!< Callback parameter for the event `ESP_GATTS_READ_EVT` */ /** - * @brief ESP_GATTS_WRITE_EVT + * @brief Callback parameter for the event `ESP_GATTS_WRITE_EVT` */ struct gatts_write_evt_param { - uint16_t conn_id; /*!< Connection id */ - uint32_t trans_id; /*!< Transfer id */ - esp_bd_addr_t bda; /*!< The bluetooth device address which been written */ + uint16_t conn_id; /*!< Connection ID */ + uint32_t trans_id; /*!< Transfer ID */ + esp_bd_addr_t bda; /*!< The device address to write */ uint16_t handle; /*!< The attribute handle */ - uint16_t offset; /*!< Offset of the value, if the value is too long */ - bool need_rsp; /*!< The write operation need to do response */ - bool is_prep; /*!< This write operation is prepare write */ - uint16_t len; /*!< The write attribute value length */ + uint16_t offset; /*!< The position offset to write. If the length of value is less than or equal to the MTU size, this value is 0.*/ + bool need_rsp; /*!< True indicates that the `esp_ble_gatts_send_response` is required in the following step; false otherwise. */ + bool is_prep; /*!< True indicates the write operation is a prepared write operation */ + uint16_t len; /*!< The length of the write attribute value in bytes */ uint8_t *value; /*!< The write attribute value */ - } write; /*!< Gatt server callback param of ESP_GATTS_WRITE_EVT */ + } write; /*!< Callback parameter for the event `ESP_GATTS_WRITE_EVT` */ /** - * @brief ESP_GATTS_EXEC_WRITE_EVT + * @brief Callback parameter for the event `ESP_GATTS_EXEC_WRITE_EVT` */ struct gatts_exec_write_evt_param { - uint16_t conn_id; /*!< Connection id */ - uint32_t trans_id; /*!< Transfer id */ - esp_bd_addr_t bda; /*!< The bluetooth device address which been written */ -#define ESP_GATT_PREP_WRITE_CANCEL 0x00 /*!< Prepare write flag to indicate cancel prepare write */ -#define ESP_GATT_PREP_WRITE_EXEC 0x01 /*!< Prepare write flag to indicate execute prepare write */ - uint8_t exec_write_flag; /*!< Execute write flag */ - } exec_write; /*!< Gatt server callback param of ESP_GATTS_EXEC_WRITE_EVT */ + uint16_t conn_id; /*!< Connection ID */ + uint32_t trans_id; /*!< Transfer ID */ + esp_bd_addr_t bda; /*!< The bluetooth device address to write */ + #define ESP_GATT_PREP_WRITE_CANCEL 0x00 /*!< Flag to indicate the cancellation of a prepare write operation */ + #define ESP_GATT_PREP_WRITE_EXEC 0x01 /*!< Flag to indicate the execution of a prepare write operation */ + uint8_t exec_write_flag; /*!< Execute write flag: `ESP_GATT_PREP_WRITE_CANCEL` or `ESP_GATT_PREP_WRITE_EXEC` */ + } exec_write; /*!< Callback parameter for the event `ESP_GATTS_EXEC_WRITE_EVT` */ /** - * @brief ESP_GATTS_MTU_EVT + * @brief Callback parameter for the event `ESP_GATTS_MTU_EVT` */ struct gatts_mtu_evt_param { - uint16_t conn_id; /*!< Connection id */ + uint16_t conn_id; /*!< Connection ID */ uint16_t mtu; /*!< MTU size */ - } mtu; /*!< Gatt server callback param of ESP_GATTS_MTU_EVT */ + } mtu; /*!< Callback parameter for the event `ESP_GATTS_MTU_EVT` */ /** - * @brief ESP_GATTS_CONF_EVT + * @brief Callback parameter for the event `ESP_GATTS_CONF_EVT` */ struct gatts_conf_evt_param { esp_gatt_status_t status; /*!< Operation status */ - uint16_t conn_id; /*!< Connection id */ - uint16_t handle; /*!< attribute handle */ - uint16_t len; /*!< The indication or notification value length, len is valid when send notification or indication failed */ - uint8_t *value; /*!< The indication or notification value , value is valid when send notification or indication failed */ - } conf; /*!< Gatt server callback param of ESP_GATTS_CONF_EVT (confirm) */ + uint16_t conn_id; /*!< Connection ID */ + uint16_t handle; /*!< Attribute handle */ + uint16_t len; /*!< The length of indication or notification value in bytes. The length is invalid if the notification or indication failed. */ + uint8_t *value; /*!< The indication or notification value. The value is invalid if the notification or indication failed. */ + } conf; /*!< Callback parameter for the event `ESP_GATTS_CONF_EVT` */ /** - * @brief ESP_GATTS_UNREG_EVT - */ - - /** - * @brief ESP_GATTS_CREATE_EVT + * @brief Callback parameter for the event `ESP_GATTS_CREATE_EVT` */ struct gatts_create_evt_param { esp_gatt_status_t status; /*!< Operation status */ uint16_t service_handle; /*!< Service attribute handle */ - esp_gatt_srvc_id_t service_id; /*!< Service id, include service uuid and other information */ - } create; /*!< Gatt server callback param of ESP_GATTS_CREATE_EVT */ + esp_gatt_srvc_id_t service_id; /*!< Service ID, including service UUID and other information */ + } create; /*!< Callback parameter for the event `ESP_GATTS_CREATE_EVT` */ /** - * @brief ESP_GATTS_ADD_INCL_SRVC_EVT + * @brief Callback parameter for the event `ESP_GATTS_ADD_INCL_SRVC_EVT` */ struct gatts_add_incl_srvc_evt_param { esp_gatt_status_t status; /*!< Operation status */ uint16_t attr_handle; /*!< Included service attribute handle */ uint16_t service_handle; /*!< Service attribute handle */ - } add_incl_srvc; /*!< Gatt server callback param of ESP_GATTS_ADD_INCL_SRVC_EVT */ + } add_incl_srvc; /*!< Callback parameter for the event `ESP_GATTS_ADD_INCL_SRVC_EVT` */ /** - * @brief ESP_GATTS_ADD_CHAR_EVT + * @brief Callback parameter for the event `ESP_GATTS_ADD_CHAR_EVT` */ struct gatts_add_char_evt_param { esp_gatt_status_t status; /*!< Operation status */ uint16_t attr_handle; /*!< Characteristic attribute handle */ uint16_t service_handle; /*!< Service attribute handle */ - esp_bt_uuid_t char_uuid; /*!< Characteristic uuid */ - } add_char; /*!< Gatt server callback param of ESP_GATTS_ADD_CHAR_EVT */ + esp_bt_uuid_t char_uuid; /*!< Characteristic UUID */ + } add_char; /*!< Callback parameter for the event `ESP_GATTS_ADD_CHAR_EVT` */ /** - * @brief ESP_GATTS_ADD_CHAR_DESCR_EVT + * @brief Callback parameter for the event `ESP_GATTS_ADD_CHAR_DESCR_EVT` */ struct gatts_add_char_descr_evt_param { esp_gatt_status_t status; /*!< Operation status */ uint16_t attr_handle; /*!< Descriptor attribute handle */ uint16_t service_handle; /*!< Service attribute handle */ - esp_bt_uuid_t descr_uuid; /*!< Characteristic descriptor uuid */ - } add_char_descr; /*!< Gatt server callback param of ESP_GATTS_ADD_CHAR_DESCR_EVT */ + esp_bt_uuid_t descr_uuid; /*!< Characteristic descriptor UUID */ + } add_char_descr; /*!< Callback parameter for the event `ESP_GATTS_ADD_CHAR_DESCR_EVT` */ /** - * @brief ESP_GATTS_DELETE_EVT + * @brief Callback parameter for the event `ESP_GATTS_DELETE_EVT` */ struct gatts_delete_evt_param { esp_gatt_status_t status; /*!< Operation status */ uint16_t service_handle; /*!< Service attribute handle */ - } del; /*!< Gatt server callback param of ESP_GATTS_DELETE_EVT */ + } del; /*!< Callback parameter for the event `ESP_GATTS_DELETE_EVT` */ /** - * @brief ESP_GATTS_START_EVT + * @brief Callback parameter for the event `ESP_GATTS_START_EVT` */ struct gatts_start_evt_param { esp_gatt_status_t status; /*!< Operation status */ uint16_t service_handle; /*!< Service attribute handle */ - } start; /*!< Gatt server callback param of ESP_GATTS_START_EVT */ + } start; /*!< Callback parameter for the event `ESP_GATTS_START_EVT` */ /** - * @brief ESP_GATTS_STOP_EVT + * @brief Callback parameter for the event `ESP_GATTS_STOP_EVT` */ struct gatts_stop_evt_param { esp_gatt_status_t status; /*!< Operation status */ uint16_t service_handle; /*!< Service attribute handle */ - } stop; /*!< Gatt server callback param of ESP_GATTS_STOP_EVT */ + } stop; /*!< Callback parameter for the event `ESP_GATTS_STOP_EVT` */ /** - * @brief ESP_GATTS_CONNECT_EVT + * @brief Callback parameter for the event `ESP_GATTS_CONNECT_EVT` */ struct gatts_connect_evt_param { - uint16_t conn_id; /*!< Connection id */ - uint8_t link_role; /*!< Link role : master role = 0 ; slave role = 1*/ - esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */ - esp_gatt_conn_params_t conn_params; /*!< current Connection parameters */ - esp_ble_addr_type_t ble_addr_type; /*!< Remote BLE device address type */ - uint16_t conn_handle; /*!< HCI connection handle */ - } connect; /*!< Gatt server callback param of ESP_GATTS_CONNECT_EVT */ + uint16_t conn_id; /*!< Connection ID */ + uint8_t link_role; /*!< Link role: master role = 0; slave role = 1 */ + esp_bd_addr_t remote_bda; /*!< Remote device address */ + esp_gatt_conn_params_t conn_params; /*!< Current connection parameters */ + esp_ble_addr_type_t ble_addr_type; /*!< Remote device address type */ + uint16_t conn_handle; /*!< HCI connection handle */ + } connect; /*!< Callback parameter for the event `ESP_GATTS_CONNECT_EVT` */ /** - * @brief ESP_GATTS_DISCONNECT_EVT + * @brief Callback parameter for the event `ESP_GATTS_DISCONNECT_EVT` */ struct gatts_disconnect_evt_param { - uint16_t conn_id; /*!< Connection id */ - esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */ - esp_gatt_conn_reason_t reason; /*!< Indicate the reason of disconnection */ - } disconnect; /*!< Gatt server callback param of ESP_GATTS_DISCONNECT_EVT */ + uint16_t conn_id; /*!< Connection ID */ + esp_bd_addr_t remote_bda; /*!< Remote device address */ + esp_gatt_conn_reason_t reason; /*!< The reason of disconnection */ + } disconnect; /*!< Callback parameter for the event `ESP_GATTS_DISCONNECT_EVT` */ /** - * @brief ESP_GATTS_OPEN_EVT + * @brief Callback parameter for the event `ESP_GATTS_OPEN_EVT` */ struct gatts_open_evt_param { esp_gatt_status_t status; /*!< Operation status */ - } open; /*!< Gatt server callback param of ESP_GATTS_OPEN_EVT */ + } open; /*!< Callback parameter for the event `ESP_GATTS_OPEN_EVT` */ /** - * @brief ESP_GATTS_CANCEL_OPEN_EVT + * @brief Callback parameter for the event `ESP_GATTS_CANCEL_OPEN_EVT` */ struct gatts_cancel_open_evt_param { esp_gatt_status_t status; /*!< Operation status */ - } cancel_open; /*!< Gatt server callback param of ESP_GATTS_CANCEL_OPEN_EVT */ + } cancel_open; /*!< Callback parameter for the event `ESP_GATTS_CANCEL_OPEN_EVT` */ /** - * @brief ESP_GATTS_CLOSE_EVT + * @brief Callback parameter for the event `ESP_GATTS_CLOSE_EVT` */ struct gatts_close_evt_param { esp_gatt_status_t status; /*!< Operation status */ - uint16_t conn_id; /*!< Connection id */ - } close; /*!< Gatt server callback param of ESP_GATTS_CLOSE_EVT */ + uint16_t conn_id; /*!< Connection ID */ + } close; /*!< Callback parameter for the event `ESP_GATTS_CLOSE_EVT` */ /** - * @brief ESP_GATTS_LISTEN_EVT - */ - /** - * @brief ESP_GATTS_CONGEST_EVT + * @brief Callback parameter for the event `ESP_GATTS_CONGEST_EVT` */ struct gatts_congest_evt_param { - uint16_t conn_id; /*!< Connection id */ - bool congested; /*!< Congested or not */ - } congest; /*!< Gatt server callback param of ESP_GATTS_CONGEST_EVT */ + uint16_t conn_id; /*!< Connection ID */ + bool congested; /*!< True indicates the connection is congested; false otherwise. */ + } congest; /*!< Callback parameter for the event `ESP_GATTS_CONGEST_EVT` */ /** - * @brief ESP_GATTS_RESPONSE_EVT + * @brief Callback parameter for the event `ESP_GATTS_RESPONSE_EVT` */ struct gatts_rsp_evt_param { esp_gatt_status_t status; /*!< Operation status */ - uint16_t handle; /*!< Attribute handle which send response */ - } rsp; /*!< Gatt server callback param of ESP_GATTS_RESPONSE_EVT */ + uint16_t conn_id; /*!< Connection ID */ + uint16_t handle; /*!< Attribute handle which sends the response */ + } rsp; /*!< Callback parameter for the event `ESP_GATTS_RESPONSE_EVT` */ /** - * @brief ESP_GATTS_CREAT_ATTR_TAB_EVT + * @brief Callback parameter for the event `ESP_GATTS_CREAT_ATTR_TAB_EVT` */ struct gatts_add_attr_tab_evt_param{ esp_gatt_status_t status; /*!< Operation status */ - esp_bt_uuid_t svc_uuid; /*!< Service uuid type */ - uint8_t svc_inst_id; /*!< Service id */ - uint16_t num_handle; /*!< The number of the attribute handle to be added to the gatts database */ - uint16_t *handles; /*!< The number to the handles */ - } add_attr_tab; /*!< Gatt server callback param of ESP_GATTS_CREAT_ATTR_TAB_EVT */ + esp_bt_uuid_t svc_uuid; /*!< Service UUID type */ + uint8_t svc_inst_id; /*!< Service ID */ + uint16_t num_handle; /*!< The number of the attribute handles which have been added to the GATT Service table */ + uint16_t *handles; /*!< The handles which have been added to the table */ + } add_attr_tab; /*!< Callback parameter for the event `ESP_GATTS_CREAT_ATTR_TAB_EVT` */ /** - * @brief ESP_GATTS_SET_ATTR_VAL_EVT + * @brief Callback parameter for the event `ESP_GATTS_SET_ATTR_VAL_EVT` */ struct gatts_set_attr_val_evt_param{ uint16_t srvc_handle; /*!< The service handle */ - uint16_t attr_handle; /*!< The attribute handle */ - esp_gatt_status_t status; /*!< Operation status*/ - } set_attr_val; /*!< Gatt server callback param of ESP_GATTS_SET_ATTR_VAL_EVT */ + uint16_t attr_handle; /*!< The attribute handle */ + esp_gatt_status_t status; /*!< Operation status */ + } set_attr_val; /*!< Callback parameter for the event `ESP_GATTS_SET_ATTR_VAL_EVT` */ /** - * @brief ESP_GATTS_SEND_SERVICE_CHANGE_EVT + * @brief Callback parameter for the event `ESP_GATTS_SEND_SERVICE_CHANGE_EVT` */ struct gatts_send_service_change_evt_param{ - esp_gatt_status_t status; /*!< Operation status*/ - } service_change; /*!< Gatt server callback param of ESP_GATTS_SEND_SERVICE_CHANGE_EVT */ + esp_gatt_status_t status; /*!< Operation status */ + } service_change; /*!< Callback parameter for the event `ESP_GATTS_SEND_SERVICE_CHANGE_EVT` */ } esp_ble_gatts_cb_param_t; /** * @brief GATT Server callback function type - * @param event : Event type - * @param gatts_if : GATT server access interface, normally - * different gatts_if correspond to different profile - * @param param : Point to callback parameter, currently is union type + * + * @param[in] event Event type + * @param[in] gatts_if GATT Server access interface. Typically, different `gatts_if` values correspond to different profiles. + * @param[in] param The pointer to the callback parameter, which is of a union type. */ typedef void (* esp_gatts_cb_t)(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param); /** - * @brief This function is called to register application callbacks - * with BTA GATTS module. + * @brief Register GATT Server application callbacks * - * @return - * - ESP_OK : success - * - other : failed + * @param[in] callback The pointer to the application callback function * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure */ esp_err_t esp_ble_gatts_register_callback(esp_gatts_cb_t callback); /** - * @brief This function is called to get the current application callbacks - * with BTA GATTS module. + * @brief Get the current GATT Server application callback * * @return - * - esp_gatts_cb_t : current callback - * + * - esp_gatts_cb_t: Current callback */ esp_gatts_cb_t esp_ble_gatts_get_callback(void); /** - * @brief This function is called to register application identifier + * @brief Register GATT Server application * - * @return - * - ESP_OK : success - * - other : failed + * @param[in] app_id: The UUID for different application + * + * @note + * 1. This function triggers `ESP_GATTS_REG_EVT`. + * 2. The maximum number of applications is limited to 6. * + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_ARG: The input `app_id` exceeds `ESP_APP_ID_MAX` (0x7fff) defined in esp_bt_defs.h. + * - ESP_FAIL: Failure due to other reasons */ esp_err_t esp_ble_gatts_app_register(uint16_t app_id); - - /** - * @brief unregister with GATT Server. + * @brief Unregister an GATT Server application * - * @param[in] gatts_if: GATT server access interface - * @return - * - ESP_OK : success - * - other : failed + * @param[in] gatts_if GATT Server access interface. * + * @note + * 1. This function triggers `ESP_GATTS_UNREG_EVT`. + * 2. The maximum number of applications is limited to 6. + * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure */ esp_err_t esp_ble_gatts_app_unregister(esp_gatt_if_t gatts_if); - /** - * @brief Create a service. When service creation is done, a callback - * event ESP_GATTS_CREATE_EVT is called to report status - * and service ID to the profile. The service ID obtained in - * the callback function needs to be used when adding included - * service and characteristics/descriptors into the service. + * @brief Create a GATT Server service * - * @param[in] gatts_if: GATT server access interface - * @param[in] service_id: service ID. - * @param[in] num_handle: number of handle requested for this service. + * @param[in] gatts_if GATT Server access interface + * @param[in] service_id The pointer to the Service ID + * @param[in] num_handle The number of handles requested for this service. * - * @return - * - ESP_OK : success - * - other : failed + * @note + * 1. This function triggers `ESP_GATTS_CREATE_EVT`. + * 2. `num_handle` should not be greater than CONFIG_BT_GATT_MAX_SR_ATTRIBUTES. * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure */ esp_err_t esp_ble_gatts_create_service(esp_gatt_if_t gatts_if, esp_gatt_srvc_id_t *service_id, uint16_t num_handle); /** - * @brief Create a service attribute tab. - * @param[in] gatts_attr_db: the pointer to the service attr tab - * @param[in] gatts_if: GATT server access interface - * @param[in] max_nb_attr: the number of attribute to be added to the service database. - * @param[in] srvc_inst_id: the instance id of the service + * @brief Create a service attribute table * - * @return - * - ESP_OK : success - * - other : failed + * @param[in] gatts_attr_db The pointer to the service attribute table + * @param[in] gatts_if GATT Server access interface + * @param[in] max_nb_attr The number of attributes to be added to the service database + * @param[in] srvc_inst_id The instance ID of the service + * + * @note + * 1. This function triggers `ESP_GATTS_CREAT_ATTR_TAB_EVT`. + * 2. `max_nb_attr` should not be greater than CONFIG_BT_GATT_MAX_SR_ATTRIBUTES. * + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_ARG: Invalid `max_nb_attr` + * - ESP_FAIL: Failure */ esp_err_t esp_ble_gatts_create_attr_tab(const esp_gatts_attr_db_t *gatts_attr_db, esp_gatt_if_t gatts_if, uint16_t max_nb_attr, uint8_t srvc_inst_id); /** - * @brief This function is called to add an included service. This function have to be called between - * 'esp_ble_gatts_create_service' and 'esp_ble_gatts_add_char'. After included - * service is included, a callback event ESP_GATTS_ADD_INCL_SRVC_EVT - * is reported the included service ID. + * @brief Add an included service * - * @param[in] service_handle: service handle to which this included service is to - * be added. - * @param[in] included_service_handle: the service ID to be included. + * @param[in] service_handle Target service handle to add + * @param[in] included_service_handle The handle of included service to be added * - * @return - * - ESP_OK : success - * - other : failed + * @note + * 1. This function triggers `ESP_GATTS_ADD_INCL_SRVC_EVT`. + * 2. This function has to be called between `esp_ble_gatts_create_service` and `esp_ble_gatts_add_char`. * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure */ esp_err_t esp_ble_gatts_add_included_service(uint16_t service_handle, uint16_t included_service_handle); - - /** - * @brief This function is called to add a characteristic into a service. + * @brief Add a characteristic into a service. * - * @param[in] service_handle: service handle to which this included service is to - * be added. - * @param[in] char_uuid : Characteristic UUID. - * @param[in] perm : Characteristic value declaration attribute permission. - * @param[in] property : Characteristic Properties - * @param[in] char_val : Characteristic value - * @param[in] control : attribute response control byte + * @param[in] service_handle Target service handle to add the characteristic + * @param[in] char_uuid The pointer to the characteristic UUID + * @param[in] perm Characteristic value declaration attribute permission + * @param[in] property Characteristic Properties + * @param[in] char_val The pointer to the characteristic value + * @param[in] control The pointer to the attribute response control byte * - * @return - * - ESP_OK : success - * - other : failed + * @note + * 1. This function triggers `ESP_GATTS_ADD_CHAR_EVT`. + * 2. `control->auto_rsp` should be set to `ESP_GATT_AUTO_RSP` or `ESP_GATT_RSP_BY_APP`. + * 3. For stack respond attribute (`ESP_GATT_AUTO_RSP`), `char_val` should not be NULL and `char_val->attr_max_len` must be greater than 0. * + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_ARG: Invalid arguments + * - ESP_FAIL: Failure due to other reasons */ esp_err_t esp_ble_gatts_add_char(uint16_t service_handle, esp_bt_uuid_t *char_uuid, esp_gatt_perm_t perm, esp_gatt_char_prop_t property, esp_attr_value_t *char_val, esp_attr_control_t *control); - /** - * @brief This function is called to add characteristic descriptor. When - * it's done, a callback event ESP_GATTS_ADD_DESCR_EVT is called - * to report the status and an ID number for this descriptor. - * - * @param[in] service_handle: service handle to which this characteristic descriptor is to - * be added. - * @param[in] perm: descriptor access permission. - * @param[in] descr_uuid: descriptor UUID. - * @param[in] char_descr_val : Characteristic descriptor value - * @param[in] control : attribute response control byte - * @return - * - ESP_OK : success - * - other : failed + * @brief Add a characteristic descriptor + * + * @param[in] service_handle Target service handle to add the characteristic descriptor + * @param[in] descr_uuid The pointer to the descriptor UUID + * @param[in] perm Descriptor access permission + * @param[in] char_descr_val The pointer to the characteristic descriptor value + * @param[in] control The pointer to the attribute response control byte * + * @note + * 1. This function triggers `ESP_GATTS_ADD_CHAR_DESCR_EVT`. + * 2. `control->auto_rsp` should be set to `ESP_GATT_AUTO_RSP` or `ESP_GATT_RSP_BY_APP`. + * 3. For stack respond attribute (`ESP_GATT_AUTO_RSP`), `char_val` should not be NULL and `char_val->attr_max_len` must be greater than 0. + * + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_ARG: Invalid arguments + * - ESP_FAIL: Failure due to other reasons */ esp_err_t esp_ble_gatts_add_char_descr (uint16_t service_handle, esp_bt_uuid_t *descr_uuid, esp_gatt_perm_t perm, esp_attr_value_t *char_descr_val, esp_attr_control_t *control); - - /** - * @brief This function is called to delete a service. When this is done, - * a callback event ESP_GATTS_DELETE_EVT is report with the status. + * @brief Delete a service * - * @param[in] service_handle: service_handle to be deleted. + * @param[in] service_handle Target service handle to delete * - * @return - * - ESP_OK : success - * - other : failed + * @note This function triggers `ESP_GATTS_DELETE_EVT`. * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure */ esp_err_t esp_ble_gatts_delete_service(uint16_t service_handle); - - /** - * @brief This function is called to start a service. + * @brief Start a service * - * @param[in] service_handle: the service handle to be started. + * @param[in] service_handle Target service handle to start * - * @return - * - ESP_OK : success - * - other : failed + * @note This function triggers `ESP_GATTS_START_EVT`. * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure */ esp_err_t esp_ble_gatts_start_service(uint16_t service_handle); - - /** - * @brief This function is called to stop a service. + * @brief Stop a service. * - * @param[in] service_handle - service to be topped. + * @param[in] service_handle Target service handle to stop * - * @return - * - ESP_OK : success - * - other : failed + * @note This function triggers `ESP_GATTS_STOP_EVT`. * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure */ esp_err_t esp_ble_gatts_stop_service(uint16_t service_handle); - - /** - * @brief Send indicate or notify to GATT client. - * Set param need_confirm as false will send notification, otherwise indication. - * Note: the size of indicate or notify data need less than MTU size,see "esp_ble_gattc_send_mtu_req". - * - * @param[in] gatts_if: GATT server access interface - * @param[in] conn_id - connection id to indicate. - * @param[in] attr_handle - attribute handle to indicate. - * @param[in] value_len - indicate value length. - * @param[in] value: value to indicate. - * @param[in] need_confirm - Whether a confirmation is required. - * false sends a GATT notification, true sends a GATT indication. + * @brief Send indication or notification to a GATT Client * - * @return - * - ESP_OK : success - * - other : failed + * @param[in] gatts_if GATT Server access interface + * @param[in] conn_id Connection ID + * @param[in] attr_handle Attribute handle to indicate + * @param[in] value_len Indication value length in bytes + * @param[in] value Value to indicate + * @param[in] need_confirm True if a confirmation is required, which is a GATT indication; false if the confirmation is not required, which is a GATT notification. + * + * @note + * 1. This function triggers `ESP_GATTS_CONF_EVT`. + * 2. The size of indication or notification data must be less than or equal to MTU size, see `esp_ble_gattc_send_mtu_req`. + * 3. This function should be called only after the connection has been established. * + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_STATE: The connection has not been established. + * - ESP_FAIL: Failure due to other reasons */ esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id, uint16_t attr_handle, uint16_t value_len, uint8_t *value, bool need_confirm); - /** - * @brief This function is called to send a response to a request. + * @brief Send a response to a request * - * @param[in] gatts_if: GATT server access interface - * @param[in] conn_id - connection identifier. - * @param[in] trans_id - transfer id - * @param[in] status - response status - * @param[in] rsp - response data. + * @param[in] gatts_if GATT Server access interface + * @param[in] conn_id Connection ID + * @param[in] trans_id Transfer ID + * @param[in] status Response status + * @param[in] rsp The pointer to the response data * - * @return - * - ESP_OK : success - * - other : failed + * @note + * 1. This function triggers `ESP_GATTS_RESPONSE_EVT`. + * 2. This function should be called only after the connection has been established. * + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_STATE: The connection has not been established. + * - ESP_FAIL: Failure due to other reasons */ esp_err_t esp_ble_gatts_send_response(esp_gatt_if_t gatts_if, uint16_t conn_id, uint32_t trans_id, esp_gatt_status_t status, esp_gatt_rsp_t *rsp); - /** - * @brief This function is called to set the attribute value by the application + * @brief Set the attribute value * - * @param[in] attr_handle: the attribute handle which to be set - * @param[in] length: the value length - * @param[in] value: the pointer to the attribute value + * @param[in] attr_handle Target attribute handle to set the value + * @param[in] length The value length in bytes + * @param[in] value The pointer to the attribute value * - * @return - * - ESP_OK : success - * - other : failed + * @note This function triggers `ESP_GATTS_SET_ATTR_VAL_EVT`. * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure */ esp_err_t esp_ble_gatts_set_attr_value(uint16_t attr_handle, uint16_t length, const uint8_t *value); /** - * @brief Retrieve attribute value + * @brief Retrieve attribute value * - * @param[in] attr_handle: Attribute handle. - * @param[out] length: pointer to the attribute value length - * @param[out] value: Pointer to attribute value payload, the value cannot be modified by user + * @param[in] attr_handle Attribute handle + * @param[out] length The pointer to the attribute value length in bytes + * @param[out] value The pointer to attribute value payload. This value cannot be modified by user. * - * @return - * - ESP_GATT_OK : success - * - other : failed + * @note + * 1. This function does not trigger any event. + * 2. `attr_handle` must be greater than 0. * + * @return + * - ESP_OK: Success + * - ESP_GATT_INVALID_HANDLE: Invalid `attr_handle` + * - ESP_FAIL: Failure due to other reasons */ esp_gatt_status_t esp_ble_gatts_get_attr_value(uint16_t attr_handle, uint16_t *length, const uint8_t **value); - /** - * @brief Open a direct open connection or add a background auto connection + * @brief Create an ACL connection when `BT_BLE_42_FEATURES_SUPPORTED` is enabled in the menuconfig * - * @param[in] gatts_if: GATT server access interface - * @param[in] remote_bda: remote device bluetooth device address. - * @param[in] is_direct: direct connection or background auto connection + * @param[in] gatts_if GATT Server access interface + * @param[in] remote_bda Remote device address + * @param[in] is_direct `True` indicates a direct connection, while `False` indicates a background auto connection. Currently, background auto connection is not supported, so please always set this parameter to True. * - * @return - * - ESP_OK : success - * - other : failed + * @note + * 1. The function always triggers `ESP_GATTS_CONNECT_EVT` and `ESP_GATTS_OPEN_EVT`. + * 2. When the device acts as GATT Server, besides the above two events, this function triggers `ESP_GATTS_CONNECT_EVT` as well. + * 3. This function will establish an ACL connection as a Central and a virtual connection as a GATT Server. If the ACL connection already exists, it will create a virtual connection only. * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure */ esp_err_t esp_ble_gatts_open(esp_gatt_if_t gatts_if, esp_bd_addr_t remote_bda, bool is_direct); /** - * @brief Close a connection a remote device. + * @brief Close a connection with a remote device * - * @param[in] gatts_if: GATT server access interface - * @param[in] conn_id: connection ID to be closed. + * @param[in] gatts_if GATT Server access interface + * @param[in] conn_id Connection ID to be closed * - * @return - * - ESP_OK : success - * - other : failed + * @note + * 1. This function triggers `ESP_GATTS_CLOSE_EVT`. + * 2. There may be multiple virtual GATT server connections when multiple `app_id` got registered. + * 3. This API closes one virtual GATT server connection only, if there exist other virtual GATT server connections. It does not close the physical connection. + * 4. The API `esp_ble_gap_disconnect` can be used to disconnect the physical connection directly. + * 5. If there is only one virtual GATT connection left, this API will terminate the ACL connection in addition, and trigger `ESP_GATTS_DISCONNECT_EVT`. Then there is no need to call `esp_ble_gap_disconnect` anymore. * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure */ esp_err_t esp_ble_gatts_close(esp_gatt_if_t gatts_if, uint16_t conn_id); /** - * @brief Send service change indication + * @brief Send service change indication * - * @param[in] gatts_if: GATT server access interface - * @param[in] remote_bda: remote device bluetooth device address. + * @param[in] gatts_if GATT Server access interface + * @param[in] remote_bda Remote device address. * If remote_bda is NULL then it will send service change * indication to all the connected devices and if not then - * to a specific device + * to a specific device. * - * @return - * - ESP_OK : success - * - other : failed + * @note This function triggers `ESP_GATTS_SEND_SERVICE_CHANGE_EVT`. * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure */ esp_err_t esp_ble_gatts_send_service_change_indication(esp_gatt_if_t gatts_if, esp_bd_addr_t remote_bda); /** - * @brief Print local database (GATT service table) + * @brief Display the Server's local attribute database. * - * @return - * - ESP_OK : success - * - other : failed + * This API prints the local attribute database of the BLE server, including details + * of all services, characteristics, and descriptors. * + * @note + * 1. This function does not trigger any event. + * 2. It is primarily intended for debugging purposes to verify the server's current configuration. + * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure */ esp_err_t esp_ble_gatts_show_local_database(void); diff --git a/components/bt/host/bluedroid/api/include/api/esp_hf_ag_api.h b/components/bt/host/bluedroid/api/include/api/esp_hf_ag_api.h index 84086118f3..c079614b29 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_hf_ag_api.h +++ b/components/bt/host/bluedroid/api/include/api/esp_hf_ag_api.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -63,6 +63,7 @@ typedef enum ESP_HF_WBS_RESPONSE_EVT, /*!< Codec Status */ ESP_HF_BCS_RESPONSE_EVT, /*!< Final Codec Choice */ ESP_HF_PKT_STAT_NUMS_GET_EVT, /*!< Request number of packet different status */ + ESP_HF_PROF_STATE_EVT, /*!< Indicate HF init or deinit complete */ } esp_hf_cb_event_t; /// Dial type of ESP_HF_DIAL_EVT @@ -223,6 +224,13 @@ typedef union uint32_t tx_discarded; /*!< the total number of packets send lost */ } pkt_nums; /*!< AG callback param of ESP_HF_PKT_STAT_NUMS_GET_EVT */ + /** + * @brief ESP_HF_PROF_STATE_EVT + */ + struct ag_prof_stat_param { + esp_hf_prof_state_t state; /*!< hf profile state param */ + } prof_stat; /*!< status to indicate hf prof init or deinit */ + } esp_hf_cb_param_t; /*!< HFP AG callback param compound*/ /** @@ -284,6 +292,7 @@ esp_err_t esp_hf_ag_register_callback(esp_hf_cb_t callback); * * @brief Initialize the bluetooth HF AG module. * This function should be called after esp_bluedroid_enable() completes successfully. + * ESP_HF_PROF_STATE_EVT with ESP_HF_INIT_SUCCESS will reported to the APP layer. * * @return * - ESP_OK: if the initialization request is sent successfully @@ -297,6 +306,7 @@ esp_err_t esp_hf_ag_init(void); * * @brief De-initialize for HF AG module. * This function should be called only after esp_bluedroid_enable() completes successfully. + * ESP_HF_PROF_STATE_EVT with ESP_HF_DEINIT_SUCCESS will reported to the APP layer. * * @return * - ESP_OK: success @@ -504,13 +514,13 @@ esp_err_t esp_hf_ag_cind_response(esp_bd_addr_t remote_addr, /** * - * @brief Reponse for AT+COPS command from HF Client. + * @brief Response for AT+COPS command from HF Client. * As a precondition to use this API, Service Level Connection shall exist with HFP client. * * @param[in] remote_addr: remote bluetooth device address * @param[in] name: current operator name * @return - * - ESP_OK: reponse for AT+COPS command is sent to lower layer + * - ESP_OK: response for AT+COPS command is sent to lower layer * - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled * - ESP_FAIL: others * @@ -529,7 +539,7 @@ esp_err_t esp_hf_ag_cops_response(esp_bd_addr_t remote_addr, char *name); * @param[in] mode: current call mode (voice/data/fax) * @param[in] mpty: single or multi type * @param[in] number: current call number - * @param[in] type: international type or unknow + * @param[in] type: international type or unknown * @return * - ESP_OK: response to AT+CLCC command is sent to lower layer * - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled diff --git a/components/bt/host/bluedroid/api/include/api/esp_hf_client_api.h b/components/bt/host/bluedroid/api/include/api/esp_hf_client_api.h index 9353fc032b..cbc7277e65 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_hf_client_api.h +++ b/components/bt/host/bluedroid/api/include/api/esp_hf_client_api.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -97,6 +97,7 @@ typedef enum { ESP_HF_CLIENT_BINP_EVT, /*!< requested number of last voice tag from AG */ ESP_HF_CLIENT_RING_IND_EVT, /*!< ring indication event */ ESP_HF_CLIENT_PKT_STAT_NUMS_GET_EVT, /*!< requested number of packet different status */ + ESP_HF_CLIENT_PROF_STATE_EVT, /*!< Indicate HF CLIENT init or deinit complete */ } esp_hf_client_cb_event_t; /// HFP client callback parameters @@ -266,6 +267,13 @@ typedef union { uint32_t tx_discarded; /*!< the total number of packets send lost */ } pkt_nums; /*!< HF callback param of ESP_HF_CLIENT_PKT_STAT_NUMS_GET_EVT */ + /** + * @brief ESP_HF_CLIENT_PROF_STATE_EVT + */ + struct hf_client_prof_stat_param { + esp_hf_prof_state_t state; /*!< hf client profile state param */ + } prof_stat; /*!< status to indicate hf client prof init or deinit */ + } esp_hf_client_cb_param_t; /*!< HFP client callback parameters */ /** @@ -323,6 +331,7 @@ esp_err_t esp_hf_client_register_callback(esp_hf_client_cb_t callback); * * @brief Initialize the bluetooth HFP client module. * This function should be called after esp_bluedroid_enable() completes successfully. + * ESP_HF_CLIENT_PROF_STATE_EVT with ESP_HF_INIT_SUCCESS will reported to the APP layer. * * @return * - ESP_OK: if the initialization request is sent successfully @@ -336,6 +345,7 @@ esp_err_t esp_hf_client_init(void); * * @brief De-initialize for HFP client module. * This function should be called only after esp_bluedroid_enable() completes successfully. + * ESP_HF_CLIENT_PROF_STATE_EVT with ESP_HF_DEINIT_SUCCESS will reported to the APP layer. * * @return * - ESP_OK: success @@ -422,7 +432,7 @@ esp_err_t esp_hf_client_start_voice_recognition(void); * As a precondition to use this API, Service Level Connection shall exist with AG. * * @return - * - ESP_OK: stoping voice recognition is sent to lower layer + * - ESP_OK: stopping voice recognition is sent to lower layer * - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled * - ESP_FAIL: others * diff --git a/components/bt/host/bluedroid/api/include/api/esp_hf_defs.h b/components/bt/host/bluedroid/api/include/api/esp_hf_defs.h index b7671ff1e7..ec41b8641a 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_hf_defs.h +++ b/components/bt/host/bluedroid/api/include/api/esp_hf_defs.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -13,6 +13,16 @@ extern "C" { #endif +/// profile states +typedef enum { + ESP_HF_INIT_SUCCESS = 0, /*!< Indicate init successful */ + ESP_HF_INIT_ALREADY, /*!< Indicate init repeated */ + ESP_HF_INIT_FAIL, /*!< Indicate init fail */ + ESP_HF_DEINIT_SUCCESS, /*!< Indicate deinit successful */ + ESP_HF_DEINIT_ALREADY, /*!< Indicate deinit repeated */ + ESP_HF_DEINIT_FAIL, /*!< Indicate deinit fail */ +} esp_hf_prof_state_t; + /// in-band ring tone state typedef enum { ESP_HF_IN_BAND_RINGTONE_NOT_PROVIDED = 0, @@ -128,7 +138,7 @@ typedef enum { /// +CLCC address type typedef enum { - ESP_HF_CALL_ADDR_TYPE_UNKNOWN = 0x81, /*!< unkown address type */ + ESP_HF_CALL_ADDR_TYPE_UNKNOWN = 0x81, /*!< unknown address type */ ESP_HF_CALL_ADDR_TYPE_INTERNATIONAL = 0x91, /*!< international address */ } esp_hf_call_addr_type_t; @@ -160,7 +170,7 @@ typedef enum ESP_HF_NREC_START } esp_hf_nrec_t; -///+CCWA resposne status +///+CCWA response status typedef enum { ESP_HF_CALL_WAITING_INACTIVE, ESP_HF_CALL_WAITING_ACTIVE, diff --git a/components/bt/host/bluedroid/api/include/api/esp_sdp_api.h b/components/bt/host/bluedroid/api/include/api/esp_sdp_api.h index 14741e7471..50c79b8ba1 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_sdp_api.h +++ b/components/bt/host/bluedroid/api/include/api/esp_sdp_api.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -14,123 +14,131 @@ extern "C" { #endif -#define ESP_SDP_SERVER_NAME_MAX 32 /*!< Service name max length */ -#define SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH 15 /*!< OPP supported format list maximum length */ +#define ESP_SDP_SERVER_NAME_MAX 32 /*!< Service name max length */ +#define SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH 15 /*!< OPP supported format list maximum length */ + +#define ESP_SDP_UUID_MAP_MAS 0x1132 /*!< Message Access Service UUID */ +#define ESP_SDP_UUID_MAP_MNS 0x1133 /*!< Message Notification Service UUID */ +#define ESP_SDP_UUID_PBAP_PSE 0x112F /*!< Phone Book Server Equipment UUID */ +#define ESP_SDP_UUID_PBAP_PCE 0x112E /*!< Phone Book Client Equipment UUID */ +#define ESP_SDP_UUID_OPP 0x1105 /*!< Object Push Profile UUID */ +#define ESP_SDP_UUID_SAP 0x112D /*!< SIM Access Profile UUID */ +#define ESP_SDP_UUID_DIP 0x1200 /*!< Device Identification Profile UUID */ + +#define ESP_SDP_BUILD_BT_UUID16(uuid16_val) \ + (esp_bt_uuid_t) { .len = ESP_UUID_LEN_16, .uuid = {.uuid16 = (uint16_t)(uuid16_val),}, } typedef enum { - ESP_SDP_SUCCESS = 0, /*!< Successful operation. */ - ESP_SDP_FAILURE, /*!< Generic failure. */ - ESP_SDP_NO_RESOURCE, /*!< No more resource */ - ESP_SDP_NEED_INIT, /*!< SDP module shall init first */ - ESP_SDP_NEED_DEINIT, /*!< SDP module shall deinit first */ - ESP_SDP_NO_CREATE_RECORD, /*!< No record created */ + ESP_SDP_SUCCESS = 0, /*!< Successful operation. */ + ESP_SDP_FAILURE, /*!< Generic failure. */ + ESP_SDP_NO_RESOURCE, /*!< No more resource */ + ESP_SDP_NEED_INIT, /*!< SDP module shall init first */ + ESP_SDP_NEED_DEINIT, /*!< SDP module shall deinit first */ + ESP_SDP_NO_CREATE_RECORD, /*!< No record created */ } esp_sdp_status_t; /** * @brief SDP callback function events */ typedef enum { - ESP_SDP_INIT_EVT = 0, /*!< When SDP is initialized, the event comes */ - ESP_SDP_DEINIT_EVT = 1, /*!< When SDP is deinitialized, the event comes */ - ESP_SDP_SEARCH_COMP_EVT = 2, /*!< When SDP search complete, the event comes */ - ESP_SDP_CREATE_RECORD_COMP_EVT = 3, /*!< When create SDP records complete, the event comes */ - ESP_SDP_REMOVE_RECORD_COMP_EVT = 4, /*!< When remove a SDP record complete, the event comes */ + ESP_SDP_INIT_EVT = 0, /*!< When SDP is initialized, the event comes */ + ESP_SDP_DEINIT_EVT = 1, /*!< When SDP is de-initialized, the event comes */ + ESP_SDP_SEARCH_COMP_EVT = 2, /*!< When SDP search complete, the event comes */ + ESP_SDP_CREATE_RECORD_COMP_EVT = 3, /*!< When create SDP records complete, the event comes */ + ESP_SDP_REMOVE_RECORD_COMP_EVT = 4, /*!< When remove a SDP record complete, the event comes */ } esp_sdp_cb_event_t; /** * @brief SDP record type */ typedef enum { - ESP_SDP_TYPE_RAW, /*!< Used to carry raw SDP search data for unknown UUIDs */ - ESP_SDP_TYPE_MAP_MAS, /*!< Message Access Profile - Server */ - ESP_SDP_TYPE_MAP_MNS, /*!< Message Access Profile - Client (Notification Server) */ - ESP_SDP_TYPE_PBAP_PSE, /*!< Phone Book Profile - Server */ - ESP_SDP_TYPE_PBAP_PCE, /*!< Phone Book Profile - Client */ - ESP_SDP_TYPE_OPP_SERVER, /*!< Object Push Profile */ - ESP_SDP_TYPE_SAP_SERVER /*!< SIM Access Profile */ + ESP_SDP_TYPE_RAW, /*!< Used to carry raw SDP search data for unknown UUIDs */ + ESP_SDP_TYPE_MAP_MAS, /*!< Message Access Profile - Server */ + ESP_SDP_TYPE_MAP_MNS, /*!< Message Access Profile - Client (Notification Server) */ + ESP_SDP_TYPE_PBAP_PSE, /*!< Phone Book Profile - Server */ + ESP_SDP_TYPE_PBAP_PCE, /*!< Phone Book Profile - Client */ + ESP_SDP_TYPE_OPP_SERVER, /*!< Object Push Profile */ + ESP_SDP_TYPE_SAP_SERVER, /*!< SIM Access Profile */ } esp_bluetooth_sdp_types_t; /** - * @brief Some signals need additional pointers, hence we introduce a - * generic way to handle these pointers. + * @brief SDP header structure */ typedef struct bluetooth_sdp_hdr_overlay { - esp_bluetooth_sdp_types_t type; /*!< SDP type */ - esp_bt_uuid_t uuid; /*!< UUID type, include uuid and uuid length */ - uint32_t service_name_length; /*!< Service name length */ - char *service_name; /*!< service name */ - int32_t rfcomm_channel_number; /*!< rfcomm channel number, if not used set to -1*/ - int32_t l2cap_psm; /*!< l2cap psm, if not used set to -1 */ - int32_t profile_version; /*!< profile version */ - - // User pointers, only used for some signals - see esp_bluetooth_sdp_ops_record_t - int user1_ptr_len; /*!< see esp_bluetooth_sdp_ops_record_t */ - uint8_t *user1_ptr; /*!< see esp_bluetooth_sdp_ops_record_t */ - int user2_ptr_len; /*!< see esp_bluetooth_sdp_ops_record_t */ - uint8_t *user2_ptr; /*!< see esp_bluetooth_sdp_ops_record_t */ + esp_bluetooth_sdp_types_t type; /*!< SDP type */ + esp_bt_uuid_t uuid; /*!< UUID type, include uuid and uuid length, only needed to be set for RAW record creation */ + uint32_t service_name_length; /*!< Service name length */ + char *service_name; /*!< Service name */ + int32_t rfcomm_channel_number; /*!< RFCOMM channel number, if not used set to -1*/ + int32_t l2cap_psm; /*!< L2CAP psm, if not used set to -1 */ + int32_t profile_version; /*!< Profile version */ + int user1_ptr_len; /*!< User data1 length, only used for searching RAW record */ + uint8_t *user1_ptr; /*!< User data1 pointer to the raw SDP response data, only used for searching RAW record */ + int user2_ptr_len; /*!< User data2 length, only used for searching RAW record */ + uint8_t *user2_ptr; /*!< User data2 pointer, only used for searching RAW record */ } esp_bluetooth_sdp_hdr_overlay_t; /** * @brief Message Access Profile - Server parameters */ typedef struct bluetooth_sdp_mas_record { - esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ - uint32_t mas_instance_id; /*!< MAS Instance ID */ - uint32_t supported_features; /*!< Map supported features */ - uint32_t supported_message_types; /*!< Supported message types */ + esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ + uint32_t mas_instance_id; /*!< MAS Instance ID */ + uint32_t supported_features; /*!< Map supported features */ + uint32_t supported_message_types; /*!< Supported message types */ } esp_bluetooth_sdp_mas_record_t; /** * @brief Message Access Profile - Client (Notification Server) parameters */ typedef struct bluetooth_sdp_mns_record { - esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ - uint32_t supported_features; /*!< Supported features */ + esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ + uint32_t supported_features; /*!< Supported features */ } esp_bluetooth_sdp_mns_record_t; /** * @brief Phone Book Profile - Server parameters */ typedef struct bluetooth_sdp_pse_record { - esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ - uint32_t supported_features; /*!< Pbap Supported Features */ - uint32_t supported_repositories; /*!< Supported Repositories */ + esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ + uint32_t supported_features; /*!< PBAP Supported Features */ + uint32_t supported_repositories; /*!< Supported Repositories */ } esp_bluetooth_sdp_pse_record_t; /** * @brief Phone Book Profile - Client parameters */ typedef struct bluetooth_sdp_pce_record { - esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ + esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ } esp_bluetooth_sdp_pce_record_t; /** * @brief Object Push Profile parameters */ typedef struct bluetooth_sdp_ops_record { - esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ - int supported_formats_list_len; /*!< Supported formats list length */ - uint8_t supported_formats_list[SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH]; /*!< Supported formats list */ + esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ + int supported_formats_list_len; /*!< Supported formats list length */ + uint8_t supported_formats_list[SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH]; /*!< Supported formats list */ } esp_bluetooth_sdp_ops_record_t; /** * @brief SIM Access Profile parameters */ typedef struct bluetooth_sdp_sap_record { - esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ + esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ } esp_bluetooth_sdp_sap_record_t; /** * @brief SDP record parameters union */ typedef union { - esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ - esp_bluetooth_sdp_mas_record_t mas; /*!< Message Access Profile - Server */ - esp_bluetooth_sdp_mns_record_t mns; /*!< Message Access Profile - Client (Notification Server) */ - esp_bluetooth_sdp_pse_record_t pse; /*!< Phone Book Profile - Server */ - esp_bluetooth_sdp_pce_record_t pce; /*!< Phone Book Profile - Client */ - esp_bluetooth_sdp_ops_record_t ops; /*!< Object Push Profile */ - esp_bluetooth_sdp_sap_record_t sap; /*!< SIM Access Profile */ + esp_bluetooth_sdp_hdr_overlay_t hdr; /*!< General info */ + esp_bluetooth_sdp_mas_record_t mas; /*!< Message Access Profile - Server */ + esp_bluetooth_sdp_mns_record_t mns; /*!< Message Access Profile - Client (Notification Server) */ + esp_bluetooth_sdp_pse_record_t pse; /*!< Phone Book Profile - Server */ + esp_bluetooth_sdp_pce_record_t pce; /*!< Phone Book Profile - Client */ + esp_bluetooth_sdp_ops_record_t ops; /*!< Object Push Profile */ + esp_bluetooth_sdp_sap_record_t sap; /*!< SIM Access Profile */ } esp_bluetooth_sdp_record_t; /** @@ -141,44 +149,43 @@ typedef union { * @brief ESP_SDP_INIT_EVT */ struct sdp_init_evt_param { - esp_sdp_status_t status; /*!< status */ - } init; /*!< SDP callback param of ESP_SDP_INIT_EVT */ + esp_sdp_status_t status; /*!< Status */ + } init; /*!< SDP callback param of ESP_SDP_INIT_EVT */ /** * @brief ESP_SDP_DEINIT_EVT */ struct sdp_deinit_evt_param { - esp_sdp_status_t status; /*!< status */ - } deinit; /*!< SDP callback param of ESP_SDP_DEINIT_EVT */ + esp_sdp_status_t status; /*!< Status */ + } deinit; /*!< SDP callback param of ESP_SDP_DEINIT_EVT */ /** * @brief ESP_SDP_SEARCH_COMP_EVT */ struct sdp_search_evt_param { - esp_sdp_status_t status; /*!< status */ - esp_bd_addr_t remote_addr; /*!< remote device address */ - esp_bt_uuid_t sdp_uuid; /*!< service uuid */ - int record_count; /*!< Number of SDP records */ - esp_bluetooth_sdp_record_t *records;/*!< SDP records */ - } search; /*!< SDP callback param of ESP_SDP_SEARCH_COMP_EVT */ + esp_sdp_status_t status; /*!< Status */ + esp_bd_addr_t remote_addr; /*!< Remote device address */ + esp_bt_uuid_t sdp_uuid; /*!< Service uuid */ + int record_count; /*!< Number of SDP records */ + esp_bluetooth_sdp_record_t *records; /*!< SDP records */ + } search; /*!< SDP callback param of ESP_SDP_SEARCH_COMP_EVT */ /** * @brief ESP_SDP_CREATE_RECORD_COMP_EVT */ - struct sdp_crate_record_evt_param { - esp_sdp_status_t status; /*!< status */ - int record_handle; /*!< SDP record handle */ - } create_record; /*!< SDP callback param of ESP_SDP_CREATE_RECORD_COMP_EVT */ + struct sdp_create_record_evt_param { + esp_sdp_status_t status; /*!< Status */ + int record_handle; /*!< SDP record handle */ + } create_record; /*!< SDP callback param of ESP_SDP_CREATE_RECORD_COMP_EVT */ /** * @brief ESP_SDP_REMOVE_RECORD_COMP_EVT */ struct sdp_remove_record_evt_param { - esp_sdp_status_t status; /*!< status */ - } remove_record; /*!< SDP callback param of ESP_SDP_REMOVE_RECORD_COMP_EVT */ - -} esp_sdp_cb_param_t; /*!< SDP callback parameter union type */ + esp_sdp_status_t status; /*!< Status */ + } remove_record; /*!< SDP callback param of ESP_SDP_REMOVE_RECORD_COMP_EVT */ +} esp_sdp_cb_param_t; /** * @brief SDP callback function type. diff --git a/components/bt/host/bluedroid/bta/av/bta_av_act.c b/components/bt/host/bluedroid/bta/av/bta_av_act.c index 13a5750713..431b4d5aa0 100644 --- a/components/bt/host/bluedroid/bta/av/bta_av_act.c +++ b/components/bt/host/bluedroid/bta/av/bta_av_act.c @@ -127,9 +127,6 @@ void bta_av_del_rc(tBTA_AV_RCB *p_rcb) } /* else ACP && connected. do not clear the handle yet */ AVRC_Close(rc_handle); - if (rc_handle == bta_av_cb.rc_acp_handle) { - bta_av_cb.rc_acp_handle = BTA_AV_RC_HANDLE_NONE; - } APPL_TRACE_EVENT("end del_rc handle: %d status=0x%x, rc_acp_handle:%d, lidx:%d", p_rcb->handle, p_rcb->status, bta_av_cb.rc_acp_handle, p_rcb->lidx); } @@ -302,7 +299,7 @@ UINT8 bta_av_rc_create(tBTA_AV_CB *p_cb, UINT8 role, UINT8 shdl, UINT8 lidx) bda = p_scb->peer_addr; status = BTA_AV_RC_ROLE_INT; } else { - if ((p_rcb = bta_av_get_rcb_by_shdl(shdl)) != NULL ) { + if (shdl != 0 && ((p_rcb = bta_av_get_rcb_by_shdl(shdl)) != NULL)) { APPL_TRACE_ERROR("bta_av_rc_create ACP handle exist for shdl:%d", shdl); return p_rcb->handle; } @@ -1143,7 +1140,7 @@ void bta_av_conn_chg(tBTA_AV_DATA *p_data) p_data->conn_chg.peer_addr[5]); if (p_lcb_rc->conn_msk && bdcmp(p_lcb_rc->addr, p_data->conn_chg.peer_addr) == 0) { /* AVRCP is already connected. - * need to update the association betwen SCB and RCB */ + * need to update the association between SCB and RCB */ p_lcb_rc->conn_msk = 0; /* indicate RC ONLY is not connected */ p_lcb_rc->lidx = 0; p_scb->rc_handle = p_cb->rc_acp_handle; @@ -1636,6 +1633,8 @@ void bta_av_rc_disc_done(tBTA_AV_DATA *p_data) } } else { p_cb->rcb[rc_handle].peer_features = peer_features; + p_cb->rcb[rc_handle].peer_ct_features = peer_ct_features; + p_cb->rcb[rc_handle].peer_tg_features = peer_tg_features; rc_feat.rc_handle = rc_handle; rc_feat.peer_features = peer_features; rc_feat.peer_ct_features = peer_ct_features; @@ -1711,7 +1710,8 @@ void bta_av_rc_closed(tBTA_AV_DATA *p_data) bta_av_del_rc(p_rcb); /* if the AVRCP is no longer listening, create the listening channel */ - if (bta_av_cb.rc_acp_handle == BTA_AV_RC_HANDLE_NONE && bta_av_cb.features & BTA_AV_FEAT_RCTG) { + if (bta_av_cb.rc_acp_handle == p_msg->handle && bta_av_cb.features & BTA_AV_FEAT_RCTG) { + bta_av_cb.rc_acp_handle = BTA_AV_RC_HANDLE_NONE; bta_av_rc_create(&bta_av_cb, AVCT_ACP, 0, BTA_AV_NUM_LINKS + 1); } } diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c index 95be58bbb2..8d88f98af3 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c @@ -5762,6 +5762,12 @@ void bta_dm_ble_gap_set_privacy_mode(tBTA_DM_MSG *p_data) p_data->ble_set_privacy_mode.privacy_mode, p_data->ble_set_privacy_mode.p_cback); } +void bta_dm_ble_gap_set_csa_support(tBTA_DM_MSG *p_data) +{ + APPL_TRACE_API("%s, csa_select = %d", __func__, p_data->ble_set_csa_support.csa_select); + BTM_BleSetCsaSupport(p_data->ble_set_csa_support.csa_select, p_data->ble_set_csa_support.p_cback); +} + #if (BLE_50_FEATURE_SUPPORT == TRUE) void bta_dm_ble_gap_dtm_enhance_tx_start(tBTA_DM_MSG *p_data) { @@ -5946,7 +5952,7 @@ void bta_dm_ble_gap_set_prefer_ext_conn_params(tBTA_DM_MSG *p_data) sizeof(tBTA_DM_BLE_CONN_PARAMS)); } - if (conn_params.phy_mask & BTAS_PHY_CODED_MASK) { + if (conn_params.phy_mask & BTA_PHY_CODED_MASK) { memcpy(&conn_params.phy_coded_conn_params, &p_data->ble_set_per_ext_conn_params.phy_coded_conn_params, sizeof(tBTA_DM_BLE_CONN_PARAMS)); } @@ -6570,7 +6576,9 @@ void btm_dm_start_gatt_discovery (BD_ADDR bd_addr) btm_dm_start_disc_gatt_services(bta_dm_search_cb.conn_id); } else { //TODO need to add addr_type in future - BTA_GATTC_Open(bta_dm_search_cb.client_if, bd_addr, BLE_ADDR_UNKNOWN_TYPE, TRUE, BTA_GATT_TRANSPORT_LE, FALSE); + BTA_GATTC_Enh_Open(bta_dm_search_cb.client_if, bd_addr, BLE_ADDR_UNKNOWN_TYPE, TRUE, + BTA_GATT_TRANSPORT_LE, FALSE, BLE_ADDR_UNKNOWN_TYPE, 0, NULL, NULL, NULL); + } } #endif /* #if (GATTC_INCLUDED == TRUE) */ diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_api.c b/components/bt/host/bluedroid/bta/dm/bta_dm_api.c index 83082e4b46..2a5421671b 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_api.c @@ -29,6 +29,7 @@ #include "stack/btm_api.h" #include "btm_int.h" #include +#include #include "bta/utl.h" #include "osi/allocator.h" @@ -991,22 +992,67 @@ UINT16 BTA_DmGetConnectionState( BD_ADDR bd_addr ) tBTA_STATUS BTA_DmSetLocalDiRecord( tBTA_DI_RECORD *p_device_info, UINT32 *p_handle ) { - tBTA_STATUS status = BTA_FAILURE; + tBTA_STATUS status = BTA_FAILURE; if (bta_dm_di_cb.di_num < BTA_DI_NUM_MAX) { if (SDP_SetLocalDiRecord((tSDP_DI_RECORD *)p_device_info, p_handle) == SDP_SUCCESS) { if (!p_device_info->primary_record) { - bta_dm_di_cb.di_handle[bta_dm_di_cb.di_num] = *p_handle; - bta_dm_di_cb.di_num ++; + for (uint8_t i = 1; i < BTA_DI_NUM_MAX; i++) { + if (!bta_dm_di_cb.di_handle[i]) { + bta_dm_di_cb.di_handle[i] = *p_handle; + break; + } + } + bta_dm_di_cb.di_num++; + } else if (!bta_dm_di_cb.di_handle[0]) { + bta_dm_di_cb.di_handle[0] = *p_handle; + bta_dm_di_cb.di_num++; + } else { + assert(bta_dm_di_cb.di_handle[0] == (*p_handle)); + } + + if (!bta_dm_di_cb.uuid_added) { + bta_sys_add_uuid(UUID_SERVCLASS_PNP_INFORMATION); + bta_dm_di_cb.uuid_added = TRUE; } - bta_sys_add_uuid(UUID_SERVCLASS_PNP_INFORMATION); - status = BTA_SUCCESS; + status = BTA_SUCCESS; } } return status; } + +/******************************************************************************* +** +** Function BTA_DmRemoveLocalDiRecord +** +** Description This function removes a DI record from the local SDP database. +** +** Returns BTA_SUCCESS if record is removed successfully, otherwise error code. +** +*******************************************************************************/ +tBTA_STATUS BTA_DmRemoveLocalDiRecord(UINT32 handle) +{ + tBTA_STATUS status = BTA_FAILURE; + + for (uint8_t i = 0; i < BTA_DI_NUM_MAX; i++) { + if (bta_dm_di_cb.di_handle[i] == handle) { + if (SDP_DeleteRecord(handle)) { + bta_dm_di_cb.di_handle[i] = 0; + bta_dm_di_cb.di_num--; + status = BTA_SUCCESS; + break; + } + } + } + + if (bta_dm_di_cb.di_num == 0 && bta_dm_di_cb.uuid_added) { + bta_sys_remove_uuid(UUID_SERVCLASS_PNP_INFORMATION); + } + + return status; +} #endif ///SDP_INCLUDED == TRUE /******************************************************************************* ** @@ -2884,6 +2930,19 @@ void BTA_DmClearRandAddress(void) } } +void BTA_DmBleGapSetCsaSupport(uint8_t csa_select, tBTA_SET_CSA_SUPPORT_CMPL_CBACK *p_callback) +{ + tBTA_DM_API_BLE_SET_CSA_SUPPORT *p_msg; + + if ((p_msg = (tBTA_DM_API_BLE_SET_CSA_SUPPORT *)osi_malloc(sizeof(tBTA_DM_API_BLE_SET_CSA_SUPPORT))) + != NULL) { + p_msg->hdr.event = BTA_DM_API_BLE_SET_CSA_SUPPORT_EVT; + p_msg->csa_select = csa_select; + p_msg->p_cback = p_callback; + bta_sys_sendmsg(p_msg); + } +} + /******************************************************************************* ** ** Function BTA_VendorInit diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_cfg.c b/components/bt/host/bluedroid/bta/dm/bta_dm_cfg.c index a4792ce846..81bbd4667f 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_cfg.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_cfg.c @@ -151,13 +151,13 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = { (BTA_DM_PM_SSR2), /* the SSR entry */ #endif { - {{BTA_DM_PM_SNIFF_A2DP_IDX, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */ + {{BTA_DM_PM_SNIFF_AG_OPEN_IDX, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */ {{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */ {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */ {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */ {{BTA_DM_PM_SNIFF_SCO_OPEN_IDX, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open, active */ - {{BTA_DM_PM_SNIFF_A2DP_IDX, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close sniff */ - {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */ + {{BTA_DM_PM_SNIFF_SCO_CLOSE_IDX, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close sniff */ + {{BTA_DM_PM_SNIFF_AG_IDLE_IDX, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */ {{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */ {{BTA_DM_PM_RETRY, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */ } @@ -231,9 +231,9 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = { {{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */ {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */ {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */ - {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open, active */ - {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close sniff */ - {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */ + {{BTA_DM_PM_SNIFF3, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open, active */ + {{BTA_DM_PM_SNIFF, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close sniff */ + {{BTA_DM_PM_SNIFF, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */ {{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */ {{BTA_DM_PM_RETRY, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */ } @@ -409,7 +409,7 @@ tBTA_DM_SSR_SPEC bta_dm_ssr_spec[] = { /*max_lat, min_rmt_to, min_loc_to*/ {0, 0, 0}, /* BTA_DM_PM_SSR0 - do not use SSR */ {0, 0, 2}, /* BTA_DM_PM_SSR1 - HH, can NOT share entry with any other profile, - seting default max latency and min remote timeout as 0, + setting default max latency and min remote timeout as 0, and always read individual device preference from HH module */ {1200, 2, 2}, /* BTA_DM_PM_SSR2 - others (as long as sniff is allowed)*/ {360, 160, 1600} /* BTA_DM_PM_SSR3 - HD */ @@ -466,7 +466,7 @@ tBTA_DM_EIR_CONF bta_dm_eir_cfg = { { /* mask of UUID list in EIR */ 0xFFFFFFFF, /* LSB is the first UUID of the first 32 UUIDs in BTM_EIR_UUID_LKUP_TBL */ 0xFFFFFFFF /* LSB is the first UUID of the next 32 UUIDs in BTM_EIR_UUID_LKUP_TBL */ - /* BTM_EIR_UUID_LKUP_TBL can be overrided */ + /* BTM_EIR_UUID_LKUP_TBL can be overridden */ }, #endif // BTA_EIR_CANNED_UUID_LIST FALSE, /* Not included TX power*/ diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_main.c b/components/bt/host/bluedroid/bta/dm/bta_dm_main.c index 4bbf06cb16..fb479fabc7 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_main.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_main.c @@ -222,6 +222,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = { bta_dm_ble_gap_set_rpa_timeout, /* BTA_DM_API_SET_RPA_TIMEOUT_EVT */ bta_dm_ble_gap_add_dev_to_resolving_list, /* BTA_DM_API_ADD_DEV_TO_RESOLVING_LIST_EVT */ bta_dm_ble_gap_set_privacy_mode, /* BTA_DM_API_SET_PRIVACY_MODE_EVT */ + bta_dm_ble_gap_set_csa_support, /* BTA_DM_API_BLE_SET_CSA_SUPPORT_EVT */ #endif }; diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_pm.c b/components/bt/host/bluedroid/bta/dm/bta_dm_pm.c index 149b4fac65..8167ddf9a6 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_pm.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_pm.c @@ -75,7 +75,7 @@ void bta_dm_init_pm(void) { memset(&bta_dm_conn_srvcs, 0x00, sizeof(bta_dm_conn_srvcs)); - /* if there are no power manger entries, so not register */ + /* if there are no power manager entries, so not register */ if (p_bta_dm_pm_cfg[0].app_id != 0) { bta_sys_pm_register((tBTA_SYS_CONN_CBACK *)bta_dm_pm_cback); @@ -694,9 +694,9 @@ static BOOLEAN bta_dm_pm_sniff(tBTA_DM_PEER_DEVICE *p_peer_dev, UINT8 index) #endif { #if (BTM_SSR_INCLUDED == TRUE) - /* Dont initiate Sniff if controller has alreay accepted + /* Dont initiate Sniff if controller has already accepted * remote sniff params. This avoid sniff loop issue with - * some agrresive headsets who use sniff latencies more than + * some aggressive headsets who use sniff latencies more than * DUT supported range of Sniff intervals.*/ if ((mode == BTM_PM_MD_SNIFF) && (p_peer_dev->info & BTA_DM_DI_ACP_SNIFF)) { APPL_TRACE_DEBUG("%s: already in remote initiate sniff", __func__); @@ -917,7 +917,7 @@ void bta_dm_pm_btm_status(tBTA_DM_MSG *p_data) } else { #if (BTM_SSR_INCLUDED == TRUE) if (p_dev->prev_low) { - /* need to send the SSR paramaters to controller again */ + /* need to send the SSR parameters to controller again */ bta_dm_pm_ssr(p_dev->peer_bdaddr); } p_dev->prev_low = BTM_PM_STS_ACTIVE; @@ -980,6 +980,7 @@ void bta_dm_pm_btm_status(tBTA_DM_MSG *p_data) ) { tBTA_DM_SEC conn; conn.mode_chg.mode = p_data->pm_status.status; + conn.mode_chg.interval = p_data->pm_status.value; bdcpy(conn.mode_chg.bd_addr, p_data->pm_status.bd_addr); bta_dm_cb.p_sec_cback(BTA_DM_PM_MODE_CHG_EVT, (tBTA_DM_SEC *)&conn); } diff --git a/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h b/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h index 35ac3c3912..9b643aa4a5 100644 --- a/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h +++ b/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h @@ -218,6 +218,7 @@ enum { BTA_DM_API_SET_RPA_TIMEOUT_EVT, BTA_DM_API_ADD_DEV_TO_RESOLVING_LIST_EVT, BTA_DM_API_SET_PRIVACY_MODE_EVT, + BTA_DM_API_BLE_SET_CSA_SUPPORT_EVT, #endif BTA_DM_MAX_EVT }; @@ -918,6 +919,12 @@ typedef struct { tBTA_SET_PRIVACY_MODE_CMPL_CBACK *p_cback; } tBTA_DM_API_SET_PRIVACY_MODE; +typedef struct { + BT_HDR hdr; + UINT8 csa_select; + tBTA_SET_CSA_SUPPORT_CMPL_CBACK *p_cback; +} tBTA_DM_API_BLE_SET_CSA_SUPPORT; + #endif /* BLE_INCLUDED */ /* data type for BTA_DM_API_REMOVE_ACL_EVT */ @@ -992,7 +999,7 @@ typedef struct { #define BTA_PHY_1M_MASK (1 << 0) #define BTA_PHY_2M_MASK (1 << 1) -#define BTAS_PHY_CODED_MASK (1 << 2) +#define BTA_PHY_CODED_MASK (1 << 2) typedef struct { BT_HDR hdr; BD_ADDR bd_addr; @@ -1316,6 +1323,7 @@ typedef union { tBTA_DM_API_BLE_DTM_STOP dtm_stop; tBTA_DM_API_CLEAR_ADV ble_clear_adv; tBTA_DM_API_SET_PRIVACY_MODE ble_set_privacy_mode; + tBTA_DM_API_BLE_SET_CSA_SUPPORT ble_set_csa_support; #endif tBTA_DM_API_REMOVE_ACL remove_acl; @@ -1541,6 +1549,7 @@ typedef struct { #if (SDP_INCLUDED == TRUE) tSDP_DISCOVERY_DB *p_di_db; /* pointer to the DI discovery database */ #endif ///SDP_INCLUDED == TRUE + BOOLEAN uuid_added; UINT8 di_num; /* total local DI record number */ UINT32 di_handle[BTA_DI_NUM_MAX]; /* local DI record handle, the first one is primary record */ } tBTA_DM_DI_CB; @@ -1759,6 +1768,7 @@ extern void bta_dm_ble_gap_clear_adv(tBTA_DM_MSG *p_data); extern void bta_dm_ble_gap_set_rpa_timeout(tBTA_DM_MSG *p_data); extern void bta_dm_ble_gap_add_dev_to_resolving_list(tBTA_DM_MSG *p_data); extern void bta_dm_ble_gap_set_privacy_mode(tBTA_DM_MSG *p_data); +extern void bta_dm_ble_gap_set_csa_support(tBTA_DM_MSG *p_data); #if (BLE_50_FEATURE_SUPPORT == TRUE) extern void bta_dm_ble_gap_dtm_enhance_tx_start(tBTA_DM_MSG *p_data); extern void bta_dm_ble_gap_dtm_enhance_rx_start(tBTA_DM_MSG *p_data); diff --git a/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c b/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c index 543b9b04bf..ee096928a2 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c @@ -36,6 +36,7 @@ #include "osi/allocator.h" #include "osi/mutex.h" #include "bta_hh_int.h" +#include "btm_int.h" #if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE) #include "bta_hh_int.h" @@ -70,6 +71,7 @@ static void bta_gattc_req_cback (UINT16 conn_id, UINT32 trans_id, tGATTS_REQ_TYP static tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_id, BD_ADDR remote_bda); extern void btc_gattc_congest_callback(tBTA_GATTC *param); +extern uint32_t BTM_BleUpdateOwnType(uint8_t *own_bda_type, tBTM_START_ADV_CMPL_CBACK *cb); static const tGATT_CBACK bta_gattc_cl_cback = { bta_gattc_conn_cback, @@ -336,6 +338,10 @@ void bta_gattc_process_api_open (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg) UNUSED(p_cb); if (p_clreg != NULL) { + if (p_msg->api_conn.own_addr_type <= BLE_ADDR_TYPE_MAX) { + // update own address type for creating connection + BTM_BleUpdateOwnType(&p_msg->api_conn.own_addr_type, NULL); + } if (p_msg->api_conn.is_direct) { if ((p_clcb = bta_gattc_find_alloc_clcb(p_msg->api_conn.client_if, p_msg->api_conn.remote_bda, @@ -503,6 +509,7 @@ void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data) tBTA_GATTC_DATA gattc_data; BOOLEAN found_app = FALSE; tGATT_TCB *p_tcb; + tBTM_SEC_DEV_REC *p_dev_rec = NULL; if (!p_clcb || !p_data) { return; @@ -512,6 +519,33 @@ void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data) if(p_tcb) { found_app = gatt_find_specific_app_in_hold_link(p_tcb, p_clcb->p_rcb->client_if); } + + if (p_data->api_conn.phy_mask) { + p_dev_rec = btm_find_or_alloc_dev(p_data->api_conn.remote_bda); + if (p_dev_rec) { + if (p_data->api_conn.is_aux) { +#if (BLE_50_FEATURE_SUPPORT == TRUE) + p_dev_rec->ext_conn_params.phy_mask = p_data->api_conn.phy_mask; + if (p_data->api_conn.phy_mask & BTA_BLE_PHY_1M_MASK) { + memcpy(&p_dev_rec->ext_conn_params.phy_1m_conn_params, &p_data->api_conn.phy_1m_conn_params, sizeof(tBTA_BLE_CONN_PARAMS)); + } + if (p_data->api_conn.phy_mask & BTA_BLE_PHY_2M_MASK) { + memcpy(&p_dev_rec->ext_conn_params.phy_2m_conn_params, &p_data->api_conn.phy_2m_conn_params, sizeof(tBTA_BLE_CONN_PARAMS)); + } + if (p_data->api_conn.phy_mask & BTA_BLE_PHY_CODED_MASK) { + memcpy(&p_dev_rec->ext_conn_params.phy_coded_conn_params, &p_data->api_conn.phy_coded_conn_params, sizeof(tBTA_BLE_CONN_PARAMS)); + } +#endif + } else { + if (p_data->api_conn.phy_mask & BTA_BLE_PHY_1M_MASK) { + memcpy(&p_dev_rec->conn_params, &p_data->api_conn.phy_1m_conn_params, sizeof(tBTA_BLE_CONN_PARAMS)); + } + } + } else { + APPL_TRACE_ERROR("Unknown Device, setting rejected"); + } + } + /* open/hold a connection */ if (!GATT_Connect(p_clcb->p_rcb->client_if, p_data->api_conn.remote_bda, p_data->api_conn.remote_addr_type, TRUE, p_data->api_conn.transport, p_data->api_conn.is_aux)) { @@ -1807,8 +1841,8 @@ static void bta_gattc_enc_cmpl_cback(tGATT_IF gattc_if, BD_ADDR bda) *******************************************************************************/ void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg) { - tBTA_GATTC_SERV *p_srvc_cb = bta_gattc_find_srvr_cache(p_msg->api_conn.remote_bda); - tBTA_GATTC_CLCB *p_clcb = &bta_gattc_cb.clcb[0]; + tBTA_GATTC_SERV *p_srvc_cb = bta_gattc_find_srvr_cache(p_msg->api_refresh.remote_bda); + tBTA_GATTC_CLCB *p_clcb = &bta_gattc_cb.clcb[0]; BOOLEAN found = FALSE; UINT8 i; UNUSED(p_cb); @@ -1928,7 +1962,7 @@ void bta_gattc_process_api_cache_get_addr_list(tBTA_GATTC_CB *p_cb, tBTA_GATTC_D *******************************************************************************/ void bta_gattc_process_api_cache_clean(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg) { - tBTA_GATTC_SERV *p_srvc_cb = bta_gattc_find_srvr_cache(p_msg->api_conn.remote_bda); + tBTA_GATTC_SERV *p_srvc_cb = bta_gattc_find_srvr_cache(p_msg->api_clean.remote_bda); UNUSED(p_cb); if (p_srvc_cb != NULL && p_srvc_cb->p_srvc_cache != NULL) { diff --git a/components/bt/host/bluedroid/bta/gatt/bta_gattc_api.c b/components/bt/host/bluedroid/bta/gatt/bta_gattc_api.c index 6e2586d69c..20cff5255a 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gattc_api.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gattc_api.c @@ -128,7 +128,7 @@ void BTA_GATTC_AppDeregister(tBTA_GATTC_IF client_if) /******************************************************************************* ** -** Function BTA_GATTC_Open +** Function BTA_GATTC_Enh_Open ** ** Description Open a direct connection or add a background auto connection ** bd address @@ -142,8 +142,10 @@ void BTA_GATTC_AppDeregister(tBTA_GATTC_IF client_if) ** Returns void ** *******************************************************************************/ -void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE remote_addr_type, - BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport, BOOLEAN is_aux) +void BTA_GATTC_Enh_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE remote_addr_type, + BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport, BOOLEAN is_aux, tBTA_ADDR_TYPE own_addr_type, + UINT8 phy_mask, tBTA_BLE_CONN_PARAMS *phy_1m_conn_params, tBTA_BLE_CONN_PARAMS *phy_2m_conn_params, + tBTA_BLE_CONN_PARAMS *phy_coded_conn_params) { tBTA_GATTC_API_OPEN *p_buf; @@ -155,8 +157,18 @@ void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE p_buf->transport = transport; p_buf->is_aux = is_aux; p_buf->remote_addr_type = remote_addr_type; + p_buf->own_addr_type = own_addr_type; + p_buf->phy_mask = phy_mask; memcpy(p_buf->remote_bda, remote_bda, BD_ADDR_LEN); - + if ((phy_mask & BTA_BLE_PHY_1M_MASK) && phy_1m_conn_params) { + memcpy(&p_buf->phy_1m_conn_params, phy_1m_conn_params, sizeof(tBTA_BLE_CONN_PARAMS)); + } + if ((phy_mask & BTA_BLE_PHY_2M_MASK) && phy_2m_conn_params) { + memcpy(&p_buf->phy_2m_conn_params, phy_2m_conn_params, sizeof(tBTA_BLE_CONN_PARAMS)); + } + if ((phy_mask & BTA_BLE_PHY_CODED_MASK) && phy_coded_conn_params) { + memcpy(&p_buf->phy_coded_conn_params, phy_coded_conn_params, sizeof(tBTA_BLE_CONN_PARAMS)); + } bta_sys_sendmsg(p_buf); } @@ -472,7 +484,7 @@ void BTA_GATTC_GetGattDb(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle ** Description This function is called to read a characteristics value ** ** Parameters conn_id - connection ID. -** handle - characteritic handle to read. +** handle - characteristic handle to read. ** ** Returns None ** @@ -607,7 +619,7 @@ void BTA_GATTC_ReadMultipleVariable(UINT16 conn_id, tBTA_GATTC_MULTI *p_read_mul ** ** Parameters conn_id - connection ID. ** s_handle - start handle. -** e_handle - end hanle +** e_handle - end handle ** uuid - The attribute UUID. ** ** Returns None @@ -687,7 +699,7 @@ void BTA_GATTC_WriteCharValue ( UINT16 conn_id, ** Description This function is called to write descriptor value. ** ** Parameters conn_id - connection ID -** handle - descriptor hadle to write. +** handle - descriptor handle to write. ** write_type - write type. ** p_value - the value to be written. ** @@ -738,7 +750,7 @@ void BTA_GATTC_WriteCharDescr (UINT16 conn_id, ** Description This function is called to prepare write a characteristic value. ** ** Parameters conn_id - connection ID. -** p_char_id - GATT characteritic ID of the service. +** p_char_id - GATT characteristic ID of the service. ** offset - offset of the write value. ** len: length of the data to be written. ** p_value - the value to be written. @@ -781,7 +793,7 @@ void BTA_GATTC_PrepareWrite (UINT16 conn_id, UINT16 handle, ** Description This function is called to prepare write a characteristic descriptor value. ** ** Parameters conn_id - connection ID. -** p_char_descr_id - GATT characteritic descriptor ID of the service. +** p_char_descr_id - GATT characteristic descriptor ID of the service. ** offset - offset of the write value. ** len: length of the data to be written. ** p_value - the value to be written. @@ -1010,9 +1022,9 @@ void BTA_GATTC_Refresh(BD_ADDR remote_bda, bool erase_flash) if(bta_sys_is_register(BTA_ID_GATTC) == FALSE) { return; } - tBTA_GATTC_API_OPEN *p_buf; + tBTA_GATTC_API_CACHE_REFRESH *p_buf; - if ((p_buf = (tBTA_GATTC_API_OPEN *) osi_malloc(sizeof(tBTA_GATTC_API_OPEN))) != NULL) { + if ((p_buf = (tBTA_GATTC_API_CACHE_REFRESH *) osi_malloc(sizeof(tBTA_GATTC_API_CACHE_REFRESH))) != NULL) { p_buf->hdr.event = BTA_GATTC_API_REFRESH_EVT; memcpy(p_buf->remote_bda, remote_bda, BD_ADDR_LEN); @@ -1068,9 +1080,9 @@ void BTA_GATTC_Clean(BD_ADDR remote_bda) bta_gattc_cache_reset(remote_bda); #endif - tBTA_GATTC_API_OPEN *p_buf; + tBTA_GATTC_API_CACHE_CLEAN *p_buf; - if ((p_buf = (tBTA_GATTC_API_OPEN *) osi_malloc(sizeof(tBTA_GATTC_API_OPEN))) != NULL) { + if ((p_buf = (tBTA_GATTC_API_CACHE_CLEAN *) osi_malloc(sizeof(tBTA_GATTC_API_CACHE_CLEAN))) != NULL) { p_buf->hdr.event = BTA_GATTC_API_CACHE_CLEAN_EVT; memcpy(p_buf->remote_bda, remote_bda, BD_ADDR_LEN); diff --git a/components/bt/host/bluedroid/bta/gatt/bta_gattc_main.c b/components/bt/host/bluedroid/bta/gatt/bta_gattc_main.c index 0cc55995a5..47f210c872 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gattc_main.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gattc_main.c @@ -538,9 +538,14 @@ void bta_gattc_deinit(void) uint8_t bta_gattc_cl_rcb_active_count(void) { uint8_t count = 0; + uint8_t dm_gattc_uuid[16]; + + // When SDP is included, Bluedroid stack will register the DM GATTC application + memset(dm_gattc_uuid, 0x87, 16); for (uint8_t i = 0; i < BTA_GATTC_CL_MAX; i ++) { - if (bta_gattc_cb.cl_rcb[i].in_use) { + if (bta_gattc_cb.cl_rcb[i].in_use && + memcmp(bta_gattc_cb.cl_rcb[i].app_uuid.uu.uuid128, dm_gattc_uuid, 16)) { count++; } } diff --git a/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h b/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h index 108358ca63..aa404e55a2 100644 --- a/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h +++ b/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h @@ -110,7 +110,7 @@ typedef enum { #define BTA_GATTC_WRITE_PREPARE GATT_WRITE_PREPARE #define BTA_GATTC_INVALID_HANDLE 0 -/* internal strucutre for GATTC register API */ +/* internal structure for GATTC register API */ typedef struct { BT_HDR hdr; tBT_UUID app_uuid; @@ -133,9 +133,20 @@ typedef struct { BOOLEAN is_direct; BOOLEAN is_aux; tBTA_TRANSPORT transport; + tBTA_ADDR_TYPE own_addr_type; + UINT8 phy_mask; + tBTA_BLE_CONN_PARAMS phy_1m_conn_params; + tBTA_BLE_CONN_PARAMS phy_2m_conn_params; + tBTA_BLE_CONN_PARAMS phy_coded_conn_params; } tBTA_GATTC_API_OPEN; -typedef tBTA_GATTC_API_OPEN tBTA_GATTC_API_CANCEL_OPEN; +typedef struct { + BT_HDR hdr; + BD_ADDR remote_bda; + tBTA_ADDR_TYPE remote_addr_type; + tBTA_GATTC_IF client_if; + BOOLEAN is_direct; +} tBTA_GATTC_API_CANCEL_OPEN; typedef struct { BT_HDR hdr; @@ -202,6 +213,11 @@ typedef struct { BT_HDR hdr; } tBTA_GATTC_API_CFG_MTU; +typedef struct { + BT_HDR hdr; + BD_ADDR remote_bda; +} tBTA_GATTC_API_CACHE_REFRESH; + typedef struct { BT_HDR hdr; tBTA_GATTC_IF client_if; @@ -215,6 +231,11 @@ typedef struct { tBTA_GATTC_IF client_if; } tBTA_GATTC_API_GET_ADDR; +typedef struct { + BT_HDR hdr; + BD_ADDR remote_bda; +} tBTA_GATTC_API_CACHE_CLEAN; + typedef struct { BT_HDR hdr; BD_ADDR remote_bda; @@ -247,8 +268,10 @@ typedef union { tBTA_GATTC_API_EXEC api_exec; tBTA_GATTC_API_READ_MULTI api_read_multi; tBTA_GATTC_API_CFG_MTU api_mtu; + tBTA_GATTC_API_CACHE_REFRESH api_refresh; tBTA_GATTC_API_CACHE_ASSOC api_assoc; tBTA_GATTC_API_GET_ADDR api_get_addr; + tBTA_GATTC_API_CACHE_CLEAN api_clean; tBTA_GATTC_OP_CMPL op_cmpl; tBTA_GATTC_INT_CONN int_conn; tBTA_GATTC_ENC_CMPL enc_cmpl; @@ -313,7 +336,7 @@ typedef struct { UINT16 total_char; UINT16 total_attr; UINT8 srvc_hdl_chg; /* service handle change indication pending */ - UINT16 attr_index; /* cahce NV saving/loading attribute index */ + UINT16 attr_index; /* cache NV saving/loading attribute index */ UINT16 mtu; bool update_incl_srvc; diff --git a/components/bt/host/bluedroid/bta/hf_client/bta_hf_client_act.c b/components/bt/host/bluedroid/bta/hf_client/bta_hf_client_act.c index 0e0c43addf..930f30a57d 100644 --- a/components/bt/host/bluedroid/bta/hf_client/bta_hf_client_act.c +++ b/components/bt/host/bluedroid/bta/hf_client/bta_hf_client_act.c @@ -511,7 +511,9 @@ void bta_hf_client_rfc_data(tBTA_HF_CLIENT_DATA *p_data) break; } + bta_sys_busy(BTA_ID_HS, 1, bta_hf_client_cb.scb.peer_addr); bta_hf_client_at_parse(buf, len); + bta_sys_idle(BTA_ID_HS, 1, bta_hf_client_cb.scb.peer_addr); /* no more data to read, we're done */ if (len < BTA_HF_CLIENT_RFC_READ_MAX) { diff --git a/components/bt/host/bluedroid/bta/hf_client/bta_hf_client_main.c b/components/bt/host/bluedroid/bta/hf_client/bta_hf_client_main.c index 4124a10f30..9fdefa97f5 100644 --- a/components/bt/host/bluedroid/bta/hf_client/bta_hf_client_main.c +++ b/components/bt/host/bluedroid/bta/hf_client/bta_hf_client_main.c @@ -413,7 +413,11 @@ static void bta_hf_client_api_enable(tBTA_HF_CLIENT_DATA *p_data) /* check if mSBC support enabled */ if (bta_hf_client_version >= HFP_HF_VERSION_1_6) { +#if (BTM_WBS_INCLUDED == TRUE) bta_hf_client_cb.msbc_enabled = TRUE; +#else + bta_hf_client_cb.msbc_enabled = FALSE; +#endif } else{ bta_hf_client_cb.msbc_enabled = FALSE; } diff --git a/components/bt/host/bluedroid/bta/hh/bta_hh_le.c b/components/bt/host/bluedroid/bta/hh/bta_hh_le.c index a80314efa6..f5697dff52 100644 --- a/components/bt/host/bluedroid/bta/hh/bta_hh_le.c +++ b/components/bt/host/bluedroid/bta/hh/bta_hh_le.c @@ -117,7 +117,7 @@ static void bta_hh_le_hid_report_dbg(tBTA_HH_DEV_CB *p_cb) if (p_cb->hid_srvc[i].in_use) { p_rpt = &p_cb->hid_srvc[i].report[0]; - APPL_TRACE_DEBUG("\t HID serivce inst: %d", i); + APPL_TRACE_DEBUG("\t HID service inst: %d", i); for (j = 0; j < BTA_HH_LE_RPT_MAX; j ++, p_rpt++) { rpt_name = "Unknown"; @@ -334,14 +334,15 @@ void bta_hh_le_open_conn(tBTA_HH_DEV_CB *p_cb, BD_ADDR remote_bda) bta_hh_cb.le_cb_index[BTA_HH_GET_LE_CB_IDX(p_cb->hid_handle)] = p_cb->index; p_cb->in_use = TRUE; - BTA_GATTC_Open(bta_hh_cb.gatt_if, remote_bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, BTA_GATT_TRANSPORT_LE, FALSE); + BTA_GATTC_Enh_Open(bta_hh_cb.gatt_if, remote_bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, + BTA_GATT_TRANSPORT_LE, FALSE, BLE_ADDR_UNKNOWN_TYPE, 0, NULL, NULL, NULL); } /******************************************************************************* ** ** Function bta_hh_le_fill_16bits_gatt_id ** -** Description Utility function to fill a GATT ID strucure +** Description Utility function to fill a GATT ID structure ** *******************************************************************************/ void bta_hh_le_fill_16bits_gatt_id(UINT8 inst_id, UINT16 uuid, tBTA_GATT_ID *p_output) @@ -355,7 +356,7 @@ void bta_hh_le_fill_16bits_gatt_id(UINT8 inst_id, UINT16 uuid, tBTA_GATT_ID *p_ ** ** Function bta_hh_le_fill_16bits_srvc_id ** -** Description Utility function to fill a service ID strucure with a 16 bits +** Description Utility function to fill a service ID structure with a 16 bits ** service UUID. ** *******************************************************************************/ @@ -372,7 +373,7 @@ void bta_hh_le_fill_16bits_srvc_id(BOOLEAN is_pri, UINT8 inst_id, UINT16 srvc_uu ** ** Function bta_hh_le_fill_16bits_char_id ** -** Description Utility function to fill a char ID strucure with a 16 bits +** Description Utility function to fill a char ID structure with a 16 bits ** char UUID. ** *******************************************************************************/ @@ -624,7 +625,7 @@ tBTA_HH_STATUS bta_hh_le_read_char_dscrpt(tBTA_HH_DEV_CB *p_cb, UINT16 srvc_uuid ** ** Function bta_hh_le_read_rpt_ref_descr ** -** Description read report refernece descriptors in service discovery process +** Description read report reference descriptors in service discovery process ** *******************************************************************************/ void bta_hh_le_read_rpt_ref_descr(tBTA_HH_DEV_CB *p_dev_cb, tBTA_HH_LE_RPT *p_rpt) @@ -841,7 +842,7 @@ void bta_hh_le_register_input_notif(tBTA_HH_DEV_CB *p_dev_cb, UINT8 srvc_inst, } } /* - else unknow protocol mode */ + else unknown protocol mode */ } } } @@ -1486,7 +1487,7 @@ void bta_hh_le_gatt_disc_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_STATUS status) { APPL_TRACE_DEBUG("bta_hh_le_gatt_disc_cmpl "); - /* if open sucessful or protocol mode not desired, keep the connection open but inform app */ + /* if open successful or protocol mode not desired, keep the connection open but inform app */ if (status == BTA_HH_OK || status == BTA_HH_ERR_PROTO) { /* assign a special APP ID temp, since device type unknown */ p_cb->app_id = BTA_HH_APP_ID_LE; @@ -1504,7 +1505,7 @@ void bta_hh_le_gatt_disc_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_STATUS status) ** ** Function bta_hh_le_srvc_expl_srvc ** -** Description This function discover the next avaible HID service. +** Description This function discover the next available HID service. ** ** Parameters: ** @@ -2076,7 +2077,7 @@ void bta_hh_w4_le_read_descr_cmpl(tBTA_HH_DEV_CB *p_dev_cb, tBTA_HH_DATA *p_buf) ** ** Function bta_hh_w4_le_write_cmpl ** -** Description Write charactersitic complete event at W4_CONN st. +** Description Write characteristic complete event at W4_CONN st. ** ** Parameters: ** @@ -2104,7 +2105,7 @@ void bta_hh_w4_le_write_cmpl(tBTA_HH_DEV_CB *p_dev_cb, tBTA_HH_DATA *p_buf) ** ** Function bta_hh_le_write_cmpl ** -** Description Write charactersitic complete event at CONN st. +** Description Write characteristic complete event at CONN st. ** ** Parameters: ** @@ -2162,7 +2163,7 @@ void bta_hh_le_write_cmpl(tBTA_HH_DEV_CB *p_dev_cb, tBTA_HH_DATA *p_buf) ** ** Function bta_hh_le_write_char_descr_cmpl ** -** Description Write charactersitic descriptor complete event +** Description Write characteristic descriptor complete event ** ** Parameters: ** @@ -2216,7 +2217,7 @@ void bta_hh_le_write_char_descr_cmpl(tBTA_HH_DEV_CB *p_dev_cb, tBTA_HH_DATA *p_b ** ** Function bta_hh_le_input_rpt_notify ** -** Description process the notificaton event, most likely for input report. +** Description process the notification event, most likely for input report. ** ** Parameters: ** @@ -2357,7 +2358,7 @@ void bta_hh_gatt_close(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data) ** ** Function bta_hh_le_api_disc_act ** -** Description initaite a Close API to a remote HID device +** Description initiate a Close API to a remote HID device ** ** Returns void ** @@ -2601,7 +2602,8 @@ static void bta_hh_le_add_dev_bg_conn(tBTA_HH_DEV_CB *p_cb, BOOLEAN check_bond) if (/*p_cb->dscp_info.flag & BTA_HH_LE_NORMAL_CONN &&*/ !p_cb->in_bg_conn && to_add) { /* add device into BG connection to accept remote initiated connection */ - BTA_GATTC_Open(bta_hh_cb.gatt_if, p_cb->addr, BLE_ADDR_UNKNOWN_TYPE, FALSE, BTA_GATT_TRANSPORT_LE, FALSE); + BTA_GATTC_Enh_Open(bta_hh_cb.gatt_if, p_cb->addr, BLE_ADDR_UNKNOWN_TYPE, FALSE, + BTA_GATT_TRANSPORT_LE, FALSE, BLE_ADDR_UNKNOWN_TYPE, 0, NULL, NULL); p_cb->in_bg_conn = TRUE; BTA_DmBleSetBgConnType(BTA_DM_BLE_CONN_AUTO, NULL); @@ -2682,7 +2684,7 @@ void bta_hh_le_update_scpp(tBTA_HH_DEV_CB *p_dev_cb, tBTA_HH_DATA *p_buf) if (!p_dev_cb->is_le_device || p_dev_cb->mode != BTA_HH_PROTO_RPT_MODE || p_dev_cb->scps_supported == FALSE) { - APPL_TRACE_ERROR("Can not set ScPP scan paramter as boot host, or remote does not support ScPP "); + APPL_TRACE_ERROR("Can not set ScPP scan parameter as boot host, or remote does not support ScPP "); cback_data.handle = p_dev_cb->hid_handle; cback_data.status = BTA_HH_ERR; @@ -2908,7 +2910,7 @@ static void bta_hh_le_search_scps_chars(tBTA_HH_DEV_CB *p_cb) ** ** Function bta_hh_le_register_scpp_notif ** -** Description register scan parameter refresh notitication complete +** Description register scan parameter refresh notification complete ** ** ** Parameters: @@ -2919,7 +2921,7 @@ static void bta_hh_le_register_scpp_notif(tBTA_HH_DEV_CB *p_dev_cb, tBTA_GATT_ST UINT8 sec_flag = 0; tBTA_GATTC_CHAR_ID char_id; - /* if write scan parameter sucessful */ + /* if write scan parameter successful */ /* if bonded and notification is not enabled, configure the client configuration */ if (status == BTA_GATT_OK && (p_dev_cb->scps_notify & BTA_HH_LE_SCPS_NOTIFY_SPT) != 0 && @@ -2949,7 +2951,7 @@ static void bta_hh_le_register_scpp_notif(tBTA_HH_DEV_CB *p_dev_cb, tBTA_GATT_ST ** ** Function bta_hh_le_register_scpp_notif_cmpl ** -** Description action function to register scan parameter refresh notitication +** Description action function to register scan parameter refresh notification ** ** Parameters: ** diff --git a/components/bt/host/bluedroid/bta/include/bta/bta_api.h b/components/bt/host/bluedroid/bta/include/bta/bta_api.h index 4238e7bf75..b3471bd15a 100644 --- a/components/bt/host/bluedroid/bta/include/bta/bta_api.h +++ b/components/bt/host/bluedroid/bta/include/bta/bta_api.h @@ -439,6 +439,8 @@ typedef tBTM_ADD_DEV_TO_RESOLVING_LIST_CMPL_CBACK tBTA_ADD_DEV_TO_RESOLVING_LIST typedef tBTM_SET_PRIVACY_MODE_CMPL_CBACK tBTA_SET_PRIVACY_MODE_CMPL_CBACK; +typedef tBTM_SET_CSA_SUPPORT_CMPL_CBACK tBTA_SET_CSA_SUPPORT_CMPL_CBACK; + typedef tBTM_CMPL_CB tBTA_CMPL_CB; typedef tBTM_VSC_CMPL tBTA_VSC_CMPL; @@ -993,6 +995,7 @@ typedef struct { typedef struct { BD_ADDR bd_addr; /* BD address peer device. */ tBTA_PM_MODE mode; /* the new connection role */ + UINT16 interval; /* Number of baseband slots */ } tBTA_DM_MODE_CHG; typedef struct { @@ -1336,10 +1339,22 @@ typedef UINT8 tBTA_DM_PM_ACTION; #define BTA_DM_PM_SNIFF_HD_IDLE_IDX BTA_DM_PM_SNIFF4 #endif +#ifndef BTA_DM_PM_SNIFF_AG_OPEN_IDX +#define BTA_DM_PM_SNIFF_AG_OPEN_IDX BTA_DM_PM_SNIFF +#endif + +#ifndef BTA_DM_PM_SNIFF_AG_IDLE_IDX +#define BTA_DM_PM_SNIFF_AG_IDLE_IDX BTA_DM_PM_SNIFF +#endif + #ifndef BTA_DM_PM_SNIFF_SCO_OPEN_IDX #define BTA_DM_PM_SNIFF_SCO_OPEN_IDX BTA_DM_PM_SNIFF3 #endif +#ifndef BTA_DM_PM_SNIFF_SCO_CLOSE_IDX +#define BTA_DM_PM_SNIFF_SCO_CLOSE_IDX BTA_DM_PM_SNIFF +#endif + #ifndef BTA_DM_PM_SNIFF_HD_ACTIVE_IDX #define BTA_DM_PM_SNIFF_HD_ACTIVE_IDX BTA_DM_PM_SNIFF5 #endif @@ -2125,6 +2140,17 @@ extern UINT16 BTA_DmGetConnectionState( BD_ADDR bd_addr ); *******************************************************************************/ extern tBTA_STATUS BTA_DmSetLocalDiRecord( tBTA_DI_RECORD *p_device_info, UINT32 *p_handle ); + +/******************************************************************************* +** +** Function BTA_DmRemoveLocalDiRecord +** +** Description This function removes a DI record from the local SDP database. +** +** Returns BTA_SUCCESS if record is removed successfully, otherwise error code. +** +*******************************************************************************/ +extern tBTA_STATUS BTA_DmRemoveLocalDiRecord(UINT32 handle); #endif ///SDP_INCLUDED == TRUE /******************************************************************************* ** @@ -2832,6 +2858,8 @@ extern void BTA_DmBleDtmStop(tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback); extern void BTA_DmBleSetPrivacyMode(uint8_t addr_type, BD_ADDR addr, uint8_t privacy_mode, tBTA_SET_PRIVACY_MODE_CMPL_CBACK *p_cback); +extern void BTA_DmBleGapSetCsaSupport(uint8_t csa_select, tBTM_SET_CSA_SUPPORT_CMPL_CBACK *p_callback); + /******************************************************************************* ** ** Function BTA_DmBleSetStorageParams diff --git a/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h b/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h index 183e3acc5a..ebfcd14369 100644 --- a/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h +++ b/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h @@ -180,7 +180,7 @@ typedef UINT8 tBTA_GATT_STATUS; #define BTA_GATTC_ADV_VSC_EVT 34 /* ADV VSC event */ #define BTA_GATTC_CONNECT_EVT 35 /* GATTC CONNECT event */ #define BTA_GATTC_DISCONNECT_EVT 36 /* GATTC DISCONNECT event */ -#define BTA_GATTC_READ_MULTIPLE_EVT 37 /* GATTC Read mutiple event */ +#define BTA_GATTC_READ_MULTIPLE_EVT 37 /* GATTC Read multiple event */ #define BTA_GATTC_QUEUE_FULL_EVT 38 /* GATTC queue full event */ #define BTA_GATTC_ASSOC_EVT 39 /* GATTC association address event */ #define BTA_GATTC_GET_ADDR_LIST_EVT 40 /* GATTC get address list in the cache event */ @@ -728,6 +728,21 @@ typedef struct tBTA_GATTC_SERVICE *included_service; } __attribute__((packed)) tBTA_GATTC_INCLUDED_SVC; +typedef struct { + UINT16 scan_interval; + UINT16 scan_window; + UINT16 interval_min; + UINT16 interval_max; + UINT16 latency; + UINT16 supervision_timeout; + UINT16 min_ce_len; + UINT16 max_ce_len; +} tBTA_BLE_CONN_PARAMS; + +#define BTA_BLE_PHY_1M_MASK (1 << 0) +#define BTA_BLE_PHY_2M_MASK (1 << 1) +#define BTA_BLE_PHY_CODED_MASK (1 << 2) + /***************************************************************************** ** External Function Declarations *****************************************************************************/ @@ -783,9 +798,10 @@ extern void BTA_GATTC_AppRegister(tBT_UUID *p_app_uuid, tBTA_GATTC_CBACK *p_clie *******************************************************************************/ extern void BTA_GATTC_AppDeregister (tBTA_GATTC_IF client_if); + /******************************************************************************* ** -** Function BTA_GATTC_Open +** Function BTA_GATTC_Enh_Open ** ** Description Open a direct connection or add a background auto connection ** bd address @@ -793,13 +809,16 @@ extern void BTA_GATTC_AppDeregister (tBTA_GATTC_IF client_if); ** Parameters client_if: server interface. ** remote_bda: remote device BD address. ** remote_addr_type: remote device BD address type. -** is_direct: direct connection or background auto connection +** is_direct: direct connection or background auto connection. +** own_addr_type: own address type. ** ** Returns void ** *******************************************************************************/ -extern void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE remote_addr_type, - BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport, BOOLEAN is_aux); +extern void BTA_GATTC_Enh_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE remote_addr_type, + BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport, BOOLEAN is_aux, tBTA_ADDR_TYPE own_addr_type, + UINT8 phy_mask, tBTA_BLE_CONN_PARAMS *phy_1m_conn_params, tBTA_BLE_CONN_PARAMS *phy_2m_conn_params, + tBTA_BLE_CONN_PARAMS *phy_coded_conn_params); /******************************************************************************* ** @@ -937,8 +956,8 @@ extern void BTA_GATTC_GetGattDb(UINT16 conn_id, UINT16 start_handle, UINT16 end_ ** ** Description This function is called to read a characteristics value ** -** Parameters conn_id - connectino ID. -** handle - characteritic handle to read. +** Parameters conn_id - connection ID. +** handle - characteristic handle to read. ** ** Returns None ** @@ -953,7 +972,7 @@ void BTA_GATTC_ReadCharacteristic(UINT16 conn_id, UINT16 handle, tBTA_GATT_AUTH_ ** ** Parameters conn_id - connection ID. ** s_handle - start handle. -** e_handle - end hanle +** e_handle - end handle ** uuid - The attribute UUID. ** ** Returns None @@ -1072,7 +1091,7 @@ extern tBTA_GATT_STATUS BTA_GATTC_DeregisterForNotifications (tBTA_GATTC_IF ** Description This function is called to prepare write a characteristic value. ** ** Parameters conn_id - connection ID. -** handle - GATT characteritic handle. +** handle - GATT characteristic handle. ** offset - offset of the write value. ** len - length of the data to be written. ** p_value - the value to be written. @@ -1094,7 +1113,7 @@ extern void BTA_GATTC_PrepareWrite (UINT16 conn_id, ** Description This function is called to prepare write a characteristic descriptor value. ** ** Parameters conn_id - connection ID. -** p_char_descr_id - GATT characteritic descriptor ID of the service. +** p_char_descr_id - GATT characteristic descriptor ID of the service. ** offset - offset of the write value. ** len: length of the data to be written. ** p_value - the value to be written. @@ -1238,7 +1257,7 @@ extern void BTA_GATTC_ConfigureMTU (UINT16 conn_id); ** ** Function BTA_GATTS_Init ** -** Description This function is called to initalize GATTS module +** Description This function is called to initialize GATTS module ** ** Parameters None ** diff --git a/components/bt/host/bluedroid/bta/include/bta/bta_sdp_api.h b/components/bt/host/bluedroid/bta/include/bta/bta_sdp_api.h index 62b5228a88..fadc8183f0 100644 --- a/components/bt/host/bluedroid/bta/include/bta/bta_sdp_api.h +++ b/components/bt/host/bluedroid/bta/include/bta/bta_sdp_api.h @@ -41,7 +41,7 @@ typedef UINT8 tBTA_SDP_STATUS; /* SDP I/F callback events */ /* events received by tBTA_SDP_DM_CBACK */ #define BTA_SDP_ENABLE_EVT 0 /* SDP service enabled */ -#define BTA_SDP_DISENABLE_EVT 1 /* SDP service disenabled */ +#define BTA_SDP_DISABLE_EVT 1 /* SDP service disenabled */ #define BTA_SDP_SEARCH_EVT 2 /* SDP search started */ #define BTA_SDP_SEARCH_COMP_EVT 3 /* SDP search complete */ #define BTA_SDP_CREATE_RECORD_USER_EVT 4 /* SDP create record complete */ @@ -67,10 +67,17 @@ typedef struct { int handle; } tBTA_SDP_CREATE_RECORD_USER; +/* data associated with BTA_SDP_REMOVE_RECORD_USER_EVT */ +typedef struct { + tBTA_SDP_STATUS status; + int handle; +} tBTA_SDP_REMOVE_RECORD_USER; + typedef union { tBTA_SDP_STATUS status; /* BTA_SDP_SEARCH_EVT */ tBTA_SDP_SEARCH_COMP sdp_search_comp; /* BTA_SDP_SEARCH_COMP_EVT */ tBTA_SDP_CREATE_RECORD_USER sdp_create_record; /* BTA_SDP_CREATE_RECORD_USER_EVT */ + tBTA_SDP_REMOVE_RECORD_USER sdp_remove_record; /* BTA_SDP_REMOVE_RECORD_USER_EVT */ } tBTA_SDP; /* SDP DM Interface callback */ @@ -78,9 +85,11 @@ typedef void (tBTA_SDP_DM_CBACK)(tBTA_SDP_EVT event, tBTA_SDP *p_data, void *use /* MCE configuration structure */ typedef struct { - UINT16 sdp_db_size; /* The size of p_sdp_db */ + UINT16 sdp_raw_size; /* The size of p_sdp_raw_data */ + UINT16 sdp_db_size; /* The size of p_sdp_db */ #if (SDP_INCLUDED == TRUE) - tSDP_DISCOVERY_DB *p_sdp_db; /* The data buffer to keep SDP database */ + UINT8 *p_sdp_raw_data; /* The data buffer to keep raw data */ + tSDP_DISCOVERY_DB *p_sdp_db; /* The data buffer to keep SDP database */ #endif ///SDP_INCLUDED == TRUE } tBTA_SDP_CFG; @@ -108,14 +117,28 @@ extern tBTA_SDP_STATUS BTA_SdpEnable(tBTA_SDP_DM_CBACK *p_cback); ** ** Function BTA_SdpDisable ** -** Description Disable the SDP search I/F service. +** Description This function is used to request a callback to perform disable +** operation. The registered callback will be called with event +** BTA_SDP_DISABLE_EVT. +** +** Returns BTA_SDP_SUCCESS, if the request is being processed. +** BTA_SDP_FAILURE, otherwise. +** +*******************************************************************************/ +extern tBTA_SDP_STATUS BTA_SdpDisable(void); + +/******************************************************************************* +** +** Function BTA_SdpCleanup +** +** Description Cleanup the SDP search I/F service. ** Free buffer for SDP configuration structure. ** ** Returns BTA_SDP_SUCCESS if successful. ** BTA_SDP_FAIL if internal failure. ** *******************************************************************************/ -extern tBTA_SDP_STATUS BTA_SdpDisable(void); +extern tBTA_SDP_STATUS BTA_SdpCleanup(void); /******************************************************************************* ** diff --git a/components/bt/host/bluedroid/bta/include/bta/utl.h b/components/bt/host/bluedroid/bta/include/bta/utl.h index a140832f32..9dd46a75e6 100644 --- a/components/bt/host/bluedroid/bta/include/bta/utl.h +++ b/components/bt/host/bluedroid/bta/include/bta/utl.h @@ -36,6 +36,7 @@ #define BTA_UTL_CLR_COD_SERVICE_CLASS 0x04 #define BTA_UTL_SET_COD_ALL 0x08 /* take service class as the input (may clear some set bits!!) */ #define BTA_UTL_INIT_COD 0x0a +#define BTA_UTL_SET_COD_RESERVED_2 0x10 /* overwrite the two least significant bits reserved_2 */ /***************************************************************************** ** Type Definitions @@ -43,6 +44,7 @@ /** for utl_set_device_class() **/ typedef struct { + UINT8 reserved_2; UINT8 minor; UINT8 major; UINT16 service; @@ -125,11 +127,12 @@ extern void utl_freebuf(void **p); ** p_cod - Pointer to the device class to set to ** ** cmd - the fields of the device class to update. +** BTA_UTL_SET_COD_RESERVED_2 - overwrite the two least significant bits reserved_2 ** BTA_UTL_SET_COD_MAJOR_MINOR, - overwrite major, minor class ** BTA_UTL_SET_COD_SERVICE_CLASS - set the bits in the input ** BTA_UTL_CLR_COD_SERVICE_CLASS - clear the bits in the input -** BTA_UTL_SET_COD_ALL - overwrite major, minor, set the bits in service class -** BTA_UTL_INIT_COD - overwrite major, minor, and service class +** BTA_UTL_SET_COD_ALL - overwrite major, minor, set the bits in service class, reserved_2 remain unchanged +** BTA_UTL_INIT_COD - overwrite major, minor, and service class, reserved_2 remain unchanged ** ** Returns TRUE if successful, Otherwise FALSE ** diff --git a/components/bt/host/bluedroid/bta/sdp/bta_sdp.c b/components/bt/host/bluedroid/bta/sdp/bta_sdp.c index 4deabe9aff..71773d984c 100644 --- a/components/bt/host/bluedroid/bta/sdp/bta_sdp.c +++ b/components/bt/host/bluedroid/bta/sdp/bta_sdp.c @@ -49,10 +49,11 @@ typedef void (*tBTA_SDP_ACTION)(tBTA_SDP_MSG *p_data); /* action function list */ const tBTA_SDP_ACTION bta_sdp_action[] = { - bta_sdp_enable, /* BTA_SDP_API_ENABLE_EVT */ - bta_sdp_search, /* BTA_SDP_API_SEARCH_EVT */ - bta_sdp_create_record, /* BTA_SDP_API_CREATE_RECORD_USER_EVT */ - bta_sdp_remove_record, /* BTA_SDP_API_REMOVE_RECORD_USER_EVT */ + bta_sdp_enable, /* BTA_SDP_API_ENABLE_EVT */ + bta_sdp_search, /* BTA_SDP_API_SEARCH_EVT */ + bta_sdp_create_record, /* BTA_SDP_API_CREATE_RECORD_USER_EVT */ + bta_sdp_remove_record, /* BTA_SDP_API_REMOVE_RECORD_USER_EVT */ + bta_sdp_disable, /* BTA_SDP_API_DISABLE_EVT */ }; /******************************************************************************* diff --git a/components/bt/host/bluedroid/bta/sdp/bta_sdp_act.c b/components/bt/host/bluedroid/bta/sdp/bta_sdp_act.c index 70aa00ba75..ba6aad42d6 100644 --- a/components/bt/host/bluedroid/bta/sdp/bta_sdp_act.c +++ b/components/bt/host/bluedroid/bta/sdp/bta_sdp_act.c @@ -363,8 +363,8 @@ static void bta_create_raw_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE /* Try to extract a service name */ if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_NAME)) != NULL) { - record->pse.hdr.service_name_length = SDP_DISC_ATTR_LEN(p_attr->attr_len_type); - record->pse.hdr.service_name = (char *)p_attr->attr_value.v.array; + record->hdr.service_name_length = SDP_DISC_ATTR_LEN(p_attr->attr_len_type); + record->hdr.service_name = (char *)p_attr->attr_value.v.array; } if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_GOEP_L2CAP_PSM)) != NULL) { @@ -373,9 +373,9 @@ static void bta_create_raw_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE /* Try to extract an RFCOMM channel */ if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe)) { - record->pse.hdr.rfcomm_channel_number = pe.params[0]; + record->hdr.rfcomm_channel_number = pe.params[0]; } - record->hdr.user1_ptr_len = p_bta_sdp_cfg->p_sdp_db->raw_size; + record->hdr.user1_ptr_len = p_bta_sdp_cfg->p_sdp_db->raw_used; record->hdr.user1_ptr = p_bta_sdp_cfg->p_sdp_db->raw_data; } @@ -526,6 +526,10 @@ void bta_sdp_search(tBTA_SDP_MSG *p_data) SDP_InitDiscoveryDb (p_bta_sdp_cfg->p_sdp_db, p_bta_sdp_cfg->sdp_db_size, 1, bta_sdp_search_uuid, 0, NULL); + /* tell SDP to keep the raw data */ + p_bta_sdp_cfg->p_sdp_db->raw_size = p_bta_sdp_cfg->sdp_raw_size; + p_bta_sdp_cfg->p_sdp_db->raw_data = p_bta_sdp_cfg->p_sdp_raw_data; + if (!SDP_ServiceSearchAttributeRequest2(p_data->get_search.bd_addr, p_bta_sdp_cfg->p_sdp_db, bta_sdp_search_cback, (void *)bta_sdp_search_uuid)) { bta_sdp_cb.sdp_active = BTA_SDP_ACTIVE_NONE; @@ -558,7 +562,7 @@ void bta_sdp_create_record(tBTA_SDP_MSG *p_data) APPL_TRACE_DEBUG("%s() event: %d\n", __func__, p_data->record.hdr.event); tBTA_SDP_CREATE_RECORD_USER bta_sdp = {0}; bta_sdp.status = BTA_SDP_SUCCESS; - bta_sdp.handle = (int)p_data->record.user_data; + bta_sdp.handle = -1; if (bta_sdp_cb.p_dm_cback) { bta_sdp_cb.p_dm_cback(BTA_SDP_CREATE_RECORD_USER_EVT, (tBTA_SDP *)&bta_sdp, p_data->record.user_data); } @@ -576,10 +580,30 @@ void bta_sdp_create_record(tBTA_SDP_MSG *p_data) void bta_sdp_remove_record(tBTA_SDP_MSG *p_data) { APPL_TRACE_DEBUG("%s() event: %d\n", __func__, p_data->record.hdr.event); + tBTA_SDP_REMOVE_RECORD_USER bta_sdp; + bta_sdp.status = BTA_SDP_SUCCESS; + bta_sdp.handle = -1; + if (bta_sdp_cb.p_dm_cback) { + bta_sdp_cb.p_dm_cback(BTA_SDP_REMOVE_RECORD_USER_EVT, (tBTA_SDP *)&bta_sdp, p_data->record.user_data); + } +} + +/******************************************************************************* +** +** Function bta_sdp_disable +** +** Description Removes an SDP record +** +** Returns void +** +*******************************************************************************/ +void bta_sdp_disable(tBTA_SDP_MSG *p_data) +{ + APPL_TRACE_DEBUG("%s()\n", __func__); tBTA_SDP bta_sdp; bta_sdp.status = BTA_SDP_SUCCESS; if (bta_sdp_cb.p_dm_cback) { - bta_sdp_cb.p_dm_cback(BTA_SDP_REMOVE_RECORD_USER_EVT, &bta_sdp, p_data->record.user_data); + bta_sdp_cb.p_dm_cback(BTA_SDP_DISABLE_EVT, &bta_sdp, NULL); } } diff --git a/components/bt/host/bluedroid/bta/sdp/bta_sdp_api.c b/components/bt/host/bluedroid/bta/sdp/bta_sdp_api.c index cafb1a4a4c..d46f784bf1 100644 --- a/components/bt/host/bluedroid/bta/sdp/bta_sdp_api.c +++ b/components/bt/host/bluedroid/bta/sdp/bta_sdp_api.c @@ -65,7 +65,9 @@ tBTA_SDP_STATUS BTA_SdpEnable(tBTA_SDP_DM_CBACK *p_cback) #if BTA_DYNAMIC_MEMORY == TRUE /* Malloc buffer for SDP configuration structure */ p_bta_sdp_cfg->p_sdp_db = (tSDP_DISCOVERY_DB *)osi_malloc(p_bta_sdp_cfg->sdp_db_size); - if (p_bta_sdp_cfg->p_sdp_db == NULL) { + p_bta_sdp_cfg->p_sdp_raw_data = (UINT8 *)osi_malloc(p_bta_sdp_cfg->sdp_raw_size); + if (p_bta_sdp_cfg->p_sdp_db == NULL || p_bta_sdp_cfg->p_sdp_raw_data == NULL) { + BTA_SdpCleanup(); return BTA_SDP_FAILURE; } #endif @@ -101,15 +103,34 @@ tBTA_SDP_STATUS BTA_SdpEnable(tBTA_SDP_DM_CBACK *p_cback) *******************************************************************************/ tBTA_SDP_STATUS BTA_SdpDisable(void) { + BT_HDR *p_buf = NULL; tBTA_SDP_STATUS status = BTA_SDP_SUCCESS; + if ((p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR))) != NULL) { + p_buf->event = BTA_SDP_API_DISABLE_EVT; + bta_sys_sendmsg(p_buf); + status = BTA_SDP_FAILURE; + } + + return status; +} + +tBTA_SDP_STATUS BTA_SdpCleanup(void) +{ bta_sys_deregister(BTA_ID_SDP); #if BTA_DYNAMIC_MEMORY == TRUE /* Free buffer for SDP configuration structure */ - osi_free(p_bta_sdp_cfg->p_sdp_db); - p_bta_sdp_cfg->p_sdp_db = NULL; + if (p_bta_sdp_cfg->p_sdp_db) { + osi_free(p_bta_sdp_cfg->p_sdp_db); + p_bta_sdp_cfg->p_sdp_db = NULL; + } + + if (p_bta_sdp_cfg->p_sdp_raw_data) { + osi_free(p_bta_sdp_cfg->p_sdp_raw_data); + p_bta_sdp_cfg->p_sdp_raw_data = NULL; + } #endif - return (status); + return BTA_SDP_SUCCESS; } /******************************************************************************* diff --git a/components/bt/host/bluedroid/bta/sdp/bta_sdp_cfg.c b/components/bt/host/bluedroid/bta/sdp/bta_sdp_cfg.c index 322b25caec..423905bc50 100644 --- a/components/bt/host/bluedroid/bta/sdp/bta_sdp_cfg.c +++ b/components/bt/host/bluedroid/bta/sdp/bta_sdp_cfg.c @@ -30,16 +30,24 @@ #define BTA_SDP_DB_SIZE 1500 #endif +#ifndef BTA_SDP_RAW_DATA_SIZE +#define BTA_SDP_RAW_DATA_SIZE 1024 +#endif + #if BTA_DYNAMIC_MEMORY == FALSE +static UINT8 bta_sdp_raw_data[BTA_SDP_RAW_DATA_SIZE]; static UINT8 __attribute__ ((aligned(4))) bta_sdp_db_data[BTA_SDP_DB_SIZE]; #endif /* SDP configuration structure */ tBTA_SDP_CFG bta_sdp_cfg = { + BTA_SDP_RAW_DATA_SIZE, BTA_SDP_DB_SIZE, #if BTA_DYNAMIC_MEMORY == FALSE + bta_sdp_raw_data, (tSDP_DISCOVERY_DB *)bta_sdp_db_data /* The data buffer to keep SDP database */ #else + NULL, NULL #endif }; diff --git a/components/bt/host/bluedroid/bta/sdp/include/bta_sdp_int.h b/components/bt/host/bluedroid/bta/sdp/include/bta_sdp_int.h index cf0eb99cc1..f350ae372f 100644 --- a/components/bt/host/bluedroid/bta/sdp/include/bta_sdp_int.h +++ b/components/bt/host/bluedroid/bta/sdp/include/bta_sdp_int.h @@ -42,6 +42,7 @@ enum { BTA_SDP_API_SEARCH_EVT, BTA_SDP_API_CREATE_RECORD_USER_EVT, BTA_SDP_API_REMOVE_RECORD_USER_EVT, + BTA_SDP_API_DISABLE_EVT, BTA_SDP_MAX_INT_EVT }; @@ -105,6 +106,7 @@ extern void bta_sdp_enable (tBTA_SDP_MSG *p_data); extern void bta_sdp_search (tBTA_SDP_MSG *p_data); extern void bta_sdp_create_record(tBTA_SDP_MSG *p_data); extern void bta_sdp_remove_record(tBTA_SDP_MSG *p_data); +extern void bta_sdp_disable(tBTA_SDP_MSG *p_data); #endif ///SDP_INCLUDED == TRUE diff --git a/components/bt/host/bluedroid/bta/sys/utl.c b/components/bt/host/bluedroid/bta/sys/utl.c index c18567cd6d..94348e85f0 100644 --- a/components/bt/host/bluedroid/bta/sys/utl.c +++ b/components/bt/host/bluedroid/bta/sys/utl.c @@ -170,11 +170,12 @@ void utl_freebuf(void **p) ** p_cod - Pointer to the device class to set to ** ** cmd - the fields of the device class to update. +** BTA_UTL_SET_COD_RESERVED_2 - overwrite the two least significant bits reserved_2 ** BTA_UTL_SET_COD_MAJOR_MINOR, - overwrite major, minor class ** BTA_UTL_SET_COD_SERVICE_CLASS - set the bits in the input ** BTA_UTL_CLR_COD_SERVICE_CLASS - clear the bits in the input -** BTA_UTL_SET_COD_ALL - overwrite major, minor, set the bits in service class -** BTA_UTL_INIT_COD - overwrite major, minor, and service class +** BTA_UTL_SET_COD_ALL - overwrite major, minor, set the bits in service class, reserved_2 remain unchanged +** BTA_UTL_INIT_COD - overwrite major, minor, and service class, reserved_2 remain unchanged ** ** Returns TRUE if successful, Otherwise FALSE ** @@ -183,15 +184,19 @@ BOOLEAN utl_set_device_class(tBTA_UTL_COD *p_cod, UINT8 cmd) { UINT8 *dev; UINT16 service; - UINT8 minor, major; + UINT8 minor, major, reserved_2; DEV_CLASS dev_class; dev = BTM_ReadDeviceClass(); BTM_COD_SERVICE_CLASS( service, dev ); BTM_COD_MINOR_CLASS(minor, dev ); BTM_COD_MAJOR_CLASS(major, dev ); + BTM_COD_RESERVED_2(reserved_2, dev); switch (cmd) { + case BTA_UTL_SET_COD_RESERVED_2: + reserved_2 = p_cod->reserved_2 & BTM_COD_RESERVED_2_MASK; + break; case BTA_UTL_SET_COD_MAJOR_MINOR: minor = p_cod->minor & BTM_COD_MINOR_CLASS_MASK; major = p_cod->major & BTM_COD_MAJOR_CLASS_MASK; @@ -226,7 +231,7 @@ BOOLEAN utl_set_device_class(tBTA_UTL_COD *p_cod, UINT8 cmd) } /* convert the fields into the device class type */ - FIELDS_TO_COD(dev_class, minor, major, service); + FIELDS_TO_COD(dev_class, reserved_2, minor, major, service); if (BTM_SetDeviceClass(dev_class) == BTM_SUCCESS) { return TRUE; @@ -252,16 +257,18 @@ BOOLEAN utl_get_device_class(tBTA_UTL_COD *p_cod) { UINT8 *dev; UINT16 service; - UINT8 minor, major; + UINT8 minor, major, reserved_2; dev = BTM_ReadDeviceClass(); BTM_COD_SERVICE_CLASS( service, dev ); BTM_COD_MINOR_CLASS(minor, dev ); BTM_COD_MAJOR_CLASS(major, dev ); + BTM_COD_RESERVED_2(reserved_2, dev ); p_cod->minor = minor; p_cod->major = major; p_cod->service = service; + p_cod->reserved_2 = reserved_2; return TRUE; } diff --git a/components/bt/host/bluedroid/btc/core/btc_dm.c b/components/bt/host/bluedroid/btc/core/btc_dm.c index 8c55d7bbe3..9838dc0651 100644 --- a/components/bt/host/bluedroid/btc/core/btc_dm.c +++ b/components/bt/host/bluedroid/btc/core/btc_dm.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -182,11 +182,12 @@ static void btc_dm_remove_ble_bonding_keys(void) btc_storage_remove_ble_bonding_keys(&bd_addr); } +#if BLE_SMP_BOND_NVS_FLASH static void btc_dm_save_ble_bonding_keys(void) { if (!(btc_dm_cb.pairing_cb.ble.is_penc_key_rcvd || btc_dm_cb.pairing_cb.ble.is_pid_key_rcvd || btc_dm_cb.pairing_cb.ble.is_pcsrk_key_rcvd || - btc_dm_cb.pairing_cb.ble.is_lenc_key_rcvd || btc_dm_cb.pairing_cb.ble.is_lcsrk_key_rcvd || btc_dm_cb.pairing_cb.ble.is_lidk_key_rcvd)) { - return ; + btc_dm_cb.pairing_cb.ble.is_lenc_key_rcvd || btc_dm_cb.pairing_cb.ble.is_lcsrk_key_rcvd || btc_dm_cb.pairing_cb.ble.is_lidk_key_rcvd)) { + return; } bt_bdaddr_t bd_addr; @@ -244,13 +245,13 @@ static void btc_dm_save_ble_bonding_keys(void) btc_dm_cb.pairing_cb.ble.is_lidk_key_rcvd = false; } } +#endif static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) { /* Save link key, if not temporary */ BTC_TRACE_DEBUG("%s, status = %d", __func__, p_auth_cmpl->success); bt_status_t status = BT_STATUS_FAIL; - int addr_type; bt_bdaddr_t bdaddr; bdcpy(bdaddr.address, p_auth_cmpl->bd_addr); bdcpy(btc_dm_cb.pairing_cb.bd_addr, p_auth_cmpl->bd_addr); @@ -266,6 +267,9 @@ static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) return; } +#if BLE_SMP_BOND_NVS_FLASH + int addr_type; + if (btc_dm_cb.pairing_cb.ble.is_pid_key_rcvd) { // delete unused section in NVS btc_storage_remove_unused_sections(p_auth_cmpl->bd_addr, &btc_dm_cb.pairing_cb.ble.pid_key); @@ -276,6 +280,7 @@ static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) } btc_storage_set_ble_dev_auth_mode(&bdaddr, p_auth_cmpl->auth_mode, true); btc_dm_save_ble_bonding_keys(); +#endif } else { /*Map the HCI fail reason to bt status */ switch (p_auth_cmpl->fail_reason) { @@ -602,6 +607,7 @@ static void btc_dm_pm_mode_chg_evt(tBTA_DM_MODE_CHG *p_mode_chg) msg->act = BTC_GAP_BT_MODE_CHG_EVT; memcpy(param.mode_chg.bda, p_mode_chg->bd_addr, ESP_BD_ADDR_LEN); param.mode_chg.mode = p_mode_chg->mode; + param.mode_chg.interval= p_mode_chg->interval; memcpy(msg->arg, ¶m, sizeof(esp_bt_gap_cb_param_t)); ret = btc_inter_profile_call(msg); diff --git a/components/bt/host/bluedroid/btc/core/btc_main.c b/components/bt/host/bluedroid/btc/core/btc_main.c index c1c694b8a2..5fe01627fc 100644 --- a/components/bt/host/bluedroid/btc/core/btc_main.c +++ b/components/bt/host/bluedroid/btc/core/btc_main.c @@ -122,6 +122,11 @@ uint32_t btc_get_ble_status(void) { uint32_t status = BTC_BLE_STATUS_IDLE; + if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) { + BTC_TRACE_ERROR("%s Bluedroid not enabled", __func__); + return status; + } + #if (BLE_INCLUDED == TRUE) // Number of active advertising extern uint8_t btm_ble_adv_active_count(void); @@ -141,6 +146,12 @@ uint32_t btc_get_ble_status(void) status |= BIT(BTC_BLE_STATUS_CONN); } + // Address resolve status + extern uint8_t btm_get_ble_addr_resolve_disable_status(void); + if (btm_get_ble_addr_resolve_disable_status()) { + status |= BIT(BTC_BLE_STATUS_ADDR_RESOLVE_DISABLE); + } + #if (SMP_INCLUDED == TRUE) // Number of recorded devices extern uint8_t btm_ble_sec_dev_active_count(void); diff --git a/components/bt/host/bluedroid/btc/core/btc_util.c b/components/bt/host/bluedroid/btc/core/btc_util.c index 5e29aba8be..e22efce3a8 100644 --- a/components/bt/host/bluedroid/btc/core/btc_util.c +++ b/components/bt/host/bluedroid/btc/core/btc_util.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -349,10 +349,10 @@ esp_bt_status_t btc_hci_to_esp_status(uint8_t hci_status) return esp_status; } -esp_bt_status_t btc_btm_status_to_esp_status (uint8_t btm_status) +esp_bt_status_t btc_btm_status_to_esp_status(uint8_t btm_status) { esp_bt_status_t esp_status = ESP_BT_STATUS_FAIL; - switch(btm_status){ + switch(btm_status) { case BTM_SUCCESS: esp_status = ESP_BT_STATUS_SUCCESS; break; @@ -381,14 +381,18 @@ esp_bt_status_t btc_btm_status_to_esp_status (uint8_t btm_status) esp_status = ESP_BT_STATUS_FAIL; break; default: - esp_status = ESP_BT_STATUS_FAIL; + if (btm_status & BTM_HCI_ERROR) { + esp_status = ESP_BT_STATUS_BASE_FOR_HCI_ERR | (btm_status & 0x7F); + } else { + esp_status = ESP_BT_STATUS_FAIL; + } break; } return esp_status; } -esp_bt_status_t btc_bta_status_to_esp_status (uint8_t bta_status) +esp_bt_status_t btc_bta_status_to_esp_status(uint8_t bta_status) { esp_bt_status_t esp_status = ESP_BT_STATUS_FAIL; switch(bta_status){ @@ -420,3 +424,36 @@ esp_bt_status_t btc_bta_status_to_esp_status (uint8_t bta_status) return esp_status; } + +void bta_to_btc_uuid(esp_bt_uuid_t *p_dest, tBT_UUID *p_src) +{ + p_dest->len = p_src->len; + if (p_src->len == LEN_UUID_16) { + p_dest->uuid.uuid16 = p_src->uu.uuid16; + } else if (p_src->len == LEN_UUID_32) { + p_dest->uuid.uuid32 = p_src->uu.uuid32; + } else if (p_src->len == LEN_UUID_128) { + memcpy(&p_dest->uuid.uuid128, p_src->uu.uuid128, p_dest->len); + } else if (p_src->len == 0) { + /* do nothing for now, there's some scenario will input 0 + such as, receive notify, the descriptor may be 0 */ + } else { + BTC_TRACE_ERROR("%s UUID len is invalid %d\n", __func__, p_src->len); + } +} + +void btc_to_bta_uuid(tBT_UUID *p_dest, esp_bt_uuid_t *p_src) +{ + p_dest->len = p_src->len; + if (p_src->len == LEN_UUID_16) { + p_dest->uu.uuid16 = p_src->uuid.uuid16; + } else if (p_src->len == LEN_UUID_32) { + p_dest->uu.uuid32 = p_src->uuid.uuid32; + } else if (p_src->len == LEN_UUID_128) { + memcpy(&p_dest->uu.uuid128, p_src->uuid.uuid128, p_dest->len); + } else if (p_src->len == 0) { + /* do nothing for now, there's some scenario will input 0 */ + } else { + BTC_TRACE_ERROR("%s UUID len is invalid %d\n", __func__, p_src->len); + } +} diff --git a/components/bt/host/bluedroid/btc/include/btc/btc_main.h b/components/bt/host/bluedroid/btc/include/btc/btc_main.h index df20a63878..e9b6f5ba2a 100644 --- a/components/bt/host/bluedroid/btc/include/btc/btc_main.h +++ b/components/bt/host/bluedroid/btc/include/btc/btc_main.h @@ -40,6 +40,7 @@ typedef enum { BTC_BLE_STATUS_GATTC_APP, // GATTC application exist BTC_BLE_STATUS_GATTS_SRVC, // GATTS service exist BTC_BLE_STATUS_PRIVACY, // Privacy enabled + BTC_BLE_STATUS_ADDR_RESOLVE_DISABLE,// Address resolution disable status } tBTC_BLE_STATUS; future_t **btc_main_get_future_p(btc_main_future_type_t type); diff --git a/components/bt/host/bluedroid/btc/include/btc/btc_util.h b/components/bt/host/bluedroid/btc/include/btc/btc_util.h index deb5599075..1b96d6f48c 100644 --- a/components/bt/host/bluedroid/btc/include/btc/btc_util.h +++ b/components/bt/host/bluedroid/btc/include/btc/btc_util.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -57,8 +57,11 @@ void uuid128_be_to_esp_uuid(esp_bt_uuid_t *u, uint8_t* uuid128); void uuid_to_string_legacy(bt_uuid_t *p_uuid, char *str); esp_bt_status_t btc_hci_to_esp_status(uint8_t hci_status); -esp_bt_status_t btc_btm_status_to_esp_status (uint8_t btm_status); -esp_bt_status_t btc_bta_status_to_esp_status (uint8_t bta_status); +esp_bt_status_t btc_btm_status_to_esp_status(uint8_t btm_status); +esp_bt_status_t btc_bta_status_to_esp_status(uint8_t bta_status); + +void bta_to_btc_uuid(esp_bt_uuid_t *p_dest, tBT_UUID *p_src); +void btc_to_bta_uuid(tBT_UUID *p_dest, esp_bt_uuid_t *p_src); #ifdef __cplusplus } diff --git a/components/bt/host/bluedroid/btc/profile/std/avrc/btc_avrc.c b/components/bt/host/bluedroid/btc/profile/std/avrc/btc_avrc.c index 7e7f1b2bb6..738fbfd3c9 100644 --- a/components/bt/host/bluedroid/btc/profile/std/avrc/btc_avrc.c +++ b/components/bt/host/bluedroid/btc/profile/std/avrc/btc_avrc.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -40,7 +40,7 @@ static void btc_rc_upstreams_evt(UINT16 event, tAVRC_COMMAND *pavrc_cmd, UINT8 c ** Static variables ******************************************************************************/ -/* flag indicating wheter TG/CT is initialized */ +/* flag indicating whether TG/CT is initialized */ static uint32_t s_rc_ct_init; static uint32_t s_rc_tg_init; @@ -170,8 +170,7 @@ bool btc_avrc_ct_init_p(void) bool btc_avrc_tg_connected_p(void) { return (s_rc_tg_init == BTC_RC_TG_INIT_MAGIC) && - (btc_rc_cb.rc_connected == TRUE) && - (btc_rc_cb.rc_features & BTA_AV_FEAT_RCCT); + (btc_rc_cb.rc_connected == TRUE); } bool btc_avrc_ct_connected_p(void) @@ -456,7 +455,7 @@ static void handle_rc_connect (tBTA_AV_RC_OPEN *p_rc_open) btc_avrc_ct_cb_to_app(ESP_AVRC_CT_CONNECTION_STATE_EVT, ¶m); } - if (p_rc_open->peer_features & BTA_AV_FEAT_RCCT) { + if (btc_avrc_tg_init_p()) { esp_avrc_tg_cb_param_t param; memset(¶m, 0, sizeof(esp_avrc_tg_cb_param_t)); param.conn_stat.connected = true; @@ -515,7 +514,7 @@ static void handle_rc_disconnect (tBTA_AV_RC_CLOSE *p_rc_close) btc_avrc_ct_cb_to_app(ESP_AVRC_CT_CONNECTION_STATE_EVT, ¶m); } - if (rc_features & BTA_AV_FEAT_RCCT) { + if (btc_avrc_tg_init_p()) { esp_avrc_tg_cb_param_t param; memset(¶m, 0, sizeof(esp_avrc_ct_cb_param_t)); param.conn_stat.connected = false; @@ -751,7 +750,7 @@ static void btc_rc_upstreams_evt(UINT16 event, tAVRC_COMMAND *pavrc_cmd, UINT8 c btc_rc_cb.rc_ntf[event_id - 1].registered = TRUE; btc_rc_cb.rc_ntf[event_id - 1].label = label; - BTC_TRACE_EVENT("%s: New registerd notification: event_id:0x%x, label:0x%x", + BTC_TRACE_EVENT("%s: New register notification: event_id:0x%x, label:0x%x", __FUNCTION__, event_id, label); // set up callback @@ -941,14 +940,10 @@ void btc_rc_handler(tBTA_AV_EVT event, tBTA_AV *p_data) memcpy(param.conn_stat.remote_bda, btc_rc_cb.rc_addr, sizeof(esp_bd_addr_t)); btc_avrc_ct_cb_to_app(ESP_AVRC_CT_CONNECTION_STATE_EVT, ¶m); } - if ((p_data->rc_feat.peer_features & BTA_AV_FEAT_RCCT) && - !(old_feats & BTA_AV_FEAT_RCCT)) { - esp_avrc_tg_cb_param_t param; - memset(¶m, 0, sizeof(esp_avrc_ct_cb_param_t)); - param.conn_stat.connected = true; - memcpy(param.conn_stat.remote_bda, btc_rc_cb.rc_addr, sizeof(esp_bd_addr_t)); - btc_avrc_tg_cb_to_app(ESP_AVRC_CT_CONNECTION_STATE_EVT, ¶m); - } + /** + * @note ESP_AVRC_TG_CONNECTION_STATE_EVT has been reported on rc connect/disconnect event, + * it doesn't rely on the SDP results. + */ } while (0); btc_rc_cb.rc_features = p_data->rc_feat.peer_features; btc_rc_cb.rc_ct_features = p_data->rc_feat.peer_ct_features; @@ -1041,7 +1036,7 @@ static void btc_avrc_ct_deinit(void) BTC_TRACE_API("## %s ##", __FUNCTION__); if (g_a2dp_on_deinit) { - BTC_TRACE_WARNING("A2DP already deinit, AVRC CT shuold deinit in advance of A2DP !!!"); + BTC_TRACE_WARNING("A2DP already deinit, AVRC CT should deinit in advance of A2DP !!!"); } if (s_rc_ct_init != BTC_RC_CT_INIT_MAGIC) { @@ -1255,7 +1250,7 @@ static bt_status_t btc_avrc_ct_send_passthrough_cmd(uint8_t tl, uint8_t key_code BTA_AvRemoteCmd(btc_rc_cb.rc_handle, tl, (tBTA_AV_RC)key_code, (tBTA_AV_STATE)key_state); status = BT_STATUS_SUCCESS; - BTC_TRACE_API("%s: succesfully sent passthrough command to BTA", __FUNCTION__); + BTC_TRACE_API("%s: successfully sent passthrough command to BTA", __FUNCTION__); } else { status = BT_STATUS_FAIL; BTC_TRACE_DEBUG("%s: feature not supported", __FUNCTION__); @@ -1298,7 +1293,7 @@ static void btc_avrc_tg_init(void) } if (g_a2dp_on_init) { - BTC_TRACE_WARNING("AVRC Taget is expected to be initialized in advance of A2DP !!!"); + BTC_TRACE_WARNING("AVRC Target is expected to be initialized in advance of A2DP !!!"); } } @@ -1320,7 +1315,7 @@ static void btc_avrc_tg_deinit(void) BTC_TRACE_API("## %s ##", __FUNCTION__); if (g_a2dp_on_deinit) { - BTC_TRACE_WARNING("A2DP already deinit, AVRC TG shuold deinit in advance of A2DP !!!"); + BTC_TRACE_WARNING("A2DP already deinit, AVRC TG should deinit in advance of A2DP !!!"); } if (s_rc_tg_init != BTC_RC_TG_INIT_MAGIC) { diff --git a/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c b/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c index 3c6531b491..3566867578 100644 --- a/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c +++ b/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c @@ -1356,6 +1356,25 @@ static void btc_ble_set_privacy_mode_callback(UINT8 status) } } +static void btc_ble_set_csa_support_callback(UINT8 status) +{ + esp_ble_gap_cb_param_t param; + bt_status_t ret; + btc_msg_t msg = {0}; + + msg.sig = BTC_SIG_API_CB; + msg.pid = BTC_PID_GAP_BLE; + msg.act = ESP_GAP_BLE_SET_CSA_SUPPORT_COMPLETE_EVT; + + param.set_csa_support_cmpl.status = btc_btm_status_to_esp_status(status); + + ret = btc_transfer_context(&msg, ¶m, sizeof(esp_ble_gap_cb_param_t), NULL, NULL); + + if (ret != BT_STATUS_SUCCESS) { + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); + } +} + void btc_get_whitelist_size(uint16_t *length) { BTM_BleGetWhiteListSize(length); @@ -2375,6 +2394,9 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) btc_ble_set_privacy_mode(arg->set_privacy_mode.addr_type, arg->set_privacy_mode.addr, arg->set_privacy_mode.privacy_mode, btc_ble_set_privacy_mode_callback); break; + case BTC_GAP_BLE_SET_CSA_SUPPORT: + BTA_DmBleGapSetCsaSupport(arg->set_csa_support.csa_select, btc_ble_set_csa_support_callback); + break; default: break; } diff --git a/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_bt.c b/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_bt.c index f43e96390c..a1b723d1f5 100644 --- a/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_bt.c +++ b/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_bt.c @@ -585,6 +585,7 @@ static void btc_gap_bt_set_cod(btc_gap_bt_args_t *arg) { tBTA_UTL_COD p_cod; esp_bt_cod_t *cod = &(arg->set_cod.cod); + p_cod.reserved_2 = cod->reserved_2; p_cod.minor = cod->minor << 2; p_cod.major = cod->major; p_cod.service = cod->service << 5; @@ -602,6 +603,7 @@ esp_err_t btc_gap_bt_get_cod(esp_bt_cod_t *cod) BTC_TRACE_ERROR("%s get class of device failed!",__func__); return ESP_BT_STATUS_FAIL; } + cod->reserved_2 = p_cod.reserved_2; cod->minor = p_cod.minor >> 2; cod->major = p_cod.major; cod->service = p_cod.service >> 5; diff --git a/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gatt_util.c b/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gatt_util.c index bca8ea6613..9d4d108bef 100644 --- a/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gatt_util.c +++ b/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gatt_util.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -82,23 +82,6 @@ void btc128_to_bta_uuid(tBT_UUID *p_dest, uint8_t *p_src) /******************************************************************************* * BTC -> BTA conversion functions *******************************************************************************/ - -void btc_to_bta_uuid(tBT_UUID *p_dest, esp_bt_uuid_t *p_src) -{ - p_dest->len = p_src->len; - if (p_src->len == LEN_UUID_16) { - p_dest->uu.uuid16 = p_src->uuid.uuid16; - } else if (p_src->len == LEN_UUID_32) { - p_dest->uu.uuid32 = p_src->uuid.uuid32; - } else if (p_src->len == LEN_UUID_128) { - memcpy(&p_dest->uu.uuid128, p_src->uuid.uuid128, p_dest->len); - } else if (p_src->len == 0) { - /* do nothing for now, there's some scenario will input 0 */ - } else { - BTC_TRACE_ERROR("%s UUID len is invalid %d\n", __func__, p_src->len); - } -} - void btc_to_bta_gatt_id(tBTA_GATT_ID *p_dest, esp_gatt_id_t *p_src) { p_dest->inst_id = p_src->inst_id; @@ -115,23 +98,6 @@ void btc_to_bta_srvc_id(tBTA_GATT_SRVC_ID *p_dest, esp_gatt_srvc_id_t *p_src) /******************************************************************************* * BTA -> BTC conversion functions *******************************************************************************/ -void bta_to_btc_uuid(esp_bt_uuid_t *p_dest, tBT_UUID *p_src) -{ - p_dest->len = p_src->len; - if (p_src->len == LEN_UUID_16) { - p_dest->uuid.uuid16 = p_src->uu.uuid16; - } else if (p_src->len == LEN_UUID_32) { - p_dest->uuid.uuid32 = p_src->uu.uuid32; - } else if (p_src->len == LEN_UUID_128) { - memcpy(&p_dest->uuid.uuid128, p_src->uu.uuid128, p_dest->len); - } else if (p_src->len == 0) { - /* do nothing for now, there's some scenario will input 0 - such as, receive notify, the descriptor may be 0 */ - } else { - BTC_TRACE_ERROR("%s UUID len is invalid %d\n", __func__, p_src->len); - } -} - void bta_to_btc_gatt_id(esp_gatt_id_t *p_dest, tBTA_GATT_ID *p_src) { p_dest->inst_id = p_src->inst_id; diff --git a/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gattc.c b/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gattc.c index e69eed48f3..86221e3c89 100644 --- a/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gattc.c +++ b/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gattc.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 @@ -212,9 +212,12 @@ static void btc_gattc_app_unregister(btc_ble_gattc_args_t *arg) static void btc_gattc_open(btc_ble_gattc_args_t *arg) { tBTA_GATT_TRANSPORT transport = BTA_GATT_TRANSPORT_LE; - BTA_GATTC_Open(arg->open.gattc_if, arg->open.remote_bda, + + BTA_GATTC_Enh_Open(arg->open.gattc_if, arg->open.remote_bda, arg->open.remote_addr_type, arg->open.is_direct, - transport, arg->open.is_aux); + transport, arg->open.is_aux, arg->open.own_addr_type, + arg->open.phy_mask, (void *)&arg->open.phy_1m_conn_params, + (void *)&arg->open.phy_2m_conn_params, (void *)&arg->open.phy_coded_conn_params); } static void btc_gattc_close(btc_ble_gattc_args_t *arg) diff --git a/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gatts.c b/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gatts.c index df9a4ceb19..7eab806e2f 100644 --- a/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gatts.c +++ b/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gatts.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -469,7 +469,7 @@ static esp_gatt_status_t btc_gatts_check_valid_attr_tab(esp_gatts_attr_db_t *gat if(gatts_attr_db[i+1].att_desc.uuid_length != ESP_UUID_LEN_16 && gatts_attr_db[i+1].att_desc.uuid_length != ESP_UUID_LEN_32 && gatts_attr_db[i+1].att_desc.uuid_length != ESP_UUID_LEN_128) { - BTC_TRACE_ERROR("%s, The Charateristic uuid length = %d is invalid", __func__,\ + BTC_TRACE_ERROR("%s, The Characteristic uuid length = %d is invalid", __func__,\ gatts_attr_db[i+1].att_desc.uuid_length); return ESP_GATT_INVALID_ATTR_LEN; } @@ -481,7 +481,7 @@ static esp_gatt_status_t btc_gatts_check_valid_attr_tab(esp_gatts_attr_db_t *gat uuid == ESP_GATT_UUID_CHAR_SRVR_CONFIG || uuid == ESP_GATT_UUID_CHAR_PRESENT_FORMAT || uuid == ESP_GATT_UUID_CHAR_AGG_FORMAT || uuid == ESP_GATT_UUID_CHAR_VALID_RANGE || uuid == ESP_GATT_UUID_EXT_RPT_REF_DESCR || uuid == ESP_GATT_UUID_RPT_REF_DESCR) { - BTC_TRACE_ERROR("%s, The charateristic value uuid = %d is invalid", __func__, uuid); + BTC_TRACE_ERROR("%s, The characteristic value uuid = %d is invalid", __func__, uuid); return ESP_GATT_INVALID_PDU; } } @@ -694,6 +694,7 @@ void btc_gatts_call_handler(btc_msg_t *msg) } param.rsp.status = 0; + param.rsp.conn_id = BTC_GATT_GET_CONN_ID(arg->send_rsp.conn_id); btc_gatts_cb_to_app(ESP_GATTS_RESPONSE_EVT, BTC_GATT_GET_GATT_IF(arg->send_rsp.conn_id), ¶m); break; } diff --git a/components/bt/host/bluedroid/btc/profile/std/hf_ag/btc_hf_ag.c b/components/bt/host/bluedroid/btc/profile/std/hf_ag/btc_hf_ag.c index a4c5faeb01..0e0bc6c270 100644 --- a/components/bt/host/bluedroid/btc/profile/std/hf_ag/btc_hf_ag.c +++ b/components/bt/host/bluedroid/btc/profile/std/hf_ag/btc_hf_ag.c @@ -314,6 +314,19 @@ bt_status_t btc_hf_init(void) { int idx = 0; +#if HFP_DYNAMIC_MEMORY == TRUE + if (hf_local_param) +#endif + { + if (hf_local_param[idx].btc_hf_cb.initialized) { + esp_hf_cb_param_t param = { + .prof_stat.state = ESP_HF_INIT_ALREADY, + }; + btc_hf_cb_to_app(ESP_HF_PROF_STATE_EVT, ¶m); + return BT_STATUS_SUCCESS; + } + } + BTC_TRACE_DEBUG("%s - max_hf_clients=%d", __func__, btc_max_hf_clients); #if HFP_DYNAMIC_MEMORY == TRUE @@ -336,8 +349,6 @@ bt_status_t btc_hf_init(void) #endif clear_phone_state(); memset(&hf_local_param[idx].btc_hf_cb, 0, sizeof(btc_hf_cb_t)); - // custom initialization here - hf_local_param[idx].btc_hf_cb.initialized = true; // set audio path #if BTM_SCO_HCI_INCLUDED uint8_t data_path = ESP_SCO_DATA_PATH_HCI; @@ -345,14 +356,30 @@ bt_status_t btc_hf_init(void) uint8_t data_path = ESP_SCO_DATA_PATH_PCM; #endif esp_bredr_sco_datapath_set(data_path); + return BT_STATUS_SUCCESS; } void btc_hf_deinit(void) { BTC_TRACE_EVENT("%s", __FUNCTION__); + + int idx = 0; + +#if HFP_DYNAMIC_MEMORY == TRUE + if (hf_local_param) +#endif + { + if (!hf_local_param[idx].btc_hf_cb.initialized) { + esp_hf_cb_param_t param = { + .prof_stat.state = ESP_HF_DEINIT_ALREADY, + }; + btc_hf_cb_to_app(ESP_HF_PROF_STATE_EVT, ¶m); + return; + } + } + btc_dm_disable_service(BTA_HFP_SERVICE_ID); - hf_local_param[0].btc_hf_cb.initialized = false; } static void btc_hf_cb_release(void) @@ -1264,7 +1291,18 @@ void btc_hf_cb_handler(btc_msg_t *msg) break; case BTA_AG_DISABLE_EVT: { - btc_hf_cb_release(); + idx = 0; +#if HFP_DYNAMIC_MEMORY == TRUE + if (hf_local_param) +#endif + { + if (hf_local_param[idx].btc_hf_cb.initialized) { + hf_local_param[idx].btc_hf_cb.initialized = false; + btc_hf_cb_release(); + param.prof_stat.state = ESP_HF_DEINIT_SUCCESS; + btc_hf_cb_to_app(ESP_HF_PROF_STATE_EVT, ¶m); + } + } break; } case BTA_AG_REGISTER_EVT: @@ -1274,6 +1312,11 @@ void btc_hf_cb_handler(btc_msg_t *msg) hf_local_param[idx].btc_hf_cb.handle = p_data->reg.hdr.handle; BTC_TRACE_DEBUG("%s: BTA_AG_REGISTER_EVT," "hf_local_param[%d].btc_hf_cb.handle = %d", __FUNCTION__, idx, hf_local_param[idx].btc_hf_cb.handle); + if (!hf_local_param[idx].btc_hf_cb.initialized) { + param.prof_stat.state = ESP_HF_INIT_SUCCESS; + btc_hf_cb_to_app(ESP_HF_PROF_STATE_EVT, ¶m); + } + hf_local_param[idx].btc_hf_cb.initialized = true; break; } diff --git a/components/bt/host/bluedroid/btc/profile/std/hf_client/btc_hf_client.c b/components/bt/host/bluedroid/btc/profile/std/hf_client/btc_hf_client.c index 3909a4c6f6..d3ac2a433a 100644 --- a/components/bt/host/bluedroid/btc/profile/std/hf_client/btc_hf_client.c +++ b/components/bt/host/bluedroid/btc/profile/std/hf_client/btc_hf_client.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -168,12 +168,18 @@ bt_status_t btc_hf_client_init(void) BTC_TRACE_EVENT("%s", __FUNCTION__); uint8_t data_path; + if (hf_client_local_param.btc_hf_client_cb.initialized) { + esp_hf_client_cb_param_t param = { + .prof_stat.state = ESP_HF_INIT_ALREADY, + }; + btc_hf_client_cb_to_app(ESP_HF_CLIENT_PROF_STATE_EVT, ¶m); + return BT_STATUS_SUCCESS; + } + btc_dm_enable_service(BTA_HFP_HS_SERVICE_ID); clear_state(); - hf_client_local_param.btc_hf_client_cb.initialized = true; - #if BTM_SCO_HCI_INCLUDED data_path = ESP_SCO_DATA_PATH_HCI; #else @@ -229,9 +235,15 @@ void btc_hf_client_deinit( void ) { BTC_TRACE_EVENT("%s", __FUNCTION__); - btc_dm_disable_service(BTA_HFP_HS_SERVICE_ID); + if (!hf_client_local_param.btc_hf_client_cb.initialized) { + esp_hf_client_cb_param_t param = { + .prof_stat.state = ESP_HF_DEINIT_ALREADY, + }; + btc_hf_client_cb_to_app(ESP_HF_CLIENT_PROF_STATE_EVT, ¶m); + return; + } - hf_client_local_param.btc_hf_client_cb.initialized = false; + btc_dm_disable_service(BTA_HFP_HS_SERVICE_ID); } /******************************************************************************* @@ -849,10 +861,21 @@ void btc_hf_client_cb_handler(btc_msg_t *msg) switch (event) { case BTA_HF_CLIENT_ENABLE_EVT: + break; case BTA_HF_CLIENT_DISABLE_EVT: + if (hf_client_local_param.btc_hf_client_cb.initialized) { + param.prof_stat.state = ESP_HF_DEINIT_SUCCESS, + btc_hf_client_cb_to_app(ESP_HF_CLIENT_PROF_STATE_EVT, ¶m); + } + hf_client_local_param.btc_hf_client_cb.initialized = false; break; case BTA_HF_CLIENT_REGISTER_EVT: hf_client_local_param.btc_hf_client_cb.handle = p_data->reg.handle; + if (!hf_client_local_param.btc_hf_client_cb.initialized) { + param.prof_stat.state = ESP_HF_INIT_SUCCESS, + btc_hf_client_cb_to_app(ESP_HF_CLIENT_PROF_STATE_EVT, ¶m); + } + hf_client_local_param.btc_hf_client_cb.initialized = true; break; case BTA_HF_CLIENT_OPEN_EVT: if (p_data->open.status == BTA_HF_CLIENT_SUCCESS) diff --git a/components/bt/host/bluedroid/btc/profile/std/include/bt_sdp.h b/components/bt/host/bluedroid/btc/profile/std/include/bt_sdp.h index 63ca09a80f..bc30fb3cf7 100644 --- a/components/bt/host/bluedroid/btc/profile/std/include/bt_sdp.h +++ b/components/bt/host/bluedroid/btc/profile/std/include/bt_sdp.h @@ -34,55 +34,43 @@ typedef enum { SDP_TYPE_PBAP_PSE, // Phone Book Profile - Server SDP_TYPE_PBAP_PCE, // Phone Book Profile - Client SDP_TYPE_OPP_SERVER, // Object Push Profile - SDP_TYPE_SAP_SERVER // SIM Access Profile + SDP_TYPE_SAP_SERVER, // SIM Access Profile } bluetooth_sdp_types; -typedef struct _bluetooth_sdp_hdr { - bluetooth_sdp_types type; - esp_bt_uuid_t uuid; - uint32_t service_name_length; - char *service_name; - int32_t rfcomm_channel_number; - int32_t l2cap_psm; - int32_t profile_version; -} bluetooth_sdp_hdr; - /** * Some signals need additional pointers, hence we introduce a * generic way to handle these pointers. */ typedef struct _bluetooth_sdp_hdr_overlay { bluetooth_sdp_types type; - esp_bt_uuid_t bt_uuid; - uint32_t service_name_length; - char *service_name; - int32_t rfcomm_channel_number; - int32_t l2cap_psm; - int32_t profile_version; - - // User pointers, only used for some signals - see bluetooth_sdp_ops_record - int user1_ptr_len; - uint8_t *user1_ptr; - int user2_ptr_len; - uint8_t *user2_ptr; + esp_bt_uuid_t uuid; + uint32_t service_name_length; + char *service_name; + int32_t rfcomm_channel_number; + int32_t l2cap_psm; + int32_t profile_version; + int user1_ptr_len; + uint8_t *user1_ptr; + int user2_ptr_len; // not used + uint8_t *user2_ptr; // not used } bluetooth_sdp_hdr_overlay; typedef struct _bluetooth_sdp_mas_record { bluetooth_sdp_hdr_overlay hdr; - uint32_t mas_instance_id; - uint32_t supported_features; - uint32_t supported_message_types; + uint32_t mas_instance_id; + uint32_t supported_features; + uint32_t supported_message_types; } bluetooth_sdp_mas_record; typedef struct _bluetooth_sdp_mns_record { bluetooth_sdp_hdr_overlay hdr; - uint32_t supported_features; + uint32_t supported_features; } bluetooth_sdp_mns_record; typedef struct _bluetooth_sdp_pse_record { bluetooth_sdp_hdr_overlay hdr; - uint32_t supported_features; - uint32_t supported_repositories; + uint32_t supported_features; + uint32_t supported_repositories; } bluetooth_sdp_pse_record; typedef struct _bluetooth_sdp_pce_record { @@ -91,8 +79,8 @@ typedef struct _bluetooth_sdp_pce_record { typedef struct _bluetooth_sdp_ops_record { bluetooth_sdp_hdr_overlay hdr; - int supported_formats_list_len; - uint8_t supported_formats_list[SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH]; + int supported_formats_list_len; + uint8_t supported_formats_list[SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH]; } bluetooth_sdp_ops_record; typedef struct _bluetooth_sdp_sap_record { @@ -100,13 +88,13 @@ typedef struct _bluetooth_sdp_sap_record { } bluetooth_sdp_sap_record; typedef union { - bluetooth_sdp_hdr_overlay hdr; - bluetooth_sdp_mas_record mas; - bluetooth_sdp_mns_record mns; - bluetooth_sdp_pse_record pse; - bluetooth_sdp_pce_record pce; - bluetooth_sdp_ops_record ops; - bluetooth_sdp_sap_record sap; + bluetooth_sdp_hdr_overlay hdr; + bluetooth_sdp_mas_record mas; + bluetooth_sdp_mns_record mns; + bluetooth_sdp_pse_record pse; + bluetooth_sdp_pce_record pce; + bluetooth_sdp_ops_record ops; + bluetooth_sdp_sap_record sap; } bluetooth_sdp_record; #endif /* __BT_SDP_H__ */ diff --git a/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h b/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h index 69e95eb66d..e55c521420 100644 --- a/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h +++ b/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h @@ -11,11 +11,13 @@ #include "esp_gap_ble_api.h" #if BTC_DYNAMIC_MEMORY == TRUE +#if (BLE_42_FEATURE_SUPPORT == TRUE) #include "bta/bta_api.h" extern tBTA_BLE_ADV_DATA *gl_bta_adv_data_ptr; extern tBTA_BLE_ADV_DATA *gl_bta_scan_rsp_data_ptr; #define gl_bta_adv_data (*gl_bta_adv_data_ptr) #define gl_bta_scan_rsp_data (*gl_bta_scan_rsp_data_ptr) +#endif // BLE_42_FEATURE_SUPPORT #endif #define BLE_ISVALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max))) @@ -106,6 +108,7 @@ typedef enum { BTC_GAP_BLE_ACT_ADD_DEVICE_TO_RESOLVING_LIST, BTC_GAP_BLE_ACT_VENDOR_HCI_CMD_EVT, BTC_GAP_BLE_SET_PRIVACY_MODE, + BTC_GAP_BLE_SET_CSA_SUPPORT, } btc_gap_ble_act_t; /* btc_ble_gap_args_t */ @@ -274,6 +277,10 @@ typedef union { esp_bd_addr_t addr; uint8_t privacy_mode; } set_privacy_mode; + // BTC_GAP_BLE_SET_CSA_SUPPORT + struct set_csa_support_args { + uint8_t csa_select; + } set_csa_support; } btc_ble_gap_args_t; #if (BLE_50_FEATURE_SUPPORT == TRUE) diff --git a/components/bt/host/bluedroid/btc/profile/std/include/btc_gatt_util.h b/components/bt/host/bluedroid/btc/profile/std/include/btc_gatt_util.h index 3eb38abd3e..487708e6cb 100644 --- a/components/bt/host/bluedroid/btc/profile/std/include/btc_gatt_util.h +++ b/components/bt/host/bluedroid/btc/profile/std/include/btc_gatt_util.h @@ -9,6 +9,7 @@ #include "stack/bt_types.h" #include "bta/bta_gatt_api.h" +#include "btc/btc_util.h" #include "esp_bt_defs.h" #include "esp_gatt_defs.h" #include "esp_gattc_api.h" @@ -18,12 +19,10 @@ #define BTC_GATT_GET_GATT_IF(conn_id) ((uint8_t)(conn_id)) void btc128_to_bta_uuid(tBT_UUID *p_dest, uint8_t *p_src); -void btc_to_bta_uuid(tBT_UUID *p_dest, esp_bt_uuid_t *p_src); void btc_to_bta_gatt_id(tBTA_GATT_ID *p_dest, esp_gatt_id_t *p_src); void btc_to_bta_srvc_id(tBTA_GATT_SRVC_ID *p_dest, esp_gatt_srvc_id_t *p_src); void btc_to_bta_response(tBTA_GATTS_RSP *rsp_struct, esp_gatt_rsp_t *p_rsp); -void bta_to_btc_uuid(esp_bt_uuid_t *p_dest, tBT_UUID *p_src); void bta_to_btc_gatt_id(esp_gatt_id_t *p_dest, tBTA_GATT_ID *p_src); void bta_to_btc_srvc_id(esp_gatt_srvc_id_t *p_dest, tBTA_GATT_SRVC_ID *p_src); diff --git a/components/bt/host/bluedroid/btc/profile/std/include/btc_gattc.h b/components/bt/host/bluedroid/btc/profile/std/include/btc_gattc.h index eeebb427f2..1c8ef828b0 100644 --- a/components/bt/host/bluedroid/btc/profile/std/include/btc_gattc.h +++ b/components/bt/host/bluedroid/btc/profile/std/include/btc_gattc.h @@ -57,6 +57,11 @@ typedef union { esp_ble_addr_type_t remote_addr_type; bool is_direct; bool is_aux; + esp_ble_addr_type_t own_addr_type; + esp_ble_phy_mask_t phy_mask; + esp_ble_conn_params_t phy_1m_conn_params; + esp_ble_conn_params_t phy_2m_conn_params; + esp_ble_conn_params_t phy_coded_conn_params; } open; //BTC_GATTC_ACT_CLOSE, struct close_arg { diff --git a/components/bt/host/bluedroid/btc/profile/std/include/btc_sdp.h b/components/bt/host/bluedroid/btc/profile/std/include/btc_sdp.h index 60772fa3c4..fa117988e9 100644 --- a/components/bt/host/bluedroid/btc/profile/std/include/btc_sdp.h +++ b/components/bt/host/bluedroid/btc/profile/std/include/btc_sdp.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -32,9 +32,9 @@ typedef union { } search; //BTC_SDP_ACT_CREATE_RECORD - struct creat_record_arg { + struct create_record_arg { bluetooth_sdp_record *record; - } creat_record; + } create_record; //BTC_SDP_ACT_REMOVE_RECORD struct remove_record_arg { diff --git a/components/bt/host/bluedroid/btc/profile/std/l2cap/btc_l2cap.c b/components/bt/host/bluedroid/btc/profile/std/l2cap/btc_l2cap.c index 7c5157736a..12e55c6218 100644 --- a/components/bt/host/bluedroid/btc/profile/std/l2cap/btc_l2cap.c +++ b/components/bt/host/bluedroid/btc/profile/std/l2cap/btc_l2cap.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -281,7 +281,7 @@ static void close_timeout_handler(void *arg) status = btc_transfer_context(&msg, slot->alarm_arg, sizeof(tBTA_JV), NULL, NULL); if (slot->alarm_arg) { - free(slot->alarm_arg); + osi_free(slot->alarm_arg); slot->alarm_arg = NULL; } @@ -832,7 +832,7 @@ void btc_l2cap_cb_handler(btc_msg_t *msg) // if rx still has data, delay free slot if (slot->close_alarm == NULL && slot->rx.queue && fixed_queue_length(slot->rx.queue) > 0) { tBTA_JV *p_arg = NULL; - if ((p_arg = malloc(sizeof(tBTA_JV))) == NULL) { + if ((p_arg = osi_malloc(sizeof(tBTA_JV))) == NULL) { param.close.status = ESP_BT_L2CAP_NO_RESOURCE; osi_mutex_unlock(&l2cap_local_param.l2cap_slot_mutex); BTC_TRACE_ERROR("%s unable to malloc slot close_alarm arg!", __func__); @@ -842,7 +842,7 @@ void btc_l2cap_cb_handler(btc_msg_t *msg) slot->alarm_arg = (void *)p_arg; if ((slot->close_alarm = osi_alarm_new("slot", close_timeout_handler, (void *)slot, VFS_CLOSE_TIMEOUT)) == NULL) { - free(p_arg); + osi_free(p_arg); slot->alarm_arg = NULL; param.close.status = ESP_BT_L2CAP_NO_RESOURCE; osi_mutex_unlock(&l2cap_local_param.l2cap_slot_mutex); @@ -850,7 +850,7 @@ void btc_l2cap_cb_handler(btc_msg_t *msg) break; } if (osi_alarm_set(slot->close_alarm, VFS_CLOSE_TIMEOUT) != OSI_ALARM_ERR_PASS) { - free(p_arg); + osi_free(p_arg); slot->alarm_arg = NULL; osi_alarm_free(slot->close_alarm); param.close.status = ESP_BT_L2CAP_BUSY; diff --git a/components/bt/host/bluedroid/btc/profile/std/sdp/btc_sdp.c b/components/bt/host/bluedroid/btc/profile/std/sdp/btc_sdp.c index 6eaf6cfb52..a07fd32c18 100644 --- a/components/bt/host/bluedroid/btc/profile/std/sdp/btc_sdp.c +++ b/components/bt/host/bluedroid/btc/profile/std/sdp/btc_sdp.c @@ -9,6 +9,7 @@ #include "btc_sdp.h" #include "btc/btc_manage.h" #include "btc/btc_task.h" +#include "btc/btc_util.h" #include "bta/bta_sdp_api.h" #include "bta/bta_sys.h" #include "bta/utl.h" @@ -25,12 +26,14 @@ typedef enum { } sdp_state_t; typedef struct { - sdp_state_t state; + uint8_t state; int sdp_handle; - bluetooth_sdp_record* record_data; + esp_bt_uuid_t uuid; + void* record_data; } sdp_slot_t; typedef struct { + bool search_allowed; sdp_slot_t *sdp_slots[SDP_MAX_RECORDS]; osi_mutex_t sdp_slot_mutex; } sdp_local_param_t; @@ -48,6 +51,21 @@ static sdp_local_param_t *sdp_local_param_ptr; #define is_sdp_init() (&sdp_local_param != NULL && sdp_local_param.sdp_slot_mutex != NULL) #endif +static void btc_sdp_cleanup(void) +{ +#if SDP_DYNAMIC_MEMORY == TRUE + if (sdp_local_param_ptr) { +#endif + if (sdp_local_param.sdp_slot_mutex) { + osi_mutex_free(&sdp_local_param.sdp_slot_mutex); + sdp_local_param.sdp_slot_mutex = NULL; + } +#if SDP_DYNAMIC_MEMORY == TRUE + osi_free(sdp_local_param_ptr); + sdp_local_param_ptr = NULL; + } +#endif +} static inline void btc_sdp_cb_to_app(esp_sdp_cb_event_t event, esp_sdp_cb_param_t *param) { @@ -57,46 +75,25 @@ static inline void btc_sdp_cb_to_app(esp_sdp_cb_event_t event, esp_sdp_cb_param_ } } -static void sdp_disable_handler(void) -{ - btc_msg_t msg; - bt_status_t status; - - msg.sig = BTC_SIG_API_CB; - msg.pid = BTC_PID_SDP; - msg.act = BTA_SDP_DISENABLE_EVT; - - status = btc_transfer_context(&msg, NULL, 0, NULL, NULL); - - if (status != BT_STATUS_SUCCESS) { - BTC_TRACE_ERROR("%s btc_transfer_context failed", __func__); - } -} - -static int get_sdp_records_size(bluetooth_sdp_record* in_record, int count) +static int get_sdp_record_size(bluetooth_sdp_record* in_record) { - bluetooth_sdp_record* record = in_record; + bluetooth_sdp_record *record = in_record; int records_size = 0; - for(int i = 0; i < count; i++) { - record = &in_record[i]; - records_size += sizeof(bluetooth_sdp_record); - records_size += record->hdr.service_name_length; - if(record->hdr.service_name_length > 0){ - records_size++; /* + '\0' termination of string */ - } - records_size += record->hdr.user1_ptr_len; - records_size += record->hdr.user2_ptr_len; + records_size += sizeof(bluetooth_sdp_record); + records_size += record->hdr.service_name_length; + if (record->hdr.service_name_length > 0) { + records_size++; /* + '\0' termination of string */ } return records_size; } -static void set_sdp_handle(int id, int handle) +static void set_sdp_slot_info(int id, int sdp_handle, esp_bt_uuid_t *uuid) { sdp_slot_t *slot = NULL; - BTC_TRACE_DEBUG("%s() id=%d to handle=0x%08x", __func__, id, handle); + BTC_TRACE_DEBUG("%s() id=%d to sdp_handle=0x%08x", __func__, id, sdp_handle); if(id >= SDP_MAX_RECORDS) { BTC_TRACE_ERROR("%s() failed - id %d is invalid", __func__, id); @@ -104,34 +101,64 @@ static void set_sdp_handle(int id, int handle) } osi_mutex_lock(&sdp_local_param.sdp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); - slot = sdp_local_param.sdp_slots[id]; - if (slot == NULL) { - osi_mutex_unlock(&sdp_local_param.sdp_slot_mutex); - BTC_TRACE_ERROR("%s() id=%d to handle=0x%08x, set failed", __func__, id, handle); - return; - } - slot->sdp_handle = handle; + + do { + slot = sdp_local_param.sdp_slots[id]; + if (slot == NULL) { + BTC_TRACE_ERROR("%s() id = %d ", __func__, id); + break; + } + + if (slot->state != SDP_RECORD_ALLOCED) { + BTC_TRACE_ERROR("%s() failed - state for id %d is state = %d expected %d", __func__, id, + sdp_local_param.sdp_slots[id]->state, SDP_RECORD_ALLOCED); + break; + } + slot->sdp_handle = sdp_handle; + slot->record_data = NULL; + if (uuid) { + memcpy(&slot->uuid, uuid, sizeof(esp_bt_uuid_t)); + } else { + memset(&slot->uuid, 0, sizeof(esp_bt_uuid_t)); + } + } while (0); + osi_mutex_unlock(&sdp_local_param.sdp_slot_mutex); } - -static bool get_sdp_record_by_handle(int handle, bluetooth_sdp_record* record) +static void get_sdp_slot_info(int id, int *sdp_handle, esp_bt_uuid_t *uuid) { sdp_slot_t *slot = NULL; + if(id >= SDP_MAX_RECORDS) { + BTC_TRACE_ERROR("%s() failed - id %d is invalid", __func__, id); + return; + } + osi_mutex_lock(&sdp_local_param.sdp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); - for (int i = 0; i < SDP_MAX_RECORDS; i++) { - slot = sdp_local_param.sdp_slots[i]; - if ((slot != NULL) && (slot->sdp_handle == handle)) { - memcpy(record, slot->record_data, sizeof(bluetooth_sdp_record)); - osi_mutex_unlock(&sdp_local_param.sdp_slot_mutex); - return true; + do { + slot = sdp_local_param.sdp_slots[id]; + if (slot == NULL) { + break; } - } + + if (slot->state != SDP_RECORD_ALLOCED) { + BTC_TRACE_ERROR("%s() failed - state for id %d is state = %d expected %d", __func__, id, + sdp_local_param.sdp_slots[id]->state, SDP_RECORD_ALLOCED); + break; + } + + if (sdp_handle) { + *sdp_handle = slot->sdp_handle; + } + + if (uuid) { + memcpy(uuid, &slot->uuid, sizeof(esp_bt_uuid_t)); + } + } while (0); osi_mutex_unlock(&sdp_local_param.sdp_slot_mutex); - return false; } static int get_sdp_slot_id_by_handle(int handle) @@ -152,9 +179,10 @@ static int get_sdp_slot_id_by_handle(int handle) return -1; } -static sdp_slot_t *start_create_sdp(int id) +static bluetooth_sdp_record *start_create_sdp(int id) { - sdp_slot_t *sdp_slot = NULL; + sdp_slot_t *slot = NULL; + bluetooth_sdp_record* record_data = NULL; if(id >= SDP_MAX_RECORDS) { BTC_TRACE_ERROR("%s() failed - id %d is invalid", __func__, id); @@ -162,62 +190,58 @@ static sdp_slot_t *start_create_sdp(int id) } osi_mutex_lock(&sdp_local_param.sdp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); - sdp_slot = sdp_local_param.sdp_slots[id]; - if (sdp_slot == NULL) { - BTC_TRACE_ERROR("%s() id = %d ", __func__, id); - } else if(sdp_slot->state != SDP_RECORD_ALLOCED) { - BTC_TRACE_ERROR("%s() failed - state for id %d is state = %d expected %d", __func__, - id, sdp_local_param.sdp_slots[id]->state, SDP_RECORD_ALLOCED); - /* The record have been removed before this event occurred - e.g. deinit */ - sdp_slot = NULL; - } + + do { + slot = sdp_local_param.sdp_slots[id]; + if (slot == NULL) { + BTC_TRACE_ERROR("%s() id = %d ", __func__, id); + break; + } + + if (slot->state != SDP_RECORD_ALLOCED) { + BTC_TRACE_ERROR("%s() failed - state for id %d is state = %d expected %d", __func__, id, + sdp_local_param.sdp_slots[id]->state, SDP_RECORD_ALLOCED); + break; + } + record_data = slot->record_data; + } while (0); + osi_mutex_unlock(&sdp_local_param.sdp_slot_mutex); - return sdp_slot; + return record_data; } /* Deep copy all content of in_records into out_records. * out_records must point to a chunk of memory large enough to contain all * the data. Use getSdpRecordsSize() to calculate the needed size. */ -static void copy_sdp_records(bluetooth_sdp_record* in_records, bluetooth_sdp_record* out_records, int count) +static void copy_sdp_record_common(bluetooth_sdp_record* in_record, bluetooth_sdp_record* out_record) { - bluetooth_sdp_record *in_record; - bluetooth_sdp_record *out_record; - char *free_ptr = (char*)(&out_records[count]); /* set pointer to after the last entry */ - - for(int i = 0; i < count; i++) { - in_record = &in_records[i]; - out_record = &out_records[i]; - *out_record = *in_record; - - if(in_record->hdr.service_name == NULL || in_record->hdr.service_name_length == 0) { - out_record->hdr.service_name = NULL; - out_record->hdr.service_name_length = 0; - } else { - out_record->hdr.service_name = free_ptr; // Update service_name pointer - // Copy string - memcpy(free_ptr, in_record->hdr.service_name, in_record->hdr.service_name_length); - free_ptr += in_record->hdr.service_name_length; - *(free_ptr) = '\0'; // Set '\0' termination of string - free_ptr++; - } - if(in_record->hdr.user1_ptr != NULL) { - out_record->hdr.user1_ptr = (UINT8*)free_ptr; // Update pointer - memcpy(free_ptr, in_record->hdr.user1_ptr, in_record->hdr.user1_ptr_len); // Copy content - free_ptr += in_record->hdr.user1_ptr_len; - } - if(in_record->hdr.user2_ptr != NULL) { - out_record->hdr.user2_ptr = (UINT8*)free_ptr; // Update pointer - memcpy(free_ptr, in_record->hdr.user2_ptr, in_record->hdr.user2_ptr_len); // Copy content - free_ptr += in_record->hdr.user2_ptr_len; - } + uint8_t *free_ptr = (uint8_t *)(out_record + 1); /* set pointer to after the last entry */ + + memcpy(out_record, in_record, sizeof(bluetooth_sdp_record)); + + if (in_record->hdr.service_name == NULL || in_record->hdr.service_name_length == 0) { + out_record->hdr.service_name = NULL; + out_record->hdr.service_name_length = 0; + } else { + out_record->hdr.service_name = (char *)free_ptr; // Update service_name pointer + // Copy string + memcpy(free_ptr, in_record->hdr.service_name, in_record->hdr.service_name_length); + free_ptr += in_record->hdr.service_name_length; + *(free_ptr) = '\0'; // Set '\0' termination of string + free_ptr++; } } +static void copy_sdp_record(bluetooth_sdp_record* in_record, bluetooth_sdp_record* out_record) +{ + copy_sdp_record_common(in_record, out_record); +} + static int alloc_sdp_slot(bluetooth_sdp_record* in_record) { int i; - int record_size = get_sdp_records_size(in_record, 1); + int record_size = get_sdp_record_size(in_record); bluetooth_sdp_record *record = NULL; sdp_slot_t **slot = NULL; @@ -227,11 +251,10 @@ static int alloc_sdp_slot(bluetooth_sdp_record* in_record) return -1; } - copy_sdp_records(in_record, record, 1); + copy_sdp_record(in_record, record); osi_mutex_lock(&sdp_local_param.sdp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT); - for(i = 0; i < SDP_MAX_RECORDS; i++) - { + for (i = 0; i < SDP_MAX_RECORDS; i++) { slot = &sdp_local_param.sdp_slots[i]; if ((*slot) == NULL) { if (((*slot) = (sdp_slot_t *)osi_malloc(sizeof(sdp_slot_t))) == NULL) { @@ -240,8 +263,8 @@ static int alloc_sdp_slot(bluetooth_sdp_record* in_record) osi_free(record); return -1; } - (*slot)->state = SDP_RECORD_ALLOCED; - (*slot)->record_data = record; + (*slot)->state = SDP_RECORD_ALLOCED; + (*slot)->record_data = record; break; } } @@ -292,7 +315,7 @@ static int free_sdp_slot(int id) } /* Create a raw SDP record based on information stored in a bluetooth_sdp_raw_record */ -static int add_raw_sdp(const bluetooth_sdp_record* rec) +static int add_raw_sdp(const bluetooth_sdp_record *rec) { tSDP_PROTOCOL_ELEM protoList [2]; UINT16 browse = UUID_SERVCLASS_PUBLIC_BROWSE_GROUP; @@ -301,6 +324,7 @@ static int add_raw_sdp(const bluetooth_sdp_record* rec) UINT8 temp[LEN_UUID_128]; UINT8* p_temp = temp; UINT32 sdp_handle = 0; + const esp_bt_uuid_t *p_uuid = &rec->hdr.uuid; BTC_TRACE_DEBUG("%s(): scn 0x%02x, psm = 0x%04x\n service name %s", __func__, rec->hdr.rfcomm_channel_number, rec->hdr.l2cap_psm, rec->hdr.service_name); @@ -310,15 +334,15 @@ static int add_raw_sdp(const bluetooth_sdp_record* rec) return sdp_handle; } - if (rec->hdr.bt_uuid.len == ESP_UUID_LEN_16) { + if (p_uuid->len == ESP_UUID_LEN_16) { UINT8_TO_BE_STREAM (p_temp, (UUID_DESC_TYPE << 3) | SIZE_TWO_BYTES); - UINT16_TO_BE_STREAM (p_temp, rec->hdr.bt_uuid.uuid.uuid16); - } else if (rec->hdr.bt_uuid.len == ESP_UUID_LEN_32) { + UINT16_TO_BE_STREAM (p_temp, p_uuid->uuid.uuid16); + } else if (p_uuid->len == ESP_UUID_LEN_32) { UINT8_TO_BE_STREAM (p_temp, (UUID_DESC_TYPE << 3) | SIZE_FOUR_BYTES); - UINT32_TO_BE_STREAM (p_temp, rec->hdr.bt_uuid.uuid.uuid32); - } else if (rec->hdr.bt_uuid.len == ESP_UUID_LEN_128) { + UINT32_TO_BE_STREAM (p_temp, p_uuid->uuid.uuid32); + } else if (p_uuid->len == ESP_UUID_LEN_128) { UINT8_TO_BE_STREAM (p_temp, (UUID_DESC_TYPE << 3) | SIZE_SIXTEEN_BYTES); - ARRAY_TO_BE_STREAM (p_temp, rec->hdr.bt_uuid.uuid.uuid128, LEN_UUID_128); + ARRAY_TO_BE_STREAM (p_temp, p_uuid->uuid.uuid128, LEN_UUID_128); } else { SDP_DeleteRecord(sdp_handle); sdp_handle = 0; @@ -357,7 +381,7 @@ static int add_raw_sdp(const bluetooth_sdp_record* rec) UINT_DESC_TYPE, (UINT32)2, temp); } - /* Make the service browseable */ + /* Make the service browsable */ status &= SDP_AddUuidSequence (sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, &browse); if (!status) { @@ -365,12 +389,12 @@ static int add_raw_sdp(const bluetooth_sdp_record* rec) sdp_handle = 0; BTC_TRACE_ERROR("%s() FAILED, status = %d", __func__, status); } else { - if (rec->hdr.bt_uuid.len == ESP_UUID_LEN_16) { - bta_sys_add_uuid(rec->hdr.bt_uuid.uuid.uuid16); - } else if (rec->hdr.bt_uuid.len == ESP_UUID_LEN_32) { - bta_sys_add_uuid_32(rec->hdr.bt_uuid.uuid.uuid32); - } else if (rec->hdr.bt_uuid.len == ESP_UUID_LEN_128) { - bta_sys_add_uuid_128((UINT8 *)&rec->hdr.bt_uuid.uuid.uuid128); + if (p_uuid->len == ESP_UUID_LEN_16) { + bta_sys_add_uuid(p_uuid->uuid.uuid16); + } else if (p_uuid->len == ESP_UUID_LEN_32) { + bta_sys_add_uuid_32(p_uuid->uuid.uuid32); + } else if (p_uuid->len == ESP_UUID_LEN_128) { + bta_sys_add_uuid_128((UINT8 *)&p_uuid->uuid.uuid128); } BTC_TRACE_DEBUG("%s(): SDP Registered (handle 0x%08x)", __func__, sdp_handle); } @@ -448,7 +472,7 @@ static int add_maps_sdp(const bluetooth_sdp_mas_record* rec) UINT_DESC_TYPE, (UINT32)2, temp); } - /* Make the service browseable */ + /* Make the service browsable */ status &= SDP_AddUuidSequence (sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, &browse); if (!status) { @@ -523,7 +547,7 @@ static int add_mapc_sdp(const bluetooth_sdp_mns_record* rec) UINT_DESC_TYPE, (UINT32)2, temp); } - /* Make the service browseable */ + /* Make the service browsable */ status &= SDP_AddUuidSequence (sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, &browse); if (!status) { @@ -603,7 +627,7 @@ static int add_pbaps_sdp(const bluetooth_sdp_pse_record* rec) UINT_DESC_TYPE, (UINT32)2, temp); } - /* Make the service browseable */ + /* Make the service browsable */ status &= SDP_AddUuidSequence (sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, &browse); if (!status) { @@ -649,7 +673,7 @@ static int add_pbapc_sdp(const bluetooth_sdp_pce_record* rec) UUID_SERVCLASS_PHONE_ACCESS, rec->hdr.profile_version); - /* Make the service browseable */ + /* Make the service browsable */ status &= SDP_AddUuidSequence (sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, &browse); if (!status) { @@ -736,7 +760,7 @@ static int add_opps_sdp(const bluetooth_sdp_ops_record* rec) UINT_DESC_TYPE, (UINT32)2, temp); } - /* Make the service browseable */ + /* Make the service browsable */ status &= SDP_AddUuidSequence (sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, &browse); if (!status) { @@ -799,7 +823,7 @@ static int add_saps_sdp(const bluetooth_sdp_sap_record* rec) UUID_SERVCLASS_SAP, rec->hdr.profile_version); - // Make the service browseable + // Make the service browsable status &= SDP_AddUuidSequence (sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, &browse); if (!status) { @@ -816,64 +840,183 @@ static int add_saps_sdp(const bluetooth_sdp_sap_record* rec) static int btc_handle_create_record_event(int id) { - int handle = -1; - const sdp_slot_t *sdp_slot = NULL; + int sdp_handle = 0; + bluetooth_sdp_record *record = start_create_sdp(id); + esp_bt_uuid_t service_uuid = {0}; BTC_TRACE_DEBUG("Sdp Server %s", __func__); - sdp_slot = start_create_sdp(id); - if(sdp_slot != NULL) { - bluetooth_sdp_record* record = sdp_slot->record_data; - switch(record->hdr.type) { + if (record != NULL) { + switch (record->hdr.type) { case SDP_TYPE_RAW: - handle = add_raw_sdp(record); + sdp_handle = add_raw_sdp(record); + memcpy(&service_uuid, &record->hdr.uuid, sizeof(esp_bt_uuid_t)); break; case SDP_TYPE_MAP_MAS: - handle = add_maps_sdp(&record->mas); + sdp_handle = add_maps_sdp(&record->mas); + service_uuid.len = ESP_UUID_LEN_16; + service_uuid.uuid.uuid16 = UUID_SERVCLASS_MESSAGE_ACCESS; break; case SDP_TYPE_MAP_MNS: - handle = add_mapc_sdp(&record->mns); + sdp_handle = add_mapc_sdp(&record->mns); + service_uuid.len = ESP_UUID_LEN_16; + service_uuid.uuid.uuid16 = UUID_SERVCLASS_MESSAGE_NOTIFICATION; break; case SDP_TYPE_PBAP_PSE: - handle = add_pbaps_sdp(&record->pse); + sdp_handle = add_pbaps_sdp(&record->pse); + service_uuid.len = ESP_UUID_LEN_16; + service_uuid.uuid.uuid16 = UUID_SERVCLASS_PBAP_PSE; break; case SDP_TYPE_PBAP_PCE: - handle = add_pbapc_sdp(&record->pce); + sdp_handle = add_pbapc_sdp(&record->pce); + service_uuid.len = ESP_UUID_LEN_16; + service_uuid.uuid.uuid16 = UUID_SERVCLASS_PBAP_PCE; break; case SDP_TYPE_OPP_SERVER: - handle = add_opps_sdp(&record->ops); + sdp_handle = add_opps_sdp(&record->ops); + service_uuid.len = ESP_UUID_LEN_16; + service_uuid.uuid.uuid16 = UUID_SERVCLASS_OBEX_OBJECT_PUSH; break; case SDP_TYPE_SAP_SERVER: - handle = add_saps_sdp(&record->sap); + sdp_handle = add_saps_sdp(&record->sap); + service_uuid.len = ESP_UUID_LEN_16; + service_uuid.uuid.uuid16 = UUID_SERVCLASS_SAP; break; default: - BTC_TRACE_DEBUG("Record type %d is not supported",record->hdr.type); + BTC_TRACE_DEBUG("Record type %d is not supported", record->hdr.type); break; } - if(handle != -1) { - set_sdp_handle(id, handle); + + if(sdp_handle != 0) { + set_sdp_slot_info(id, sdp_handle, &service_uuid); + // free the record, since not use it anymore + osi_free(record); + } else { + sdp_handle = -1; } + } else { + sdp_handle = -1; } - return handle; + if (sdp_handle == -1) { + free_sdp_slot(id); + } + + return sdp_handle; } -static bool btc_sdp_remove_record_event(int handle) +static bool btc_sdp_remove_record_event(int id, int *p_sdp_handle) { + BTC_TRACE_DEBUG("Sdp Server %s", __func__); + bool result = false; + int sdp_handle = -1; + esp_bt_uuid_t service_uuid = {0}; - BTC_TRACE_DEBUG("Sdp Server %s", __func__); + get_sdp_slot_info(id, &sdp_handle, &service_uuid); - if(handle != -1 && handle != 0) { - result = SDP_DeleteRecord(handle); - if(result == false) { - BTC_TRACE_ERROR(" Unable to remove handle 0x%08x", handle); + if (sdp_handle > 0) { + do { + result = SDP_DeleteRecord(sdp_handle); + if (!result) { + BTC_TRACE_ERROR("Unable to remove handle 0x%08x", sdp_handle); + break; + } + + if (service_uuid.len == ESP_UUID_LEN_16) { + bta_sys_remove_uuid(service_uuid.uuid.uuid16); + } else if (service_uuid.len == ESP_UUID_LEN_32) { + bta_sys_remove_uuid_32(service_uuid.uuid.uuid32); + } else if (service_uuid.len == ESP_UUID_LEN_128) { + bta_sys_remove_uuid_128((UINT8 *)&service_uuid.uuid.uuid128); + } + } while (0); + + if (p_sdp_handle) { + *p_sdp_handle = sdp_handle; } } return result; } +static void btc_sdp_cb_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) +{ + switch (msg->act) { + case BTA_SDP_SEARCH_COMP_EVT: { + tBTA_SDP_SEARCH_COMP *src_search_comp = (tBTA_SDP_SEARCH_COMP *)p_src; + tBTA_SDP_SEARCH_COMP *dest_search_comp = (tBTA_SDP_SEARCH_COMP *)p_dest; + int record_count = src_search_comp->record_count; + + for (int i = 0; i < record_count; i++) { + bluetooth_sdp_record *src_record = &src_search_comp->records[i]; + bluetooth_sdp_record *dest_record = &dest_search_comp->records[i]; + // deep copy service name + uint32_t src_service_name_length = src_record->hdr.service_name_length; + char *src_service_name = src_record->hdr.service_name; + dest_record->hdr.service_name_length = 0; + dest_record->hdr.service_name = NULL; + if (src_service_name && src_service_name_length) { + char *service_name = (char *)osi_malloc(src_service_name_length + 1); + if (service_name) { + memcpy(service_name, src_service_name, src_service_name_length); + service_name[src_service_name_length] = '\0'; + + dest_record->hdr.service_name_length = src_service_name_length; + dest_record->hdr.service_name = service_name; + } else { + BTC_TRACE_ERROR("%s malloc service name failed, orig service name:%s", __func__, src_service_name); + } + } + + // deep copy user1_ptr fow RAW type + int src_user1_ptr_len = src_record->hdr.user1_ptr_len; + uint8_t *src_user1_ptr = src_record->hdr.user1_ptr; + dest_record->hdr.user1_ptr_len = 0; + dest_record->hdr.user1_ptr = NULL; + if (src_record->hdr.type == SDP_TYPE_RAW && src_user1_ptr && src_user1_ptr_len) { + uint8_t *user1_ptr = (uint8_t *)osi_malloc(src_user1_ptr_len); + if (user1_ptr) { + memcpy(user1_ptr, src_user1_ptr, src_user1_ptr_len); + + dest_record->hdr.user1_ptr_len = src_user1_ptr_len; + dest_record->hdr.user1_ptr = user1_ptr; + } else { + BTC_TRACE_ERROR("%s malloc user1_ptr failed", __func__); + } + } + } + + break; + } + default: + break; + } +} + +static void btc_sdp_cb_arg_deep_free(btc_msg_t *msg) +{ + switch (msg->act) { + case BTA_SDP_SEARCH_COMP_EVT: { + tBTA_SDP_SEARCH_COMP *search_comp = (tBTA_SDP_SEARCH_COMP *)msg->arg; + for (size_t i = 0; i < search_comp->record_count; i++) { + bluetooth_sdp_record *record = &search_comp->records[i]; + if (record->hdr.service_name) { + osi_free(record->hdr.service_name); + } + + if (record->hdr.user1_ptr) { + osi_free(record->hdr.user1_ptr); + } + } + + break; + } + default: + break; + } +} + static void btc_sdp_dm_cback(tBTA_SDP_EVT event, tBTA_SDP* p_data, void* user_data) { btc_msg_t msg; @@ -881,18 +1024,18 @@ static void btc_sdp_dm_cback(tBTA_SDP_EVT event, tBTA_SDP* p_data, void* user_da switch (event) { case BTA_SDP_CREATE_RECORD_USER_EVT: { - if (p_data->status == BTA_SDP_SUCCESS) { + if (p_data->sdp_create_record.status == BTA_SDP_SUCCESS) { p_data->sdp_create_record.handle = btc_handle_create_record_event((int)user_data); if (p_data->sdp_create_record.handle < 0) { - p_data->status = BTA_SDP_FAILURE; + p_data->sdp_create_record.status = BTA_SDP_FAILURE; } } } break; case BTA_SDP_REMOVE_RECORD_USER_EVT: { - if (p_data->status == BTA_SDP_SUCCESS) { - if (btc_sdp_remove_record_event((int)user_data) == false) { - p_data->status = BTA_SDP_FAILURE; + if (p_data->sdp_remove_record.status == BTA_SDP_SUCCESS) { + if (btc_sdp_remove_record_event((int)user_data, &p_data->sdp_remove_record.handle) == false) { + p_data->sdp_remove_record.status = BTA_SDP_FAILURE; } } } @@ -905,7 +1048,7 @@ static void btc_sdp_dm_cback(tBTA_SDP_EVT event, tBTA_SDP* p_data, void* user_da msg.pid = BTC_PID_SDP; msg.act = event; - status = btc_transfer_context(&msg, p_data, sizeof(tBTA_SDP), NULL, NULL); + status = btc_transfer_context(&msg, p_data, sizeof(tBTA_SDP), btc_sdp_cb_arg_deep_copy, btc_sdp_cb_arg_deep_free); if (status != BT_STATUS_SUCCESS) { BTC_TRACE_ERROR("%s btc_transfer_context failed", __func__); @@ -930,23 +1073,27 @@ static void btc_sdp_init(void) ret = ESP_SDP_NO_RESOURCE; break; } - memset((void *)sdp_local_param_ptr, 0, sizeof(sdp_local_param_t)); #endif + memset(&sdp_local_param, 0, sizeof(sdp_local_param_t)); if (osi_mutex_new(&sdp_local_param.sdp_slot_mutex) != 0) { -#if SDP_DYNAMIC_MEMORY == TRUE - osi_free(sdp_local_param_ptr); - sdp_local_param_ptr = NULL; -#endif BTC_TRACE_ERROR("%s osi_mutex_new failed\n", __func__); ret = ESP_SDP_NO_RESOURCE; break; } ret = BTA_SdpEnable(btc_sdp_dm_cback); + if (ret != ESP_SDP_SUCCESS) { + BTC_TRACE_ERROR("%s BTA_SdpEnable failed, ret = %d\n", __func__, ret); + ret = ESP_SDP_FAILURE; + break; + } + + sdp_local_param.search_allowed = true; } while(0); if (ret != ESP_SDP_SUCCESS) { + btc_sdp_cleanup(); param.init.status = ret; btc_sdp_cb_to_app(ESP_SDP_INIT_EVT, ¶m); } @@ -956,7 +1103,6 @@ static void btc_sdp_deinit(void) { esp_sdp_cb_param_t param; esp_sdp_status_t ret = ESP_SDP_SUCCESS; - int handle; do { if (!is_sdp_init()) { @@ -966,12 +1112,13 @@ static void btc_sdp_deinit(void) } for(int i = 0; i < SDP_MAX_RECORDS; i++) { - handle = free_sdp_slot(i); - if (handle > 0) { - BTA_SdpRemoveRecordByUser((void*)handle); + int sdp_handle = -1; + get_sdp_slot_info(i, &sdp_handle, NULL); + if (sdp_handle > 0) { + BTA_SdpRemoveRecordByUser((void*)i); } } - sdp_disable_handler(); + BTA_SdpDisable(); } while(0); if (ret != ESP_SDP_SUCCESS) { @@ -982,7 +1129,7 @@ static void btc_sdp_deinit(void) static void btc_sdp_create_record(btc_sdp_args_t *arg) { - int handle; + int slot_id; esp_sdp_cb_param_t param; esp_sdp_status_t ret = ESP_SDP_SUCCESS; @@ -993,13 +1140,13 @@ static void btc_sdp_create_record(btc_sdp_args_t *arg) break; } - handle = alloc_sdp_slot(arg->creat_record.record); - if (handle < 0) { + slot_id = alloc_sdp_slot(arg->create_record.record); + if (slot_id < 0) { ret = ESP_SDP_FAILURE; break; } - BTA_SdpCreateRecordByUser((void *) handle); + BTA_SdpCreateRecordByUser((void *) slot_id); } while(0); if (ret != ESP_SDP_SUCCESS) { @@ -1011,7 +1158,6 @@ static void btc_sdp_create_record(btc_sdp_args_t *arg) static void btc_sdp_remove_record(btc_sdp_args_t *arg) { - int handle; esp_sdp_cb_param_t param; esp_sdp_status_t ret = ESP_SDP_SUCCESS; @@ -1022,42 +1168,16 @@ static void btc_sdp_remove_record(btc_sdp_args_t *arg) break; } - bluetooth_sdp_record rec; - if (get_sdp_record_by_handle(arg->remove_record.record_handle, &rec)) { - if (rec.hdr.bt_uuid.len == ESP_UUID_LEN_16) { - bta_sys_remove_uuid(rec.hdr.bt_uuid.uuid.uuid16); - } else if (rec.hdr.bt_uuid.len == ESP_UUID_LEN_32) { - bta_sys_remove_uuid_32(rec.hdr.bt_uuid.uuid.uuid32); - } else if (rec.hdr.bt_uuid.len == ESP_UUID_LEN_128) { - bta_sys_remove_uuid_128((UINT8 *)&rec.hdr.bt_uuid.uuid.uuid128); - } - } else { - BTC_TRACE_ERROR("%s SDP record with handle %d not found", - __func__, arg->remove_record.record_handle); - ret = ESP_SDP_NO_CREATE_RECORD; - break; - } - /* Get the Record handle, and free the slot */ /* The application layer record_handle is equivalent to the id of the btc layer */ - int slot = get_sdp_slot_id_by_handle(arg->remove_record.record_handle); - if (slot < 0) { + int slot_id = get_sdp_slot_id_by_handle(arg->remove_record.record_handle); + if (slot_id < 0) { + BTC_TRACE_ERROR("%s SDP record with handle %d not found", __func__, arg->remove_record.record_handle); ret = ESP_SDP_NO_CREATE_RECORD; break; } - handle = free_sdp_slot(slot); - - BTC_TRACE_DEBUG("Sdp Server %s id=%d to handle=0x%08x", - __func__, arg->remove_record.record_handle, handle); - - /* Pass the actual record handle */ - if(handle > 0) { - BTA_SdpRemoveRecordByUser((void*) handle); - } else { - ret = ESP_SDP_NO_CREATE_RECORD; - break; - } + BTA_SdpRemoveRecordByUser((void *)slot_id); } while(0); if (ret != ESP_SDP_SUCCESS) { @@ -1078,7 +1198,18 @@ static void btc_sdp_search(btc_sdp_args_t *arg) break; } + if (!sdp_local_param.search_allowed) { + BTC_TRACE_ERROR("%s SDP search is not allowed!", __func__); + ret = ESP_SDP_NO_RESOURCE; + break; + } + BTA_SdpSearch(arg->search.bd_addr, &arg->search.sdp_uuid); + /** + * ESP_SDP_SEARCH_COMP_EVT will refer service name in BTA sdp database, so it is not allowed to be search until + * the previous search is completed + */ + sdp_local_param.search_allowed = false; } while(0); if (ret != ESP_SDP_SUCCESS) { @@ -1089,26 +1220,21 @@ static void btc_sdp_search(btc_sdp_args_t *arg) void btc_sdp_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) { - btc_sdp_args_t *dst = (btc_sdp_args_t *)p_dest; - btc_sdp_args_t *src = (btc_sdp_args_t *)p_src; - switch (msg->act) { - case BTC_SDP_ACT_CREATE_RECORD: - dst->creat_record.record = (bluetooth_sdp_record *)osi_calloc(sizeof(bluetooth_sdp_record)); - if (dst->creat_record.record) { - memcpy(dst->creat_record.record, src->creat_record.record, sizeof(bluetooth_sdp_record)); + case BTC_SDP_ACT_CREATE_RECORD: { + bluetooth_sdp_record **dst_record = &((btc_sdp_args_t *)p_dest)->create_record.record; + bluetooth_sdp_record *src_record = ((btc_sdp_args_t *)p_src)->create_record.record; + bluetooth_sdp_record *record = (bluetooth_sdp_record *)osi_calloc(get_sdp_record_size(src_record)); + if (record) { + copy_sdp_record(src_record, record); } else { BTC_TRACE_ERROR("%s %d osi_malloc failed\n", __func__, msg->act); break; } - dst->creat_record.record->hdr.service_name = (char *)osi_calloc(src->creat_record.record->hdr.service_name_length); - if (dst->creat_record.record->hdr.service_name) { - strcpy(dst->creat_record.record->hdr.service_name, src->creat_record.record->hdr.service_name); - } else { - BTC_TRACE_ERROR("%s %d osi_malloc failed\n", __func__, msg->act); - } + *dst_record = record; break; + } default: break; } @@ -1116,17 +1242,15 @@ void btc_sdp_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) void btc_sdp_arg_deep_free(btc_msg_t *msg) { - btc_sdp_args_t *arg = (btc_sdp_args_t *)msg->arg; - switch (msg->act) { - case BTC_SDP_ACT_CREATE_RECORD: - if (arg->creat_record.record) { - osi_free(arg->creat_record.record); - } - if (arg->creat_record.record->hdr.service_name) { - osi_free(arg->creat_record.record->hdr.service_name); + case BTC_SDP_ACT_CREATE_RECORD: { + btc_sdp_args_t *arg = (btc_sdp_args_t *)msg->arg; + bluetooth_sdp_record *record = arg->create_record.record; + if (record) { + osi_free(record); } break; + } default: break; } @@ -1172,35 +1296,22 @@ void btc_sdp_cb_handler(btc_msg_t *msg) param.init.status = p_data->status; btc_sdp_cb_to_app(ESP_SDP_INIT_EVT, ¶m); break; - case BTA_SDP_DISENABLE_EVT: - BTA_SdpDisable(); - osi_mutex_free(&sdp_local_param.sdp_slot_mutex); - #if SDP_DYNAMIC_MEMORY == TRUE - osi_free(sdp_local_param_ptr); - sdp_local_param_ptr = NULL; - #endif + case BTA_SDP_DISABLE_EVT: + BTA_SdpCleanup(); + btc_sdp_cleanup(); param.deinit.status = ESP_SDP_SUCCESS; btc_sdp_cb_to_app(ESP_SDP_DEINIT_EVT, ¶m); break; case BTA_SDP_SEARCH_COMP_EVT: + // SDP search completed, now can be searched again + sdp_local_param.search_allowed = true; + param.search.status = p_data->sdp_search_comp.status; - if (param.search.status == ESP_SDP_SUCCESS) { - memcpy(param.search.remote_addr, p_data->sdp_search_comp.remote_addr, sizeof(BD_ADDR)); - memcpy(¶m.search.sdp_uuid, &p_data->sdp_search_comp.uuid, sizeof(tSDP_UUID)); - param.search.record_count = p_data->sdp_search_comp.record_count; - param.search.records = osi_malloc(sizeof(esp_bluetooth_sdp_record_t)*p_data->sdp_search_comp.record_count); - if (param.search.records != NULL) { - memcpy(param.search.records, p_data->sdp_search_comp.records, - sizeof(esp_bluetooth_sdp_record_t)*p_data->sdp_search_comp.record_count); - } else { - BTC_TRACE_ERROR("%s %d osi_malloc failed\n", __func__, event); - param.search.status = ESP_SDP_NO_RESOURCE; - } - } + memcpy(param.search.remote_addr, p_data->sdp_search_comp.remote_addr, sizeof(BD_ADDR)); + bta_to_btc_uuid(¶m.search.sdp_uuid, &p_data->sdp_search_comp.uuid); + param.search.record_count = p_data->sdp_search_comp.record_count; + param.search.records = (esp_bluetooth_sdp_record_t *)p_data->sdp_search_comp.records; btc_sdp_cb_to_app(ESP_SDP_SEARCH_COMP_EVT, ¶m); - if (param.search.records != NULL) { - osi_free(param.search.records); - } break; case BTA_SDP_CREATE_RECORD_USER_EVT: param.create_record.status = p_data->sdp_create_record.status; @@ -1208,13 +1319,25 @@ void btc_sdp_cb_handler(btc_msg_t *msg) btc_sdp_cb_to_app(ESP_SDP_CREATE_RECORD_COMP_EVT, ¶m); break; case BTA_SDP_REMOVE_RECORD_USER_EVT: - param.remove_record.status = p_data->status; + if (p_data->sdp_remove_record.status == BTA_SDP_SUCCESS) { + int slot_id = get_sdp_slot_id_by_handle(p_data->sdp_remove_record.handle); + if (slot_id < 0) { + p_data->sdp_remove_record.status = ESP_SDP_NO_CREATE_RECORD; + break; + } else { + free_sdp_slot(slot_id); + } + } + + param.remove_record.status = p_data->sdp_remove_record.status; btc_sdp_cb_to_app(ESP_SDP_REMOVE_RECORD_COMP_EVT, ¶m); break; default: BTC_TRACE_DEBUG("%s: Unhandled event (%d)!", __func__, msg->act); break; } + + btc_sdp_cb_arg_deep_free(msg); } #endif ///defined BTC_SDP_INCLUDED && BTC_SDP_INCLUDED == TRUE diff --git a/components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c b/components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c index cf33449448..181f201416 100644 --- a/components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c +++ b/components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -1199,7 +1199,7 @@ void btc_spp_cb_handler(btc_msg_t *msg) slot->alarm_arg = (void *)p_arg; if ((slot->close_alarm = osi_alarm_new("slot", close_timeout_handler, (void *)slot, VFS_CLOSE_TIMEOUT)) == NULL) { - free(p_arg); + osi_free(p_arg); slot->alarm_arg = NULL; param.close.status = ESP_SPP_NO_RESOURCE; osi_mutex_unlock(&spp_local_param.spp_slot_mutex); @@ -1207,7 +1207,7 @@ void btc_spp_cb_handler(btc_msg_t *msg) break; } if (osi_alarm_set(slot->close_alarm, VFS_CLOSE_TIMEOUT) != OSI_ALARM_ERR_PASS) { - free(p_arg); + osi_free(p_arg); slot->alarm_arg = NULL; osi_alarm_free(slot->close_alarm); param.close.status = ESP_SPP_BUSY; @@ -1488,7 +1488,7 @@ static ssize_t spp_vfs_write(int fd, const void * data, size_t size) BTC_TRACE_DEBUG("%s items_waiting:%d, fd:%d\n", __func__, items_waiting, fd); osi_mutex_unlock(&spp_local_param.spp_slot_mutex); - // block untill under water level, be closed or time out + // block until under water level, be closed or time out tx_event_group_val = xEventGroupWaitBits(spp_local_param.tx_event_group, SLOT_WRITE_BIT(serial) | SLOT_CLOSE_BIT(serial), pdTRUE, pdFALSE, VFS_WRITE_TIMEOUT / portTICK_PERIOD_MS); diff --git a/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h b/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h index c8464551d9..18b0734da8 100644 --- a/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h +++ b/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h @@ -48,16 +48,16 @@ //L2CAP #ifdef CONFIG_BT_L2CAP_ENABLED -#define UC_BT_L2CAP_ENABLED CONFIG_BT_L2CAP_ENABLED +#define UC_BT_L2CAP_ENABLED CONFIG_BT_L2CAP_ENABLED #else -#define UC_BT_L2CAP_ENABLED FALSE +#define UC_BT_L2CAP_ENABLED FALSE #endif //HFP(AG) #ifdef CONFIG_BT_HFP_AG_ENABLE -#define UC_BT_HFP_AG_ENABLED CONFIG_BT_HFP_AG_ENABLE +#define UC_BT_HFP_AG_ENABLED CONFIG_BT_HFP_AG_ENABLE #else -#define UC_BT_HFP_AG_ENABLED FALSE +#define UC_BT_HFP_AG_ENABLED FALSE #endif //HFP(Client) @@ -222,6 +222,12 @@ #define UC_BT_BLE_SMP_ID_RESET_ENABLE FALSE #endif +#ifdef CONFIG_BT_BLE_SMP_BOND_NVS_FLASH +#define UC_BT_BLE_SMP_BOND_NVS_FLASH CONFIG_BT_BLE_SMP_BOND_NVS_FLASH +#else +#define UC_BT_BLE_SMP_BOND_NVS_FLASH FALSE +#endif + //Device Name Maximum Length #ifdef CONFIG_BT_MAX_DEVICE_NAME_LEN #define UC_MAX_LOC_BD_NAME_LEN CONFIG_BT_MAX_DEVICE_NAME_LEN @@ -379,20 +385,6 @@ * Memory reference **********************************************************/ -//MEMORY ALLOCATOR -#ifdef CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST -#define UC_HEAP_ALLOCATION_FROM_SPIRAM_FIRST CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST -#else -#define UC_HEAP_ALLOCATION_FROM_SPIRAM_FIRST FALSE -#endif - -//MEMORY DEBUG -#ifdef CONFIG_BT_BLUEDROID_MEM_DEBUG -#define UC_BT_BLUEDROID_MEM_DEBUG CONFIG_BT_BLUEDROID_MEM_DEBUG -#else -#define UC_BT_BLUEDROID_MEM_DEBUG FALSE -#endif - /********************************************************** * Trace reference diff --git a/components/bt/host/bluedroid/common/include/common/bt_target.h b/components/bt/host/bluedroid/common/include/common/bt_target.h index eaf71090b1..8f5178e6a7 100644 --- a/components/bt/host/bluedroid/common/include/common/bt_target.h +++ b/components/bt/host/bluedroid/common/include/common/bt_target.h @@ -187,11 +187,16 @@ #define BLE_50_FEATURE_SUPPORT FALSE #endif +#if (UC_BT_BLE_ENABLED ==TRUE) #if (UC_BT_BLE_42_FEATURES_SUPPORTED == TRUE || BLE_50_FEATURE_SUPPORT == FALSE) #define BLE_42_FEATURE_SUPPORT TRUE #else #define BLE_42_FEATURE_SUPPORT FALSE #endif +#else +#define BLE_42_FEATURE_SUPPORT FALSE +#define BLE_50_FEATURE_SUPPORT FALSE +#endif /* UC_BT_BLE_ENABLED */ #if (UC_BT_BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) #define BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER TRUE @@ -283,6 +288,12 @@ #define BLE_SMP_ID_RESET_ENABLE FALSE #endif +#if (UC_BT_BLE_SMP_BOND_NVS_FLASH) +#define BLE_SMP_BOND_NVS_FLASH TRUE +#else +#define BLE_SMP_BOND_NVS_FLASH FALSE +#endif + #ifdef UC_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP #define BLE_ADV_REPORT_FLOW_CONTROL (UC_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP && BLE_INCLUDED) #endif /* UC_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP */ @@ -1274,7 +1285,7 @@ #ifdef CONFIG_IDF_TARGET_ESP32 #define BTM_BLE_ADV_TX_POWER {-12, -9, -6, -3, 0, 3, 6, 9} #else -#define BTM_BLE_ADV_TX_POWER {-24, -21, -18, -15, -12, -9, -6, -3, 0, 3, 6, 9, 12, 15, 18, 21} +#define BTM_BLE_ADV_TX_POWER {-24, -21, -18, -15, -12, -9, -6, -3, 0, 3, 6, 9, 12, 15, 18, 20} #endif #endif @@ -1282,7 +1293,7 @@ #ifdef CONFIG_IDF_TARGET_ESP32 #define BTM_TX_POWER {-12, -9, -6, -3, 0, 3, 6, 9} #else -#define BTM_TX_POWER {-24, -21, -18, -15, -12, -9, -6, -3, 0, 3, 6, 9, 12, 15, 18, 21} +#define BTM_TX_POWER {-24, -21, -18, -15, -12, -9, -6, -3, 0, 3, 6, 9, 12, 15, 18, 20} #endif #endif @@ -2378,12 +2389,6 @@ The maximum number of payload octets that the local device can receive in a sing #define BTSNOOP_MEM FALSE #endif -#if UC_HEAP_ALLOCATION_FROM_SPIRAM_FIRST -#define HEAP_ALLOCATION_FROM_SPIRAM_FIRST TRUE -#else -#define HEAP_ALLOCATION_FROM_SPIRAM_FIRST FALSE -#endif - #include "common/bt_trace.h" #endif /* BT_TARGET_H */ diff --git a/components/bt/host/bluedroid/device/controller.c b/components/bt/host/bluedroid/device/controller.c index 8d2349b4cd..70e528fe8c 100644 --- a/components/bt/host/bluedroid/device/controller.c +++ b/components/bt/host/bluedroid/device/controller.c @@ -271,7 +271,7 @@ static void start_up(void) #endif //#if (BLE_50_FEATURE_SUPPORT == TRUE) #if (BLE_50_FEATURE_SUPPORT == TRUE && BLE_42_FEATURE_SUPPORT == FALSE) - if (HCI_LE_ENHANCED_PRIVACY_SUPPORTED(controller_param.features_ble.as_array)) { + if (HCI_LE_EXT_ADV_SUPPORTED(controller_param.features_ble.as_array)) { response = AWAIT_COMMAND(controller_param.packet_factory->make_read_max_adv_data_len()); controller_param.packet_parser->parse_ble_read_adv_max_len_response( response, diff --git a/components/bt/host/bluedroid/hci/hci_hal_h4.c b/components/bt/host/bluedroid/hci/hci_hal_h4.c index 96007404b5..99ff8bf5d9 100644 --- a/components/bt/host/bluedroid/hci/hci_hal_h4.c +++ b/components/bt/host/bluedroid/hci/hci_hal_h4.c @@ -592,7 +592,11 @@ static int host_recv_pkt_cb(uint8_t *data, uint16_t len) } #endif pkt_size = BT_PKT_LINKED_HDR_SIZE + BT_HDR_SIZE + len; + #if HEAP_MEMORY_DEBUG linked_pkt = (pkt_linked_item_t *) osi_calloc(pkt_size); + #else + linked_pkt = (pkt_linked_item_t *) osi_calloc_base(pkt_size); + #endif if (!linked_pkt) { #if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE) hci_adv_credits_consumed(1); diff --git a/components/bt/host/bluedroid/hci/hci_packet_parser.c b/components/bt/host/bluedroid/hci/hci_packet_parser.c index 885153764e..d25caf3506 100644 --- a/components/bt/host/bluedroid/hci/hci_packet_parser.c +++ b/components/bt/host/bluedroid/hci/hci_packet_parser.c @@ -186,7 +186,9 @@ static void parse_ble_read_resolving_list_size_response( { uint8_t *stream = read_command_complete_header(response, HCI_BLE_READ_RESOLVING_LIST_SIZE, 1 /* bytes after */); - STREAM_TO_UINT8(*resolving_list_size_ptr, stream); + if (stream) { + STREAM_TO_UINT8(*resolving_list_size_ptr, stream); + } osi_free(response); } @@ -198,10 +200,14 @@ static void parse_ble_read_suggested_default_data_length_response( { uint8_t *stream = read_command_complete_header(response, HCI_BLE_READ_DEFAULT_DATA_LENGTH, 2 /* bytes after */); - STREAM_TO_UINT16(*ble_default_packet_length_ptr, stream); - STREAM_TO_UINT16(*ble_default_packet_txtime_ptr, stream); + if (stream) { + STREAM_TO_UINT16(*ble_default_packet_length_ptr, stream); + STREAM_TO_UINT16(*ble_default_packet_txtime_ptr, stream); + } + osi_free(response); } + #if (BLE_50_FEATURE_SUPPORT == TRUE) static void parse_ble_read_adv_max_len_response( BT_HDR *response, @@ -209,9 +215,10 @@ static void parse_ble_read_adv_max_len_response( { uint8_t *stream = read_command_complete_header(response, HCI_BLE_RD_MAX_ADV_DATA_LEN, 1 /* bytes after */); - // Size: 2 Octets ; Value: 0x001F – 0x0672 ; Maximum supported advertising data length - STREAM_TO_UINT16(*adv_max_len_ptr, stream); - + if (stream) { + // Size: 2 Octets ; Value: 0x001F – 0x0672 ; Maximum supported advertising data length + STREAM_TO_UINT16(*adv_max_len_ptr, stream); + } osi_free(response); } #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) @@ -254,6 +261,7 @@ static uint8_t *read_command_complete_header( STREAM_TO_UINT8(status, stream); if (status != HCI_SUCCESS) { + HCI_TRACE_ERROR("%s failed: opcode 0x%04x, status 0x%02x", __func__, opcode, status); return NULL; } diff --git a/components/bt/host/bluedroid/hci/packet_fragmenter.c b/components/bt/host/bluedroid/hci/packet_fragmenter.c index 78b6151e51..d8f2ff918f 100644 --- a/components/bt/host/bluedroid/hci/packet_fragmenter.c +++ b/components/bt/host/bluedroid/hci/packet_fragmenter.c @@ -171,6 +171,12 @@ static void reassemble_and_dispatch(BT_HDR *packet) return; } partial_packet = (BT_HDR *)osi_calloc(full_length + sizeof(BT_HDR)); + + if (partial_packet == NULL) { + HCI_TRACE_WARNING("%s full_length %d no memory.\n", __func__, full_length); + assert(0); + } + partial_packet->event = packet->event; partial_packet->len = full_length; partial_packet->offset = packet->len; diff --git a/components/bt/host/bluedroid/stack/avct/avct_lcb.c b/components/bt/host/bluedroid/stack/avct/avct_lcb.c index 61f6c9a556..84a0f02125 100644 --- a/components/bt/host/bluedroid/stack/avct/avct_lcb.c +++ b/components/bt/host/bluedroid/stack/avct/avct_lcb.c @@ -430,10 +430,10 @@ BOOLEAN avct_lcb_last_ccb(tAVCT_LCB *p_lcb, tAVCT_CCB *p_ccb_last) tAVCT_CCB *p_ccb = &avct_cb.ccb[0]; int i; - AVCT_TRACE_WARNING("avct_lcb_last_ccb"); + AVCT_TRACE_DEBUG("avct_lcb_last_ccb"); for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) { - AVCT_TRACE_WARNING("%x: aloc:%d, lcb:%p/%p, ccb:%p/%p", - i, p_ccb->allocated, p_ccb->p_lcb, p_lcb, p_ccb, p_ccb_last); + AVCT_TRACE_DEBUG("%x: aloc:%d, lcb:%p/%p, ccb:%p/%p", + i, p_ccb->allocated, p_ccb->p_lcb, p_lcb, p_ccb, p_ccb_last); if (p_ccb->allocated && (p_ccb->p_lcb == p_lcb) && (p_ccb != p_ccb_last)) { return FALSE; } diff --git a/components/bt/host/bluedroid/stack/avrc/avrc_pars_tg.c b/components/bt/host/bluedroid/stack/avrc/avrc_pars_tg.c index c30bf94a3b..fe04ca8f32 100644 --- a/components/bt/host/bluedroid/stack/avrc/avrc_pars_tg.c +++ b/components/bt/host/bluedroid/stack/avrc/avrc_pars_tg.c @@ -71,7 +71,7 @@ static tAVRC_STS avrc_pars_vendor_cmd(tAVRC_MSG_VENDOR *p_msg, tAVRC_COMMAND *p_ p++; /* skip the reserved byte */ BE_STREAM_TO_UINT16 (len, p); if ((len + 4) != (p_msg->vendor_len)) { - status = AVRC_STS_INTERNAL_ERR; + status = AVRC_STS_NOT_FOUND; } if (status != AVRC_STS_NO_ERROR) { diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble.c b/components/bt/host/bluedroid/stack/btm/btm_ble.c index 0d1e8fd626..a69c1f0f2f 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble.c @@ -2148,7 +2148,7 @@ void btm_ble_create_ll_conn_complete (UINT8 status) tL2C_LCB *p_lcb = l2cu_find_lcb_by_bd_addr(l2cb.ble_connecting_bda, BT_TRANSPORT_LE); /* Do not remove lcb if an LE link is already up as a peripheral */ if (p_lcb != NULL && - !(p_lcb->link_role == HCI_ROLE_SLAVE && BTM_ACL_IS_CONNECTED(l2cb.ble_connecting_bda))) { + !(p_lcb->link_role == HCI_ROLE_SLAVE && BTM_LE_ACL_IS_CONNECTED(l2cb.ble_connecting_bda))) { p_lcb->disc_reason = L2CAP_CONN_CANCEL; l2cu_release_lcb (p_lcb); } diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c b/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c index f595e3e6ef..13a424586f 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c @@ -249,10 +249,10 @@ tBTM_STATUS BTM_BleSetPreferDefaultPhy(UINT8 tx_phy_mask, UINT8 rx_phy_mask) if ((err = btsnd_hcic_ble_set_prefered_default_phy(all_phys, tx_phy_mask, rx_phy_mask)) != HCI_SUCCESS) { BTM_TRACE_ERROR("%s, fail to send the hci command, the error code = %s(0x%x)", __func__, btm_ble_hci_status_to_str(err), err); - status = BTM_ILLEGAL_VALUE; + status = BTM_HCI_ERROR | err; } - cb_params.set_perf_def_phy.status = err; + cb_params.set_perf_def_phy.status = status; BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_SET_PREFERED_DEFAULT_PHY_COMPLETE_EVT, &cb_params); @@ -330,7 +330,7 @@ tBTM_STATUS BTM_BleSetExtendedAdvRandaddr(UINT8 instance, BD_ADDR rand_addr) if((err = btsnd_hcic_ble_set_extend_rand_address(instance, rand_addr)) != HCI_SUCCESS) { BTM_TRACE_ERROR("%s, fail to send the hci command, the error code = %s(0x%x)", __func__, btm_ble_hci_status_to_str(err), err); - status = BTM_ILLEGAL_VALUE; + status = BTM_HCI_ERROR | err; } else { // set random address success, update address info if(extend_adv_cb.inst[instance].configured && extend_adv_cb.inst[instance].connetable) { @@ -403,7 +403,7 @@ tBTM_STATUS BTM_BleSetExtendedAdvParams(UINT8 instance, tBTM_BLE_GAP_EXT_ADV_PAR params->primary_phy, params->max_skip, params->secondary_phy, params->sid, params->scan_req_notif)) != HCI_SUCCESS) { BTM_TRACE_ERROR("LE EA SetParams: cmd err=0x%x", err); - status = BTM_ILLEGAL_VALUE; + status = BTM_HCI_ERROR | err; goto end; } @@ -414,7 +414,7 @@ tBTM_STATUS BTM_BleSetExtendedAdvParams(UINT8 instance, tBTM_BLE_GAP_EXT_ADV_PAR // update RPA address if((err = btsnd_hcic_ble_set_extend_rand_address(instance, rand_addr)) != HCI_SUCCESS) { BTM_TRACE_ERROR("LE EA SetParams: cmd err=0x%x", err); - status = BTM_ILLEGAL_VALUE; + status = BTM_HCI_ERROR | err; } else { // set addr success, update address info BTM_UpdateAddrInfor(BLE_ADDR_RANDOM, rand_addr); @@ -452,23 +452,25 @@ tBTM_STATUS BTM_BleConfigExtendedAdvDataRaw(BOOLEAN is_scan_rsp, UINT8 instance, } else if (rem_len <= BTM_BLE_EXT_ADV_DATA_LEN_MAX) { operation = BTM_BLE_ADV_DATA_OP_LAST_FRAG; } else { - operation = BTM_BLE_ADV_DATA_OP_INTERMEDIATE_FRAG; - } + operation = BTM_BLE_ADV_DATA_OP_INTERMEDIATE_FRAG; + } } if (!is_scan_rsp) { if ((err = btsnd_hcic_ble_set_ext_adv_data(instance, operation, 0, send_data_len, &data[data_offset])) != HCI_SUCCESS) { BTM_TRACE_ERROR("LE EA SetAdvData: cmd err=0x%x", err); - status = BTM_ILLEGAL_VALUE; + status = BTM_HCI_ERROR | err; + break; } } else { if ((err = btsnd_hcic_ble_set_ext_adv_scan_rsp_data(instance, operation, 0, send_data_len, &data[data_offset])) != HCI_SUCCESS) { BTM_TRACE_ERROR("LE EA SetScanRspData: cmd err=0x%x", err); - status = BTM_ILLEGAL_VALUE; + status = BTM_HCI_ERROR | err; + break; } } rem_len -= send_data_len; - data_offset += send_data_len; + data_offset += send_data_len; } while (rem_len); end: @@ -522,7 +524,7 @@ tBTM_STATUS BTM_BleStartExtAdv(BOOLEAN enable, UINT8 num, tBTM_BLE_EXT_ADV *ext_ if ((err = btsnd_hcic_ble_ext_adv_enable(enable, num, instance, duration, max_events)) != HCI_SUCCESS) { BTM_TRACE_ERROR("LE EA En=%d: cmd err=0x%x", enable, err); - status = BTM_ILLEGAL_VALUE; + status = BTM_HCI_ERROR | err; } osi_free(instance); @@ -533,7 +535,7 @@ tBTM_STATUS BTM_BleStartExtAdv(BOOLEAN enable, UINT8 num, tBTM_BLE_EXT_ADV *ext_ if ((err = btsnd_hcic_ble_ext_adv_enable(enable, num, NULL, NULL, NULL)) != HCI_SUCCESS) { BTM_TRACE_ERROR("LE EA En=%d: cmd err=0x%x", enable, err); - status = BTM_ILLEGAL_VALUE; + status = BTM_HCI_ERROR | err; } goto end; } @@ -631,7 +633,7 @@ tBTM_STATUS BTM_BleExtAdvSetRemove(UINT8 instance) if ((err = btsnd_hcic_ble_remove_adv_set(instance)) != HCI_SUCCESS) { BTM_TRACE_ERROR("LE EAS Rm: cmd err=0x%x", err); - status = BTM_ILLEGAL_VALUE; + status = BTM_HCI_ERROR | err; } else { extend_adv_cb.inst[instance].configured = false; extend_adv_cb.inst[instance].legacy_pdu = false; @@ -659,7 +661,7 @@ tBTM_STATUS BTM_BleExtAdvSetClear(void) if ((err = btsnd_hcic_ble_clear_adv_set()) != HCI_SUCCESS) { BTM_TRACE_ERROR("LE EAS Clr: cmd err=0x%x", err); - status = BTM_ILLEGAL_VALUE; + status = BTM_HCI_ERROR | err; } else { for (uint8_t i = 0; i < MAX_BLE_ADV_INSTANCE; i++) { extend_adv_cb.inst[i].configured = false; @@ -703,7 +705,7 @@ tBTM_STATUS BTM_BlePeriodicAdvSetParams(UINT8 instance, tBTM_BLE_Periodic_Adv_Pa if ((err= btsnd_hcic_ble_set_periodic_adv_params(instance, params->interval_min, params->interval_max, params->properties)) != HCI_SUCCESS) { BTM_TRACE_ERROR("LE PA SetParams: cmd err=0x%x", err); - status = BTM_ILLEGAL_VALUE; + status = BTM_HCI_ERROR | err; } end: @@ -756,10 +758,12 @@ tBTM_STATUS BTM_BlePeriodicAdvCfgDataRaw(UINT8 instance, UINT16 len, UINT8 *data if ((err = btsnd_hcic_ble_set_periodic_adv_data(instance, operation, send_data_len, &data[data_offset])) != HCI_SUCCESS) { BTM_TRACE_ERROR("LE PA SetData: cmd err=0x%x", err); - status = BTM_ILLEGAL_VALUE; + status = BTM_HCI_ERROR | err; + break; } + rem_len -= send_data_len; - data_offset += send_data_len; + data_offset += send_data_len; } while(rem_len); end: @@ -785,7 +789,7 @@ tBTM_STATUS BTM_BlePeriodicAdvEnable(UINT8 instance, UINT8 enable) if ((err = btsnd_hcic_ble_periodic_adv_enable(enable, instance)) != HCI_SUCCESS) { BTM_TRACE_ERROR("LE PA En=%d: cmd err=0x%x", enable, err); - status = BTM_ILLEGAL_VALUE; + status = BTM_HCI_ERROR | err; } end: @@ -860,6 +864,7 @@ tBTM_STATUS BTM_BlePeriodicAdvCreateSync(tBTM_BLE_Periodic_Sync_Params *params) return status; } + void btm_set_phy_callback(UINT8 status) { tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0}; @@ -868,6 +873,7 @@ void btm_set_phy_callback(UINT8 status) BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_SET_PREFERED_PHY_COMPLETE_EVT, &cb_params); } + void btm_create_sync_callback(UINT8 status) { tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0}; @@ -903,7 +909,7 @@ tBTM_STATUS BTM_BlePeriodicAdvSyncCancel(void) if ((err = btsnd_hcic_ble_periodic_adv_create_sync_cancel()) != HCI_SUCCESS) { BTM_TRACE_ERROR("LE PA SyncCancel, cmd err=0x%x", err); - status = BTM_ILLEGAL_VALUE; + status = BTM_HCI_ERROR | err; } cb_params.status = status; @@ -921,7 +927,7 @@ tBTM_STATUS BTM_BlePeriodicAdvSyncTerm(UINT16 sync_handle) if (( err = btsnd_hcic_ble_periodic_adv_term_sync(sync_handle)) != HCI_SUCCESS) { BTM_TRACE_ERROR("LE PA SyncTerm: cmd err=0x%x", err); - status = BTM_ILLEGAL_VALUE; + status = BTM_HCI_ERROR | err; } cb_params.status = status; @@ -945,7 +951,7 @@ tBTM_STATUS BTM_BlePeriodicAdvAddDevToList(tBLE_ADDR_TYPE addr_type, BD_ADDR add if ((err = btsnd_hcic_ble_add_dev_to_periodic_adv_list(addr_type, addr, sid)) != HCI_SUCCESS) { BTM_TRACE_ERROR("LE PA AddDevToList: cmd err=0x%x", err); - status = BTM_ILLEGAL_VALUE; + status = BTM_HCI_ERROR | err; } end: @@ -969,7 +975,7 @@ tBTM_STATUS BTM_BlePeriodicAdvRemoveDevFromList(tBLE_ADDR_TYPE addr_type, BD_ADD if ((err = btsnd_hcic_ble_rm_dev_from_periodic_adv_list(addr_type, addr, sid)) != HCI_SUCCESS) { BTM_TRACE_ERROR("LE PA RmDevFromList: cmd err=0x%x", err); - status = BTM_ILLEGAL_VALUE; + status = BTM_HCI_ERROR | err; } end: @@ -987,7 +993,7 @@ tBTM_STATUS BTM_BlePeriodicAdvClearDev(void) if ((err = btsnd_hcic_ble_clear_periodic_adv_list()) != HCI_SUCCESS) { BTM_TRACE_ERROR("LE PA ClrDev: cmd err=0x%x", err); - status = BTM_ILLEGAL_VALUE; + status = BTM_HCI_ERROR | err; } cb_params.status = status; @@ -1039,7 +1045,7 @@ tBTM_STATUS BTM_BleSetExtendedScanParams(tBTM_BLE_EXT_SCAN_PARAMS *params) if ((err = btsnd_hcic_ble_set_ext_scan_params(params->own_addr_type, params->filter_policy, phy_mask, phy_count, hci_params)) != HCI_SUCCESS) { BTM_TRACE_ERROR("LE ES SetParams: cmd err=0x%x", err); - status = BTM_ILLEGAL_VALUE; + status = BTM_HCI_ERROR | err; } end: @@ -1065,7 +1071,7 @@ tBTM_STATUS BTM_BleExtendedScan(BOOLEAN enable, UINT16 duration, UINT16 period) if ((err = btsnd_hcic_ble_ext_scan_enable(enable, extend_adv_cb.scan_duplicate, duration, period)) != HCI_SUCCESS) { BTM_TRACE_ERROR("LE ES En=%d: cmd err=0x%x", enable, err); - status = BTM_ILLEGAL_VALUE; + status = BTM_HCI_ERROR | err; } end: @@ -1080,18 +1086,23 @@ tBTM_STATUS BTM_BleExtendedScan(BOOLEAN enable, UINT16 duration, UINT16 period) void BTM_BleSetPreferExtenedConnParams (BD_ADDR bd_addr, tBTM_EXT_CONN_PARAMS *params) { tBTM_SEC_DEV_REC *p_dev_rec = btm_find_or_alloc_dev (bd_addr); + tBTM_STATUS status = BTM_SUCCESS; + tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0}; if (p_dev_rec) { if (params) { memcpy(&p_dev_rec->ext_conn_params, params, sizeof(tBTM_EXT_CONN_PARAMS)); } else { - BTM_TRACE_ERROR("Invalid Extand connection parameters"); + BTM_TRACE_ERROR("Invalid Extended connection parameters"); + status = BTM_ILLEGAL_VALUE; } } else { - BTM_TRACE_ERROR("Unknown Device, setting rejected"); + BTM_TRACE_ERROR("Unknown Device, setting rejected"); + status = BTM_UNKNOWN_ADDR; } - return; + cb_params.status = status; + BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_PREFER_EXT_CONN_PARAMS_SET_COMPLETE_EVT, &cb_params); } void btm_ble_extended_init(void) @@ -1401,7 +1412,7 @@ void BTM_BlePeriodicAdvRecvEnable(UINT16 sync_handle, UINT8 enable) if ((err = btsnd_hcic_ble_set_periodic_adv_recv_enable(sync_handle, enable)) != HCI_SUCCESS) { BTM_TRACE_ERROR("%s cmd err=0x%x", __func__, err); - status = BTM_ILLEGAL_VALUE; + status = BTM_HCI_ERROR | err; } cb_params.status = status; @@ -1460,7 +1471,7 @@ void BTM_BleSetPeriodicAdvSyncTransParams(BD_ADDR bd_addr, UINT8 mode, UINT16 sk tHCI_STATUS err = HCI_SUCCESS; if ((err = btsnd_hcic_ble_set_default_periodic_adv_sync_trans_params(mode, skip, sync_timeout, cte_type)) != HCI_SUCCESS) { BTM_TRACE_ERROR("%s cmd err=0x%x", __func__, err); - status = BTM_ILLEGAL_VALUE; + status = BTM_HCI_ERROR | err; } cb_params.set_past_params.status = status; diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_addr.c b/components/bt/host/bluedroid/stack/btm/btm_ble_addr.c index d7ed2095cd..60548a76ba 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_addr.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_addr.c @@ -384,6 +384,10 @@ static BOOLEAN btm_ble_match_random_bda(tBTM_SEC_DEV_REC *p_dev_rec) void btm_ble_resolve_random_addr(BD_ADDR random_bda, tBTM_BLE_RESOLVE_CBACK *p_cback, void *p) { #if (SMP_INCLUDED == TRUE) + if (btm_cb.addr_res_en == FALSE) { + return; + } + tBTM_LE_RANDOM_CB *p_mgnt_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb; list_node_t *p_node = NULL; tBTM_SEC_DEV_REC *p_dev_rec = NULL; @@ -458,6 +462,10 @@ tBTM_SEC_DEV_REC *btm_find_dev_by_identity_addr(BD_ADDR bd_addr, UINT8 addr_type BOOLEAN btm_identity_addr_to_random_pseudo(BD_ADDR bd_addr, UINT8 *p_addr_type, BOOLEAN refresh) { #if BLE_PRIVACY_SPT == TRUE + if (btm_cb.addr_res_en == FALSE) { + return TRUE; + } + tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_identity_addr(bd_addr, *p_addr_type); BTM_TRACE_EVENT ("%s", __func__); @@ -491,6 +499,10 @@ BOOLEAN btm_identity_addr_to_random_pseudo(BD_ADDR bd_addr, UINT8 *p_addr_type, BOOLEAN btm_random_pseudo_to_identity_addr(BD_ADDR random_pseudo, UINT8 *p_static_addr_type) { #if BLE_PRIVACY_SPT == TRUE + if (btm_cb.addr_res_en == FALSE) { + return TRUE; + } + tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (random_pseudo); if (p_dev_rec != NULL) { diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c b/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c index 15b4a042d8..1269f11401 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c @@ -2101,7 +2101,7 @@ BOOLEAN BTM_BleGetCurrentAddress(BD_ADDR addr, uint8_t *addr_type) ** Returns pointer of ADV data ** *******************************************************************************/ -UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length) +UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT16 adv_data_len, UINT8 type, UINT8 *p_length) { UINT8 *p = p_adv; UINT8 length; @@ -2110,7 +2110,7 @@ UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length) STREAM_TO_UINT8(length, p); - while ( length && (p - p_adv < BTM_BLE_CACHE_ADV_DATA_MAX)) { + while ( length && (p - p_adv < adv_data_len)) { STREAM_TO_UINT8(adv_type, p); if ( adv_type == type ) { @@ -2123,7 +2123,7 @@ UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length) /* Break loop if advertising data is in an incorrect format, as it may lead to memory overflow */ - if (p >= p_adv + BTM_BLE_CACHE_ADV_DATA_MAX) { + if (p >= p_adv + adv_data_len) { break; } @@ -3176,7 +3176,7 @@ UINT8 btm_ble_is_discoverable(BD_ADDR bda, UINT8 evt_type, UINT8 *p) } if (p_le_inq_cb->adv_len != 0) { - if ((p_flag = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache, + if ((p_flag = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache, p_le_inq_cb->adv_len, BTM_BLE_AD_TYPE_FLAG, &data_len)) != NULL) { flag = * p_flag; @@ -3392,7 +3392,7 @@ BOOLEAN btm_ble_update_inq_result(BD_ADDR bda, tINQ_DB_ENT *p_i, UINT8 addr_type p_i->inq_count = p_inq->inq_counter; /* Mark entry for current inquiry */ if (p_le_inq_cb->adv_len != 0) { - if ((p_flag = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache, BTM_BLE_AD_TYPE_FLAG, &len)) != NULL) { + if ((p_flag = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache, p_le_inq_cb->adv_len, BTM_BLE_AD_TYPE_FLAG, &len)) != NULL) { p_cur->flag = * p_flag; } } @@ -3402,11 +3402,11 @@ BOOLEAN btm_ble_update_inq_result(BD_ADDR bda, tINQ_DB_ENT *p_i, UINT8 addr_type * then try to convert the appearance value to a class of device value Bluedroid can use. * Otherwise fall back to trying to infer if it is a HID device based on the service class. */ - p_uuid16 = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache, BTM_BLE_AD_TYPE_APPEARANCE, &len); + p_uuid16 = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache, p_le_inq_cb->adv_len, BTM_BLE_AD_TYPE_APPEARANCE, &len); if (p_uuid16 && len == 2) { btm_ble_appearance_to_cod((UINT16)p_uuid16[0] | (p_uuid16[1] << 8), p_cur->dev_class); } else { - if ((p_uuid16 = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache, + if ((p_uuid16 = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache, p_le_inq_cb->adv_len, BTM_BLE_AD_TYPE_16SRV_CMPL, &len)) != NULL) { UINT8 i; for (i = 0; i + 2 <= len; i = i + 2) { @@ -3493,10 +3493,10 @@ void btm_send_sel_conn_callback(BD_ADDR remote_bda, UINT8 evt_type, UINT8 *p_dat /* get the device name if exist in ADV data */ if (data_len != 0) { - p_dev_name = BTM_CheckAdvData(p_data, BTM_BLE_AD_TYPE_NAME_CMPL, &len); + p_dev_name = BTM_CheckAdvData(p_data, data_len, BTM_BLE_AD_TYPE_NAME_CMPL, &len); if (p_dev_name == NULL) { - p_dev_name = BTM_CheckAdvData(p_data, BTM_BLE_AD_TYPE_NAME_SHORT, &len); + p_dev_name = BTM_CheckAdvData(p_data, data_len, BTM_BLE_AD_TYPE_NAME_SHORT, &len); } if (p_dev_name) { @@ -4617,6 +4617,12 @@ void btm_ble_free (void) #endif } +static bool enable_topology_check_flag = true; +void esp_qa_enable_topology_check(bool enable) +{ + // This is a workaround: If the topology check is disabled, the 'Supported States' will not be checked. + enable_topology_check_flag = enable; +} /******************************************************************************* ** ** Function btm_ble_topology_check @@ -4629,6 +4635,7 @@ void btm_ble_free (void) *******************************************************************************/ BOOLEAN btm_ble_topology_check(tBTM_BLE_STATE_MASK request_state_mask) { + if(!enable_topology_check_flag) return TRUE; BOOLEAN rt = FALSE; UINT8 state_offset = 0; @@ -4761,6 +4768,17 @@ BOOLEAN BTM_BleSetPrivacyMode(UINT8 addr_type, BD_ADDR bd_addr, UINT8 privacy_mo return TRUE; } +BOOLEAN BTM_BleSetCsaSupport(UINT8 csa_select, tBTM_SET_CSA_SUPPORT_CMPL_CBACK *p_callback) +{ + if (btsnd_hcic_ble_set_csa_support(csa_select) != TRUE) { + BTM_TRACE_ERROR("LE SetCsaSupport csa_select=%d: error", csa_select); + return FALSE; + } + + btm_cb.ble_ctr_cb.set_csa_support_cmpl_cb = p_callback; + return TRUE; +} + bool btm_ble_adv_pkt_ready(void) { tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb; diff --git a/components/bt/host/bluedroid/stack/btm/btm_devctl.c b/components/bt/host/bluedroid/stack/btm/btm_devctl.c index d092e2b71e..d025295c7f 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_devctl.c +++ b/components/bt/host/bluedroid/stack/btm/btm_devctl.c @@ -722,6 +722,14 @@ void btm_vsc_complete (UINT8 *p, UINT16 opcode, UINT16 evt_len, } break; } + case HCI_VENDOR_BLE_SET_CSA_SUPPORT: { + uint8_t status; + STREAM_TO_UINT8(status, p); + if (ble_cb && ble_cb->set_csa_support_cmpl_cb) { + ble_cb->set_csa_support_cmpl_cb(status); + } + break; + } default: break; } diff --git a/components/bt/host/bluedroid/stack/btm/btm_inq.c b/components/bt/host/bluedroid/stack/btm/btm_inq.c index b8da232795..528c7a066f 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_inq.c +++ b/components/bt/host/bluedroid/stack/btm/btm_inq.c @@ -163,7 +163,7 @@ tBTM_STATUS BTM_SetDiscoverability (UINT16 inq_mode, UINT16 window, UINT16 inter UINT8 scan_mode = 0; UINT16 service_class; UINT8 *p_cod; - UINT8 major, minor; + UINT8 major, minor, reserved_2; DEV_CLASS cod; LAP temp_lap[2]; BOOLEAN is_limited; @@ -255,13 +255,14 @@ tBTM_STATUS BTM_SetDiscoverability (UINT16 inq_mode, UINT16 window, UINT16 inter if (is_limited ^ cod_limited) { BTM_COD_MINOR_CLASS(minor, p_cod ); BTM_COD_MAJOR_CLASS(major, p_cod ); + BTM_COD_RESERVED_2(reserved_2, p_cod); if (is_limited) { service_class |= BTM_COD_SERVICE_LMTD_DISCOVER; } else { service_class &= ~BTM_COD_SERVICE_LMTD_DISCOVER; } - FIELDS_TO_COD(cod, minor, major, service_class); + FIELDS_TO_COD(cod, reserved_2, minor, major, service_class); (void) BTM_SetDeviceClass (cod); } @@ -515,7 +516,7 @@ tBTM_STATUS BTM_SetPeriodicInquiryMode (tBTM_INQ_PARMS *p_inqparms, UINT16 max_d /* Before beginning the inquiry the current filter must be cleared, so initiate the command */ if ((status = btm_set_inq_event_filter (p_inqparms->filter_cond_type, &p_inqparms->filter_cond)) != BTM_CMD_STARTED) { - /* If set filter command is not succesful reset the state */ + /* If set filter command is not successful reset the state */ p_inq->p_inq_results_cb = NULL; p_inq->state = BTM_INQ_INACTIVE_STATE; @@ -688,7 +689,7 @@ UINT16 BTM_ReadConnectability (UINT16 *p_window, UINT16 *p_interval) ** Description This function returns a bit mask of the current inquiry state ** ** Returns BTM_INQUIRY_INACTIVE if inactive (0) -** BTM_LIMITED_INQUIRY_ACTIVE if a limted inquiry is active +** BTM_LIMITED_INQUIRY_ACTIVE if a limited inquiry is active ** BTM_GENERAL_INQUIRY_ACTIVE if a general inquiry is active ** BTM_PERIODIC_INQUIRY_ACTIVE if a periodic inquiry is active ** @@ -783,7 +784,7 @@ tBTM_STATUS BTM_CancelInquiry(void) ** Description This function is called to start an inquiry. ** ** Parameters: p_inqparms - pointer to the inquiry information -** mode - GENERAL or LIMITED inquiry, BR/LE bit mask seperately +** mode - GENERAL or LIMITED inquiry, BR/LE bit mask separately ** duration - length in 1.28 sec intervals (If '0', the inquiry is CANCELLED) ** max_resps - maximum amount of devices to search for before ending the inquiry ** filter_cond_type - BTM_CLR_INQUIRY_FILTER, BTM_FILTER_COND_DEVICE_CLASS, or @@ -1858,7 +1859,7 @@ void btm_process_inq_results (UINT8 *p, UINT8 inq_res_mode) #if BLE_INCLUDED == TRUE /* new device response */ && ( p_i == NULL || - /* exisiting device with BR/EDR info */ + /* existing device with BR/EDR info */ (p_i && (p_i->inq_info.results.device_type & BT_DEVICE_TYPE_BREDR) != 0) ) #endif diff --git a/components/bt/host/bluedroid/stack/btm/btm_main.c b/components/bt/host/bluedroid/stack/btm/btm_main.c index 8e49aa3e6d..1519ecb990 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_main.c +++ b/components/bt/host/bluedroid/stack/btm/btm_main.c @@ -84,6 +84,7 @@ void btm_init (void) #if BLE_INCLUDED == TRUE btm_ble_lock_init(); btm_ble_sem_init(); + btm_cb.addr_res_en = TRUE; #endif btm_sec_dev_init(); #if (BLE_50_FEATURE_SUPPORT == TRUE) @@ -109,6 +110,9 @@ void btm_free(void) fixed_queue_free(btm_cb.sec_pending_q, osi_free_func); btm_acl_free(); btm_sec_dev_free(); +#if BTM_SCO_INCLUDED == TRUE + btm_sco_free(); +#endif #if BTM_DYNAMIC_MEMORY FREE_AND_RESET(btm_cb_ptr); #endif @@ -133,3 +137,16 @@ uint8_t btm_acl_active_count(void) return count; } +#if (BLE_INCLUDED == TRUE) +// Address resolution status +uint8_t btm_get_ble_addr_resolve_disable_status(void) +{ + // Returns false if address resolution is enabled, true if disabled + return (btm_cb.addr_res_en) ? 0 : 1; +} + +void btm_ble_addr_resolve_enable(bool enable) +{ + btm_cb.addr_res_en = enable; +} +#endif /*BLE_INCLUDED*/ diff --git a/components/bt/host/bluedroid/stack/btm/btm_pm.c b/components/bt/host/bluedroid/stack/btm/btm_pm.c index 4c52348ecd..1c46a7446f 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_pm.c +++ b/components/bt/host/bluedroid/stack/btm/btm_pm.c @@ -543,7 +543,7 @@ static tBTM_PM_MODE btm_pm_get_set_mode(UINT8 pm_id, tBTM_PM_MCB *p_cb, tBTM_PM_ ** Function btm_pm_snd_md_req ** Description get the resulting mode and send the resuest to host controller ** Returns tBTM_STATUS -**, BOOLEAN *p_chg_ind +** *******************************************************************************/ static tBTM_STATUS btm_pm_snd_md_req(UINT8 pm_id, UINT16 link_hdl, tBTM_PM_PWR_MD *p_mode) { @@ -565,6 +565,8 @@ static tBTM_STATUS btm_pm_snd_md_req(UINT8 pm_id, UINT16 link_hdl, tBTM_PM_PWR_M /* already in the resulting mode */ if ( (mode == BTM_PM_MD_ACTIVE) || ((md_res.max >= p_cb->interval) && (md_res.min <= p_cb->interval)) ) { + // Clear request change indication because already in result mode + p_cb->chg_ind = FALSE; return BTM_CMD_STORED; } /* Otherwise, needs to wake, then sleep */ @@ -689,7 +691,7 @@ static void btm_pm_check_stored(void) ** Description This function is called when an HCI command status event occurs ** for power manager related commands. ** -** Input Parms status - status of the event (HCI_SUCCESS if no errors) +** Input Params status - status of the event (HCI_SUCCESS if no errors) ** ** Returns none. ** @@ -717,7 +719,7 @@ void btm_pm_proc_cmd_status(UINT8 status) #if BTM_PM_DEBUG == TRUE BTM_TRACE_DEBUG( "btm_pm_proc_cmd_status new state:0x%x", p_cb->state); #endif // BTM_PM_DEBUG - } else { /* the command was not successfull. Stay in the same state */ + } else { /* the command was not successful. Stay in the same state */ pm_status = BTM_PM_STS_ERROR; } @@ -743,7 +745,7 @@ void btm_pm_proc_cmd_status(UINT8 status) ** ** Description This function is called when an HCI mode change event occurs. ** -** Input Parms hci_status - status of the event (HCI_SUCCESS if no errors) +** Input Params hci_status - status of the event (HCI_SUCCESS if no errors) ** hci_handle - connection handle associated with the change ** mode - HCI_MODE_ACTIVE, HCI_MODE_HOLD, HCI_MODE_SNIFF, or HCI_MODE_PARK ** interval - number of baseband slots (meaning depends on mode) diff --git a/components/bt/host/bluedroid/stack/btm/btm_sco.c b/components/bt/host/bluedroid/stack/btm/btm_sco.c index 53a9768a1a..7dede5d4d3 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_sco.c +++ b/components/bt/host/bluedroid/stack/btm/btm_sco.c @@ -123,6 +123,22 @@ void btm_sco_init (void) btm_cb.sco_cb.desired_sco_mode = BTM_DEFAULT_SCO_MODE; } +/******************************************************************************* +** +** Function btm_sco_free +** +** Description Free sco specific fixed_queue from btm control block +** +*******************************************************************************/ +void btm_sco_free(void) +{ +#if (BTM_SCO_HCI_INCLUDED == TRUE) + for (int i = 0; i < BTM_MAX_SCO_LINKS; i++) { + fixed_queue_free(btm_cb.sco_cb.sco_db[i].xmit_data_q, osi_free_func); + } +#endif +} + /******************************************************************************* ** ** Function btm_esco_conn_rsp @@ -233,7 +249,7 @@ void btm_sco_process_num_bufs (UINT16 num_lm_sco_bufs) ** pointer is used, PCM parameter maintained in ** the control block will be used; otherwise update ** control block value. -** err_data_rpt: Lisbon feature to enable the erronous data report +** err_data_rpt: Lisbon feature to enable the erroneous data report ** or not. ** ** Returns BTM_SUCCESS if the successful. @@ -947,7 +963,7 @@ void btm_sco_conn_req (BD_ADDR bda, DEV_CLASS dev_class, UINT8 link_type) for (xx = 0; xx < BTM_MAX_SCO_LINKS; xx++, p++) { /* * If the sco state is in the SCO_ST_CONNECTING state, we still need - * to return accept sco to avoid race conditon for sco creation + * to return accept sco to avoid race condition for sco creation */ int rem_bd_matches = p->rem_bd_known && !memcmp (p->esco.data.bd_addr, bda, BD_ADDR_LEN); diff --git a/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h b/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h index 0f8888fb1b..b3bc06aff4 100644 --- a/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h +++ b/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h @@ -212,11 +212,14 @@ typedef struct { #define BTM_BLE_MAX_BG_CONN_DEV_NUM 10 typedef struct { + UINT16 scan_interval; + UINT16 scan_window; UINT16 min_conn_int; UINT16 max_conn_int; UINT16 slave_latency; UINT16 supervision_tout; - + UINT16 min_ce_len; + UINT16 max_ce_len; } tBTM_LE_CONN_PRAMS; @@ -377,6 +380,7 @@ typedef struct { tBTM_BLE_STATE_MASK cur_states; /* bit mask of tBTM_BLE_STATE */ UINT8 link_count[2]; /* total link count master and slave*/ tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK *update_exceptional_list_cmp_cb; + tBTM_SET_CSA_SUPPORT_CMPL_CBACK *set_csa_support_cmpl_cb; } tBTM_BLE_CB; #ifdef __cplusplus diff --git a/components/bt/host/bluedroid/stack/btm/include/btm_int.h b/components/bt/host/bluedroid/stack/btm/include/btm_int.h index 47a398c87f..7d76629267 100644 --- a/components/bt/host/bluedroid/stack/btm/include/btm_int.h +++ b/components/bt/host/bluedroid/stack/btm/include/btm_int.h @@ -50,6 +50,7 @@ typedef char tBTM_LOC_BD_NAME[BTM_MAX_LOC_BD_NAME_LEN + 1]; #endif #define BTM_ACL_IS_CONNECTED(bda) (btm_bda_to_acl (bda, BT_TRANSPORT_BR_EDR) != NULL) +#define BTM_LE_ACL_IS_CONNECTED(bda) (btm_bda_to_acl (bda, BT_TRANSPORT_LE) != NULL) /* Definitions for Server Channel Number (SCN) management */ @@ -875,6 +876,7 @@ typedef struct { UINT16 ediv; /* received ediv value from LTK request */ UINT8 key_size; tBTM_BLE_VSC_CB cmn_ble_vsc_cb; + BOOLEAN addr_res_en; /* internal use for test: address resolution enable/disable */ #endif /* Packet types supported by the local device */ @@ -1107,6 +1109,7 @@ void btm_ble_periodic_adv_sync_trans_complete(UINT16 op_code, UINT8 hci_status, ******************************************** */ void btm_sco_init (void); +void btm_sco_free(void); void btm_sco_connected (UINT8 hci_status, BD_ADDR bda, UINT16 hci_handle, tBTM_ESCO_DATA *p_esco_data); void btm_esco_proc_conn_chg (UINT8 status, UINT16 handle, UINT8 tx_interval, diff --git a/components/bt/host/bluedroid/stack/btu/btu_hcif.c b/components/bt/host/bluedroid/stack/btu/btu_hcif.c index 4140a4d79c..e5d602fbc7 100644 --- a/components/bt/host/bluedroid/stack/btu/btu_hcif.c +++ b/components/bt/host/bluedroid/stack/btu/btu_hcif.c @@ -145,6 +145,7 @@ static void btu_ble_periodic_adv_sync_lost_evt(UINT8 *p); static void btu_ble_scan_timeout_evt(UINT8 *p); static void btu_ble_adv_set_terminate_evt(UINT8 *p); static void btu_ble_scan_req_received_evt(UINT8 *p); +static void btu_ble_channel_select_alg_evt(UINT8 *p); #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) static void btu_ble_periodic_adv_sync_trans_recv(UINT8 *p); @@ -413,6 +414,7 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) btu_ble_scan_req_received_evt(p); break; case HCI_BLE_CHANNEL_SELECT_ALG: + btu_ble_channel_select_alg_evt(p); break; #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) @@ -2154,7 +2156,9 @@ static void btu_ble_ext_adv_report_evt(UINT8 *p, UINT16 evt_len) { tBTM_BLE_EXT_ADV_REPORT ext_adv_report = {0}; UINT8 num_reports = {0}; +#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE) UINT8 *pp = p; +#endif //UINT8 legacy_event_type = 0; UINT16 evt_type = 0; uint8_t addr_type; @@ -2341,6 +2345,21 @@ static void btu_ble_scan_req_received_evt(UINT8 *p) btm_ble_scan_req_received_evt(&req_received); } + +static void btu_ble_channel_select_alg_evt(UINT8 *p) +{ + tBTM_BLE_CHANNEL_SEL_ALG chan_sel_alg = {0}; + + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + + STREAM_TO_UINT16(chan_sel_alg.conn_handle, p); + STREAM_TO_UINT8(chan_sel_alg.channel_sel_alg, p); + + btm_ble_channel_select_algorithm_evt(&chan_sel_alg); +} #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) diff --git a/components/bt/host/bluedroid/stack/gatt/gatt_db.c b/components/bt/host/bluedroid/stack/gatt/gatt_db.c index e84580bc95..8844ef5dc8 100644 --- a/components/bt/host/bluedroid/stack/gatt/gatt_db.c +++ b/components/bt/host/bluedroid/stack/gatt/gatt_db.c @@ -60,7 +60,7 @@ static BOOLEAN gatts_add_char_desc_value_check (tGATT_ATTR_VAL *attr_val, tGATTS ** Parameter p_db: database pointer. ** len: size of the memory space. ** -** Returns Status of te operation. +** Returns Status of the operation. ** *******************************************************************************/ BOOLEAN gatts_init_service_db (tGATT_SVC_DB *p_db, tBT_UUID *p_service, BOOLEAN is_pri, @@ -94,7 +94,7 @@ BOOLEAN gatts_init_service_db (tGATT_SVC_DB *p_db, tBT_UUID *p_service, BOOLEAN ** Parameter p_db: database pointer. ** len: size of the memory space. ** -** Returns Status of te operation. +** Returns Status of the operation. ** *******************************************************************************/ tBT_UUID *gatts_get_service_uuid (tGATT_SVC_DB *p_db) @@ -497,14 +497,14 @@ UINT16 gatts_add_included_service (tGATT_SVC_DB *p_db, UINT16 s_handle, UINT16 e ** Function gatts_add_characteristic ** ** Description This function add a characteristics and its descriptor into -** a servce identified by the service database pointer. +** a service identified by the service database pointer. ** ** Parameter p_db: database pointer. ** perm: permission (authentication and key size requirements) ** property: property of the characteristic. ** p_char: characteristic value information. ** -** Returns Status of te operation. +** Returns Status of the operation. ** *******************************************************************************/ UINT16 gatts_add_characteristic (tGATT_SVC_DB *p_db, tGATT_PERM perm, @@ -1173,40 +1173,40 @@ tGATT_STATUS gatts_write_attr_perm_check (tGATT_SVC_DB *p_db, UINT8 op_code, if ((op_code == GATT_SIGN_CMD_WRITE) && !(perm & GATT_WRITE_SIGNED_PERM)) { status = GATT_WRITE_NOT_PERMIT; - GATT_TRACE_DEBUG( "gatts_write_attr_perm_check - sign cmd write not allowed,handle:0x%04x",handle); + GATT_TRACE_DEBUG( "gatts_write_attr_perm_check - sign cmd write not allowed,handle %04x,perm %04x", handle, perm); } if ((op_code == GATT_SIGN_CMD_WRITE) && (sec_flag & GATT_SEC_FLAG_ENCRYPTED)) { status = GATT_INVALID_PDU; - GATT_TRACE_ERROR( "gatts_write_attr_perm_check - Error!! sign cmd write sent on a encypted link,handle:0x%04x",handle); + GATT_TRACE_ERROR( "gatts_write_attr_perm_check - Error!! sign cmd write sent on a encrypted link,handle %04x,perm %04x", handle, perm); } else if (!(perm & GATT_WRITE_ALLOWED)) { status = GATT_WRITE_NOT_PERMIT; - GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_WRITE_NOT_PERMIT,handle:0x%04x",handle); + GATT_TRACE_ERROR("gatts_write_attr_perm_check - GATT_WRITE_NOT_PERMIT,handle %04x, perm %04x", handle, perm); } /* require authentication, but not been authenticated */ else if ((perm & GATT_WRITE_AUTH_REQUIRED ) && !(sec_flag & GATT_SEC_FLAG_LKEY_UNAUTHED)) { status = GATT_INSUF_AUTHENTICATION; - GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_AUTHENTICATION,handle:0x%04x",handle); + GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_AUTHENTICATION,handle %04x, perm %04x", handle, perm); } else if ((perm & GATT_WRITE_MITM_REQUIRED ) && !(sec_flag & GATT_SEC_FLAG_LKEY_AUTHED)) { status = GATT_INSUF_AUTHENTICATION; - GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_AUTHENTICATION: MITM required,handle:0x%04x",handle); + GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_AUTHENTICATION: MITM required,handle %04x,perm %04x", handle, perm); } else if ((perm & GATT_WRITE_ENCRYPTED_PERM ) && !(sec_flag & GATT_SEC_FLAG_ENCRYPTED)) { status = GATT_INSUF_ENCRYPTION; - GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_ENCRYPTION,handle:0x%04x",handle); + GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_ENCRYPTION,handle:0x%04x, perm:0x%04x", handle, perm); } else if ((perm & GATT_WRITE_ENCRYPTED_PERM ) && (sec_flag & GATT_SEC_FLAG_ENCRYPTED) && (key_size < min_key_size)) { status = GATT_INSUF_KEY_SIZE; - GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_KEY_SIZE,handle:0x%04x",handle); + GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_KEY_SIZE,handle %04x,perm %04x", handle, perm); } /* LE Authorization check*/ else if ((perm & GATT_WRITE_AUTHORIZATION) && (!(sec_flag & GATT_SEC_FLAG_LKEY_AUTHED) || !(sec_flag & GATT_SEC_FLAG_AUTHORIZATION))){ status = GATT_INSUF_AUTHORIZATION; - GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_AUTHORIZATION,handle:0x%04x",handle); + GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_AUTHORIZATION,handle %04x,perm %04x", handle, perm); } /* LE security mode 2 attribute */ else if (perm & GATT_WRITE_SIGNED_PERM && op_code != GATT_SIGN_CMD_WRITE && !(sec_flag & GATT_SEC_FLAG_ENCRYPTED) && (perm & GATT_WRITE_ALLOWED) == 0) { status = GATT_INSUF_AUTHENTICATION; - GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_AUTHENTICATION: LE security mode 2 required,handle:0x%04x",handle); - } else { /* writable: must be char value declaration or char descritpors */ + GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_AUTHENTICATION: LE security mode 2 required,handle %04x,perm %04x", handle, perm); + } else { /* writable: must be char value declaration or char descriptors */ if (p_attr->uuid_type == GATT_ATTR_UUID_TYPE_16) { switch (p_attr->uuid) { case GATT_UUID_CHAR_PRESENT_FORMAT:/* should be readable only */ @@ -1215,13 +1215,19 @@ tGATT_STATUS gatts_write_attr_perm_check (tGATT_SVC_DB *p_db, UINT8 op_code, case GATT_UUID_CHAR_VALID_RANGE: status = GATT_WRITE_NOT_PERMIT; break; - + case GATT_UUID_GAP_ICON:/* The Appearance characteristic value shall be 2 octets in length */ case GATT_UUID_CHAR_CLIENT_CONFIG: /* coverity[MISSING_BREAK] */ /* intnended fall through, ignored */ /* fall through */ case GATT_UUID_CHAR_SRVR_CONFIG: max_size = 2; + status = GATT_SUCCESS; + break; + case GATT_UUID_CLIENT_SUP_FEAT: + max_size = 1; + status = GATT_SUCCESS; + break; case GATT_UUID_CHAR_DESCRIPTION: default: /* any other must be character value declaration */ status = GATT_SUCCESS; @@ -1249,10 +1255,10 @@ tGATT_STATUS gatts_write_attr_perm_check (tGATT_SVC_DB *p_db, UINT8 op_code, { if (op_code == GATT_REQ_PREPARE_WRITE) { /* does not allow write blob */ status = GATT_REQ_NOT_SUPPORTED; - GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_REQ_NOT_SUPPORTED,handle:0x%04x",handle); + GATT_TRACE_ERROR("gatts_write_attr_perm_check - GATT_REQ_NOT_SUPPORTED,handle %04x,opcode %4x", handle, op_code); } else if (len != max_size) { /* data does not match the required format */ status = GATT_INVALID_ATTR_LEN; - GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INVALID_ATTR_LEN,handle:0x%04x",handle); + GATT_TRACE_ERROR("gatts_write_attr_perm_check - GATT_INVALID_ATTR_LEN,handle %04x,op_code %04x,len %d,max_size %d", handle, op_code, len, max_size); } else { status = GATT_SUCCESS; } @@ -1554,7 +1560,7 @@ static BOOLEAN gatts_db_add_service_declaration(tGATT_SVC_DB *p_db, tBT_UUID *p_ uuid.uu.uuid16 = GATT_UUID_SEC_SERVICE; } - /* add service declration record */ + /* add service declaration record */ if ((p_attr = (tGATT_ATTR16 *)(allocate_attr_in_db(p_db, &uuid, GATT_PERM_READ))) != NULL) { if (copy_extra_byte_in_db (p_db, (void **)&p_attr->p_value, sizeof(tBT_UUID))) { if (p_service->len == LEN_UUID_16) { diff --git a/components/bt/host/bluedroid/stack/hcic/hciblecmds.c b/components/bt/host/bluedroid/stack/hcic/hciblecmds.c index 52a2b2dc09..286f8e3ae5 100644 --- a/components/bt/host/bluedroid/stack/hcic/hciblecmds.c +++ b/components/bt/host/bluedroid/stack/hcic/hciblecmds.c @@ -349,8 +349,8 @@ BOOLEAN btsnd_hcic_ble_create_ll_conn (UINT16 scan_int, UINT16 scan_win, UINT16_TO_STREAM (pp, conn_latency); UINT16_TO_STREAM (pp, conn_timeout); - UINT16_TO_STREAM (pp, min_ce_len); - UINT16_TO_STREAM (pp, max_ce_len); + UINT16_TO_STREAM (pp, min_ce_len ? min_ce_len : BLE_CE_LEN_MIN); + UINT16_TO_STREAM (pp, max_ce_len ? max_ce_len : BLE_CE_LEN_MIN); btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); return (TRUE); @@ -1594,8 +1594,8 @@ BOOLEAN btsnd_hcic_ble_create_ext_conn(tHCI_CreatExtConn *p_conn) UINT16_TO_STREAM(pp, params->conn_interval_max); UINT16_TO_STREAM(pp, params->conn_latency); UINT16_TO_STREAM(pp, params->sup_timeout); - UINT16_TO_STREAM(pp, BLE_CE_LEN_MIN); - UINT16_TO_STREAM(pp, BLE_CE_LEN_MIN); + UINT16_TO_STREAM(pp, params->min_ce_len ? params->min_ce_len : BLE_CE_LEN_MIN); + UINT16_TO_STREAM(pp, params->max_ce_len ? params->max_ce_len : BLE_CE_LEN_MIN); } if (p_conn->init_phy_mask & 0x02) { @@ -1606,8 +1606,8 @@ BOOLEAN btsnd_hcic_ble_create_ext_conn(tHCI_CreatExtConn *p_conn) UINT16_TO_STREAM(pp, params->conn_interval_max); UINT16_TO_STREAM(pp, params->conn_latency); UINT16_TO_STREAM(pp, params->sup_timeout); - UINT16_TO_STREAM(pp, BLE_CE_LEN_MIN); - UINT16_TO_STREAM(pp, BLE_CE_LEN_MIN); + UINT16_TO_STREAM(pp, params->min_ce_len ? params->min_ce_len : BLE_CE_LEN_MIN); + UINT16_TO_STREAM(pp, params->max_ce_len ? params->max_ce_len : BLE_CE_LEN_MIN); } if (p_conn->init_phy_mask & 0x04) { @@ -1618,8 +1618,8 @@ BOOLEAN btsnd_hcic_ble_create_ext_conn(tHCI_CreatExtConn *p_conn) UINT16_TO_STREAM(pp, params->conn_interval_max); UINT16_TO_STREAM(pp, params->conn_latency); UINT16_TO_STREAM(pp, params->sup_timeout); - UINT16_TO_STREAM(pp, BLE_CE_LEN_MIN); - UINT16_TO_STREAM(pp, BLE_CE_LEN_MIN); + UINT16_TO_STREAM(pp, params->min_ce_len ? params->min_ce_len : BLE_CE_LEN_MIN); + UINT16_TO_STREAM(pp, params->max_ce_len ? params->max_ce_len : BLE_CE_LEN_MIN); } btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); @@ -1910,7 +1910,7 @@ UINT8 btsnd_hcic_ble_set_default_periodic_adv_sync_trans_params(UINT8 mode, UINT } #endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) -UINT8 btsnd_hcic_ble_set_privacy_mode(UINT8 addr_type, BD_ADDR addr, UINT8 privacy_mode) +BOOLEAN btsnd_hcic_ble_set_privacy_mode(UINT8 addr_type, BD_ADDR addr, UINT8 privacy_mode) { BT_HDR *p; UINT8 *pp; @@ -1933,4 +1933,26 @@ UINT8 btsnd_hcic_ble_set_privacy_mode(UINT8 addr_type, BD_ADDR addr, UINT8 priva btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); return (TRUE); } + +BOOLEAN btsnd_hcic_ble_set_csa_support (UINT8 csa_select) +{ + BT_HDR *p; + UINT8 *pp; + + if ((p = HCI_GET_CMD_BUF (HCIC_PARAM_SIZE_BLE_SET_CSA_SUPPORT)) == NULL) { + return (FALSE); + } + + pp = (UINT8 *)(p + 1); + + p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_SET_CSA_SUPPORT; + p->offset = 0; + + UINT16_TO_STREAM (pp, HCI_VENDOR_BLE_SET_CSA_SUPPORT); + UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_SET_CSA_SUPPORT); + UINT8_TO_STREAM (pp, csa_select); + + btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); + return TRUE; +} #endif diff --git a/components/bt/host/bluedroid/stack/include/stack/btm_api.h b/components/bt/host/bluedroid/stack/include/stack/btm_api.h index 1d4b059627..ceed6d2391 100644 --- a/components/bt/host/bluedroid/stack/include/stack/btm_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/btm_api.h @@ -75,6 +75,7 @@ enum { BTM_SET_STATIC_RAND_ADDR_FAIL, /* 25 Command failed */ BTM_INVALID_STATIC_RAND_ADDR, /* 26 invalid static rand addr */ BTM_SEC_DEV_REC_REMOVED, /* 27 Device record relate to the bd_addr is removed */ + BTM_HCI_ERROR = 128, /* 128 HCI error code from controller (0x80) */ }; typedef uint8_t tBTM_STATUS; @@ -434,22 +435,22 @@ typedef void (tBTM_ADD_DEV_TO_RESOLVING_LIST_CMPL_CBACK) (UINT8 status); #define BTM_COD_SERVICE_INFORMATION 0x8000 /* class of device field macros */ -#define BTM_COD_FORMAT_TYPE(u8, pd) {u8 = pd[2]&0x03;} +#define BTM_COD_RESERVED_2(u8, pd) {u8 = pd[2]&0x03;} #define BTM_COD_MINOR_CLASS(u8, pd) {u8 = pd[2]&0xFC;} #define BTM_COD_MAJOR_CLASS(u8, pd) {u8 = pd[1]&0x1F;} #define BTM_COD_SERVICE_CLASS(u16, pd) {u16 = pd[0]; u16<<=8; u16 += pd[1]&0xE0;} /* to set the fields (assumes that format type is always 0) */ -#define FIELDS_TO_COD(pd, mn, mj, sv) {pd[2] = mn; pd[1] = \ - mj+ ((sv)&BTM_COD_SERVICE_CLASS_LO_B); \ - pd[0] = (sv) >> 8;} +#define FIELDS_TO_COD(pd, rs, mn, mj, sv) {pd[2] = (mn & BTM_COD_MINOR_CLASS_MASK) + (rs & BTM_COD_RESERVED_2_MASK); \ + pd[1] = mj+ ((sv)&BTM_COD_SERVICE_CLASS_LO_B); \ + pd[0] = (sv) >> 8;} /* the COD masks */ -#define BTM_COD_FORMAT_TYPE_MASK 0x03 #define BTM_COD_MINOR_CLASS_MASK 0xFC #define BTM_COD_MAJOR_CLASS_MASK 0x1F #define BTM_COD_SERVICE_CLASS_LO_B 0x00E0 #define BTM_COD_SERVICE_CLASS_MASK 0xFFE0 +#define BTM_COD_RESERVED_2_MASK 0x03 /* BTM service definitions diff --git a/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h b/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h index 1b30964284..3dc7dc8b33 100644 --- a/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h @@ -1007,6 +1007,7 @@ typedef void (tBTM_START_STOP_ADV_CMPL_CBACK) (UINT8 status); typedef void (tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK) (tBTM_STATUS status, uint8_t subcode, uint32_t length, uint8_t *device_info); typedef void (tBTM_CLEAR_ADV_CMPL_CBACK) (UINT8 status); typedef void (tBTM_SET_PRIVACY_MODE_CMPL_CBACK) (tBTM_STATUS status); +typedef void (tBTM_SET_CSA_SUPPORT_CMPL_CBACK) (tBTM_STATUS status); #if (BLE_50_FEATURE_SUPPORT == TRUE) #define BTM_BLE_5_GAP_READ_PHY_COMPLETE_EVT 1 @@ -2112,7 +2113,7 @@ void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK *p_vsc_cback); ** *******************************************************************************/ //extern -UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length); +UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT16 adv_data_len, UINT8 type, UINT8 *p_length); /******************************************************************************* ** @@ -2724,6 +2725,20 @@ BOOLEAN BTM_BleSetPrivacyMode(UINT8 addr_type, UINT8 privacy_mode, tBTM_SET_PRIVACY_MODE_CMPL_CBACK *p_callback); +/******************************************************************************* +** +** Function BTM_BleSetCsaSupport +** +** Description This function is called to set the ChSel field of Advertising or Initiating PDUs +** +** Parameters csa_select - Select LE Channel Selection Algorithm. +** p_callback - Callback function to be called when the operation is completed. +** +** Returns TRUE if the operation was successful, otherwise FALSE. +** +*******************************************************************************/ +BOOLEAN BTM_BleSetCsaSupport (UINT8 csa_select, tBTM_SET_CSA_SUPPORT_CMPL_CBACK *p_callback); + /* #ifdef __cplusplus } diff --git a/components/bt/host/bluedroid/stack/include/stack/hcidefs.h b/components/bt/host/bluedroid/stack/include/stack/hcidefs.h index 2caedaf9e2..9150155682 100644 --- a/components/bt/host/bluedroid/stack/include/stack/hcidefs.h +++ b/components/bt/host/bluedroid/stack/include/stack/hcidefs.h @@ -421,6 +421,7 @@ #define HCI_SUBCODE_BLE_ADV_REPORT_FLOW_CONTROL 0x0A #define HCI_SUBCODE_BLE_RD_STATIC_ADDR 0x0B #define HCI_SUBCODE_BLE_CLEAR_ADV 0x0C +#define HCI_SUBCODE_BLE_SET_CSA_SUPPORT 0x12 #define HCI_SUBCODE_BLE_MAX 0x7F //ESP BT subcode define @@ -466,6 +467,8 @@ #define HCI_VENDOR_BLE_ADV_REPORT_FLOW_CONTROL HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_ADV_REPORT_FLOW_CONTROL) /* BLE clear legacy advertising */ #define HCI_VENDOR_BLE_CLEAR_ADV HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_CLEAR_ADV) +/* BLE set CSA support */ +#define HCI_VENDOR_BLE_SET_CSA_SUPPORT HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_SET_CSA_SUPPORT) //ESP BT HCI CMD /* subcode for multi adv feature */ @@ -1867,42 +1870,50 @@ typedef struct { #define HCI_PING_SUPPORTED(x) ((x)[HCI_EXT_FEATURE_PING_OFF] & HCI_EXT_FEATURE_PING_MASK) /* -** LE features encoding - page 0 (the only page for now) +** LE features encoding - page 0 */ -/* LE Encryption */ +/* LE Encryption: bit 0 */ #define HCI_LE_FEATURE_LE_ENCRYPTION_MASK 0x01 #define HCI_LE_FEATURE_LE_ENCRYPTION_OFF 0 #define HCI_LE_ENCRYPTION_SUPPORTED(x) ((x)[HCI_LE_FEATURE_LE_ENCRYPTION_OFF] & HCI_LE_FEATURE_LE_ENCRYPTION_MASK) -/* Connection Parameters Request Procedure */ +/* Connection Parameters Request Procedure: bit 1 */ #define HCI_LE_FEATURE_CONN_PARAM_REQ_MASK 0x02 #define HCI_LE_FEATURE_CONN_PARAM_REQ_OFF 0 #define HCI_LE_CONN_PARAM_REQ_SUPPORTED(x) ((x)[HCI_LE_FEATURE_CONN_PARAM_REQ_OFF] & HCI_LE_FEATURE_CONN_PARAM_REQ_MASK) -/* Extended Reject Indication */ +/* Extended Reject Indication: bit 2 */ #define HCI_LE_FEATURE_EXT_REJ_IND_MASK 0x04 #define HCI_LE_FEATURE_EXT_REJ_IND_OFF 0 #define HCI_LE_EXT_REJ_IND_SUPPORTED(x) ((x)[HCI_LE_FEATURE_EXT_REJ_IND_OFF] & HCI_LE_FEATURE_EXT_REJ_IND_MASK) -/* Slave-initiated Features Exchange */ +/* Slave-initiated Features Exchange: bit 3 */ #define HCI_LE_FEATURE_SLAVE_INIT_FEAT_EXC_MASK 0x08 #define HCI_LE_FEATURE_SLAVE_INIT_FEAT_EXC_OFF 0 #define HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(x) ((x)[HCI_LE_FEATURE_SLAVE_INIT_FEAT_EXC_OFF] & HCI_LE_FEATURE_SLAVE_INIT_FEAT_EXC_MASK) +/* LE Data Packet Length Extension: bit 5 */ +#define HCI_LE_FEATURE_DATA_LEN_EXT_MASK 0x20 +#define HCI_LE_FEATURE_DATA_LEN_EXT_OFF 0 +#define HCI_LE_DATA_LEN_EXT_SUPPORTED(x) ((x)[HCI_LE_FEATURE_DATA_LEN_EXT_OFF] & HCI_LE_FEATURE_DATA_LEN_EXT_MASK) + /* Enhanced privacy Feature: bit 6 */ #define HCI_LE_FEATURE_ENHANCED_PRIVACY_MASK 0x40 #define HCI_LE_FEATURE_ENHANCED_PRIVACY_OFF 0 #define HCI_LE_ENHANCED_PRIVACY_SUPPORTED(x) ((x)[HCI_LE_FEATURE_ENHANCED_PRIVACY_OFF] & HCI_LE_FEATURE_ENHANCED_PRIVACY_MASK) -/* Extended scanner filter policy : 7 */ +/* Extended scanner filter policy: bit 7 */ #define HCI_LE_FEATURE_EXT_SCAN_FILTER_POLICY_MASK 0x80 #define HCI_LE_FEATURE_EXT_SCAN_FILTER_POLICY_OFF 0 #define HCI_LE_EXT_SCAN_FILTER_POLICY_SUPPORTED(x) ((x)[HCI_LE_FEATURE_EXT_SCAN_FILTER_POLICY_OFF] & HCI_LE_FEATURE_EXT_SCAN_FILTER_POLICY_MASK) -/* Slave-initiated Features Exchange */ -#define HCI_LE_FEATURE_DATA_LEN_EXT_MASK 0x20 -#define HCI_LE_FEATURE_DATA_LEN_EXT_OFF 0 -#define HCI_LE_DATA_LEN_EXT_SUPPORTED(x) ((x)[HCI_LE_FEATURE_DATA_LEN_EXT_OFF] & HCI_LE_FEATURE_DATA_LEN_EXT_MASK) +/* +** LE features encoding - page 1 +*/ +/* LE Extended Advertising: bit 12 */ +#define HCI_LE_FEATURE_EXT_ADV_MASK 0x10 +#define HCI_LE_FEATURE_EXT_ADV_OFF 1 +#define HCI_LE_EXT_ADV_SUPPORTED(x) ((x)[HCI_LE_FEATURE_EXT_ADV_OFF] & HCI_LE_FEATURE_EXT_ADV_MASK) /* ** Local Supported Commands encoding diff --git a/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h b/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h index ed98f8f63d..b5f2e2ad50 100644 --- a/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h +++ b/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h @@ -755,6 +755,7 @@ void btsnd_hcic_vendor_spec_cmd (BT_HDR *buffer, UINT16 opcode, #define HCIC_PARAM_SIZE_BLE_UPDATE_ADV_FLOW_CONTROL 2 #define HCIC_PARAM_SIZE_BLE_CLEAR_ADV 0 #define HCIC_PARAM_SIZE_SET_PRIVACY_MODE 8 +#define HCIC_PARAM_SIZE_BLE_SET_CSA_SUPPORT 1 #if (BLE_50_FEATURE_SUPPORT == TRUE) #define HCIC_PARAM_SIZE_BLE_READ_PHY 2 #define HCIC_PARAM_SIZE_BLE_SET_DEF_PHY 3 @@ -910,7 +911,12 @@ BOOLEAN btsnd_hcic_ble_set_rand_priv_addr_timeout (UINT16 rpa_timout); BOOLEAN btsnd_hcic_ble_clear_adv(void); +BOOLEAN btsnd_hcic_ble_set_privacy_mode(UINT8 addr_type, BD_ADDR addr, UINT8 privacy_mode); + +BOOLEAN btsnd_hcic_ble_set_csa_support (UINT8 csa_select); + #endif /* BLE_INCLUDED */ + #if (BLE_50_FEATURE_SUPPORT == TRUE) typedef struct { UINT8 scan_type; @@ -1038,8 +1044,6 @@ UINT8 btsnd_hcic_ble_write_rf_path_compensation(UINT16 rf_tx_path, UINT16 rf_rx_ #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) -UINT8 btsnd_hcic_ble_set_privacy_mode(UINT8 addr_type, BD_ADDR addr, UINT8 privacy_mode); - #define HCIC_PARAM_SIZE_WRITE_AUTHENT_PAYLOAD_TOUT 4 #define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_HANDLE_OFF 0 diff --git a/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c b/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c index 956a4b7fb2..ecb42fc321 100644 --- a/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c +++ b/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c @@ -111,7 +111,7 @@ BOOLEAN L2CA_CancelBleConnectReq (BD_ADDR rem_bda) p_lcb = l2cu_find_lcb_by_bd_addr(rem_bda, BT_TRANSPORT_LE); /* Do not remove lcb if an LE link is already up as a peripheral */ if (p_lcb != NULL && - !(p_lcb->link_role == HCI_ROLE_SLAVE && BTM_ACL_IS_CONNECTED(rem_bda))) { + !(p_lcb->link_role == HCI_ROLE_SLAVE && BTM_LE_ACL_IS_CONNECTED(rem_bda))) { p_lcb->disc_reason = L2CAP_CONN_CANCEL; l2cu_release_lcb (p_lcb); } @@ -376,6 +376,7 @@ void l2cble_scanner_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE type, p_lcb->waiting_update_conn_latency = p_lcb->current_used_conn_latency = conn_latency; p_lcb->conn_update_mask = L2C_BLE_NOT_DEFAULT_PARAM; p_lcb->updating_param_flag = false; + p_lcb->ble_addr_type = type; /* If there are any preferred connection parameters, set them now */ if ( (p_dev_rec->conn_params.min_conn_int >= BTM_BLE_CONN_INT_MIN ) && @@ -476,6 +477,7 @@ void l2cble_advertiser_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE typ p_lcb->waiting_update_conn_latency = p_lcb->current_used_conn_latency = conn_latency; p_lcb->conn_update_mask = L2C_BLE_NOT_DEFAULT_PARAM; p_lcb->updating_param_flag = false; + p_lcb->ble_addr_type = type; /* Tell BTM Acl management about the link */ p_dev_rec = btm_find_or_alloc_dev (bda); @@ -900,6 +902,12 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb) scan_int = (p_cb->scan_int == BTM_BLE_SCAN_PARAM_UNDEF) ? BTM_BLE_SCAN_FAST_INT : p_cb->scan_int; scan_win = (p_cb->scan_win == BTM_BLE_SCAN_PARAM_UNDEF) ? BTM_BLE_SCAN_FAST_WIN : p_cb->scan_win; + if (p_dev_rec->conn_params.scan_interval && p_dev_rec->conn_params.scan_interval != BTM_BLE_CONN_PARAM_UNDEF) { + scan_int = p_dev_rec->conn_params.scan_interval; + } + if (p_dev_rec->conn_params.scan_window && p_dev_rec->conn_params.scan_window != BTM_BLE_CONN_PARAM_UNDEF) { + scan_win = p_dev_rec->conn_params.scan_window; + } peer_addr_type = p_lcb->ble_addr_type; memcpy(peer_addr, p_lcb->remote_bd_addr, BD_ADDR_LEN); @@ -964,22 +972,24 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb) } if (!p_lcb->is_aux) { - if (!btsnd_hcic_ble_create_ll_conn (scan_int,/* UINT16 scan_int */ - scan_win, /* UINT16 scan_win */ - FALSE, /* UINT8 white_list */ - peer_addr_type, /* UINT8 addr_type_peer */ - peer_addr, /* BD_ADDR bda_peer */ - own_addr_type, /* UINT8 addr_type_own */ + if (!btsnd_hcic_ble_create_ll_conn (scan_int, /* UINT16 scan_int */ + scan_win, /* UINT16 scan_win */ + FALSE, /* UINT8 white_list */ + peer_addr_type, /* UINT8 addr_type_peer */ + peer_addr, /* BD_ADDR bda_peer */ + own_addr_type, /* UINT8 addr_type_own */ (UINT16) ((p_dev_rec->conn_params.min_conn_int != BTM_BLE_CONN_PARAM_UNDEF) ? - p_dev_rec->conn_params.min_conn_int : BTM_BLE_CONN_INT_MIN_DEF), /* UINT16 conn_int_min */ + p_dev_rec->conn_params.min_conn_int : BTM_BLE_CONN_INT_MIN_DEF), /* UINT16 conn_int_min */ (UINT16) ((p_dev_rec->conn_params.max_conn_int != BTM_BLE_CONN_PARAM_UNDEF) ? - p_dev_rec->conn_params.max_conn_int : BTM_BLE_CONN_INT_MAX_DEF), /* UINT16 conn_int_max */ + p_dev_rec->conn_params.max_conn_int : BTM_BLE_CONN_INT_MAX_DEF), /* UINT16 conn_int_max */ (UINT16) ((p_dev_rec->conn_params.slave_latency != BTM_BLE_CONN_PARAM_UNDEF) ? - p_dev_rec->conn_params.slave_latency : BTM_BLE_CONN_SLAVE_LATENCY_DEF), /* UINT16 conn_latency */ + p_dev_rec->conn_params.slave_latency : BTM_BLE_CONN_SLAVE_LATENCY_DEF), /* UINT16 conn_latency */ (UINT16) ((p_dev_rec->conn_params.supervision_tout != BTM_BLE_CONN_PARAM_UNDEF) ? - p_dev_rec->conn_params.supervision_tout : BTM_BLE_CONN_TIMEOUT_DEF), /* conn_timeout */ - BLE_CE_LEN_MIN, /* UINT16 min_len */ - BLE_CE_LEN_MIN)) { /* UINT16 max_len */ + p_dev_rec->conn_params.supervision_tout : BTM_BLE_CONN_TIMEOUT_DEF), /* UINT16 conn_timeout */ + (UINT16) ((p_dev_rec->conn_params.min_ce_len != BTM_BLE_CONN_PARAM_UNDEF) ? + p_dev_rec->conn_params.min_ce_len : BLE_CE_LEN_MIN), /* UINT16 min_ce_len */ + (UINT16) ((p_dev_rec->conn_params.max_ce_len != BTM_BLE_CONN_PARAM_UNDEF) ? + p_dev_rec->conn_params.max_ce_len : BLE_CE_LEN_MIN) /* UINT16 max_ce_len */)) { l2cu_release_lcb (p_lcb); L2CAP_TRACE_ERROR("initiate direct connection fail, no resources"); return (FALSE); diff --git a/components/bt/host/bluedroid/stack/sdp/sdp_db.c b/components/bt/host/bluedroid/stack/sdp/sdp_db.c index a9b3daa4ca..60dd04a6b9 100644 --- a/components/bt/host/bluedroid/stack/sdp/sdp_db.c +++ b/components/bt/host/bluedroid/stack/sdp/sdp_db.c @@ -276,7 +276,7 @@ static int sdp_compose_proto_list( UINT8 *p, UINT16 num_elem, ** ** Description This function is called to create a record in the database. ** This would be through the SDP database maintenance API. The -** record is created empty, teh application should then call +** record is created empty, the application should then call ** "add_attribute" to add the record's attributes. ** ** Returns Record handle if OK, else 0. @@ -293,15 +293,15 @@ UINT32 SDP_CreateRecord (void) /* First, check if there is a free record */ if (p_db->num_records < SDP_MAX_RECORDS) { - p_rec =(tSDP_RECORD *)osi_malloc(sizeof(tSDP_RECORD)); - if (p_rec) { - memset(p_rec, 0, sizeof(tSDP_RECORD)); - /* Save previous rec */ - if (p_db->num_records) { - p_rec_prev = list_back(p_db->p_record_list); - } - /* Append new record */ - list_append(p_db->p_record_list, p_rec); + p_rec = (tSDP_RECORD *)osi_malloc(sizeof(tSDP_RECORD)); + if (p_rec) { + memset(p_rec, 0, sizeof(tSDP_RECORD)); + /* Save previous rec */ + if (p_db->num_records) { + p_rec_prev = list_back(p_db->p_record_list); + } + /* Append new record */ + list_append(p_db->p_record_list, p_rec); /* We will use a handle of the first unreserved handle plus last record ** number + 1 */ @@ -321,10 +321,12 @@ UINT32 SDP_CreateRecord (void) 4, buf); return (p_rec->record_handle); - } else { + } + else { SDP_TRACE_ERROR("SDP_CreateRecord fail, memory allocation failed\n"); - } - } else { + } + } + else { SDP_TRACE_ERROR("SDP_CreateRecord fail, exceed maximum records:%d\n", SDP_MAX_RECORDS); } #endif @@ -354,17 +356,17 @@ BOOLEAN SDP_DeleteRecord (UINT32 handle) if (handle == 0 || sdp_cb.server_db.num_records == 0) { /* Delete all records in the database */ sdp_cb.server_db.num_records = 0; - for(p_node = list_begin(sdp_cb.server_db.p_record_list); p_node; p_node = list_next(p_node)) { - list_remove(sdp_cb.server_db.p_record_list, p_node); - } + for (p_node = list_begin(sdp_cb.server_db.p_record_list); p_node; p_node = list_next(p_node)) { + list_remove(sdp_cb.server_db.p_record_list, p_node); + } /* require new DI record to be created in SDP_SetLocalDiRecord */ sdp_cb.server_db.di_primary_handle = 0; return (TRUE); } else { /* Find the record in the database */ - for(p_node = list_begin(sdp_cb.server_db.p_record_list); p_node; p_node = list_next(p_node)) { - p_rec = list_node(p_node); + for (p_node = list_begin(sdp_cb.server_db.p_record_list); p_node; p_node = list_next(p_node)) { + p_rec = list_node(p_node); if (p_rec->record_handle == handle) { /* Found it. Shift everything up one */ list_remove(sdp_cb.server_db.p_record_list, p_rec); @@ -374,7 +376,7 @@ BOOLEAN SDP_DeleteRecord (UINT32 handle) SDP_TRACE_DEBUG("SDP_DeleteRecord ok, num_records:%d\n", sdp_cb.server_db.num_records); /* if we're deleting the primary DI record, clear the */ /* value in the control block */ - if ( sdp_cb.server_db.di_primary_handle == handle ) { + if (sdp_cb.server_db.di_primary_handle == handle) { sdp_cb.server_db.di_primary_handle = 0; } diff --git a/components/bt/host/bluedroid/stack/sdp/sdp_discovery.c b/components/bt/host/bluedroid/stack/sdp/sdp_discovery.c index d63b164ded..31ab11f46f 100644 --- a/components/bt/host/bluedroid/stack/sdp/sdp_discovery.c +++ b/components/bt/host/bluedroid/stack/sdp/sdp_discovery.c @@ -453,7 +453,7 @@ static void process_service_attr_rsp (tCONN_CB *p_ccb, UINT8 *p_reply) } } - /* Now, ask for the next handle. Re-use the buffer we just got. */ + /* Now, ask for the next handle. Reuse the buffer we just got. */ if (p_ccb->cur_handle < p_ccb->num_handles) { BT_HDR *p_msg = (BT_HDR *) osi_malloc(SDP_DATA_BUF_SIZE); UINT8 *p; @@ -669,6 +669,7 @@ static void process_service_search_attr_rsp (tCONN_CB *p_ccb, UINT8 *p_reply) if ((type >> 3) != DATA_ELE_SEQ_DESC_TYPE) { SDP_TRACE_WARNING ("SDP - Wrong type: 0x%02x in attr_rsp\n", type); + sdp_disconnect (p_ccb, SDP_ILLEGAL_PARAMETER); return; } p = sdpu_get_len_from_type (p, type, &seq_len); diff --git a/components/bt/host/bluedroid/stack/smp/smp_utils.c b/components/bt/host/bluedroid/stack/smp/smp_utils.c index 2e9fac77c9..48ba6c0ae3 100644 --- a/components/bt/host/bluedroid/stack/smp/smp_utils.c +++ b/components/bt/host/bluedroid/stack/smp/smp_utils.c @@ -331,8 +331,7 @@ BOOLEAN smp_send_msg_to_L2CAP(BD_ADDR rem_bda, BT_HDR *p_toL2CAP) if ((l2cap_ret = L2CA_SendFixedChnlData (fixed_cid, rem_bda, p_toL2CAP)) == L2CAP_DW_FAILED) { smp_cb.total_tx_unacked -= 1; - SMP_TRACE_ERROR("SMP failed to pass msg:0x%0x to L2CAP", - *((UINT8 *)(p_toL2CAP + 1) + p_toL2CAP->offset)); + SMP_TRACE_ERROR("SMP failed to pass msg to L2CAP"); return FALSE; } else { return TRUE; @@ -1125,7 +1124,7 @@ BOOLEAN smp_pairing_request_response_parameters_are_valid(tSMP_CB *p_cb) SMP_TRACE_DEBUG("%s for cmd code 0x%02x\n", __func__, p_cb->rcvd_cmd_code); if (io_caps >= BTM_IO_CAP_MAX) { - SMP_TRACE_WARNING("Rcvd from the peer cmd 0x%02x with IO Capabilty \ + SMP_TRACE_WARNING("Rcvd from the peer cmd 0x%02x with IO Capability \ value (0x%02x) out of range).\n", p_cb->rcvd_cmd_code, io_caps); return FALSE; diff --git a/components/bt/host/nimble/Kconfig.in b/components/bt/host/nimble/Kconfig.in index d352fe1342..c8abddaa44 100644 --- a/components/bt/host/nimble/Kconfig.in +++ b/components/bt/host/nimble/Kconfig.in @@ -100,6 +100,14 @@ config BT_NIMBLE_L2CAP_COC_MAX_NUM help Defines maximum number of BLE Connection Oriented Channels. When set to (0), BLE COC is not compiled in +config BT_NIMBLE_L2CAP_ENHANCED_COC + bool "L2CAP Enhanced Connection Oriented Channel" + depends on BT_NIMBLE_ENABLED && (BT_NIMBLE_L2CAP_COC_MAX_NUM >= 1) + default 0 + help + Enable Enhanced Credit Based Flow Control Mode + + choice BT_NIMBLE_PINNED_TO_CORE_CHOICE prompt "The CPU core on which NimBLE host will run" depends on BT_NIMBLE_ENABLED && !FREERTOS_UNICORE @@ -222,6 +230,13 @@ config BT_NIMBLE_SM_SC_LVL 3. Authenticated pairing with encryption 4. Authenticated LE Secure Connections pairing with encryption using a 128-bit strength encryption key. +config BT_NIMBLE_SM_SC_ONLY + int "Enable Secure Connections Only Mode" + depends on BT_NIMBLE_SECURITY_ENABLE + default 0 + help + Enable Secure Connections Only Mode + config BT_NIMBLE_DEBUG bool "Enable extra runtime asserts and host debugging" default n @@ -543,131 +558,163 @@ menuconfig BT_NIMBLE_50_FEATURE_SUPPORT help Enable BLE 5 feature -config BT_NIMBLE_LL_CFG_FEAT_LE_2M_PHY - bool "Enable 2M Phy" - depends on BT_NIMBLE_50_FEATURE_SUPPORT - default y - help - Enable 2M-PHY - -config BT_NIMBLE_LL_CFG_FEAT_LE_CODED_PHY - bool "Enable coded Phy" - depends on BT_NIMBLE_50_FEATURE_SUPPORT - default y - help - Enable coded-PHY - -config BT_NIMBLE_EXT_ADV - bool "Enable extended advertising" - depends on BT_NIMBLE_50_FEATURE_SUPPORT - default n - help - Enable this option to do extended advertising. Extended advertising - will be supported from BLE 5.0 onwards. +if BT_NIMBLE_50_FEATURE_SUPPORT + config BT_NIMBLE_LL_CFG_FEAT_LE_2M_PHY + bool "Enable 2M Phy" + depends on BT_NIMBLE_50_FEATURE_SUPPORT + default y + help + Enable 2M-PHY -if BT_NIMBLE_EXT_ADV - config BT_NIMBLE_MAX_EXT_ADV_INSTANCES - int "Maximum number of extended advertising instances." - range 0 4 - default 1 if BT_NIMBLE_EXT_ADV - default 0 - depends on BT_NIMBLE_EXT_ADV + config BT_NIMBLE_LL_CFG_FEAT_LE_CODED_PHY + bool "Enable coded Phy" + depends on BT_NIMBLE_50_FEATURE_SUPPORT + default y help - Change this option to set maximum number of extended advertising - instances. Minimum there is always one instance of - advertising. Enter how many more advertising instances you - want. - For ESP32C2, ESP32C6 and ESP32H2, each extended advertising instance - will take about 0.5k DRAM. - - config BT_NIMBLE_EXT_ADV_MAX_SIZE - int "Maximum length of the advertising data." - range 0 1650 - default 1650 if BT_NIMBLE_EXT_ADV - default 0 - depends on BT_NIMBLE_EXT_ADV + Enable coded-PHY + + config BT_NIMBLE_EXT_ADV + bool "Enable extended advertising" + depends on BT_NIMBLE_50_FEATURE_SUPPORT + default n help - Defines the length of the extended adv data. The value should not - exceed 1650. + Enable this option to do extended advertising. Extended advertising + will be supported from BLE 5.0 onwards. + + if BT_NIMBLE_EXT_ADV + config BT_NIMBLE_MAX_EXT_ADV_INSTANCES + int "Maximum number of extended advertising instances." + range 0 4 + default 1 if BT_NIMBLE_EXT_ADV + default 0 + depends on BT_NIMBLE_EXT_ADV + help + Change this option to set maximum number of extended advertising + instances. Minimum there is always one instance of + advertising. Enter how many more advertising instances you + want. + For ESP32C2, ESP32C6 and ESP32H2, each extended advertising instance + will take about 0.5k DRAM. + + config BT_NIMBLE_EXT_ADV_MAX_SIZE + int "Maximum length of the advertising data." + range 0 1650 + default 1650 if BT_NIMBLE_EXT_ADV + default 0 + depends on BT_NIMBLE_EXT_ADV + help + Defines the length of the extended adv data. The value should not + exceed 1650. - config BT_NIMBLE_ENABLE_PERIODIC_ADV - bool "Enable periodic advertisement." + config BT_NIMBLE_ENABLE_PERIODIC_ADV + bool "Enable periodic advertisement." + default y + depends on BT_NIMBLE_EXT_ADV + help + Enable this option to start periodic advertisement. + + config BT_NIMBLE_PERIODIC_ADV_ENH + bool "Periodic adv enhancements(adi support)" + depends on BT_NIMBLE_ENABLE_PERIODIC_ADV && SOC_BLE_PERIODIC_ADV_ENH_SUPPORTED + help + Enable the periodic advertising enhancements + + config BT_NIMBLE_PERIODIC_ADV_SYNC_TRANSFER + bool "Enable Transfer Sync Events" + depends on BT_NIMBLE_ENABLE_PERIODIC_ADV + default y + help + This enables controller transfer periodic sync events to host + + config BT_NIMBLE_PERIODIC_ADV_WITH_RESPONSES + bool "Enable Periodic Advertisement with Response (EXPERIMENTAL)" + depends on BT_NIMBLE_ENABLE_PERIODIC_ADV + default n + help + This enables controller PAwR (Periodic Advertisement with Response). + endif + + config BT_NIMBLE_EXT_SCAN + bool "Enable extended scanning" + depends on BT_NIMBLE_50_FEATURE_SUPPORT && BT_NIMBLE_ROLE_OBSERVER default y - depends on BT_NIMBLE_EXT_ADV help - Enable this option to start periodic advertisement. + Enable this option to do extended scanning. - config BT_NIMBLE_PERIODIC_ADV_SYNC_TRANSFER - bool "Enable Transfer Sync Events" - depends on BT_NIMBLE_ENABLE_PERIODIC_ADV + config BT_NIMBLE_ENABLE_PERIODIC_SYNC + bool "Enable periodic sync" default y + depends on BT_NIMBLE_EXT_SCAN help - This enables controller transfer periodic sync events to host -endif - -config BT_NIMBLE_MAX_PERIODIC_SYNCS - int "Maximum number of periodic advertising syncs" - depends on BT_NIMBLE_50_FEATURE_SUPPORT - range 0 3 if IDF_TARGET_ESP32C2 - range 0 8 - default 1 if BT_NIMBLE_ENABLE_PERIODIC_ADV - default 0 - help - Set this option to set the upper limit for number of periodic sync - connections. This should be less than maximum connections allowed by - controller. - -config BT_NIMBLE_MAX_PERIODIC_ADVERTISER_LIST - int "Maximum number of periodic advertiser list" - depends on BT_NIMBLE_50_FEATURE_SUPPORT && SOC_ESP_NIMBLE_CONTROLLER - range 1 5 - default 5 if BT_NIMBLE_50_FEATURE_SUPPORT - help - Set this option to set the upper limit for number of periodic advertiser list. + Enable this option to receive periodic advertisement. + + if BT_NIMBLE_ENABLE_PERIODIC_SYNC + config BT_NIMBLE_MAX_PERIODIC_SYNCS + int "Maximum number of periodic advertising syncs" + range 0 3 if IDF_TARGET_ESP32C2 + range 0 8 + default 1 if BT_NIMBLE_ENABLE_PERIODIC_ADV + default 0 + help + Set this option to set the upper limit for number of periodic sync + connections. This should be less than maximum connections allowed by + controller. + + config BT_NIMBLE_MAX_PERIODIC_ADVERTISER_LIST + int "Maximum number of periodic advertiser list" + depends on SOC_ESP_NIMBLE_CONTROLLER + range 1 5 + default 5 if BT_NIMBLE_50_FEATURE_SUPPORT + help + Set this option to set the upper limit for number of periodic advertiser list. + endif -config BT_NIMBLE_BLE_POWER_CONTROL - bool "Enable support for BLE Power Control" - depends on BT_NIMBLE_50_FEATURE_SUPPORT && SOC_BLE_POWER_CONTROL_SUPPORTED - default n - help - Set this option to enable the Power Control feature + config BT_NIMBLE_BLE_POWER_CONTROL + bool "Enable support for BLE Power Control" + depends on BT_NIMBLE_50_FEATURE_SUPPORT && SOC_BLE_POWER_CONTROL_SUPPORTED + default n + help + Set this option to enable the Power Control feature -config BT_NIMBLE_PERIODIC_ADV_ENH - bool "Periodic adv enhancements(adi support)" - depends on BT_NIMBLE_ENABLE_PERIODIC_ADV && BT_NIMBLE_50_FEATURE_SUPPORT && SOC_BLE_PERIODIC_ADV_ENH_SUPPORTED - help - Enable the periodic advertising enhancements + menuconfig BT_NIMBLE_GATT_CACHING + bool "Enable GATT caching" + depends on BT_NIMBLE_ENABLED && BT_NIMBLE_50_FEATURE_SUPPORT + select BT_NIMBLE_DYNAMIC_SERVICE + help + Enable GATT caching + config BT_NIMBLE_GATT_CACHING_MAX_CONNS + int "Maximum connections to be cached" + depends on BT_NIMBLE_GATT_CACHING + default 1 + help + Set this option to set the upper limit on number of connections to be cached. + config BT_NIMBLE_GATT_CACHING_MAX_SVCS + int "Maximum number of services per connection" + depends on BT_NIMBLE_GATT_CACHING + default 64 + help + Set this option to set the upper limit on number of services per connection to be cached. + config BT_NIMBLE_GATT_CACHING_MAX_CHRS + int "Maximum number of characteristics per connection" + depends on BT_NIMBLE_GATT_CACHING + default 64 + help + Set this option to set the upper limit on number of characteristics per connection to be cached. + config BT_NIMBLE_GATT_CACHING_MAX_DSCS + int "Maximum number of descriptors per connection" + depends on BT_NIMBLE_GATT_CACHING + default 64 + help + Set this option to set the upper limit on number of descriptors per connection to be cached. + config BT_NIMBLE_GATT_CACHING_DISABLE_AUTO + bool "Do not start discovery procedure automatically upon receiving Out of Sync" + depends on BT_NIMBLE_GATT_CACHING + default n + help + When client receives ATT out-of-sync error message, it will not automatically start the discovery procedure + to correct the invalid cache. +endif -menuconfig BT_NIMBLE_GATT_CACHING - bool "Enable GATT caching" - depends on BT_NIMBLE_ENABLED && BT_NIMBLE_50_FEATURE_SUPPORT - select BT_NIMBLE_DYNAMIC_SERVICE - help - Enable GATT caching -config BT_NIMBLE_GATT_CACHING_MAX_CONNS - int "Maximum connections to be cached" - depends on BT_NIMBLE_GATT_CACHING - default 1 - help - Set this option to set the upper limit on number of connections to be cached. -config BT_NIMBLE_GATT_CACHING_MAX_SVCS - int "Maximum number of services per connection" - depends on BT_NIMBLE_GATT_CACHING - default 64 - help - Set this option to set the upper limit on number of services per connection to be cached. -config BT_NIMBLE_GATT_CACHING_MAX_CHRS - int "Maximum number of characteristics per connection" - depends on BT_NIMBLE_GATT_CACHING - default 64 - help - Set this option to set the upper limit on number of characteristics per connection to be cached. -config BT_NIMBLE_GATT_CACHING_MAX_DSCS - int "Maximum number of descriptors per connection" - depends on BT_NIMBLE_GATT_CACHING - default 64 - help - Set this option to set the upper limit on number of descriptors per connection to be cached. config BT_NIMBLE_WHITELIST_SIZE int "BLE white list size" @@ -865,6 +912,12 @@ menu "GAP Service" Peripheral Preferred Connection Parameter: Supervision Timeout Timeout = Value * 10 ms + config BT_NIMBLE_SVC_GAP_GATT_SECURITY_LEVEL + bool "LE GATT Security Level Characteristic" + default n + help + Enable the LE GATT Security Level Characteristic + endmenu menu "BLE Services" @@ -888,6 +941,71 @@ menu "BLE Services" default 3 help Defines maximum number of report characteristics per service instance + + config BT_NIMBLE_SVC_BAS_BATTERY_LEVEL_NOTIFY + depends on BT_NIMBLE_ENABLED + bool "BAS Battery Level NOTIFY permission" + default n + help + Enable/Disable notifications on BAS Battery Level Characteristic + + menu "Device Information Service" + config BT_NIMBLE_SVC_DIS_MANUFACTURER_NAME + depends on BT_NIMBLE_ENABLED + bool "Manufacturer Name" + default n + help + Enable the DIS characteristic Manufacturer Name String characteristic + + config BT_NIMBLE_SVC_DIS_SERIAL_NUMBER + depends on BT_NIMBLE_ENABLED + bool "Serial Number" + default n + help + Enable the DIS Serial Number characteristic + + config BT_NIMBLE_SVC_DIS_HARDWARE_REVISION + depends on BT_NIMBLE_ENABLED + bool "Hardware Revision" + default n + help + Enable the DIS Hardware Revision characteristic + + config BT_NIMBLE_SVC_DIS_FIRMWARE_REVISION + depends on BT_NIMBLE_ENABLED + bool "Firmware Revision" + default n + help + Enable the DIS Firmware Revision characteristic + + config BT_NIMBLE_SVC_DIS_SOFTWARE_REVISION + depends on BT_NIMBLE_ENABLED + bool "Software Revision" + default n + help + Enable the DIS Software Revision characteristic + + config BT_NIMBLE_SVC_DIS_SYSTEM_ID + depends on BT_NIMBLE_ENABLED + bool "System ID" + default n + help + Enable the DIS System ID characteristic + + config BT_NIMBLE_SVC_DIS_PNP_ID + depends on BT_NIMBLE_ENABLED + bool "PnP ID" + default n + help + Enable the DIS PnP ID characteristic + + config BT_NIMBLE_SVC_DIS_INCLUDED + depends on BT_NIMBLE_ENABLED + bool "DIS as an Included Service" + default n + help + Use DIS as an included service + endmenu endmenu config BT_NIMBLE_VS_SUPPORT @@ -908,7 +1026,6 @@ config BT_NIMBLE_OPTIMIZE_MULTI_CONN config BT_NIMBLE_ENC_ADV_DATA bool "Encrypted Advertising Data" - select BT_NIMBLE_EXT_ADV help This option is used to enable encrypted advertising data. @@ -1056,3 +1173,17 @@ menu "Host-controller Transport" help UART HCI CTS pin endmenu + +config BT_NIMBLE_EATT_CHAN_NUM + int "Maximum number of EATT channels" + default 0 + depends on BT_NIMBLE_ENABLED + help + Defines the number of channels EATT bearers can use + +config BT_NIMBLE_SUBRATE + bool "Enable Subrate Change" + default n + depends on BT_NIMBLE_ENABLED + help + Enable connection subrate change feature diff --git a/components/bt/host/nimble/esp-hci/src/esp_nimble_hci.c b/components/bt/host/nimble/esp-hci/src/esp_nimble_hci.c index ed4b7adfeb..9fec7119f1 100644 --- a/components/bt/host/nimble/esp-hci/src/esp_nimble_hci.c +++ b/components/bt/host/nimble/esp-hci/src/esp_nimble_hci.c @@ -163,14 +163,14 @@ static void ble_hci_rx_acl(uint8_t *data, uint16_t len) m = ble_transport_alloc_acl_from_ll(); if (!m) { - ESP_LOGD(TAG,"Failed to allocate buffer, retrying \n"); + esp_rom_printf("Failed to allocate buffer, retrying "); /* Give some time to free buffer and try again */ vTaskDelay(1); } }while(!m); if ((rc = os_mbuf_append(m, data, len)) != 0) { - ESP_LOGE(TAG, "%s failed to os_mbuf_append; rc = %d", __func__, rc); + esp_rom_printf("%s failed to os_mbuf_append; rc = %d", __func__, rc); os_mbuf_free_chain(m); return; } @@ -190,6 +190,11 @@ static void controller_rcv_pkt_ready(void) } } +static void dummy_controller_rcv_pkt_ready(void) +{ + /* Dummy function */ +} + void bt_record_hci_data(uint8_t *data, uint16_t len) { #if (BT_HCI_LOG_INCLUDED == TRUE) @@ -203,6 +208,12 @@ void bt_record_hci_data(uint8_t *data, uint16_t len) #endif // (BT_HCI_LOG_INCLUDED == TRUE) } +static int dummy_host_rcv_pkt(uint8_t *data, uint16_t len) +{ + /* Dummy function */ + return 0; +} + /* * @brief: BT controller callback function, to transfer data packet to the host */ @@ -212,7 +223,7 @@ static int host_rcv_pkt(uint8_t *data, uint16_t len) if(!ble_hs_enabled_state) { /* If host is not enabled, drop the packet */ - ESP_LOGE(TAG, "Host not enabled. Dropping the packet!"); + esp_rom_printf("Host not enabled. Dropping the packet!"); return 0; } @@ -225,7 +236,7 @@ static int host_rcv_pkt(uint8_t *data, uint16_t len) assert(totlen <= UINT8_MAX + BLE_HCI_EVENT_HDR_LEN); if (totlen > MYNEWT_VAL(BLE_TRANSPORT_EVT_SIZE)) { - ESP_LOGE(TAG, "Received HCI data length at host (%d) exceeds maximum configured HCI event buffer size (%d).", + esp_rom_printf("Received HCI data length at host (%d) exceeds maximum configured HCI event buffer size (%d).", totlen, MYNEWT_VAL(BLE_TRANSPORT_EVT_SIZE)); ble_hs_sched_reset(BLE_HS_ECONTROLLER); return 0; @@ -264,6 +275,11 @@ static const esp_vhci_host_callback_t vhci_host_cb = { .notify_host_recv = host_rcv_pkt, }; +static const esp_vhci_host_callback_t dummy_vhci_host_cb = { + .notify_host_send_available = dummy_controller_rcv_pkt_ready, + .notify_host_recv = dummy_host_rcv_pkt, +}; + extern void ble_transport_init(void); extern esp_err_t ble_buf_alloc(void); @@ -313,6 +329,8 @@ esp_err_t esp_nimble_hci_deinit(void) } ble_transport_deinit(); + esp_vhci_host_register_callback(&dummy_vhci_host_cb); + ble_buf_free(); #if MYNEWT_VAL(BLE_QUEUE_CONG_CHECK) diff --git a/components/bt/host/nimble/nimble b/components/bt/host/nimble/nimble index 1fa7edc41d..b10b120363 160000 --- a/components/bt/host/nimble/nimble +++ b/components/bt/host/nimble/nimble @@ -1 +1 @@ -Subproject commit 1fa7edc41d7ee415699b7abe8fa1f7375d344c83 +Subproject commit b10b120363e7d5efa7fac388ab5b4f8ce743076d diff --git a/components/bt/host/nimble/port/include/esp_nimble_cfg.h b/components/bt/host/nimble/port/include/esp_nimble_cfg.h index 06aa199add..b9a77f5de0 100644 --- a/components/bt/host/nimble/port/include/esp_nimble_cfg.h +++ b/components/bt/host/nimble/port/include/esp_nimble_cfg.h @@ -158,6 +158,16 @@ #define MYNEWT_VAL_BLE_GATT_CACHING_MAX_DSCS (0) #endif +#ifdef CONFIG_BT_NIMBLE_GATT_CACHING_DISABLE_AUTO +#define MYNEWT_VAL_BLE_GATT_CACHING_DISABLE_AUTO (CONFIG_BT_NIMBLE_GATT_CACHING_DISABLE_AUTO) +#else +#define MYNEWT_VAL_BLE_GATT_CACHING_DISABLE_AUTO (0) +#endif + +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_CSFC_SIZE +#define MYNEWT_VAL_BLE_GATT_CSFC_SIZE (1) #endif #ifndef CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES @@ -507,6 +517,12 @@ /*** @apache-mynewt-nimble/nimble/host */ +#if CONFIG_BT_NIMBLE_L2CAP_ENHANCED_COC || CONFIG_BT_NIMBLE_EATT_CHAN_NUM +#define MYNEWT_VAL_BLE_L2CAP_ENHANCED_COC (1) +#else +#define MYNEWT_VAL_BLE_L2CAP_ENHANCED_COC (0) +#endif + #ifndef MYNEWT_VAL_BLE_DYNAMIC_SERVICE #ifdef CONFIG_BT_NIMBLE_DYNAMIC_SERVICE #define MYNEWT_VAL_BLE_DYNAMIC_SERVICE CONFIG_BT_NIMBLE_DYNAMIC_SERVICE @@ -539,6 +555,10 @@ #define MYNEWT_VAL_BLE_ATT_SVR_NOTIFY (1) #endif +#ifndef MYNEWT_VAL_BLE_ATT_SVR_NOTIFY_MULTI +#define MYNEWT_VAL_BLE_ATT_SVR_NOTIFY_MULTI (1) +#endif + #ifndef MYNEWT_VAL_BLE_ATT_SVR_QUEUED_WRITE #define MYNEWT_VAL_BLE_ATT_SVR_QUEUED_WRITE (1) #endif @@ -563,6 +583,10 @@ #define MYNEWT_VAL_BLE_ATT_SVR_READ_MULT (1) #endif +#ifndef MYNEWT_VAL_BLE_ATT_SVR_READ_MULT_VAR +#define MYNEWT_VAL_BLE_ATT_SVR_READ_MULT_VAR (1) +#endif + #ifndef MYNEWT_VAL_BLE_ATT_SVR_READ_TYPE #define MYNEWT_VAL_BLE_ATT_SVR_READ_TYPE (1) #endif @@ -579,6 +603,49 @@ #define MYNEWT_VAL_BLE_ATT_SVR_WRITE_NO_RSP (1) #endif +#ifndef MYNEWT_VAL_BLE_EATT_CHAN_NUM +#define MYNEWT_VAL_BLE_EATT_CHAN_NUM (CONFIG_BT_NIMBLE_EATT_CHAN_NUM) +#endif + +#ifndef MYNEWT_VAL_BLE_EATT_LOG_LVL +#define MYNEWT_VAL_BLE_EATT_LOG_LVL (1) +#endif + +#ifndef MYNEWT_VAL_BLE_EATT_LOG_MOD +#define MYNEWT_VAL_BLE_EATT_LOG_MOD (27) +#endif + +#ifndef MYNEWT_VAL_BLE_EATT_MTU +#define MYNEWT_VAL_BLE_EATT_MTU (128) +#endif + +#ifndef MYNEWT_VAL_BLE_CLIENT_SUPPORTED_FEATURES + +#if MYNEWT_VAL_BLE_GATT_CACHING +#define MYNEWT_VAL_BLE_CLIENT_SUPPORTED_FEATURES_ROBUST_CACHING (1) +#else +#define MYNEWT_VAL_BLE_CLIENT_SUPPORTED_FEATURES_ROBUST_CACHING (0) +#endif //MYNEWT_VAL_BLE_GATT_CACHING + +#if CONFIG_BT_NIMBLE_EATT_CHAN_NUM +#define MYNEWT_VAL_BLE_CLIENT_SUPPORTED_FEATURES_EATT (2) +#else +#define MYNEWT_VAL_BLE_CLIENT_SUPPORTED_FEATURES_EATT (0) +#endif //CONFIG_BT_NIMBLE_EATT_CHAN_NUM + +#if MYNEWT_VAL_BLE_ATT_SVR_NOTIFY_MULTI +#define MYNEWT_VAL_BLE_CLIENT_SUPPORTED_FEATURES_NOTIFY_MULTI (4) +#else +#define MYNEWT_VAL_BLE_CLIENT_SUPPORTED_FEATURES_NOTIFY_MULTI (0) +#endif //MYNEWT_VAL_BLE_ATT_SVR_NOTIFY_MULTI + +#define MYNEWT_VAL_BLE_CLIENT_SUPPORTED_FEATURES ( \ + MYNEWT_VAL_BLE_CLIENT_SUPPORTED_FEATURES_ROBUST_CACHING | \ + MYNEWT_VAL_BLE_CLIENT_SUPPORTED_FEATURES_EATT | \ + MYNEWT_VAL_BLE_CLIENT_SUPPORTED_FEATURES_NOTIFY_MULTI \ + ) +#endif //MYNEWT_VAL_CLIENT_SUPPORTED_FEATURES + #ifndef MYNEWT_VAL_BLE_GAP_MAX_PENDING_CONN_PARAM_UPDATE #define MYNEWT_VAL_BLE_GAP_MAX_PENDING_CONN_PARAM_UPDATE (1) #endif @@ -619,6 +686,10 @@ #define MYNEWT_VAL_BLE_GATT_NOTIFY (1) #endif +#ifndef MYNEWT_VAL_BLE_GATT_NOTIFY_MULTIPLE +#define MYNEWT_VAL_BLE_GATT_NOTIFY_MULTIPLE (1) +#endif + #ifndef MYNEWT_VAL_BLE_GATT_READ #define MYNEWT_VAL_BLE_GATT_READ (MYNEWT_VAL_BLE_ROLE_CENTRAL) #endif @@ -745,11 +816,15 @@ #define MYNEWT_VAL_BLE_HS_SYSINIT_STAGE (200) #endif +#if CONFIG_BT_NIMBLE_EATT_CHAN_NUM > CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM +#define MYNEWT_VAL_BLE_L2CAP_COC_MAX_NUM (CONFIG_BT_NIMBLE_EATT_CHAN_NUM) +#else #ifndef CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM #define MYNEWT_VAL_BLE_L2CAP_COC_MAX_NUM (2) #else #define MYNEWT_VAL_BLE_L2CAP_COC_MAX_NUM CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM -#endif +#endif //CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM +#endif //CONFIG_BT_NIMBLE_EATT_CHAN_NUM #ifndef MYNEWT_VAL_BLE_L2CAP_COC_MPS #define MYNEWT_VAL_BLE_L2CAP_COC_MPS (MYNEWT_VAL_MSYS_1_BLOCK_SIZE-8) @@ -767,7 +842,11 @@ #define MYNEWT_VAL_BLE_L2CAP_RX_FRAG_TIMEOUT (30000) #endif -#ifndef MYNEWT_VAL_BLE_L2CAP_SIG_MAX_PROCS +#if CONFIG_BT_NIMBLE_EATT_CHAN_NUM > CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM +#define MYNEWT_VAL_BLE_L2CAP_SIG_MAX_PROCS (CONFIG_BT_NIMBLE_EATT_CHAN_NUM) +#elif CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM +#define MYNEWT_VAL_BLE_L2CAP_SIG_MAX_PROCS (CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM) +#else #define MYNEWT_VAL_BLE_L2CAP_SIG_MAX_PROCS (1) #endif @@ -881,8 +960,12 @@ #endif #ifndef MYNEWT_VAL_BLE_SM_SC_ONLY +#ifdef CONFIG_BT_NIMBLE_SM_SC_ONLY +#define MYNEWT_VAL_BLE_SM_SC_ONLY (CONFIG_BT_NIMBLE_SM_SC_ONLY) +#else #define MYNEWT_VAL_BLE_SM_SC_ONLY (0) #endif +#endif #ifndef MYNEWT_VAL_BLE_SM_THEIR_KEY_DIST @@ -909,6 +992,10 @@ #define MYNEWT_VAL_BLE_STORE_MAX_CCCDS CONFIG_BT_NIMBLE_MAX_CCCDS #endif +#ifndef MYNEWT_VAL_BLE_STORE_MAX_CSFCS +#define MYNEWT_VAL_BLE_STORE_MAX_CSFCS CONFIG_BT_NIMBLE_MAX_BONDS +#endif + #ifdef CONFIG_BT_NIMBLE_MAX_EADS #define MYNEWT_VAL_BLE_STORE_MAX_EADS CONFIG_BT_NIMBLE_MAX_EADS #endif @@ -953,7 +1040,7 @@ /*** nimble/host/services/bas */ #ifndef MYNEWT_VAL_BLE_SVC_BAS_BATTERY_LEVEL_NOTIFY_ENABLE -#define MYNEWT_VAL_BLE_SVC_BAS_BATTERY_LEVEL_NOTIFY_ENABLE (1) +#define MYNEWT_VAL_BLE_SVC_BAS_BATTERY_LEVEL_NOTIFY_ENABLE (CONFIG_BT_NIMBLE_SVC_BAS_BATTERY_LEVEL_NOTIFY) #endif #ifndef MYNEWT_VAL_BLE_SVC_BAS_BATTERY_LEVEL_READ_PERM @@ -1553,7 +1640,7 @@ /*** @apache-mynewt-nimble/nimble/host/services/bas */ #ifndef MYNEWT_VAL_BLE_SVC_BAS_BATTERY_LEVEL_NOTIFY_ENABLE -#define MYNEWT_VAL_BLE_SVC_BAS_BATTERY_LEVEL_NOTIFY_ENABLE (1) +#define MYNEWT_VAL_BLE_SVC_BAS_BATTERY_LEVEL_NOTIFY_ENABLE (CONFIG_BT_NIMBLE_SVC_BAS_BATTERY_LEVEL_NOTIFY) #endif #ifndef MYNEWT_VAL_BLE_SVC_BAS_BATTERY_LEVEL_READ_PERM @@ -1570,29 +1657,34 @@ #endif #ifndef MYNEWT_VAL_BLE_SVC_DIS_FIRMWARE_REVISION_DEFAULT -#define MYNEWT_VAL_BLE_SVC_DIS_FIRMWARE_REVISION_DEFAULT (NULL) +#define MYNEWT_VAL_BLE_SVC_DIS_FIRMWARE_REVISION_DEFAULT ("0000") #endif /* Value copied from BLE_SVC_DIS_DEFAULT_READ_PERM */ -#ifndef MYNEWT_VAL_BLE_SVC_DIS_FIRMWARE_REVISION_READ_PERM +#if CONFIG_BT_NIMBLE_SVC_DIS_FIRMWARE_REVISION +#define MYNEWT_VAL_BLE_SVC_DIS_FIRMWARE_REVISION_READ_PERM (0) +#else #define MYNEWT_VAL_BLE_SVC_DIS_FIRMWARE_REVISION_READ_PERM (-1) #endif #ifndef MYNEWT_VAL_BLE_SVC_DIS_HARDWARE_REVISION_DEFAULT -#define MYNEWT_VAL_BLE_SVC_DIS_HARDWARE_REVISION_DEFAULT (NULL) +#define MYNEWT_VAL_BLE_SVC_DIS_HARDWARE_REVISION_DEFAULT ("0000") #endif /* Value copied from BLE_SVC_DIS_DEFAULT_READ_PERM */ -#ifndef MYNEWT_VAL_BLE_SVC_DIS_HARDWARE_REVISION_READ_PERM +#if CONFIG_BT_NIMBLE_SVC_DIS_HARDWARE_REVISION +#define MYNEWT_VAL_BLE_SVC_DIS_HARDWARE_REVISION_READ_PERM (0) +#else #define MYNEWT_VAL_BLE_SVC_DIS_HARDWARE_REVISION_READ_PERM (-1) #endif #ifndef MYNEWT_VAL_BLE_SVC_DIS_MANUFACTURER_NAME_DEFAULT -#define MYNEWT_VAL_BLE_SVC_DIS_MANUFACTURER_NAME_DEFAULT (NULL) +#define MYNEWT_VAL_BLE_SVC_DIS_MANUFACTURER_NAME_DEFAULT ("espressif") #endif -/* Value copied from BLE_SVC_DIS_DEFAULT_READ_PERM */ -#ifndef MYNEWT_VAL_BLE_SVC_DIS_MANUFACTURER_NAME_READ_PERM +#if CONFIG_BT_NIMBLE_SVC_DIS_MANUFACTURER_NAME +#define MYNEWT_VAL_BLE_SVC_DIS_MANUFACTURER_NAME_READ_PERM (0) +#else #define MYNEWT_VAL_BLE_SVC_DIS_MANUFACTURER_NAME_READ_PERM (-1) #endif @@ -1605,20 +1697,24 @@ #endif #ifndef MYNEWT_VAL_BLE_SVC_DIS_SERIAL_NUMBER_DEFAULT -#define MYNEWT_VAL_BLE_SVC_DIS_SERIAL_NUMBER_DEFAULT (NULL) +#define MYNEWT_VAL_BLE_SVC_DIS_SERIAL_NUMBER_DEFAULT ("0000") #endif /* Value copied from BLE_SVC_DIS_DEFAULT_READ_PERM */ -#ifndef MYNEWT_VAL_BLE_SVC_DIS_SERIAL_NUMBER_READ_PERM +#if CONFIG_BT_NIMBLE_SVC_DIS_SERIAL_NUMBER +#define MYNEWT_VAL_BLE_SVC_DIS_SERIAL_NUMBER_READ_PERM (0) +#else #define MYNEWT_VAL_BLE_SVC_DIS_SERIAL_NUMBER_READ_PERM (-1) #endif #ifndef MYNEWT_VAL_BLE_SVC_DIS_SOFTWARE_REVISION_DEFAULT -#define MYNEWT_VAL_BLE_SVC_DIS_SOFTWARE_REVISION_DEFAULT (NULL) +#define MYNEWT_VAL_BLE_SVC_DIS_SOFTWARE_REVISION_DEFAULT ("0000") #endif /* Value copied from BLE_SVC_DIS_DEFAULT_READ_PERM */ -#ifndef MYNEWT_VAL_BLE_SVC_DIS_SOFTWARE_REVISION_READ_PERM +#if CONFIG_BT_NIMBLE_SVC_DIS_SOFTWARE_REVISION +#define MYNEWT_VAL_BLE_SVC_DIS_SOFTWARE_REVISION_READ_PERM (0) +#else #define MYNEWT_VAL_BLE_SVC_DIS_SOFTWARE_REVISION_READ_PERM (-1) #endif @@ -1627,23 +1723,31 @@ #endif #ifndef MYNEWT_VAL_BLE_SVC_DIS_SYSTEM_ID_DEFAULT -#define MYNEWT_VAL_BLE_SVC_DIS_SYSTEM_ID_DEFAULT (NULL) +#define MYNEWT_VAL_BLE_SVC_DIS_SYSTEM_ID_DEFAULT ("00000000") #endif /* Value copied from BLE_SVC_DIS_DEFAULT_READ_PERM */ -#ifndef MYNEWT_VAL_BLE_SVC_DIS_SYSTEM_ID_READ_PERM +#if CONFIG_BT_NIMBLE_SVC_DIS_SYSTEM_ID +#define MYNEWT_VAL_BLE_SVC_DIS_SYSTEM_ID_READ_PERM (0) +#else #define MYNEWT_VAL_BLE_SVC_DIS_SYSTEM_ID_READ_PERM (-1) #endif #ifndef MYNEWT_VAL_BLE_SVC_DIS_PNP_ID_DEFAULT -#define MYNEWT_VAL_BLE_SVC_DIS_PNP_ID_DEFAULT (NULL) +#define MYNEWT_VAL_BLE_SVC_DIS_PNP_ID_DEFAULT ("000000") #endif /* Value copied from BLE_SVC_DIS_DEFAULT_READ_PERM */ -#ifndef MYNEWT_VAL_BLE_SVC_DIS_PNP_ID_READ_PERM +#if CONFIG_BT_NIMBLE_SVC_DIS_PNP_ID +#define MYNEWT_VAL_BLE_SVC_DIS_PNP_ID_READ_PERM (0) +#else #define MYNEWT_VAL_BLE_SVC_DIS_PNP_ID_READ_PERM (-1) #endif +#ifndef MYNEWT_VAL_BLE_SVC_DIS_INCLUDED +#define MYNEWT_VAL_BLE_SVC_DIS_INCLUDED (CONFIG_BT_NIMBLE_SVC_DIS_INCLUDED) +#endif + /*** @apache-mynewt-nimble/nimble/host/services/gap */ #ifndef MYNEWT_VAL_BLE_SVC_GAP_APPEARANCE #define MYNEWT_VAL_BLE_SVC_GAP_APPEARANCE CONFIG_BT_NIMBLE_SVC_GAP_APPEARANCE @@ -1706,6 +1810,11 @@ CONFIG_BT_NIMBLE_SVC_GAP_PPCP_SUPERVISION_TMO #endif +#ifndef MYNEWT_VAL_BLE_SVC_GAP_GATT_SECURITY_LEVEL +#define MYNEWT_VAL_BLE_SVC_GAP_GATT_SECURITY_LEVEL \ + CONFIG_BT_NIMBLE_SVC_GAP_GATT_SECURITY_LEVEL +#endif + /*** nimble/transport */ #ifndef MYNEWT_VAL_BLE_HCI_TRANSPORT_EMSPI #define MYNEWT_VAL_BLE_HCI_TRANSPORT_EMSPI (0) @@ -1821,7 +1930,7 @@ #ifdef CONFIG_BT_NIMBLE_HOST_QUEUE_CONG_CHECK #define MYNEWT_VAL_BLE_QUEUE_CONG_CHECK CONFIG_BT_NIMBLE_HOST_QUEUE_CONG_CHECK #else -#define MYNEWT_VAL_BLE_QUEUE_CONG_CHECK FALSE +#define MYNEWT_VAL_BLE_QUEUE_CONG_CHECK (0) #endif #endif @@ -1841,6 +1950,14 @@ #endif #endif +#ifndef MYNEWT_VAL_BT_HCI_LOG_INCLUDED +#ifdef CONFIG_BT_HCI_LOG_DEBUG_EN +#define MYNEWT_VAL_BT_HCI_LOG_INCLUDED CONFIG_BT_HCI_LOG_DEBUG_EN +#else +#define MYNEWT_VAL_BT_HCI_LOG_INCLUDED (0) +#endif +#endif + #if CONFIG_BT_CONTROLLER_DISABLED && CONFIG_BT_NIMBLE_TRANSPORT_UART #ifndef MYNEWT_VAL_BLE_TRANSPORT_UART_PORT #define MYNEWT_VAL_BLE_TRANSPORT_UART_PORT CONFIG_BT_NIMBLE_TRANSPORT_UART_PORT @@ -1875,4 +1992,12 @@ #endif #endif +#ifndef MYNEWT_VAL_BLE_PERIODIC_ADV_WITH_RESPONSES +#ifdef CONFIG_BT_NIMBLE_PERIODIC_ADV_WITH_RESPONSES +#define MYNEWT_VAL_BLE_PERIODIC_ADV_WITH_RESPONSES (CONFIG_BT_NIMBLE_PERIODIC_ADV_WITH_RESPONSES) +#else +#define MYNEWT_VAL_BLE_PERIODIC_ADV_WITH_RESPONSES (0) +#endif +#endif + #endif diff --git a/components/bt/include/esp32/include/esp_bt.h b/components/bt/include/esp32/include/esp_bt.h index cf442169a8..bb561af825 100644 --- a/components/bt/include/esp32/include/esp_bt.h +++ b/components/bt/include/esp32/include/esp_bt.h @@ -55,7 +55,7 @@ extern "C" { * * @note Please do not modify this value. */ -#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20240722 +#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20241015 /** * @brief Bluetooth Controller mode @@ -178,6 +178,27 @@ the adv packet will be discarded until the memory is restored. */ #else #define BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX 0 #endif + +#ifdef CONFIG_BTDM_BLE_LLCP_CONN_UPDATE +#define BTDM_BLE_LLCP_CONN_UPDATE (1<<0) +#else +#define BTDM_BLE_LLCP_CONN_UPDATE (0<<0) +#endif + +#ifdef CONFIG_BTDM_BLE_LLCP_CHAN_MAP_UPDATE +#define BTDM_BLE_LLCP_CHAN_MAP_UPDATE (1<<1) +#else +#define BTDM_BLE_LLCP_CHAN_MAP_UPDATE (0<<1) +#endif + +#define BTDM_BLE_LLCP_DISC_FLAG (BTDM_BLE_LLCP_CONN_UPDATE | BTDM_BLE_LLCP_CHAN_MAP_UPDATE) + +#ifdef CONFIG_BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS +#define BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED CONFIG_BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS +#else +#define BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED 0 +#endif + /** * @brief Default Bluetooth Controller configuration */ @@ -206,6 +227,8 @@ the adv packet will be discarded until the memory is restored. */ .hli = BTDM_CTRL_HLI, \ .dup_list_refresh_period = SCAN_DUPL_CACHE_REFRESH_PERIOD, \ .ble_scan_backoff = BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \ + .ble_llcp_disc_flag = BTDM_BLE_LLCP_DISC_FLAG, \ + .ble_aa_check = BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED, \ .magic = ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL, \ } @@ -219,45 +242,73 @@ the adv packet will be discarded until the memory is restored. */ /** * @brief Bluetooth Controller config options * @note - * 1. For parameters configurable in menuconfig, please refer to menuconfig for details on range and default values. - * 2. It is not recommended to modify the default values of `controller_task_stack_size`, `controller_task_prio`. + * 1. For parameters configurable through menuconfig, it is recommended to adjust them via the menuconfig interface. Please refer to menuconfig for details on the range and default values. + * 2. It is not recommended to modify the values for parameters which are not configurable through menuconfig. */ typedef struct { uint16_t controller_task_stack_size; /*!< Bluetooth Controller task stack size in bytes */ uint8_t controller_task_prio; /*!< Bluetooth Controller task priority */ - uint8_t hci_uart_no; /*!< Indicates UART number if using UART1/2 as HCI I/O interface. Configurable in menuconfig. */ - uint32_t hci_uart_baudrate; /*!< Indicates UART baudrate if using UART1/2 as HCI I/O interface. Configurable in menuconfig. */ - uint8_t scan_duplicate_mode; /*!< Scan duplicate filtering mode. Configurable in menuconfig. */ - uint8_t scan_duplicate_type; /*!< Scan duplicate filtering type. Configurable in menuconfig. */ - uint16_t normal_adv_size; /*!< Maximum number of devices in scan duplicate filtering list. Configurable in menuconfig. */ - uint16_t mesh_adv_size; /*!< Maximum number of Mesh ADV packets in scan duplicate filtering list. Configurable in menuconfig. */ + uint8_t hci_uart_no; /*!< UART number as HCI I/O interface. Configurable in menuconfig. + - 1 - URAT 1 (default) + - 2 - URAT 2 */ + uint32_t hci_uart_baudrate; /*!< UART baudrate. Configurable in menuconfig. + - Range: 115200 - 921600 + - Default: 921600 */ + uint8_t scan_duplicate_mode; /*!< Scan duplicate filtering mode. Configurable in menuconfig. + - 0 - Normal scan duplicate filtering mode (default) + - 1 - Special scan duplicate filtering mode for BLE Mesh */ + uint8_t scan_duplicate_type; /*!< Scan duplicate filtering type. If `scan_duplicate_mode` is set to 1, this parameter will be ignored. Configurable in menuconfig. + - 0 - Filter scan duplicates by device address only (default) + - 1 - Filter scan duplicates by advertising data only, even if they originate from different devices. + - 2 - Filter scan duplicated by device address and advertising data. */ + uint16_t normal_adv_size; /*!< Maximum number of devices in scan duplicate filtering list. Configurable in menuconfig + - Range: 10 - 1000 + - Default: 100 */ + uint16_t mesh_adv_size; /*!< Maximum number of Mesh advertising packets in scan duplicate filtering list. Configurable in menuconfig + - Range: 10 - 1000 + - Default: 100 */ uint16_t send_adv_reserved_size; /*!< Controller minimum memory value in bytes. Internal use only */ uint32_t controller_debug_flag; /*!< Controller debug log flag. Internal use only */ - uint8_t mode; /*!< Controller mode: - - 1: BLE mode - - 2: Classic Bluetooth mode - - 3: Dual mode - - Others: Invalid - C - onfigurable in menuconfig - */ - uint8_t ble_max_conn; /*!< Maximum number of BLE connections. Configurable in menuconfig. */ - uint8_t bt_max_acl_conn; /*!< Maximum number of BR/EDR ACL connections. Configurable in menuconfig. */ - uint8_t bt_sco_datapath; /*!< SCO data path, i.e. HCI or PCM module. Configurable in menuconfig. */ - bool auto_latency; /*!< True if BLE auto latency is enabled, used to enhance Classic Bluetooth performance; false otherwise. Configurable in menuconfig.*/ - bool bt_legacy_auth_vs_evt; /*!< True if BR/EDR Legacy Authentication Vendor Specific Event is enabled, which is required to protect from BIAS attack; false otherwise. Configurable in menuconfig. */ - uint8_t bt_max_sync_conn; /*!< Maximum number of BR/EDR synchronous connections. Configurable in menuconfig. */ - uint8_t ble_sca; /*!< BLE low power crystal accuracy index. Configurable in menuconfig. */ - uint8_t pcm_role; /*!< PCM role (master & slave). Configurable in menuconfig.*/ - uint8_t pcm_polar; /*!< PCM polar trig (falling clk edge & rising clk edge). Configurable in menuconfig. */ - uint8_t pcm_fsyncshp; /*!< Physical shape of the PCM Frame Synchronization signal (stereo mode & mono mode). Configurable in menuconfig */ - bool hli; /*!< True if using high level interrupt; false otherwise. Configurable in menuconfig. */ - uint16_t dup_list_refresh_period; /*!< Scan duplicate filtering list refresh period in seconds. Configurable in menuconfig.*/ - bool ble_scan_backoff; /*!< True if BLE scan backoff is enabled; false otherwise. Configurable in menuconfig.*/ + uint8_t mode; /*!< Controller mode. Configurable in menuconfig + - 1 - BLE mode + - 2 - Classic Bluetooth mode + - 3 - Dual mode + - 4 - Others: Invalid */ + uint8_t ble_max_conn; /*!< Maximum number of BLE connections. Configurable in menuconfig + - Range: 1 - 9 + - Default: 3 */ + uint8_t bt_max_acl_conn; /*!< Maximum number of BR/EDR ACL connections. Configurable in menuconfig + - Range: 1 - 7 + - Default: 2 */ + uint8_t bt_sco_datapath; /*!< SCO data path. Configurable in menuconfig + - 0 - HCI module (default) + - 1 - PCM module */ + bool auto_latency; /*!< True if BLE auto latency is enabled, used to enhance Classic Bluetooth performance in the Dual mode; false otherwise (default). Configurable in menuconfig */ + bool bt_legacy_auth_vs_evt; /*!< True if BR/EDR Legacy Authentication Vendor Specific Event is enabled (default in the classic bluetooth or Dual mode), which is required to protect from BIAS attack; false otherwise. Configurable in menuconfig */ + uint8_t bt_max_sync_conn; /*!< Maximum number of BR/EDR synchronous connections. Configurable in menuconfig + - Range: 0 - 3 + - Default: 0 */ + uint8_t ble_sca; /*!< BLE low power crystal accuracy index. Configurable in menuconfig + - 0 - `BTDM_BLE_DEFAULT_SCA_500PPM` + - 1 - `BTDM_BLE_DEFAULT_SCA_250PPM` (default) */ + uint8_t pcm_role; /*!< PCM role. Configurable in menuconfig + - 0 - PCM master (default) + - 1 - PCM slave (default) */ + uint8_t pcm_polar; /*!< PCM polarity (falling clk edge & rising clk edge). Configurable in menuconfig + - 0 - Falling Edge (default) + - 1 - Rising Edge */ + uint8_t pcm_fsyncshp; /*!< Physical shape of the PCM Frame Synchronization signal. Configurable in menuconfig + - 0 - Stereo Mode (default) + - 1 - Mono Mode 1 + - 2 - Mono Mode 2 */ + bool hli; /*!< True if using high-level (level 4) interrupt (default); false otherwise. Configurable in menuconfig */ + uint16_t dup_list_refresh_period; /*!< Scan duplicate filtering list refresh period in seconds. Configurable in menuconfig + - Range: 0 - 100 seconds + - Default: 0 second */ + bool ble_scan_backoff; /*!< True if BLE scan backoff is enabled; false otherwise (default). Configurable in menuconfig */ + uint8_t ble_llcp_disc_flag; /*!< Flag indicating whether the Controller disconnects after Instant Passed (0x28) error occurs. Configurable in menuconfig. + - The Controller does not disconnect after Instant Passed (0x28) by default. */ + bool ble_aa_check; /*!< True if adds a verification step for the Access Address within the `CONNECT_IND` PDU; false otherwise (default). Configurable in menuconfig */ uint32_t magic; /*!< Magic number */ } esp_bt_controller_config_t; @@ -326,82 +377,6 @@ typedef enum { ESP_SCO_DATA_PATH_PCM = 1, /*!< data over PCM interface */ } esp_sco_data_path_t; -/** - * @brief Set BLE TX power - * - * @note Connection TX power should only be set after the connection is established. - * - * @param[in] power_type The type of TX power. It could be Advertising, Connection, Default, etc. - * @param[in] power_level Power level (index) corresponding to the absolute value (dBm) - * - * @return - * - ESP_OK: Success - * - ESP_ERR_INVALID_ARG: Invalid argument - */ -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 - * - * @note Connection TX power should only be retrieved after the connection is established. - * - * @param[in] power_type The type of TX power. It could be Advertising/Connection/Default and etc. - * - * @return - * - Power level - * - */ -esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type); - -/** - * @brief Set BR/EDR TX power - * - * BR/EDR power control will use the power within the range of minimum value and maximum value. - * The power level will affect the global BR/EDR TX power for operations such as inquiry, page, and connection. - * - * @note - * 1. Please call this function after `esp_bt_controller_enable()` and before any functions that cause RF transmission, - * such as performing discovery, profile initialization, and so on. - * 2. For BR/EDR to use the new TX power for inquiry, call this function before starting an inquiry. - * If BR/EDR is already inquiring, restart the inquiry after calling this function. - * - * @param[in] min_power_level The minimum power level. The default value is `ESP_PWR_LVL_N0`. - * @param[in] max_power_level The maximum power level. The default value is `ESP_PWR_LVL_P3`. - * - * @return - * - ESP_OK: Success - * - ESP_ERR_INVALID_ARG: Invalid argument - * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state - */ -esp_err_t esp_bredr_tx_power_set(esp_power_level_t min_power_level, esp_power_level_t max_power_level); - -/** - * @brief Get BR/EDR TX power - * - * The corresponding power levels will be stored into the arguments. - * - * @param[out] min_power_level Pointer to store the minimum power level - * @param[out] max_power_level The maximum power level - * - * @return - * - ESP_OK: Success - * - ESP_ERR_INVALID_ARG: Invalid argument - */ -esp_err_t esp_bredr_tx_power_get(esp_power_level_t *min_power_level, esp_power_level_t *max_power_level); - -/** - * @brief Set default SCO data path - * - * @note This function should be called after the Controller is enabled, and before (e)SCO link is established. - * - * @param[in] data_path SCO data path - * - * @return - * - ESP_OK: Success - * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state - */ -esp_err_t esp_bredr_sco_datapath_set(esp_sco_data_path_t data_path); - /** * @brief Initialize the Bluetooth Controller to allocate tasks and other resources * @@ -412,6 +387,8 @@ esp_err_t esp_bredr_sco_datapath_set(esp_sco_data_path_t data_path); * @return * - ESP_OK: Success * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state + * - ESP_ERR_INVALID_ARG: Invalid arguments + * - ESP_ERR_NO_MEM: Out of memory */ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg); @@ -420,13 +397,12 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg); * * @note * 1. You should stop advertising and scanning, and disconnect all existing connections before de-initializing Bluetooth Controller. - * 2. This function should be called only once, after any other Bluetooth functions. + * 2. This function should be called after `esp_bt_controller_disable` if the Controller was enabled before. + * 3. This function should be called only once, after any other Bluetooth functions. * * @return * - ESP_OK: Success - * - ESP_ERR_INVALID_ARG: Invalid argument * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state - * - ESP_ERR_NO_MEM: Out of memory */ esp_err_t esp_bt_controller_deinit(void); @@ -446,6 +422,7 @@ esp_err_t esp_bt_controller_deinit(void); * @return * - ESP_OK: Success * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state + * - ESP_ERR_INVALID_ARG: Invalid arguments */ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode); @@ -468,49 +445,6 @@ esp_err_t esp_bt_controller_disable(void); */ esp_bt_controller_status_t esp_bt_controller_get_status(void); -/** - * @brief Vendor HCI (VHCI) callback functions to notify the Host on the next operation - */ -typedef struct esp_vhci_host_callback { - void (*notify_host_send_available)(void); /*!< Callback to notify the Host that the Controller is ready to receive the packet */ - int (*notify_host_recv)(uint8_t *data, uint16_t len); /*!< Callback to notify the Host that the Controller has a packet to send */ -} esp_vhci_host_callback_t; - -/** - * @brief Check whether the Controller is ready to receive the packet - * - * If the return value is True, the Host can send the packet to the Controller. - * - * @note This function should be called before each `esp_vhci_host_send_packet()`. - * - * @return - * True if the Controller is ready to receive packets; false otherwise - */ -bool esp_vhci_host_check_send_available(void); - -/** - * @brief Send the packet to the Controller - * - * @note - * 1. This function shall not be called within a critical section or when the scheduler is suspended. - * 2. This function should be called only if `esp_vhci_host_check_send_available()` returns True. - * - * @param[in] data Pointer to the packet data - * @param[in] len The packet length - */ -void esp_vhci_host_send_packet(uint8_t *data, uint16_t len); - -/** - * @brief Register the VHCI callback funations defined in `esp_vhci_host_callback` structure. - * - * @param[in] callback `esp_vhci_host_callback` type variable - * - * @return - * - ESP_OK: Success - * - ESP_FAIL: Failure - */ -esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback); - /** * @brief Release the Controller memory as per the mode * @@ -518,7 +452,7 @@ esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callba * * @note * 1. This function is optional and should be called only if you want to free up memory for other components. - * 2. This function should only be called when the controller is in `ESP_BT_CONTROLLER_STATUS_IDLE` status. + * 2. This function should only be called when the Controller is in `ESP_BT_CONTROLLER_STATUS_IDLE` status. * 3. Once Bluetooth Controller memory is released, the process cannot be reversed. This means you cannot use the Bluetooth Controller mode that you have released using this function. * 4. If your firmware will upgrade the Bluetooth Controller mode later (such as switching from BLE to Classic Bluetooth or from disabled to enabled), then do not call this function. * @@ -528,6 +462,7 @@ esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callba * * If you intend to use Classic Bluetooth only, calling `esp_bt_controller_mem_release(ESP_BT_MODE_BLE)` could release the BSS and data consumed by BLE Controller. You can then continue using Classic Bluetooth. * + * * @param[in] mode The Bluetooth Controller mode * * @return @@ -537,12 +472,11 @@ esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callba */ esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode); -/** - * @brief Release the Controller memory, BSS and data section of the Classic Bluetooth/BLE Host stack as per the mode +/** @brief Release the Controller memory, BSS and data section of the Classic Bluetooth/BLE Host stack as per the mode * * @note * 1. This function is optional and should be called only if you want to free up memory for other components. - * 2. This function should only be called when the controller is in `ESP_BT_CONTROLLER_STATUS_IDLE` status. + * 2. This function should only be called when the Controller is in `ESP_BT_CONTROLLER_STATUS_IDLE` status. * 3. Once Bluetooth Controller memory is released, the process cannot be reversed. This means you cannot use the Bluetooth Controller mode that you have released using this function. * 4. If your firmware will upgrade the Bluetooth Controller mode later (such as switching from BLE to Classic Bluetooth or from disabled to enabled), then do not call this function. * @@ -591,7 +525,6 @@ esp_err_t esp_bt_mem_release(esp_bt_mode_t mode); */ esp_err_t esp_bt_sleep_enable(void); - /** * @brief Disable Bluetooth modem sleep * @@ -604,12 +537,39 @@ esp_err_t esp_bt_sleep_enable(void); * @return * - ESP_OK: Success * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state - * - ESP_ERR_NOT_SUPPORTED: Operation or feature not supported + * - ESP_ERR_NOT_SUPPORTED: The modem sleep mode is not supported */ esp_err_t esp_bt_sleep_disable(void); /** - * @brief Manually clear the scan duplicate list + * @brief Set BLE TX power + * + * @note Connection TX power should only be set after the connection is established. + * + * @param[in] power_type The type of TX power. It could be Advertising, Connection, Default, etc. + * @param[in] power_level Power level (index) corresponding to the absolute value (dBm) + * + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_ARG: Invalid argument + */ +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 + * + * @note Connection TX power should only be retrieved after the connection is established. + * + * @param[in] power_type The type of TX power. It could be Advertising/Connection/Default and etc. + * + * @return + * - Power level + * + */ +esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type); + +/** + * @brief Manually clear the BLE scan duplicate list * * @note * 1. This function name is incorrectly spelled, it will be fixed in release 5.x version. @@ -620,19 +580,112 @@ esp_err_t esp_bt_sleep_disable(void); * - ESP_OK: Success * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state */ +esp_err_t esp_ble_scan_duplicate_list_flush(void); esp_err_t esp_ble_scan_dupilcate_list_flush(void); /** - * @brief Power on Bluetooth Wi-Fi power domain + * @brief Set BR/EDR TX power + * + * BR/EDR power control will use the power within the range of minimum value and maximum value. + * The power level will affect the global BR/EDR TX power for operations such as inquiry, page, and connection. + * + * @note + * 1. Please call this function after `esp_bt_controller_enable()` and before any functions that cause RF transmission, + * such as performing discovery, profile initialization, and so on. + * 2. For BR/EDR to use the new TX power for inquiry, call this function before starting an inquiry. + * If BR/EDR is already inquiring, restart the inquiry after calling this function. + * + * @param[in] min_power_level The minimum power level. The default value is `ESP_PWR_LVL_N0`. + * @param[in] max_power_level The maximum power level. The default value is `ESP_PWR_LVL_P3`. + * + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_ARG: Invalid argument + * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state + */ +esp_err_t esp_bredr_tx_power_set(esp_power_level_t min_power_level, esp_power_level_t max_power_level); + +/** + * @brief Get BR/EDR TX power + * + * The corresponding power levels will be stored into the arguments. + * + * @param[out] min_power_level Pointer to store the minimum power level + * @param[out] max_power_level The maximum power level + * + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_ARG: Invalid argument + */ +esp_err_t esp_bredr_tx_power_get(esp_power_level_t *min_power_level, esp_power_level_t *max_power_level); + +/** + * @brief Set BR/EDR default SCO data path + * + * @note This function should be called after the Controller is enabled, and before (e)SCO link is established. * - * @note This function is not recommended to use due to potential risk. + * @param[in] data_path SCO data path + * + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state + */ +esp_err_t esp_bredr_sco_datapath_set(esp_sco_data_path_t data_path); + +/** + * @brief Virtual HCI (VHCI) callback functions to notify the Host on the next operation + */ +typedef struct esp_vhci_host_callback { + void (*notify_host_send_available)(void); /*!< Callback to notify the Host that the Controller is ready to receive the HCI data */ + int (*notify_host_recv)(uint8_t *data, uint16_t len); /*!< Callback to notify the Host that the Controller has the HCI data to send */ +} esp_vhci_host_callback_t; + +/** + * @brief Check whether the Controller is ready to receive the HCI data from the Host + * + * If the return value is True, the Host can send the HCI data to the Controller. + * + * @note This function should be called before each `esp_vhci_host_send_packet()`. + * + * @return + * True if the Controller is ready to receive the HCI data; false otherwise + */ +bool esp_vhci_host_check_send_available(void); + +/** + * @brief Send the HCI data to the Controller + * + * @note + * 1. This function shall not be called within a critical section or when the scheduler is suspended. + * 2. This function should be called only if `esp_vhci_host_check_send_available()` returns True. + * + * @param[in] data Pointer to the HCI data + * @param[in] len The HCI data length + */ +void esp_vhci_host_send_packet(uint8_t *data, uint16_t len); + +/** + * @brief Register the VHCI callback functions defined in `esp_vhci_host_callback` structure + * + * @param[in] callback `esp_vhci_host_callback` type variable + * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure + */ +esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback); + +/** +* @brief Power on Bluetooth Wi-Fi power domain +* +* @note This function is not recommended to use due to potential risk. */ void esp_wifi_bt_power_domain_on(void); /** - * @brief Power off Bluetooth Wi-Fi power domain - * - * @note This function is not recommended to use due to potential risk. +* @brief Power off Bluetooth Wi-Fi power domain +* +* @note This function is not recommended to use due to potential risk. */ void esp_wifi_bt_power_domain_off(void); diff --git a/components/bt/include/esp32c2/include/esp_bt.h b/components/bt/include/esp32c2/include/esp_bt.h index c73d4cb924..a92bda8f08 100644 --- a/components/bt/include/esp32c2/include/esp_bt.h +++ b/components/bt/include/esp32c2/include/esp_bt.h @@ -16,6 +16,7 @@ #include "nimble/nimble_npl.h" #include "../../../../controller/esp32c2/esp_bt_cfg.h" #include "hal/efuse_hal.h" +#include "esp_private/esp_modem_clock.h" #ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART #include "driver/uart.h" @@ -166,7 +167,7 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po */ uint8_t esp_ble_get_chip_rev_version(void); -#define CONFIG_VERSION 0x20231124 +#define CONFIG_VERSION 0x20241121 #define CONFIG_MAGIC 0x5A5AA5A5 /** @@ -226,6 +227,7 @@ typedef struct { uint8_t version_num; /*!< Version number */ uint8_t ignore_wl_for_direct_adv; /*!< Ignore the white list for directed advertising */ uint8_t csa2_select; /*!< Select CSA#2 */ + uint8_t ble_aa_check; /*!< True if adds a verification step for the Access Address within the CONNECT_IND PDU; false otherwise. Configurable in menuconfig */ uint32_t config_magic; /*!< Configuration magic value */ } esp_bt_controller_config_t; @@ -272,6 +274,7 @@ typedef struct { .version_num = esp_ble_get_chip_rev_version(), \ .ignore_wl_for_direct_adv = 0, \ .csa2_select = DEFAULT_BT_LE_50_FEATURE_SUPPORT, \ + .ble_aa_check = DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS, \ .config_magic = CONFIG_MAGIC, \ } @@ -428,6 +431,12 @@ extern int esp_ble_hw_get_static_addr(esp_ble_addr_t *addr); void esp_ble_controller_log_dump_all(bool output); #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED +#if CONFIG_PM_ENABLE +modem_clock_lpclk_src_t esp_bt_get_lpclk_src(void); + +void esp_bt_set_lpclk_src(modem_clock_lpclk_src_t clk_src); +#endif // CONFIG_PM_ENABLE + #ifdef __cplusplus } #endif diff --git a/components/bt/include/esp32c3/include/esp_bt.h b/components/bt/include/esp32c3/include/esp_bt.h index ba2bc51057..d4234df510 100644 --- a/components/bt/include/esp32c3/include/esp_bt.h +++ b/components/bt/include/esp32c3/include/esp_bt.h @@ -18,50 +18,76 @@ extern "C" { #endif +/** +* @brief Internal use only +* +* @note Please do not modify this value +*/ #define ESP_BT_CTRL_CONFIG_MAGIC_VAL 0x5A5AA5A5 -#define ESP_BT_CTRL_CONFIG_VERSION 0x02404010 +/** +* @brief Internal use only +* +* @note Please do not modify this value +*/ +#define ESP_BT_CTRL_CONFIG_VERSION 0x02410230 + +/** +* @brief Internal use only +* +* @note Please do not modify this value +*/ #define ESP_BT_HCI_TL_MAGIC_VALUE 0xfadebead + +/** +* @brief Internal use only +* +* @note Please do not modify this value +*/ #define ESP_BT_HCI_TL_VERSION 0x00010000 /** - * @brief Bluetooth mode for controller enable/disable + * @brief Bluetooth Controller mode */ typedef enum { - ESP_BT_MODE_IDLE = 0x00, /*!< Bluetooth is not running */ - ESP_BT_MODE_BLE = 0x01, /*!< Run BLE mode */ - ESP_BT_MODE_CLASSIC_BT = 0x02, /*!< Run Classic BT mode */ - ESP_BT_MODE_BTDM = 0x03, /*!< Run dual mode */ + ESP_BT_MODE_IDLE = 0x00, /*!< Bluetooth is not operating. */ + ESP_BT_MODE_BLE = 0x01, /*!< Bluetooth is operating in BLE mode. */ + ESP_BT_MODE_CLASSIC_BT = 0x02, /*!< Unsupported mode */ + ESP_BT_MODE_BTDM = 0x03, /*!< Unsupported mode */ } esp_bt_mode_t; /** - * @brief Type of controller HCI transport layer + * @brief BLE Controller HCI transport layer type */ 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_VHCI = 1, /*!< Virtual HCI interface */ } esp_bt_ctrl_hci_tl_t; /** - * @brief type of BLE connection event length computation + * @brief BLE connection event length computation type */ typedef enum { ESP_BLE_CE_LEN_TYPE_ORIG = 0, /*!< original */ - ESP_BLE_CE_LEN_TYPE_CE = 1, /*!< use CE_LEN parameter from HCI commands */ + ESP_BLE_CE_LEN_TYPE_CE = 1, /*!< use `CE_LEN` parameter from HCI commands */ ESP_BLE_CE_LEN_TYPE_SD = 1, /*!< Espressif vendor defined */ } esp_ble_ce_len_t; /** - * @brief Bluetooth sleep mode + * @brief Bluetooth modem sleep mode */ typedef enum { - ESP_BT_SLEEP_MODE_NONE = 0, /*!< Bluetooth sleep mode disabled */ - ESP_BT_SLEEP_MODE_1 = 1, /*!< Bluetooth sleep mode 1 */ + ESP_BT_SLEEP_MODE_NONE = 0, /*!< Disable modem sleep */ + ESP_BT_SLEEP_MODE_1 = 1, /*!< Enable modem sleep */ } esp_bt_sleep_mode_t; /** - * @brief Bluetooth sleep clock + * @brief Bluetooth modem sleep clock source + * + * @note If the modem sleep mode is enabled, `ESP_BT_SLEEP_CLOCK_MAIN_XTAL` is the default option and + * `ESP_BT_SLEEP_CLOCK_NONE` will become an invalid option. */ + typedef enum { ESP_BT_SLEEP_CLOCK_NONE = 0, /*!< Sleep clock not configured */ ESP_BT_SLEEP_CLOCK_MAIN_XTAL = 1, /*!< SoC main crystal */ @@ -71,19 +97,19 @@ typedef enum { } esp_bt_sleep_clock_t; /** - * @brief antenna index used for bluetooth + * @brief Bluetooth antenna index */ enum { - ESP_BT_ANT_IDX_0 = 0, /*!< anntena NO 0 */ - ESP_BT_ANT_IDX_1 = 1, /*!< anntena NO 1 */ + ESP_BT_ANT_IDX_0 = 0, /*!< Antenna NO 0 */ + ESP_BT_ANT_IDX_1 = 1, /*!< Antenna NO 1 */ }; /** - * @brief Maximum Tx/Rx time limit on Coded-PHY connection + * @brief Enable / disable the maximum TX/RX time limit for Coded-PHY connections in coexistence with Wi-Fi scenarios */ enum { ESP_BT_COEX_PHY_CODED_TX_RX_TIME_LIMIT_FORCE_DISABLE = 0, /*!< Disable the limit */ - ESP_BT_COEX_PHY_CODED_TX_RX_TIME_LIMIT_FORCE_ENABLE, /*!< Always Enable the limit */ + ESP_BT_COEX_PHY_CODED_TX_RX_TIME_LIMIT_FORCE_ENABLE, /*!< Enable the limit */ }; #define ESP_BT_HCI_TL_STATUS_OK (0) /*!< HCI_TL Tx/Rx operation status OK */ @@ -217,6 +243,82 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status); #define BLE_HW_TARGET_CODE_CHIP_ECO0 (0x02010000) #endif +#ifdef CONFIG_BT_CTRL_BLE_LLCP_CONN_UPDATE +#define BT_CTRL_BLE_LLCP_CONN_UPDATE (1<<0) +#else +#define BT_CTRL_BLE_LLCP_CONN_UPDATE (0<<0) +#endif + +#ifdef CONFIG_BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE +#define BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE (1<<1) +#else +#define BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE (0<<1) +#endif + +#ifdef CONFIG_BT_CTRL_BLE_LLCP_PHY_UPDATE +#define BT_CTRL_BLE_LLCP_PHY_UPDATE (1<<2) +#else +#define BT_CTRL_BLE_LLCP_PHY_UPDATE (0<<2) +#endif + +#define BT_CTRL_BLE_LLCP_DISC_FLAG (BT_CTRL_BLE_LLCP_CONN_UPDATE | BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE | BT_CTRL_BLE_LLCP_PHY_UPDATE) +#if defined(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY) +#define BT_CTRL_RUN_IN_FLASH_ONLY CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY +#else +#define BT_CTRL_RUN_IN_FLASH_ONLY (0) +#endif + +#if (BT_CTRL_RUN_IN_FLASH_ONLY == 1) + +#if defined(CONFIG_BT_CTRL_DTM_ENABLE) +#define BT_CTRL_DTM_ENABLE CONFIG_BT_CTRL_DTM_ENABLE +#else +#define BT_CTRL_DTM_ENABLE (0) +#endif + +#if defined(CONFIG_BT_CTRL_BLE_MASTER) +#define BT_CTRL_BLE_MASTER CONFIG_BT_CTRL_BLE_MASTER +#else +#define BT_CTRL_BLE_MASTER (0) +#endif + +#if defined(CONFIG_BT_CTRL_BLE_TEST) +#define BT_CTRL_BLE_TEST CONFIG_BT_CTRL_BLE_TEST +#else +#define BT_CTRL_BLE_TEST (0) +#endif + +#if defined (CONFIG_BT_NIMBLE_SECURITY_ENABLE) || defined (CONFIG_BT_BLE_SMP_ENABLE) +#ifdef CONFIG_BT_NIMBLE_SECURITY_ENABLE +#define BLE_SECURITY_ENABLE (CONFIG_BT_NIMBLE_SECURITY_ENABLE) +#endif //CONFIG_BT_NIMBLE_SECURITY_ENABLE +#ifdef CONFIG_BT_BLE_SMP_ENABLE +#define BLE_SECURITY_ENABLE (CONFIG_BT_BLE_SMP_ENABLE) +#endif //CONFIG_BT_BLE_SMP_ENABLE +#else +#define BLE_SECURITY_ENABLE (0) +#endif // (CONFIG_BT_NIMBLE_SECURITY_ENABLE) || (CONFIG_BT_BLE_SMP_ENABLE) + +#if defined (CONFIG_BT_CTRL_BLE_SCAN) +#define BT_CTRL_BLE_SCAN CONFIG_BT_CTRL_BLE_SCAN +#else +#define BT_CTRL_BLE_SCAN (0) +#endif + +#else +#define BT_CTRL_BLE_MASTER (1) +#define BT_CTRL_DTM_ENABLE (1) +#define BT_CTRL_BLE_TEST (1) +#define BLE_SECURITY_ENABLE (1) +#define BT_CTRL_BLE_SCAN (1) +#endif // (BT_CTRL_RUN_IN_FLASH_ONLY == 1) + +#ifdef CONFIG_BT_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS +#define BLE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED CONFIG_BT_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS +#else +#define BLE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED 0 +#endif + #define BT_CONTROLLER_INIT_CONFIG_DEFAULT() { \ .magic = ESP_BT_CTRL_CONFIG_MAGIC_VAL, \ .version = ESP_BT_CTRL_CONFIG_VERSION, \ @@ -255,6 +357,14 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status); .ble_data_lenth_zero_aux = BT_BLE_ADV_DATA_LENGTH_ZERO_AUX, \ .ble_chan_ass_en = BT_CTRL_CHAN_ASS_EN, \ .ble_ping_en = BT_CTRL_LE_PING_EN, \ + .ble_llcp_disc_flag = BT_CTRL_BLE_LLCP_DISC_FLAG, \ + .run_in_flash = BT_CTRL_RUN_IN_FLASH_ONLY, \ + .dtm_en = BT_CTRL_DTM_ENABLE, \ + .enc_en = BLE_SECURITY_ENABLE, \ + .qa_test = BT_CTRL_BLE_TEST, \ + .master_en = BT_CTRL_BLE_MASTER, \ + .scan_en = BT_CTRL_BLE_SCAN, \ + .ble_aa_check = BLE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED, \ } #else @@ -263,7 +373,8 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status); /** * @brief Controller HCI transport layer function structure - * This structure shall be registered when HCI transport layer is UART + * + * @note This structure must be registered when HCI transport layer is UART */ typedef struct { uint32_t _magic; /*!< Magic number */ @@ -279,382 +390,529 @@ typedef struct { } esp_bt_hci_tl_t; /** - * @brief Controller config options, depend on config mask. - * Config mask indicate which functions enabled, this means - * some options or parameters of some functions enabled by config mask. + * @brief Bluetooth Controller config options + * @note + * 1. For parameters configurable through menuconfig, it is recommended to adjust them via the menuconfig interface. Please refer to menuconfig for details on the range and default values. + * 2. It is not recommended to modify the values for parameters which are not configurable through menuconfig. */ typedef struct { - /* - * Following parameters can not be configured runtime when call esp_bt_controller_init() - * They will be overwritten by constant values from menuconfig options or from macros. - * So, do not modify the value when esp_bt_controller_init() - */ uint32_t magic; /*!< Magic number */ uint32_t version; /*!< version number of the defined structure */ - /* - * Following parameters can be configured runtime, when call esp_bt_controller_init() - */ - uint16_t controller_task_stack_size; /*!< Bluetooth controller task stack size */ - uint8_t controller_task_prio; /*!< Bluetooth controller task priority */ - uint8_t controller_task_run_cpu; /*!< CPU num that Bluetooth controller task runs on */ - uint8_t bluetooth_mode; /*!< Controller mode: BR/EDR, BLE or Dual Mode */ - uint8_t ble_max_act; /*!< BLE maximum number of air activities */ - uint8_t sleep_mode; /*!< controller sleep mode */ - uint8_t sleep_clock; /*!< controller sleep clock */ - uint8_t ble_st_acl_tx_buf_nb; /*!< controller static ACL TX BUFFER number */ - uint8_t ble_hw_cca_check; /*!< controller hardware triggered CCA check */ - uint16_t ble_adv_dup_filt_max; /*!< maximum number of duplicate scan filter */ - bool coex_param_en; /*!< deprecated */ - uint8_t ce_len_type; /*!< connection event length computation method */ - bool coex_use_hooks; /*!< deprecated */ - uint8_t hci_tl_type; /*!< HCI transport layer, UART, VHCI, etc */ - esp_bt_hci_tl_t *hci_tl_funcs; /*!< hci transport functions used, must be set when hci_tl_type is UART */ - uint8_t txant_dft; /*!< default Tx antenna */ - uint8_t rxant_dft; /*!< default Rx antenna */ - uint8_t txpwr_dft; /*!< default Tx power */ + uint16_t controller_task_stack_size; /*!< Bluetooth Controller task stack size in bytes */ + uint8_t controller_task_prio; /*!< Bluetooth Controller task priority */ + uint8_t controller_task_run_cpu; /*!< CPU number that Bluetooth Controller task runs on. Configurable in menuconfig. + - 0 - CPU 0 (default) + - 1 - CPU 1 */ + uint8_t bluetooth_mode; /*!< BLE mode */ + uint8_t ble_max_act; /*!< The maximum number of BLE instance. Configurable in menuconfig. + - Range: 1 - 10 + - Default: 6 */ + uint8_t sleep_mode; /*!< Modem sleep mode. Configurable in menuconfig. + - 0 - Disable (default) + - 1 - Enable */ + uint8_t sleep_clock; /*!< Modem sleep clock source. Configurable in menuconfig. */ + uint8_t ble_st_acl_tx_buf_nb; /*!< Static ACL TX buffer numbers. Configurable in menuconfig. + - Range: 0 - 12 + - Default: 0 */ + uint8_t ble_hw_cca_check; /*!< Deprecated */ + uint16_t ble_adv_dup_filt_max; /*!< The maximum number of extended duplicate scan filter. Configurable in menuconfig. + - Range: 1 - 500 + - Default: 30 */ + bool coex_param_en; /*!< Deprecated */ + uint8_t ce_len_type; /*!< Connection event length determination method. Configurable in menuconfig. + - 0 - Original (default) + - 1 - use `CE_LEN` parameter from HCI commands + - 2 - Espressif vendor defined method */ + bool coex_use_hooks; /*!< Deprecated */ + uint8_t hci_tl_type; /*!< HCI transport layer type. Configurable in menuconfig. + - 0 - URAT + - 1 - Virtual HCI (default) */ + esp_bt_hci_tl_t *hci_tl_funcs; /*!< HCI transport functions used. It must be set when `hci_tl_type` is UART. */ + uint8_t txant_dft; /*!< Default TX antenna. Configurable in menuconfig. + - 0 - Antenna 0 (default) + - 1 - Antenna 1 */ + uint8_t rxant_dft; /*!< Default RX antenna. Configurable in menuconfig. + - 0 - Antenna 0 (default) + - 1 - Antenna 1 */ + uint8_t txpwr_dft; /*!< Default TX power. Please refer to `esp_power_level_t` for supported power level. Configurable in menuconfig. + - Default : `ESP_PWR_LVL_P9` +9 dBm. */ uint32_t cfg_mask; /*!< Configuration mask to set specific options */ - uint8_t scan_duplicate_mode; /*!< scan duplicate mode */ - uint8_t scan_duplicate_type; /*!< scan duplicate type */ - uint16_t normal_adv_size; /*!< Normal adv size for scan duplicate */ - uint16_t mesh_adv_size; /*!< Mesh adv size for scan duplicate */ - uint8_t coex_phy_coded_tx_rx_time_limit; /*!< limit on max tx/rx time in case of connection using CODED-PHY with Wi-Fi coexistence */ - uint32_t hw_target_code; /*!< hardware target */ - uint8_t slave_ce_len_min; /*!< slave minimum ce length*/ - uint8_t hw_recorrect_en; /*!< Hardware re-correction enabled */ - uint8_t cca_thresh; /*!< cca threshold*/ - uint16_t scan_backoff_upperlimitmax; /*!< scan backoff upperlimitmax value */ - uint16_t dup_list_refresh_period; /*!< duplicate scan list refresh time */ - bool ble_50_feat_supp; /*!< BLE 5.0 feature support */ - uint8_t ble_cca_mode; /*!< BLE CCA mode */ - uint8_t ble_data_lenth_zero_aux; /*!< Config ext adv aux option */ - uint8_t ble_chan_ass_en; /*!< BLE channel assessment enable */ - uint8_t ble_ping_en; /*!< BLE ping procedure enable */ + uint8_t scan_duplicate_mode; /*!< Scan duplicate filtering mode. Configurable in menuconfig. + - 0 - Normal scan duplicate filtering mode (default) + - 1 - Special scan duplicate filtering mode for BLE Mesh */ + uint8_t scan_duplicate_type; /*!< Scan duplicate filtering type. If `scan_duplicate_mode` is set to 1, this parameter will be ignored. Configurable in menuconfig. + - 0 - Filter scan duplicates by device address only (default) + - 1 - Filter scan duplicates by advertising data only, even if they originate from different devices. + - 2 - Filter scan duplicated by device address and advertising data. */ + uint16_t normal_adv_size; /*!< Maximum number of devices in scan duplicate filtering list. Configurable in menuconfig. + - Range: 10 - 1000 + - Default: 100 */ + uint16_t mesh_adv_size; /*!< Maximum number of Mesh advertising packets in scan duplicate filtering list. Configurable in menuconfig. + - Range: 10 - 1000 + - Default: 100 */ + uint8_t coex_phy_coded_tx_rx_time_limit; /*!< Enable / disable the maximum TX/RX time limit for Coded-PHY connections in coexistence with Wi-Fi scenarios. Configurable in menuconfig. + - 0 - Disable (default) + - 1 - Enable */ + uint32_t hw_target_code; /*!< Hardware target. Internal use only. Please do not modify this value. */ + uint8_t slave_ce_len_min; /*!< Slave minimum connection event length: 5 slots. Please do not modify this value. */ + uint8_t hw_recorrect_en; /*!< Enable / disable uncoded phy / coded phy hardware re-correction. Configurable in menuconfig. */ + uint8_t cca_thresh; /*!< Absolute value of hardware-triggered CCA threshold. The CCA threshold is always negative. + If the channel assessment result exceeds the CCA threshold (e.g. -75 dBm), indicating the channel is busy, + the hardware will not transmit packets on that channel. Configurable in menuconfig. + - Range: 20 dBm - 100 dBm + - Default: 75 dBm */ + uint16_t scan_backoff_upperlimitmax; /*!< Enable / disable active scan backoff. Configurable in menuconfig. + - 0 - Disable (default) + - 1 - Enable */ + uint16_t dup_list_refresh_period; /*!< Scan duplicate filtering list refresh period in seconds. Configurable in menuconfig + - Range: 0 - 100 seconds + - Default: 0 second */ + bool ble_50_feat_supp; /*!< True if BLE 5.0 features are enabled; false otherwise. This option depends on whether the Host enable the 5.0 features. */ + uint8_t ble_cca_mode; /*!< BLE CCA mode. Configurable in menuconfig + - 0 - Disable (default) + - 1 - Hardware-triggered CCA + - 2 - Software-based CCA */ + uint8_t ble_data_lenth_zero_aux; /*!< Enable / disable auxiliary packets when the extended ADV data length is zero. Configurable in menuconfig. + - 0 - Disable (default) + - 1 - Enable */ + uint8_t ble_chan_ass_en; /*!< Enable / disable BLE channel assessment. Configurable in menuconfig. + - 0 - Disable + - 1 - Enable (default) */ + uint8_t ble_ping_en; /*!< Enable / disable BLE ping procedure. Configurable in menuconfig. + - 0 - Disable + - 1 - Enable (default) */ + uint8_t ble_llcp_disc_flag; /*!< Flag indicating whether the Controller disconnects after Instant Passed (0x28) error occurs. Configurable in menuconfig. + - The Controller does not disconnect after Instant Passed (0x28) by default. */ + bool run_in_flash; /*!< True if the Controller code is in flash (flash model); false otherwise (default). Configurable in menuconfig. */ + bool dtm_en; /*!< In the flash mode, True if the DTM feature is enabled; false otherwise (default). Configurable in menuconfig. */ + bool enc_en; /*!< In the flash mode, True if the encryption feature is enabled (default); false otherwise. Configurable in menuconfig. */ + bool qa_test; /*!< In the flash mode, True if the QA test feature is enabled; false otherwise (default). Configurable in menuconfig.*/ + bool master_en; /*!< In the flash mode, True if the master feature is enabled (default); false otherwise. Configurable in menuconfig.*/ + bool scan_en; /*!< In the flash mode, True if the scan feature is enabled (default); false otherwise. Configurable in menuconfig.*/ + bool ble_aa_check; /*!< True if adds a verification step for the Access Address within the CONNECT_IND PDU; false otherwise. Configurable in menuconfig */ } esp_bt_controller_config_t; /** - * @brief Bluetooth controller enable/disable/initialised/de-initialised status + * @brief Bluetooth Controller status */ typedef enum { - ESP_BT_CONTROLLER_STATUS_IDLE = 0, - ESP_BT_CONTROLLER_STATUS_INITED, - ESP_BT_CONTROLLER_STATUS_ENABLED, - ESP_BT_CONTROLLER_STATUS_NUM, + ESP_BT_CONTROLLER_STATUS_IDLE = 0, /*!< The Controller is not initialized or has been de-initialized. */ + ESP_BT_CONTROLLER_STATUS_INITED, /*!< The Controller has been initialized, but not enabled or has been disabled. */ + ESP_BT_CONTROLLER_STATUS_ENABLED, /*!< The Controller has been initialized and enabled. */ + ESP_BT_CONTROLLER_STATUS_NUM, /*!< Number of Controller statuses */ } esp_bt_controller_status_t; /** - * @brief BLE tx power type - * ESP_BLE_PWR_TYPE_CONN_HDL0-8: for each connection, and only be set after connection completed. - * when disconnect, the correspond TX power is not effected. - * ESP_BLE_PWR_TYPE_ADV : for advertising/scan response. - * ESP_BLE_PWR_TYPE_SCAN : for scan. - * ESP_BLE_PWR_TYPE_DEFAULT : if each connection's TX power is not set, it will use this default value. - * if neither in scan mode nor in adv mode, it will use this default value. - * If none of power type is set, system will use ESP_PWR_LVL_P3 as default for ADV/SCAN/CONN0-9. + * @brief BLE TX power type + * + * This TX power type is used for the API `esp_ble_tx_power_set()` and `esp_ble_tx_power_get()`. + * + * @note + * 1. The connection TX power can only be set after the connection is established. + * After disconnecting, the corresponding TX power will not be affected. + * 2. `ESP_BLE_PWR_TYPE_DEFAULT` can be used to set the TX power for power types that have not been set before. + * It will not affect the TX power values which have been set for the ADV/SCAN/CONN0-8 power types. + * 3. If none of power type is set, the system will use `ESP_PWR_LVL_P3` as default for all power types. */ typedef enum { - ESP_BLE_PWR_TYPE_CONN_HDL0 = 0, /*!< For connection handle 0 */ - ESP_BLE_PWR_TYPE_CONN_HDL1 = 1, /*!< For connection handle 1 */ - ESP_BLE_PWR_TYPE_CONN_HDL2 = 2, /*!< For connection handle 2 */ - ESP_BLE_PWR_TYPE_CONN_HDL3 = 3, /*!< For connection handle 3 */ - ESP_BLE_PWR_TYPE_CONN_HDL4 = 4, /*!< For connection handle 4 */ - ESP_BLE_PWR_TYPE_CONN_HDL5 = 5, /*!< For connection handle 5 */ - ESP_BLE_PWR_TYPE_CONN_HDL6 = 6, /*!< For connection handle 6 */ - ESP_BLE_PWR_TYPE_CONN_HDL7 = 7, /*!< For connection handle 7 */ - ESP_BLE_PWR_TYPE_CONN_HDL8 = 8, /*!< For connection handle 8 */ - ESP_BLE_PWR_TYPE_ADV = 9, /*!< For advertising */ - ESP_BLE_PWR_TYPE_SCAN = 10, /*!< For scan */ - ESP_BLE_PWR_TYPE_DEFAULT = 11, /*!< For default, if not set other, it will use default value */ - ESP_BLE_PWR_TYPE_NUM = 12, /*!< TYPE numbers */ + ESP_BLE_PWR_TYPE_CONN_HDL0 = 0, /*!< TX power for Connection state handle 0 */ + ESP_BLE_PWR_TYPE_CONN_HDL1 = 1, /*!< TX power for Connection state handle 1 */ + ESP_BLE_PWR_TYPE_CONN_HDL2 = 2, /*!< TX power for Connection state handle 2 */ + ESP_BLE_PWR_TYPE_CONN_HDL3 = 3, /*!< TX power for Connection state handle 3 */ + ESP_BLE_PWR_TYPE_CONN_HDL4 = 4, /*!< TX power for Connection state handle 4 */ + ESP_BLE_PWR_TYPE_CONN_HDL5 = 5, /*!< TX power for Connection state handle 5 */ + ESP_BLE_PWR_TYPE_CONN_HDL6 = 6, /*!< TX power for Connection state handle 6 */ + ESP_BLE_PWR_TYPE_CONN_HDL7 = 7, /*!< TX power for Connection state handle 7 */ + ESP_BLE_PWR_TYPE_CONN_HDL8 = 8, /*!< TX power for Connection state handle 8 */ + ESP_BLE_PWR_TYPE_ADV = 9, /*!< TX power for Advertising state*/ + ESP_BLE_PWR_TYPE_SCAN = 10, /*!< TX power for Scanning state */ + ESP_BLE_PWR_TYPE_DEFAULT = 11, /*!< TX power for states that have not been set before */ + ESP_BLE_PWR_TYPE_NUM = 12, /*!< Reserved */ } esp_ble_power_type_t; /** - * @brief Bluetooth TX power level(index), it's just a index corresponding to power(dbm). - */ -typedef enum { - ESP_PWR_LVL_N24 = 0, /*!< Corresponding to -24dbm */ - ESP_PWR_LVL_N21 = 1, /*!< Corresponding to -21dbm */ - ESP_PWR_LVL_N18 = 2, /*!< Corresponding to -18dbm */ - ESP_PWR_LVL_N15 = 3, /*!< Corresponding to -15dbm */ - ESP_PWR_LVL_N12 = 4, /*!< Corresponding to -12dbm */ - ESP_PWR_LVL_N9 = 5, /*!< Corresponding to -9dbm */ - ESP_PWR_LVL_N6 = 6, /*!< Corresponding to -6dbm */ - ESP_PWR_LVL_N3 = 7, /*!< Corresponding to -3dbm */ - ESP_PWR_LVL_N0 = 8, /*!< Corresponding to 0dbm */ - ESP_PWR_LVL_P3 = 9, /*!< Corresponding to +3dbm */ - ESP_PWR_LVL_P6 = 10, /*!< Corresponding to +6dbm */ - ESP_PWR_LVL_P9 = 11, /*!< Corresponding to +9dbm */ - ESP_PWR_LVL_P12 = 12, /*!< Corresponding to +12dbm */ - ESP_PWR_LVL_P15 = 13, /*!< Corresponding to +15dbm */ - ESP_PWR_LVL_P18 = 14, /*!< Corresponding to +18dbm */ - ESP_PWR_LVL_P21 = 15, /*!< Corresponding to +21dbm */ - ESP_PWR_LVL_INVALID = 0xFF, /*!< Indicates an invalid value */ -} esp_power_level_t; - -/** - * @brief The enhanced type of which tx power, could set Advertising/Connection/Default and etc. + * @brief The enhanced type of which TX power, could set Advertising/Connection/Default and etc. + * + * This TX power type is used for the API `esp_ble_tx_power_set_enhanced()` and `esp_ble_tx_power_get_enhanced()`. + * + * @note + * 1. The connection TX power can only be set after the connection is established. + * After disconnecting, the corresponding TX power will not be affected. + * 2. `ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT` can be used to set the TX power for power types that have not been set before. + * It will not affect the TX power values which have been set for the ADV/SCAN/INIT/CONN power types. + * 3. If none of power type is set, the system will use `ESP_PWR_LVL_P3` as default for all power types. */ typedef enum { - ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT = 0, - ESP_BLE_ENHANCED_PWR_TYPE_ADV, - ESP_BLE_ENHANCED_PWR_TYPE_SCAN, - ESP_BLE_ENHANCED_PWR_TYPE_INIT, - ESP_BLE_ENHANCED_PWR_TYPE_CONN, - ESP_BLE_ENHANCED_PWR_TYPE_MAX, + ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT = 0, /*!< TX power for states that have not been set before */ + ESP_BLE_ENHANCED_PWR_TYPE_ADV, /*!< TX power for Advertising state */ + ESP_BLE_ENHANCED_PWR_TYPE_SCAN, /*!< TX power for Scanning state */ + ESP_BLE_ENHANCED_PWR_TYPE_INIT, /*!< TX power for Initiating state */ + ESP_BLE_ENHANCED_PWR_TYPE_CONN, /*!< TX power for Connection state */ + ESP_BLE_ENHANCED_PWR_TYPE_MAX, /*!< Reserved */ } esp_ble_enhanced_power_type_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 - */ -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 + * @brief Bluetooth TX power level (index). Each index corresponds to a specific power value in dBm. */ -esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle); +typedef enum { + ESP_PWR_LVL_N24 = 0, /*!< Corresponding to -24 dBm */ + ESP_PWR_LVL_N21 = 1, /*!< Corresponding to -21 dBm */ + ESP_PWR_LVL_N18 = 2, /*!< Corresponding to -18 dBm */ + ESP_PWR_LVL_N15 = 3, /*!< Corresponding to -15 dBm */ + ESP_PWR_LVL_N12 = 4, /*!< Corresponding to -12 dBm */ + ESP_PWR_LVL_N9 = 5, /*!< Corresponding to -9 dBm */ + ESP_PWR_LVL_N6 = 6, /*!< Corresponding to -6 dBm */ + ESP_PWR_LVL_N3 = 7, /*!< Corresponding to -3 dBm */ + ESP_PWR_LVL_N0 = 8, /*!< Corresponding to 0 dBm */ + ESP_PWR_LVL_P3 = 9, /*!< Corresponding to +3 dBm */ + ESP_PWR_LVL_P6 = 10, /*!< Corresponding to +6 dBm */ + ESP_PWR_LVL_P9 = 11, /*!< Corresponding to +9 dBm */ + ESP_PWR_LVL_P12 = 12, /*!< Corresponding to +12 dBm */ + ESP_PWR_LVL_P15 = 13, /*!< Corresponding to +15 dBm */ + ESP_PWR_LVL_P18 = 14, /*!< Corresponding to +18 dBm */ + ESP_PWR_LVL_P20 = 15, /*!< Corresponding to +20 dBm */ + ESP_PWR_LVL_P21 = 15, /*!< Deprecated */ + ESP_PWR_LVL_INVALID = 0xFF, /*!< Indicates an invalid value */ +} esp_power_level_t; /** - * @brief Initialize BT controller to allocate task and other resource. - * This function should be called only once, before any other BT functions are called. - * @param cfg: Initial configuration of BT controller. Different from previous version, there's a mode and some - * connection configuration in "cfg" to configure controller work mode and allocate the resource which is needed. - * @return ESP_OK - success, other - failed + * @brief Initialize the Bluetooth Controller to allocate tasks and other resources + * + * @note This function should be called only once, before any other Bluetooth functions. + * + * @param[in] cfg Initial Bluetooth Controller configuration + * + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state + * - ESP_ERR_NOT_SUPPORTED: Invalid Bluetooth Controller mode + * - ESP_ERR_INVALID_ARG: Invalid arguments + * - ESP_ERR_NO_MEM: Out of memory + * - ESP_FAIL: Failure due to other reasons + * */ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg); /** - * @brief De-initialize BT controller to free resource and delete task. - * You should stop advertising and scanning, as well as - * disconnect all existing connections before de-initializing BT controller. + * @brief De-initialize Bluetooth Controller to free resources and delete tasks + * + * @note + * 1. You should make sure that the Controller is in idle state before de-initializing it. + * 2. This function should be called only once, after any other Bluetooth functions. * - * This function should be called only once, after any other BT functions are called. - * This function is not whole completed, esp_bt_controller_init cannot called after this function. - * @return ESP_OK - success, other - failed + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_ARG: Invalid arguments + * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state + * - ESP_ERR_NO_MEM: Out of memory */ esp_err_t esp_bt_controller_deinit(void); /** - * @brief Enable BT controller. - * Due to a known issue, you cannot call esp_bt_controller_enable() a second time - * to change the controller mode dynamically. To change controller mode, call - * esp_bt_controller_disable() and then call esp_bt_controller_enable() with the new mode. - * @param mode : the mode(BLE/BT/BTDM) to enable. For compatible of API, retain this argument. This mode must be - * equal as the mode in "cfg" of esp_bt_controller_init(). - * @return ESP_OK - success, other - failed + * @brief Enable Bluetooth Controller + * + * @note + * 1. Bluetooth Controller cannot be enabled in `ESP_BT_CONTROLLER_STATUS_IDLE` status. It has to be initialized first. + * 2. Due to a known issue, you cannot call `esp_bt_controller_enable()` for the second time + * to change the Controller mode dynamically. To change the Controller mode, call + * `esp_bt_controller_disable()` and then call `esp_bt_controller_enable()` with the new mode. + * + * @param[in] mode The Bluetooth Controller mode to enable + * + * For API compatibility, retain this argument. This mode must match the mode specified in the `cfg` of `esp_bt_controller_init()`. + * + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state + * - ESP_ERR_INVALID_ARG: Invalid arguments */ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode); /** - * @brief Disable BT controller - * @return ESP_OK - success, other - failed + * @brief Disable Bluetooth Controller + * + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state */ 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); - -uint16_t esp_bt_get_tx_buf_num(void); - -/** @brief esp_vhci_host_callback - * used for vhci call host function to notify what host need to do - */ -typedef struct esp_vhci_host_callback { - void (*notify_host_send_available)(void); /*!< callback used to notify that the host can send packet to controller */ - int (*notify_host_recv)(uint8_t *data, uint16_t len); /*!< callback used to notify that the controller has a packet to send to the host*/ -} esp_vhci_host_callback_t; - -/** @brief esp_vhci_host_check_send_available - * used for check actively if the host can send packet to controller or not. - * @return true for ready to send, false means cannot send packet - */ -bool esp_vhci_host_check_send_available(void); - -/** @brief esp_vhci_host_send_packet - * host send packet to controller + * @brief Get Bluetooth Controller status * - * Should not call this function from within a critical section - * or when the scheduler is suspended. - * - * @param data the packet point - * @param len the packet length - */ -void esp_vhci_host_send_packet(uint8_t *data, uint16_t len); - -/** @brief esp_vhci_host_register_callback - * register the vhci reference callback - * struct defined by vhci_host_callback structure. - * @param callback esp_vhci_host_callback type variable - * @return ESP_OK - success, ESP_FAIL - failed + * @return + * - ESP_BT_CONTROLLER_STATUS_IDLE: The Controller is not initialized or has been de-initialized. + * - ESP_BT_CONTROLLER_STATUS_INITED: The Controller has been initialized, but not enabled or has been disabled. + * - ESP_BT_CONTROLLER_STATUS_ENABLED: The Controller has been initialized and enabled. */ -esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback); +esp_bt_controller_status_t esp_bt_controller_get_status(void); -/** @brief esp_bt_controller_mem_release - * release the controller memory as per the mode - * - * This function releases the BSS, data and other sections of the controller to heap. The total size is about 70k bytes. +/** + * @brief Release the Controller memory as per the mode * - * esp_bt_controller_mem_release(mode) should be called only before esp_bt_controller_init() - * or after esp_bt_controller_deinit(). + * This function releases the BSS, data and other sections of the Controller to heap. The total size is about 70 KB. * - * Note that once BT controller memory is released, the process cannot be reversed. It means you cannot use the bluetooth - * mode which you have released by this function. + * @note + * 1. This function is optional and should be called only if you want to free up memory for other components. + * 2. This function should only be called when the Controller is in `ESP_BT_CONTROLLER_STATUS_IDLE` status. + * 3. Once Bluetooth Controller memory is released, the process cannot be reversed. This means you cannot use the Bluetooth Controller mode that you have released using this function. + * 4. If your firmware will upgrade the Bluetooth Controller mode later (such as from disabled to enabled), then do not call this function. * - * If your firmware will later upgrade the Bluetooth controller mode (BLE -> BT Classic or disabled -> enabled) - * then do not call this function. + * If you never intend to use Bluetooth in a current boot-up cycle, calling `esp_bt_controller_mem_release(ESP_BT_MODE_BLE)` could release the BSS and data consumed by BLE Controller to heap. * - * If the app calls esp_bt_controller_enable(ESP_BT_MODE_BLE) to use BLE only then it is safe to call - * esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT) at initialization time to free unused BT Classic memory. * - * If the mode is ESP_BT_MODE_BTDM, then it may be useful to call API esp_bt_mem_release(ESP_BT_MODE_BTDM) instead, - * which internally calls esp_bt_controller_mem_release(ESP_BT_MODE_BTDM) and additionally releases the BSS and data - * consumed by the BT/BLE host stack to heap. For more details about usage please refer to the documentation of - * esp_bt_mem_release() function + * @param[in] mode The Bluetooth Controller mode * - * @param mode : the mode want to release memory - * @return ESP_OK - success, other - failed + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state + * - ESP_ERR_NOT_FOUND: Requested resource not found */ esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode); -/** @brief esp_bt_mem_release - * release controller memory and BSS and data section of the BT/BLE host stack as per the mode - * - * This function first releases controller memory by internally calling esp_bt_controller_mem_release(). - * Additionally, if the mode is set to ESP_BT_MODE_BTDM, it also releases the BSS and data consumed by the BT/BLE host stack to heap +/** @brief Release the Controller memory, BSS and data section of the BLE Host stack as per the mode * - * Note that once BT memory is released, the process cannot be reversed. It means you cannot use the bluetooth - * mode which you have released by this function. + * @note + * 1. This function is optional and should be called only if you want to free up memory for other components. + * 2. This function should only be called when the Controller is in `ESP_BT_CONTROLLER_STATUS_IDLE` status. + * 3. Once Bluetooth Controller memory is released, the process cannot be reversed. This means you cannot use the Bluetooth Controller mode that you have released using this function. + * 4. If your firmware will upgrade the Bluetooth Controller mode later (such as from disabled to enabled), then do not call this function. * - * If your firmware will later upgrade the Bluetooth controller mode (BLE -> BT Classic or disabled -> enabled) - * then do not call this function. + * This function first releases Controller memory by internally calling `esp_bt_controller_mem_release()`, then releases Host memory. * - * If you never intend to use bluetooth in a current boot-up cycle, you can call esp_bt_mem_release(ESP_BT_MODE_BTDM) - * before esp_bt_controller_init or after esp_bt_controller_deinit. + * If you never intend to use Bluetooth in a current boot-up cycle, calling `esp_bt_mem_release(ESP_BT_MODE_BLE)` could release the BSS and data consumed by BLE stack to heap. * - * For example, if a user only uses bluetooth for setting the WiFi configuration, and does not use bluetooth in the rest of the product operation". - * In such cases, after receiving the WiFi configuration, you can disable/deinit bluetooth and release its memory. + * For example, if you only use Bluetooth for setting the Wi-Fi configuration, and do not use Bluetooth in the rest of the product operation, + * after receiving the Wi-Fi configuration, you can disable/de-init Bluetooth and release its memory. * Below is the sequence of APIs to be called for such scenarios: * - * esp_bluedroid_disable(); - * esp_bluedroid_deinit(); - * esp_bt_controller_disable(); - * esp_bt_controller_deinit(); - * esp_bt_mem_release(ESP_BT_MODE_BTDM); + * esp_bluedroid_disable(); + * esp_bluedroid_deinit(); + * esp_bt_controller_disable(); + * esp_bt_controller_deinit(); + * esp_bt_mem_release(ESP_BT_MODE_BLE); + * + * @param[in] mode The Bluetooth Controller mode * - * @param mode : the mode whose memory is to be released - * @return ESP_OK - success, other - failed + * @return + * - ESP_OK: Success + * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state + * - ESP_ERR_NOT_FOUND: Requested resource not found */ esp_err_t esp_bt_mem_release(esp_bt_mode_t mode); /** - * @brief enable bluetooth to enter modem sleep + * @brief Enable Bluetooth modem sleep * - * Note that this function shall not be invoked before esp_bt_controller_enable() + * There are currently two options for Bluetooth modem sleep: ORIG mode and EVED mode. The latter is intended for BLE only. + * The modem sleep mode could be configured in menuconfig. * - * There are currently two options for bluetooth modem sleep, one is ORIG mode, and another is EVED Mode. EVED Mode is intended for BLE only. + * In ORIG mode, if there is no event to process, the Bluetooth Controller will periodically switch off some components and pause operation, then wake up according to the scheduled interval and resume work. + * It can also wakeup earlier upon external request using function `esp_bt_controller_wakeup_request()`. * - * For ORIG mode: - * Bluetooth modem sleep is enabled in controller start up by default if CONFIG_BTDM_CONTROLLER_MODEM_SLEEP is set and "ORIG mode" is selected. In ORIG modem sleep mode, bluetooth controller will switch off some components and pause to work every now and then, if there is no event to process; and wakeup according to the scheduled interval and resume the work. It can also wakeup earlier upon external request using function "esp_bt_controller_wakeup_request". + * @note This function shall not be invoked before `esp_bt_controller_enable()`. * * @return - * - ESP_OK : success - * - other : failed + * - ESP_OK: Success + * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state + * - ESP_ERR_NOT_SUPPORTED: Operation or feature not supported */ esp_err_t esp_bt_sleep_enable(void); - /** - * @brief disable bluetooth modem sleep - * - * Note that this function shall not be invoked before esp_bt_controller_enable() + * @brief Disable Bluetooth modem sleep * - * If esp_bt_sleep_disable() is called, bluetooth controller will not be allowed to enter modem sleep; - * - * If ORIG modem sleep mode is in use, if this function is called, bluetooth controller may not immediately wake up if it is dormant then. - * In this case, esp_bt_controller_wakeup_request() can be used to shorten the time for wakeup. + * @note + * 1. Bluetooth Controller will not be allowed to enter modem sleep after calling this function. + * 2. In ORIG modem sleep mode, calling this function may not immediately wake up the Controller if it is currently dormant. + * In this case, `esp_bt_controller_wakeup_request()` can be used to shorten the wake-up time. + * 3. This function shall not be invoked before `esp_bt_controller_enable()`. * * @return - * - ESP_OK : success - * - other : failed + * - ESP_OK: Success + * - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state + * - ESP_ERR_NOT_SUPPORTED: Operation or feature not supported */ esp_err_t esp_bt_sleep_disable(void); /** - * @brief to check whether bluetooth controller is sleeping at the instant, if modem sleep is enabled + * @brief Get the Bluetooth sleep clock source. * - * Note that this function shall not be invoked before esp_bt_controller_enable() - * This function is supposed to be used ORIG mode of modem sleep + * @note This function shall not be invoked before `esp_bt_controller_init()`. * - * @return true if in modem sleep state, false otherwise + * @return clock source used in Bluetooth low power mode */ -bool esp_bt_controller_is_sleeping(void); +esp_bt_sleep_clock_t esp_bt_get_lpclk_src(void); /** - * @brief request controller to wakeup from sleeping state during sleep mode + * @brief Check if the Bluetooth Controller is currently in sleep mode when modem sleep is enabled. * - * Note that this function shall not be invoked before esp_bt_controller_enable() - * Note that this function is supposed to be used ORIG mode of modem sleep - * Note that after this request, bluetooth controller may again enter sleep as long as the modem sleep is enabled + * @note + * 1. This function shall not be invoked before `esp_bt_controller_enable()`. + * 2. This function is supposed to be used ORIG mode of modem sleep. + * + * @return + * - True if the Controller is in modem sleep state; false otherwise. + */ +bool esp_bt_controller_is_sleeping(void); + +/** + * @brief Request the Controller to wakeup from sleeping state during sleep mode * * Profiling shows that it takes several milliseconds to wakeup from modem sleep after this request. + * * Generally it takes longer if 32kHz XTAL is used than the main XTAL, due to the lower frequency of the former as the bluetooth low power clock source. + * + * @note + * 1. This function shall not be invoked before `esp_bt_controller_enable()`. + * 2. This function is supposed to be used ORIG mode of modem sleep. + * 3. After this request, the Bluetooth Controller can re-enter sleep as long as modem sleep remains enabled. */ void esp_bt_controller_wakeup_request(void); /** - * @brief notify bluetooth controller task to process the event upon Tx or Rx done + * @brief Set BLE TX power for the specified power type + * + * It is recommended to use `esp_ble_tx_power_set_enhanced` to set TX power for individual advertising and connection handle. + * + * @note Connection TX power should only be set after the connection is established. + * + * @param[in] power_type The type of TX power. It could be Advertising, Connection, or Default. + * @param[in] power_level Power level (index) corresponding to the absolute value (dBm) + * + * @return + * - ESP_OK: Success + * - ESP_ERR_NOT_SUPPORTED: Invalid TX power type + * - ESP_FAIL: Failure due to other reasons + */ +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 of the specified power type + * + * It is recommended to use `esp_ble_tx_power_get_enhanced` to get TX power of individual advertising and connection handle. * - * Note that this function shall not be invoked before esp_bt_controller_enable() - * This function can be called in both ISR and non-ISR context + * @note + * 1. Connection TX power should only be retrieved after the connection is established. + * 2. If an invalid power type is provided, this API returns `ESP_PWR_LVL_INVALID`. + * + * @param[in] power_type The type of TX power. It could be Advertising/Connection/Default and etc. + * + * @return + * - Power level * */ +esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type); + +/** + * @brief Set BLE TX power for the specified Advertising or Connection handle + * + * For the TX power type: `ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT`, `ESP_BLE_ENHANCED_PWR_TYPE_SCAN`, `ESP_BLE_ENHANCED_PWR_TYPE_INIT`, + * this API will ignore the input handle number, and set 0 internally. + * + * For the TX power type: `ESP_BLE_ENHANCED_PWR_TYPE_ADV` and `ESP_BLE_ENHANCED_PWR_TYPE_CONN`, + * this API will set the TX power for the target handle. + * + * @note + * 1. Connection TX power should only be set after connection created. + * + * @param[in] power_type The type of TX power + * @param[in] handle The handle of Advertising or Connection + * @param[in] power_level Power level (index) corresponding to absolute value (dBm) + * + * @return + * - ESP_OK: Success + * - ESP_ERR_NOT_SUPPORTED: Invalid TX power type + * - ESP_FAIL: Failure due to other reasons + */ +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 Get BLE TX power of the specified Advertising or Connection handle + * + * For the TX power type: `ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT`, `ESP_BLE_ENHANCED_PWR_TYPE_SCAN`, `ESP_BLE_ENHANCED_PWR_TYPE_INIT`, + * this API will ignore the input handle number. + * + * For the TX power type: `ESP_BLE_ENHANCED_PWR_TYPE_ADV` and `ESP_BLE_ENHANCED_PWR_TYPE_CONN`, + * this API will return the TX power of the target handle. + * + * @note + * 1. Connection Tx power should only be get after connection created. + * 2. If an invalid power type is provided, this API returns `ESP_PWR_LVL_INVALID`. + * + * @param[in] power_type The type of TX power + * @param[in] handle The handle of Advertising or Connection and the value 0 for other enhanced power types + * + * @return Power level + */ +esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle); + +/** + * @brief Notify Bluetooth Controller task to process the event upon TX or RX done + * + * @note + * 1. This function shall not be invoked before `esp_bt_controller_enable()`. + * 2. This function can be called in both ISR and non-ISR context. + * 3. This function ignored the passed `event` value currently + */ int esp_bt_h4tl_eif_io_event_notify(int event); /** - * @brief bt Wi-Fi power domain power on + * @brief Virtual HCI (VHCI) callback functions to notify the Host on the next operation */ -void esp_wifi_bt_power_domain_on(void); +typedef struct esp_vhci_host_callback { + void (*notify_host_send_available)(void); /*!< callback used to notify that the Host can send the HCI data to Controller */ + int (*notify_host_recv)(uint8_t *data, uint16_t len); /*!< callback used to notify that the Controller has the HCI data to send to the Host */ +} esp_vhci_host_callback_t; /** - * @brief bt Wi-Fi power domain power off + * @brief Check whether the Controller is ready to receive the HCI data + * + * If the return value is True, the Host can send the HCI data to the Controller. + * + * @note This function should be called before each `esp_vhci_host_send_packet()`. + * + * @return + * True if the Controller is ready to receive the HCI data; false otherwise. */ -void esp_wifi_bt_power_domain_off(void); +bool esp_vhci_host_check_send_available(void); /** - * @brief Get the Bluetooth module sleep clock source. + * @brief Send the HCI data to the Controller * - * Note that this function shall not be invoked before esp_bt_controller_init() + * @note + * 1. This function shall not be called within a critical section or when the scheduler is suspended. + * 2. This function should be called only if `esp_vhci_host_check_send_available` returns True. * - * @return clock source used in Bluetooth low power mode + * @param[in] data Pointer to the HCI data + * @param[in] len The HCI data length */ -esp_bt_sleep_clock_t esp_bt_get_lpclk_src(void); +void esp_vhci_host_send_packet(uint8_t *data, uint16_t len); + +/** + * @brief Register the VHCI callback functions defined in `esp_vhci_host_callback` structure. + * + * @param[in] callback `esp_vhci_host_callback` type variable + * + * @return + * - ESP_OK: Success + * - ESP_FAIL: Failure + */ +esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback); + +/** +* @brief Power on Bluetooth Wi-Fi power domain +* +* @note This function is not recommended to use due to potential risk. +*/ +void esp_wifi_bt_power_domain_on(void); + +/** +* @brief Power off Bluetooth Wi-Fi power domain +* +* @note This function is not recommended to use due to potential risk. +*/ +void esp_wifi_bt_power_domain_off(void); #ifdef __cplusplus } diff --git a/components/bt/include/esp32c6/include/esp_bt.h b/components/bt/include/esp32c6/include/esp_bt.h index ea27228722..e8f26f7faf 100644 --- a/components/bt/include/esp32c6/include/esp_bt.h +++ b/components/bt/include/esp32c6/include/esp_bt.h @@ -16,6 +16,7 @@ #include "nimble/nimble_npl.h" #include "../../../../controller/esp32c6/esp_bt_cfg.h" #include "hal/efuse_hal.h" +#include "esp_private/esp_modem_clock.h" #ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART #include "driver/uart.h" @@ -155,7 +156,7 @@ esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type */ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle); -#define CONFIG_VERSION 0x20240422 +#define CONFIG_VERSION 0x20241121 #define CONFIG_MAGIC 0x5A5AA5A5 /** @@ -210,6 +211,8 @@ typedef struct { uint8_t ignore_wl_for_direct_adv; /*!< Ignore the whitelist for direct advertising */ uint8_t enable_pcl; /*!< Enable power control */ uint8_t csa2_select; /*!< Select CSA#2*/ + uint8_t enable_csr; /*!< Enable CSR */ + uint8_t ble_aa_check; /*!< True if adds a verification step for the Access Address within the CONNECT_IND PDU; false otherwise. Configurable in menuconfig */ uint32_t config_magic; /*!< Magic number for configuration validation */ } esp_bt_controller_config_t; @@ -258,6 +261,8 @@ typedef struct { .ignore_wl_for_direct_adv = 0, \ .enable_pcl = DEFAULT_BT_LE_POWER_CONTROL_ENABLED, \ .csa2_select = DEFAULT_BT_LE_50_FEATURE_SUPPORT, \ + .enable_csr = 0, \ + .ble_aa_check = DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS, \ .config_magic = CONFIG_MAGIC, \ } @@ -414,6 +419,12 @@ extern int esp_ble_hw_get_static_addr(esp_ble_addr_t *addr); void esp_ble_controller_log_dump_all(bool output); #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED +#if CONFIG_PM_ENABLE +modem_clock_lpclk_src_t esp_bt_get_lpclk_src(void); + +void esp_bt_set_lpclk_src(modem_clock_lpclk_src_t clk_src); +#endif // CONFIG_PM_ENABLE + #ifdef __cplusplus } #endif diff --git a/components/bt/include/esp32h2/include/esp_bt.h b/components/bt/include/esp32h2/include/esp_bt.h index bbecb64072..c21a1bc854 100644 --- a/components/bt/include/esp32h2/include/esp_bt.h +++ b/components/bt/include/esp32h2/include/esp_bt.h @@ -15,6 +15,7 @@ #include "nimble/nimble_npl.h" #include "../../../../controller/esp32h2/esp_bt_cfg.h" +#include "esp_private/esp_modem_clock.h" #ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART #include "driver/uart.h" @@ -160,7 +161,7 @@ esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type */ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, uint16_t handle); -#define CONFIG_VERSION 0x20240422 +#define CONFIG_VERSION 0x20241121 #define CONFIG_MAGIC 0x5A5AA5A5 /** @@ -213,7 +214,9 @@ typedef struct { uint8_t cpu_freq_mhz; /*!< CPU frequency in megahertz */ 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; /*!< Select CSA#2*/ + uint8_t csa2_select; /*!< Select CSA#2*/ + uint8_t enable_csr; /*!< Enable CSR */ + uint8_t ble_aa_check; /*!< True if adds a verification step for the Access Address within the CONNECT_IND PDU; false otherwise. Configurable in menuconfig */ uint32_t config_magic; /*!< Configuration magic value */ } esp_bt_controller_config_t; @@ -261,7 +264,9 @@ typedef struct { .cpu_freq_mhz = CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ, \ .ignore_wl_for_direct_adv = 0, \ .enable_pcl = 0, \ - .csa2_select = DEFAULT_BT_LE_50_FEATURE_SUPPORT, \ + .csa2_select = DEFAULT_BT_LE_50_FEATURE_SUPPORT, \ + .enable_csr = 0, \ + .ble_aa_check = DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS, \ .config_magic = CONFIG_MAGIC, \ } @@ -418,6 +423,12 @@ extern int esp_ble_hw_get_static_addr(esp_ble_addr_t *addr); void esp_ble_controller_log_dump_all(bool output); #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED +#if CONFIG_PM_ENABLE +modem_clock_lpclk_src_t esp_bt_get_lpclk_src(void); + +void esp_bt_set_lpclk_src(modem_clock_lpclk_src_t clk_src); +#endif // CONFIG_PM_ENABLE + #ifdef __cplusplus } #endif diff --git a/components/bt/linker_common.lf b/components/bt/linker_common.lf index 501acd9505..a8f796838b 100644 --- a/components/bt/linker_common.lf +++ b/components/bt/linker_common.lf @@ -6,37 +6,8 @@ entries: entries: COMMON -[scheme:bt_default] -entries: - bt_bss -> dram0_bss - bt_common -> dram0_bss - data -> dram0_data - [scheme:bt_extram_bss] entries: bt_bss -> extern_ram bt_common -> extern_ram data -> dram0_data - -# For the following fragments, order matters for -# 'ALIGN(4) ALIGN(4, post) SURROUND(sym)', which generates: -# -# . = ALIGN(4) -# _sym_start -# ... -# . = ALIGN(4) -# _sym_end - -[mapping:bt] -archive: libbt.a -entries: - if ESP_ALLOW_BSS_SEG_EXTERNAL_MEMORY = y: - * (bt_extram_bss); - bt_bss -> extern_ram ALIGN(4) ALIGN(4, post) SURROUND(bt_bss), - bt_common -> extern_ram ALIGN(4) ALIGN(4, post) SURROUND(bt_common), - data -> dram0_data ALIGN(4) ALIGN(4, post) SURROUND(bt_data) - else: - * (bt_default); - bt_bss -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_bss), - bt_common -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_common), - data -> dram0_data ALIGN(4) ALIGN(4, post) SURROUND(bt_data) diff --git a/components/bt/linker_esp32c2.lf b/components/bt/linker_esp32c2.lf index 7178420a00..75f0d59680 100644 --- a/components/bt/linker_esp32c2.lf +++ b/components/bt/linker_esp32c2.lf @@ -2,6 +2,14 @@ entries: .iram1+ +[sections:bt_isr_iram_text] +entries: + .isr_iram1+ + +[sections:bt_conn_iram_text] +entries: + .conn_iram1+ + [sections:bt_bss] entries: .bss+ @@ -19,10 +27,26 @@ entries: [scheme:bt_default] entries: - bt_iram_text -> iram0_bt_text - bt_bss -> dram0_bt_bss - bt_common -> dram0_bt_bss - bt_data -> dram0_bt_data + if BT_CTRL_RUN_IN_FLASH_ONLY = y: + bt_iram_text -> flash_text + bt_bss -> dram0_bt_bss + bt_common -> dram0_bt_bss + bt_data -> dram0_bt_data + + if BT_LE_PLACE_CONN_RELATED_INTO_IRAM = y: + bt_conn_iram_text -> iram0_bt_text + bt_isr_iram_text -> iram0_bt_text + else: + bt_conn_iram_text -> flash_text + bt_isr_iram_text -> flash_text + else: + bt_iram_text -> iram0_bt_text + bt_bss -> dram0_bt_bss + bt_common -> dram0_bt_bss + bt_data -> dram0_bt_data + + bt_conn_iram_text -> iram0_bt_text + bt_isr_iram_text -> iram0_bt_text # For the following fragments, order matters for # 'ALIGN(4) ALIGN(4, post) SURROUND(sym)', which generates: @@ -48,3 +72,11 @@ entries: bt_bss -> dram0_bt_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_bss), bt_common -> dram0_bt_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_common), bt_data -> dram0_bt_data ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_data) + +[mapping:ble_app_flash] +archive: libble_app_flash.a +entries: + * (bt_default); + bt_bss -> dram0_bt_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_bss), + bt_common -> dram0_bt_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_common), + bt_data -> dram0_bt_data ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_data) diff --git a/components/bt/linker_esp_ble_controller.lf b/components/bt/linker_esp_ble_controller.lf index fe8598112b..d6bd1df10c 100644 --- a/components/bt/linker_esp_ble_controller.lf +++ b/components/bt/linker_esp_ble_controller.lf @@ -1,3 +1,33 @@ +[scheme:bt_default] +entries: + bt_bss -> dram0_bss + bt_common -> dram0_bss + data -> dram0_data + +# For the following fragments, order matters for +# 'ALIGN(4) ALIGN(4, post) SURROUND(sym)', which generates: +# +# . = ALIGN(4) +# _sym_start +# ... +# . = ALIGN(4) +# _sym_end + +[mapping:bt] +archive: libbt.a +entries: + if ESP_ALLOW_BSS_SEG_EXTERNAL_MEMORY = y: + * (bt_extram_bss); + bt_bss -> extern_ram ALIGN(4) ALIGN(4, post) SURROUND(bt_bss), + bt_common -> extern_ram ALIGN(4) ALIGN(4, post) SURROUND(bt_common), + data -> dram0_data ALIGN(4) ALIGN(4, post) SURROUND(bt_data) + else: + * (bt_default); + bt_bss -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_bss), + bt_common -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_common), + data -> dram0_data ALIGN(4) ALIGN(4, post) SURROUND(bt_data) + + [mapping:ble_app] archive: libble_app.a entries: diff --git a/components/bt/linker_rw_bt_controller.lf b/components/bt/linker_rw_bt_controller.lf index 083d6e90b7..575aea58e2 100644 --- a/components/bt/linker_rw_bt_controller.lf +++ b/components/bt/linker_rw_bt_controller.lf @@ -1,3 +1,33 @@ +[scheme:bt_default] +entries: + bt_bss -> dram0_bss + bt_common -> dram0_bss + data -> dram0_data + +# For the following fragments, order matters for +# 'ALIGN(4) ALIGN(4, post) SURROUND(sym)', which generates: +# +# . = ALIGN(4) +# _sym_start +# ... +# . = ALIGN(4) +# _sym_end + +[mapping:bt] +archive: libbt.a +entries: + if ESP_ALLOW_BSS_SEG_EXTERNAL_MEMORY = y: + * (bt_extram_bss); + bt_bss -> extern_ram ALIGN(4) ALIGN(4, post) SURROUND(bt_bss), + bt_common -> extern_ram ALIGN(4) ALIGN(4, post) SURROUND(bt_common), + data -> dram0_data ALIGN(4) ALIGN(4, post) SURROUND(bt_data) + else: + * (bt_default); + bt_bss -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_bss), + bt_common -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_common), + data -> dram0_data ALIGN(4) ALIGN(4, post) SURROUND(bt_data) + + [mapping:btdm] archive: libbtdm_app.a entries: diff --git a/components/bt/porting/mem/bt_osi_mem.c b/components/bt/porting/mem/bt_osi_mem.c index 69c656dd6a..612099d277 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-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -7,18 +7,31 @@ #include "esp_attr.h" #include "esp_heap_caps.h" #include "sdkconfig.h" +#include "esp_log.h" +#include +static uint8_t log_count; IRAM_ATTR void *bt_osi_mem_malloc(size_t size) { + void *mem = NULL; #ifdef CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL - return heap_caps_malloc(size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT); + mem = heap_caps_malloc(size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT); #elif CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL - return heap_caps_malloc(size, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT); + mem = heap_caps_malloc(size, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT); #elif CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_IRAM_8BIT - return heap_caps_malloc_prefer(size, 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT); + mem = heap_caps_malloc_prefer(size, 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT); #else - return malloc(size); + mem = malloc(size); #endif + if (!mem) { + log_count ++; + if ((log_count % 100) == 0) { + ESP_EARLY_LOGI("ESP_LOG_INFO","malloc failed (size %zu)",size); + log_count = 0; + } + assert(mem != NULL); + } + return mem; } IRAM_ATTR void *bt_osi_mem_calloc(size_t n, size_t size) 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 29e2567d55..9e5c9863c3 100644 --- a/components/bt/porting/npl/freertos/src/npl_os_freertos.c +++ b/components/bt/porting/npl/freertos/src/npl_os_freertos.c @@ -21,6 +21,7 @@ #include "esp_log.h" #include "soc/soc_caps.h" #include "esp_bt.h" +#include "bt_osi_mem.h" portMUX_TYPE ble_port_mutex = portMUX_INITIALIZER_UNLOCKED; @@ -95,7 +96,7 @@ IRAM_ATTR npl_freertos_event_init(struct ble_npl_event *ev, ble_npl_event_fn *fn } #else if(!ev->event) { - ev->event = malloc(sizeof(struct ble_npl_event_freertos)); + ev->event = bt_osi_mem_malloc_internal(sizeof(struct ble_npl_event_freertos)); } #endif event = (struct ble_npl_event_freertos *)ev->event; @@ -113,7 +114,7 @@ IRAM_ATTR npl_freertos_event_deinit(struct ble_npl_event *ev) #if OS_MEM_ALLOC os_memblock_put(&ble_freertos_ev_pool,ev->event); #else - free(ev->event); + bt_osi_mem_free(ev->event); #endif ev->event = NULL; } @@ -144,7 +145,7 @@ npl_freertos_eventq_init(struct ble_npl_eventq *evq) } #else if(!evq->eventq) { - evq->eventq = malloc(sizeof(struct ble_npl_eventq_freertos)); + evq->eventq = bt_osi_mem_malloc_internal(sizeof(struct ble_npl_eventq_freertos)); eventq = (struct ble_npl_eventq_freertos*)evq->eventq; BLE_LL_ASSERT(eventq); memset(eventq, 0, sizeof(*eventq)); @@ -167,7 +168,7 @@ npl_freertos_eventq_deinit(struct ble_npl_eventq *evq) #if OS_MEM_ALLOC os_memblock_put(&ble_freertos_evq_pool,eventq); #else - free((void *)eventq); + bt_osi_mem_free((void *)eventq); #endif evq->eventq = NULL; } @@ -357,7 +358,7 @@ npl_freertos_mutex_init(struct ble_npl_mutex *mu) } #else if(!mu->mutex) { - mu->mutex = malloc(sizeof(struct ble_npl_mutex_freertos)); + mu->mutex = bt_osi_mem_malloc_internal(sizeof(struct ble_npl_mutex_freertos)); mutex = (struct ble_npl_mutex_freertos *)mu->mutex; if (!mutex) { @@ -388,7 +389,7 @@ npl_freertos_mutex_deinit(struct ble_npl_mutex *mu) #if OS_MEM_ALLOC os_memblock_put(&ble_freertos_mutex_pool,mutex); #else - free((void *)mutex); + bt_osi_mem_free((void *)mutex); #endif mu->mutex = NULL; @@ -494,7 +495,7 @@ npl_freertos_sem_init(struct ble_npl_sem *sem, uint16_t tokens) } #else if(!sem->sem) { - sem->sem = malloc(sizeof(struct ble_npl_sem_freertos)); + sem->sem = bt_osi_mem_malloc_internal(sizeof(struct ble_npl_sem_freertos)); semaphore = (struct ble_npl_sem_freertos *)sem->sem; if (!semaphore) { @@ -525,7 +526,7 @@ npl_freertos_sem_deinit(struct ble_npl_sem *sem) #if OS_MEM_ALLOC os_memblock_put(&ble_freertos_sem_pool,semaphore); #else - free((void *)semaphore); + bt_osi_mem_free((void *)semaphore); #endif sem->sem = NULL; @@ -684,7 +685,7 @@ npl_freertos_callout_init(struct ble_npl_callout *co, struct ble_npl_eventq *evq #else if(!co->co) { - co->co = malloc(sizeof(struct ble_npl_callout_freertos)); + co->co = bt_osi_mem_malloc_internal(sizeof(struct ble_npl_callout_freertos)); callout = (struct ble_npl_callout_freertos *)co->co; if (!callout) { return -1; @@ -704,7 +705,7 @@ npl_freertos_callout_init(struct ble_npl_callout *co, struct ble_npl_eventq *evq if (esp_timer_create(&create_args, &callout->handle) != ESP_OK) { ble_npl_event_deinit(&callout->ev); - free((void *)callout); + bt_osi_mem_free((void *)callout); co->co = NULL; return -1; } @@ -713,7 +714,7 @@ npl_freertos_callout_init(struct ble_npl_callout *co, struct ble_npl_eventq *evq if (!callout->handle) { ble_npl_event_deinit(&callout->ev); - free((void *)callout); + bt_osi_mem_free((void *)callout); co->co = NULL; return -1; } @@ -761,7 +762,7 @@ npl_freertos_callout_deinit(struct ble_npl_callout *co) #if OS_MEM_ALLOC os_memblock_put(&ble_freertos_co_pool,callout); #else - free((void *)callout); + bt_osi_mem_free((void *)callout); #endif // OS_MEM_ALLOC co->co = NULL; memset(co, 0, sizeof(struct ble_npl_callout)); @@ -1089,7 +1090,7 @@ struct npl_funcs_t * npl_freertos_funcs_get(void) void npl_freertos_funcs_init(void) { - npl_funcs = (struct npl_funcs_t *)malloc(sizeof(struct npl_funcs_t)); + npl_funcs = (struct npl_funcs_t *)bt_osi_mem_malloc_internal(sizeof(struct npl_funcs_t)); if(!npl_funcs) { printf("npl funcs init failed\n"); assert(0); @@ -1123,7 +1124,7 @@ int npl_freertos_mempool_init(void) ble_freertos_total_event_cnt = ble_total_evt_count; if (ble_total_evt_count) { - ble_freertos_ev_buf = malloc(OS_MEMPOOL_SIZE(ble_total_evt_count, + ble_freertos_ev_buf = bt_osi_mem_malloc_internal(OS_MEMPOOL_SIZE(ble_total_evt_count, sizeof (struct ble_npl_event_freertos)) * sizeof(os_membuf_t)); if (!ble_freertos_ev_buf) { @@ -1138,7 +1139,7 @@ int npl_freertos_mempool_init(void) } if (ble_total_evtq_count) { - ble_freertos_evq_buf = malloc(OS_MEMPOOL_SIZE(ble_total_evtq_count, + ble_freertos_evq_buf = bt_osi_mem_malloc_internal(OS_MEMPOOL_SIZE(ble_total_evtq_count, sizeof (struct ble_npl_eventq_freertos)) * sizeof(os_membuf_t)); if (!ble_freertos_evq_buf) { @@ -1153,7 +1154,7 @@ int npl_freertos_mempool_init(void) } if (ble_total_co_count) { - ble_freertos_co_buf = malloc(OS_MEMPOOL_SIZE(ble_total_co_count, + ble_freertos_co_buf = bt_osi_mem_malloc_internal(OS_MEMPOOL_SIZE(ble_total_co_count, sizeof (struct ble_npl_callout_freertos)) * sizeof(os_membuf_t)); if (!ble_freertos_co_buf) { @@ -1168,7 +1169,7 @@ int npl_freertos_mempool_init(void) } if (ble_total_sem_count) { - ble_freertos_sem_buf = malloc(OS_MEMPOOL_SIZE(ble_total_sem_count, + ble_freertos_sem_buf = bt_osi_mem_malloc_internal(OS_MEMPOOL_SIZE(ble_total_sem_count, sizeof (struct ble_npl_sem_freertos)) * sizeof(os_membuf_t)); if (!ble_freertos_sem_buf) { @@ -1183,7 +1184,7 @@ int npl_freertos_mempool_init(void) } if (ble_total_mutex_count) { - ble_freertos_mutex_buf = malloc(OS_MEMPOOL_SIZE(ble_total_mutex_count, + ble_freertos_mutex_buf = bt_osi_mem_malloc_internal(OS_MEMPOOL_SIZE(ble_total_mutex_count, sizeof (struct ble_npl_mutex_freertos)) * sizeof(os_membuf_t)); if (!ble_freertos_mutex_buf) { @@ -1200,27 +1201,27 @@ int npl_freertos_mempool_init(void) return 0; _error: if (ble_freertos_ev_buf) { - free(ble_freertos_ev_buf); + bt_osi_mem_free(ble_freertos_ev_buf); ble_freertos_ev_buf = NULL; } if (ble_freertos_evq_buf) { - free(ble_freertos_evq_buf); + bt_osi_mem_free(ble_freertos_evq_buf); ble_freertos_evq_buf = NULL; } if (ble_freertos_co_buf) { - free(ble_freertos_co_buf); + bt_osi_mem_free(ble_freertos_co_buf); ble_freertos_co_buf = NULL; } if (ble_freertos_sem_buf) { - free(ble_freertos_sem_buf); + bt_osi_mem_free(ble_freertos_sem_buf); ble_freertos_sem_buf = NULL; } if (ble_freertos_mutex_buf) { - free(ble_freertos_mutex_buf); + bt_osi_mem_free(ble_freertos_mutex_buf); ble_freertos_mutex_buf = NULL; } return -1; @@ -1229,23 +1230,23 @@ int npl_freertos_mempool_init(void) void npl_freertos_mempool_deinit(void) { if (ble_freertos_ev_buf) { - free(ble_freertos_ev_buf); + bt_osi_mem_free(ble_freertos_ev_buf); ble_freertos_ev_buf = NULL; } if (ble_freertos_evq_buf) { - free(ble_freertos_evq_buf); + bt_osi_mem_free(ble_freertos_evq_buf); ble_freertos_evq_buf = NULL; } if (ble_freertos_co_buf) { - free(ble_freertos_co_buf); + bt_osi_mem_free(ble_freertos_co_buf); ble_freertos_co_buf = NULL; } if (ble_freertos_sem_buf) { - free(ble_freertos_sem_buf); + bt_osi_mem_free(ble_freertos_sem_buf); ble_freertos_sem_buf = NULL; } if (ble_freertos_mutex_buf) { - free(ble_freertos_mutex_buf); + bt_osi_mem_free(ble_freertos_mutex_buf); ble_freertos_mutex_buf = NULL; } } @@ -1253,7 +1254,7 @@ void npl_freertos_mempool_deinit(void) void npl_freertos_funcs_deinit(void) { if (npl_funcs) { - free(npl_funcs); + bt_osi_mem_free(npl_funcs); } npl_funcs = NULL; } 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 6ac2a462fa..636cf49749 100644 --- a/components/bt/porting/transport/driver/uart/hci_driver_uart.c +++ b/components/bt/porting/transport/driver/uart/hci_driver_uart.c @@ -140,7 +140,7 @@ hci_driver_uart_task_create(void) } static void -hci_driver_uart_deinit(void) +hci_driver_uart_task_delete(void) { if (s_hci_driver_uart_env.tx_task_handler) { vTaskDelete(s_hci_driver_uart_env.tx_task_handler); @@ -151,10 +151,16 @@ hci_driver_uart_deinit(void) vTaskDelete(s_hci_driver_uart_env.rx_task_handler); s_hci_driver_uart_env.rx_task_handler = NULL; } +} + +static void +hci_driver_uart_deinit(void) +{ + hci_driver_uart_task_delete(); ESP_ERROR_CHECK(uart_driver_delete(s_hci_driver_uart_env.hci_uart_params->hci_uart_port)); - if (!s_hci_driver_uart_env.tx_sem) { + if (s_hci_driver_uart_env.tx_sem) { vSemaphoreDelete(s_hci_driver_uart_env.tx_sem); } @@ -207,12 +213,28 @@ hci_driver_uart_init(hci_driver_forward_fn *cb) int hci_driver_uart_reconfig_pin(int tx_pin, int rx_pin, int cts_pin, int rts_pin) { + int rc; hci_driver_uart_params_config_t *uart_param = s_hci_driver_uart_env.hci_uart_params; + + hci_driver_uart_task_delete(); uart_param->hci_uart_tx_pin = tx_pin; uart_param->hci_uart_rx_pin = rx_pin; uart_param->hci_uart_rts_pin = rts_pin; uart_param->hci_uart_cts_pin = cts_pin; - return hci_driver_uart_config(uart_param); + hci_driver_uart_config(uart_param); + /* 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, + CONFIG_BT_LE_HCI_UART_RX_BUFFER_SIZE, + CONFIG_BT_LE_HCI_UART_TX_BUFFER_SIZE, + 1, &s_hci_driver_uart_env.rx_event_queue, + 0)); + rc = hci_driver_uart_task_create(); + if (rc) { + hci_driver_uart_task_delete(); + return -2; + } + + return 0; } hci_driver_ops_t hci_driver_uart_ops = { diff --git a/components/bt/porting/transport/driver/uart/hci_driver_uart.h b/components/bt/porting/transport/driver/uart/hci_driver_uart.h index 8b5f5eb856..f8ec574df5 100644 --- a/components/bt/porting/transport/driver/uart/hci_driver_uart.h +++ b/components/bt/porting/transport/driver/uart/hci_driver_uart.h @@ -60,38 +60,6 @@ typedef struct hci_driver_uart_params_config */ int hci_driver_uart_config(hci_driver_uart_params_config_t *uart_config); -#if CONFIG_BT_LE_UART_HCI_DMA_MODE -/** - * @brief Reconfigure the UART pins for the HCI driver. - * - * This function changes the UART pin configuration for the HCI driver. - * - * @param tx_pin The pin number for the UART TX (transmit) line. - * @param rx_pin The pin number for the UART RX (receive) line. - * @param cts_pin The pin number for the UART CTS (clear to send) line. - * @param rts_pin The pin number for the UART RTS (request to send) line. - * - * @return int Returns 0 on success, or a negative error code on failure. - */ -int hci_driver_uart_dma_reconfig_pin(int tx_pin, int rx_pin, int cts_pin, int rts_pin); -#define hci_uart_reconfig_pin hci_driver_uart_dma_reconfig_pin -#else -/** - * @brief Reconfigure the UART pins for the HCI driver. - * - * This function changes the UART pin configuration for the HCI driver. - * - * @param tx_pin The pin number for the UART TX (transmit) line. - * @param rx_pin The pin number for the UART RX (receive) line. - * @param cts_pin The pin number for the UART CTS (clear to send) line. - * @param rts_pin The pin number for the UART RTS (request to send) line. - * - * @return int Returns 0 on success, or a negative error code on failure. - */ -int hci_driver_uart_reconfig_pin(int tx_pin, int rx_pin, int cts_pin, int rts_pin); -#define hci_uart_reconfig_pin hci_driver_uart_reconfig_pin -#endif // CONFIG_BT_LE_UART_HCI_DMA_MODE - #ifdef __cplusplus } #endif diff --git a/components/bt/porting/transport/driver/vhci/hci_driver_standard.c b/components/bt/porting/transport/driver/vhci/hci_driver_standard.c index 2cdab4359e..5e9d02af94 100644 --- a/components/bt/porting/transport/driver/vhci/hci_driver_standard.c +++ b/components/bt/porting/transport/driver/vhci/hci_driver_standard.c @@ -139,6 +139,10 @@ esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback) void esp_vhci_host_send_packet(uint8_t *data, uint16_t len) { + if (esp_bt_controller_get_status() != ESP_BT_CONTROLLER_STATUS_ENABLED) { + return; + } + hci_driver_vhci_tx(data[0], data, len, HCI_DRIVER_DIR_H2C); } diff --git a/components/bt/porting/transport/include/esp_hci_driver.h b/components/bt/porting/transport/include/esp_hci_driver.h index 09102edff8..04bf929766 100644 --- a/components/bt/porting/transport/include/esp_hci_driver.h +++ b/components/bt/porting/transport/include/esp_hci_driver.h @@ -43,9 +43,38 @@ extern hci_driver_ops_t hci_driver_vhci_ops; #endif // CONFIG_BT_LE_HCI_INTERFACE_USE_RAM #if CONFIG_BT_LE_HCI_INTERFACE_USE_UART -extern hci_driver_ops_t hci_driver_uart_ops; #if CONFIG_BT_LE_UART_HCI_DMA_MODE extern hci_driver_ops_t hci_driver_uart_dma_ops; +/** + * @brief Reconfigure the UART pins for the HCI driver. + * + * This function changes the UART pin configuration for the HCI driver. + * + * @param tx_pin The pin number for the UART TX (transmit) line. + * @param rx_pin The pin number for the UART RX (receive) line. + * @param cts_pin The pin number for the UART CTS (clear to send) line. + * @param rts_pin The pin number for the UART RTS (request to send) line. + * + * @return int Returns 0 on success, or a negative error code on failure. + */ +int hci_driver_uart_dma_reconfig_pin(int tx_pin, int rx_pin, int cts_pin, int rts_pin); +#define hci_uart_reconfig_pin hci_driver_uart_dma_reconfig_pin +#else +extern hci_driver_ops_t hci_driver_uart_ops; +/** + * @brief Reconfigure the UART pins for the HCI driver. + * + * This function changes the UART pin configuration for the HCI driver. + * + * @param tx_pin The pin number for the UART TX (transmit) line. + * @param rx_pin The pin number for the UART RX (receive) line. + * @param cts_pin The pin number for the UART CTS (clear to send) line. + * @param rts_pin The pin number for the UART RTS (request to send) line. + * + * @return int Returns 0 on success, or a negative error code on failure. + */ +int hci_driver_uart_reconfig_pin(int tx_pin, int rx_pin, int cts_pin, int rts_pin); +#define hci_uart_reconfig_pin hci_driver_uart_reconfig_pin #endif // CONFIG_BT_LE_UART_HCI_DMA_MODE #endif // CONFIG_BT_LE_HCI_INTERFACE_USE_UART diff --git a/components/esp_adc/adc_cali.c b/components/esp_adc/adc_cali.c index 4b5b4e26aa..084fae818a 100644 --- a/components/esp_adc/adc_cali.c +++ b/components/esp_adc/adc_cali.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -15,6 +15,7 @@ #include "hal/adc_types.h" #include "esp_adc/adc_cali.h" #include "adc_cali_interface.h" +#include "adc_cali_schemes.h" const __attribute__((unused)) static char *TAG = "adc_cali"; @@ -23,9 +24,9 @@ esp_err_t adc_cali_check_scheme(adc_cali_scheme_ver_t *scheme_mask) { ESP_RETURN_ON_FALSE(scheme_mask, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer"); *scheme_mask = 0; -#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 +#if ADC_CALI_SCHEME_LINE_FITTING_SUPPORTED *scheme_mask |= ADC_CALI_SCHEME_VER_LINE_FITTING; -#elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3 +#elif ADC_CALI_SCHEME_CURVE_FITTING_SUPPORTED *scheme_mask |= ADC_CALI_SCHEME_VER_CURVE_FITTING; #endif diff --git a/components/esp_coex/CMakeLists.txt b/components/esp_coex/CMakeLists.txt index 8918bdd600..a17cf060a0 100644 --- a/components/esp_coex/CMakeLists.txt +++ b/components/esp_coex/CMakeLists.txt @@ -13,7 +13,9 @@ if(CONFIG_ESP_COEX_SW_COEXIST_ENABLE OR CONFIG_ESP_COEX_EXTERNAL_COEXIST_ENABLE) endif() if(CONFIG_ESP_WIFI_ENABLED) - list(APPEND srcs "${idf_target}/esp_coex_adapter.c") + list(APPEND srcs "${idf_target}/esp_coex_adapter.c" + "src/coexist_debug_diagram.c" + "src/coexist_debug.c") endif() idf_component_register(SRCS "${srcs}" diff --git a/components/esp_coex/Kconfig b/components/esp_coex/Kconfig index d5de082a3c..c690ec5474 100644 --- a/components/esp_coex/Kconfig +++ b/components/esp_coex/Kconfig @@ -33,4 +33,201 @@ menu "Wireless Coexistence" help If enabled, coexist power management will be enabled. + config ESP_COEX_GPIO_DEBUG + bool "GPIO debugging for coexistence" + default n + depends on !PM_SLP_DISABLE_GPIO && !PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP + help + Support coexistence GPIO debugging + + if (ESP_COEX_GPIO_DEBUG) + + choice ESP_COEX_GPIO_DEBUG_DIAG + prompt "Debugging Diagram" + default ESP_COEX_GPIO_DEBUG_DIAG_GENERAL + help + Select type of debugging diagram + + config ESP_COEX_GPIO_DEBUG_DIAG_GENERAL + bool "General" + config ESP_COEX_GPIO_DEBUG_DIAG_WIFI + bool "Wi-Fi" + + endchoice + + config ESP_COEX_GPIO_DEBUG_IO_COUNT + int "Max number of debugging GPIOs" + range 0 12 + default 12 + + config ESP_COEX_GPIO_DEBUG_IO_IDX0 + depends on (ESP_COEX_GPIO_DEBUG_IO_COUNT > 0) + int "Actual IO num for Debug IO ID0" + range 0 SOC_GPIO_OUT_RANGE_MAX + default 15 if IDF_TARGET_ESP32 + default 4 if IDF_TARGET_ESP32S2 + default 19 if IDF_TARGET_ESP32C3 + default 4 if IDF_TARGET_ESP32S3 + default 18 if IDF_TARGET_ESP32C2 + default 4 if IDF_TARGET_ESP32C6 + default 2 if IDF_TARGET_ESP32C5 + default 4 if IDF_TARGET_ESP32C61 + default 1 + + config ESP_COEX_GPIO_DEBUG_IO_IDX1 + depends on (ESP_COEX_GPIO_DEBUG_IO_COUNT > 1) + int "Actual IO num for Debug IO ID1" + range 0 SOC_GPIO_OUT_RANGE_MAX + default 2 if IDF_TARGET_ESP32 + default 5 if IDF_TARGET_ESP32S2 + default 18 if IDF_TARGET_ESP32C3 + default 5 if IDF_TARGET_ESP32S3 + default 4 if IDF_TARGET_ESP32C2 + default 5 if IDF_TARGET_ESP32C6 + default 3 if IDF_TARGET_ESP32C5 + default 5 if IDF_TARGET_ESP32C61 + default 2 + + config ESP_COEX_GPIO_DEBUG_IO_IDX2 + depends on (ESP_COEX_GPIO_DEBUG_IO_COUNT > 2) + int "Actual IO num for Debug IO ID2" + range 0 SOC_GPIO_OUT_RANGE_MAX + default 0 if IDF_TARGET_ESP32 + default 6 if IDF_TARGET_ESP32S2 + default 4 if IDF_TARGET_ESP32C3 + default 6 if IDF_TARGET_ESP32S3 + default 5 if IDF_TARGET_ESP32C2 + default 6 if IDF_TARGET_ESP32C6 + default 4 if IDF_TARGET_ESP32C5 + default 6 if IDF_TARGET_ESP32C61 + default 3 + + config ESP_COEX_GPIO_DEBUG_IO_IDX3 + depends on (ESP_COEX_GPIO_DEBUG_IO_COUNT > 3) + int "Actual IO num for Debug IO ID3" + range 0 SOC_GPIO_OUT_RANGE_MAX + default 4 if IDF_TARGET_ESP32 + default 7 if IDF_TARGET_ESP32S2 + default 5 if IDF_TARGET_ESP32C3 + default 7 if IDF_TARGET_ESP32S3 + default 6 if IDF_TARGET_ESP32C2 + default 7 if IDF_TARGET_ESP32C6 + default 5 if IDF_TARGET_ESP32C5 + default 7 if IDF_TARGET_ESP32C61 + default 4 + + config ESP_COEX_GPIO_DEBUG_IO_IDX4 + depends on (ESP_COEX_GPIO_DEBUG_IO_COUNT > 4) + int "Actual IO num for Debug IO ID4" + range 0 SOC_GPIO_OUT_RANGE_MAX + default 5 if IDF_TARGET_ESP32 + default 8 if IDF_TARGET_ESP32S2 + default 6 if IDF_TARGET_ESP32C3 + default 15 if IDF_TARGET_ESP32S3 + default 7 if IDF_TARGET_ESP32C2 + default 8 if IDF_TARGET_ESP32C6 + default 27 if IDF_TARGET_ESP32C5 + default 0 if IDF_TARGET_ESP32C61 + default 5 + + config ESP_COEX_GPIO_DEBUG_IO_IDX5 + depends on (ESP_COEX_GPIO_DEBUG_IO_COUNT > 5) + int "Actual IO num for Debug IO ID5" + range 0 SOC_GPIO_OUT_RANGE_MAX + default 18 if IDF_TARGET_ESP32 + default 9 if IDF_TARGET_ESP32S2 + default 7 if IDF_TARGET_ESP32C3 + default 16 if IDF_TARGET_ESP32S3 + default 8 if IDF_TARGET_ESP32C2 + default 10 if IDF_TARGET_ESP32C6 + default 6 if IDF_TARGET_ESP32C5 + default 1 if IDF_TARGET_ESP32C61 + default 6 + + config ESP_COEX_GPIO_DEBUG_IO_IDX6 + depends on (ESP_COEX_GPIO_DEBUG_IO_COUNT > 6) + int "Actual IO num for Debug IO ID6" + range 0 SOC_GPIO_OUT_RANGE_MAX + default 19 if IDF_TARGET_ESP32 + default 10 if IDF_TARGET_ESP32S2 + default 8 if IDF_TARGET_ESP32C3 + default 17 if IDF_TARGET_ESP32S3 + default 9 if IDF_TARGET_ESP32C2 + default 11 if IDF_TARGET_ESP32C6 + default 7 if IDF_TARGET_ESP32C5 + default 8 if IDF_TARGET_ESP32C61 + default 7 + + config ESP_COEX_GPIO_DEBUG_IO_IDX7 + depends on (ESP_COEX_GPIO_DEBUG_IO_COUNT > 7) + int "Actual IO num for Debug IO ID7" + range 0 SOC_GPIO_OUT_RANGE_MAX + default 22 if IDF_TARGET_ESP32 + default 11 if IDF_TARGET_ESP32S2 + default 9 if IDF_TARGET_ESP32C3 + default 18 if IDF_TARGET_ESP32S3 + default 10 if IDF_TARGET_ESP32C2 + default 2 if IDF_TARGET_ESP32C6 + default 26 if IDF_TARGET_ESP32C5 + default 2 if IDF_TARGET_ESP32C61 + default 8 + + config ESP_COEX_GPIO_DEBUG_IO_IDX8 + depends on (ESP_COEX_GPIO_DEBUG_IO_COUNT > 8) + int "Actual IO num for Debug IO ID8" + range 0 SOC_GPIO_OUT_RANGE_MAX + default 13 if IDF_TARGET_ESP32 + default 12 if IDF_TARGET_ESP32S2 + default 10 if IDF_TARGET_ESP32C3 + default 10 if IDF_TARGET_ESP32S3 + default 1 if IDF_TARGET_ESP32C2 + default 15 if IDF_TARGET_ESP32C6 + default 24 if IDF_TARGET_ESP32C5 + default 3 if IDF_TARGET_ESP32C61 + default 9 + + config ESP_COEX_GPIO_DEBUG_IO_IDX9 + depends on (ESP_COEX_GPIO_DEBUG_IO_COUNT > 9) + int "Actual IO num for Debug IO ID9" + range 0 SOC_GPIO_OUT_RANGE_MAX + default 12 if IDF_TARGET_ESP32 + default 13 if IDF_TARGET_ESP32S2 + default 0 if IDF_TARGET_ESP32C3 + default 11 if IDF_TARGET_ESP32S3 + default 0 if IDF_TARGET_ESP32C2 + default 23 if IDF_TARGET_ESP32C6 + default 23 if IDF_TARGET_ESP32C5 + default 9 if IDF_TARGET_ESP32C61 + default 10 + + config ESP_COEX_GPIO_DEBUG_IO_IDX10 + depends on (ESP_COEX_GPIO_DEBUG_IO_COUNT > 10) + int "Actual IO num for Debug IO ID10" + range 0 SOC_GPIO_OUT_RANGE_MAX + default 14 if IDF_TARGET_ESP32 + default 14 if IDF_TARGET_ESP32S2 + default 3 if IDF_TARGET_ESP32C3 + default 12 if IDF_TARGET_ESP32S3 + default 3 if IDF_TARGET_ESP32C2 + default 22 if IDF_TARGET_ESP32C6 + default 10 if IDF_TARGET_ESP32C5 + default 13 if IDF_TARGET_ESP32C61 + default 11 + + config ESP_COEX_GPIO_DEBUG_IO_IDX11 + depends on (ESP_COEX_GPIO_DEBUG_IO_COUNT > 11) + int "Actual IO num for Debug IO ID11" + range 0 SOC_GPIO_OUT_RANGE_MAX + default 27 if IDF_TARGET_ESP32 + default 15 if IDF_TARGET_ESP32S2 + default 2 if IDF_TARGET_ESP32C3 + default 13 if IDF_TARGET_ESP32S3 + default 2 if IDF_TARGET_ESP32C2 + default 21 if IDF_TARGET_ESP32C6 + default 9 if IDF_TARGET_ESP32C5 + default 12 if IDF_TARGET_ESP32C61 + default 12 + + endif + endmenu # Wireless Coexistence diff --git a/components/esp_coex/esp32/esp_coex_adapter.c b/components/esp_coex/esp32/esp_coex_adapter.c index d3b297036d..fbd93f6a6a 100644 --- a/components/esp_coex/esp32/esp_coex_adapter.c +++ b/components/esp_coex/esp32/esp_coex_adapter.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -20,6 +20,7 @@ #include "esp_timer.h" #include "private/esp_coexist_adapter.h" #include "esp32/rom/ets_sys.h" +#include "private/esp_coexist_debug.h" #define TAG "esp_coex_adapter" @@ -206,6 +207,15 @@ static int32_t esp_coex_internal_semphr_give_wrapper(void *semphr) return (int32_t)xSemaphoreGive(((modem_static_queue_t *)semphr)->handle); } +static int esp_coexist_debug_matrix_init_wrapper(int evt, int sig, bool rev) +{ +#if CONFIG_ESP_COEX_GPIO_DEBUG + return esp_coexist_debug_matrix_init(evt, sig, rev); +#else + return ESP_ERR_NOT_SUPPORTED; +#endif +} + coex_adapter_funcs_t g_coex_adapter_funcs = { ._version = COEX_ADAPTER_VERSION, ._spin_lock_create = esp_coex_common_spin_lock_create_wrapper, @@ -227,5 +237,6 @@ coex_adapter_funcs_t g_coex_adapter_funcs = { ._timer_done = esp_coex_common_timer_done_wrapper, ._timer_setfn = esp_coex_common_timer_setfn_wrapper, ._timer_arm_us = esp_coex_common_timer_arm_us_wrapper, + ._debug_matrix_init = esp_coexist_debug_matrix_init_wrapper, ._magic = COEX_ADAPTER_MAGIC, }; diff --git a/components/esp_coex/esp32c2/esp_coex_adapter.c b/components/esp_coex/esp32c2/esp_coex_adapter.c index 25805bc7ed..b98c9c9474 100644 --- a/components/esp_coex/esp32c2/esp_coex_adapter.c +++ b/components/esp_coex/esp32c2/esp_coex_adapter.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -22,6 +22,7 @@ #include "esp_private/esp_clk.h" #include "private/esp_coexist_adapter.h" #include "esp32c2/rom/ets_sys.h" +#include "private/esp_coexist_debug.h" #define TAG "esp_coex_adapter" @@ -142,6 +143,20 @@ static int32_t IRAM_ATTR esp_coex_semphr_give_from_isr_wrapper(void *semphr, voi return (int32_t)xSemaphoreGiveFromISR(semphr, hptw); } +static int esp_coexist_debug_matrix_init_wrapper(int evt, int sig, bool rev) +{ +#if CONFIG_ESP_COEX_GPIO_DEBUG + return esp_coexist_debug_matrix_init(evt, sig, rev); +#else + return ESP_ERR_NOT_SUPPORTED; +#endif +} + +static IRAM_ATTR int esp_coex_common_xtal_freq_get_wrapper(void) +{ + return rtc_clk_xtal_freq_get(); +} + coex_adapter_funcs_t g_coex_adapter_funcs = { ._version = COEX_ADAPTER_VERSION, ._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper, @@ -161,5 +176,7 @@ coex_adapter_funcs_t g_coex_adapter_funcs = { ._timer_done = esp_coex_common_timer_done_wrapper, ._timer_setfn = esp_coex_common_timer_setfn_wrapper, ._timer_arm_us = esp_coex_common_timer_arm_us_wrapper, + ._debug_matrix_init = esp_coexist_debug_matrix_init_wrapper, + ._xtal_freq_get = esp_coex_common_xtal_freq_get_wrapper, ._magic = COEX_ADAPTER_MAGIC, }; diff --git a/components/esp_coex/esp32c3/esp_coex_adapter.c b/components/esp_coex/esp32c3/esp_coex_adapter.c index 9dd290e5af..56454a5aaf 100644 --- a/components/esp_coex/esp32c3/esp_coex_adapter.c +++ b/components/esp_coex/esp32c3/esp_coex_adapter.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -23,6 +23,7 @@ #include "private/esp_coexist_adapter.h" #include "esp32c3/rom/ets_sys.h" #include "soc/system_reg.h" +#include "private/esp_coexist_debug.h" #define TAG "esp_coex_adapter" @@ -148,6 +149,15 @@ static int32_t IRAM_ATTR esp_coex_semphr_give_from_isr_wrapper(void *semphr, voi return (int32_t)xSemaphoreGiveFromISR(semphr, hptw); } +static int esp_coexist_debug_matrix_init_wrapper(int evt, int sig, bool rev) +{ +#if CONFIG_ESP_COEX_GPIO_DEBUG + return esp_coexist_debug_matrix_init(evt, sig, rev); +#else + return ESP_ERR_NOT_SUPPORTED; +#endif +} + coex_adapter_funcs_t g_coex_adapter_funcs = { ._version = COEX_ADAPTER_VERSION, ._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper, @@ -165,5 +175,6 @@ coex_adapter_funcs_t g_coex_adapter_funcs = { ._timer_done = esp_coex_common_timer_done_wrapper, ._timer_setfn = esp_coex_common_timer_setfn_wrapper, ._timer_arm_us = esp_coex_common_timer_arm_us_wrapper, + ._debug_matrix_init = esp_coexist_debug_matrix_init_wrapper, ._magic = COEX_ADAPTER_MAGIC, }; diff --git a/components/esp_coex/esp32c6/esp_coex_adapter.c b/components/esp_coex/esp32c6/esp_coex_adapter.c index 1fde5726f8..4b920ce159 100644 --- a/components/esp_coex/esp32c6/esp_coex_adapter.c +++ b/components/esp_coex/esp32c6/esp_coex_adapter.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -22,6 +22,7 @@ #include "esp_private/esp_clk.h" #include "private/esp_coexist_adapter.h" #include "esp32c6/rom/ets_sys.h" +#include "private/esp_coexist_debug.h" #define TAG "esp_coex_adapter" @@ -142,6 +143,20 @@ static int32_t IRAM_ATTR esp_coex_semphr_give_from_isr_wrapper(void *semphr, voi return (int32_t)xSemaphoreGiveFromISR(semphr, hptw); } +static int esp_coexist_debug_matrix_init_wrapper(int evt, int sig, bool rev) +{ +#if CONFIG_ESP_COEX_GPIO_DEBUG + return esp_coexist_debug_matrix_init(evt, sig, rev); +#else + return ESP_ERR_NOT_SUPPORTED; +#endif +} + +static IRAM_ATTR int esp_coex_common_xtal_freq_get_wrapper(void) +{ + return rtc_clk_xtal_freq_get(); +} + coex_adapter_funcs_t g_coex_adapter_funcs = { ._version = COEX_ADAPTER_VERSION, ._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper, @@ -160,5 +175,7 @@ coex_adapter_funcs_t g_coex_adapter_funcs = { ._timer_done = esp_coex_common_timer_done_wrapper, ._timer_setfn = esp_coex_common_timer_setfn_wrapper, ._timer_arm_us = esp_coex_common_timer_arm_us_wrapper, + ._debug_matrix_init = esp_coexist_debug_matrix_init_wrapper, + ._xtal_freq_get = esp_coex_common_xtal_freq_get_wrapper, ._magic = COEX_ADAPTER_MAGIC, }; diff --git a/components/esp_coex/esp32h2/esp_coex_adapter.c b/components/esp_coex/esp32h2/esp_coex_adapter.c index 6cdfdd9bd9..1fa2243ae9 100644 --- a/components/esp_coex/esp32h2/esp_coex_adapter.c +++ b/components/esp_coex/esp32h2/esp_coex_adapter.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -21,7 +21,8 @@ #include "soc/rtc.h" #include "esp_private/esp_clk.h" #include "private/esp_coexist_adapter.h" -#include "esp32c6/rom/ets_sys.h" +#include "esp32h2/rom/ets_sys.h" +#include "private/esp_coexist_debug.h" #define TAG "esp_coex_adapter" @@ -134,6 +135,20 @@ static int32_t IRAM_ATTR esp_coex_semphr_give_from_isr_wrapper(void *semphr, voi return (int32_t)xSemaphoreGiveFromISR(semphr, hptw); } +static int esp_coexist_debug_matrix_init_wrapper(int evt, int sig, bool rev) +{ +#if CONFIG_ESP_COEX_GPIO_DEBUG + return esp_coexist_debug_matrix_init(evt, sig, rev); +#else + return ESP_ERR_NOT_SUPPORTED; +#endif +} + +static IRAM_ATTR int esp_coex_common_xtal_freq_get_wrapper(void) +{ + return rtc_clk_xtal_freq_get(); +} + coex_adapter_funcs_t g_coex_adapter_funcs = { ._version = COEX_ADAPTER_VERSION, ._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper, @@ -152,5 +167,7 @@ coex_adapter_funcs_t g_coex_adapter_funcs = { ._timer_done = esp_coex_common_timer_done_wrapper, ._timer_setfn = esp_coex_common_timer_setfn_wrapper, ._timer_arm_us = esp_coex_common_timer_arm_us_wrapper, + ._debug_matrix_init = esp_coexist_debug_matrix_init_wrapper, + ._xtal_freq_get = esp_coex_common_xtal_freq_get_wrapper, ._magic = COEX_ADAPTER_MAGIC, }; diff --git a/components/esp_coex/esp32s2/esp_coex_adapter.c b/components/esp_coex/esp32s2/esp_coex_adapter.c index c8d50258bf..8611f76c3c 100644 --- a/components/esp_coex/esp32s2/esp_coex_adapter.c +++ b/components/esp_coex/esp32s2/esp_coex_adapter.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -22,6 +22,7 @@ #include "esp_private/esp_clk.h" #include "private/esp_coexist_adapter.h" #include "esp32s2/rom/ets_sys.h" +#include "private/esp_coexist_debug.h" #define TAG "esp_coex_adapter" @@ -216,6 +217,15 @@ static int32_t esp_coex_internal_semphr_give_wrapper(void *semphr) return (int32_t)xSemaphoreGive(((modem_static_queue_t *)semphr)->handle); } +static int esp_coexist_debug_matrix_init_wrapper(int evt, int sig, bool rev) +{ +#if CONFIG_ESP_COEX_GPIO_DEBUG + return esp_coexist_debug_matrix_init(evt, sig, rev); +#else + return ESP_ERR_NOT_SUPPORTED; +#endif +} + coex_adapter_funcs_t g_coex_adapter_funcs = { ._version = COEX_ADAPTER_VERSION, ._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper, @@ -233,5 +243,6 @@ coex_adapter_funcs_t g_coex_adapter_funcs = { ._timer_done = esp_coex_common_timer_done_wrapper, ._timer_setfn = esp_coex_common_timer_setfn_wrapper, ._timer_arm_us = esp_coex_common_timer_arm_us_wrapper, + ._debug_matrix_init = esp_coexist_debug_matrix_init_wrapper, ._magic = COEX_ADAPTER_MAGIC, }; diff --git a/components/esp_coex/esp32s3/esp_coex_adapter.c b/components/esp_coex/esp32s3/esp_coex_adapter.c index 6aa42b1a98..4765b92548 100644 --- a/components/esp_coex/esp32s3/esp_coex_adapter.c +++ b/components/esp_coex/esp32s3/esp_coex_adapter.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -23,6 +23,7 @@ #include "private/esp_coexist_adapter.h" #include "esp32s3/rom/ets_sys.h" #include "soc/system_reg.h" +#include "private/esp_coexist_debug.h" #define TAG "esp_coex_adapter" @@ -222,6 +223,15 @@ static int32_t esp_coex_internal_semphr_give_wrapper(void *semphr) return (int32_t)xSemaphoreGive(((modem_static_queue_t *)semphr)->handle); } +static int esp_coexist_debug_matrix_init_wrapper(int evt, int sig, bool rev) +{ +#if CONFIG_ESP_COEX_GPIO_DEBUG + return esp_coexist_debug_matrix_init(evt, sig, rev); +#else + return ESP_ERR_NOT_SUPPORTED; +#endif +} + coex_adapter_funcs_t g_coex_adapter_funcs = { ._version = COEX_ADAPTER_VERSION, ._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper, @@ -239,5 +249,6 @@ coex_adapter_funcs_t g_coex_adapter_funcs = { ._timer_done = esp_coex_common_timer_done_wrapper, ._timer_setfn = esp_coex_common_timer_setfn_wrapper, ._timer_arm_us = esp_coex_common_timer_arm_us_wrapper, + ._debug_matrix_init = esp_coexist_debug_matrix_init_wrapper, ._magic = COEX_ADAPTER_MAGIC, }; diff --git a/components/esp_coex/include/esp_coex_i154.h b/components/esp_coex/include/esp_coex_i154.h index 942de35613..d601205ebe 100644 --- a/components/esp_coex/include/esp_coex_i154.h +++ b/components/esp_coex/include/esp_coex_i154.h @@ -1,12 +1,11 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #ifndef __COEXIST_I154_H__ #define __COEXIST_I154_H__ -#ifdef CONFIG_SOC_IEEE802154_SUPPORTED typedef enum { IEEE802154_HIGH = 1, IEEE802154_MIDDLE, @@ -15,9 +14,16 @@ typedef enum { IEEE802154_EVENT_MAX, } ieee802154_coex_event_t; +typedef struct { + ieee802154_coex_event_t idle; + ieee802154_coex_event_t txrx; + ieee802154_coex_event_t txrx_at; +} esp_ieee802154_coex_config_t; + void esp_coex_ieee802154_txrx_pti_set(ieee802154_coex_event_t event); void esp_coex_ieee802154_ack_pti_set(ieee802154_coex_event_t event); void esp_coex_ieee802154_coex_break_notify(void); -#endif +void esp_coex_ieee802154_extcoex_tx_stage(void); +void esp_coex_ieee802154_extcoex_rx_stage(void); #endif diff --git a/components/esp_coex/include/esp_coexist.h b/components/esp_coex/include/esp_coexist.h index 63e83dfcd0..5354d741fa 100644 --- a/components/esp_coex/include/esp_coexist.h +++ b/components/esp_coex/include/esp_coexist.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -116,7 +116,7 @@ const char *esp_coex_version_get(void); * @deprecated Use esp_coex_status_bit_set() and esp_coex_status_bit_clear() instead. * Set coexist preference of performance * For example, if prefer to bluetooth, then it will make A2DP(play audio via classic bt) - * more smooth while wifi is runnning something. + * more smooth while wifi is running something. * If prefer to wifi, it will do similar things as prefer to bluetooth. * Default, it prefer to balance. * @@ -164,7 +164,7 @@ esp_err_t esp_enable_extern_coex_gpio_pin(external_coex_wire_t wire_type, * @brief Disable external coex. * @return : ESP_OK - success, other - failed */ -esp_err_t esp_disable_extern_coex_gpio_pin(); +esp_err_t esp_disable_extern_coex_gpio_pin(void); #if SOC_EXTERNAL_COEX_ADVANCE /** @@ -219,6 +219,15 @@ esp_err_t esp_external_coex_set_validate_high(bool is_high_valid); esp_err_t esp_coex_wifi_i154_enable(void); #endif +#if CONFIG_ESP_COEX_GPIO_DEBUG +/** + * @brief Enable coexist GPIO debug. + * To fully enable this feature, make sure functions in rom_funcs are out of ROM. + * @return : ESP_OK - success, other - failed + */ +esp_err_t esp_coexist_debug_init(void); +#endif + #ifdef __cplusplus } #endif diff --git a/components/esp_coex/include/private/esp_coexist_adapter.h b/components/esp_coex/include/private/esp_coexist_adapter.h index 539fd3ec63..15e8ef7114 100644 --- a/components/esp_coex/include/private/esp_coexist_adapter.h +++ b/components/esp_coex/include/private/esp_coexist_adapter.h @@ -46,6 +46,8 @@ typedef struct { void (* _timer_done)(void *ptimer); void (* _timer_setfn)(void *ptimer, void *pfunction, void *parg); void (* _timer_arm_us)(void *ptimer, uint32_t us, bool repeat); + int (* _debug_matrix_init)(int event, int signal, bool rev); + int (* _xtal_freq_get)(void); int32_t _magic; } coex_adapter_funcs_t; diff --git a/components/esp_coex/include/private/esp_coexist_debug.h b/components/esp_coex/include/private/esp_coexist_debug.h new file mode 100644 index 0000000000..80bfbbd5aa --- /dev/null +++ b/components/esp_coex/include/private/esp_coexist_debug.h @@ -0,0 +1,152 @@ +/* + * SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "sdkconfig.h" + +#if CONFIG_ESP_COEX_GPIO_DEBUG +#include "esp_err.h" +#include "stdbool.h" +#include "soc/soc_caps.h" + +#define COEX_GPIO_DEBUG_IO_INVALID SOC_GPIO_PIN_COUNT + +/* Debug signal */ +#define COEX_GPIO_DEBUG_SIG_RES_US 10 +typedef enum { + COEX_GPIO_DEBUG_SIG_POSE, + COEX_GPIO_DEBUG_SIG_NEGA, +} coex_gpio_debug_sig_t; +#define COEX_GPIO_DEBUG_SIG_TO_DURATION(sig) ((sig - COEX_GPIO_DEBUG_SIG_NEGA) * COEX_GPIO_DEBUG_SIG_RES_US) +#define COEX_GPIO_DEBUG_SIG_CHECK_US 100 + +/* User diagram */ +#ifdef CONFIG_ESP_COEX_GPIO_DEBUG_DIAG_GENERAL +#define COEX_GPIO_DEBUG_DIAG_GENERAL 1 +#elif defined(CONFIG_ESP_COEX_GPIO_DEBUG_DIAG_WIFI) +#define COEX_GPIO_DEBUG_DIAG_WIFI 1 +#endif + +/* User configuration validity check */ +#define COEX_GPIO_DEBUG_IO_COUNT_MAX 12 +#define COEX_GPIO_DEBUG_IO_COUNT CONFIG_ESP_COEX_GPIO_DEBUG_IO_COUNT + +#if !defined(CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX0) +#define COEX_GPIO_DEBUG_IO_IDX0 COEX_GPIO_DEBUG_IO_INVALID +#else +#define COEX_GPIO_DEBUG_IO_IDX0 CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX0 +#endif + +#if !defined(CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX1) +#define COEX_GPIO_DEBUG_IO_IDX1 COEX_GPIO_DEBUG_IO_INVALID +#else +#define COEX_GPIO_DEBUG_IO_IDX1 CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX1 +#endif + +#if !defined(CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX2) +#define COEX_GPIO_DEBUG_IO_IDX2 COEX_GPIO_DEBUG_IO_INVALID +#else +#define COEX_GPIO_DEBUG_IO_IDX2 CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX2 +#endif + +#if !defined(CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX3) +#define COEX_GPIO_DEBUG_IO_IDX3 COEX_GPIO_DEBUG_IO_INVALID +#else +#define COEX_GPIO_DEBUG_IO_IDX3 CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX3 +#endif + +#if !defined(CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX4) +#define COEX_GPIO_DEBUG_IO_IDX4 COEX_GPIO_DEBUG_IO_INVALID +#else +#define COEX_GPIO_DEBUG_IO_IDX4 CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX4 +#endif + +#if !defined(CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX5) +#define COEX_GPIO_DEBUG_IO_IDX5 COEX_GPIO_DEBUG_IO_INVALID +#else +#define COEX_GPIO_DEBUG_IO_IDX5 CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX5 +#endif + +#if !defined(CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX6) +#define COEX_GPIO_DEBUG_IO_IDX6 COEX_GPIO_DEBUG_IO_INVALID +#else +#define COEX_GPIO_DEBUG_IO_IDX6 CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX6 +#endif + +#if !defined(CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX7) +#define COEX_GPIO_DEBUG_IO_IDX7 COEX_GPIO_DEBUG_IO_INVALID +#else +#define COEX_GPIO_DEBUG_IO_IDX7 CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX7 +#endif + +#if !defined(CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX8) +#define COEX_GPIO_DEBUG_IO_IDX8 COEX_GPIO_DEBUG_IO_INVALID +#else +#define COEX_GPIO_DEBUG_IO_IDX8 CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX8 +#endif + +#if !defined(CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX9) +#define COEX_GPIO_DEBUG_IO_IDX9 COEX_GPIO_DEBUG_IO_INVALID +#else +#define COEX_GPIO_DEBUG_IO_IDX9 CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX9 +#endif + +#if !defined(CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX10) +#define COEX_GPIO_DEBUG_IO_IDX10 COEX_GPIO_DEBUG_IO_INVALID +#else +#define COEX_GPIO_DEBUG_IO_IDX10 CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX10 +#endif + +#if !defined(CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX11) +#define COEX_GPIO_DEBUG_IO_IDX11 COEX_GPIO_DEBUG_IO_INVALID +#else +#define COEX_GPIO_DEBUG_IO_IDX11 CONFIG_ESP_COEX_GPIO_DEBUG_IO_IDX11 +#endif + +/* wifi callback -> debug */ +void wifi_set_gpio_debug_cb(void (* cb)(int, coex_gpio_debug_sig_t)); +int wifi_gpio_debug_max_event_get(void); + +/* functions to check if in ROM */ +void lmacProcessTxComplete(void); +void lmacTxFrame(void); +void pm_update_by_connectionless_status(void); +void pm_sleep(void); +void pm_dream(void); +void pm_beacon_monitor_timeout_process(void); +void pm_connectionless_wake_window_timeout_process(void); +void pm_coex_schm_process(void); +void pm_tbtt_process(void); +void pm_rx_beacon_process(void); +void ppTask(void); +void wDev_IndicateFrame(void); +void pm_check_state(void); +void pm_tx_null_data_done_process(void); +void pm_start(void); +void pm_stop(void); +void pm_disconnected_wake(void); + +/* coex callback -> debug */ +void coex_set_gpio_debug_cb(void (*cb)(int, coex_gpio_debug_sig_t)); +int coex_gpio_debug_max_event_get(void); +esp_err_t coex_gpio_debug_matrix_init(void); + +/* debug -> coex wrapper */ +esp_err_t esp_coexist_debug_matrix_init(int evt, int sig, bool rev); + +/* debug <-> diagram */ +void wifi_bind_io_to_evt(uint8_t io_idx, uint8_t evt); +void coex_bind_io_to_evt(uint8_t io_idx, uint8_t evt); +void diagram_bind_io_to_evt(void); + +/* coex -> debug + * configure single gpio debug event */ +esp_err_t coex_gpio_debug_matrix_config(int event); +/* debug -> internal use */ +esp_err_t esp_coexist_gpio_debug_matrix_config(int event); + +#endif diff --git a/components/esp_coex/include/private/esp_coexist_internal.h b/components/esp_coex/include/private/esp_coexist_internal.h index 20cea8a437..5eac40b708 100644 --- a/components/esp_coex/include/private/esp_coexist_internal.h +++ b/components/esp_coex/include/private/esp_coexist_internal.h @@ -28,6 +28,16 @@ typedef enum { COEX_SCHM_CALLBACK_TYPE_I154, } coex_schm_callback_type_t; +typedef enum { + COEX_SCHM_ST_TYPE_WIFI = 0, + COEX_SCHM_ST_TYPE_BLE, + COEX_SCHM_ST_TYPE_BT, +} coex_schm_st_type_t; + +#define COEX_STATUS_GET_WIFI_BITMAP (1 << COEX_SCHM_ST_TYPE_WIFI) +#define COEX_STATUS_GET_BLE_BITMAP (1 << COEX_SCHM_ST_TYPE_BLE) +#define COEX_STATUS_GET_BT_BITMAP (1 << COEX_SCHM_ST_TYPE_BT) + typedef void (* coex_func_cb_t)(uint32_t event, int sched_cnt); typedef esp_err_t (* coex_set_lpclk_source_callback_t)(void); typedef void (* coex_wifi_channel_change_cb_t)(uint8_t primary, uint8_t secondary); @@ -94,9 +104,11 @@ esp_err_t coex_preference_set(coex_prefer_t prefer); /** * @brief Get software coexist status. + * + * @param bitmap : bitmap of the module getting status. * @return : software coexist status */ -uint32_t coex_status_get(void); +uint32_t coex_status_get(uint8_t bitmap); /** * @brief WiFi requests coexistence. diff --git a/components/esp_coex/src/coexist.c b/components/esp_coex/src/coexist.c index e5d1477933..f2fade97f7 100644 --- a/components/esp_coex/src/coexist.c +++ b/components/esp_coex/src/coexist.c @@ -1,21 +1,24 @@ /* - * SPDX-FileCopyrightText: 2018-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include "esp_coexist.h" #include "private/esp_coexist_internal.h" +#include "soc/soc_caps.h" #if CONFIG_EXTERNAL_COEX_ENABLE #include "esp_log.h" #include "driver/gpio.h" #include "esp_rom_gpio.h" #include "hal/gpio_hal.h" -#include "hal/gpio_types.h" -#include "soc/gpio_periph.h" -#include "soc/gpio_struct.h" #include "esp_attr.h" +#include "esp_private/gpio.h" +#endif + +#if SOC_MODEM_CLOCK_IS_INDEPENDENT +#include "esp_private/esp_modem_clock.h" #endif #if SOC_EXTERNAL_COEX_ADVANCE @@ -163,9 +166,6 @@ esp_err_t esp_enable_extern_coex_gpio_pin(external_coex_wire_t wire_type, esp_ex return ESP_ERR_INVALID_ARG; } esp_coex_external_set_wire_type(wire_type); -#if SOC_EXTERNAL_COEX_ADVANCE - esp_coex_external_params(g_external_coex_params, 0, 0); -#endif if(EXTERNAL_COEX_LEADER_ROLE == g_external_coex_params.work_mode) { switch (wire_type) @@ -259,14 +259,23 @@ esp_err_t esp_enable_extern_coex_gpio_pin(external_coex_wire_t wire_type, esp_ex return ESP_ERR_INVALID_ARG; #endif /* SOC_EXTERNAL_COEX_ADVANCE */ } +#if SOC_MODEM_CLOCK_IS_INDEPENDENT + modem_clock_module_enable(PERIPH_COEX_MODULE); +#endif +#if SOC_EXTERNAL_COEX_ADVANCE + esp_coex_external_params(g_external_coex_params, 0, 0); +#endif esp_err_t ret = esp_coex_external_set(EXTERN_COEX_PTI_MID, EXTERN_COEX_PTI_MID, EXTERN_COEX_PTI_HIGH); +#if SOC_MODEM_CLOCK_IS_INDEPENDENT + modem_clock_module_disable(PERIPH_COEX_MODULE); +#endif if (ESP_OK != ret) { return ESP_FAIL; } return ESP_OK; } -esp_err_t esp_disable_extern_coex_gpio_pin() +esp_err_t esp_disable_extern_coex_gpio_pin(void) { esp_coex_external_stop(); diff --git a/components/esp_coex/src/coexist_debug.c b/components/esp_coex/src/coexist_debug.c new file mode 100644 index 0000000000..b0cc341313 --- /dev/null +++ b/components/esp_coex/src/coexist_debug.c @@ -0,0 +1,279 @@ +/* + * SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + + +#include "private/esp_coexist_debug.h" + +#include +#include "esp_err.h" +#include "string.h" +#include "esp_attr.h" +#include "esp_log.h" + +#include "rom/ets_sys.h" +#include "driver/gpio.h" +#include "soc/gpio_sig_map.h" +#include "esp_rom_gpio.h" +#include "soc/soc.h" +#if SOC_MODEM_CLOCK_IS_INDEPENDENT +#include "esp_private/esp_modem_clock.h" +#endif + +#if CONFIG_ESP_COEX_GPIO_DEBUG +static char* TAG = "coexist debug"; + +__attribute__((weak)) void wifi_set_gpio_debug_cb(void (* cb)(int, coex_gpio_debug_sig_t)) +{ + ESP_LOGW(TAG, "Not support: %s", __FUNCTION__); +} +__attribute__((weak)) int wifi_gpio_debug_max_event_get(void) +{ + ESP_LOGW(TAG, "Not support: %s", __FUNCTION__); + return 0; +} + +__attribute__((weak)) void coex_set_gpio_debug_cb(void (*cb)(int, coex_gpio_debug_sig_t)) +{ + ESP_LOGW(TAG, "Not support: %s", __FUNCTION__); +} + +__attribute__((weak)) int coex_gpio_debug_max_event_get(void) +{ + ESP_LOGW(TAG, "Not support: %s", __FUNCTION__); + return 0; +} + +__attribute__((weak)) esp_err_t coex_gpio_debug_matrix_init(void) +{ + ESP_LOGW(TAG, "Not support: %s", __FUNCTION__); + return ESP_OK; +} + +/* Check if functions in ROM */ +static const void* rom_funcs[] = { +#if CONFIG_ESP_WIFI_ENABLED + lmacProcessTxComplete, + lmacTxFrame, + pm_update_by_connectionless_status, + pm_sleep, + pm_dream, + pm_beacon_monitor_timeout_process, + pm_connectionless_wake_window_timeout_process, + pm_coex_schm_process, + pm_tbtt_process, + pm_rx_beacon_process, + ppTask, + wDev_IndicateFrame, + pm_check_state, + pm_tx_null_data_done_process, + pm_start, + pm_stop, + pm_disconnected_wake, +#endif +}; +static const char* rom_funcs_name[] = { +#if CONFIG_ESP_WIFI_ENABLED + "lmacProcessTxComplete", + "lmacTxframe", + "pm_update_by_connectionless_status", + "pm_sleep", + "pm_dream", + "pm_beacon_monitor_timeout_process", + "pm_connectionless_wake_window_timeout_process", + "pm_coex_schm_process", + "pm_tbtt_process", + "pm_rx_beacon_process", + "ppTask", + "wDev_IndicateFrame", + "pm_check_state", + "pm_tx_null_data_done_process", + "pm_start", + "pm_stop", + "pm_disconnected_wake", +#endif +}; + +static bool check_funcs_in_rom(void) +{ + bool in_rom = false; + for (uint8_t i = 0; i < sizeof(rom_funcs) / sizeof(void*); i++) { + if ((uint32_t)rom_funcs[i] >= SOC_IROM_MASK_LOW && (uint32_t)rom_funcs[i] <= SOC_IROM_MASK_HIGH) { + ESP_LOGE(TAG, "remove function from ROM: %s", rom_funcs_name[i]); + in_rom = true; + } + } + return in_rom; +} + +/* Define used IO nums */ +static const DRAM_ATTR gpio_num_t s_io_nums[COEX_GPIO_DEBUG_IO_COUNT_MAX] = { + COEX_GPIO_DEBUG_IO_IDX0, + COEX_GPIO_DEBUG_IO_IDX1, + COEX_GPIO_DEBUG_IO_IDX2, + COEX_GPIO_DEBUG_IO_IDX3, + COEX_GPIO_DEBUG_IO_IDX4, + COEX_GPIO_DEBUG_IO_IDX5, + COEX_GPIO_DEBUG_IO_IDX6, + COEX_GPIO_DEBUG_IO_IDX7, + COEX_GPIO_DEBUG_IO_IDX8, + COEX_GPIO_DEBUG_IO_IDX9, + COEX_GPIO_DEBUG_IO_IDX10, + COEX_GPIO_DEBUG_IO_IDX11, +}; + +/* Mapping from evt to IO */ +static DRAM_ATTR gpio_num_t *s_evt_io_map, *s_wifi_evt_io_map, *s_coex_evt_io_map; +static DRAM_ATTR uint8_t s_wifi_evt_max, s_coex_evt_max; + +inline static void bind_io_to_evt(gpio_num_t *ptrmap, uint8_t io, uint8_t evt) +{ + ptrmap[evt] = io; +} + +inline static void evt_set_signal(gpio_num_t io, coex_gpio_debug_sig_t sig) +{ + if (sig == COEX_GPIO_DEBUG_SIG_POSE) { + gpio_set_level(io, true); + } else if (sig == COEX_GPIO_DEBUG_SIG_NEGA) { + gpio_set_level(io, false); + } else { + gpio_set_level(io, true); + esp_rom_delay_us(COEX_GPIO_DEBUG_SIG_TO_DURATION(sig)); + gpio_set_level(io, false); + } +} + +void wifi_bind_io_to_evt(uint8_t io_idx, uint8_t evt) +{ + if (!s_wifi_evt_io_map || evt >= s_wifi_evt_max || io_idx >= COEX_GPIO_DEBUG_IO_COUNT) { + return; + } + ESP_LOGI(TAG, "Bind IO %u to Wi-Fi evt %u", s_io_nums[io_idx], evt); + bind_io_to_evt(s_wifi_evt_io_map, s_io_nums[io_idx], evt); +} + +void coex_bind_io_to_evt(uint8_t io_idx, uint8_t evt) +{ + if (!s_coex_evt_io_map || evt >= s_coex_evt_max || io_idx >= COEX_GPIO_DEBUG_IO_COUNT) { + return; + } + ESP_LOGI(TAG, "Bind IO %u to coexist evt %u", s_io_nums[io_idx], evt); + bind_io_to_evt(s_coex_evt_io_map, s_io_nums[io_idx], evt); +} + +IRAM_ATTR void wifi_set_gpio_debug(int evt, coex_gpio_debug_sig_t sig) +{ + if (evt >= s_wifi_evt_max || s_wifi_evt_io_map[evt] == COEX_GPIO_DEBUG_IO_INVALID) { + return; + } + evt_set_signal(s_wifi_evt_io_map[evt], sig); +} + +IRAM_ATTR void coex_set_gpio_debug(int evt, coex_gpio_debug_sig_t sig) +{ + if (evt >= s_coex_evt_max || s_coex_evt_io_map[evt] == COEX_GPIO_DEBUG_IO_INVALID) { + return; + } + evt_set_signal(s_coex_evt_io_map[evt], sig); +} + +esp_err_t esp_coexist_debug_matrix_init(int evt, int sig, bool rev) +{ + if (evt >= s_coex_evt_max || s_coex_evt_io_map[evt] == COEX_GPIO_DEBUG_IO_INVALID) { + return ESP_ERR_INVALID_ARG; + } + esp_rom_gpio_connect_out_signal(s_coex_evt_io_map[evt], sig, rev, false); + return ESP_OK; +} + +esp_err_t esp_coexist_gpio_debug_matrix_config(int event) +{ +#if SOC_MODEM_CLOCK_IS_INDEPENDENT + modem_clock_module_enable(PERIPH_COEX_MODULE); +#endif + esp_err_t ret = coex_gpio_debug_matrix_config(event); +#if SOC_MODEM_CLOCK_IS_INDEPENDENT + modem_clock_module_disable(PERIPH_COEX_MODULE); +#endif + return ret; +} + +esp_err_t esp_coexist_debug_init(void) +{ + if (check_funcs_in_rom()) { + return ESP_ERR_INVALID_STATE; + } + + s_wifi_evt_max = wifi_gpio_debug_max_event_get(); + s_coex_evt_max = coex_gpio_debug_max_event_get(); + uint8_t evt_max = s_wifi_evt_max + s_coex_evt_max; + if (evt_max == 0) { + return ESP_ERR_NOT_SUPPORTED; + } + + /* Allocate binding map */ + s_evt_io_map = malloc(sizeof(gpio_num_t) * evt_max); + if (!s_evt_io_map) { + return ESP_ERR_NO_MEM; + } + /* Init to invalid IO num */ + for (uint8_t i = 0; i < evt_max; i++) { + s_evt_io_map[i] = COEX_GPIO_DEBUG_IO_INVALID; + } + s_wifi_evt_io_map = s_evt_io_map; + s_coex_evt_io_map = s_evt_io_map + s_wifi_evt_max; + + /* binding map configuration */ + diagram_bind_io_to_evt(); + + /* Register callback for Wi-Fi evt */ + wifi_set_gpio_debug_cb(wifi_set_gpio_debug); + + /* Register callback for coexist evt */ + coex_set_gpio_debug_cb(coex_set_gpio_debug); + + /* IO init and validity check */ + gpio_config_t io_conf = { + //disable interrupt + .intr_type = GPIO_INTR_DISABLE, + //set as output mode + .mode = GPIO_MODE_OUTPUT, + //bit mask of the pins that you want to set,e.g.GPIO18/19 + .pin_bit_mask = 0, + //disable pull-down mode + .pull_down_en = GPIO_PULLDOWN_DISABLE, + //enable pull-up mode + .pull_up_en = GPIO_PULLUP_ENABLE, + }; + + for (uint8_t i = 0; i < COEX_GPIO_DEBUG_IO_COUNT; i++) { + gpio_num_t io = s_io_nums[i]; + io_conf.pin_bit_mask = (1ULL << io); + gpio_config(&io_conf); + gpio_set_level(io, 0); + } + esp_rom_delay_us(COEX_GPIO_DEBUG_SIG_CHECK_US); + for (uint8_t i = 0; i < COEX_GPIO_DEBUG_IO_COUNT; i++) { + gpio_set_level(s_io_nums[i], true); + } + esp_rom_delay_us(COEX_GPIO_DEBUG_SIG_CHECK_US); + for (uint8_t i = 0; i < COEX_GPIO_DEBUG_IO_COUNT; i++) { + gpio_set_level(s_io_nums[i], false); + } + +#if SOC_MODEM_CLOCK_IS_INDEPENDENT + modem_clock_module_enable(PERIPH_COEX_MODULE); +#endif + /* Init coexist hardware signal */ + ESP_ERROR_CHECK(coex_gpio_debug_matrix_init()); +#if SOC_MODEM_CLOCK_IS_INDEPENDENT + modem_clock_module_disable(PERIPH_COEX_MODULE); +#endif + + return ESP_OK; +} + +#endif diff --git a/components/esp_coex/src/coexist_debug_diagram.c b/components/esp_coex/src/coexist_debug_diagram.c new file mode 100644 index 0000000000..ed2fd1c88e --- /dev/null +++ b/components/esp_coex/src/coexist_debug_diagram.c @@ -0,0 +1,59 @@ +/* + * SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "private/esp_coexist_debug.h" + +#if CONFIG_ESP_COEX_GPIO_DEBUG +#ifdef COEX_GPIO_DEBUG_DIAG_GENERAL +void diagram_bind_io_to_evt(void) { + /* Bind IO to coexist evt */ +#if CONFIG_IDF_TARGET_ESP32 + coex_bind_io_to_evt(0, 8); + coex_bind_io_to_evt(0, 11); + coex_bind_io_to_evt(1, 16); +#else + coex_bind_io_to_evt(0, 0); + coex_bind_io_to_evt(1, 1); +#endif + /* Bind IO to Wi-Fi evt */ + wifi_bind_io_to_evt(2, 9); + wifi_bind_io_to_evt(3, 10); + wifi_bind_io_to_evt(4, 11); + + wifi_bind_io_to_evt(5, 0); + wifi_bind_io_to_evt(6, 1); +} +#elif defined(COEX_GPIO_DEBUG_DIAG_WIFI) +void diagram_bind_io_to_evt(void) { + /* Bind IO to coexist evt */ +#if CONFIG_IDF_TARGET_ESP32 + coex_bind_io_to_evt(0, 8); + coex_bind_io_to_evt(0, 11); + coex_bind_io_to_evt(1, 16); +#else + coex_bind_io_to_evt(0, 0); + coex_bind_io_to_evt(1, 1); +#endif + /* Bind IO to Wi-Fi evt */ + wifi_bind_io_to_evt(2, 9); + wifi_bind_io_to_evt(3, 10); + wifi_bind_io_to_evt(4, 11); + + wifi_bind_io_to_evt(5, 0); + wifi_bind_io_to_evt(6, 1); + + wifi_bind_io_to_evt(7, 3); + wifi_bind_io_to_evt(8, 4); + wifi_bind_io_to_evt(9, 5); + wifi_bind_io_to_evt(10, 6); + wifi_bind_io_to_evt(11, 7); +} +#else +void diagram_bind_io_to_evt(void) { +} +#endif + +#endif diff --git a/components/esp_coex/test_md5/test_md5.sh b/components/esp_coex/test_md5/test_md5.sh index 65a32ebb49..299b5798a2 100755 --- a/components/esp_coex/test_md5/test_md5.sh +++ b/components/esp_coex/test_md5/test_md5.sh @@ -32,40 +32,74 @@ case $IDF_TARGET in esac LIB_DIR=${IDF_TARGET} -ELF_FILE=test.elf +COEX_ELF_FILE=coex.elf +TEST_ELF_FILE=test.elf FAILURES=0 function check_md5() +{ + if [ "$1" != "$2" ]; then + echo " error: MD5 mismatch!" + FAILURES=$(($FAILURES+1)) + fi +} + +function check_md5_file_lib() { FILENAME=$1 SYMBOL=$2 - ${PREFIX}ld --unresolved-symbols=ignore-all --entry 0 -o ${ELF_FILE} \ + ${PREFIX}ld --unresolved-symbols=ignore-all --entry 0 -o ${COEX_ELF_FILE} \ -u ${SYMBOL} \ ${IDF_PATH}/components/esp_coex/lib/${LIB_DIR}/*.a GDB_COMMAND="printf \"%s\\n\", (const char*) ${SYMBOL}" - MD5_FROM_LIB=$(${PREFIX}gdb -n -batch ${ELF_FILE} -ex "${GDB_COMMAND}") + MD5_FROM_LIB=$(${PREFIX}gdb -n -batch ${COEX_ELF_FILE} -ex "${GDB_COMMAND}") MD5_FROM_HEADER=$(md5sum ${FILENAME} | cut -c 1-7) - echo "Checking ${FILENAME}:" echo " ${MD5_FROM_HEADER} - from header file" echo " ${MD5_FROM_LIB} - from library" - if [ "${MD5_FROM_LIB}" != "${MD5_FROM_HEADER}" ]; then - echo " error: MD5 mismatch!" - FAILURES=$(($FAILURES+1)) - fi + check_md5 ${MD5_FROM_HEADER} ${MD5_FROM_LIB} +} + +function check_md5_libs() +{ + COEX_SYMBOL=$1 + TEST_SYMBOL=$2 + TEST_PATH=$3 + + ${PREFIX}ld --unresolved-symbols=ignore-all --entry 0 -o ${COEX_ELF_FILE} \ + -u ${COEX_SYMBOL} \ + ${IDF_PATH}/components/esp_coex/lib/${LIB_DIR}/*.a + + ${PREFIX}ld --unresolved-symbols=ignore-all --entry 0 -o ${TEST_ELF_FILE} \ + -u ${TEST_SYMBOL} \ + ${TEST_PATH}/*.a + + COEX_GDB_COMMAND="printf \"%s\\n\", (const char*) ${COEX_SYMBOL}" + TEST_GDB_COMMAND="printf \"%s\\n\", (const char*) ${TEST_SYMBOL}" + COEX_MD5_FROM_LIB=$(${PREFIX}gdb -n -batch ${COEX_ELF_FILE} -ex "${COEX_GDB_COMMAND}") + TEST_MD5_FROM_LIB=$(${PREFIX}gdb -n -batch ${TEST_ELF_FILE} -ex "${TEST_GDB_COMMAND}") + + echo "Checking ${TEST_PATH}/${TEST_SYMBOL} " + echo " ${COEX_MD5_FROM_LIB} - from coexist library" + echo " ${TEST_MD5_FROM_LIB} - from test library" + check_md5 ${COEX_MD5_FROM_LIB} ${TEST_MD5_FROM_LIB} } echo "Checking libraries for target ${IDF_TARGET}..." -check_md5 ${IDF_PATH}/components/esp_coex/include/private/esp_coexist_adapter.h g_coex_adapter_funcs_md5 +check_md5_file_lib ${IDF_PATH}/components/esp_coex/include/private/esp_coexist_adapter.h g_coex_adapter_funcs_md5 case $IDF_TARGET in esp32c6|esp32h2) - check_md5 ${IDF_PATH}/components/esp_coex/include/esp_coex_i154.h g_coex_i154_funcs_md5 + check_md5_file_lib ${IDF_PATH}/components/esp_coex/include/esp_coex_i154.h g_coex_i154_funcs_md5 ;; esac +if [[ ! "$IDF_TARGET" =~ ^(esp32h2)$ ]]; then + check_md5_libs g_coex_basic_md5 g_wifi_coex_basic_md5 ${IDF_PATH}/components/esp_wifi/lib/${LIB_DIR} +fi + if [ $FAILURES -gt 0 ]; then exit 1 fi diff --git a/components/esp_common/.build-test-rules.yml b/components/esp_common/.build-test-rules.yml index 04fd48936f..c52d810e15 100644 --- a/components/esp_common/.build-test-rules.yml +++ b/components/esp_common/.build-test-rules.yml @@ -3,3 +3,4 @@ components/esp_common/test_apps/esp_common: disable: - if: CONFIG_NAME == "psram" and SOC_SPIRAM_SUPPORTED != 1 + - if: CONFIG_NAME == "psram_noinit" and SOC_SPIRAM_SUPPORTED != 1 diff --git a/components/esp_common/include/esp_idf_version.h b/components/esp_common/include/esp_idf_version.h index 7aa122ac1f..cdfbdbc360 100644 --- a/components/esp_common/include/esp_idf_version.h +++ b/components/esp_common/include/esp_idf_version.h @@ -15,7 +15,7 @@ extern "C" { /** Minor version number (x.X.x) */ #define ESP_IDF_VERSION_MINOR 1 /** Patch version number (x.x.X) */ -#define ESP_IDF_VERSION_PATCH 4 +#define ESP_IDF_VERSION_PATCH 5 /** * Macro to convert IDF version number into an integer diff --git a/components/esp_common/test_apps/esp_common/main/CMakeLists.txt b/components/esp_common/test_apps/esp_common/main/CMakeLists.txt index 44a5ed32a2..d1e953e638 100644 --- a/components/esp_common/test_apps/esp_common/main/CMakeLists.txt +++ b/components/esp_common/test_apps/esp_common/main/CMakeLists.txt @@ -1,4 +1,4 @@ idf_component_register(SRCS "test_app_main.c" "test_attr.c" INCLUDE_DIRS "." - PRIV_REQUIRES unity esp_psram + PRIV_REQUIRES unity esp_mm esp_psram WHOLE_ARCHIVE) diff --git a/components/esp_common/test_apps/esp_common/main/test_attr.c b/components/esp_common/test_apps/esp_common/main/test_attr.c index 6b1d7520a2..563e6079bb 100644 --- a/components/esp_common/test_apps/esp_common/main/test_attr.c +++ b/components/esp_common/test_apps/esp_common/main/test_attr.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -10,10 +10,17 @@ #include "esp_log.h" #include "soc/soc.h" #include "esp_system.h" +#include "hal/cache_ll.h" +#include "hal/cache_hal.h" +#include "esp_cache.h" #if CONFIG_IDF_TARGET_ESP32 #include "esp_private/esp_psram_extram.h" #endif +#define ALIGN_UP(num, align) (((num) + ((align) - 1)) & ~((align) - 1)) + +static const char *TAG = "attr_test"; + extern int _rtc_noinit_start; extern int _rtc_noinit_end; extern int _rtc_data_start; @@ -45,6 +52,7 @@ static EXT_RAM_NOINIT_ATTR uint32_t s_noinit_ext; static bool data_in_segment(void *ptr, int *seg_start, int *seg_end) { + ESP_LOGV(TAG, "ptr:%p seg_start:%p seg_end:%p", ptr, seg_start, seg_end); return ((intptr_t)ptr < (intptr_t)seg_end) && \ ((intptr_t)ptr >= (intptr_t)seg_start); } @@ -95,7 +103,13 @@ static void write_spiram_and_reset(void) } printf("Flushing cache\n"); // Flush the cache out to SPIRAM before resetting. +#if CONFIG_IDF_TARGET_ESP32 esp_psram_extram_writeback_cache(); +#else + size_t psram_alignment = cache_hal_get_cache_line_size(CACHE_TYPE_DATA); + uint32_t ext_noinit_size = sizeof(s_noinit_buffer); + TEST_ESP_OK(esp_cache_msync(&s_noinit_buffer, ALIGN_UP(ext_noinit_size, psram_alignment), 0)); +#endif printf("Restarting\n"); // Reset to test that noinit memory is left intact. diff --git a/components/esp_common/test_apps/esp_common/pytest_esp_common.py b/components/esp_common/test_apps/esp_common/pytest_esp_common.py index 983220995f..a22484686f 100644 --- a/components/esp_common/test_apps/esp_common/pytest_esp_common.py +++ b/components/esp_common/test_apps/esp_common/pytest_esp_common.py @@ -1,5 +1,6 @@ -# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: CC0-1.0 +from typing import Any import pytest from pytest_embedded import Dut @@ -20,6 +21,8 @@ def test_esp_common(dut: Dut) -> None: # psram noinit attr tests with psram enabled @pytest.mark.esp32 +@pytest.mark.esp32s2 +@pytest.mark.esp32s3 @pytest.mark.generic @pytest.mark.parametrize( 'config', @@ -34,8 +37,9 @@ def test_esp_attr_psram_noinit(dut: Dut) -> None: # psram noinit memory tests with psram enabled @pytest.mark.esp32 +@pytest.mark.esp32s2 +@pytest.mark.esp32s3 @pytest.mark.generic -@pytest.mark.supported_targets @pytest.mark.parametrize( 'config', [ @@ -43,8 +47,8 @@ def test_esp_attr_psram_noinit(dut: Dut) -> None: ], indirect=True, ) -def run_multiple_stages(dut: Dut, test_case_num: int, stages: int) -> None: - dut.run_all_single_board_cases() +def test_esp_attr_psram_noinit_multiple_stages(case_tester: Any) -> None: + case_tester.run_all_multi_stage_cases() # psram attr tests with psram enabled diff --git a/components/esp_common/test_apps/esp_common/sdkconfig.ci.psram_noinit b/components/esp_common/test_apps/esp_common/sdkconfig.ci.psram_noinit index b3e109b8af..dbbc267982 100644 --- a/components/esp_common/test_apps/esp_common/sdkconfig.ci.psram_noinit +++ b/components/esp_common/test_apps/esp_common/sdkconfig.ci.psram_noinit @@ -1,6 +1,5 @@ # For EXT_RAM_NOINIT_ATTR -CONFIG_IDF_TARGET="esp32" CONFIG_SPIRAM=y CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY=y CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y diff --git a/components/esp_common/test_apps/esp_common/sdkconfig.ci.xip_psram_esp32s2 b/components/esp_common/test_apps/esp_common/sdkconfig.ci.xip_psram_esp32s2 index 0e7812b975..fd9b7e865c 100644 --- a/components/esp_common/test_apps/esp_common/sdkconfig.ci.xip_psram_esp32s2 +++ b/components/esp_common/test_apps/esp_common/sdkconfig.ci.xip_psram_esp32s2 @@ -3,5 +3,6 @@ CONFIG_IDF_TARGET="esp32s2" CONFIG_SPIRAM=y CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y +CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY=y CONFIG_SPIRAM_RODATA=y CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y diff --git a/components/esp_common/test_apps/esp_common/sdkconfig.ci.xip_psram_esp32s3 b/components/esp_common/test_apps/esp_common/sdkconfig.ci.xip_psram_esp32s3 index b774ddf1fd..3b1db1f233 100644 --- a/components/esp_common/test_apps/esp_common/sdkconfig.ci.xip_psram_esp32s3 +++ b/components/esp_common/test_apps/esp_common/sdkconfig.ci.xip_psram_esp32s3 @@ -3,5 +3,6 @@ CONFIG_IDF_TARGET="esp32s3" CONFIG_SPIRAM=y CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y +CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY=y CONFIG_SPIRAM_RODATA=y CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y diff --git a/components/esp_hw_support/CMakeLists.txt b/components/esp_hw_support/CMakeLists.txt index b29f78b068..f3f2c853a1 100644 --- a/components/esp_hw_support/CMakeLists.txt +++ b/components/esp_hw_support/CMakeLists.txt @@ -16,6 +16,10 @@ if(${target} STREQUAL "esp32c6") list(APPEND priv_requires hal) endif() +if(CONFIG_RTC_CLK_SRC_INT_RC32K) + message(WARNING "Internal RC32K clock is unstable at extreme temperatures and is not recommended for use.") +endif() + set(srcs "cpu.c" "port/${IDF_TARGET}/esp_cpu_intr.c" "esp_memory_utils.c" "port/${IDF_TARGET}/cpu_region_protect.c") if(NOT BOOTLOADER_BUILD) list(APPEND srcs "esp_clk.c" diff --git a/components/esp_hw_support/dma/gdma_sleep_retention.c b/components/esp_hw_support/dma/gdma_sleep_retention.c index 2b818c33ba..e39f641403 100644 --- a/components/esp_hw_support/dma/gdma_sleep_retention.c +++ b/components/esp_hw_support/dma/gdma_sleep_retention.c @@ -43,7 +43,7 @@ static esp_err_t sleep_gdma_channel_retention_init(void *arg) int pair_id = parg->pair_id; sleep_retention_module_bitmap_t module = GDMA_CH_RETENTION_GET_MODULE_ID(group_id, pair_id); - esp_err_t err = sleep_retention_entries_create(gdma_chx_regs_retention[group_id][pair_id].link_list, gdma_chx_regs_retention[group_id][pair_id].link_num, REGDMA_LINK_PRI_7, module); + esp_err_t err = sleep_retention_entries_create(gdma_chx_regs_retention[group_id][pair_id].link_list, gdma_chx_regs_retention[group_id][pair_id].link_num, REGDMA_LINK_PRI_GDMA, module); if (err == ESP_OK) { ESP_LOGD(TAG, "GDMA pair (%d, %d) retention initialization", group_id, pair_id); } diff --git a/components/esp_hw_support/include/esp_private/esp_modem_clock.h b/components/esp_hw_support/include/esp_private/esp_modem_clock.h index a09d450ac3..b048442fc0 100644 --- a/components/esp_hw_support/include/esp_private/esp_modem_clock.h +++ b/components/esp_hw_support/include/esp_private/esp_modem_clock.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -107,9 +107,15 @@ void modem_clock_select_lp_clock_source(periph_module_t module, modem_clock_lpcl /** * @brief Disable lowpower clock source selection + * @param module modem module */ void modem_clock_deselect_lp_clock_source(periph_module_t module); +/** +* @brief Disable all modem module's lowpower clock source selection + */ +void modem_clock_deselect_all_module_lp_clock_source(void); + /** * @brief Reset wifi mac */ diff --git a/components/esp_hw_support/include/esp_private/esp_regdma.h b/components/esp_hw_support/include/esp_private/esp_regdma.h index aaf8039ed3..6fb4846c1e 100644 --- a/components/esp_hw_support/include/esp_private/esp_regdma.h +++ b/components/esp_hw_support/include/esp_private/esp_regdma.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -67,6 +67,17 @@ typedef enum regdma_link_mode { } regdma_link_mode_t; +#define REGDMA_LINK_PRI_SYS_CLK REGDMA_LINK_PRI_0 +#define REGDMA_LINK_PRI_MODEM_CLK REGDMA_LINK_PRI_1 +#define REGDMA_LINK_PRI_CRITICAL_TEE_APM REGDMA_LINK_PRI_2 +#define REGDMA_LINK_PRI_WIFI_MAC_BB REGDMA_LINK_PRI_3 +#define REGDMA_LINK_PRI_NON_CRITICAL_TEE_APM REGDMA_LINK_PRI_4 +#define REGDMA_LINK_PRI_BT_MAC_BB REGDMA_LINK_PRI_5 +#define REGDMA_LINK_PRI_SYS_PERIPH_HIGH REGDMA_LINK_PRI_5 // INT_MTX & HP_SYSTEM & Console UART +#define REGDMA_LINK_PRI_SYS_PERIPH_LOW REGDMA_LINK_PRI_6 // TG0 & IO MUX & SPI MEM & Systimer +#define REGDMA_LINK_PRI_IEEE802154 REGDMA_LINK_PRI_7 +#define REGDMA_LINK_PRI_GDMA REGDMA_LINK_PRI_7 + typedef struct regdma_link_head { volatile uint32_t length: 10, /* total count of registers that need to be backup or restore, unit: 1 word = 4 bytes */ reserve0: 6, @@ -519,6 +530,13 @@ void *regdma_link_new_branch_wait_default(void *backup, uint32_t value, uint32_t */ void *regdma_link_init(const regdma_link_config_t *config, bool branch, uint32_t module, int nentry, ...); +/** + * @brief Get REGDMA linked list node mode through configuration parameters + * @param config REGDMA linked node configuration parameters + * @return REGDMA linked list node mode + */ +regdma_link_mode_t regdma_link_get_config_mode(const regdma_link_config_t *config); + /** * @brief Recurse the REGDMA linked list and call the hook subroutine for each node * @param link The REGDMA linkded list head pointer diff --git a/components/esp_hw_support/include/esp_private/rtc_clk.h b/components/esp_hw_support/include/esp_private/rtc_clk.h index 17c1a939b6..a94f057702 100644 --- a/components/esp_hw_support/include/esp_private/rtc_clk.h +++ b/components/esp_hw_support/include/esp_private/rtc_clk.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -16,8 +16,8 @@ extern "C" { * @brief Switch CPU clock source to XTAL, and let cpu frequency equal to main XTAL frequency. * * This function does not disable BBPLL. If BBPLL requires to be disabled to save power, please call - * `rtc_clk_cpu_freq_set_xtal` instead. It does one extra check to see whether can disable the BBPLL after switching the - * CPU clock source to XTAL. + * `rtc_clk_cpu_freq_set_xtal` instead. It will always disable the corresponding PLL after switching the CPU clock + * source to XTAL (except for S2). * * Currently, this function should only be called in `esp_restart_noos` and `esp_restart_noos_dig` to switch the CPU * clock source back to XTAL (by default) before reset. @@ -30,12 +30,6 @@ void rtc_clk_cpu_set_to_default_config(void); * Currently, this function is only used for tracking whether USB Serial/JTAG is using the 48MHz PHY clock * * Note: Calling this function only helps to not disable the BBPLL clock in `rtc_clk_cpu_freq_set_config`. - * For light and deep sleep, whether to disable the BBPLL in the interal call to `rtc_clk_cpu_freq_set_xtal` - * varies for targets. - * On ESP32C3/S3, USB CDC device can not function properly during sleep due to the lack of APB clock. Therefore. - * `rtc_clk_cpu_freq_set_xtal` will always disable BBPLL, no matter whether BBPLL has any consumer. - * On ESP32C6/H2, USB CDC device can maintain the minimum connection with the host during sleep, so - * `rtc_clk_cpu_freq_set_xtal` will check for BBPLL consumers, and keep BBPLL if USB Serial/JTAG is in use. */ void rtc_clk_bbpll_add_consumer(void); @@ -44,12 +38,6 @@ void rtc_clk_bbpll_add_consumer(void); */ void rtc_clk_bbpll_remove_consumer(void); -/** - * @brief Workaround for C2, S3, C6, H2. Trigger the calibration of PLL. Should be called when the bootloader doesn't provide a good enough PLL accuracy. -*/ -void rtc_clk_recalib_bbpll(void); - - #ifdef __cplusplus } #endif diff --git a/components/esp_hw_support/modem_clock.c b/components/esp_hw_support/modem_clock.c index 0b2a9482c7..d89db5fc2f 100644 --- a/components/esp_hw_support/modem_clock.c +++ b/components/esp_hw_support/modem_clock.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -340,6 +340,17 @@ void IRAM_ATTR modem_clock_module_disable(periph_module_t module) modem_clock_device_disable(MODEM_CLOCK_instance(), deps); } +void modem_clock_deselect_all_module_lp_clock_source(void) +{ +#if SOC_WIFI_SUPPORTED + modem_clock_hal_deselect_all_wifi_lpclk_source(MODEM_CLOCK_instance()->hal); +#endif +#if SOC_BT_SUPPORTED + modem_clock_hal_deselect_all_ble_rtc_timer_lpclk_source(MODEM_CLOCK_instance()->hal); +#endif + modem_clock_hal_deselect_all_coex_lpclk_source(MODEM_CLOCK_instance()->hal); +} + void modem_clock_select_lp_clock_source(periph_module_t module, modem_clock_lpclk_src_t src, uint32_t divider) { assert(IS_MODEM_MODULE(module)); diff --git a/components/esp_hw_support/port/esp32c2/Kconfig.hw_support b/components/esp_hw_support/port/esp32c2/Kconfig.hw_support index e5c05941ae..59107a9442 100644 --- a/components/esp_hw_support/port/esp32c2/Kconfig.hw_support +++ b/components/esp_hw_support/port/esp32c2/Kconfig.hw_support @@ -13,12 +13,15 @@ choice ESP32C2_REV_MIN bool "Rev v1.0 (ECO1)" config ESP32C2_REV_MIN_1_1 bool "Rev v1.1 (ECO2)" + config ESP32C2_REV_MIN_200 + bool "Rev v2.0 (ECO4)" endchoice config ESP32C2_REV_MIN_FULL int default 100 if ESP32C2_REV_MIN_1 default 101 if ESP32C2_REV_MIN_1_1 + default 200 if ESP32C2_REV_MIN_200 config ESP_REV_MIN_FULL int diff --git a/components/esp_hw_support/port/esp32c2/rtc_clk.c b/components/esp_hw_support/port/esp32c2/rtc_clk.c index 2501c2f6df..a494daba47 100644 --- a/components/esp_hw_support/port/esp32c2/rtc_clk.c +++ b/components/esp_hw_support/port/esp32c2/rtc_clk.c @@ -358,24 +358,6 @@ bool rtc_dig_8m_enabled(void) return clk_ll_rc_fast_digi_is_enabled(); } -// Workaround for bootloader not calibrated well issue. -// Placed in IRAM because disabling BBPLL may influence the cache -void rtc_clk_recalib_bbpll(void) -{ - rtc_cpu_freq_config_t old_config; - rtc_clk_cpu_freq_get_config(&old_config); - - // There are two paths we arrive here: 1. CPU reset. 2. Other reset reasons. - // - For other reasons, the bootloader will set CPU source to BBPLL and enable it. But there are calibration issues. - // Turn off the BBPLL and do calibration again to fix the issue. - // - For CPU reset, the CPU source will be set to XTAL, while the BBPLL is kept to meet USB Serial JTAG's - // requirements. In this case, we don't touch BBPLL to avoid USJ disconnection. - if (old_config.source == SOC_CPU_CLK_SRC_PLL) { - rtc_clk_cpu_freq_set_xtal(); - rtc_clk_cpu_freq_set_config(&old_config); - } -} - /* Name used in libphy.a:phy_chip_v7.o * TODO: update the library to use rtc_clk_xtal_freq_get */ diff --git a/components/esp_hw_support/port/esp32c3/rtc_clk.c b/components/esp_hw_support/port/esp32c3/rtc_clk.c index ea8881f088..b505f7bf17 100644 --- a/components/esp_hw_support/port/esp32c3/rtc_clk.c +++ b/components/esp_hw_support/port/esp32c3/rtc_clk.c @@ -12,6 +12,7 @@ #include "sdkconfig.h" #include "esp32c3/rom/rtc.h" #include "soc/rtc.h" +#include "soc/io_mux_reg.h" #include "esp_private/rtc_clk.h" #include "esp_hw_log.h" #include "esp_rom_sys.h" @@ -49,6 +50,8 @@ void rtc_clk_32k_enable(bool enable) void rtc_clk_32k_enable_external(void) { + PIN_INPUT_ENABLE(IO_MUX_GPIO0_REG); + SET_PERI_REG_MASK(RTC_CNTL_PAD_HOLD_REG, RTC_CNTL_GPIO_PIN0_HOLD); clk_ll_xtal32k_enable(CLK_LL_XTAL32K_ENABLE_MODE_EXTERNAL); } diff --git a/components/esp_hw_support/port/esp32c6/Kconfig.rtc b/components/esp_hw_support/port/esp32c6/Kconfig.rtc index 24a5b8fb94..0b7c9dc517 100644 --- a/components/esp_hw_support/port/esp32c6/Kconfig.rtc +++ b/components/esp_hw_support/port/esp32c6/Kconfig.rtc @@ -14,6 +14,9 @@ choice RTC_CLK_SRC select ESP_SYSTEM_RTC_EXT_OSC config RTC_CLK_SRC_INT_RC32K bool "Internal 32kHz RC oscillator" + help + Internal RC32K clock is unstable at extreme temperatures and is not recommended for use. + This option will be removed in IDF v6.0. endchoice config RTC_CLK_CAL_CYCLES diff --git a/components/esp_hw_support/port/esp32c6/pmu_param.c b/components/esp_hw_support/port/esp32c6/pmu_param.c index 41c15ab8d0..54c8dd70bc 100644 --- a/components/esp_hw_support/port/esp32c6/pmu_param.c +++ b/components/esp_hw_support/port/esp32c6/pmu_param.c @@ -367,21 +367,14 @@ const pmu_hp_system_retention_param_t * pmu_hp_system_retention_param_default(pm /** LP system default parameter */ - -#if CONFIG_ESP_SYSTEM_RTC_EXT_XTAL -# define PMU_SLOW_CLK_USE_EXT_XTAL (1) -#else -# define PMU_SLOW_CLK_USE_EXT_XTAL (0) -#endif - #define PMU_LP_ACTIVE_POWER_CONFIG_DEFAULT() { \ .dig_power = { \ .mem_dslp = 0, \ .peri_pd_en = 0, \ }, \ .clk_power = { \ - .xpd_xtal32k = PMU_SLOW_CLK_USE_EXT_XTAL, \ - .xpd_rc32k = 0, \ + .xpd_xtal32k = 1, \ + .xpd_rc32k = 1, \ .xpd_fosc = 1, \ .pd_osc = 0 \ } \ diff --git a/components/esp_hw_support/port/esp32c6/pmu_sleep.c b/components/esp_hw_support/port/esp32c6/pmu_sleep.c index 5cf7aa1615..9f0d9def62 100644 --- a/components/esp_hw_support/port/esp32c6/pmu_sleep.c +++ b/components/esp_hw_support/port/esp32c6/pmu_sleep.c @@ -201,11 +201,6 @@ const pmu_sleep_config_t* pmu_sleep_config_default( { pmu_sleep_power_config_t power_default = PMU_SLEEP_POWER_CONFIG_DEFAULT(pd_flags); - uint32_t iram_pd_flags = 0; - iram_pd_flags |= (pd_flags & PMU_SLEEP_PD_MEM_G0) ? BIT(0) : 0; - iram_pd_flags |= (pd_flags & PMU_SLEEP_PD_MEM_G1) ? BIT(1) : 0; - iram_pd_flags |= (pd_flags & PMU_SLEEP_PD_MEM_G2) ? BIT(2) : 0; - iram_pd_flags |= (pd_flags & PMU_SLEEP_PD_MEM_G3) ? BIT(3) : 0; config->power = power_default; pmu_sleep_param_config_t param_default = PMU_SLEEP_PARAM_CONFIG_DEFAULT(pd_flags); diff --git a/components/esp_hw_support/port/esp32c6/private_include/pmu_param.h b/components/esp_hw_support/port/esp32c6/private_include/pmu_param.h index 44ffce061a..edf3dcb29c 100644 --- a/components/esp_hw_support/port/esp32c6/private_include/pmu_param.h +++ b/components/esp_hw_support/port/esp32c6/private_include/pmu_param.h @@ -365,8 +365,8 @@ typedef struct { #define PMU_SLEEP_ANALOG_DSLP_CONFIG_DEFAULT(pd_flags) { \ .hp_sys = { \ .analog = { \ - .pd_cur = PMU_PD_CUR_SLEEP_ON, \ - .bias_sleep = PMU_BIASSLP_SLEEP_ON, \ + .pd_cur = PMU_PD_CUR_SLEEP_DEFAULT, \ + .bias_sleep = PMU_BIASSLP_SLEEP_DEFAULT, \ .xpd = PMU_HP_XPD_DEEPSLEEP, \ .dbg_atten = PMU_DBG_HP_DEEPSLEEP \ } \ diff --git a/components/esp_hw_support/port/esp32c6/rtc_clk.c b/components/esp_hw_support/port/esp32c6/rtc_clk.c index 14ede0160a..7358fcdeba 100644 --- a/components/esp_hw_support/port/esp32c6/rtc_clk.c +++ b/components/esp_hw_support/port/esp32c6/rtc_clk.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -343,10 +343,7 @@ void rtc_clk_cpu_freq_set_config_fast(const rtc_cpu_freq_config_t *config) void rtc_clk_cpu_freq_set_xtal(void) { rtc_clk_cpu_set_to_default_config(); - // We don't turn off the bbpll if some consumers depend on bbpll - if (!s_bbpll_digi_consumers_ref_count) { - rtc_clk_bbpll_disable(); - } + rtc_clk_bbpll_disable(); } void rtc_clk_cpu_set_to_default_config(void) @@ -354,6 +351,7 @@ void rtc_clk_cpu_set_to_default_config(void) int freq_mhz = (int)rtc_clk_xtal_freq_get(); rtc_clk_cpu_freq_to_xtal(freq_mhz, 1); + s_cur_pll_freq = 0; // no disable PLL, but set freq to 0 to trigger a PLL calibration after wake-up from sleep } void rtc_clk_cpu_freq_to_pll_and_pll_lock_release(int cpu_freq_mhz) @@ -428,25 +426,6 @@ bool rtc_dig_8m_enabled(void) return clk_ll_rc_fast_digi_is_enabled(); } -// Workaround for bootloader not calibrated well issue. -// Placed in IRAM because disabling BBPLL may influence the cache -void rtc_clk_recalib_bbpll(void) -{ - rtc_cpu_freq_config_t old_config; - rtc_clk_cpu_freq_get_config(&old_config); - - // There are two paths we arrive here: 1. CPU reset. 2. Other reset reasons. - // - For other reasons, the bootloader will set CPU source to BBPLL and enable it. But there are calibration issues. - // Turn off the BBPLL and do calibration again to fix the issue. - // - For CPU reset, the CPU source will be set to XTAL, while the BBPLL is kept to meet USB Serial JTAG's - // requirements. In this case, we don't touch BBPLL to avoid USJ disconnection. - if (old_config.source == SOC_CPU_CLK_SRC_PLL) { - rtc_clk_cpu_freq_set_xtal(); - rtc_clk_cpu_freq_set_config(&old_config); - } -} - - /* Name used in libphy.a:phy_chip_v7.o * TODO: update the library to use rtc_clk_xtal_freq_get */ diff --git a/components/esp_hw_support/port/esp32h2/Kconfig.rtc b/components/esp_hw_support/port/esp32h2/Kconfig.rtc index 24a5b8fb94..0b7c9dc517 100644 --- a/components/esp_hw_support/port/esp32h2/Kconfig.rtc +++ b/components/esp_hw_support/port/esp32h2/Kconfig.rtc @@ -14,6 +14,9 @@ choice RTC_CLK_SRC select ESP_SYSTEM_RTC_EXT_OSC config RTC_CLK_SRC_INT_RC32K bool "Internal 32kHz RC oscillator" + help + Internal RC32K clock is unstable at extreme temperatures and is not recommended for use. + This option will be removed in IDF v6.0. endchoice config RTC_CLK_CAL_CYCLES diff --git a/components/esp_hw_support/port/esp32h2/pmu_param.c b/components/esp_hw_support/port/esp32h2/pmu_param.c index b15e97b78e..6120a1367c 100644 --- a/components/esp_hw_support/port/esp32h2/pmu_param.c +++ b/components/esp_hw_support/port/esp32h2/pmu_param.c @@ -366,21 +366,14 @@ const pmu_hp_system_retention_param_t * pmu_hp_system_retention_param_default(pm /** LP system default parameter */ - -#if CONFIG_ESP_SYSTEM_RTC_EXT_XTAL -# define PMU_SLOW_CLK_USE_EXT_XTAL (1) -#else -# define PMU_SLOW_CLK_USE_EXT_XTAL (0) -#endif - #define PMU_LP_ACTIVE_POWER_CONFIG_DEFAULT() { \ .dig_power = { \ .mem_dslp = 0, \ .peri_pd_en = 0, \ }, \ .clk_power = { \ - .xpd_xtal32k = PMU_SLOW_CLK_USE_EXT_XTAL, \ - .xpd_rc32k = 0, \ + .xpd_xtal32k = 1, \ + .xpd_rc32k = 1, \ .xpd_fosc = 1, \ .pd_osc = 0 \ } \ diff --git a/components/esp_hw_support/port/esp32h2/pmu_sleep.c b/components/esp_hw_support/port/esp32h2/pmu_sleep.c index a59e81f1ec..33f84d20ce 100644 --- a/components/esp_hw_support/port/esp32h2/pmu_sleep.c +++ b/components/esp_hw_support/port/esp32h2/pmu_sleep.c @@ -20,6 +20,8 @@ #include "hal/efuse_ll.h" #include "hal/efuse_hal.h" #include "esp_hw_log.h" +#include "soc/regi2c_bias.h" +#include "regi2c_ctrl.h" static __attribute__((unused)) const char *TAG = "pmu_sleep"; @@ -263,6 +265,8 @@ uint32_t pmu_sleep_start(uint32_t wakeup_opt, uint32_t reject_opt, uint32_t lslp bool pmu_sleep_finish(void) { + // Restore registers lost during sleep + REGI2C_WRITE_MASK(I2C_BIAS, I2C_BIAS_DREG_0P8, 8); // fix low temp issue, need to increase this internal voltage return pmu_ll_hp_is_sleep_reject(PMU_instance()->hal->dev); } diff --git a/components/esp_hw_support/port/esp32h2/private_include/pmu_param.h b/components/esp_hw_support/port/esp32h2/private_include/pmu_param.h index 58fbf97ff4..52ad70fa21 100644 --- a/components/esp_hw_support/port/esp32h2/private_include/pmu_param.h +++ b/components/esp_hw_support/port/esp32h2/private_include/pmu_param.h @@ -340,7 +340,7 @@ typedef struct { }, \ .lp_sys[PMU_MODE_LP_SLEEP] = { \ .analog = { \ - .drv_b = PMU_LP_DRVB_DEEPSLEEP, \ + .drv_b = PMU_LP_DRVB_LIGHTSLEEP, \ .pd_cur = PMU_PD_CUR_SLEEP_DEFAULT, \ .bias_sleep = PMU_BIASSLP_SLEEP_DEFAULT, \ .slp_xpd = PMU_LP_SLP_XPD_SLEEP_DEFAULT, \ @@ -407,7 +407,7 @@ typedef struct { typedef struct pmu_sleep_machine_constant { struct { - uint16_t min_slp_time_us; /* Mininum sleep protection time (unit: microsecond) */ + uint16_t min_slp_time_us; /* Minimum sleep protection time (unit: microsecond) */ uint8_t reserved0; uint16_t reserved1; uint16_t analog_wait_time_us; /* LP LDO power up wait time (unit: microsecond) */ @@ -418,7 +418,7 @@ typedef struct pmu_sleep_machine_constant { uint16_t power_up_wait_time_us; /* (unit: microsecond) */ } lp; struct { - uint16_t min_slp_time_us; /* Mininum sleep protection time (unit: microsecond) */ + uint16_t min_slp_time_us; /* Minimum sleep protection time (unit: microsecond) */ uint16_t analog_wait_time_us; /* HP LDO power up wait time (unit: microsecond) */ uint16_t power_supply_wait_time_us; /* (unit: microsecond) */ uint16_t power_up_wait_time_us; /* (unit: microsecond) */ diff --git a/components/esp_hw_support/port/esp32h2/rtc_clk.c b/components/esp_hw_support/port/esp32h2/rtc_clk.c index 1f6fd3b8fe..8b94a7aeab 100644 --- a/components/esp_hw_support/port/esp32h2/rtc_clk.c +++ b/components/esp_hw_support/port/esp32h2/rtc_clk.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -239,7 +239,7 @@ static void rtc_clk_cpu_freq_to_pll_mhz(int cpu_freq_mhz) /** * Switch to FLASH_PLL as cpu clock source. * On ESP32H2, FLASH_PLL frequency is 64MHz. - * PLL must alreay be enabled. + * PLL must already be enabled. */ static void rtc_clk_cpu_freq_to_flash_pll(uint32_t cpu_freq_mhz, uint32_t cpu_divider) { @@ -399,10 +399,7 @@ void rtc_clk_cpu_freq_set_config_fast(const rtc_cpu_freq_config_t *config) void rtc_clk_cpu_freq_set_xtal(void) { rtc_clk_cpu_set_to_default_config(); - // We don't turn off the bbpll if some consumers only depends on bbpll - if (!s_bbpll_digi_consumers_ref_count) { - rtc_clk_bbpll_disable(); - } + rtc_clk_bbpll_disable(); } void rtc_clk_cpu_set_to_default_config(void) @@ -410,6 +407,7 @@ void rtc_clk_cpu_set_to_default_config(void) int freq_mhz = (int)rtc_clk_xtal_freq_get(); rtc_clk_cpu_freq_to_xtal(freq_mhz, 1); + s_cur_pll_freq = 0; // no disable PLL, but set freq to 0 to trigger a PLL calibration after wake-up from sleep } rtc_xtal_freq_t rtc_clk_xtal_freq_get(void) @@ -475,21 +473,3 @@ bool rtc_dig_8m_enabled(void) { return clk_ll_rc_fast_digi_is_enabled(); } - -// Workaround for bootloader not calibrated well issue. -// Placed in IRAM because disabling BBPLL may influence the cache -void rtc_clk_recalib_bbpll(void) -{ - rtc_cpu_freq_config_t old_config; - rtc_clk_cpu_freq_get_config(&old_config); - - // There are two paths we arrive here: 1. CPU reset. 2. Other reset reasons. - // - For other reasons, the bootloader will set CPU source to BBPLL and enable it. But there are calibration issues. - // Turn off the BBPLL and do calibration again to fix the issue. Flash_PLL comes from the same source as PLL. - // - For CPU reset, the CPU source will be set to XTAL, while the BBPLL is kept to meet USB Serial JTAG's - // requirements. In this case, we don't touch BBPLL to avoid USJ disconnection. - if (old_config.source == SOC_CPU_CLK_SRC_PLL || old_config.source == SOC_CPU_CLK_SRC_FLASH_PLL) { - rtc_clk_cpu_freq_set_xtal(); - rtc_clk_cpu_freq_set_config(&old_config); - } -} diff --git a/components/esp_hw_support/port/esp32s3/rtc_clk.c b/components/esp_hw_support/port/esp32s3/rtc_clk.c index 07f609c5f3..2017637f82 100644 --- a/components/esp_hw_support/port/esp32s3/rtc_clk.c +++ b/components/esp_hw_support/port/esp32s3/rtc_clk.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -12,6 +12,7 @@ #include "sdkconfig.h" #include "esp32s3/rom/rtc.h" #include "soc/rtc.h" +#include "soc/io_mux_reg.h" #include "esp_private/rtc_clk.h" #include "soc/rtc_io_reg.h" #include "esp_rom_sys.h" @@ -20,6 +21,7 @@ #include "hal/regi2c_ctrl_ll.h" #include "esp_private/regi2c_ctrl.h" #include "soc/regi2c_dig_reg.h" +#include "soc/sens_reg.h" #include "sdkconfig.h" static const char *TAG = "rtc_clk"; @@ -62,8 +64,9 @@ void rtc_clk_32k_enable(bool enable) void rtc_clk_32k_enable_external(void) { - SET_PERI_REG_MASK(RTC_IO_XTAL_32P_PAD_REG, RTC_IO_X32P_MUX_SEL); - SET_PERI_REG_MASK(RTC_IO_XTAL_32N_PAD_REG, RTC_IO_X32N_MUX_SEL); + PIN_INPUT_ENABLE(IO_MUX_GPIO15_REG); + SET_PERI_REG_MASK(SENS_SAR_PERI_CLK_GATE_CONF_REG, SENS_IOMUX_CLK_EN); + SET_PERI_REG_MASK(RTC_CNTL_PAD_HOLD_REG, RTC_CNTL_X32P_HOLD); clk_ll_xtal32k_enable(CLK_LL_XTAL32K_ENABLE_MODE_EXTERNAL); } @@ -186,7 +189,7 @@ static void rtc_clk_bbpll_configure(rtc_xtal_freq_t xtal_freq, int pll_freq) */ static void rtc_clk_cpu_freq_to_pll_mhz(int cpu_freq_mhz) { - /* There are totally 6 LDO slaves(all on by default). At the moment of swithing LDO slave, LDO voltage will also change instantaneously. + /* There are totally 6 LDO slaves(all on by default). At the moment of switching LDO slave, LDO voltage will also change instantaneously. * LDO slave can reduce the voltage change caused by switching frequency. * CPU frequency <= 40M : just open 3 LDO slaves; CPU frequency = 80M : open 4 LDO slaves; CPU frequency = 160M : open 5 LDO slaves; CPU frequency = 240M : open 6 LDO slaves; * @@ -460,25 +463,6 @@ bool rtc_dig_8m_enabled(void) return clk_ll_rc_fast_digi_is_enabled(); } -// Workaround for bootloader not calibrated well issue. -// Placed in IRAM because disabling BBPLL may influence the cache -void rtc_clk_recalib_bbpll(void) -{ - rtc_cpu_freq_config_t old_config; - rtc_clk_cpu_freq_get_config(&old_config); - - // There are two paths we arrive here: 1. CPU reset. 2. Other reset reasons. - // - For other reasons, the bootloader will set CPU source to BBPLL and enable it. But there are calibration issues. - // Turn off the BBPLL and do calibration again to fix the issue. - // - For CPU reset, the CPU source will be set to XTAL, while the BBPLL is kept to meet USB Serial JTAG's - // requirements. In this case, we don't touch BBPLL to avoid USJ disconnection. - if (old_config.source == SOC_CPU_CLK_SRC_PLL) { - rtc_clk_cpu_freq_set_xtal(); - rtc_clk_cpu_freq_set_config(&old_config); - } -} - - /* Name used in libphy.a:phy_chip_v7.o * TODO: update the library to use rtc_clk_xtal_freq_get */ diff --git a/components/esp_hw_support/port/regdma_link.c b/components/esp_hw_support/port/regdma_link.c index b40ea0ea4e..ef80e96848 100644 --- a/components/esp_hw_support/port/regdma_link.c +++ b/components/esp_hw_support/port/regdma_link.c @@ -710,6 +710,12 @@ void * regdma_find_prev_module_link_tail(void *link, void *tail, int entry, uint return NULL; } +regdma_link_mode_t regdma_link_get_config_mode(const regdma_link_config_t *config) +{ + assert(config != NULL); + return (regdma_link_mode_t)config->head.mode; +} + #if REGDMA_LINK_DBG static __attribute__((unused)) const char *TAG = "regdma_link"; diff --git a/components/esp_hw_support/sleep_clock.c b/components/esp_hw_support/sleep_clock.c index b75683187e..7b85fb1566 100644 --- a/components/esp_hw_support/sleep_clock.c +++ b/components/esp_hw_support/sleep_clock.c @@ -37,10 +37,15 @@ static esp_err_t sleep_clock_system_retention_init(void *arg) #define N_REGS_PCR() (((PCR_PWDET_SAR_CLK_CONF_REG - DR_REG_PCR_BASE) / 4) + 1) #endif const static sleep_retention_entries_config_t pcr_regs_retention[] = { - [0] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_PCR_LINK(0), DR_REG_PCR_BASE, DR_REG_PCR_BASE, N_REGS_PCR(), 0, 0), .owner = ENTRY(0) | ENTRY(2) } /* pcr */ + [0] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_PCR_LINK(0), DR_REG_PCR_BASE, DR_REG_PCR_BASE, N_REGS_PCR(), 0, 0), .owner = ENTRY(0) | ENTRY(2) }, + [1] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_PCR_LINK(1), PCR_RESET_EVENT_BYPASS_REG, PCR_RESET_EVENT_BYPASS_REG, 1, 0, 0), .owner = ENTRY(0) | ENTRY(2) }, +#if CONFIG_IDF_TARGET_ESP32H2 + [2] = { .config = REGDMA_LINK_WRITE_INIT (REGDMA_PCR_LINK(2), PCR_BUS_CLK_UPDATE_REG, PCR_BUS_CLOCK_UPDATE, PCR_BUS_CLOCK_UPDATE_M, 1, 0), .owner = ENTRY(0) | ENTRY(2) }, + [3] = { .config = REGDMA_LINK_WAIT_INIT (REGDMA_PCR_LINK(3), PCR_BUS_CLK_UPDATE_REG, 0x0, PCR_BUS_CLOCK_UPDATE_M, 1, 0), .owner = ENTRY(0) | ENTRY(2) }, +#endif }; - esp_err_t err = sleep_retention_entries_create(pcr_regs_retention, ARRAY_SIZE(pcr_regs_retention), REGDMA_LINK_PRI_0, SLEEP_RETENTION_MODULE_CLOCK_SYSTEM); + esp_err_t err = sleep_retention_entries_create(pcr_regs_retention, ARRAY_SIZE(pcr_regs_retention), REGDMA_LINK_PRI_SYS_CLK, SLEEP_RETENTION_MODULE_CLOCK_SYSTEM); ESP_RETURN_ON_ERROR(err, TAG, "failed to allocate memory for system (PCR) retention"); ESP_LOGI(TAG, "System Power, Clock and Reset sleep retention initialization"); return ESP_OK; @@ -73,7 +78,7 @@ static esp_err_t sleep_clock_modem_retention_init(void *arg) [0] = { .config = REGDMA_LINK_WRITE_INIT (REGDMA_MODEMSYSCON_LINK(0xf0), MODEM_SYSCON_CLK_CONF1_FORCE_ON_REG, 0x0, MODEM_WIFI_RETENTION_CLOCK_MASK, 0, 0), .owner = ENTRY(0) } /* WiFi (MAC, BB and FE) retention clock disable */ }; #endif - esp_err_t err = sleep_retention_entries_create(modem_regs_retention, ARRAY_SIZE(modem_regs_retention), REGDMA_LINK_PRI_1, SLEEP_RETENTION_MODULE_CLOCK_MODEM); + esp_err_t err = sleep_retention_entries_create(modem_regs_retention, ARRAY_SIZE(modem_regs_retention), REGDMA_LINK_PRI_MODEM_CLK, SLEEP_RETENTION_MODULE_CLOCK_MODEM); ESP_RETURN_ON_ERROR(err, TAG, "failed to allocate memory for modem (SYSCON) retention, 2 level priority"); #if SOC_WIFI_SUPPORTED err = sleep_retention_entries_create(modem_retention_clock, ARRAY_SIZE(modem_retention_clock), REGDMA_LINK_PRI_7, SLEEP_RETENTION_MODULE_CLOCK_MODEM); diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index 6b0da141c7..d59c7ed2d9 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -238,7 +238,7 @@ static sleep_config_t s_config = { .refs = 0 } }, - .ccount_ticks_record = 0, + .ccount_ticks_record = 0, .sleep_time_overhead_out = DEFAULT_SLEEP_OUT_OVERHEAD_US, .wakeup_triggers = 0 }; @@ -303,13 +303,12 @@ static void __attribute__((section(".rtc.entry.text"))) esp_wake_stub_entry(void #ifdef __riscv __asm__ __volatile__ ( - "addi sp, sp, -16 \n" - "sw ra, 0(sp) \n" - "la ra, " SYM2STR(esp_wake_stub_start) "\n" // Load full address of esp_wake_stub_start - "jalr ra \n" // Jump to the address in ra - "lw ra, 0(sp) \n" - "addi sp, sp, 16 \n" -); + "addi sp, sp, -16 \n" + "sw ra, 0(sp) \n" + "jal ra, " SYM2STR(esp_wake_stub_start) "\n" + "lw ra, 0(sp) \n" + "addi sp, sp, 16 \n" + ); #else // call4 has a larger effective addressing range (-524284 to 524288 bytes), // which is sufficient for instruction addressing in RTC fast memory. @@ -972,12 +971,14 @@ static esp_err_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t m esp_sleep_execute_event_callbacks(SLEEP_EVENT_SW_CLK_READY, (void *)0); if (!deep_sleep) { - s_config.ccount_ticks_record = esp_cpu_get_cycle_count(); + if (result == ESP_OK) { + s_config.ccount_ticks_record = esp_cpu_get_cycle_count(); #if SOC_PM_RETENTION_SW_TRIGGER_REGDMA - if (pd_flags & PMU_SLEEP_PD_TOP) { - sleep_retention_do_system_retention(false); - } + if (pd_flags & PMU_SLEEP_PD_TOP) { + sleep_retention_do_system_retention(false); + } #endif + } misc_modules_wake_prepare(); } @@ -1130,7 +1131,7 @@ static esp_err_t esp_light_sleep_inner(uint32_t pd_flags, #endif // If SPI flash was powered down, wait for it to become ready - if (pd_flags & RTC_SLEEP_PD_VDDSDIO) { + if (!reject && (pd_flags & RTC_SLEEP_PD_VDDSDIO)) { #if SOC_PM_SUPPORT_TOP_PD if (pd_flags & PMU_SLEEP_PD_TOP) { uint32_t flash_ready_hw_waited_time_us = pmu_sleep_get_wakup_retention_cost(); @@ -1184,7 +1185,7 @@ esp_err_t esp_light_sleep_start(void) timerret = esp_task_wdt_stop(); #endif // CONFIG_ESP_TASK_WDT_USE_ESP_TIMER - s_config.lock = irq_lock(); + s_config.lock = irq_lock(); /* Note: We are about to stall the other CPU via the esp_ipc_isr_stall_other_cpu(). However, there is a chance of deadlock if after stalling the other CPU, we attempt to take spinlocks already held by the other CPU that is. @@ -1223,8 +1224,7 @@ esp_err_t esp_light_sleep_start(void) // Decide which power domains can be powered down uint32_t pd_flags = get_power_down_flags(); - -#if CONFIG_SOC_SERIES_ESP32 || CONFIG_SOC_SERIES_ESP32S2 || CONFIG_SOC_SERIES_ESP32S3 +#ifdef CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND pd_flags &= ~RTC_SLEEP_PD_RTC_PERIPH; #endif @@ -1331,22 +1331,18 @@ esp_err_t esp_light_sleep_start(void) // System timer has been stopped for the duration of the sleep, correct for that. uint64_t rtc_ticks_at_end = rtc_time_get(); - uint64_t rtc_time_diff = rtc_time_slowclk_to_us(rtc_ticks_at_end - s_config.rtc_ticks_at_sleep_start, s_config.rtc_clk_cal_period); - -#if CONFIG_ESP_SLEEP_DEBUG - if (s_sleep_ctx != NULL) { - s_sleep_ctx->sleep_out_rtc_time_stamp = rtc_ticks_at_end; - } -#endif - /** - * If sleep duration is too small(less than 1 rtc_slow_clk cycle), rtc_time_diff will be zero. - * In this case, just ignore the time compensation and keep esp_timer monotonic. - */ - if (rtc_time_diff > 0) { - esp_timer_private_set(high_res_time_at_start + rtc_time_diff); + if (s_light_sleep_wakeup) { + uint64_t rtc_time_diff = rtc_time_slowclk_to_us(rtc_ticks_at_end - s_config.rtc_ticks_at_sleep_start, s_config.rtc_clk_cal_period); + /** + * If sleep duration is too small(less than 1 rtc_slow_clk cycle), rtc_time_diff will be zero. + * In this case, just ignore the time compensation and keep esp_timer monotonic. + */ + if (rtc_time_diff > 0) { + esp_timer_private_set(high_res_time_at_start + rtc_time_diff); + } + // esp_set_time_from_rtc(); } - // esp_set_time_from_rtc(); esp_clk_private_unlock(); esp_timer_private_unlock(); @@ -1356,7 +1352,6 @@ esp_err_t esp_light_sleep_start(void) wdt_hal_disable(&rtc_wdt_ctx); wdt_hal_write_protect_enable(&rtc_wdt_ctx); } - irq_unlock(s_config.lock); #if CONFIG_ESP_TASK_WDT_USE_ESP_TIMER /* Restart the Task Watchdog timer as it was stopped before sleeping. */ @@ -1366,13 +1361,19 @@ esp_err_t esp_light_sleep_start(void) #endif // CONFIG_ESP_TASK_WDT_USE_ESP_TIMER esp_sleep_execute_event_callbacks(SLEEP_EVENT_SW_EXIT_SLEEP, (void *)0); - s_config.sleep_time_overhead_out = (esp_cpu_get_cycle_count() - s_config.ccount_ticks_record) / (esp_clk_cpu_freq() / 1000000ULL); #if CONFIG_ESP_SLEEP_DEBUG if (s_sleep_ctx != NULL) { + s_sleep_ctx->sleep_out_rtc_time_stamp = rtc_ticks_at_end; s_sleep_ctx->sleep_request_result = err; } #endif + + if (s_light_sleep_wakeup) { + s_config.sleep_time_overhead_out = (esp_cpu_get_cycle_count() - s_config.ccount_ticks_record) / (esp_clk_cpu_freq() / 1000000ULL); + } + + irq_unlock(s_config.lock); return err; } diff --git a/components/esp_hw_support/sleep_retention.c b/components/esp_hw_support/sleep_retention.c index 172d4854da..faec10f8ff 100644 --- a/components/esp_hw_support/sleep_retention.c +++ b/components/esp_hw_support/sleep_retention.c @@ -21,6 +21,10 @@ #include "sdkconfig.h" #include "esp_pmu.h" +#if SOC_PM_PAU_REGDMA_UPDATE_CACHE_BEFORE_WAIT_COMPARE +#include "soc/pmu_reg.h" // for PMU_DATE_REG, it can provide full 32 bit read and write access +#endif + static __attribute__((unused)) const char *TAG = "sleep"; struct sleep_retention_module_object { @@ -475,8 +479,9 @@ static void sleep_retention_entries_destroy(sleep_retention_module_t module) static esp_err_t sleep_retention_entries_create_impl(const sleep_retention_entries_config_t retent[], int num, regdma_link_priority_t priority, sleep_retention_module_t module) { + esp_err_t err = ESP_OK; k_sem_take(&s_retention_lock, K_FOREVER); - for (int i = num - 1; i >= 0; i--) { + for (int i = num - 1; (i >= 0) && (err == ESP_OK); i--) { #if SOC_PM_RETENTION_HAS_CLOCK_BUG if ((retent[i].owner > BIT(EXTRA_LINK_NUM)) && (retent[i].config.id != 0xffff)) { k_sem_give(&s_retention_lock); @@ -484,16 +489,40 @@ static esp_err_t sleep_retention_entries_create_impl(const sleep_retention_entri return ESP_ERR_NOT_SUPPORTED; } #endif - void *link = sleep_retention_entries_try_create(&retent[i].config, retent[i].owner, priority, module); - if (link == NULL) { - k_sem_give(&s_retention_lock); - sleep_retention_entries_do_destroy(module); - return ESP_ERR_NO_MEM; +#if SOC_PM_PAU_REGDMA_UPDATE_CACHE_BEFORE_WAIT_COMPARE + /* There is a bug in REGDMA wait mode, when two wait nodes need to wait for the + * same value (_val & _mask), the second wait node will immediately return to + * wait done, The reason is that the wait mode comparison output logic immediate + * compares the value of the previous wait register cached inside the + * digital logic before reading out he register contents specified by _backup. + */ + #define config_is_wait_mode(_config) (regdma_link_get_config_mode(_config) == REGDMA_LINK_MODE_WAIT) + if ((retent[i].config.id != 0xffff) && config_is_wait_mode(&(retent[i].config)) && (retent[i].config.id != 0xfffe)) { + uint32_t value = retent[i].config.write_wait.value; + uint32_t mask = retent[i].config.write_wait.mask; + bool skip_b = retent[i].config.head.skip_b; + bool skip_r = retent[i].config.head.skip_r; + sleep_retention_entries_config_t wait_bug_workaround[] = { + [0] = { .config = REGDMA_LINK_WRITE_INIT(0xfffe, PMU_DATE_REG, ~value, mask, skip_b, skip_r), .owner = retent[i].owner }, + [1] = { .config = REGDMA_LINK_WAIT_INIT (0xfffe, PMU_DATE_REG, ~value, mask, skip_b, skip_r), .owner = retent[i].owner } + }; + err = sleep_retention_entries_create_impl(wait_bug_workaround, ARRAY_SIZE(wait_bug_workaround), priority, module); + } +#endif + if (err == ESP_OK) { + void *link = sleep_retention_entries_try_create(&retent[i].config, retent[i].owner, priority, module); + if (link == NULL) { + k_sem_give(&s_retention_lock); + sleep_retention_entries_do_destroy(module); + return ESP_ERR_NO_MEM; + } + sleep_retention_entries_update(retent[i].owner, link, priority); + } else { + break; } - sleep_retention_entries_update(retent[i].owner, link, priority); } k_sem_give(&s_retention_lock); - return ESP_OK; + return err; } static esp_err_t sleep_retention_entries_create_bonding(regdma_link_priority_t priority, sleep_retention_module_t module) diff --git a/components/esp_hw_support/sleep_system_peripheral.c b/components/esp_hw_support/sleep_system_peripheral.c index 202d1b535e..6b5e7d3022 100644 --- a/components/esp_hw_support/sleep_system_peripheral.c +++ b/components/esp_hw_support/sleep_system_peripheral.c @@ -32,7 +32,7 @@ static __attribute__((unused)) const char *TAG = "sleep_sys_periph"; -#define SLEEP_RETENTION_PERIPHERALS_PRIORITY_DEFAULT (REGDMA_LINK_PRI_6) +#define SLEEP_RETENTION_PERIPHERALS_PRIORITY_DEFAULT (REGDMA_LINK_PRI_SYS_PERIPH_LOW) static __attribute__((unused)) esp_err_t sleep_sys_periph_intr_matrix_retention_init(void *arg) { @@ -42,7 +42,7 @@ static __attribute__((unused)) esp_err_t sleep_sys_periph_intr_matrix_retention_ [0] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_INTMTX_LINK(0), DR_REG_INTERRUPT_MATRIX_BASE, DR_REG_INTERRUPT_MATRIX_BASE, N_REGS_INTR_MATRIX(), 0, 0), .owner = ENTRY(0) | ENTRY(2) } /* intr matrix */ }; - esp_err_t err = sleep_retention_entries_create(intr_matrix_regs_retention, ARRAY_SIZE(intr_matrix_regs_retention), REGDMA_LINK_PRI_5, SLEEP_RETENTION_MODULE_SYS_PERIPH); + esp_err_t err = sleep_retention_entries_create(intr_matrix_regs_retention, ARRAY_SIZE(intr_matrix_regs_retention), REGDMA_LINK_PRI_SYS_PERIPH_HIGH, SLEEP_RETENTION_MODULE_SYS_PERIPH); ESP_RETURN_ON_ERROR(err, TAG, "failed to allocate memory for digital peripherals (%s) retention", "Interrupt matrix"); ESP_LOGD(TAG, "Interrupt Matrix sleep retention initialization"); return ESP_OK; @@ -56,7 +56,7 @@ static __attribute__((unused)) esp_err_t sleep_sys_periph_hp_system_retention_in [0] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_HPSYS_LINK(0), DR_REG_HP_SYSTEM_BASE, DR_REG_HP_SYSTEM_BASE, N_REGS_HP_SYSTEM(), 0, 0), .owner = ENTRY(0) | ENTRY(2) } /* hp system */ }; - esp_err_t err = sleep_retention_entries_create(hp_system_regs_retention, ARRAY_SIZE(hp_system_regs_retention), REGDMA_LINK_PRI_5, SLEEP_RETENTION_MODULE_SYS_PERIPH); + esp_err_t err = sleep_retention_entries_create(hp_system_regs_retention, ARRAY_SIZE(hp_system_regs_retention), REGDMA_LINK_PRI_SYS_PERIPH_HIGH, SLEEP_RETENTION_MODULE_SYS_PERIPH); ESP_RETURN_ON_ERROR(err, TAG, "failed to allocate memory for digital peripherals (%s) retention", "HP system"); ESP_LOGD(TAG, "HP System sleep retention initialization"); return ESP_OK; @@ -72,12 +72,12 @@ static __attribute__((unused)) esp_err_t sleep_sys_periph_tee_apm_retention_init [1] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_TEEAPM_LINK(1), DR_REG_TEE_BASE, DR_REG_TEE_BASE, N_REGS_TEE(), 0, 0), .owner = ENTRY(0) | ENTRY(2) } /* tee */ }; - esp_err_t err = sleep_retention_entries_create(tee_apm_regs_retention, ARRAY_SIZE(tee_apm_regs_retention), REGDMA_LINK_PRI_4, SLEEP_RETENTION_MODULE_SYS_PERIPH); + esp_err_t err = sleep_retention_entries_create(tee_apm_regs_retention, ARRAY_SIZE(tee_apm_regs_retention), REGDMA_LINK_PRI_NON_CRITICAL_TEE_APM, SLEEP_RETENTION_MODULE_SYS_PERIPH); if (err == ESP_OK) { const static sleep_retention_entries_config_t regs_highpri_retention[] = { [0] = { .config = REGDMA_LINK_WRITE_INIT(REGDMA_TEEAPM_LINK(2), TEE_M4_MODE_CTRL_REG, 0x0, 0xffffffff, 1, 0), .owner = ENTRY(2) } }; - err = sleep_retention_entries_create(regs_highpri_retention, ARRAY_SIZE(regs_highpri_retention), REGDMA_LINK_PRI_2, SLEEP_RETENTION_MODULE_SYS_PERIPH); + err = sleep_retention_entries_create(regs_highpri_retention, ARRAY_SIZE(regs_highpri_retention), REGDMA_LINK_PRI_CRITICAL_TEE_APM, SLEEP_RETENTION_MODULE_SYS_PERIPH); } ESP_RETURN_ON_ERROR(err, TAG, "failed to allocate memory for digital peripherals (%s) retention", "TEE/APM"); ESP_LOGD(TAG, "TEE/APM sleep retention initialization"); @@ -95,7 +95,7 @@ static __attribute__((unused)) esp_err_t sleep_sys_periph_uart0_retention_init(v [2] = { .config = REGDMA_LINK_WAIT_INIT (REGDMA_UART_LINK(0x02), UART_REG_UPDATE_REG(0), 0x0, UART_REG_UPDATE_M, 1, 0), .owner = ENTRY(0) | ENTRY(2) } }; - esp_err_t err = sleep_retention_entries_create(uart_regs_retention, ARRAY_SIZE(uart_regs_retention), REGDMA_LINK_PRI_5, SLEEP_RETENTION_MODULE_SYS_PERIPH); + esp_err_t err = sleep_retention_entries_create(uart_regs_retention, ARRAY_SIZE(uart_regs_retention), REGDMA_LINK_PRI_SYS_PERIPH_HIGH, SLEEP_RETENTION_MODULE_SYS_PERIPH); ESP_RETURN_ON_ERROR(err, TAG, "failed to allocate memory for digital peripherals (%s) retention", "UART"); ESP_LOGD(TAG, "UART sleep retention initialization"); return ESP_OK; diff --git a/components/esp_phy/CMakeLists.txt b/components/esp_phy/CMakeLists.txt index f6cea7452d..b3efc9c51f 100644 --- a/components/esp_phy/CMakeLists.txt +++ b/components/esp_phy/CMakeLists.txt @@ -57,22 +57,30 @@ if(link_binary_libs) idf_component_get_property(esp_phy_lib esp_phy COMPONENT_LIB) + if(CONFIG_ESP_PHY_ENABLE_CERT_TEST) + if(CONFIG_IDF_TARGET_ESP32) + target_link_libraries(${COMPONENT_LIB} INTERFACE $ libbttestmode.a + librftest.a $) + elseif(CONFIG_IDF_TARGET_ESP32S2) + target_link_libraries(${COMPONENT_LIB} INTERFACE $ librftest.a + librfate.a $) + else() + target_link_libraries(${COMPONENT_LIB} INTERFACE $ libbttestmode.a + librfate.a librftest.a $) + endif() + endif() + if(CONFIG_IDF_TARGET_ESP32) target_link_libraries(${COMPONENT_LIB} PUBLIC rtc) target_link_libraries(${COMPONENT_LIB} INTERFACE $ libphy.a librtc.a $) - elseif(CONFIG_IDF_TARGET_ESP32S2) - target_link_libraries(${COMPONENT_LIB} INTERFACE $ libphy.a - $) elseif(CONFIG_SOC_BT_SUPPORTED OR CONFIG_SOC_IEEE802154_SUPPORTED) target_link_libraries(${COMPONENT_LIB} PUBLIC btbb) target_link_libraries(${COMPONENT_LIB} INTERFACE $ libphy.a libbtbb.a $) - endif() - - if(CONFIG_ESP_PHY_ENABLE_CERT_TEST) - target_link_libraries(${COMPONENT_LIB} INTERFACE $ libbttestmode.a - librfate.a librftest.a $) + elseif(CONFIG_SOC_WIFI_SUPPORTED) + target_link_libraries(${COMPONENT_LIB} INTERFACE $ libphy.a + $) endif() endif() diff --git a/components/esp_phy/Kconfig b/components/esp_phy/Kconfig index b6b4e4923e..ab8155eb98 100644 --- a/components/esp_phy/Kconfig +++ b/components/esp_phy/Kconfig @@ -74,6 +74,12 @@ menu "PHY" If enabled, when an error occurs while the PHY init data is updated, the program will terminate and restart. If not enabled, the PHY init data will not be updated when an error occurs. + + config ESP_PHY_RECORD_USED_TIME + bool "Record PHY used time" + default n + help + Select to support record and query phy used time. endif config ESP_PHY_MAX_WIFI_TX_POWER @@ -124,7 +130,6 @@ menu "PHY" config ESP_PHY_ENABLE_CERT_TEST bool "Enable RF certification test functions" default n - depends on IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3 help If enabled, you can use RF certification test APIs. diff --git a/components/esp_phy/include/esp_phy_cert_test.h b/components/esp_phy/include/esp_phy_cert_test.h index 461295683c..75e6b5e093 100644 --- a/components/esp_phy/include/esp_phy_cert_test.h +++ b/components/esp_phy/include/esp_phy_cert_test.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -63,7 +63,7 @@ typedef struct { uint32_t phy_rx_correct_count; /*!< The number of desired packets received */ int phy_rx_rssi; /*!< Average RSSI of desired packets */ uint32_t phy_rx_total_count; /*!< The number of total packets received */ - uint32_t phy_rx_result_flag; /*!< 0 means no RX info; 1 means the lastest Wi-Fi RX info; 2 means the lastest BLE RX info. */ + uint32_t phy_rx_result_flag; /*!< 0 means no RX info; 1 means the latest Wi-Fi RX info; 2 means the latest BLE RX info. */ } esp_phy_rx_result_t; /** @@ -120,7 +120,7 @@ void esp_phy_cbw40m_en(bool en); void esp_phy_wifi_tx(uint32_t chan, esp_phy_wifi_rate_t rate, int8_t backoff, uint32_t length_byte, uint32_t packet_delay, uint32_t packet_num); /** - * @brief Test start/stop command, used to stop transmitting or reciving state. + * @brief Test start/stop command, used to stop transmitting or receiving state. * * @param value: * Value should be set to 3 before TX/RX. diff --git a/components/esp_phy/include/esp_phy_init.h b/components/esp_phy/include/esp_phy_init.h index 50b9ceb765..f2e2e418d8 100644 --- a/components/esp_phy/include/esp_phy_init.h +++ b/components/esp_phy/include/esp_phy_init.h @@ -34,6 +34,7 @@ typedef enum { PHY_MODEM_WIFI = 1, /*!< PHY modem WIFI */ PHY_MODEM_BT = 2, /*!< PHY modem BT */ PHY_MODEM_IEEE802154 = 4, /*!< PHY modem IEEE802154 */ + PHY_MODEM_MAX, /*!< Don't use it. Used by ESP_PHY_MODEM_COUNT_MAX */ } esp_phy_modem_t; /** @@ -282,6 +283,23 @@ void phy_init_param_set(uint8_t param); */ void phy_wifi_enable_set(uint8_t enable); +#if CONFIG_ESP_PHY_RECORD_USED_TIME +/** + * @brief Get phy used time from different modem + * @param used_time pointer of variable to get used time, in microseconds + * @param modem modem type + * @return ESP_ERR_INVALID_ARG on incorrect modem type. + */ +esp_err_t phy_query_used_time(uint64_t *used_time, esp_phy_modem_t modem); + +/** + * @brief Clear phy used time for different modem + * @param modem modem type + * @return ESP_ERR_INVALID_ARG on incorrect modem type. + */ +esp_err_t phy_clear_used_time(esp_phy_modem_t modem); +#endif + #ifdef __cplusplus } #endif diff --git a/components/esp_phy/include/esp_private/phy.h b/components/esp_phy/include/esp_private/phy.h index c86ba1367c..039fe84d51 100644 --- a/components/esp_phy/include/esp_private/phy.h +++ b/components/esp_phy/include/esp_private/phy.h @@ -41,7 +41,7 @@ void phy_get_romfunc_addr(void); * @param[in] init_data Initialization parameters to be used by the PHY * @param[inout] cal_data As input, calibration data previously obtained. As output, will contain new calibration data. * @param[in] cal_mode RF calibration mode - * @return ESP_CAL_DATA_CHECK_FAIL if calibration data checksum fails, other values are reserved for future use + * @return ESP_CAL_DATA_CHECK_FAIL if the calibration data checksum fails or if the calibration data is outdated, other values are reserved for future use */ int register_chipv7_phy(const esp_phy_init_data_t* init_data, esp_phy_calibration_data_t *cal_data, esp_phy_calibration_mode_t cal_mode); diff --git a/components/esp_phy/src/btbb_init.c b/components/esp_phy/src/btbb_init.c index 41d78dd83a..6a1bc5e311 100644 --- a/components/esp_phy/src/btbb_init.c +++ b/components/esp_phy/src/btbb_init.c @@ -35,7 +35,7 @@ static esp_err_t btbb_sleep_retention_init(void *arg) [1] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_MODEM_BT_BB_LINK(0x01), BB_PART_1_ADDR, BB_PART_1_ADDR, BB_PART_1_SIZE, 0, 0), .owner = BTBB_LINK_OWNER }, [2] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_MODEM_BT_BB_LINK(0x02), BB_PART_2_ADDR, BB_PART_2_ADDR, BB_PART_2_SIZE, 0, 0), .owner = BTBB_LINK_OWNER } }; - esp_err_t err = sleep_retention_entries_create(btbb_regs_retention, ARRAY_SIZE(btbb_regs_retention), REGDMA_LINK_PRI_5, SLEEP_RETENTION_MODULE_BT_BB); + esp_err_t err = sleep_retention_entries_create(btbb_regs_retention, ARRAY_SIZE(btbb_regs_retention), REGDMA_LINK_PRI_BT_MAC_BB, SLEEP_RETENTION_MODULE_BT_BB); ESP_RETURN_ON_ERROR(err, TAG, "failed to allocate memory for btbb retention"); ESP_LOGD(TAG, "btbb sleep retention initialization"); return ESP_OK; diff --git a/components/esp_phy/src/phy_init.c b/components/esp_phy/src/phy_init.c index 9797b50cb9..2a0b3cd3ba 100644 --- a/components/esp_phy/src/phy_init.c +++ b/components/esp_phy/src/phy_init.c @@ -48,7 +48,7 @@ #endif #if CONFIG_IDF_TARGET_ESP32 -wifi_mac_time_update_cb_t s_wifi_mac_time_update_cb = NULL; +wifi_mac_time_update_cb_t s_wifi_mac_time_update_cb; #endif static const char* TAG = "phy_init"; @@ -155,6 +155,60 @@ static phy_country_to_bin_type_t s_country_code_map_type_table[] = { {"US", ESP_PHY_INIT_DATA_TYPE_FCC}, }; #endif + +#if CONFIG_ESP_PHY_RECORD_USED_TIME +#define ESP_PHY_MODEM_COUNT_MAX (__builtin_ffs(PHY_MODEM_MAX - 1)) +#define ESP_PHY_IS_VALID_MODEM(modem) (__builtin_popcount(modem) == 1 && __builtin_ctz(modem) < ESP_PHY_MODEM_COUNT_MAX) + +static DRAM_ATTR struct { + uint64_t used_time; + uint64_t enabled_time; + uint64_t disabled_time; +} s_phy_rf_used_info[ESP_PHY_MODEM_COUNT_MAX]; + +static IRAM_ATTR void phy_record_time(bool enabled, esp_phy_modem_t modem) { + uint8_t index = __builtin_ctz(modem); + if (enabled) { + s_phy_rf_used_info[index].enabled_time = esp_timer_get_time(); + } else { + s_phy_rf_used_info[index].disabled_time = esp_timer_get_time(); + s_phy_rf_used_info[index].used_time += s_phy_rf_used_info[index].disabled_time - s_phy_rf_used_info[index].enabled_time; + } +} + +esp_err_t phy_query_used_time(uint64_t *used_time, esp_phy_modem_t modem) { + if (!ESP_PHY_IS_VALID_MODEM(modem)) { + return ESP_ERR_INVALID_ARG; + } + uint8_t index = __builtin_ctz(modem); + k_mutex_lock(&s_phy_access_lock, K_FOREVER); + *used_time = s_phy_rf_used_info[index].used_time; + if (s_phy_rf_used_info[index].disabled_time < s_phy_rf_used_info[index].enabled_time) { + // phy is being used + *used_time += esp_timer_get_time() - s_phy_rf_used_info[index].enabled_time; + } + k_mutex_unlock(&s_phy_access_lock); + return ESP_OK; +} + +esp_err_t phy_clear_used_time(esp_phy_modem_t modem) { + if (!ESP_PHY_IS_VALID_MODEM(modem)) { + return ESP_ERR_INVALID_ARG; + } + uint8_t index = __builtin_ctz(modem); + k_mutex_lock(&s_phy_access_lock, K_FOREVER); + if (s_phy_rf_used_info[index].enabled_time > s_phy_rf_used_info[index].disabled_time) { + // phy is being used + s_phy_rf_used_info[index].enabled_time = esp_timer_get_time(); + } else { + s_phy_rf_used_info[index].enabled_time = s_phy_rf_used_info[index].disabled_time; + } + s_phy_rf_used_info[index].used_time = 0; + k_mutex_unlock(&s_phy_access_lock); + return ESP_OK; +} +#endif + uint32_t IRAM_ATTR phy_enter_critical(void) { int key = irq_lock(); @@ -287,13 +341,18 @@ void esp_phy_enable(esp_phy_modem_t modem) phy_track_pll(); #endif +#if CONFIG_ESP_PHY_RECORD_USED_TIME + phy_record_time(true, modem); +#endif k_mutex_unlock(&s_phy_access_lock); } void esp_phy_disable(esp_phy_modem_t modem) { k_mutex_lock(&s_phy_access_lock, K_FOREVER); - +#if CONFIG_ESP_PHY_RECORD_USED_TIME + phy_record_time(false, modem); +#endif phy_clr_modem_flag(modem); if (phy_get_modem_flag() == 0) { // ESP32 will track pll in the wifi/BT modem interrupt handler. @@ -304,6 +363,8 @@ void esp_phy_disable(esp_phy_modem_t modem) phy_digital_regs_store(); #endif #if SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP + extern void pm_mac_modem_clear_rf_power_state(void); + pm_mac_modem_clear_rf_power_state(); if (sleep_modem_wifi_modem_state_enabled()) { sleep_modem_wifi_do_phy_retention(false); } else @@ -704,7 +765,7 @@ void esp_phy_load_cal_and_init(void) memcpy(cal_data->mac, sta_mac, 6); esp_err_t ret = register_chipv7_phy(init_data, cal_data, calibration_mode); if (ret == ESP_CAL_DATA_CHECK_FAIL) { - ESP_LOGW(TAG, "saving new calibration data because of checksum failure, mode(%d)", calibration_mode); + ESP_LOGI(TAG, "Saving new calibration data due to checksum failure or outdated calibration data, mode(%d)", calibration_mode); } if ((calibration_mode != PHY_RF_CAL_NONE) && ((err != ESP_OK) || (ret == ESP_CAL_DATA_CHECK_FAIL))) { diff --git a/components/esp_phy/src/phy_init_esp32hxx.c b/components/esp_phy/src/phy_init_esp32hxx.c index d0d3e2a20b..9ff88d452f 100644 --- a/components/esp_phy/src/phy_init_esp32hxx.c +++ b/components/esp_phy/src/phy_init_esp32hxx.c @@ -8,6 +8,7 @@ #include "freertos/portmacro.h" #include "esp_phy_init.h" #include "esp_private/phy.h" +#include "esp_timer.h" #if SOC_MODEM_CLOCK_IS_INDEPENDENT #include "esp_private/esp_modem_clock.h" @@ -23,6 +24,59 @@ static _lock_t s_phy_access_lock; /* Reference count of enabling PHY */ static bool s_phy_is_enabled = false; +#if CONFIG_ESP_PHY_RECORD_USED_TIME +#define ESP_PHY_MODEM_COUNT_MAX (__builtin_ffs(PHY_MODEM_MAX - 1)) +#define ESP_PHY_IS_VALID_MODEM(modem) (__builtin_popcount(modem) == 1 && __builtin_ctz(modem) < ESP_PHY_MODEM_COUNT_MAX) + +static DRAM_ATTR struct { + uint64_t used_time; + uint64_t enabled_time; + uint64_t disabled_time; +} s_phy_rf_used_info[ESP_PHY_MODEM_COUNT_MAX]; + +static IRAM_ATTR void phy_record_time(bool enabled, esp_phy_modem_t modem) { + uint8_t index = __builtin_ctz(modem); + if (enabled) { + s_phy_rf_used_info[index].enabled_time = esp_timer_get_time(); + } else { + s_phy_rf_used_info[index].disabled_time = esp_timer_get_time(); + s_phy_rf_used_info[index].used_time += s_phy_rf_used_info[index].disabled_time - s_phy_rf_used_info[index].enabled_time; + } +} + +esp_err_t phy_query_used_time(uint64_t *used_time, esp_phy_modem_t modem) { + if (!ESP_PHY_IS_VALID_MODEM(modem)) { + return ESP_ERR_INVALID_ARG; + } + uint8_t index = __builtin_ctz(modem); + _lock_acquire(&s_phy_access_lock); + *used_time = s_phy_rf_used_info[index].used_time; + if (s_phy_rf_used_info[index].disabled_time < s_phy_rf_used_info[index].enabled_time) { + // phy is being used + *used_time += esp_timer_get_time() - s_phy_rf_used_info[index].enabled_time; + } + _lock_release(&s_phy_access_lock); + return ESP_OK; +} + +esp_err_t phy_clear_used_time(esp_phy_modem_t modem) { + if (!ESP_PHY_IS_VALID_MODEM(modem)) { + return ESP_ERR_INVALID_ARG; + } + uint8_t index = __builtin_ctz(modem); + _lock_acquire(&s_phy_access_lock); + if (s_phy_rf_used_info[index].enabled_time > s_phy_rf_used_info[index].disabled_time) { + // phy is being used + s_phy_rf_used_info[index].enabled_time = esp_timer_get_time(); + } else { + s_phy_rf_used_info[index].enabled_time = s_phy_rf_used_info[index].disabled_time; + } + s_phy_rf_used_info[index].used_time = 0; + _lock_release(&s_phy_access_lock); + return ESP_OK; +} +#endif + uint32_t IRAM_ATTR phy_enter_critical(void) { if (xPortInIsrContext()) { @@ -64,13 +118,18 @@ void esp_phy_enable(esp_phy_modem_t modem) phy_set_modem_flag(modem); // Immediately track pll when phy enabled. phy_track_pll(); +#if CONFIG_ESP_PHY_RECORD_USED_TIME + phy_record_time(true, modem); +#endif _lock_release(&s_phy_access_lock); } void esp_phy_disable(esp_phy_modem_t modem) { _lock_acquire(&s_phy_access_lock); - +#if CONFIG_ESP_PHY_RECORD_USED_TIME + phy_record_time(false, modem); +#endif phy_clr_modem_flag(modem); if (phy_get_modem_flag() == 0) { diff --git a/components/esp_rom/CMakeLists.txt b/components/esp_rom/CMakeLists.txt index df01320e24..0d8b826083 100644 --- a/components/esp_rom/CMakeLists.txt +++ b/components/esp_rom/CMakeLists.txt @@ -18,7 +18,8 @@ else() "patches/esp_rom_sys.c" "patches/esp_rom_uart.c" "patches/esp_rom_spiflash.c" - "patches/esp_rom_efuse.c") + "patches/esp_rom_efuse.c" + "patches/esp_rom_gpio.c") # Override regi2c implementation in ROM @@ -82,6 +83,11 @@ if(target STREQUAL "linux") else() target_linker_script(${COMPONENT_LIB} INTERFACE "${target}/${ld_folder}/${target}.rom.ld") rom_linker_script("api") + if(NOT CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY) + if(target STREQUAL "esp32s3" OR target STREQUAL "esp32c3") + rom_linker_script("bt_funcs") + endif() + endif() if(CONFIG_COMPILER_FLOAT_LIB_FROM_GCCLIB) rom_linker_script("libgcc") @@ -183,6 +189,30 @@ else() # Regular app build rom_linker_script("newlib") rom_linker_script("version") + if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY) + if(NOT CONFIG_BT_CTRL_BLE_MASTER) + rom_linker_script("ble_master") + endif() + if(NOT CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT AND NOT CONFIG_BT_BLE_50_FEATURES_SUPPORTED) + rom_linker_script("ble_50") + endif() + if(CONFIG_BT_BLE_CCA_MODE_NONE) + rom_linker_script("ble_cca") + endif() + if(NOT CONFIG_BT_NIMBLE_SECURITY_ENABLE AND NOT CONFIG_BT_BLE_SMP_ENABLE) + rom_linker_script("ble_smp") + endif() + if(NOT CONFIG_BT_CTRL_DTM_ENABLE) + rom_linker_script("ble_dtm") + endif() + if(NOT CONFIG_BT_CTRL_BLE_TEST) + rom_linker_script("ble_test") + endif() + if(NOT CONFIG_BT_CTRL_BLE_SCAN) + rom_linker_script("ble_scan") + endif() + endif() + if(time_t_size EQUAL 4) # The ROM functions listed in this linker script depend on sizeof(time_t). # Since ROM for ESP32-S3 was compiled for 32-bit time_t, only link these functions @@ -199,6 +229,30 @@ else() # Regular app build rom_linker_script("newlib") rom_linker_script("version") + if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY) + if(NOT CONFIG_BT_CTRL_BLE_MASTER) + rom_linker_script("ble_master") + endif() + if(NOT CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT AND NOT CONFIG_BT_BLE_50_FEATURES_SUPPORTED) + rom_linker_script("ble_50") + endif() + if(CONFIG_BT_BLE_CCA_MODE_NONE) + rom_linker_script("ble_cca") + endif() + if(NOT CONFIG_BT_NIMBLE_SECURITY_ENABLE AND NOT CONFIG_BT_BLE_SMP_ENABLE) + rom_linker_script("ble_smp") + endif() + if(NOT CONFIG_BT_CTRL_DTM_ENABLE) + rom_linker_script("ble_dtm") + endif() + if(NOT CONFIG_BT_CTRL_BLE_TEST) + rom_linker_script("ble_test") + endif() + if(NOT CONFIG_BT_CTRL_BLE_SCAN) + rom_linker_script("ble_scan") + endif() + endif() + if(time_t_size EQUAL 4) # The ROM functions listed in this linker script depend on sizeof(time_t). # Since ROM for ESP32-C3 was compiled for 32-bit time_t, only link these functions @@ -213,10 +267,16 @@ else() # Regular app build if(CONFIG_ESP32C3_REV_MIN_FULL GREATER_EQUAL 3) rom_linker_script("eco3") + if(NOT CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY) + rom_linker_script("eco3_bt_funcs") + endif() endif() if(CONFIG_ESP32C3_REV_MIN_FULL GREATER_EQUAL 101) rom_linker_script("eco7") + if(NOT CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY) + rom_linker_script("eco7_bt_funcs") + endif() endif() elseif(target STREQUAL "esp32c2") @@ -225,6 +285,10 @@ else() # Regular app build if(CONFIG_MBEDTLS_USE_CRYPTO_ROM_IMPL) rom_linker_script("mbedtls") + # For ESP32C2(ECO4), mbedTLS in ROM has been updated to v3.6.0-LTS + if(CONFIG_ESP32C2_REV_MIN_FULL GREATER_EQUAL 200) + rom_linker_script("mbedtls.eco4") + endif() endif() if(CONFIG_NEWLIB_NANO_FORMAT) @@ -232,6 +296,18 @@ else() # Regular app build rom_linker_script("newlib-nano") endif() + if(CONFIG_ESP32C2_REV_MIN_FULL GREATER_EQUAL 200) + rom_linker_script("eco4") + endif() + + if(NOT CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY) + if(CONFIG_ESP32C2_REV_MIN_FULL GREATER_EQUAL 200) + rom_linker_script("ble-eco4") + else() + rom_linker_script("ble") + endif() + endif() + elseif(target STREQUAL "esp32c6") rom_linker_script("newlib") rom_linker_script("version") diff --git a/components/esp_rom/esp32/ld/esp32.rom.ld b/components/esp_rom/esp32/ld/esp32.rom.ld index b47c3140b8..8b873de821 100644 --- a/components/esp_rom/esp32/ld/esp32.rom.ld +++ b/components/esp_rom/esp32/ld/esp32.rom.ld @@ -663,6 +663,8 @@ PROVIDE ( ld_acl_rsw_frm_cbk = 0x40033bb0 ); PROVIDE ( ld_sco_modify = 0x40031778 ); PROVIDE ( lm_cmd_cmp_send = 0x40051838 ); PROVIDE ( ld_sco_frm_cbk = 0x400349dc ); +PROVIDE ( ld_sco_evt_stop_cbk = 0x40031d78 ); +PROVIDE ( ld_acl_rsw_evt_start_cbk = 0x40031154 ); PROVIDE ( ld_acl_sco_rsvd_check = 0x4002fa94 ); PROVIDE ( ld_acl_sniff_frm_cbk = 0x4003482c ); PROVIDE ( ld_inq_end = 0x4003ab48 ); @@ -1368,6 +1370,7 @@ PROVIDE ( esp_rom_spiflash_config_clk = 0x40062bc8 ); PROVIDE ( g_rom_spiflash_chip = 0x3ffae270 ); PROVIDE ( SPI_write_enable = 0x40062320 ); PROVIDE ( hci_le_rd_rem_used_feats_cmd_handler = 0x400417b4 ); +PROVIDE ( hci_per_inq_mode_cmd_handler = 0x400519b0 ); PROVIDE ( llcp_length_req_handler = 0x40043808 ); PROVIDE ( llcp_unknown_rsp_handler = 0x40043ba8 ); PROVIDE ( llcp_channel_map_req_handler = 0x4004291c ); diff --git a/components/esp_rom/esp32c2/ld/esp32c2.rom.ble-eco4.ld b/components/esp_rom/esp32c2/ld/esp32c2.rom.ble-eco4.ld new file mode 100644 index 0000000000..a71f2a1cf2 --- /dev/null +++ b/components/esp_rom/esp32c2/ld/esp32c2.rom.ble-eco4.ld @@ -0,0 +1,1230 @@ +/* + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* ROM function interface esp32c2.rom.ld for esp32c2 + * + * + * Generated from ./interface-esp32c2.yml md5sum c679b6ed5e9f0a9c3e7b93e5e0f2a1a3 + * + * Compatible with ROM where ECO version equal or greater to 1. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + + +/*************************************** + Group bluetooth + ***************************************/ + +/* Functions */ +ble_controller_rom_data_init = 0x40000aa8; +ble_osi_coex_funcs_register = 0x40000aac; +bt_rf_coex_cfg_get_default = 0x40000ab0; +bt_rf_coex_dft_pti_get_default = 0x40000ab4; +bt_rf_coex_hooks_p_set = 0x40000ab8; +r__os_mbuf_copypkthdr = 0x40000abc; +r__os_msys_find_pool = 0x40000ac0; +r_ble_controller_get_rom_compile_version = 0x40000ac4; +//r_ble_hci_ram_hs_acl_tx = 0x40000ac8; +//r_ble_hci_ram_hs_cmd_tx = 0x40000acc; +//r_ble_hci_ram_ll_acl_tx = 0x40000ad0; +//r_ble_hci_ram_ll_evt_tx = 0x40000ad4; +r_ble_hci_ram_reset = 0x40000ad8; +r_ble_hci_ram_set_acl_free_cb = 0x40000adc; +r_ble_hci_trans_acl_buf_alloc = 0x40000ae0; +r_ble_hci_trans_buf_alloc = 0x40000ae4; +r_ble_hci_trans_buf_free = 0x40000ae8; +r_ble_hci_trans_cfg_hs = 0x40000aec; +r_ble_hci_trans_cfg_ll = 0x40000af0; +r_ble_hci_trans_deinit = 0x40000af4; +//r_ble_hci_trans_env_init = 0x40000af8; +r_ble_hci_trans_init = 0x40000afc; +r_ble_hci_uart_acl_tx = 0x40000b00; +r_ble_hci_uart_cmdevt_tx = 0x40000b04; +r_ble_hci_uart_config = 0x40000b08; +r_ble_hci_uart_free_pkt = 0x40000b0c; +r_ble_hci_uart_hs_acl_tx = 0x40000b10; +r_ble_hci_uart_hs_cmd_tx = 0x40000b14; +r_ble_hci_uart_ll_acl_tx = 0x40000b18; +r_ble_hci_uart_ll_evt_tx = 0x40000b1c; +r_ble_hci_uart_rx_acl = 0x40000b20; +r_ble_hci_uart_rx_char = 0x40000b24; +r_ble_hci_uart_rx_cmd = 0x40000b28; +r_ble_hci_uart_rx_evt = 0x40000b2c; +r_ble_hci_uart_rx_evt_cb = 0x40000b30; +r_ble_hci_uart_rx_le_evt = 0x40000b34; +r_ble_hci_uart_rx_pkt_type = 0x40000b38; +r_ble_hci_uart_rx_skip_acl = 0x40000b3c; +r_ble_hci_uart_rx_skip_cmd = 0x40000b40; +r_ble_hci_uart_rx_skip_evt = 0x40000b44; +r_ble_hci_uart_rx_sync_loss = 0x40000b48; +r_ble_hci_uart_set_acl_free_cb = 0x40000b4c; +r_ble_hci_uart_sync_lost = 0x40000b50; +r_ble_hci_uart_trans_reset = 0x40000b54; +r_ble_hci_uart_tx_char = 0x40000b58; +r_ble_hci_uart_tx_pkt_type = 0x40000b5c; +r_ble_hw_driver_deinit = 0x40000b60; +r_ble_hw_driver_env_init = 0x40000b64; +r_ble_hw_encrypt_block = 0x40000b68; +r_ble_hw_get_public_addr = 0x40000b6c; +r_ble_hw_get_static_addr = 0x40000b70; +r_ble_hw_periodiclist_add = 0x40000b74; +r_ble_hw_periodiclist_clear = 0x40000b78; +r_ble_hw_periodiclist_rmv = 0x40000b7c; +r_ble_hw_resolv_list_cur_entry = 0x40000b80; +r_ble_hw_resolv_list_get_cur_entry = 0x40000b84; +r_ble_hw_resolv_list_set = 0x40000b88; +r_ble_hw_rng_init = 0x40000b8c; +r_ble_hw_rng_start = 0x40000b90; +r_ble_hw_rng_stop = 0x40000b94; +r_ble_hw_rx_local_is_resolved = 0x40000b98; +r_ble_hw_rx_local_is_rpa = 0x40000b9c; +r_ble_hw_whitelist_add = 0x40000ba0; +r_ble_hw_whitelist_clear = 0x40000ba4; +r_ble_hw_whitelist_dev_num = 0x40000ba8; +r_ble_hw_whitelist_get_base = 0x40000bac; +r_ble_hw_whitelist_rmv = 0x40000bb0; +r_ble_hw_whitelist_search = 0x40000bb4; +r_ble_hw_whitelist_sort = 0x40000bb8; +r_ble_ll_acl_data_in = 0x40000bbc; +r_ble_ll_addr_is_id = 0x40000bc0; +r_ble_ll_addr_subtype = 0x40000bc4; +r_ble_ll_adv_active_chanset_clear = 0x40000bc8; +r_ble_ll_adv_active_chanset_is_pri = 0x40000bcc; +r_ble_ll_adv_active_chanset_is_sec = 0x40000bd0; +r_ble_ll_adv_active_chanset_set_pri = 0x40000bd4; +r_ble_ll_adv_active_chanset_set_sec = 0x40000bd8; +r_ble_ll_adv_aux_calculate = 0x40000bdc; +r_ble_ll_adv_aux_conn_rsp_pdu_make = 0x40000be0; +r_ble_ll_adv_aux_pdu_make = 0x40000be4; +r_ble_ll_adv_aux_scannable_pdu_make = 0x40000be8; +r_ble_ll_adv_aux_txed = 0x40000bec; +r_ble_ll_adv_can_chg_whitelist = 0x40000bf0; +r_ble_ll_adv_chk_rpa_timeout = 0x40000bf4; +r_ble_ll_adv_clear_all = 0x40000bf8; +r_ble_ll_adv_conn_req_rxd = 0x40000bfc; +r_ble_ll_adv_deinit = 0x40000c00; +r_ble_ll_adv_enabled = 0x40000c04; +r_ble_ll_adv_env_init = 0x40000c08; +r_ble_ll_adv_ext_set_adv_data = 0x40000c0c; +r_ble_ll_adv_ext_set_enable = 0x40000c10; +//r_ble_ll_adv_ext_set_param = 0x40000c14; +r_ble_ll_adv_ext_set_scan_rsp = 0x40000c18; +r_ble_ll_adv_final_chan = 0x40000c1c; +r_ble_ll_adv_first_chan = 0x40000c20; +r_ble_ll_adv_flags_clear = 0x40000c24; +r_ble_ll_adv_flags_set = 0x40000c28; +r_ble_ll_adv_get_chan_num = 0x40000c2c; +r_ble_ll_adv_get_local_rpa = 0x40000c30; +r_ble_ll_adv_get_peer_rpa = 0x40000c34; +r_ble_ll_adv_hci_set_random_addr = 0x40000c38; +r_ble_ll_adv_init = 0x40000c3c; +r_ble_ll_adv_legacy_pdu_make = 0x40000c40; +r_ble_ll_adv_next_chan = 0x40000c44; +r_ble_ll_adv_pdu_make = 0x40000c48; +r_ble_ll_adv_periodic_check_data_itvl = 0x40000c4c; +r_ble_ll_adv_periodic_enable = 0x40000c50; +r_ble_ll_adv_periodic_estimate_data_itvl = 0x40000c54; +r_ble_ll_adv_periodic_send_sync_ind = 0x40000c58; +r_ble_ll_adv_periodic_set_data = 0x40000c5c; +r_ble_ll_adv_periodic_set_info_transfer = 0x40000c60; +r_ble_ll_adv_periodic_set_param = 0x40000c64; +r_ble_ll_adv_pre_process = 0x40000c68; +r_ble_ll_adv_put_acad_chM_update_ind = 0x40000c6c; +r_ble_ll_adv_put_aux_ptr = 0x40000c70; +r_ble_ll_adv_put_syncinfo = 0x40000c74; +r_ble_ll_adv_rd_max_adv_data_len = 0x40000c78; +r_ble_ll_adv_rd_sup_adv_sets = 0x40000c7c; +r_ble_ll_adv_read_txpwr = 0x40000c80; +r_ble_ll_adv_remove = 0x40000c84; +r_ble_ll_adv_reset = 0x40000c88; +r_ble_ll_adv_rpa_timeout = 0x40000c8c; +r_ble_ll_adv_rpa_update = 0x40000c90; +r_ble_ll_adv_rx_pkt_in = 0x40000c94; +r_ble_ll_adv_scan_req_rxd = 0x40000c98; +r_ble_ll_adv_scan_rsp_legacy_pdu_make = 0x40000c9c; +r_ble_ll_adv_scan_rsp_pdu_make = 0x40000ca0; +r_ble_ll_adv_scheduled = 0x40000ca4; +r_ble_ll_adv_send_conn_comp_ev = 0x40000ca8; +//r_ble_ll_adv_set_adv_data = 0x40000cac; +//r_ble_ll_adv_set_adv_params = 0x40000cb0; +//r_ble_ll_adv_set_enable = 0x40000cb4; +r_ble_ll_adv_set_random_addr = 0x40000cb8; +//r_ble_ll_adv_set_scan_rsp_data = 0x40000cbc; +r_ble_ll_adv_set_sched = 0x40000cc0; +r_ble_ll_adv_sm_deinit = 0x40000cc4; +r_ble_ll_adv_sm_event_init = 0x40000cc8; +r_ble_ll_adv_sm_find_configured = 0x40000ccc; +r_ble_ll_adv_sm_get = 0x40000cd0; +r_ble_ll_adv_sm_init = 0x40000cd4; +r_ble_ll_adv_sm_reset = 0x40000cd8; +r_ble_ll_adv_sm_start = 0x40000cdc; +r_ble_ll_adv_sm_start_periodic = 0x40000ce0; +r_ble_ll_adv_sm_stop = 0x40000ce4; +r_ble_ll_adv_sm_stop_limit_reached = 0x40000ce8; +r_ble_ll_adv_sm_stop_periodic = 0x40000cec; +r_ble_ll_adv_sm_stop_timeout = 0x40000cf0; +r_ble_ll_adv_sync_calculate = 0x40000cf4; +r_ble_ll_adv_sync_get_pdu_len = 0x40000cf8; +r_ble_ll_adv_sync_pdu_make = 0x40000cfc; +r_ble_ll_adv_update_adv_scan_rsp_data = 0x40000d00; +r_ble_ll_adv_update_data_mbuf = 0x40000d04; +r_ble_ll_adv_update_did = 0x40000d08; +r_ble_ll_adv_update_periodic_data = 0x40000d0c; +r_ble_ll_arr_pool_init = 0x40000d10; +r_ble_ll_auth_pyld_tmo_event_send = 0x40000d14; +r_ble_ll_calc_offset_ticks_us_for_rampup = 0x40000d18; +r_ble_ll_calc_session_key = 0x40000d1c; +r_ble_ll_calc_ticks_per_slot = 0x40000d20; +//r_ble_ll_check_scan_params = 0x40000d24; +r_ble_ll_chk_txrx_octets = 0x40000d28; +r_ble_ll_chk_txrx_time = 0x40000d2c; +r_ble_ll_conn_adjust_pyld_len = 0x40000d30; +r_ble_ll_conn_auth_pyld_timer_cb = 0x40000d34; +r_ble_ll_conn_auth_pyld_timer_start = 0x40000d38; +r_ble_ll_conn_calc_dci = 0x40000d3c; +r_ble_ll_conn_calc_dci_csa1 = 0x40000d40; +r_ble_ll_conn_calc_itvl_ticks = 0x40000d44; +r_ble_ll_conn_chk_csm_flags = 0x40000d48; +r_ble_ll_conn_chk_phy_upd_start = 0x40000d4c; +r_ble_ll_conn_comp_event_send = 0x40000d50; +r_ble_ll_conn_connect_ind_pdu_make = 0x40000d54; +r_ble_ll_conn_create = 0x40000d58; +r_ble_ll_conn_create_cancel = 0x40000d5c; +r_ble_ll_conn_created = 0x40000d60; +r_ble_ll_conn_cth_flow_enable = 0x40000d64; +r_ble_ll_conn_cth_flow_error_fn = 0x40000d68; +r_ble_ll_conn_cth_flow_have_credit = 0x40000d6c; +r_ble_ll_conn_cth_flow_is_enabled = 0x40000d70; +r_ble_ll_conn_cth_flow_process_cmd = 0x40000d74; +r_ble_ll_conn_cth_flow_set_buffers = 0x40000d78; +r_ble_ll_conn_enqueue_pkt = 0x40000d7c; +r_ble_ll_conn_env_init = 0x40000d80; +r_ble_ll_conn_ext_master_init = 0x40000d84; +r_ble_ll_conn_find_active_conn = 0x40000d88; +r_ble_ll_conn_get_active_conn = 0x40000d8c; +r_ble_ll_conn_get_anchor = 0x40000d90; +r_ble_ll_conn_hcc_params_set_fallback = 0x40000d94; +r_ble_ll_conn_hci_cancel_conn_complete_event = 0x40000d98; +r_ble_ll_conn_hci_chk_conn_params = 0x40000d9c; +r_ble_ll_conn_hci_chk_scan_params = 0x40000da0; +r_ble_ll_conn_hci_disconnect_cmd = 0x40000da4; +r_ble_ll_conn_hci_le_ltk_neg_reply = 0x40000da8; +r_ble_ll_conn_hci_le_ltk_reply = 0x40000dac; +r_ble_ll_conn_hci_le_rd_phy = 0x40000db0; +r_ble_ll_conn_hci_le_set_phy = 0x40000db4; +r_ble_ll_conn_hci_le_start_encrypt = 0x40000db8; +r_ble_ll_conn_hci_param_nrr = 0x40000dbc; +r_ble_ll_conn_hci_param_rr = 0x40000dc0; +r_ble_ll_conn_hci_rd_auth_pyld_tmo = 0x40000dc4; +r_ble_ll_conn_hci_rd_chan_map = 0x40000dc8; +r_ble_ll_conn_hci_rd_rem_ver_cmd = 0x40000dcc; +r_ble_ll_conn_hci_rd_rssi = 0x40000dd0; +r_ble_ll_conn_hci_read_rem_features = 0x40000dd4; +r_ble_ll_conn_hci_set_chan_class = 0x40000dd8; +r_ble_ll_conn_hci_set_data_len = 0x40000ddc; +r_ble_ll_conn_hci_update = 0x40000de0; +r_ble_ll_conn_hci_wr_auth_pyld_tmo = 0x40000de4; +r_ble_ll_conn_init_phy = 0x40000de8; +r_ble_ll_conn_is_dev_connected = 0x40000dec; +r_ble_ll_conn_is_empty_pdu = 0x40000df0; +r_ble_ll_conn_is_lru = 0x40000df4; +r_ble_ll_conn_master_init = 0x40000df8; +r_ble_ll_conn_module_deinit = 0x40000dfc; +r_ble_ll_conn_module_init = 0x40000e00; +r_ble_ll_conn_module_reset = 0x40000e04; +r_ble_ll_conn_next_event = 0x40000e08; +r_ble_ll_conn_num_comp_pkts_event_send = 0x40000e0c; +r_ble_ll_conn_prepare_tx_pdu = 0x40000e10; +r_ble_ll_conn_process_conn_params = 0x40000e14; +r_ble_ll_conn_req_peer_sca = 0x40000e18; +//r_ble_ll_conn_rx_data_pdu = 0x40000e1c; +r_ble_ll_conn_set_csa = 0x40000e20; +r_ble_ll_conn_set_ext_con_params = 0x40000e24; +r_ble_ll_conn_set_global_chanmap = 0x40000e28; +r_ble_ll_conn_set_phy = 0x40000e2c; +r_ble_ll_conn_set_txpwr_by_handle = 0x40000e30; +r_ble_ll_conn_set_unknown_rx_octets = 0x40000e34; +//r_ble_ll_conn_slave_start = 0x40000e38; +r_ble_ll_conn_sm_get = 0x40000e3c; +r_ble_ll_conn_sm_new = 0x40000e40; +r_ble_ll_conn_sm_npl_deinit = 0x40000e44; +r_ble_ll_conn_sm_npl_init = 0x40000e48; +r_ble_ll_conn_tx_pkt_in = 0x40000e4c; +r_ble_ll_conn_update_eff_data_len = 0x40000e50; +r_ble_ll_ctrl_chanmap_req_make = 0x40000e54; +r_ble_ll_ctrl_chk_proc_start = 0x40000e58; +r_ble_ll_ctrl_conn_param_pdu_make = 0x40000e5c; +r_ble_ll_ctrl_conn_param_pdu_proc = 0x40000e60; +r_ble_ll_ctrl_conn_param_reply = 0x40000e64; +r_ble_ll_ctrl_conn_upd_make = 0x40000e68; +r_ble_ll_ctrl_datalen_upd_make = 0x40000e6c; +r_ble_ll_ctrl_enc_allowed_pdu = 0x40000e70; +r_ble_ll_ctrl_enc_allowed_pdu_rx = 0x40000e74; +r_ble_ll_ctrl_enc_allowed_pdu_tx = 0x40000e78; +r_ble_ll_ctrl_enc_req_make = 0x40000e7c; +r_ble_ll_ctrl_find_new_phy = 0x40000e80; +r_ble_ll_ctrl_initiate_dle = 0x40000e84; +r_ble_ll_ctrl_len_proc = 0x40000e88; +r_ble_ll_ctrl_min_used_chan_rsp = 0x40000e8c; +r_ble_ll_ctrl_phy_from_phy_mask = 0x40000e90; +r_ble_ll_ctrl_phy_req_rsp_make = 0x40000e94; +r_ble_ll_ctrl_phy_tx_transition_get = 0x40000e98; +r_ble_ll_ctrl_phy_update_cancel = 0x40000e9c; +r_ble_ll_ctrl_phy_update_ind_make = 0x40000ea0; +r_ble_ll_ctrl_phy_update_proc_complete = 0x40000ea4; +r_ble_ll_ctrl_proc_init = 0x40000ea8; +r_ble_ll_ctrl_proc_rsp_timer_cb = 0x40000eac; +r_ble_ll_ctrl_proc_start = 0x40000eb0; +r_ble_ll_ctrl_proc_stop = 0x40000eb4; +r_ble_ll_ctrl_proc_unk_rsp = 0x40000eb8; +r_ble_ll_ctrl_proc_with_instant_initiated = 0x40000ebc; +r_ble_ll_ctrl_rej_ext_ind_make = 0x40000ec0; +r_ble_ll_ctrl_reject_ind_send = 0x40000ec4; +r_ble_ll_ctrl_rx_chanmap_req = 0x40000ec8; +r_ble_ll_ctrl_rx_conn_param_req = 0x40000ecc; +//r_ble_ll_ctrl_rx_conn_param_rsp = 0x40000ed0; +//r_ble_ll_ctrl_rx_conn_update = 0x40000ed4; +r_ble_ll_ctrl_rx_enc_req = 0x40000ed8; +r_ble_ll_ctrl_rx_enc_rsp = 0x40000edc; +r_ble_ll_ctrl_rx_feature_req = 0x40000ee0; +r_ble_ll_ctrl_rx_feature_rsp = 0x40000ee4; +r_ble_ll_ctrl_rx_pause_enc_req = 0x40000ee8; +r_ble_ll_ctrl_rx_pause_enc_rsp = 0x40000eec; +r_ble_ll_ctrl_rx_pdu = 0x40000ef0; +r_ble_ll_ctrl_rx_periodic_sync_ind = 0x40000ef4; +r_ble_ll_ctrl_rx_phy_req = 0x40000ef8; +r_ble_ll_ctrl_rx_phy_rsp = 0x40000efc; +r_ble_ll_ctrl_rx_phy_update_ind = 0x40000f00; +r_ble_ll_ctrl_rx_ping_rsp = 0x40000f04; +r_ble_ll_ctrl_rx_reject_ind = 0x40000f08; +r_ble_ll_ctrl_rx_sca_req = 0x40000f0c; +r_ble_ll_ctrl_rx_sca_rsp = 0x40000f10; +r_ble_ll_ctrl_rx_start_enc_req = 0x40000f14; +r_ble_ll_ctrl_rx_start_enc_rsp = 0x40000f18; +r_ble_ll_ctrl_rx_version_ind = 0x40000f1c; +r_ble_ll_ctrl_sca_req_rsp_make = 0x40000f20; +r_ble_ll_ctrl_start_enc_send = 0x40000f24; +r_ble_ll_ctrl_start_rsp_timer = 0x40000f28; +r_ble_ll_ctrl_terminate_start = 0x40000f2c; +r_ble_ll_ctrl_tx_done = 0x40000f30; +r_ble_ll_ctrl_update_features = 0x40000f34; +r_ble_ll_ctrl_version_ind_make = 0x40000f38; +r_ble_ll_data_buffer_overflow = 0x40000f3c; +r_ble_ll_deinit = 0x40000f40; +r_ble_ll_disconn_comp_event_send = 0x40000f44; +//r_ble_ll_env_init = 0x40000f48; +r_ble_ll_event_comp_pkts = 0x40000f4c; +r_ble_ll_event_dbuf_overflow = 0x40000f50; +r_ble_ll_event_send = 0x40000f54; +r_ble_ll_event_tx_pkt = 0x40000f58; +r_ble_ll_ext_adv_phy_mode_to_local_phy = 0x40000f5c; +r_ble_ll_ext_conn_create = 0x40000f60; +r_ble_ll_ext_scan_parse_adv_info = 0x40000f64; +r_ble_ll_ext_scan_parse_aux_ptr = 0x40000f68; +r_ble_ll_flush_pkt_queue = 0x40000f6c; +r_ble_ll_generate_dh_key_v1 = 0x40000f70; +r_ble_ll_generate_dh_key_v2 = 0x40000f74; +r_ble_ll_generic_data_init = 0x40000f78; +r_ble_ll_get_addr_type = 0x40000f7c; +r_ble_ll_get_chan_to_scan = 0x40000f80; +r_ble_ll_get_our_devaddr = 0x40000f84; +r_ble_ll_get_tx_pwr_compensation = 0x40000f88; +r_ble_ll_hci_acl_rx = 0x40000f8c; +r_ble_ll_hci_adv_mode_ext = 0x40000f90; +r_ble_ll_hci_adv_set_enable = 0x40000f94; +r_ble_ll_hci_cb_host_buf_size = 0x40000f98; +r_ble_ll_hci_cb_set_ctrlr_to_host_fc = 0x40000f9c; +r_ble_ll_hci_cb_set_event_mask = 0x40000fa0; +r_ble_ll_hci_cb_set_event_mask2 = 0x40000fa4; +r_ble_ll_hci_chk_phy_masks = 0x40000fa8; +r_ble_ll_hci_cmd_proc = 0x40000fac; +r_ble_ll_hci_cmd_rx = 0x40000fb0; +r_ble_ll_hci_ctlr_bb_cmd_proc = 0x40000fb4; +r_ble_ll_hci_deinit = 0x40000fb8; +r_ble_ll_hci_disconnect = 0x40000fbc; +r_ble_ll_hci_env_init = 0x40000fc0; +r_ble_ll_hci_ev_conn_update = 0x40000fc4; +r_ble_ll_hci_ev_databuf_overflow = 0x40000fc8; +r_ble_ll_hci_ev_datalen_chg = 0x40000fcc; +r_ble_ll_hci_ev_encrypt_chg = 0x40000fd0; +r_ble_ll_hci_ev_hw_err = 0x40000fd4; +r_ble_ll_hci_ev_le_csa = 0x40000fd8; +r_ble_ll_hci_ev_ltk_req = 0x40000fdc; +r_ble_ll_hci_ev_phy_update = 0x40000fe0; +r_ble_ll_hci_ev_rd_rem_used_feat = 0x40000fe4; +r_ble_ll_hci_ev_rd_rem_ver = 0x40000fe8; +r_ble_ll_hci_ev_rem_conn_parm_req = 0x40000fec; +r_ble_ll_hci_ev_sca_update = 0x40000ff0; +r_ble_ll_hci_ev_send_adv_set_terminated = 0x40000ff4; +r_ble_ll_hci_ev_send_scan_req_recv = 0x40000ff8; +r_ble_ll_hci_ev_send_scan_timeout = 0x40000ffc; +r_ble_ll_hci_ev_send_vendor_err = 0x40001000; +//r_ble_ll_hci_event_send = 0x40001004; +r_ble_ll_hci_ext_scan_set_enable = 0x40001008; +r_ble_ll_hci_get_num_cmd_pkts = 0x4000100c; +r_ble_ll_hci_info_params_cmd_proc = 0x40001010; +r_ble_ll_hci_init = 0x40001014; +r_ble_ll_hci_init_support_cmd_base_on_lmp_ver = 0x40001018; +r_ble_ll_hci_is_event_enabled = 0x4000101c; +r_ble_ll_hci_is_le_event_enabled = 0x40001020; +r_ble_ll_hci_le_cmd_proc = 0x40001024; +r_ble_ll_hci_le_cmd_send_cmd_status = 0x40001028; +r_ble_ll_hci_le_encrypt = 0x4000102c; +r_ble_ll_hci_le_rand = 0x40001030; +r_ble_ll_hci_le_rd_max_data_len = 0x40001034; +r_ble_ll_hci_le_rd_sugg_data_len = 0x40001038; +r_ble_ll_hci_le_read_bufsize = 0x4000103c; +r_ble_ll_hci_le_read_local_features = 0x40001040; +r_ble_ll_hci_le_read_supp_states = 0x40001044; +r_ble_ll_hci_le_set_def_phy = 0x40001048; +r_ble_ll_hci_le_wr_sugg_data_len = 0x4000104c; +r_ble_ll_hci_link_ctrl_cmd_proc = 0x40001050; +r_ble_ll_hci_npl_init = 0x40001054; +r_ble_ll_hci_post_gen_dhkey_cmp_evt = 0x40001058; +r_ble_ll_hci_post_rd_p256_pubkey_cmp_evt = 0x4000105c; +r_ble_ll_hci_rd_bd_addr = 0x40001060; +r_ble_ll_hci_rd_local_supp_cmd = 0x40001064; +r_ble_ll_hci_rd_local_supp_feat = 0x40001068; +r_ble_ll_hci_rd_local_version = 0x4000106c; +r_ble_ll_hci_scan_set_enable = 0x40001070; +r_ble_ll_hci_send_adv_report = 0x40001074; +r_ble_ll_hci_send_dir_adv_report = 0x40001078; +//r_ble_ll_hci_send_ext_adv_report = 0x4000107c; +//r_ble_ll_hci_send_legacy_ext_adv_report = 0x40001080; +r_ble_ll_hci_send_noop = 0x40001084; +r_ble_ll_hci_set_adv_data = 0x40001088; +r_ble_ll_hci_set_le_event_mask = 0x4000108c; +r_ble_ll_hci_set_scan_rsp_data = 0x40001090; +r_ble_ll_hci_status_params_cmd_proc = 0x40001094; +r_ble_ll_hci_vs_cmd_proc = 0x40001098; +r_ble_ll_hci_vs_rd_static_addr = 0x4000109c; +r_ble_ll_hw_err_timer_cb = 0x400010a0; +r_ble_ll_hw_error = 0x400010a4; +//r_ble_ll_init = 0x400010a8; +r_ble_ll_init_alloc_conn_comp_ev = 0x400010ac; +r_ble_ll_init_get_conn_comp_ev = 0x400010b0; +r_ble_ll_init_rx_pkt_in = 0x400010b4; +r_ble_ll_is_addr_empty = 0x400010b8; +r_ble_ll_is_controller_busy = 0x400010bc; +r_ble_ll_is_on_resolv_list = 0x400010c0; +r_ble_ll_is_our_devaddr = 0x400010c4; +r_ble_ll_is_rpa = 0x400010c8; +r_ble_ll_is_valid_adv_mode = 0x400010cc; +r_ble_ll_is_valid_own_addr_type = 0x400010d0; +r_ble_ll_is_valid_public_addr = 0x400010d4; +r_ble_ll_is_valid_random_addr = 0x400010d8; +r_ble_ll_mbuf_init = 0x400010dc; +r_ble_ll_misc_options_set = 0x400010e0; +r_ble_ll_modify_sca = 0x400010e4; +r_ble_ll_modify_sca_action = 0x400010e8; +r_ble_ll_pdu_max_tx_octets_get = 0x400010ec; +r_ble_ll_pdu_tx_time_get = 0x400010f0; +r_ble_ll_phy_to_phy_mode = 0x400010f4; +r_ble_ll_qa_enable = 0x400010f8; +r_ble_ll_rand = 0x400010fc; +r_ble_ll_rand_data_get = 0x40001100; +r_ble_ll_rand_deinit = 0x40001104; +r_ble_ll_rand_env_init = 0x40001108; +r_ble_ll_rand_init = 0x4000110c; +r_ble_ll_rand_prand_get = 0x40001110; +r_ble_ll_rand_sample = 0x40001114; +r_ble_ll_rand_start = 0x40001118; +r_ble_ll_read_local_p256_pub_key = 0x4000111c; +r_ble_ll_read_rf_path_compensation = 0x40001120; +r_ble_ll_read_supp_features = 0x40001124; +r_ble_ll_read_supp_states = 0x40001128; +r_ble_ll_read_tx_power = 0x4000112c; +r_ble_ll_reset = 0x40001130; +r_ble_ll_resolv_clear_all_pl_bit = 0x40001134; +r_ble_ll_resolv_clear_all_wl_bit = 0x40001138; +r_ble_ll_resolv_deinit = 0x4000113c; +r_ble_ll_resolv_enable_cmd = 0x40001140; +r_ble_ll_resolv_enabled = 0x40001144; +r_ble_ll_resolv_env_init = 0x40001148; +r_ble_ll_resolv_gen_priv_addr = 0x4000114c; +r_ble_ll_resolv_gen_rpa = 0x40001150; +r_ble_ll_resolv_get_addr_pointer = 0x40001154; +r_ble_ll_resolv_get_index = 0x40001158; +r_ble_ll_resolv_get_irk_pointer = 0x4000115c; +r_ble_ll_resolv_get_list = 0x40001160; +r_ble_ll_resolv_get_priv_addr = 0x40001164; +r_ble_ll_resolv_get_rpa_tmo = 0x40001168; +r_ble_ll_resolv_init = 0x4000116c; +r_ble_ll_resolv_irk_nonzero = 0x40001170; +r_ble_ll_resolv_list_add = 0x40001174; +r_ble_ll_resolv_list_chg_allowed = 0x40001178; +r_ble_ll_resolv_list_clr = 0x4000117c; +r_ble_ll_resolv_list_find = 0x40001180; +r_ble_ll_resolv_list_read_size = 0x40001184; +r_ble_ll_resolv_list_reset = 0x40001188; +r_ble_ll_resolv_list_rmv = 0x4000118c; +r_ble_ll_resolv_local_addr_rd = 0x40001190; +r_ble_ll_resolv_peer_addr_rd = 0x40001194; +r_ble_ll_resolv_peer_rpa_any = 0x40001198; +r_ble_ll_resolv_reset = 0x4000119c; +r_ble_ll_resolv_rpa = 0x400011a0; +r_ble_ll_resolv_rpa_timer_cb = 0x400011a4; +r_ble_ll_resolv_set_local_rpa = 0x400011a8; +r_ble_ll_resolv_set_peer_rpa = 0x400011ac; +r_ble_ll_resolv_set_rpa_tmo = 0x400011b0; +r_ble_ll_resolve_set_priv_mode = 0x400011b4; +r_ble_ll_rxpdu_alloc = 0x400011b8; +r_ble_ll_scan_add_scan_rsp_adv = 0x400011bc; +r_ble_ll_scan_adv_decode_addr = 0x400011c0; +r_ble_ll_scan_aux_data_ref = 0x400011c4; +r_ble_ll_scan_aux_data_unref = 0x400011c8; +r_ble_ll_scan_can_chg_whitelist = 0x400011cc; +r_ble_ll_scan_check_periodic_sync = 0x400011d0; +r_ble_ll_scan_classify_filter_aux_init = 0x400011d4; +r_ble_ll_scan_classify_filter_init = 0x400011d8; +//r_ble_ll_scan_common_init = 0x400011dc; +r_ble_ll_scan_continue_en = 0x400011e0; +r_ble_ll_scan_deinit = 0x400011e4; +r_ble_ll_scan_dup_check_ext = 0x400011e8; +r_ble_ll_scan_dup_check_legacy = 0x400011ec; +r_ble_ll_scan_dup_move_to_head = 0x400011f0; +r_ble_ll_scan_dup_new = 0x400011f4; +r_ble_ll_scan_dup_update_ext = 0x400011f8; +r_ble_ll_scan_dup_update_legacy = 0x400011fc; +r_ble_ll_scan_enabled = 0x40001200; +r_ble_ll_scan_end_adv_evt = 0x40001204; +//r_ble_ll_scan_env_init = 0x40001208; +r_ble_ll_scan_ext_initiator_start = 0x4000120c; +r_ble_ll_scan_get_addr_data_from_legacy = 0x40001210; +r_ble_ll_scan_get_addr_from_ext_adv = 0x40001214; +r_ble_ll_scan_get_cur_sm = 0x40001218; +r_ble_ll_scan_get_ext_adv_report = 0x4000121c; +r_ble_ll_scan_get_local_rpa = 0x40001220; +r_ble_ll_scan_get_next_adv_prim_chan = 0x40001224; +r_ble_ll_scan_get_peer_rpa = 0x40001228; +r_ble_ll_scan_have_rxd_scan_rsp = 0x4000122c; +r_ble_ll_scan_init = 0x40001230; +r_ble_ll_scan_initiator_start = 0x40001234; +r_ble_ll_scan_is_inside_window = 0x40001238; +r_ble_ll_scan_move_window_to = 0x4000123c; +r_ble_ll_scan_npl_reset = 0x40001240; +r_ble_ll_scan_parse_auxptr = 0x40001244; +r_ble_ll_scan_parse_ext_hdr = 0x40001248; +r_ble_ll_scan_pre_process = 0x4000124c; +r_ble_ll_scan_record_new_adv = 0x40001250; +r_ble_ll_scan_refresh_nrpa = 0x40001254; +r_ble_ll_scan_reset = 0x40001258; +r_ble_ll_scan_rx_pkt_in = 0x4000125c; +//r_ble_ll_scan_rx_pkt_in_on_aux = 0x40001260; +r_ble_ll_scan_rx_pkt_in_on_legacy = 0x40001264; +r_ble_ll_scan_rx_pkt_in_restore_addr_data = 0x40001268; +r_ble_ll_scan_rxed = 0x4000126c; +//r_ble_ll_scan_send_adv_report = 0x40001270; +r_ble_ll_scan_send_truncated = 0x40001274; +r_ble_ll_scan_set_enable = 0x40001278; +r_ble_ll_scan_set_peer_rpa = 0x4000127c; +r_ble_ll_scan_set_perfer_addr = 0x40001280; +r_ble_ll_scan_set_scan_params = 0x40001284; +r_ble_ll_scan_sm_start = 0x40001288; +r_ble_ll_scan_sm_stop = 0x4000128c; +r_ble_ll_scan_time_hci_to_ticks = 0x40001290; +r_ble_ll_scan_update_aux_data = 0x40001294; +r_ble_ll_scan_whitelist_enabled = 0x40001298; +r_ble_ll_set_default_privacy_mode = 0x4000129c; +r_ble_ll_set_default_sync_transfer_params = 0x400012a0; +r_ble_ll_set_ext_scan_params = 0x400012a4; +r_ble_ll_set_host_feat = 0x400012a8; +r_ble_ll_set_public_addr = 0x400012ac; +r_ble_ll_set_random_addr = 0x400012b0; +r_ble_ll_set_sync_transfer_params = 0x400012b4; +r_ble_ll_state_get = 0x400012b8; +r_ble_ll_state_set = 0x400012bc; +r_ble_ll_sync_adjust_ext_hdr = 0x400012c0; +r_ble_ll_sync_cancel = 0x400012c4; +r_ble_ll_sync_cancel_complete_event = 0x400012c8; +r_ble_ll_sync_check_acad = 0x400012cc; +r_ble_ll_sync_check_failed = 0x400012d0; +r_ble_ll_sync_create = 0x400012d4; +r_ble_ll_sync_deinit = 0x400012d8; +r_ble_ll_sync_enabled = 0x400012dc; +r_ble_ll_sync_env_init = 0x400012e0; +r_ble_ll_sync_est_event_failed = 0x400012e4; +r_ble_ll_sync_est_event_success = 0x400012e8; +r_ble_ll_sync_established = 0x400012ec; +r_ble_ll_sync_filter_enabled = 0x400012f0; +r_ble_ll_sync_find = 0x400012f4; +r_ble_ll_sync_get_cur_sm = 0x400012f8; +r_ble_ll_sync_get_handle = 0x400012fc; +r_ble_ll_sync_get_sm = 0x40001300; +r_ble_ll_sync_info_event = 0x40001304; +r_ble_ll_sync_init = 0x40001308; +r_ble_ll_sync_list_add = 0x4000130c; +r_ble_ll_sync_list_clear = 0x40001310; +r_ble_ll_sync_list_empty = 0x40001314; +r_ble_ll_sync_list_get_free = 0x40001318; +r_ble_ll_sync_list_remove = 0x4000131c; +r_ble_ll_sync_list_search = 0x40001320; +r_ble_ll_sync_list_size = 0x40001324; +r_ble_ll_sync_lost_event = 0x40001328; +r_ble_ll_sync_next_event = 0x4000132c; +r_ble_ll_sync_on_list = 0x40001330; +//r_ble_ll_sync_parse_ext_hdr = 0x40001334; +r_ble_ll_sync_periodic_ind = 0x40001338; +r_ble_ll_sync_phy_mode_to_aux_phy = 0x4000133c; +r_ble_ll_sync_phy_mode_to_hci = 0x40001340; +r_ble_ll_sync_put_syncinfo = 0x40001344; +r_ble_ll_sync_receive_enable = 0x40001348; +r_ble_ll_sync_reserve = 0x4000134c; +r_ble_ll_sync_reset = 0x40001350; +r_ble_ll_sync_reset_sm = 0x40001354; +r_ble_ll_sync_rx_pkt_in = 0x40001358; +r_ble_ll_sync_send_per_adv_rpt = 0x4000135c; +r_ble_ll_sync_send_sync_ind = 0x40001360; +r_ble_ll_sync_send_truncated_per_adv_rpt = 0x40001364; +r_ble_ll_sync_sm_clear = 0x40001368; +r_ble_ll_sync_terminate = 0x4000136c; +r_ble_ll_sync_transfer = 0x40001370; +r_ble_ll_sync_transfer_get = 0x40001374; +r_ble_ll_sync_transfer_received = 0x40001378; +r_ble_ll_task = 0x4000137c; +r_ble_ll_trace_set_func = 0x40001380; +r_ble_ll_trace_u32 = 0x40001384; +r_ble_ll_trace_u32x2 = 0x40001388; +r_ble_ll_trace_u32x3 = 0x4000138c; +r_ble_ll_tx_flat_mbuf_pducb = 0x40001390; +r_ble_ll_tx_mbuf_pducb = 0x40001394; +r_ble_ll_tx_pkt_in = 0x40001398; +r_ble_ll_update_max_tx_octets_phy_mode = 0x4000139c; +r_ble_ll_usecs_to_ticks_round_up = 0x400013a0; +r_ble_ll_utils_calc_access_addr = 0x400013a4; +r_ble_ll_utils_calc_dci_csa2 = 0x400013a8; +r_ble_ll_utils_calc_num_used_chans = 0x400013ac; +r_ble_ll_utils_calc_window_widening = 0x400013b0; +r_ble_ll_utils_csa2_perm = 0x400013b4; +r_ble_ll_utils_csa2_prng = 0x400013b8; +r_ble_ll_utils_remapped_channel = 0x400013bc; +r_ble_ll_whitelist_add = 0x400013c0; +r_ble_ll_whitelist_chg_allowed = 0x400013c4; +r_ble_ll_whitelist_clear = 0x400013c8; +r_ble_ll_whitelist_read_size = 0x400013cc; +r_ble_ll_whitelist_rmv = 0x400013d0; +r_ble_ll_whitelist_search = 0x400013d4; +r_ble_ll_write_rf_path_compensation = 0x400013d8; +r_ble_lll_adv_aux_scannable_pdu_payload_len = 0x400013dc; +r_ble_lll_adv_aux_schedule = 0x400013e0; +r_ble_lll_adv_aux_schedule_first = 0x400013e4; +r_ble_lll_adv_aux_schedule_next = 0x400013e8; +r_ble_lll_adv_aux_scheduled = 0x400013ec; +r_ble_lll_adv_aux_set_start_time = 0x400013f0; +r_ble_lll_adv_coex_dpc_calc_pti_update_itvl = 0x400013f4; +r_ble_lll_adv_coex_dpc_process_pri = 0x400013f8; +r_ble_lll_adv_coex_dpc_process_sec = 0x400013fc; +r_ble_lll_adv_coex_dpc_pti_get = 0x40001400; +r_ble_lll_adv_coex_dpc_update = 0x40001404; +r_ble_lll_adv_coex_dpc_update_on_adv_start = 0x40001408; +r_ble_lll_adv_coex_dpc_update_on_aux_scheduled = 0x4000140c; +r_ble_lll_adv_coex_dpc_update_on_data_updated = 0x40001410; +r_ble_lll_adv_coex_dpc_update_on_event_end = 0x40001414; +r_ble_lll_adv_coex_dpc_update_on_event_scheduled = 0x40001418; +r_ble_lll_adv_done = 0x4000141c; +r_ble_lll_adv_drop_event = 0x40001420; +r_ble_lll_adv_event_done = 0x40001424; +r_ble_lll_adv_event_rmvd_from_sched = 0x40001428; +r_ble_lll_adv_ext_estimate_data_itvl = 0x4000142c; +r_ble_lll_adv_get_sec_pdu_len = 0x40001430; +r_ble_lll_adv_halt = 0x40001434; +r_ble_lll_adv_make_done = 0x40001438; +r_ble_lll_adv_periodic_done = 0x4000143c; +r_ble_lll_adv_periodic_event_done = 0x40001440; +r_ble_lll_adv_periodic_rmvd_from_sched = 0x40001444; +r_ble_lll_adv_periodic_schedule_first = 0x40001448; +r_ble_lll_adv_periodic_schedule_next = 0x4000144c; +r_ble_lll_adv_periodic_start = 0x40001450; +r_ble_lll_adv_periodic_stop = 0x40001454; +r_ble_lll_adv_pri_schedule_tx_pdu = 0x40001458; +r_ble_lll_adv_reschedule_event = 0x4000145c; +r_ble_lll_adv_reschedule_periodic_event = 0x40001460; +r_ble_lll_adv_rx_pkt_isr = 0x40001464; +r_ble_lll_adv_sec_done = 0x40001468; +r_ble_lll_adv_sec_event_done = 0x4000146c; +r_ble_lll_adv_sec_schedule_next_aux = 0x40001470; +r_ble_lll_adv_secondary_tx_start_cb = 0x40001474; +r_ble_lll_adv_sm_deinit = 0x40001478; +r_ble_lll_adv_sm_event_init = 0x4000147c; +r_ble_lll_adv_sm_event_restore = 0x40001480; +r_ble_lll_adv_sm_event_store = 0x40001484; +r_ble_lll_adv_sm_init = 0x40001488; +r_ble_lll_adv_sm_reset = 0x4000148c; +r_ble_lll_adv_start = 0x40001490; +r_ble_lll_adv_stop = 0x40001494; +r_ble_lll_adv_sync_next_scheduled = 0x40001498; +r_ble_lll_adv_sync_schedule = 0x4000149c; +r_ble_lll_adv_sync_tx_done = 0x400014a0; +r_ble_lll_adv_sync_tx_end = 0x400014a4; +r_ble_lll_adv_sync_tx_start_cb = 0x400014a8; +r_ble_lll_adv_tx_done = 0x400014ac; +r_ble_lll_adv_tx_start_cb = 0x400014b0; +r_ble_lll_adv_update_rsp_offset = 0x400014b4; +r_ble_lll_aux_scan_cb = 0x400014b8; +r_ble_lll_aux_scan_drop = 0x400014bc; +r_ble_lll_aux_scan_drop_event_cb = 0x400014c0; +r_ble_lll_calc_us_convert_tick_unit = 0x400014c4; +r_ble_lll_conn_append_tx_buffer = 0x400014c8; +r_ble_lll_conn_can_send_next_pdu = 0x400014cc; +r_ble_lll_conn_check_opcode_matched = 0x400014d0; +r_ble_lll_conn_coex_dpc_process = 0x400014d4; +r_ble_lll_conn_coex_dpc_pti_get = 0x400014d8; +r_ble_lll_conn_coex_dpc_update = 0x400014dc; +r_ble_lll_conn_coex_dpc_update_on_event_end = 0x400014e0; +r_ble_lll_conn_coex_dpc_update_on_event_scheduled = 0x400014e4; +r_ble_lll_conn_coex_dpc_update_on_event_started = 0x400014e8; +r_ble_lll_conn_cth_flow_alloc_credit = 0x400014ec; +r_ble_lll_conn_cth_flow_free_credit = 0x400014f0; +r_ble_lll_conn_current_sm_over = 0x400014f4; +r_ble_lll_conn_end = 0x400014f8; +r_ble_lll_conn_env_deinit = 0x400014fc; +r_ble_lll_conn_env_init = 0x40001500; +r_ble_lll_conn_event_end = 0x40001504; +r_ble_lll_conn_event_end_timer_cb = 0x40001508; +r_ble_lll_conn_event_halt = 0x4000150c; +r_ble_lll_conn_event_is_over = 0x40001510; +r_ble_lll_conn_event_start_cb = 0x40001514; +r_ble_lll_conn_free_rx_mbuf = 0x40001518; +r_ble_lll_conn_get_addr_info_from_rx_buf = 0x4000151c; +r_ble_lll_conn_get_ce_end_time = 0x40001520; +r_ble_lll_conn_get_next_sched_time = 0x40001524; +r_ble_lll_conn_get_rx_mbuf = 0x40001528; +r_ble_lll_conn_halt = 0x4000152c; +r_ble_lll_conn_master_common_init = 0x40001530; +r_ble_lll_conn_master_new = 0x40001534; +r_ble_lll_conn_module_deinit = 0x40001538; +r_ble_lll_conn_module_init = 0x4000153c; +r_ble_lll_conn_module_reset = 0x40001540; +r_ble_lll_conn_no_mem_evt_pre_cb = 0x40001544; +r_ble_lll_conn_pre_process = 0x40001548; +r_ble_lll_conn_process_acked_pdu = 0x4000154c; +r_ble_lll_conn_process_in_isr = 0x40001550; +r_ble_lll_conn_recv_ack = 0x40001554; +r_ble_lll_conn_recv_valid_packet = 0x40001558; +r_ble_lll_conn_reset_pending_sched = 0x4000155c; +r_ble_lll_conn_rx_pkt_isr = 0x40001560; +r_ble_lll_conn_sched_next_anchor = 0x40001564; +r_ble_lll_conn_sched_next_event = 0x40001568; +r_ble_lll_conn_set_slave_flow_control = 0x4000156c; +r_ble_lll_conn_slave_new = 0x40001570; +r_ble_lll_conn_sm_new = 0x40001574; +r_ble_lll_conn_sm_npl_deinit = 0x40001578; +r_ble_lll_conn_sm_npl_init = 0x4000157c; +r_ble_lll_conn_superversion_timer_cb = 0x40001580; +r_ble_lll_conn_timeout = 0x40001584; +r_ble_lll_conn_update_anchor = 0x40001588; +r_ble_lll_conn_update_conn_ind_params = 0x4000158c; +r_ble_lll_conn_update_encryption = 0x40001590; +r_ble_lll_conn_update_tx_buffer = 0x40001594; +r_ble_lll_deinit = 0x40001598; +r_ble_lll_dtm_calculate_itvl = 0x4000159c; +r_ble_lll_dtm_ctx_free = 0x400015a0; +r_ble_lll_dtm_deinit = 0x400015a4; +r_ble_lll_dtm_end_test = 0x400015a8; +r_ble_lll_dtm_ev_rx_restart_cb = 0x400015ac; +r_ble_lll_dtm_ev_tx_resched_cb = 0x400015b0; +r_ble_lll_dtm_init = 0x400015b4; +r_ble_lll_dtm_reset = 0x400015b8; +r_ble_lll_dtm_rx_create_ctx = 0x400015bc; +r_ble_lll_dtm_rx_isr_end = 0x400015c0; +r_ble_lll_dtm_rx_isr_start = 0x400015c4; +r_ble_lll_dtm_rx_pkt_in = 0x400015c8; +r_ble_lll_dtm_rx_sched_cb = 0x400015cc; +r_ble_lll_dtm_rx_start = 0x400015d0; +r_ble_lll_dtm_rx_test = 0x400015d4; +r_ble_lll_dtm_set_next = 0x400015d8; +r_ble_lll_dtm_tx_create_ctx = 0x400015dc; +r_ble_lll_dtm_tx_done = 0x400015e0; +r_ble_lll_dtm_tx_sched_cb = 0x400015e4; +r_ble_lll_dtm_tx_test = 0x400015e8; +r_ble_lll_dtm_wfr_timer_exp = 0x400015ec; +r_ble_lll_event_rx_pkt = 0x400015f0; +r_ble_lll_ext_scan_coex_dpc_process = 0x400015f4; +r_ble_lll_ext_scan_coex_dpc_pti_get = 0x400015f8; +r_ble_lll_ext_scan_coex_dpc_update = 0x400015fc; +r_ble_lll_ext_scan_coex_dpc_update_on_start = 0x40001600; +r_ble_lll_hci_dtm_rx_test = 0x40001604; +r_ble_lll_hci_dtm_rx_test_v2 = 0x40001608; +r_ble_lll_hci_dtm_tx_test = 0x4000160c; +r_ble_lll_hci_dtm_tx_test_ext = 0x40001610; +r_ble_lll_hci_dtm_tx_test_v2 = 0x40001614; +r_ble_lll_hci_dtm_tx_test_v2_ext = 0x40001618; +r_ble_lll_init = 0x4000161c; +r_ble_lll_init_pre_process = 0x40001620; +r_ble_lll_init_rx_pkt_isr = 0x40001624; +r_ble_lll_per_adv_coex_dpc_calc_pti_update_itvl = 0x40001628; +r_ble_lll_per_adv_coex_dpc_process = 0x4000162c; +r_ble_lll_per_adv_coex_dpc_pti_get = 0x40001630; +r_ble_lll_per_adv_coex_dpc_update = 0x40001634; +r_ble_lll_per_adv_coex_dpc_update_on_data_updated = 0x40001638; +r_ble_lll_per_adv_coex_dpc_update_on_scheduled = 0x4000163c; +r_ble_lll_per_adv_coex_dpc_update_on_start = 0x40001640; +r_ble_lll_reset = 0x40001644; +r_ble_lll_rfmgmt_controller_sleep_en = 0x40001648; +r_ble_lll_rfmgmt_deinit = 0x4000164c; +//r_ble_lll_rfmgmt_disable = 0x40001650; +//r_ble_lll_rfmgmt_enable = 0x40001654; +//r_ble_lll_rfmgmt_enable_now = 0x40001658; +r_ble_lll_rfmgmt_init = 0x4000165c; +r_ble_lll_rfmgmt_is_enabled = 0x40001660; +r_ble_lll_rfmgmt_release = 0x40001664; +r_ble_lll_rfmgmt_release_ev = 0x40001668; +r_ble_lll_rfmgmt_reset = 0x4000166c; +r_ble_lll_rfmgmt_scan_changed = 0x40001670; +r_ble_lll_rfmgmt_sched_changed = 0x40001674; +r_ble_lll_rfmgmt_set_sleep_cb = 0x40001678; +r_ble_lll_rfmgmt_ticks_to_enabled = 0x4000167c; +//r_ble_lll_rfmgmt_timer_exp = 0x40001680; +//r_ble_lll_rfmgmt_timer_reschedule = 0x40001684; +r_ble_lll_rx_pdu_in = 0x40001688; +r_ble_lll_rx_pkt_in = 0x4000168c; +r_ble_lll_rx_pkt_isr = 0x40001690; +r_ble_lll_scan_abort_aux_sched = 0x40001694; +r_ble_lll_scan_aux_data_free = 0x40001698; +r_ble_lll_scan_chk_resume = 0x4000169c; +r_ble_lll_scan_clean_cur_aux_data = 0x400016a0; +//r_ble_lll_scan_coex_event_cb = 0x400016a4; +r_ble_lll_scan_common_init = 0x400016a8; +r_ble_lll_scan_deinit = 0x400016ac; +r_ble_lll_scan_duration_period_timers_restart = 0x400016b0; +r_ble_lll_scan_duration_period_timers_stop = 0x400016b4; +r_ble_lll_scan_duration_timer_cb = 0x400016b8; +r_ble_lll_scan_event_proc = 0x400016bc; +r_ble_lll_scan_ext_adv_init = 0x400016c0; +r_ble_lll_scan_halt = 0x400016c4; +r_ble_lll_scan_has_sent_scan_req = 0x400016c8; +r_ble_lll_scan_init = 0x400016cc; +r_ble_lll_scan_npl_init = 0x400016d0; +r_ble_lll_scan_npl_reset = 0x400016d4; +r_ble_lll_scan_npl_restore = 0x400016d8; +r_ble_lll_scan_npl_store = 0x400016dc; +r_ble_lll_scan_period_timer_cb = 0x400016e0; +r_ble_lll_scan_process_adv_in_isr = 0x400016e4; +r_ble_lll_scan_process_rsp_in_isr = 0x400016e8; +r_ble_lll_scan_req_backoff = 0x400016ec; +r_ble_lll_scan_restart = 0x400016f0; +r_ble_lll_scan_rx_isr_on_aux = 0x400016f4; +r_ble_lll_scan_rx_isr_on_legacy = 0x400016f8; +r_ble_lll_scan_rx_pkt_isr = 0x400016fc; +r_ble_lll_scan_sched_next_aux = 0x40001700; +r_ble_lll_scan_sched_remove = 0x40001704; +r_ble_lll_scan_start = 0x40001708; +//r_ble_lll_scan_start_rx = 0x4000170c; +r_ble_lll_scan_stop = 0x40001710; +r_ble_lll_scan_targeta_is_matched = 0x40001714; +r_ble_lll_scan_timer_cb = 0x40001718; +r_ble_lll_sched_adv_new = 0x4000171c; +r_ble_lll_sched_adv_resched_pdu = 0x40001720; +r_ble_lll_sched_adv_reschedule = 0x40001724; +r_ble_lll_sched_aux_scan = 0x40001728; +r_ble_lll_sched_conn_overlap = 0x4000172c; +r_ble_lll_sched_conn_reschedule = 0x40001730; +r_ble_lll_sched_deinit = 0x40001734; +r_ble_lll_sched_dtm = 0x40001738; +r_ble_lll_sched_env_init = 0x4000173c; +r_ble_lll_sched_execute_check = 0x40001740; +r_ble_lll_sched_execute_item = 0x40001744; +r_ble_lll_sched_init = 0x40001748; +r_ble_lll_sched_insert_if_empty = 0x4000174c; +r_ble_lll_sched_is_overlap = 0x40001750; +r_ble_lll_sched_master_new = 0x40001754; +r_ble_lll_sched_next_time = 0x40001758; +r_ble_lll_sched_overlaps_current = 0x4000175c; +r_ble_lll_sched_periodic_adv = 0x40001760; +r_ble_lll_sched_rmv_elem = 0x40001764; +r_ble_lll_sched_rmv_elem_type = 0x40001768; +r_ble_lll_sched_run = 0x4000176c; +r_ble_lll_sched_scan_req_over_aux_ptr = 0x40001770; +r_ble_lll_sched_slave_new = 0x40001774; +r_ble_lll_sched_stop = 0x40001778; +r_ble_lll_sched_sync = 0x4000177c; +r_ble_lll_sched_sync_overlaps_current = 0x40001780; +r_ble_lll_sched_sync_reschedule = 0x40001784; +r_ble_lll_sync_chain_start_cb = 0x40001788; +r_ble_lll_sync_coex_dpc_process = 0x4000178c; +r_ble_lll_sync_coex_dpc_pti_get = 0x40001790; +r_ble_lll_sync_coex_dpc_update = 0x40001794; +r_ble_lll_sync_current_sm_over = 0x40001798; +r_ble_lll_sync_deinit = 0x4000179c; +r_ble_lll_sync_event_end = 0x400017a0; +r_ble_lll_sync_event_end_cb = 0x400017a4; +r_ble_lll_sync_event_start_cb = 0x400017a8; +r_ble_lll_sync_get_event_end_time = 0x400017ac; +r_ble_lll_sync_halt = 0x400017b0; +r_ble_lll_sync_init = 0x400017b4; +r_ble_lll_sync_new = 0x400017b8; +r_ble_lll_sync_reset = 0x400017bc; +r_ble_lll_sync_reset_sm = 0x400017c0; +r_ble_lll_sync_rmvd_from_sched = 0x400017c4; +r_ble_lll_sync_rx_pkt_isr = 0x400017c8; +r_ble_lll_sync_schedule_chain = 0x400017cc; +r_ble_lll_sync_stop = 0x400017d0; +r_ble_lll_sync_trnasfer_sched = 0x400017d4; +r_ble_phy_access_addr_get = 0x400017d8; +r_ble_phy_calculate_rxtx_ifs = 0x400017dc; +r_ble_phy_calculate_rxwindow = 0x400017e0; +r_ble_phy_calculate_txrx_ifs = 0x400017e4; +r_ble_phy_check_bb_status = 0x400017e8; +r_ble_phy_complete_rx_info = 0x400017ec; +r_ble_phy_config_access_addr = 0x400017f0; +r_ble_phy_data_make = 0x400017f4; +r_ble_phy_disable = 0x400017f8; +r_ble_phy_disable_irq = 0x400017fc; +r_ble_phy_disable_whitening = 0x40001800; +r_ble_phy_enable_whitening = 0x40001804; +r_ble_phy_encrypt_disable = 0x40001808; +r_ble_phy_env_init = 0x4000180c; +r_ble_phy_get_current_phy = 0x40001810; +r_ble_phy_get_packet_counter = 0x40001814; +r_ble_phy_get_packet_status = 0x40001818; +r_ble_phy_get_pyld_time_offset = 0x4000181c; +r_ble_phy_get_rx_phy_mode = 0x40001820; +r_ble_phy_get_seq_end_st = 0x40001824; +r_ble_phy_init = 0x40001828; +//r_ble_phy_isr = 0x4000182c; +r_ble_phy_max_data_pdu_pyld = 0x40001830; +r_ble_phy_mode_config = 0x40001834; +r_ble_phy_mode_convert = 0x40001838; +r_ble_phy_mode_write = 0x4000183c; +r_ble_phy_module_deinit = 0x40001840; +r_ble_phy_module_init = 0x40001844; +r_ble_phy_monitor_bb_sync = 0x40001848; +r_ble_phy_reset_bb_monitor = 0x4000184c; +r_ble_phy_resolv_list_disable = 0x40001850; +r_ble_phy_resolv_list_enable = 0x40001854; +r_ble_phy_restart_sequence = 0x40001858; +r_ble_phy_rx_set_start_time_forcibly = 0x4000185c; +r_ble_phy_rxpdu_copy = 0x40001860; +r_ble_phy_seq_encrypt_enable = 0x40001864; +r_ble_phy_seq_encrypt_set_pkt_cntr = 0x40001868; +r_ble_phy_sequence_end_isr = 0x4000186c; +r_ble_phy_sequence_get_mode = 0x40001870; +r_ble_phy_sequence_is_running = 0x40001874; +r_ble_phy_sequence_is_waiting_rsp = 0x40001878; +r_ble_phy_sequence_single_end = 0x4000187c; +r_ble_phy_sequence_tx_end_invoke = 0x40001880; +r_ble_phy_sequence_update_conn_ind_params = 0x40001884; +r_ble_phy_set_adv_mode = 0x40001888; +r_ble_phy_set_coex_pti = 0x4000188c; +r_ble_phy_set_conn_ind_pdu = 0x40001890; +r_ble_phy_set_conn_mode = 0x40001894; +r_ble_phy_set_dev_address = 0x40001898; +r_ble_phy_set_rx_pwr_compensation = 0x4000189c; +r_ble_phy_set_rxhdr = 0x400018a0; +r_ble_phy_set_scan_mode = 0x400018a4; +r_ble_phy_set_sequence_mode = 0x400018a8; +r_ble_phy_set_single_packet_rx_sequence = 0x400018ac; +r_ble_phy_set_single_packet_tx_sequence = 0x400018b0; +r_ble_phy_set_tx_rx_transition = 0x400018b4; +r_ble_phy_set_txend_cb = 0x400018b8; +r_ble_phy_setchan = 0x400018bc; +r_ble_phy_start_rx_immediately = 0x400018c0; +r_ble_phy_state_get = 0x400018c4; +r_ble_phy_timer_config_start_time = 0x400018c8; +r_ble_phy_timer_start_now = 0x400018cc; +r_ble_phy_timer_stop = 0x400018d0; +r_ble_phy_tx_set_start_time = 0x400018d4; +//r_ble_phy_txpower_round = 0x400018d8; +r_ble_phy_txpwr_set = 0x400018dc; +//r_ble_phy_update_conn_sequence = 0x400018e0; +r_ble_phy_update_encryption = 0x400018e4; +r_ble_phy_update_ifs = 0x400018e8; +r_ble_phy_xcvr_state_get = 0x400018ec; +r_ble_plf_set_log_level = 0x400018f0; +r_ble_rtc_wake_up_cpu_init = 0x400018f4; +r_ble_rtc_wake_up_state_clr = 0x400018f8; +r_ble_vendor_hci_register = 0x400018fc; +r_bt_rf_coex_cfg_set = 0x40001900; +r_bt_rf_coex_coded_txrx_time_upper_lim = 0x40001904; +r_bt_rf_coex_dft_pti_set = 0x40001908; +r_bt_rf_coex_hook_deinit = 0x4000190c; +r_bt_rf_coex_hook_init = 0x40001910; +r_bt_rf_coex_hook_st_set = 0x40001914; +r_bt_rf_coex_hooks_p_set_default = 0x40001918; +r_btdm_disable_adv_delay = 0x4000191c; +r_btdm_switch_phy_coded = 0x40001920; +r_esp_wait_disabled = 0x40001924; +r_get_be16 = 0x40001928; +r_get_be24 = 0x4000192c; +r_get_be32 = 0x40001930; +r_get_be64 = 0x40001934; +r_get_le16 = 0x40001938; +r_get_le24 = 0x4000193c; +r_get_le32 = 0x40001940; +r_get_le64 = 0x40001944; +r_get_local_irk_offset = 0x40001948; +r_get_local_rpa_offset = 0x4000194c; +r_get_max_skip = 0x40001950; +r_get_peer_id_offset = 0x40001954; +r_get_peer_irk_offset = 0x40001958; +r_get_peer_rpa_offset = 0x4000195c; +r_hal_rtc_intr_init = 0x40001960; +//r_hal_rtc_irq_handler = 0x40001964; +r_hal_timer_deinit = 0x40001968; +r_hal_timer_disable_irq = 0x4000196c; +r_hal_timer_env_init = 0x40001970; +r_hal_timer_init = 0x40001974; +r_hal_timer_process = 0x40001978; +r_hal_timer_read = 0x4000197c; +r_hal_timer_read_tick = 0x40001980; +r_hal_timer_set_cb = 0x40001984; +r_hal_timer_set_exp_tick = 0x40001988; +r_hal_timer_start = 0x4000198c; +r_hal_timer_start_at = 0x40001990; +r_hal_timer_stop = 0x40001994; +r_hal_timer_task_start = 0x40001998; +r_ll_assert = 0x4000199c; +r_mem_init_mbuf_pool = 0x400019a0; +r_mem_malloc_mbuf_pool = 0x400019a4; +r_mem_malloc_mbufpkt_pool = 0x400019a8; +r_mem_malloc_mempool = 0x400019ac; +r_mem_malloc_mempool_ext = 0x400019b0; +r_mem_malloc_mempool_gen = 0x400019b4; +r_mem_pullup_obj = 0x400019b8; +r_mem_split_frag = 0x400019bc; +r_os_cputime_get32 = 0x400019c0; +r_os_cputime_ticks_to_usecs = 0x400019c4; +r_os_cputime_timer_init = 0x400019c8; +r_os_cputime_timer_relative = 0x400019cc; +r_os_cputime_timer_start = 0x400019d0; +r_os_cputime_timer_stop = 0x400019d4; +r_os_cputime_usecs_to_ticks = 0x400019d8; +r_os_mbuf_adj = 0x400019dc; +r_os_mbuf_append = 0x400019e0; +r_os_mbuf_appendfrom = 0x400019e4; +r_os_mbuf_cmpf = 0x400019e8; +r_os_mbuf_cmpm = 0x400019ec; +r_os_mbuf_concat = 0x400019f0; +r_os_mbuf_copydata = 0x400019f4; +r_os_mbuf_copyinto = 0x400019f8; +r_os_mbuf_dup = 0x400019fc; +r_os_mbuf_extend = 0x40001a00; +r_os_mbuf_free = 0x40001a04; +r_os_mbuf_free_chain = 0x40001a08; +r_os_mbuf_get = 0x40001a0c; +r_os_mbuf_get_pkthdr = 0x40001a10; +r_os_mbuf_leadingspace = 0x40001a14; +r_os_mbuf_len = 0x40001a18; +r_os_mbuf_off = 0x40001a1c; +r_os_mbuf_pack_chains = 0x40001a20; +r_os_mbuf_pool_init = 0x40001a24; +r_os_mbuf_prepend = 0x40001a28; +r_os_mbuf_prepend_pullup = 0x40001a2c; +r_os_mbuf_pullup = 0x40001a30; +r_os_mbuf_trailingspace = 0x40001a34; +r_os_mbuf_trim_front = 0x40001a38; +r_os_mbuf_widen = 0x40001a3c; +r_os_memblock_from = 0x40001a40; +r_os_memblock_get = 0x40001a44; +r_os_memblock_put = 0x40001a48; +r_os_memblock_put_from_cb = 0x40001a4c; +r_os_mempool_clear = 0x40001a50; +r_os_mempool_ext_clear = 0x40001a54; +r_os_mempool_ext_init = 0x40001a58; +r_os_mempool_init = 0x40001a60; +r_os_mempool_init_internal = 0x40001a64; +r_os_mempool_is_sane = 0x40001a68; +r_os_mempool_module_init = 0x40001a6c; +r_os_mqueue_get = 0x40001a74; +r_os_mqueue_init = 0x40001a78; +r_os_mqueue_put = 0x40001a7c; +r_os_msys_count = 0x40001a80; +r_os_msys_get = 0x40001a84; +r_os_msys_get_pkthdr = 0x40001a88; +r_os_msys_num_free = 0x40001a8c; +r_os_msys_register = 0x40001a90; +r_os_msys_reset = 0x40001a94; +r_pri_phy_valid = 0x40001a98; +r_put_be16 = 0x40001a9c; +r_put_be24 = 0x40001aa0; +r_put_be32 = 0x40001aa4; +r_put_be64 = 0x40001aa8; +r_put_le16 = 0x40001aac; +r_put_le24 = 0x40001ab0; +r_put_le32 = 0x40001ab4; +r_put_le64 = 0x40001ab8; +r_rtc0_timer_handler = 0x40001abc; +r_sdkconfig_get_opts = 0x40001ac0; +//r_sdkconfig_set_opts = 0x40001ac4; +r_sec_phy_valid = 0x40001ac8; +r_swap_buf = 0x40001acc; +r_swap_in_place = 0x40001ad0; +/* Data (.data, .bss, .rodata) */ +ble_lll_dtm_module_env_p = 0x3fcdffc4; +g_ble_lll_dtm_prbs15_data = 0x3ff4fee4; +g_ble_lll_dtm_prbs9_data = 0x3ff4fde4; +g_channel_rf_to_index = 0x3ff4fdbc; +g_ble_lll_rfmgmt_data = 0x3fcdff7c; +g_ble_sleep_enter_cb = 0x3fcdff78; +g_ble_sleep_exit_cb = 0x3fcdff74; +ble_lll_sched_env_p = 0x3fcdff70; +ble_ll_env_p = 0x3fcdff6c; +g_ble_ll_pdu_header_tx_time_ro = 0x3ff4fdb4; +ble_ll_adv_env_p = 0x3fcdff68; +ble_ll_conn_env_p = 0x3fcdff64; +ble_ll_conn_required_phy_mask = 0x3ff4fdb0; +ble_ll_valid_conn_phy_mask = 0x3ff4fdaf; +g_ble_ll_ctrl_pkt_lengths_ro = 0x3ff4fd8c; +ble_ll_hci_env_p = 0x3fcdff60; +g_debug_le_private_key = 0x3ff4fd6c; +g_ecc_key = 0x3fcdfefc; +ble_ll_rand_env_p = 0x3fcdfef8; +ble_ll_resolv_env_p = 0x3fcdfef4; +g_ble_ll_resolve_hdr = 0x3fcdfeec; +g_device_mode_default = 0x3fcdfe68; +ble_ll_scan_classify_filter_aux_check_cb = 0x3fcdfee8; +ble_ll_scan_classify_filter_check_cb = 0x3fcdfee4; +ble_ll_scan_env_p = 0x3fcdfee0; +g_ble_ll_supp_cmds_ro = 0x3ff4fd3c; +ble_ll_sync_env_p = 0x3fcdfedc; +g_ble_sca_ppm_tbl_ro = 0x3ff4fd2c; +priv_config_opts = 0x3fcdfe48; +ble_hci_uart_reset_cmd = 0x3ff4fd28; +ble_hci_trans_env_p = 0x3fcdfed8; +ble_hci_trans_mode = 0x3fcdfe44; +ble_hci_trans_funcs_ptr = 0x3fcdfed4; +r_ble_lll_stub_funcs_ptr = 0x3fcdfed0; +r_ble_stub_funcs_ptr = 0x3fcdfecc; +r_ext_funcs_p = 0x3fcdfec8; +r_npl_funcs = 0x3fcdfec4; +ble_hw_env_p = 0x3fcdfec0; +ble_phy_module_env_p = 0x3fcdfebc; +g_ble_phy_chan_freq_ro = 0x3ff4fd00; +g_ble_phy_mode_pkt_start_off_ro = 0x3ff4fcf8; +g_ble_phy_rxtx_ifs_compensation_ro = 0x3ff4fce8; +g_ble_phy_t_rxaddrdelay_ro = 0x3ff4fce4; +g_ble_phy_t_rxenddelay_ro = 0x3ff4fce0; +g_ble_phy_t_txdelay_ro = 0x3ff4fcdc; +g_ble_phy_t_txenddelay_ro = 0x3ff4fcd8; +g_ble_phy_txrx_ifs_compensation_ro = 0x3ff4fcc8; +hal_timer_env_p = 0x3fcdfeb8; +r_osi_coex_funcs_p = 0x3fcdfeb4; +bt_rf_coex_hooks = 0x3fcdfeac; +bt_rf_coex_hooks_p = 0x3fcdfea8; +coex_hook_st_group_tab = 0x3ff4fcbc; +coex_hook_st_group_to_coex_schm_st_tab = 0x3ff4fcb8; +s_ble_act_count_by_group = 0x3fcdfea4; +s_ble_coex_st_map = 0x3fcdfe90; +bt_rf_coex_cfg_cb = 0x3fcdfe74; +bt_rf_coex_cfg_p = 0x3fcdfe70; +bt_rf_coex_cfg_rom = 0x3ff4fc9c; +bt_rf_coex_pti_dft_p = 0x3fcdfe6c; +bt_rf_coex_pti_dft_rom = 0x3fcdfe04; +conn_dynamic_pti_param_rom = 0x3ff4fc84; +conn_phy_coded_max_data_time_param_rom = 0x3ff4fc80; +ext_adv_dynamic_pti_param_rom = 0x3ff4fc4c; +ext_scan_dynamic_param_rom = 0x3ff4fc14; +legacy_adv_dynamic_pti_param_rom = 0x3ff4fbf4; +per_adv_dynamic_pti_param_rom = 0x3ff4fbd8; +sync_dynamic_param_rom = 0x3ff4fbc0; +g_ble_plf_log_level = 0x3fcdfe00; +g_msys_pool_list = 0x3fcdfdf8; +g_os_mempool_list = 0x3fcdfdf0; + + +/*************************************** + Group eco4_bluetooth + ***************************************/ + +/* Functions */ +r_ble_ll_adv_ext_pdu_tx_len = 0x40002eb0; +//r_ble_ll_adv_ext_estimate_data_itvl = 0x40002eb4; +//r_ble_ll_adv_ext_check_data_itvl = 0x40002eb8; +r_ble_ll_ctrl_channel_status_report_timer_cb = 0x40002ebc; +r_ble_ll_ctrl_channel_class_enable_make = 0x40002ec0; +r_ble_ll_ctrl_channel_class_reporting_make = 0x40002ec4; +r_ble_ll_ctrl_rx_channel_reporting_ind = 0x40002ec8; +r_ble_ll_ctrl_rx_channel_status_ind = 0x40002ecc; +r_ble_ll_ctrl_channel_class_info_update = 0x40002ed0; +r_ble_ll_adv_set_data_related_addr_change = 0x40002ed4; +r_ble_ll_misc_additional_options_set = 0x40002ed8; +r_ble_phy_get_txdbm_by_level = 0x40002edc; +r_hal_timer_disable_intr = 0x40002ee0; +r_hal_timer_enable_intr = 0x40002ee4; +r_hal_timer_task_stop = 0x40002ee8; +//r_ble_lll_rfmgmt_env_init = 0x40002eec; +r_ble_ll_scan_set_aux_ll_flag = 0x40002ef0; +r_ble_ll_rf_temp_calibration = 0x40002ef4; +r_ble_ll_adv_env_deinit = 0x40002ef8; +r_ble_ll_conn_env_deinit = 0x40002efc; +r_ble_ll_hci_env_deinit = 0x40002f00; +r_ble_ll_rand_env_deinit = 0x40002f04; +r_ble_ll_resolv_env_deinit = 0x40002f08; +r_ble_ll_scan_env_deinit = 0x40002f0c; +r_ble_ll_sync_env_deinit = 0x40002f10; +r_ble_lll_rfmgmt_env_deinit = 0x40002f14; +r_hal_timer_env_deinit = 0x40002f18; +r_ble_ll_env_deinit = 0x40002f1c; +r_ble_ll_generic_data_deinit = 0x40002f20; +//r_ble_hci_trans_env_deinit = 0x40002f24; +r_ble_ll_conn_callout_env_init = 0x40002f28; +r_ble_ll_conn_callout_env_deinit = 0x40002f2c; +r_ble_ll_scan_callout_env_init = 0x40002f30; +r_ble_ll_scan_callout_env_deinit = 0x40002f34; +r_ble_ll_callout_env_init = 0x40002f38; +r_ble_ll_callout_env_deinit = 0x40002f3c; +r_ble_ll_resolv_callout_env_init = 0x40002f40; +r_ble_ll_resolv_callout_env_deinit = 0x40002f44; +r_ble_ll_get_npl_element_info = 0x40002f48; +r_ble_rtc_wake_up_cpu_clr = 0x40002f4c; +r_ble_ll_scan_hci_set_adv_report_flow_ctrl = 0x40002f50; +r_ble_ll_scan_hci_update_adv_report_flow_ctrl = 0x40002f54; +r_ble_ll_scan_send_adv_lost_report = 0x40002f58; +r_ble_ll_scan_adv_report_cth_flow_is_enabled = 0x40002f5c; +r_ble_ll_scan_adv_report_cth_flow_alloc_credit = 0x40002f60; +r_ble_ll_scan_adv_report_cth_flow_free_credit = 0x40002f64; +r_ble_ll_scan_adv_report_cth_flow_have_credit = 0x40002f68; +r_ble_ll_scan_adv_report_lost_cnt_threshold_arrived = 0x40002f6c; +r_ble_ll_scan_adv_report_lost_cnt_clear = 0x40002f70; +r_ble_ll_scan_adv_report_lost_cnt_add = 0x40002f74; +r_ble_ll_trace_hex = 0x40002f78; +r_ble_ll_conn_calc_closest_event_cntr = 0x40002f7c; +r_ble_ll_trace_buffer_select = 0x40002f80; +r_ble_ll_adv_vendor_hci_legacy_adv_clear = 0x40002f84; +r_ble_ll_conn_is_lru_compare_with_sync = 0x40002f88; +r_ble_ll_conn_rollback_last_unmapped_chan = 0x40002f8c; +//r_ble_ll_hci_vs_csa_set = 0x40002f90; +r_ble_ll_hci_reset = 0x40002f94; +r_ble_ll_adv_status_check = 0x40002f98; +r_ble_ll_conn_status_check = 0x40002f9c; +r_ble_ll_scan_status_check = 0x40002fa0; +r_ble_ll_sync_status_check = 0x40002fa4; +r_ble_ll_resolv_status_check = 0x40002fa8; +r_ble_ll_whitelist_status_check = 0x40002fac; +r_ble_ll_adv_delay_get = 0x40002fb0; +r_ble_ll_scan_continue_status_get = 0x40002fb4; +r_ble_ll_default_privacy_mode_get = 0x40002fb8; +r_ble_ll_adv_periodic_status_check = 0x40002fbc; +r_ble_ll_sync_list_status_check = 0x40002fc0; +r_ble_lll_rfmgmt_wake_up_ev = 0x40002fc4; +r_ble_lll_sched_env_deinit = 0x40002fc8; +r_ble_phy_env_deinit = 0x40002fcc; +r_ble_hw_driver_env_deinit = 0x40002fd0; +r_ble_lll_dtm_env_init = 0x40002fd4; +r_ble_lll_dtm_env_deinit = 0x40002fd8; +r_ble_lll_scan_callout_env_init = 0x40002fdc; +r_ble_lll_scan_callout_env_deinit = 0x40002fe0; +r_ble_lll_scan_env_init = 0x40002fe4; +r_ble_lll_scan_env_deinit = 0x40002fe8; +r_ble_lll_get_npl_element_info = 0x40002fec; +r_ble_lll_conn_rxpdu_alloc = 0x40002ff0; +r_ble_lll_scan_filter_out_useless_adv = 0x40002ff4; +r_ble_hw_whitelist_check_in_wl = 0x40002ff8; +r_ble_phy_stats_reset = 0x40002ffc; +r_ble_phy_ramup_time_set = 0x40003000; +r_ble_lll_rfmgmt_should_skip_light_sleep_check = 0x40003004; +r_ble_phy_rx_err_record = 0x40003008; +r_ble_lll_rfmgmt_wake_up_overhead_set = 0x4000300c; +//r_ble_lll_conn_event_delete_and_reschedule = 0x40003010; +r_ble_lll_conn_should_reschedule = 0x40003014; +r_ble_lll_adv_ext_event_rmvd_from_sched = 0x40003018; +r_ble_lll_conn_process_rx_data_after_halt = 0x4000301c; +r_ble_phy_global_rxbuf_get = 0x40003020; +/* Data (.data, .bss, .rodata) */ +g_ble_lll_rfmgmt_env_p = 0x3fcdf3cc; +priv_config_additional_opts_ptr = 0x3fcdfa70; +g_ble_ll_ctrl_pkt_lengths_eco4_ro = 0x3ff4fbac; diff --git a/components/esp_rom/esp32c2/ld/esp32c2.rom.ble.ld b/components/esp_rom/esp32c2/ld/esp32c2.rom.ble.ld new file mode 100644 index 0000000000..52c45ef817 --- /dev/null +++ b/components/esp_rom/esp32c2/ld/esp32c2.rom.ble.ld @@ -0,0 +1,914 @@ +/* + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* ROM function interface esp32c2.rom.ld for esp32c2 + * + * + * Generated from ./interface-esp32c2.yml md5sum c679b6ed5e9f0a9c3e7b93e5e0f2a1a3 + * + * Compatible with ROM where ECO version equal or greater to 1. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + + +/*************************************** + Group bluetooth + ***************************************/ + +/* Functions */ +ble_controller_rom_data_init = 0x40000aa8; +ble_osi_coex_funcs_register = 0x40000aac; +bt_rf_coex_cfg_get_default = 0x40000ab0; +bt_rf_coex_dft_pti_get_default = 0x40000ab4; +bt_rf_coex_hooks_p_set = 0x40000ab8; +r__os_mbuf_copypkthdr = 0x40000abc; +r_ble_controller_get_rom_compile_version = 0x40000ac4; +r_ble_hci_ram_reset = 0x40000ad8; +r_ble_hci_ram_set_acl_free_cb = 0x40000adc; +r_ble_hci_trans_acl_buf_alloc = 0x40000ae0; +r_ble_hci_trans_buf_alloc = 0x40000ae4; +r_ble_hci_trans_buf_free = 0x40000ae8; +r_ble_hci_trans_cfg_hs = 0x40000aec; +r_ble_hci_trans_cfg_ll = 0x40000af0; +r_ble_hci_trans_init = 0x40000afc; +r_ble_hci_uart_acl_tx = 0x40000b00; +r_ble_hci_uart_cmdevt_tx = 0x40000b04; +r_ble_hci_uart_config = 0x40000b08; +r_ble_hci_uart_free_pkt = 0x40000b0c; +r_ble_hci_uart_rx_acl = 0x40000b20; +r_ble_hci_uart_rx_char = 0x40000b24; +r_ble_hci_uart_rx_cmd = 0x40000b28; +r_ble_hci_uart_rx_evt = 0x40000b2c; +r_ble_hci_uart_rx_evt_cb = 0x40000b30; +r_ble_hci_uart_rx_le_evt = 0x40000b34; +r_ble_hci_uart_rx_pkt_type = 0x40000b38; +r_ble_hci_uart_rx_skip_acl = 0x40000b3c; +r_ble_hci_uart_rx_skip_cmd = 0x40000b40; +r_ble_hci_uart_rx_skip_evt = 0x40000b44; +r_ble_hci_uart_rx_sync_loss = 0x40000b48; +r_ble_hci_uart_set_acl_free_cb = 0x40000b4c; +r_ble_hci_uart_sync_lost = 0x40000b50; +r_ble_hci_uart_trans_reset = 0x40000b54; +r_ble_hci_uart_tx_char = 0x40000b58; +r_ble_hci_uart_tx_pkt_type = 0x40000b5c; +r_ble_hw_encrypt_block = 0x40000b68; +r_ble_hw_get_public_addr = 0x40000b6c; +r_ble_hw_get_static_addr = 0x40000b70; +r_ble_hw_periodiclist_add = 0x40000b74; +r_ble_hw_periodiclist_clear = 0x40000b78; +r_ble_hw_periodiclist_rmv = 0x40000b7c; +r_ble_hw_resolv_list_cur_entry = 0x40000b80; +r_ble_hw_resolv_list_set = 0x40000b88; +r_ble_hw_rng_init = 0x40000b8c; +r_ble_hw_rng_start = 0x40000b90; +r_ble_hw_rng_stop = 0x40000b94; +r_ble_hw_rx_local_is_resolved = 0x40000b98; +r_ble_hw_rx_local_is_rpa = 0x40000b9c; +r_ble_hw_whitelist_add = 0x40000ba0; +r_ble_hw_whitelist_dev_num = 0x40000ba8; +r_ble_hw_whitelist_get_base = 0x40000bac; +r_ble_hw_whitelist_search = 0x40000bb4; +r_ble_hw_whitelist_sort = 0x40000bb8; +r_ble_ll_acl_data_in = 0x40000bbc; +r_ble_ll_addr_is_id = 0x40000bc0; +r_ble_ll_addr_subtype = 0x40000bc4; +r_ble_ll_adv_active_chanset_clear = 0x40000bc8; +r_ble_ll_adv_active_chanset_is_pri = 0x40000bcc; +r_ble_ll_adv_active_chanset_is_sec = 0x40000bd0; +r_ble_ll_adv_active_chanset_set_pri = 0x40000bd4; +r_ble_ll_adv_active_chanset_set_sec = 0x40000bd8; +r_ble_ll_adv_aux_calculate = 0x40000bdc; +r_ble_ll_adv_aux_conn_rsp_pdu_make = 0x40000be0; +r_ble_ll_adv_aux_pdu_make = 0x40000be4; +r_ble_ll_adv_aux_scannable_pdu_make = 0x40000be8; +r_ble_ll_adv_aux_txed = 0x40000bec; +r_ble_ll_adv_can_chg_whitelist = 0x40000bf0; +r_ble_ll_adv_chk_rpa_timeout = 0x40000bf4; +r_ble_ll_adv_clear_all = 0x40000bf8; +r_ble_ll_adv_conn_req_rxd = 0x40000bfc; +r_ble_ll_adv_enabled = 0x40000c04; +r_ble_ll_adv_ext_set_adv_data = 0x40000c0c; +r_ble_ll_adv_ext_set_scan_rsp = 0x40000c18; +r_ble_ll_adv_final_chan = 0x40000c1c; +r_ble_ll_adv_first_chan = 0x40000c20; +r_ble_ll_adv_flags_clear = 0x40000c24; +r_ble_ll_adv_flags_set = 0x40000c28; +r_ble_ll_adv_get_chan_num = 0x40000c2c; +r_ble_ll_adv_get_local_rpa = 0x40000c30; +r_ble_ll_adv_get_peer_rpa = 0x40000c34; +r_ble_ll_adv_hci_set_random_addr = 0x40000c38; +r_ble_ll_adv_init = 0x40000c3c; +r_ble_ll_adv_next_chan = 0x40000c44; +r_ble_ll_adv_pdu_make = 0x40000c48; +r_ble_ll_adv_periodic_check_data_itvl = 0x40000c4c; +r_ble_ll_adv_periodic_estimate_data_itvl = 0x40000c54; +r_ble_ll_adv_periodic_send_sync_ind = 0x40000c58; +r_ble_ll_adv_periodic_set_info_transfer = 0x40000c60; +r_ble_ll_adv_periodic_set_param = 0x40000c64; +r_ble_ll_adv_pre_process = 0x40000c68; +r_ble_ll_adv_put_acad_chM_update_ind = 0x40000c6c; +r_ble_ll_adv_put_aux_ptr = 0x40000c70; +r_ble_ll_adv_put_syncinfo = 0x40000c74; +r_ble_ll_adv_rd_max_adv_data_len = 0x40000c78; +r_ble_ll_adv_rd_sup_adv_sets = 0x40000c7c; +r_ble_ll_adv_read_txpwr = 0x40000c80; +r_ble_ll_adv_rpa_timeout = 0x40000c8c; +r_ble_ll_adv_rpa_update = 0x40000c90; +r_ble_ll_adv_scan_req_rxd = 0x40000c98; +r_ble_ll_adv_scan_rsp_legacy_pdu_make = 0x40000c9c; +r_ble_ll_adv_scan_rsp_pdu_make = 0x40000ca0; +r_ble_ll_adv_scheduled = 0x40000ca4; +r_ble_ll_adv_set_random_addr = 0x40000cb8; +r_ble_ll_adv_sm_deinit = 0x40000cc4; +r_ble_ll_adv_sm_event_init = 0x40000cc8; +r_ble_ll_adv_sm_find_configured = 0x40000ccc; +r_ble_ll_adv_sm_get = 0x40000cd0; +r_ble_ll_adv_sm_reset = 0x40000cd8; +r_ble_ll_adv_sm_start = 0x40000cdc; +r_ble_ll_adv_sm_start_periodic = 0x40000ce0; +r_ble_ll_adv_sm_stop = 0x40000ce4; +r_ble_ll_adv_sm_stop_limit_reached = 0x40000ce8; +r_ble_ll_adv_sm_stop_periodic = 0x40000cec; +r_ble_ll_adv_sm_stop_timeout = 0x40000cf0; +r_ble_ll_adv_sync_get_pdu_len = 0x40000cf8; +r_ble_ll_adv_update_adv_scan_rsp_data = 0x40000d00; +r_ble_ll_adv_update_data_mbuf = 0x40000d04; +r_ble_ll_adv_update_did = 0x40000d08; +r_ble_ll_adv_update_periodic_data = 0x40000d0c; +r_ble_ll_auth_pyld_tmo_event_send = 0x40000d14; +r_ble_ll_calc_offset_ticks_us_for_rampup = 0x40000d18; +r_ble_ll_calc_session_key = 0x40000d1c; +r_ble_ll_calc_ticks_per_slot = 0x40000d20; +r_ble_ll_chk_txrx_octets = 0x40000d28; +r_ble_ll_chk_txrx_time = 0x40000d2c; +r_ble_ll_conn_adjust_pyld_len = 0x40000d30; +r_ble_ll_conn_auth_pyld_timer_cb = 0x40000d34; +r_ble_ll_conn_auth_pyld_timer_start = 0x40000d38; +r_ble_ll_conn_calc_dci = 0x40000d3c; +r_ble_ll_conn_calc_dci_csa1 = 0x40000d40; +r_ble_ll_conn_calc_itvl_ticks = 0x40000d44; +r_ble_ll_conn_chk_csm_flags = 0x40000d48; +r_ble_ll_conn_chk_phy_upd_start = 0x40000d4c; +r_ble_ll_conn_comp_event_send = 0x40000d50; +r_ble_ll_conn_create_cancel = 0x40000d5c; +r_ble_ll_conn_cth_flow_enable = 0x40000d64; +r_ble_ll_conn_cth_flow_error_fn = 0x40000d68; +r_ble_ll_conn_cth_flow_have_credit = 0x40000d6c; +r_ble_ll_conn_cth_flow_is_enabled = 0x40000d70; +r_ble_ll_conn_cth_flow_process_cmd = 0x40000d74; +r_ble_ll_conn_cth_flow_set_buffers = 0x40000d78; +r_ble_ll_conn_ext_master_init = 0x40000d84; +r_ble_ll_conn_find_active_conn = 0x40000d88; +r_ble_ll_conn_get_active_conn = 0x40000d8c; +r_ble_ll_conn_get_anchor = 0x40000d90; +r_ble_ll_conn_hcc_params_set_fallback = 0x40000d94; +r_ble_ll_conn_hci_cancel_conn_complete_event = 0x40000d98; +r_ble_ll_conn_hci_chk_conn_params = 0x40000d9c; +r_ble_ll_conn_hci_chk_scan_params = 0x40000da0; +r_ble_ll_conn_hci_disconnect_cmd = 0x40000da4; +r_ble_ll_conn_hci_le_ltk_neg_reply = 0x40000da8; +r_ble_ll_conn_hci_le_ltk_reply = 0x40000dac; +r_ble_ll_conn_hci_le_rd_phy = 0x40000db0; +r_ble_ll_conn_hci_le_start_encrypt = 0x40000db8; +r_ble_ll_conn_hci_param_nrr = 0x40000dbc; +r_ble_ll_conn_hci_param_rr = 0x40000dc0; +r_ble_ll_conn_hci_rd_auth_pyld_tmo = 0x40000dc4; +r_ble_ll_conn_hci_rd_chan_map = 0x40000dc8; +r_ble_ll_conn_hci_rd_rem_ver_cmd = 0x40000dcc; +r_ble_ll_conn_hci_rd_rssi = 0x40000dd0; +r_ble_ll_conn_hci_read_rem_features = 0x40000dd4; +r_ble_ll_conn_hci_set_data_len = 0x40000ddc; +r_ble_ll_conn_hci_update = 0x40000de0; +r_ble_ll_conn_hci_wr_auth_pyld_tmo = 0x40000de4; +r_ble_ll_conn_init_phy = 0x40000de8; +r_ble_ll_conn_is_empty_pdu = 0x40000df0; +r_ble_ll_conn_is_lru = 0x40000df4; +r_ble_ll_conn_master_init = 0x40000df8; +r_ble_ll_conn_module_reset = 0x40000e04; +r_ble_ll_conn_num_comp_pkts_event_send = 0x40000e0c; +r_ble_ll_conn_process_conn_params = 0x40000e14; +r_ble_ll_conn_req_peer_sca = 0x40000e18; +r_ble_ll_conn_set_csa = 0x40000e20; +r_ble_ll_conn_set_ext_con_params = 0x40000e24; +r_ble_ll_conn_set_global_chanmap = 0x40000e28; +r_ble_ll_conn_set_phy = 0x40000e2c; +r_ble_ll_conn_set_txpwr_by_handle = 0x40000e30; +r_ble_ll_conn_set_unknown_rx_octets = 0x40000e34; +r_ble_ll_conn_sm_get = 0x40000e3c; +r_ble_ll_conn_tx_pkt_in = 0x40000e4c; +r_ble_ll_conn_update_eff_data_len = 0x40000e50; +r_ble_ll_ctrl_chanmap_req_make = 0x40000e54; +r_ble_ll_ctrl_conn_param_pdu_make = 0x40000e5c; +r_ble_ll_ctrl_conn_param_pdu_proc = 0x40000e60; +r_ble_ll_ctrl_conn_param_reply = 0x40000e64; +r_ble_ll_ctrl_datalen_upd_make = 0x40000e6c; +r_ble_ll_ctrl_enc_allowed_pdu = 0x40000e70; +r_ble_ll_ctrl_enc_allowed_pdu_rx = 0x40000e74; +r_ble_ll_ctrl_enc_req_make = 0x40000e7c; +r_ble_ll_ctrl_find_new_phy = 0x40000e80; +r_ble_ll_ctrl_initiate_dle = 0x40000e84; +r_ble_ll_ctrl_len_proc = 0x40000e88; +r_ble_ll_ctrl_min_used_chan_rsp = 0x40000e8c; +r_ble_ll_ctrl_phy_from_phy_mask = 0x40000e90; +r_ble_ll_ctrl_phy_req_rsp_make = 0x40000e94; +r_ble_ll_ctrl_phy_tx_transition_get = 0x40000e98; +r_ble_ll_ctrl_phy_update_cancel = 0x40000e9c; +r_ble_ll_ctrl_phy_update_ind_make = 0x40000ea0; +r_ble_ll_ctrl_phy_update_proc_complete = 0x40000ea4; +r_ble_ll_ctrl_proc_rsp_timer_cb = 0x40000eac; +r_ble_ll_ctrl_proc_stop = 0x40000eb4; +r_ble_ll_ctrl_proc_with_instant_initiated = 0x40000ebc; +r_ble_ll_ctrl_rej_ext_ind_make = 0x40000ec0; +r_ble_ll_ctrl_reject_ind_send = 0x40000ec4; +r_ble_ll_ctrl_rx_chanmap_req = 0x40000ec8; +r_ble_ll_ctrl_rx_conn_param_req = 0x40000ecc; +r_ble_ll_ctrl_rx_enc_req = 0x40000ed8; +r_ble_ll_ctrl_rx_enc_rsp = 0x40000edc; +r_ble_ll_ctrl_rx_feature_req = 0x40000ee0; +r_ble_ll_ctrl_rx_pause_enc_req = 0x40000ee8; +r_ble_ll_ctrl_rx_pause_enc_rsp = 0x40000eec; +r_ble_ll_ctrl_rx_periodic_sync_ind = 0x40000ef4; +r_ble_ll_ctrl_rx_phy_req = 0x40000ef8; +r_ble_ll_ctrl_rx_phy_rsp = 0x40000efc; +r_ble_ll_ctrl_rx_phy_update_ind = 0x40000f00; +r_ble_ll_ctrl_rx_ping_rsp = 0x40000f04; +r_ble_ll_ctrl_rx_reject_ind = 0x40000f08; +r_ble_ll_ctrl_rx_sca_req = 0x40000f0c; +r_ble_ll_ctrl_rx_sca_rsp = 0x40000f10; +r_ble_ll_ctrl_rx_start_enc_req = 0x40000f14; +r_ble_ll_ctrl_rx_start_enc_rsp = 0x40000f18; +r_ble_ll_ctrl_rx_version_ind = 0x40000f1c; +r_ble_ll_ctrl_sca_req_rsp_make = 0x40000f20; +r_ble_ll_ctrl_start_enc_send = 0x40000f24; +r_ble_ll_ctrl_start_rsp_timer = 0x40000f28; +r_ble_ll_ctrl_terminate_start = 0x40000f2c; +r_ble_ll_ctrl_update_features = 0x40000f34; +r_ble_ll_ctrl_version_ind_make = 0x40000f38; +r_ble_ll_data_buffer_overflow = 0x40000f3c; +r_ble_ll_disconn_comp_event_send = 0x40000f44; +r_ble_ll_event_comp_pkts = 0x40000f4c; +r_ble_ll_event_dbuf_overflow = 0x40000f50; +r_ble_ll_event_send = 0x40000f54; +r_ble_ll_event_tx_pkt = 0x40000f58; +r_ble_ll_ext_adv_phy_mode_to_local_phy = 0x40000f5c; +r_ble_ll_ext_scan_parse_adv_info = 0x40000f64; +r_ble_ll_ext_scan_parse_aux_ptr = 0x40000f68; +r_ble_ll_flush_pkt_queue = 0x40000f6c; +r_ble_ll_generate_dh_key_v1 = 0x40000f70; +r_ble_ll_generate_dh_key_v2 = 0x40000f74; +r_ble_ll_get_addr_type = 0x40000f7c; +r_ble_ll_get_our_devaddr = 0x40000f84; +r_ble_ll_get_tx_pwr_compensation = 0x40000f88; +r_ble_ll_hci_acl_rx = 0x40000f8c; +r_ble_ll_hci_adv_mode_ext = 0x40000f90; +r_ble_ll_hci_adv_set_enable = 0x40000f94; +r_ble_ll_hci_cb_set_ctrlr_to_host_fc = 0x40000f9c; +r_ble_ll_hci_cb_set_event_mask = 0x40000fa0; +r_ble_ll_hci_cb_set_event_mask2 = 0x40000fa4; +r_ble_ll_hci_chk_phy_masks = 0x40000fa8; +r_ble_ll_hci_cmd_rx = 0x40000fb0; +r_ble_ll_hci_disconnect = 0x40000fbc; +r_ble_ll_hci_ev_conn_update = 0x40000fc4; +r_ble_ll_hci_ev_databuf_overflow = 0x40000fc8; +r_ble_ll_hci_ev_datalen_chg = 0x40000fcc; +r_ble_ll_hci_ev_encrypt_chg = 0x40000fd0; +r_ble_ll_hci_ev_hw_err = 0x40000fd4; +r_ble_ll_hci_ev_le_csa = 0x40000fd8; +r_ble_ll_hci_ev_ltk_req = 0x40000fdc; +r_ble_ll_hci_ev_phy_update = 0x40000fe0; +r_ble_ll_hci_ev_rd_rem_used_feat = 0x40000fe4; +r_ble_ll_hci_ev_rd_rem_ver = 0x40000fe8; +r_ble_ll_hci_ev_rem_conn_parm_req = 0x40000fec; +r_ble_ll_hci_ev_sca_update = 0x40000ff0; +r_ble_ll_hci_ev_send_adv_set_terminated = 0x40000ff4; +r_ble_ll_hci_ev_send_scan_req_recv = 0x40000ff8; +r_ble_ll_hci_ev_send_scan_timeout = 0x40000ffc; +r_ble_ll_hci_ev_send_vendor_err = 0x40001000; +r_ble_ll_hci_ext_scan_set_enable = 0x40001008; +r_ble_ll_hci_get_num_cmd_pkts = 0x4000100c; +r_ble_ll_hci_info_params_cmd_proc = 0x40001010; +r_ble_ll_hci_init = 0x40001014; +r_ble_ll_hci_init_support_cmd_base_on_lmp_ver = 0x40001018; +r_ble_ll_hci_is_event_enabled = 0x4000101c; +r_ble_ll_hci_is_le_event_enabled = 0x40001020; +r_ble_ll_hci_le_cmd_send_cmd_status = 0x40001028; +r_ble_ll_hci_le_encrypt = 0x4000102c; +r_ble_ll_hci_le_rand = 0x40001030; +r_ble_ll_hci_le_rd_max_data_len = 0x40001034; +r_ble_ll_hci_le_rd_sugg_data_len = 0x40001038; +r_ble_ll_hci_le_read_bufsize = 0x4000103c; +r_ble_ll_hci_le_read_supp_states = 0x40001044; +r_ble_ll_hci_le_set_def_phy = 0x40001048; +r_ble_ll_hci_le_wr_sugg_data_len = 0x4000104c; +r_ble_ll_hci_link_ctrl_cmd_proc = 0x40001050; +r_ble_ll_hci_npl_init = 0x40001054; +r_ble_ll_hci_post_gen_dhkey_cmp_evt = 0x40001058; +r_ble_ll_hci_post_rd_p256_pubkey_cmp_evt = 0x4000105c; +r_ble_ll_hci_rd_bd_addr = 0x40001060; +r_ble_ll_hci_rd_local_supp_cmd = 0x40001064; +r_ble_ll_hci_rd_local_supp_feat = 0x40001068; +r_ble_ll_hci_rd_local_version = 0x4000106c; +r_ble_ll_hci_scan_set_enable = 0x40001070; +r_ble_ll_hci_send_adv_report = 0x40001074; +r_ble_ll_hci_send_dir_adv_report = 0x40001078; +r_ble_ll_hci_send_noop = 0x40001084; +r_ble_ll_hci_set_adv_data = 0x40001088; +r_ble_ll_hci_set_le_event_mask = 0x4000108c; +r_ble_ll_hci_set_scan_rsp_data = 0x40001090; +r_ble_ll_hci_status_params_cmd_proc = 0x40001094; +r_ble_ll_hci_vs_cmd_proc = 0x40001098; +r_ble_ll_hci_vs_rd_static_addr = 0x4000109c; +r_ble_ll_hw_err_timer_cb = 0x400010a0; +r_ble_ll_hw_error = 0x400010a4; +r_ble_ll_init_alloc_conn_comp_ev = 0x400010ac; +r_ble_ll_init_get_conn_comp_ev = 0x400010b0; +r_ble_ll_is_addr_empty = 0x400010b8; +r_ble_ll_is_controller_busy = 0x400010bc; +r_ble_ll_is_on_resolv_list = 0x400010c0; +r_ble_ll_is_our_devaddr = 0x400010c4; +r_ble_ll_is_rpa = 0x400010c8; +r_ble_ll_is_valid_adv_mode = 0x400010cc; +r_ble_ll_is_valid_own_addr_type = 0x400010d0; +r_ble_ll_is_valid_public_addr = 0x400010d4; +r_ble_ll_is_valid_random_addr = 0x400010d8; +r_ble_ll_misc_options_set = 0x400010e0; +r_ble_ll_modify_sca = 0x400010e4; +r_ble_ll_pdu_max_tx_octets_get = 0x400010ec; +r_ble_ll_pdu_tx_time_get = 0x400010f0; +r_ble_ll_phy_to_phy_mode = 0x400010f4; +r_ble_ll_qa_enable = 0x400010f8; +r_ble_ll_rand_data_get = 0x40001100; +r_ble_ll_rand_init = 0x4000110c; +r_ble_ll_rand_prand_get = 0x40001110; +r_ble_ll_rand_sample = 0x40001114; +r_ble_ll_rand_start = 0x40001118; +r_ble_ll_read_local_p256_pub_key = 0x4000111c; +r_ble_ll_read_rf_path_compensation = 0x40001120; +r_ble_ll_read_supp_features = 0x40001124; +r_ble_ll_read_supp_states = 0x40001128; +r_ble_ll_resolv_clear_all_pl_bit = 0x40001134; +r_ble_ll_resolv_clear_all_wl_bit = 0x40001138; +r_ble_ll_resolv_enable_cmd = 0x40001140; +r_ble_ll_resolv_enabled = 0x40001144; +r_ble_ll_resolv_gen_rpa = 0x40001150; +r_ble_ll_resolv_get_addr_pointer = 0x40001154; +r_ble_ll_resolv_get_index = 0x40001158; +r_ble_ll_resolv_get_irk_pointer = 0x4000115c; +r_ble_ll_resolv_get_list = 0x40001160; +r_ble_ll_resolv_get_priv_addr = 0x40001164; +r_ble_ll_resolv_get_rpa_tmo = 0x40001168; +r_ble_ll_resolv_irk_nonzero = 0x40001170; +r_ble_ll_resolv_list_add = 0x40001174; +r_ble_ll_resolv_list_chg_allowed = 0x40001178; +r_ble_ll_resolv_list_clr = 0x4000117c; +r_ble_ll_resolv_list_find = 0x40001180; +r_ble_ll_resolv_list_read_size = 0x40001184; +r_ble_ll_resolv_list_reset = 0x40001188; +r_ble_ll_resolv_local_addr_rd = 0x40001190; +r_ble_ll_resolv_peer_addr_rd = 0x40001194; +r_ble_ll_resolv_peer_rpa_any = 0x40001198; +r_ble_ll_resolv_reset = 0x4000119c; +r_ble_ll_resolv_rpa = 0x400011a0; +r_ble_ll_resolv_rpa_timer_cb = 0x400011a4; +r_ble_ll_resolv_set_local_rpa = 0x400011a8; +r_ble_ll_resolv_set_peer_rpa = 0x400011ac; +r_ble_ll_resolv_set_rpa_tmo = 0x400011b0; +r_ble_ll_resolve_set_priv_mode = 0x400011b4; +r_ble_ll_rxpdu_alloc = 0x400011b8; +r_ble_ll_scan_add_scan_rsp_adv = 0x400011bc; +r_ble_ll_scan_adv_decode_addr = 0x400011c0; +r_ble_ll_scan_aux_data_ref = 0x400011c4; +r_ble_ll_scan_aux_data_unref = 0x400011c8; +r_ble_ll_scan_can_chg_whitelist = 0x400011cc; +r_ble_ll_scan_check_periodic_sync = 0x400011d0; +r_ble_ll_scan_classify_filter_aux_init = 0x400011d4; +r_ble_ll_scan_classify_filter_init = 0x400011d8; +//r_ble_ll_scan_common_init = 0x400011dc; +r_ble_ll_scan_continue_en = 0x400011e0; +r_ble_ll_scan_dup_check_ext = 0x400011e8; +r_ble_ll_scan_dup_check_legacy = 0x400011ec; +r_ble_ll_scan_dup_move_to_head = 0x400011f0; +r_ble_ll_scan_dup_new = 0x400011f4; +r_ble_ll_scan_dup_update_ext = 0x400011f8; +r_ble_ll_scan_dup_update_legacy = 0x400011fc; +r_ble_ll_scan_enabled = 0x40001200; +r_ble_ll_scan_end_adv_evt = 0x40001204; +r_ble_ll_scan_ext_initiator_start = 0x4000120c; +r_ble_ll_scan_get_addr_data_from_legacy = 0x40001210; +r_ble_ll_scan_get_addr_from_ext_adv = 0x40001214; +r_ble_ll_scan_get_cur_sm = 0x40001218; +r_ble_ll_scan_get_ext_adv_report = 0x4000121c; +r_ble_ll_scan_get_local_rpa = 0x40001220; +r_ble_ll_scan_get_next_adv_prim_chan = 0x40001224; +r_ble_ll_scan_get_peer_rpa = 0x40001228; +r_ble_ll_scan_have_rxd_scan_rsp = 0x4000122c; +r_ble_ll_scan_initiator_start = 0x40001234; +r_ble_ll_scan_is_inside_window = 0x40001238; +r_ble_ll_scan_move_window_to = 0x4000123c; +r_ble_ll_scan_npl_reset = 0x40001240; +r_ble_ll_scan_parse_auxptr = 0x40001244; +r_ble_ll_scan_parse_ext_hdr = 0x40001248; +r_ble_ll_scan_record_new_adv = 0x40001250; +r_ble_ll_scan_refresh_nrpa = 0x40001254; +r_ble_ll_scan_reset = 0x40001258; +r_ble_ll_scan_rx_pkt_in = 0x4000125c; +r_ble_ll_scan_rx_pkt_in_restore_addr_data = 0x40001268; +r_ble_ll_scan_rxed = 0x4000126c; +r_ble_ll_scan_send_truncated = 0x40001274; +r_ble_ll_scan_set_peer_rpa = 0x4000127c; +r_ble_ll_scan_set_perfer_addr = 0x40001280; +r_ble_ll_scan_sm_start = 0x40001288; +r_ble_ll_scan_sm_stop = 0x4000128c; +r_ble_ll_scan_time_hci_to_ticks = 0x40001290; +r_ble_ll_scan_update_aux_data = 0x40001294; +r_ble_ll_scan_whitelist_enabled = 0x40001298; +r_ble_ll_set_default_privacy_mode = 0x4000129c; +r_ble_ll_set_default_sync_transfer_params = 0x400012a0; +r_ble_ll_set_public_addr = 0x400012ac; +r_ble_ll_set_random_addr = 0x400012b0; +r_ble_ll_set_sync_transfer_params = 0x400012b4; +r_ble_ll_state_get = 0x400012b8; +r_ble_ll_state_set = 0x400012bc; +r_ble_ll_sync_adjust_ext_hdr = 0x400012c0; +r_ble_ll_sync_cancel = 0x400012c4; +r_ble_ll_sync_cancel_complete_event = 0x400012c8; +r_ble_ll_sync_check_acad = 0x400012cc; +r_ble_ll_sync_check_failed = 0x400012d0; +r_ble_ll_sync_enabled = 0x400012dc; +r_ble_ll_sync_established = 0x400012ec; +r_ble_ll_sync_filter_enabled = 0x400012f0; +r_ble_ll_sync_find = 0x400012f4; +r_ble_ll_sync_get_cur_sm = 0x400012f8; +r_ble_ll_sync_get_handle = 0x400012fc; +r_ble_ll_sync_get_sm = 0x40001300; +r_ble_ll_sync_info_event = 0x40001304; +r_ble_ll_sync_init = 0x40001308; +r_ble_ll_sync_list_add = 0x4000130c; +r_ble_ll_sync_list_clear = 0x40001310; +r_ble_ll_sync_list_empty = 0x40001314; +r_ble_ll_sync_list_get_free = 0x40001318; +r_ble_ll_sync_list_remove = 0x4000131c; +r_ble_ll_sync_list_search = 0x40001320; +r_ble_ll_sync_list_size = 0x40001324; +r_ble_ll_sync_lost_event = 0x40001328; +r_ble_ll_sync_next_event = 0x4000132c; +r_ble_ll_sync_on_list = 0x40001330; +r_ble_ll_sync_periodic_ind = 0x40001338; +r_ble_ll_sync_phy_mode_to_aux_phy = 0x4000133c; +r_ble_ll_sync_phy_mode_to_hci = 0x40001340; +r_ble_ll_sync_reserve = 0x4000134c; +r_ble_ll_sync_reset = 0x40001350; +r_ble_ll_sync_reset_sm = 0x40001354; +r_ble_ll_sync_send_per_adv_rpt = 0x4000135c; +r_ble_ll_sync_send_sync_ind = 0x40001360; +r_ble_ll_sync_send_truncated_per_adv_rpt = 0x40001364; +r_ble_ll_sync_sm_clear = 0x40001368; +r_ble_ll_sync_terminate = 0x4000136c; +r_ble_ll_sync_transfer = 0x40001370; +r_ble_ll_sync_transfer_get = 0x40001374; +r_ble_ll_sync_transfer_received = 0x40001378; +r_ble_ll_trace_u32 = 0x40001384; +r_ble_ll_trace_u32x2 = 0x40001388; +r_ble_ll_trace_u32x3 = 0x4000138c; +r_ble_ll_tx_flat_mbuf_pducb = 0x40001390; +r_ble_ll_update_max_tx_octets_phy_mode = 0x4000139c; +r_ble_ll_usecs_to_ticks_round_up = 0x400013a0; +r_ble_ll_utils_calc_access_addr = 0x400013a4; +r_ble_ll_utils_calc_dci_csa2 = 0x400013a8; +r_ble_ll_utils_calc_num_used_chans = 0x400013ac; +r_ble_ll_utils_calc_window_widening = 0x400013b0; +r_ble_ll_utils_csa2_perm = 0x400013b4; +r_ble_ll_utils_csa2_prng = 0x400013b8; +r_ble_ll_utils_remapped_channel = 0x400013bc; +r_ble_ll_whitelist_add = 0x400013c0; +r_ble_ll_whitelist_chg_allowed = 0x400013c4; +r_ble_ll_whitelist_read_size = 0x400013cc; +r_ble_ll_write_rf_path_compensation = 0x400013d8; +r_ble_lll_adv_aux_schedule = 0x400013e0; +r_ble_lll_adv_aux_schedule_first = 0x400013e4; +r_ble_lll_adv_aux_schedule_next = 0x400013e8; +r_ble_lll_adv_aux_scheduled = 0x400013ec; +r_ble_lll_adv_aux_set_start_time = 0x400013f0; +r_ble_lll_adv_coex_dpc_calc_pti_update_itvl = 0x400013f4; +r_ble_lll_adv_coex_dpc_process_pri = 0x400013f8; +r_ble_lll_adv_coex_dpc_process_sec = 0x400013fc; +r_ble_lll_adv_coex_dpc_pti_get = 0x40001400; +r_ble_lll_adv_coex_dpc_update = 0x40001404; +r_ble_lll_adv_coex_dpc_update_on_adv_start = 0x40001408; +r_ble_lll_adv_coex_dpc_update_on_aux_scheduled = 0x4000140c; +r_ble_lll_adv_coex_dpc_update_on_data_updated = 0x40001410; +r_ble_lll_adv_coex_dpc_update_on_event_end = 0x40001414; +r_ble_lll_adv_coex_dpc_update_on_event_scheduled = 0x40001418; +r_ble_lll_adv_done = 0x4000141c; +r_ble_lll_adv_event_done = 0x40001424; +r_ble_lll_adv_event_rmvd_from_sched = 0x40001428; +r_ble_lll_adv_get_sec_pdu_len = 0x40001430; +r_ble_lll_adv_make_done = 0x40001438; +r_ble_lll_adv_periodic_done = 0x4000143c; +r_ble_lll_adv_periodic_event_done = 0x40001440; +r_ble_lll_adv_periodic_rmvd_from_sched = 0x40001444; +r_ble_lll_adv_periodic_schedule_first = 0x40001448; +r_ble_lll_adv_pri_schedule_tx_pdu = 0x40001458; +r_ble_lll_adv_reschedule_event = 0x4000145c; +r_ble_lll_adv_reschedule_periodic_event = 0x40001460; +r_ble_lll_adv_sec_event_done = 0x4000146c; +r_ble_lll_adv_sec_schedule_next_aux = 0x40001470; +r_ble_lll_adv_secondary_tx_start_cb = 0x40001474; +r_ble_lll_adv_sm_deinit = 0x40001478; +r_ble_lll_adv_sm_event_init = 0x4000147c; +r_ble_lll_adv_sm_event_restore = 0x40001480; +r_ble_lll_adv_sm_event_store = 0x40001484; +r_ble_lll_adv_sm_init = 0x40001488; +r_ble_lll_adv_sm_reset = 0x4000148c; +r_ble_lll_adv_start = 0x40001490; +r_ble_lll_adv_stop = 0x40001494; +r_ble_lll_adv_sync_next_scheduled = 0x40001498; +r_ble_lll_adv_sync_schedule = 0x4000149c; +r_ble_lll_adv_sync_tx_done = 0x400014a0; +r_ble_lll_adv_sync_tx_end = 0x400014a4; +r_ble_lll_adv_sync_tx_start_cb = 0x400014a8; +r_ble_lll_adv_tx_done = 0x400014ac; +r_ble_lll_adv_tx_start_cb = 0x400014b0; +r_ble_lll_adv_update_rsp_offset = 0x400014b4; +r_ble_lll_aux_scan_cb = 0x400014b8; +r_ble_lll_aux_scan_drop = 0x400014bc; +r_ble_lll_aux_scan_drop_event_cb = 0x400014c0; +r_ble_lll_calc_us_convert_tick_unit = 0x400014c4; +r_ble_lll_conn_can_send_next_pdu = 0x400014cc; +r_ble_lll_conn_check_opcode_matched = 0x400014d0; +r_ble_lll_conn_coex_dpc_process = 0x400014d4; +r_ble_lll_conn_coex_dpc_pti_get = 0x400014d8; +r_ble_lll_conn_coex_dpc_update = 0x400014dc; +r_ble_lll_conn_coex_dpc_update_on_event_end = 0x400014e0; +r_ble_lll_conn_coex_dpc_update_on_event_scheduled = 0x400014e4; +r_ble_lll_conn_coex_dpc_update_on_event_started = 0x400014e8; +r_ble_lll_conn_cth_flow_alloc_credit = 0x400014ec; +r_ble_lll_conn_current_sm_over = 0x400014f4; +r_ble_lll_conn_event_is_over = 0x40001510; +r_ble_lll_conn_event_start_cb = 0x40001514; +r_ble_lll_conn_free_rx_mbuf = 0x40001518; +r_ble_lll_conn_get_addr_info_from_rx_buf = 0x4000151c; +r_ble_lll_conn_get_ce_end_time = 0x40001520; +r_ble_lll_conn_get_next_sched_time = 0x40001524; +r_ble_lll_conn_master_common_init = 0x40001530; +r_ble_lll_conn_master_new = 0x40001534; +r_ble_lll_conn_module_reset = 0x40001540; +r_ble_lll_conn_pre_process = 0x40001548; +r_ble_lll_conn_recv_ack = 0x40001554; +r_ble_lll_conn_recv_valid_packet = 0x40001558; +r_ble_lll_conn_reset_pending_sched = 0x4000155c; +r_ble_lll_conn_sched_next_anchor = 0x40001564; +r_ble_lll_conn_sched_next_event = 0x40001568; +r_ble_lll_conn_sm_new = 0x40001574; +r_ble_lll_conn_sm_npl_deinit = 0x40001578; +r_ble_lll_conn_sm_npl_init = 0x4000157c; +r_ble_lll_conn_superversion_timer_cb = 0x40001580; +r_ble_lll_conn_timeout = 0x40001584; +r_ble_lll_conn_update_anchor = 0x40001588; +r_ble_lll_conn_update_conn_ind_params = 0x4000158c; +r_ble_lll_conn_update_tx_buffer = 0x40001594; +r_ble_lll_deinit = 0x40001598; +r_ble_lll_dtm_calculate_itvl = 0x4000159c; +r_ble_lll_dtm_ctx_free = 0x400015a0; +r_ble_lll_dtm_end_test = 0x400015a8; +r_ble_lll_dtm_ev_rx_restart_cb = 0x400015ac; +r_ble_lll_dtm_ev_tx_resched_cb = 0x400015b0; +r_ble_lll_dtm_reset = 0x400015b8; +r_ble_lll_dtm_rx_create_ctx = 0x400015bc; +r_ble_lll_dtm_rx_isr_end = 0x400015c0; +r_ble_lll_dtm_rx_isr_start = 0x400015c4; +r_ble_lll_dtm_rx_pkt_in = 0x400015c8; +r_ble_lll_dtm_rx_sched_cb = 0x400015cc; +r_ble_lll_dtm_rx_start = 0x400015d0; +r_ble_lll_dtm_rx_test = 0x400015d4; +r_ble_lll_dtm_set_next = 0x400015d8; +r_ble_lll_dtm_tx_done = 0x400015e0; +r_ble_lll_dtm_tx_sched_cb = 0x400015e4; +r_ble_lll_dtm_tx_test = 0x400015e8; +r_ble_lll_dtm_wfr_timer_exp = 0x400015ec; +r_ble_lll_event_rx_pkt = 0x400015f0; +r_ble_lll_ext_scan_coex_dpc_process = 0x400015f4; +r_ble_lll_ext_scan_coex_dpc_pti_get = 0x400015f8; +r_ble_lll_ext_scan_coex_dpc_update = 0x400015fc; +r_ble_lll_ext_scan_coex_dpc_update_on_start = 0x40001600; +r_ble_lll_hci_dtm_rx_test = 0x40001604; +r_ble_lll_hci_dtm_rx_test_v2 = 0x40001608; +r_ble_lll_hci_dtm_tx_test = 0x4000160c; +r_ble_lll_hci_dtm_tx_test_ext = 0x40001610; +r_ble_lll_hci_dtm_tx_test_v2 = 0x40001614; +r_ble_lll_hci_dtm_tx_test_v2_ext = 0x40001618; +r_ble_lll_init = 0x4000161c; +r_ble_lll_init_pre_process = 0x40001620; +r_ble_lll_per_adv_coex_dpc_calc_pti_update_itvl = 0x40001628; +r_ble_lll_per_adv_coex_dpc_process = 0x4000162c; +r_ble_lll_per_adv_coex_dpc_pti_get = 0x40001630; +r_ble_lll_per_adv_coex_dpc_update = 0x40001634; +r_ble_lll_per_adv_coex_dpc_update_on_data_updated = 0x40001638; +r_ble_lll_per_adv_coex_dpc_update_on_scheduled = 0x4000163c; +r_ble_lll_per_adv_coex_dpc_update_on_start = 0x40001640; +r_ble_lll_rfmgmt_is_enabled = 0x40001660; +r_ble_lll_rfmgmt_release = 0x40001664; +r_ble_lll_rfmgmt_scan_changed = 0x40001670; +r_ble_lll_rfmgmt_sched_changed = 0x40001674; +r_ble_lll_rfmgmt_set_sleep_cb = 0x40001678; +r_ble_lll_rfmgmt_ticks_to_enabled = 0x4000167c; +r_ble_lll_rx_pdu_in = 0x40001688; +r_ble_lll_rx_pkt_in = 0x4000168c; +r_ble_lll_rx_pkt_isr = 0x40001690; +r_ble_lll_scan_abort_aux_sched = 0x40001694; +r_ble_lll_scan_chk_resume = 0x4000169c; +r_ble_lll_scan_clean_cur_aux_data = 0x400016a0; +//r_ble_lll_scan_coex_event_cb = 0x400016a4; +r_ble_lll_scan_common_init = 0x400016a8; +r_ble_lll_scan_deinit = 0x400016ac; +r_ble_lll_scan_duration_period_timers_restart = 0x400016b0; +r_ble_lll_scan_duration_period_timers_stop = 0x400016b4; +r_ble_lll_scan_duration_timer_cb = 0x400016b8; +r_ble_lll_scan_event_proc = 0x400016bc; +r_ble_lll_scan_ext_adv_init = 0x400016c0; +r_ble_lll_scan_has_sent_scan_req = 0x400016c8; +r_ble_lll_scan_npl_reset = 0x400016d4; +r_ble_lll_scan_npl_restore = 0x400016d8; +r_ble_lll_scan_npl_store = 0x400016dc; +r_ble_lll_scan_period_timer_cb = 0x400016e0; +r_ble_lll_scan_process_adv_in_isr = 0x400016e4; +r_ble_lll_scan_req_backoff = 0x400016ec; +r_ble_lll_scan_sched_next_aux = 0x40001700; +r_ble_lll_scan_sched_remove = 0x40001704; +r_ble_lll_scan_start = 0x40001708; +//r_ble_lll_scan_start_rx = 0x4000170c; +r_ble_lll_scan_timer_cb = 0x40001718; +r_ble_lll_sched_adv_new = 0x4000171c; +r_ble_lll_sched_adv_resched_pdu = 0x40001720; +r_ble_lll_sched_adv_reschedule = 0x40001724; +r_ble_lll_sched_aux_scan = 0x40001728; +r_ble_lll_sched_conn_overlap = 0x4000172c; +r_ble_lll_sched_dtm = 0x40001738; +r_ble_lll_sched_execute_item = 0x40001744; +r_ble_lll_sched_insert_if_empty = 0x4000174c; +r_ble_lll_sched_is_overlap = 0x40001750; +r_ble_lll_sched_master_new = 0x40001754; +r_ble_lll_sched_next_time = 0x40001758; +r_ble_lll_sched_overlaps_current = 0x4000175c; +r_ble_lll_sched_periodic_adv = 0x40001760; +r_ble_lll_sched_rmv_elem = 0x40001764; +r_ble_lll_sched_rmv_elem_type = 0x40001768; +r_ble_lll_sched_run = 0x4000176c; +r_ble_lll_sched_scan_req_over_aux_ptr = 0x40001770; +r_ble_lll_sched_slave_new = 0x40001774; +r_ble_lll_sched_stop = 0x40001778; +r_ble_lll_sched_sync = 0x4000177c; +r_ble_lll_sched_sync_overlaps_current = 0x40001780; +r_ble_lll_sync_chain_start_cb = 0x40001788; +r_ble_lll_sync_coex_dpc_process = 0x4000178c; +r_ble_lll_sync_coex_dpc_pti_get = 0x40001790; +r_ble_lll_sync_coex_dpc_update = 0x40001794; +r_ble_lll_sync_current_sm_over = 0x40001798; +r_ble_lll_sync_deinit = 0x4000179c; +r_ble_lll_sync_event_end_cb = 0x400017a4; +r_ble_lll_sync_get_event_end_time = 0x400017ac; +r_ble_lll_sync_init = 0x400017b4; +r_ble_lll_sync_new = 0x400017b8; +r_ble_lll_sync_reset = 0x400017bc; +r_ble_lll_sync_reset_sm = 0x400017c0; +r_ble_lll_sync_rmvd_from_sched = 0x400017c4; +r_ble_lll_sync_schedule_chain = 0x400017cc; +r_ble_lll_sync_stop = 0x400017d0; +r_ble_lll_sync_trnasfer_sched = 0x400017d4; +r_ble_phy_access_addr_get = 0x400017d8; +r_ble_phy_calculate_rxtx_ifs = 0x400017dc; +r_ble_phy_calculate_rxwindow = 0x400017e0; +r_ble_phy_calculate_txrx_ifs = 0x400017e4; +r_ble_phy_check_bb_status = 0x400017e8; +r_ble_phy_complete_rx_info = 0x400017ec; +r_ble_phy_data_make = 0x400017f4; +r_ble_phy_disable = 0x400017f8; +r_ble_phy_disable_irq = 0x400017fc; +r_ble_phy_disable_whitening = 0x40001800; +r_ble_phy_enable_whitening = 0x40001804; +r_ble_phy_encrypt_disable = 0x40001808; +r_ble_phy_get_current_phy = 0x40001810; +r_ble_phy_get_packet_counter = 0x40001814; +r_ble_phy_get_packet_status = 0x40001818; +r_ble_phy_get_pyld_time_offset = 0x4000181c; +r_ble_phy_get_rx_phy_mode = 0x40001820; +r_ble_phy_get_seq_end_st = 0x40001824; +r_ble_phy_max_data_pdu_pyld = 0x40001830; +r_ble_phy_mode_config = 0x40001834; +r_ble_phy_mode_convert = 0x40001838; +r_ble_phy_mode_write = 0x4000183c; +r_ble_phy_module_init = 0x40001844; +r_ble_phy_reset_bb_monitor = 0x4000184c; +r_ble_phy_resolv_list_disable = 0x40001850; +r_ble_phy_resolv_list_enable = 0x40001854; +r_ble_phy_restart_sequence = 0x40001858; +r_ble_phy_rx_set_start_time_forcibly = 0x4000185c; +r_ble_phy_rxpdu_copy = 0x40001860; +r_ble_phy_seq_encrypt_enable = 0x40001864; +r_ble_phy_seq_encrypt_set_pkt_cntr = 0x40001868; +r_ble_phy_sequence_end_isr = 0x4000186c; +r_ble_phy_sequence_get_mode = 0x40001870; +r_ble_phy_sequence_is_running = 0x40001874; +r_ble_phy_sequence_is_waiting_rsp = 0x40001878; +r_ble_phy_sequence_single_end = 0x4000187c; +r_ble_phy_sequence_tx_end_invoke = 0x40001880; +r_ble_phy_sequence_update_conn_ind_params = 0x40001884; +r_ble_phy_set_coex_pti = 0x4000188c; +r_ble_phy_set_conn_ind_pdu = 0x40001890; +r_ble_phy_set_conn_mode = 0x40001894; +r_ble_phy_set_dev_address = 0x40001898; +r_ble_phy_set_rx_pwr_compensation = 0x4000189c; +r_ble_phy_set_single_packet_rx_sequence = 0x400018ac; +r_ble_phy_set_single_packet_tx_sequence = 0x400018b0; +r_ble_phy_set_tx_rx_transition = 0x400018b4; +r_ble_phy_set_txend_cb = 0x400018b8; +r_ble_phy_setchan = 0x400018bc; +r_ble_phy_start_rx_immediately = 0x400018c0; +r_ble_phy_state_get = 0x400018c4; +r_ble_phy_timer_config_start_time = 0x400018c8; +r_ble_phy_timer_start_now = 0x400018cc; +r_ble_phy_timer_stop = 0x400018d0; +r_ble_phy_tx_set_start_time = 0x400018d4; +r_ble_phy_txpwr_set = 0x400018dc; +r_ble_phy_update_ifs = 0x400018e8; +r_ble_phy_xcvr_state_get = 0x400018ec; +r_ble_plf_set_log_level = 0x400018f0; +r_ble_rtc_wake_up_cpu_init = 0x400018f4; +r_ble_rtc_wake_up_state_clr = 0x400018f8; +r_ble_vendor_hci_register = 0x400018fc; +r_bt_rf_coex_cfg_set = 0x40001900; +r_bt_rf_coex_coded_txrx_time_upper_lim = 0x40001904; +r_bt_rf_coex_dft_pti_set = 0x40001908; +r_bt_rf_coex_hook_deinit = 0x4000190c; +r_bt_rf_coex_hook_init = 0x40001910; +r_bt_rf_coex_hook_st_set = 0x40001914; +r_bt_rf_coex_hooks_p_set_default = 0x40001918; +r_btdm_disable_adv_delay = 0x4000191c; +r_btdm_switch_phy_coded = 0x40001920; +r_esp_wait_disabled = 0x40001924; +r_get_be16 = 0x40001928; +r_get_be24 = 0x4000192c; +r_get_be32 = 0x40001930; +r_get_be64 = 0x40001934; +r_get_le16 = 0x40001938; +r_get_le24 = 0x4000193c; +r_get_le32 = 0x40001940; +r_get_le64 = 0x40001944; +r_get_local_irk_offset = 0x40001948; +r_get_local_rpa_offset = 0x4000194c; +r_get_max_skip = 0x40001950; +r_get_peer_id_offset = 0x40001954; +r_get_peer_irk_offset = 0x40001958; +r_get_peer_rpa_offset = 0x4000195c; +r_hal_timer_disable_irq = 0x4000196c; +r_hal_timer_process = 0x40001978; +r_hal_timer_read = 0x4000197c; +r_hal_timer_read_tick = 0x40001980; +r_hal_timer_set_cb = 0x40001984; +r_hal_timer_start = 0x4000198c; +r_hal_timer_task_start = 0x40001998; +r_ll_assert = 0x4000199c; +r_mem_init_mbuf_pool = 0x400019a0; +r_mem_malloc_mbuf_pool = 0x400019a4; +r_mem_malloc_mbufpkt_pool = 0x400019a8; +r_mem_malloc_mempool = 0x400019ac; +r_mem_malloc_mempool_ext = 0x400019b0; +r_mem_malloc_mempool_gen = 0x400019b4; +r_mem_pullup_obj = 0x400019b8; +r_os_cputime_get32 = 0x400019c0; +r_os_cputime_ticks_to_usecs = 0x400019c4; +r_os_cputime_timer_init = 0x400019c8; +r_os_cputime_timer_relative = 0x400019cc; +r_os_cputime_timer_start = 0x400019d0; +r_os_cputime_timer_stop = 0x400019d4; +r_os_cputime_usecs_to_ticks = 0x400019d8; +r_os_mbuf_adj = 0x400019dc; +r_os_mbuf_appendfrom = 0x400019e4; +r_os_mbuf_cmpf = 0x400019e8; +r_os_mbuf_cmpm = 0x400019ec; +r_os_mbuf_concat = 0x400019f0; +r_os_mbuf_copydata = 0x400019f4; +r_os_mbuf_copyinto = 0x400019f8; +r_os_mbuf_dup = 0x400019fc; +r_os_mbuf_extend = 0x40001a00; +r_os_mbuf_free = 0x40001a04; +r_os_mbuf_free_chain = 0x40001a08; +r_os_mbuf_get = 0x40001a0c; +r_os_mbuf_get_pkthdr = 0x40001a10; +r_os_mbuf_leadingspace = 0x40001a14; +r_os_mbuf_len = 0x40001a18; +r_os_mbuf_off = 0x40001a1c; +r_os_mbuf_pack_chains = 0x40001a20; +r_os_mbuf_pool_init = 0x40001a24; +r_os_mbuf_prepend = 0x40001a28; +r_os_mbuf_prepend_pullup = 0x40001a2c; +r_os_mbuf_pullup = 0x40001a30; +r_os_mbuf_trailingspace = 0x40001a34; +r_os_mbuf_trim_front = 0x40001a38; +r_os_mbuf_widen = 0x40001a3c; +r_os_memblock_from = 0x40001a40; +r_os_memblock_get = 0x40001a44; +r_os_memblock_put_from_cb = 0x40001a4c; +r_os_mempool_clear = 0x40001a50; +r_os_mempool_ext_clear = 0x40001a54; +r_os_mempool_ext_init = 0x40001a58; +r_os_mempool_init = 0x40001a60; +r_os_mempool_is_sane = 0x40001a68; +r_os_mqueue_get = 0x40001a74; +r_os_mqueue_init = 0x40001a78; +r_os_mqueue_put = 0x40001a7c; +r_os_msys_count = 0x40001a80; +r_os_msys_get = 0x40001a84; +r_os_msys_get_pkthdr = 0x40001a88; +r_os_msys_num_free = 0x40001a8c; +r_os_msys_register = 0x40001a90; +r_os_msys_reset = 0x40001a94; +r_pri_phy_valid = 0x40001a98; +r_put_be16 = 0x40001a9c; +r_put_be24 = 0x40001aa0; +r_put_be32 = 0x40001aa4; +r_put_be64 = 0x40001aa8; +r_put_le16 = 0x40001aac; +r_put_le24 = 0x40001ab0; +r_put_le32 = 0x40001ab4; +r_put_le64 = 0x40001ab8; +r_rtc0_timer_handler = 0x40001abc; +r_sdkconfig_get_opts = 0x40001ac0; +//r_sdkconfig_set_opts = 0x40001ac4; +r_sec_phy_valid = 0x40001ac8; +r_swap_buf = 0x40001acc; +r_swap_in_place = 0x40001ad0; +/* Data (.data, .bss, .rodata) */ +ble_lll_dtm_module_env_p = 0x3fcdffc4; +g_ble_lll_dtm_prbs15_data = 0x3ff4fee4; +g_ble_lll_dtm_prbs9_data = 0x3ff4fde4; +g_channel_rf_to_index = 0x3ff4fdbc; +g_ble_lll_rfmgmt_data = 0x3fcdff7c; +g_ble_sleep_enter_cb = 0x3fcdff78; +g_ble_sleep_exit_cb = 0x3fcdff74; +ble_lll_sched_env_p = 0x3fcdff70; +ble_ll_env_p = 0x3fcdff6c; +g_ble_ll_pdu_header_tx_time_ro = 0x3ff4fdb4; +ble_ll_adv_env_p = 0x3fcdff68; +ble_ll_conn_env_p = 0x3fcdff64; +ble_ll_conn_required_phy_mask = 0x3ff4fdb0; +ble_ll_valid_conn_phy_mask = 0x3ff4fdaf; +ble_ll_hci_env_p = 0x3fcdff60; +g_debug_le_private_key = 0x3ff4fd6c; +g_ecc_key = 0x3fcdfefc; +ble_ll_rand_env_p = 0x3fcdfef8; +ble_ll_resolv_env_p = 0x3fcdfef4; +g_ble_ll_resolve_hdr = 0x3fcdfeec; +g_device_mode_default = 0x3fcdfe68; +ble_ll_scan_classify_filter_aux_check_cb = 0x3fcdfee8; +ble_ll_scan_classify_filter_check_cb = 0x3fcdfee4; +ble_ll_scan_env_p = 0x3fcdfee0; +g_ble_ll_supp_cmds_ro = 0x3ff4fd3c; +ble_ll_sync_env_p = 0x3fcdfedc; +g_ble_sca_ppm_tbl_ro = 0x3ff4fd2c; +priv_config_opts = 0x3fcdfe48; +ble_hci_uart_reset_cmd = 0x3ff4fd28; +ble_hci_trans_env_p = 0x3fcdfed8; +ble_hci_trans_mode = 0x3fcdfe44; +ble_hci_trans_funcs_ptr = 0x3fcdfed4; +r_ble_lll_stub_funcs_ptr = 0x3fcdfed0; +r_ble_stub_funcs_ptr = 0x3fcdfecc; +r_ext_funcs_p = 0x3fcdfec8; +r_npl_funcs = 0x3fcdfec4; +ble_hw_env_p = 0x3fcdfec0; +ble_phy_module_env_p = 0x3fcdfebc; +g_ble_phy_chan_freq_ro = 0x3ff4fd00; +g_ble_phy_mode_pkt_start_off_ro = 0x3ff4fcf8; +g_ble_phy_rxtx_ifs_compensation_ro = 0x3ff4fce8; +g_ble_phy_t_rxaddrdelay_ro = 0x3ff4fce4; +g_ble_phy_t_rxenddelay_ro = 0x3ff4fce0; +g_ble_phy_t_txdelay_ro = 0x3ff4fcdc; +g_ble_phy_t_txenddelay_ro = 0x3ff4fcd8; +g_ble_phy_txrx_ifs_compensation_ro = 0x3ff4fcc8; +hal_timer_env_p = 0x3fcdfeb8; +r_osi_coex_funcs_p = 0x3fcdfeb4; +bt_rf_coex_hooks = 0x3fcdfeac; +bt_rf_coex_hooks_p = 0x3fcdfea8; +coex_hook_st_group_tab = 0x3ff4fcbc; +coex_hook_st_group_to_coex_schm_st_tab = 0x3ff4fcb8; +s_ble_act_count_by_group = 0x3fcdfea4; +s_ble_coex_st_map = 0x3fcdfe90; +bt_rf_coex_cfg_cb = 0x3fcdfe74; +bt_rf_coex_cfg_p = 0x3fcdfe70; +bt_rf_coex_cfg_rom = 0x3ff4fc9c; +bt_rf_coex_pti_dft_p = 0x3fcdfe6c; +bt_rf_coex_pti_dft_rom = 0x3fcdfe04; +conn_dynamic_pti_param_rom = 0x3ff4fc84; +conn_phy_coded_max_data_time_param_rom = 0x3ff4fc80; +ext_adv_dynamic_pti_param_rom = 0x3ff4fc4c; +ext_scan_dynamic_param_rom = 0x3ff4fc14; +legacy_adv_dynamic_pti_param_rom = 0x3ff4fbf4; +per_adv_dynamic_pti_param_rom = 0x3ff4fbd8; +sync_dynamic_param_rom = 0x3ff4fbc0; +g_ble_plf_log_level = 0x3fcdfe00; +g_msys_pool_list = 0x3fcdfdf8; +g_os_mempool_list = 0x3fcdfdf0; diff --git a/components/esp_rom/esp32c2/ld/esp32c2.rom.eco4.ld b/components/esp_rom/esp32c2/ld/esp32c2.rom.eco4.ld new file mode 100644 index 0000000000..901e551e0f --- /dev/null +++ b/components/esp_rom/esp32c2/ld/esp32c2.rom.eco4.ld @@ -0,0 +1,220 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + + +/*************************************** + Group rom_pp + ***************************************/ + +/* Functions */ +esf_buf_alloc = 0x40001ae0; +esf_buf_alloc_dynamic = 0x40001ae4; +esf_buf_recycle = 0x40001ae8; +hal_mac_tx_set_ppdu = 0x40001af8; +ic_mac_deinit = 0x40001b00; +lmacAdjustTimestamp = 0x40001b10; +lmacDiscardMSDU = 0x40001b18; +lmacEndFrameExchangeSequence = 0x40001b1c; +lmacMSDUAged = 0x40001b28; +//lmacSetTxFrame = 0x40001b4c; +pm_check_state = 0x40001b6c; +pm_dream = 0x40001b78; +pm_on_beacon_rx = 0x40001ba0; +//pm_parse_beacon = 0x40001bac; +pm_process_tim = 0x40001bb0; +pm_rx_beacon_process = 0x40001bb4; +pm_rx_data_process = 0x40001bb8; +pm_sleep = 0x40001bbc; +//pm_tbtt_process = 0x40001bc4; +ppAssembleAMPDU = 0x40001bcc; +ppCalTxAMPDULength = 0x40001bd8; +ppRxFragmentProc = 0x40001c28; +ppRxPkt = 0x40001c2c; +pp_coex_tx_request = 0x40001c54; +rcGetSched = 0x40001c88; +rcTxUpdatePer = 0x40001c94; +rcUpdateRate = 0x40001c9c; +wDev_AppendRxBlocks = 0x40001cdc; +//wDev_IndicateFrame = 0x40001cec; +wDev_ProcessFiq = 0x40001d08; +wDev_ProcessRxSucData = 0x40001d0c; +ppProcTxDone = 0x40001d1c; +pm_tx_data_done_process = 0x40001d20; +ppMapWaitTxq = 0x40001d28; +lmacDiscardFrameExchangeSequence = 0x40001d70; +lmacDisableTransmit = 0x40001d74; +lmacProcessTxTimeout = 0x40001d78; +lmacProcessTxSuccess = 0x40001d7c; +lmacProcessTxComplete = 0x40001d8c; +lmacProcessTxopQComplete = 0x40001dc0; +lmacInit = 0x40001dc8; +hal_init = 0x40001dd0; +mac_txrx_init = 0x40001de0; +lmac_stop_hw_txq = 0x40001df8; +ppTxFragmentProc = 0x40001e08; +esf_buf_setup = 0x40001e0c; +hal_crypto_set_key_entry = 0x40001e18; +pm_start = 0x40001e34; +pm_stop = 0x40001e38; +hal_set_sta_tbtt = 0x40001e4c; +//pm_update_next_tbtt = 0x40001e50; +pm_set_sleep_type = 0x40001e54; +pm_tx_null_data_done_process = 0x40001eb0; +//pm_tx_data_process = 0x40001eb4; +/*pm_attach = 0x40001eb8;*/ +/*pm_coex_schm_process = 0x40001ebc;*/ +pm_on_probe_resp_rx = 0x40001ecc; +pm_send_probe_stop = 0x40001edc; +hal_sniffer_rx_set_promis = 0x40001ef4; +hal_sniffer_set_promis_misc_pkt = 0x40001efc; +tsf_hal_set_tbtt_start_time = 0x40001f38; + + +/*************************************** + Group rom_net80211 + ***************************************/ + +/* Functions */ +ieee80211_ampdu_reorder = 0x40001fb0; +ieee80211_encap_esfbuf = 0x40001fb8; +ieee80211_output_process = 0x40001fc4; +sta_input = 0x40001fcc; +ieee80211_classify = 0x40001fe0; +ieee80211_crypto_decap = 0x40001ff8; +ieee80211_ccmp_decrypt = 0x4000200c; +ieee80211_ccmp_encrypt = 0x40002010; +//ieee80211_send_action_vendor_spec = 0x40002034; +ieee80211_send_mgmt = 0x40002038; +//ieee80211_auth_construct = 0x4000203c; +ieee80211_deauth_construct = 0x40002040; +ieee80211_disassoc_construct = 0x40002044; +//ieee80211_add_xrates = 0x40002058; +//ieee80211_assoc_req_construct = 0x40002060; +ieee80211_assoc_resp_construct = 0x40002064; +//ieee80211_timer_process = 0x4000208c; +cnx_coexist_timeout = 0x40002090; +//sta_recv_mgmt = 0x40002094; +ieee80211_send_probereq = 0x4000209c; +//sta_auth_open = 0x400020a0; +//sta_auth_sae = 0x400020a8; +cnx_coexist_timeout_process = 0x400020ac; +ieee80211_add_extcap = 0x400020cc; +//ieee80211_alloc_proberesp = 0x400020d8; +esp_wifi_80211_tx = 0x400020f8; +ieee80211_crypto_aes_128_cmac_decrypt = 0x40002104; +ieee80211_output_do = 0x4000210c; +ieee80211_send_nulldata = 0x40002110; +//ieee80211_setup_robust_mgmtframe = 0x40002114; +//ieee80211_mgmt_output = 0x40002118; +//ieee80211_send_deauth_no_bss = 0x40002120; +//ieee80211_tx_mgt_cb = 0x4000212c; +//sta_rx_csa = 0x40002134; +sta_send_sa_query_req = 0x40002138; +sta_send_sa_query_resp = 0x4000213c; +sta_recv_sa_query_req = 0x40002140; +sta_recv_sa_query_resp = 0x40002144; +//ieee80211_parse_beacon = 0x40002148; +ieee80211_match_security = 0x40002154; +//ieee80211_parse_rsn = 0x4000215c; +/* Data (.data, .bss, .rodata) */ +s_sa_query_retries = 0x3fcdfad8; +s_sa_query_success = 0x3fcdfad5; +s_trans_id = 0x3fcdfac4; + + +/*************************************** + Group rom_coexist + ***************************************/ + +/* Functions */ +coex_core_event_duration_get = 0x40002178; +coex_core_timer_idx_get = 0x4000218c; +coex_hw_timer_tick_get = 0x400021b8; + + +/*************************************** + Group rom_phy + ***************************************/ + +/* Functions */ +phy_xpd_tsens = 0x400021e8; +bt_track_pll_cap = 0x40002534; +tx_pwctrl_background = 0x40002548; + + +/*************************************** + Group eco4_systimer_hal + ***************************************/ + +/* Functions */ +systimer_hal_init = 0x400002a8; +systimer_hal_get_time = 0x400002b0; +systimer_hal_set_alarm_target = 0x400002b4; +systimer_hal_set_alarm_period = 0x400002b8; +systimer_hal_counter_value_advance = 0x400002c8; +systimer_hal_deinit = 0x40002ea8; +systimer_hal_set_tick_rate_ops = 0x40002eac; + + +/*************************************** + Group eco4_rom_net80211 + ***************************************/ + +/* Functions */ +sta_reset_beacon_timeout = 0x40003024; +ieee80211_post_hmac_tx = 0x40003028; +sta_rx_eapol = 0x4000302c; +/* Data (.data, .bss, .rodata) */ +len_dh_ie_ptr = 0x3fcdfa6c; +g_authmode_threshold_failure_ptr = 0x3fcdfa68; + + +/*************************************** + Group eco4_rom_pp + ***************************************/ + +/* Functions */ +pm_enable_dream_timer = 0x40003030; +pm_handle_tbtt_interval = 0x40003034; +hal_set_sta_light_sleep_wake_ahead_time = 0x40003038; +hal_get_time_to_sta_next_tbtt = 0x4000303c; +pm_scale_listen_interval = 0x40003040; +pm_beacon_monitor_tbtt_start = 0x40003044; +pm_beacon_monitor_tbtt_stop = 0x40003048; +pm_beacon_monitor_timeout_process = 0x4000304c; +pm_beacon_monitor_tbtt_timeout_process = 0x40003050; +pm_on_tsf_timer = 0x40003054; +pp_coex_tx_release = 0x40003058; +ppRegressAmpdu = 0x4000305c; +trc_onPPTxDone = 0x40003060; +is_fragmented_pkt = 0x40003064; +pm_tx_null_data_done_quick_wake_process = 0x40003068; +pm_enable_beacon_monitor_timer = 0x4000306c; +pm_disable_beacon_monitor_timer = 0x40003070; +pm_beacon_offset_get_average = 0x40003074; +pm_beacon_offset_get_expect = 0x40003078; +pm_beacon_offset_get_params = 0x4000307c; +pm_beacon_offset_sample_start = 0x40003080; +pm_beacon_offset_sample = 0x40003084; +pm_beacon_offset_reset = 0x40003088; +pm_beacon_offset_is_sampling = 0x4000308c; +pm_beacon_offset_is_enabled = 0x40003090; +pm_beacon_offset_configure = 0x40003094; +pm_beacon_offset_resample_timeout_process = 0x40003098; +pm_beacon_offset_set_rx_beacon_standard = 0x4000309c; +pm_beacon_offset_get_rx_beacon_success_rate = 0x400030a0; +pm_beacon_offset_add_total_counter = 0x400030a4; +pm_beacon_offset_add_loss_counter = 0x400030a8; +pm_beacon_offset_check = 0x400030ac; +pm_beacon_offset_init = 0x400030b0; +pm_beacon_offset_deinit = 0x400030b4; +pm_get_tbtt_count = 0x400030b8; +pm_coex_schm_overall_period_get = 0x400030bc; +pm_coex_pwr_update = 0x400030c0; +/* Data (.data, .bss, .rodata) */ +s_pm_beacon_offset_ptr = 0x3fcdfa64; +s_pm_beacon_offset_config_ptr = 0x3fcdfa60; +s_tbttstart_ptr = 0x3fcdfa5c; diff --git a/components/esp_rom/esp32c2/ld/esp32c2.rom.ld b/components/esp_rom/esp32c2/ld/esp32c2.rom.ld index a010210258..26248f9d99 100644 --- a/components/esp_rom/esp32c2/ld/esp32c2.rom.ld +++ b/components/esp_rom/esp32c2/ld/esp32c2.rom.ld @@ -551,905 +551,6 @@ g_uart_print = 0x3fcdffc9; g_usb_print = 0x3fcdffc8; -/*************************************** - Group bluetooth - ***************************************/ - -/* Functions */ -ble_controller_rom_data_init = 0x40000aa8; -ble_osi_coex_funcs_register = 0x40000aac; -bt_rf_coex_cfg_get_default = 0x40000ab0; -bt_rf_coex_dft_pti_get_default = 0x40000ab4; -bt_rf_coex_hooks_p_set = 0x40000ab8; -r__os_mbuf_copypkthdr = 0x40000abc; -r_ble_controller_get_rom_compile_version = 0x40000ac4; -r_ble_hci_ram_reset = 0x40000ad8; -r_ble_hci_ram_set_acl_free_cb = 0x40000adc; -r_ble_hci_trans_acl_buf_alloc = 0x40000ae0; -r_ble_hci_trans_buf_alloc = 0x40000ae4; -r_ble_hci_trans_buf_free = 0x40000ae8; -r_ble_hci_trans_cfg_hs = 0x40000aec; -r_ble_hci_trans_cfg_ll = 0x40000af0; -r_ble_hci_trans_init = 0x40000afc; -r_ble_hci_uart_acl_tx = 0x40000b00; -r_ble_hci_uart_cmdevt_tx = 0x40000b04; -r_ble_hci_uart_config = 0x40000b08; -r_ble_hci_uart_free_pkt = 0x40000b0c; -r_ble_hci_uart_rx_acl = 0x40000b20; -r_ble_hci_uart_rx_char = 0x40000b24; -r_ble_hci_uart_rx_cmd = 0x40000b28; -r_ble_hci_uart_rx_evt = 0x40000b2c; -r_ble_hci_uart_rx_evt_cb = 0x40000b30; -r_ble_hci_uart_rx_le_evt = 0x40000b34; -r_ble_hci_uart_rx_pkt_type = 0x40000b38; -r_ble_hci_uart_rx_skip_acl = 0x40000b3c; -r_ble_hci_uart_rx_skip_cmd = 0x40000b40; -r_ble_hci_uart_rx_skip_evt = 0x40000b44; -r_ble_hci_uart_rx_sync_loss = 0x40000b48; -r_ble_hci_uart_set_acl_free_cb = 0x40000b4c; -r_ble_hci_uart_sync_lost = 0x40000b50; -r_ble_hci_uart_trans_reset = 0x40000b54; -r_ble_hci_uart_tx_char = 0x40000b58; -r_ble_hci_uart_tx_pkt_type = 0x40000b5c; -r_ble_hw_encrypt_block = 0x40000b68; -r_ble_hw_get_public_addr = 0x40000b6c; -r_ble_hw_get_static_addr = 0x40000b70; -r_ble_hw_periodiclist_add = 0x40000b74; -r_ble_hw_periodiclist_clear = 0x40000b78; -r_ble_hw_periodiclist_rmv = 0x40000b7c; -r_ble_hw_resolv_list_cur_entry = 0x40000b80; -r_ble_hw_resolv_list_set = 0x40000b88; -r_ble_hw_rng_init = 0x40000b8c; -r_ble_hw_rng_start = 0x40000b90; -r_ble_hw_rng_stop = 0x40000b94; -r_ble_hw_rx_local_is_resolved = 0x40000b98; -r_ble_hw_rx_local_is_rpa = 0x40000b9c; -r_ble_hw_whitelist_add = 0x40000ba0; -r_ble_hw_whitelist_dev_num = 0x40000ba8; -r_ble_hw_whitelist_get_base = 0x40000bac; -r_ble_hw_whitelist_search = 0x40000bb4; -r_ble_hw_whitelist_sort = 0x40000bb8; -r_ble_ll_acl_data_in = 0x40000bbc; -r_ble_ll_addr_is_id = 0x40000bc0; -r_ble_ll_addr_subtype = 0x40000bc4; -r_ble_ll_adv_active_chanset_clear = 0x40000bc8; -r_ble_ll_adv_active_chanset_is_pri = 0x40000bcc; -r_ble_ll_adv_active_chanset_is_sec = 0x40000bd0; -r_ble_ll_adv_active_chanset_set_pri = 0x40000bd4; -r_ble_ll_adv_active_chanset_set_sec = 0x40000bd8; -r_ble_ll_adv_aux_calculate = 0x40000bdc; -r_ble_ll_adv_aux_conn_rsp_pdu_make = 0x40000be0; -r_ble_ll_adv_aux_pdu_make = 0x40000be4; -r_ble_ll_adv_aux_scannable_pdu_make = 0x40000be8; -r_ble_ll_adv_aux_txed = 0x40000bec; -r_ble_ll_adv_can_chg_whitelist = 0x40000bf0; -r_ble_ll_adv_chk_rpa_timeout = 0x40000bf4; -r_ble_ll_adv_clear_all = 0x40000bf8; -r_ble_ll_adv_conn_req_rxd = 0x40000bfc; -r_ble_ll_adv_enabled = 0x40000c04; -r_ble_ll_adv_ext_set_adv_data = 0x40000c0c; -r_ble_ll_adv_ext_set_scan_rsp = 0x40000c18; -r_ble_ll_adv_final_chan = 0x40000c1c; -r_ble_ll_adv_first_chan = 0x40000c20; -r_ble_ll_adv_flags_clear = 0x40000c24; -r_ble_ll_adv_flags_set = 0x40000c28; -r_ble_ll_adv_get_chan_num = 0x40000c2c; -r_ble_ll_adv_get_local_rpa = 0x40000c30; -r_ble_ll_adv_get_peer_rpa = 0x40000c34; -r_ble_ll_adv_hci_set_random_addr = 0x40000c38; -r_ble_ll_adv_init = 0x40000c3c; -r_ble_ll_adv_next_chan = 0x40000c44; -r_ble_ll_adv_pdu_make = 0x40000c48; -r_ble_ll_adv_periodic_check_data_itvl = 0x40000c4c; -r_ble_ll_adv_periodic_estimate_data_itvl = 0x40000c54; -r_ble_ll_adv_periodic_send_sync_ind = 0x40000c58; -r_ble_ll_adv_periodic_set_info_transfer = 0x40000c60; -r_ble_ll_adv_periodic_set_param = 0x40000c64; -r_ble_ll_adv_pre_process = 0x40000c68; -r_ble_ll_adv_put_acad_chM_update_ind = 0x40000c6c; -r_ble_ll_adv_put_aux_ptr = 0x40000c70; -r_ble_ll_adv_put_syncinfo = 0x40000c74; -r_ble_ll_adv_rd_max_adv_data_len = 0x40000c78; -r_ble_ll_adv_rd_sup_adv_sets = 0x40000c7c; -r_ble_ll_adv_read_txpwr = 0x40000c80; -r_ble_ll_adv_rpa_timeout = 0x40000c8c; -r_ble_ll_adv_rpa_update = 0x40000c90; -r_ble_ll_adv_scan_req_rxd = 0x40000c98; -r_ble_ll_adv_scan_rsp_legacy_pdu_make = 0x40000c9c; -r_ble_ll_adv_scan_rsp_pdu_make = 0x40000ca0; -r_ble_ll_adv_scheduled = 0x40000ca4; -r_ble_ll_adv_set_random_addr = 0x40000cb8; -r_ble_ll_adv_sm_deinit = 0x40000cc4; -r_ble_ll_adv_sm_event_init = 0x40000cc8; -r_ble_ll_adv_sm_find_configured = 0x40000ccc; -r_ble_ll_adv_sm_get = 0x40000cd0; -r_ble_ll_adv_sm_reset = 0x40000cd8; -r_ble_ll_adv_sm_start = 0x40000cdc; -r_ble_ll_adv_sm_start_periodic = 0x40000ce0; -r_ble_ll_adv_sm_stop = 0x40000ce4; -r_ble_ll_adv_sm_stop_limit_reached = 0x40000ce8; -r_ble_ll_adv_sm_stop_periodic = 0x40000cec; -r_ble_ll_adv_sm_stop_timeout = 0x40000cf0; -r_ble_ll_adv_sync_get_pdu_len = 0x40000cf8; -r_ble_ll_adv_update_adv_scan_rsp_data = 0x40000d00; -r_ble_ll_adv_update_data_mbuf = 0x40000d04; -r_ble_ll_adv_update_did = 0x40000d08; -r_ble_ll_adv_update_periodic_data = 0x40000d0c; -r_ble_ll_auth_pyld_tmo_event_send = 0x40000d14; -r_ble_ll_calc_offset_ticks_us_for_rampup = 0x40000d18; -r_ble_ll_calc_session_key = 0x40000d1c; -r_ble_ll_calc_ticks_per_slot = 0x40000d20; -r_ble_ll_chk_txrx_octets = 0x40000d28; -r_ble_ll_chk_txrx_time = 0x40000d2c; -r_ble_ll_conn_adjust_pyld_len = 0x40000d30; -r_ble_ll_conn_auth_pyld_timer_cb = 0x40000d34; -r_ble_ll_conn_auth_pyld_timer_start = 0x40000d38; -r_ble_ll_conn_calc_dci = 0x40000d3c; -r_ble_ll_conn_calc_dci_csa1 = 0x40000d40; -r_ble_ll_conn_calc_itvl_ticks = 0x40000d44; -r_ble_ll_conn_chk_csm_flags = 0x40000d48; -r_ble_ll_conn_chk_phy_upd_start = 0x40000d4c; -r_ble_ll_conn_comp_event_send = 0x40000d50; -r_ble_ll_conn_create_cancel = 0x40000d5c; -r_ble_ll_conn_cth_flow_enable = 0x40000d64; -r_ble_ll_conn_cth_flow_error_fn = 0x40000d68; -r_ble_ll_conn_cth_flow_have_credit = 0x40000d6c; -r_ble_ll_conn_cth_flow_is_enabled = 0x40000d70; -r_ble_ll_conn_cth_flow_process_cmd = 0x40000d74; -r_ble_ll_conn_cth_flow_set_buffers = 0x40000d78; -r_ble_ll_conn_ext_master_init = 0x40000d84; -r_ble_ll_conn_find_active_conn = 0x40000d88; -r_ble_ll_conn_get_active_conn = 0x40000d8c; -r_ble_ll_conn_get_anchor = 0x40000d90; -r_ble_ll_conn_hcc_params_set_fallback = 0x40000d94; -r_ble_ll_conn_hci_cancel_conn_complete_event = 0x40000d98; -r_ble_ll_conn_hci_chk_conn_params = 0x40000d9c; -r_ble_ll_conn_hci_chk_scan_params = 0x40000da0; -r_ble_ll_conn_hci_disconnect_cmd = 0x40000da4; -r_ble_ll_conn_hci_le_ltk_neg_reply = 0x40000da8; -r_ble_ll_conn_hci_le_ltk_reply = 0x40000dac; -r_ble_ll_conn_hci_le_rd_phy = 0x40000db0; -r_ble_ll_conn_hci_le_start_encrypt = 0x40000db8; -r_ble_ll_conn_hci_param_nrr = 0x40000dbc; -r_ble_ll_conn_hci_param_rr = 0x40000dc0; -r_ble_ll_conn_hci_rd_auth_pyld_tmo = 0x40000dc4; -r_ble_ll_conn_hci_rd_chan_map = 0x40000dc8; -r_ble_ll_conn_hci_rd_rem_ver_cmd = 0x40000dcc; -r_ble_ll_conn_hci_rd_rssi = 0x40000dd0; -r_ble_ll_conn_hci_read_rem_features = 0x40000dd4; -r_ble_ll_conn_hci_set_data_len = 0x40000ddc; -r_ble_ll_conn_hci_update = 0x40000de0; -r_ble_ll_conn_hci_wr_auth_pyld_tmo = 0x40000de4; -r_ble_ll_conn_init_phy = 0x40000de8; -r_ble_ll_conn_is_empty_pdu = 0x40000df0; -r_ble_ll_conn_is_lru = 0x40000df4; -r_ble_ll_conn_master_init = 0x40000df8; -r_ble_ll_conn_module_reset = 0x40000e04; -r_ble_ll_conn_num_comp_pkts_event_send = 0x40000e0c; -r_ble_ll_conn_process_conn_params = 0x40000e14; -r_ble_ll_conn_req_peer_sca = 0x40000e18; -r_ble_ll_conn_set_csa = 0x40000e20; -r_ble_ll_conn_set_ext_con_params = 0x40000e24; -r_ble_ll_conn_set_global_chanmap = 0x40000e28; -r_ble_ll_conn_set_phy = 0x40000e2c; -r_ble_ll_conn_set_txpwr_by_handle = 0x40000e30; -r_ble_ll_conn_set_unknown_rx_octets = 0x40000e34; -r_ble_ll_conn_sm_get = 0x40000e3c; -r_ble_ll_conn_tx_pkt_in = 0x40000e4c; -r_ble_ll_conn_update_eff_data_len = 0x40000e50; -r_ble_ll_ctrl_chanmap_req_make = 0x40000e54; -r_ble_ll_ctrl_conn_param_pdu_make = 0x40000e5c; -r_ble_ll_ctrl_conn_param_pdu_proc = 0x40000e60; -r_ble_ll_ctrl_conn_param_reply = 0x40000e64; -r_ble_ll_ctrl_datalen_upd_make = 0x40000e6c; -r_ble_ll_ctrl_enc_allowed_pdu = 0x40000e70; -r_ble_ll_ctrl_enc_allowed_pdu_rx = 0x40000e74; -r_ble_ll_ctrl_enc_req_make = 0x40000e7c; -r_ble_ll_ctrl_find_new_phy = 0x40000e80; -r_ble_ll_ctrl_initiate_dle = 0x40000e84; -r_ble_ll_ctrl_len_proc = 0x40000e88; -r_ble_ll_ctrl_min_used_chan_rsp = 0x40000e8c; -r_ble_ll_ctrl_phy_from_phy_mask = 0x40000e90; -r_ble_ll_ctrl_phy_req_rsp_make = 0x40000e94; -r_ble_ll_ctrl_phy_tx_transition_get = 0x40000e98; -r_ble_ll_ctrl_phy_update_cancel = 0x40000e9c; -r_ble_ll_ctrl_phy_update_ind_make = 0x40000ea0; -r_ble_ll_ctrl_phy_update_proc_complete = 0x40000ea4; -r_ble_ll_ctrl_proc_rsp_timer_cb = 0x40000eac; -r_ble_ll_ctrl_proc_stop = 0x40000eb4; -r_ble_ll_ctrl_proc_with_instant_initiated = 0x40000ebc; -r_ble_ll_ctrl_rej_ext_ind_make = 0x40000ec0; -r_ble_ll_ctrl_reject_ind_send = 0x40000ec4; -r_ble_ll_ctrl_rx_chanmap_req = 0x40000ec8; -r_ble_ll_ctrl_rx_conn_param_req = 0x40000ecc; -r_ble_ll_ctrl_rx_enc_req = 0x40000ed8; -r_ble_ll_ctrl_rx_enc_rsp = 0x40000edc; -r_ble_ll_ctrl_rx_feature_req = 0x40000ee0; -r_ble_ll_ctrl_rx_pause_enc_req = 0x40000ee8; -r_ble_ll_ctrl_rx_pause_enc_rsp = 0x40000eec; -r_ble_ll_ctrl_rx_periodic_sync_ind = 0x40000ef4; -r_ble_ll_ctrl_rx_phy_req = 0x40000ef8; -r_ble_ll_ctrl_rx_phy_rsp = 0x40000efc; -r_ble_ll_ctrl_rx_phy_update_ind = 0x40000f00; -r_ble_ll_ctrl_rx_ping_rsp = 0x40000f04; -r_ble_ll_ctrl_rx_reject_ind = 0x40000f08; -r_ble_ll_ctrl_rx_sca_req = 0x40000f0c; -r_ble_ll_ctrl_rx_sca_rsp = 0x40000f10; -r_ble_ll_ctrl_rx_start_enc_req = 0x40000f14; -r_ble_ll_ctrl_rx_start_enc_rsp = 0x40000f18; -r_ble_ll_ctrl_rx_version_ind = 0x40000f1c; -r_ble_ll_ctrl_sca_req_rsp_make = 0x40000f20; -r_ble_ll_ctrl_start_enc_send = 0x40000f24; -r_ble_ll_ctrl_start_rsp_timer = 0x40000f28; -r_ble_ll_ctrl_terminate_start = 0x40000f2c; -r_ble_ll_ctrl_update_features = 0x40000f34; -r_ble_ll_ctrl_version_ind_make = 0x40000f38; -r_ble_ll_data_buffer_overflow = 0x40000f3c; -r_ble_ll_disconn_comp_event_send = 0x40000f44; -r_ble_ll_event_comp_pkts = 0x40000f4c; -r_ble_ll_event_dbuf_overflow = 0x40000f50; -r_ble_ll_event_send = 0x40000f54; -r_ble_ll_event_tx_pkt = 0x40000f58; -r_ble_ll_ext_adv_phy_mode_to_local_phy = 0x40000f5c; -r_ble_ll_ext_scan_parse_adv_info = 0x40000f64; -r_ble_ll_ext_scan_parse_aux_ptr = 0x40000f68; -r_ble_ll_flush_pkt_queue = 0x40000f6c; -r_ble_ll_generate_dh_key_v1 = 0x40000f70; -r_ble_ll_generate_dh_key_v2 = 0x40000f74; -r_ble_ll_get_addr_type = 0x40000f7c; -r_ble_ll_get_our_devaddr = 0x40000f84; -r_ble_ll_get_tx_pwr_compensation = 0x40000f88; -r_ble_ll_hci_acl_rx = 0x40000f8c; -r_ble_ll_hci_adv_mode_ext = 0x40000f90; -r_ble_ll_hci_adv_set_enable = 0x40000f94; -r_ble_ll_hci_cb_set_ctrlr_to_host_fc = 0x40000f9c; -r_ble_ll_hci_cb_set_event_mask = 0x40000fa0; -r_ble_ll_hci_cb_set_event_mask2 = 0x40000fa4; -r_ble_ll_hci_chk_phy_masks = 0x40000fa8; -r_ble_ll_hci_cmd_rx = 0x40000fb0; -r_ble_ll_hci_disconnect = 0x40000fbc; -r_ble_ll_hci_ev_conn_update = 0x40000fc4; -r_ble_ll_hci_ev_databuf_overflow = 0x40000fc8; -r_ble_ll_hci_ev_datalen_chg = 0x40000fcc; -r_ble_ll_hci_ev_encrypt_chg = 0x40000fd0; -r_ble_ll_hci_ev_hw_err = 0x40000fd4; -r_ble_ll_hci_ev_le_csa = 0x40000fd8; -r_ble_ll_hci_ev_ltk_req = 0x40000fdc; -r_ble_ll_hci_ev_phy_update = 0x40000fe0; -r_ble_ll_hci_ev_rd_rem_used_feat = 0x40000fe4; -r_ble_ll_hci_ev_rd_rem_ver = 0x40000fe8; -r_ble_ll_hci_ev_rem_conn_parm_req = 0x40000fec; -r_ble_ll_hci_ev_sca_update = 0x40000ff0; -r_ble_ll_hci_ev_send_adv_set_terminated = 0x40000ff4; -r_ble_ll_hci_ev_send_scan_req_recv = 0x40000ff8; -r_ble_ll_hci_ev_send_scan_timeout = 0x40000ffc; -r_ble_ll_hci_ev_send_vendor_err = 0x40001000; -r_ble_ll_hci_ext_scan_set_enable = 0x40001008; -r_ble_ll_hci_get_num_cmd_pkts = 0x4000100c; -r_ble_ll_hci_info_params_cmd_proc = 0x40001010; -r_ble_ll_hci_init = 0x40001014; -r_ble_ll_hci_init_support_cmd_base_on_lmp_ver = 0x40001018; -r_ble_ll_hci_is_event_enabled = 0x4000101c; -r_ble_ll_hci_is_le_event_enabled = 0x40001020; -r_ble_ll_hci_le_cmd_send_cmd_status = 0x40001028; -r_ble_ll_hci_le_encrypt = 0x4000102c; -r_ble_ll_hci_le_rand = 0x40001030; -r_ble_ll_hci_le_rd_max_data_len = 0x40001034; -r_ble_ll_hci_le_rd_sugg_data_len = 0x40001038; -r_ble_ll_hci_le_read_bufsize = 0x4000103c; -r_ble_ll_hci_le_read_supp_states = 0x40001044; -r_ble_ll_hci_le_set_def_phy = 0x40001048; -r_ble_ll_hci_le_wr_sugg_data_len = 0x4000104c; -r_ble_ll_hci_link_ctrl_cmd_proc = 0x40001050; -r_ble_ll_hci_npl_init = 0x40001054; -r_ble_ll_hci_post_gen_dhkey_cmp_evt = 0x40001058; -r_ble_ll_hci_post_rd_p256_pubkey_cmp_evt = 0x4000105c; -r_ble_ll_hci_rd_bd_addr = 0x40001060; -r_ble_ll_hci_rd_local_supp_cmd = 0x40001064; -r_ble_ll_hci_rd_local_supp_feat = 0x40001068; -r_ble_ll_hci_rd_local_version = 0x4000106c; -r_ble_ll_hci_scan_set_enable = 0x40001070; -r_ble_ll_hci_send_adv_report = 0x40001074; -r_ble_ll_hci_send_dir_adv_report = 0x40001078; -r_ble_ll_hci_send_noop = 0x40001084; -r_ble_ll_hci_set_adv_data = 0x40001088; -r_ble_ll_hci_set_le_event_mask = 0x4000108c; -r_ble_ll_hci_set_scan_rsp_data = 0x40001090; -r_ble_ll_hci_status_params_cmd_proc = 0x40001094; -r_ble_ll_hci_vs_cmd_proc = 0x40001098; -r_ble_ll_hci_vs_rd_static_addr = 0x4000109c; -r_ble_ll_hw_err_timer_cb = 0x400010a0; -r_ble_ll_hw_error = 0x400010a4; -r_ble_ll_init_alloc_conn_comp_ev = 0x400010ac; -r_ble_ll_init_get_conn_comp_ev = 0x400010b0; -r_ble_ll_is_addr_empty = 0x400010b8; -r_ble_ll_is_controller_busy = 0x400010bc; -r_ble_ll_is_on_resolv_list = 0x400010c0; -r_ble_ll_is_our_devaddr = 0x400010c4; -r_ble_ll_is_rpa = 0x400010c8; -r_ble_ll_is_valid_adv_mode = 0x400010cc; -r_ble_ll_is_valid_own_addr_type = 0x400010d0; -r_ble_ll_is_valid_public_addr = 0x400010d4; -r_ble_ll_is_valid_random_addr = 0x400010d8; -r_ble_ll_misc_options_set = 0x400010e0; -r_ble_ll_modify_sca = 0x400010e4; -r_ble_ll_pdu_max_tx_octets_get = 0x400010ec; -r_ble_ll_pdu_tx_time_get = 0x400010f0; -r_ble_ll_phy_to_phy_mode = 0x400010f4; -r_ble_ll_qa_enable = 0x400010f8; -r_ble_ll_rand_data_get = 0x40001100; -r_ble_ll_rand_init = 0x4000110c; -r_ble_ll_rand_prand_get = 0x40001110; -r_ble_ll_rand_sample = 0x40001114; -r_ble_ll_rand_start = 0x40001118; -r_ble_ll_read_local_p256_pub_key = 0x4000111c; -r_ble_ll_read_rf_path_compensation = 0x40001120; -r_ble_ll_read_supp_features = 0x40001124; -r_ble_ll_read_supp_states = 0x40001128; -r_ble_ll_resolv_clear_all_pl_bit = 0x40001134; -r_ble_ll_resolv_clear_all_wl_bit = 0x40001138; -r_ble_ll_resolv_enable_cmd = 0x40001140; -r_ble_ll_resolv_enabled = 0x40001144; -r_ble_ll_resolv_gen_rpa = 0x40001150; -r_ble_ll_resolv_get_addr_pointer = 0x40001154; -r_ble_ll_resolv_get_index = 0x40001158; -r_ble_ll_resolv_get_irk_pointer = 0x4000115c; -r_ble_ll_resolv_get_list = 0x40001160; -r_ble_ll_resolv_get_priv_addr = 0x40001164; -r_ble_ll_resolv_get_rpa_tmo = 0x40001168; -r_ble_ll_resolv_irk_nonzero = 0x40001170; -r_ble_ll_resolv_list_add = 0x40001174; -r_ble_ll_resolv_list_chg_allowed = 0x40001178; -r_ble_ll_resolv_list_clr = 0x4000117c; -r_ble_ll_resolv_list_find = 0x40001180; -r_ble_ll_resolv_list_read_size = 0x40001184; -r_ble_ll_resolv_list_reset = 0x40001188; -r_ble_ll_resolv_local_addr_rd = 0x40001190; -r_ble_ll_resolv_peer_addr_rd = 0x40001194; -r_ble_ll_resolv_peer_rpa_any = 0x40001198; -r_ble_ll_resolv_reset = 0x4000119c; -r_ble_ll_resolv_rpa = 0x400011a0; -r_ble_ll_resolv_rpa_timer_cb = 0x400011a4; -r_ble_ll_resolv_set_local_rpa = 0x400011a8; -r_ble_ll_resolv_set_peer_rpa = 0x400011ac; -r_ble_ll_resolv_set_rpa_tmo = 0x400011b0; -r_ble_ll_resolve_set_priv_mode = 0x400011b4; -r_ble_ll_rxpdu_alloc = 0x400011b8; -r_ble_ll_scan_add_scan_rsp_adv = 0x400011bc; -r_ble_ll_scan_adv_decode_addr = 0x400011c0; -r_ble_ll_scan_aux_data_ref = 0x400011c4; -r_ble_ll_scan_aux_data_unref = 0x400011c8; -r_ble_ll_scan_can_chg_whitelist = 0x400011cc; -r_ble_ll_scan_check_periodic_sync = 0x400011d0; -r_ble_ll_scan_classify_filter_aux_init = 0x400011d4; -r_ble_ll_scan_classify_filter_init = 0x400011d8; -r_ble_ll_scan_common_init = 0x400011dc; -r_ble_ll_scan_continue_en = 0x400011e0; -r_ble_ll_scan_dup_check_ext = 0x400011e8; -r_ble_ll_scan_dup_check_legacy = 0x400011ec; -r_ble_ll_scan_dup_move_to_head = 0x400011f0; -r_ble_ll_scan_dup_new = 0x400011f4; -r_ble_ll_scan_dup_update_ext = 0x400011f8; -r_ble_ll_scan_dup_update_legacy = 0x400011fc; -r_ble_ll_scan_enabled = 0x40001200; -r_ble_ll_scan_end_adv_evt = 0x40001204; -r_ble_ll_scan_ext_initiator_start = 0x4000120c; -r_ble_ll_scan_get_addr_data_from_legacy = 0x40001210; -r_ble_ll_scan_get_addr_from_ext_adv = 0x40001214; -r_ble_ll_scan_get_cur_sm = 0x40001218; -r_ble_ll_scan_get_ext_adv_report = 0x4000121c; -r_ble_ll_scan_get_local_rpa = 0x40001220; -r_ble_ll_scan_get_next_adv_prim_chan = 0x40001224; -r_ble_ll_scan_get_peer_rpa = 0x40001228; -r_ble_ll_scan_have_rxd_scan_rsp = 0x4000122c; -r_ble_ll_scan_initiator_start = 0x40001234; -r_ble_ll_scan_is_inside_window = 0x40001238; -r_ble_ll_scan_move_window_to = 0x4000123c; -r_ble_ll_scan_npl_reset = 0x40001240; -r_ble_ll_scan_parse_auxptr = 0x40001244; -r_ble_ll_scan_parse_ext_hdr = 0x40001248; -r_ble_ll_scan_record_new_adv = 0x40001250; -r_ble_ll_scan_refresh_nrpa = 0x40001254; -r_ble_ll_scan_reset = 0x40001258; -r_ble_ll_scan_rx_pkt_in = 0x4000125c; -r_ble_ll_scan_rx_pkt_in_restore_addr_data = 0x40001268; -r_ble_ll_scan_rxed = 0x4000126c; -r_ble_ll_scan_send_truncated = 0x40001274; -r_ble_ll_scan_set_peer_rpa = 0x4000127c; -r_ble_ll_scan_set_perfer_addr = 0x40001280; -r_ble_ll_scan_sm_start = 0x40001288; -r_ble_ll_scan_sm_stop = 0x4000128c; -r_ble_ll_scan_time_hci_to_ticks = 0x40001290; -r_ble_ll_scan_update_aux_data = 0x40001294; -r_ble_ll_scan_whitelist_enabled = 0x40001298; -r_ble_ll_set_default_privacy_mode = 0x4000129c; -r_ble_ll_set_default_sync_transfer_params = 0x400012a0; -r_ble_ll_set_public_addr = 0x400012ac; -r_ble_ll_set_random_addr = 0x400012b0; -r_ble_ll_set_sync_transfer_params = 0x400012b4; -r_ble_ll_state_get = 0x400012b8; -r_ble_ll_state_set = 0x400012bc; -r_ble_ll_sync_adjust_ext_hdr = 0x400012c0; -r_ble_ll_sync_cancel = 0x400012c4; -r_ble_ll_sync_cancel_complete_event = 0x400012c8; -r_ble_ll_sync_check_acad = 0x400012cc; -r_ble_ll_sync_check_failed = 0x400012d0; -r_ble_ll_sync_enabled = 0x400012dc; -r_ble_ll_sync_established = 0x400012ec; -r_ble_ll_sync_filter_enabled = 0x400012f0; -r_ble_ll_sync_find = 0x400012f4; -r_ble_ll_sync_get_cur_sm = 0x400012f8; -r_ble_ll_sync_get_handle = 0x400012fc; -r_ble_ll_sync_get_sm = 0x40001300; -r_ble_ll_sync_info_event = 0x40001304; -r_ble_ll_sync_init = 0x40001308; -r_ble_ll_sync_list_add = 0x4000130c; -r_ble_ll_sync_list_clear = 0x40001310; -r_ble_ll_sync_list_empty = 0x40001314; -r_ble_ll_sync_list_get_free = 0x40001318; -r_ble_ll_sync_list_remove = 0x4000131c; -r_ble_ll_sync_list_search = 0x40001320; -r_ble_ll_sync_list_size = 0x40001324; -r_ble_ll_sync_lost_event = 0x40001328; -r_ble_ll_sync_next_event = 0x4000132c; -r_ble_ll_sync_on_list = 0x40001330; -r_ble_ll_sync_periodic_ind = 0x40001338; -r_ble_ll_sync_phy_mode_to_aux_phy = 0x4000133c; -r_ble_ll_sync_phy_mode_to_hci = 0x40001340; -r_ble_ll_sync_reserve = 0x4000134c; -r_ble_ll_sync_reset = 0x40001350; -r_ble_ll_sync_reset_sm = 0x40001354; -r_ble_ll_sync_send_per_adv_rpt = 0x4000135c; -r_ble_ll_sync_send_sync_ind = 0x40001360; -r_ble_ll_sync_send_truncated_per_adv_rpt = 0x40001364; -r_ble_ll_sync_sm_clear = 0x40001368; -r_ble_ll_sync_terminate = 0x4000136c; -r_ble_ll_sync_transfer = 0x40001370; -r_ble_ll_sync_transfer_get = 0x40001374; -r_ble_ll_sync_transfer_received = 0x40001378; -r_ble_ll_trace_u32 = 0x40001384; -r_ble_ll_trace_u32x2 = 0x40001388; -r_ble_ll_trace_u32x3 = 0x4000138c; -r_ble_ll_tx_flat_mbuf_pducb = 0x40001390; -r_ble_ll_update_max_tx_octets_phy_mode = 0x4000139c; -r_ble_ll_usecs_to_ticks_round_up = 0x400013a0; -r_ble_ll_utils_calc_access_addr = 0x400013a4; -r_ble_ll_utils_calc_dci_csa2 = 0x400013a8; -r_ble_ll_utils_calc_num_used_chans = 0x400013ac; -r_ble_ll_utils_calc_window_widening = 0x400013b0; -r_ble_ll_utils_csa2_perm = 0x400013b4; -r_ble_ll_utils_csa2_prng = 0x400013b8; -r_ble_ll_utils_remapped_channel = 0x400013bc; -r_ble_ll_whitelist_add = 0x400013c0; -r_ble_ll_whitelist_chg_allowed = 0x400013c4; -r_ble_ll_whitelist_read_size = 0x400013cc; -r_ble_ll_write_rf_path_compensation = 0x400013d8; -r_ble_lll_adv_aux_schedule = 0x400013e0; -r_ble_lll_adv_aux_schedule_first = 0x400013e4; -r_ble_lll_adv_aux_schedule_next = 0x400013e8; -r_ble_lll_adv_aux_scheduled = 0x400013ec; -r_ble_lll_adv_aux_set_start_time = 0x400013f0; -r_ble_lll_adv_coex_dpc_calc_pti_update_itvl = 0x400013f4; -r_ble_lll_adv_coex_dpc_process_pri = 0x400013f8; -r_ble_lll_adv_coex_dpc_process_sec = 0x400013fc; -r_ble_lll_adv_coex_dpc_pti_get = 0x40001400; -r_ble_lll_adv_coex_dpc_update = 0x40001404; -r_ble_lll_adv_coex_dpc_update_on_adv_start = 0x40001408; -r_ble_lll_adv_coex_dpc_update_on_aux_scheduled = 0x4000140c; -r_ble_lll_adv_coex_dpc_update_on_data_updated = 0x40001410; -r_ble_lll_adv_coex_dpc_update_on_event_end = 0x40001414; -r_ble_lll_adv_coex_dpc_update_on_event_scheduled = 0x40001418; -r_ble_lll_adv_done = 0x4000141c; -r_ble_lll_adv_event_done = 0x40001424; -r_ble_lll_adv_event_rmvd_from_sched = 0x40001428; -r_ble_lll_adv_get_sec_pdu_len = 0x40001430; -r_ble_lll_adv_make_done = 0x40001438; -r_ble_lll_adv_periodic_done = 0x4000143c; -r_ble_lll_adv_periodic_event_done = 0x40001440; -r_ble_lll_adv_periodic_rmvd_from_sched = 0x40001444; -r_ble_lll_adv_periodic_schedule_first = 0x40001448; -r_ble_lll_adv_pri_schedule_tx_pdu = 0x40001458; -r_ble_lll_adv_reschedule_event = 0x4000145c; -r_ble_lll_adv_reschedule_periodic_event = 0x40001460; -r_ble_lll_adv_sec_event_done = 0x4000146c; -r_ble_lll_adv_sec_schedule_next_aux = 0x40001470; -r_ble_lll_adv_secondary_tx_start_cb = 0x40001474; -r_ble_lll_adv_sm_deinit = 0x40001478; -r_ble_lll_adv_sm_event_init = 0x4000147c; -r_ble_lll_adv_sm_event_restore = 0x40001480; -r_ble_lll_adv_sm_event_store = 0x40001484; -r_ble_lll_adv_sm_init = 0x40001488; -r_ble_lll_adv_sm_reset = 0x4000148c; -r_ble_lll_adv_start = 0x40001490; -r_ble_lll_adv_stop = 0x40001494; -r_ble_lll_adv_sync_next_scheduled = 0x40001498; -r_ble_lll_adv_sync_schedule = 0x4000149c; -r_ble_lll_adv_sync_tx_done = 0x400014a0; -r_ble_lll_adv_sync_tx_end = 0x400014a4; -r_ble_lll_adv_sync_tx_start_cb = 0x400014a8; -r_ble_lll_adv_tx_done = 0x400014ac; -r_ble_lll_adv_tx_start_cb = 0x400014b0; -r_ble_lll_adv_update_rsp_offset = 0x400014b4; -r_ble_lll_aux_scan_cb = 0x400014b8; -r_ble_lll_aux_scan_drop = 0x400014bc; -r_ble_lll_aux_scan_drop_event_cb = 0x400014c0; -r_ble_lll_calc_us_convert_tick_unit = 0x400014c4; -r_ble_lll_conn_can_send_next_pdu = 0x400014cc; -r_ble_lll_conn_check_opcode_matched = 0x400014d0; -r_ble_lll_conn_coex_dpc_process = 0x400014d4; -r_ble_lll_conn_coex_dpc_pti_get = 0x400014d8; -r_ble_lll_conn_coex_dpc_update = 0x400014dc; -r_ble_lll_conn_coex_dpc_update_on_event_end = 0x400014e0; -r_ble_lll_conn_coex_dpc_update_on_event_scheduled = 0x400014e4; -r_ble_lll_conn_coex_dpc_update_on_event_started = 0x400014e8; -r_ble_lll_conn_cth_flow_alloc_credit = 0x400014ec; -r_ble_lll_conn_current_sm_over = 0x400014f4; -r_ble_lll_conn_event_is_over = 0x40001510; -r_ble_lll_conn_event_start_cb = 0x40001514; -r_ble_lll_conn_free_rx_mbuf = 0x40001518; -r_ble_lll_conn_get_addr_info_from_rx_buf = 0x4000151c; -r_ble_lll_conn_get_ce_end_time = 0x40001520; -r_ble_lll_conn_get_next_sched_time = 0x40001524; -r_ble_lll_conn_master_common_init = 0x40001530; -r_ble_lll_conn_master_new = 0x40001534; -r_ble_lll_conn_module_reset = 0x40001540; -r_ble_lll_conn_pre_process = 0x40001548; -r_ble_lll_conn_recv_ack = 0x40001554; -r_ble_lll_conn_recv_valid_packet = 0x40001558; -r_ble_lll_conn_reset_pending_sched = 0x4000155c; -r_ble_lll_conn_sched_next_anchor = 0x40001564; -r_ble_lll_conn_sched_next_event = 0x40001568; -r_ble_lll_conn_sm_new = 0x40001574; -r_ble_lll_conn_sm_npl_deinit = 0x40001578; -r_ble_lll_conn_sm_npl_init = 0x4000157c; -r_ble_lll_conn_superversion_timer_cb = 0x40001580; -r_ble_lll_conn_timeout = 0x40001584; -r_ble_lll_conn_update_anchor = 0x40001588; -r_ble_lll_conn_update_conn_ind_params = 0x4000158c; -r_ble_lll_conn_update_tx_buffer = 0x40001594; -r_ble_lll_deinit = 0x40001598; -r_ble_lll_dtm_calculate_itvl = 0x4000159c; -r_ble_lll_dtm_ctx_free = 0x400015a0; -r_ble_lll_dtm_end_test = 0x400015a8; -r_ble_lll_dtm_ev_rx_restart_cb = 0x400015ac; -r_ble_lll_dtm_ev_tx_resched_cb = 0x400015b0; -r_ble_lll_dtm_reset = 0x400015b8; -r_ble_lll_dtm_rx_create_ctx = 0x400015bc; -r_ble_lll_dtm_rx_isr_end = 0x400015c0; -r_ble_lll_dtm_rx_isr_start = 0x400015c4; -r_ble_lll_dtm_rx_pkt_in = 0x400015c8; -r_ble_lll_dtm_rx_sched_cb = 0x400015cc; -r_ble_lll_dtm_rx_start = 0x400015d0; -r_ble_lll_dtm_rx_test = 0x400015d4; -r_ble_lll_dtm_set_next = 0x400015d8; -r_ble_lll_dtm_tx_done = 0x400015e0; -r_ble_lll_dtm_tx_sched_cb = 0x400015e4; -r_ble_lll_dtm_tx_test = 0x400015e8; -r_ble_lll_dtm_wfr_timer_exp = 0x400015ec; -r_ble_lll_event_rx_pkt = 0x400015f0; -r_ble_lll_ext_scan_coex_dpc_process = 0x400015f4; -r_ble_lll_ext_scan_coex_dpc_pti_get = 0x400015f8; -r_ble_lll_ext_scan_coex_dpc_update = 0x400015fc; -r_ble_lll_ext_scan_coex_dpc_update_on_start = 0x40001600; -r_ble_lll_hci_dtm_rx_test = 0x40001604; -r_ble_lll_hci_dtm_rx_test_v2 = 0x40001608; -r_ble_lll_hci_dtm_tx_test = 0x4000160c; -r_ble_lll_hci_dtm_tx_test_ext = 0x40001610; -r_ble_lll_hci_dtm_tx_test_v2 = 0x40001614; -r_ble_lll_hci_dtm_tx_test_v2_ext = 0x40001618; -r_ble_lll_init = 0x4000161c; -r_ble_lll_init_pre_process = 0x40001620; -r_ble_lll_per_adv_coex_dpc_calc_pti_update_itvl = 0x40001628; -r_ble_lll_per_adv_coex_dpc_process = 0x4000162c; -r_ble_lll_per_adv_coex_dpc_pti_get = 0x40001630; -r_ble_lll_per_adv_coex_dpc_update = 0x40001634; -r_ble_lll_per_adv_coex_dpc_update_on_data_updated = 0x40001638; -r_ble_lll_per_adv_coex_dpc_update_on_scheduled = 0x4000163c; -r_ble_lll_per_adv_coex_dpc_update_on_start = 0x40001640; -r_ble_lll_rfmgmt_is_enabled = 0x40001660; -r_ble_lll_rfmgmt_release = 0x40001664; -r_ble_lll_rfmgmt_scan_changed = 0x40001670; -r_ble_lll_rfmgmt_sched_changed = 0x40001674; -r_ble_lll_rfmgmt_set_sleep_cb = 0x40001678; -r_ble_lll_rfmgmt_ticks_to_enabled = 0x4000167c; -r_ble_lll_rx_pdu_in = 0x40001688; -r_ble_lll_rx_pkt_in = 0x4000168c; -r_ble_lll_rx_pkt_isr = 0x40001690; -r_ble_lll_scan_abort_aux_sched = 0x40001694; -r_ble_lll_scan_chk_resume = 0x4000169c; -r_ble_lll_scan_clean_cur_aux_data = 0x400016a0; -r_ble_lll_scan_coex_event_cb = 0x400016a4; -r_ble_lll_scan_common_init = 0x400016a8; -r_ble_lll_scan_deinit = 0x400016ac; -r_ble_lll_scan_duration_period_timers_restart = 0x400016b0; -r_ble_lll_scan_duration_period_timers_stop = 0x400016b4; -r_ble_lll_scan_duration_timer_cb = 0x400016b8; -r_ble_lll_scan_event_proc = 0x400016bc; -r_ble_lll_scan_ext_adv_init = 0x400016c0; -r_ble_lll_scan_has_sent_scan_req = 0x400016c8; -r_ble_lll_scan_npl_reset = 0x400016d4; -r_ble_lll_scan_npl_restore = 0x400016d8; -r_ble_lll_scan_npl_store = 0x400016dc; -r_ble_lll_scan_period_timer_cb = 0x400016e0; -r_ble_lll_scan_process_adv_in_isr = 0x400016e4; -r_ble_lll_scan_req_backoff = 0x400016ec; -r_ble_lll_scan_sched_next_aux = 0x40001700; -r_ble_lll_scan_sched_remove = 0x40001704; -r_ble_lll_scan_start = 0x40001708; -r_ble_lll_scan_start_rx = 0x4000170c; -r_ble_lll_scan_timer_cb = 0x40001718; -r_ble_lll_sched_adv_new = 0x4000171c; -r_ble_lll_sched_adv_resched_pdu = 0x40001720; -r_ble_lll_sched_adv_reschedule = 0x40001724; -r_ble_lll_sched_aux_scan = 0x40001728; -r_ble_lll_sched_conn_overlap = 0x4000172c; -r_ble_lll_sched_dtm = 0x40001738; -r_ble_lll_sched_execute_item = 0x40001744; -r_ble_lll_sched_insert_if_empty = 0x4000174c; -r_ble_lll_sched_is_overlap = 0x40001750; -r_ble_lll_sched_master_new = 0x40001754; -r_ble_lll_sched_next_time = 0x40001758; -r_ble_lll_sched_overlaps_current = 0x4000175c; -r_ble_lll_sched_periodic_adv = 0x40001760; -r_ble_lll_sched_rmv_elem = 0x40001764; -r_ble_lll_sched_rmv_elem_type = 0x40001768; -r_ble_lll_sched_run = 0x4000176c; -r_ble_lll_sched_scan_req_over_aux_ptr = 0x40001770; -r_ble_lll_sched_slave_new = 0x40001774; -r_ble_lll_sched_stop = 0x40001778; -r_ble_lll_sched_sync = 0x4000177c; -r_ble_lll_sched_sync_overlaps_current = 0x40001780; -r_ble_lll_sync_chain_start_cb = 0x40001788; -r_ble_lll_sync_coex_dpc_process = 0x4000178c; -r_ble_lll_sync_coex_dpc_pti_get = 0x40001790; -r_ble_lll_sync_coex_dpc_update = 0x40001794; -r_ble_lll_sync_current_sm_over = 0x40001798; -r_ble_lll_sync_deinit = 0x4000179c; -r_ble_lll_sync_event_end_cb = 0x400017a4; -r_ble_lll_sync_get_event_end_time = 0x400017ac; -r_ble_lll_sync_init = 0x400017b4; -r_ble_lll_sync_new = 0x400017b8; -r_ble_lll_sync_reset = 0x400017bc; -r_ble_lll_sync_reset_sm = 0x400017c0; -r_ble_lll_sync_rmvd_from_sched = 0x400017c4; -r_ble_lll_sync_schedule_chain = 0x400017cc; -r_ble_lll_sync_stop = 0x400017d0; -r_ble_lll_sync_trnasfer_sched = 0x400017d4; -r_ble_phy_access_addr_get = 0x400017d8; -r_ble_phy_calculate_rxtx_ifs = 0x400017dc; -r_ble_phy_calculate_rxwindow = 0x400017e0; -r_ble_phy_calculate_txrx_ifs = 0x400017e4; -r_ble_phy_check_bb_status = 0x400017e8; -r_ble_phy_complete_rx_info = 0x400017ec; -r_ble_phy_data_make = 0x400017f4; -r_ble_phy_disable = 0x400017f8; -r_ble_phy_disable_irq = 0x400017fc; -r_ble_phy_disable_whitening = 0x40001800; -r_ble_phy_enable_whitening = 0x40001804; -r_ble_phy_encrypt_disable = 0x40001808; -r_ble_phy_get_current_phy = 0x40001810; -r_ble_phy_get_packet_counter = 0x40001814; -r_ble_phy_get_packet_status = 0x40001818; -r_ble_phy_get_pyld_time_offset = 0x4000181c; -r_ble_phy_get_rx_phy_mode = 0x40001820; -r_ble_phy_get_seq_end_st = 0x40001824; -r_ble_phy_max_data_pdu_pyld = 0x40001830; -r_ble_phy_mode_config = 0x40001834; -r_ble_phy_mode_convert = 0x40001838; -r_ble_phy_mode_write = 0x4000183c; -r_ble_phy_module_init = 0x40001844; -r_ble_phy_reset_bb_monitor = 0x4000184c; -r_ble_phy_resolv_list_disable = 0x40001850; -r_ble_phy_resolv_list_enable = 0x40001854; -r_ble_phy_restart_sequence = 0x40001858; -r_ble_phy_rx_set_start_time_forcibly = 0x4000185c; -r_ble_phy_rxpdu_copy = 0x40001860; -r_ble_phy_seq_encrypt_enable = 0x40001864; -r_ble_phy_seq_encrypt_set_pkt_cntr = 0x40001868; -r_ble_phy_sequence_end_isr = 0x4000186c; -r_ble_phy_sequence_get_mode = 0x40001870; -r_ble_phy_sequence_is_running = 0x40001874; -r_ble_phy_sequence_is_waiting_rsp = 0x40001878; -r_ble_phy_sequence_single_end = 0x4000187c; -r_ble_phy_sequence_tx_end_invoke = 0x40001880; -r_ble_phy_sequence_update_conn_ind_params = 0x40001884; -r_ble_phy_set_coex_pti = 0x4000188c; -r_ble_phy_set_conn_ind_pdu = 0x40001890; -r_ble_phy_set_conn_mode = 0x40001894; -r_ble_phy_set_dev_address = 0x40001898; -r_ble_phy_set_rx_pwr_compensation = 0x4000189c; -r_ble_phy_set_single_packet_rx_sequence = 0x400018ac; -r_ble_phy_set_single_packet_tx_sequence = 0x400018b0; -r_ble_phy_set_tx_rx_transition = 0x400018b4; -r_ble_phy_set_txend_cb = 0x400018b8; -r_ble_phy_setchan = 0x400018bc; -r_ble_phy_start_rx_immediately = 0x400018c0; -r_ble_phy_state_get = 0x400018c4; -r_ble_phy_timer_config_start_time = 0x400018c8; -r_ble_phy_timer_start_now = 0x400018cc; -r_ble_phy_timer_stop = 0x400018d0; -r_ble_phy_tx_set_start_time = 0x400018d4; -r_ble_phy_txpwr_set = 0x400018dc; -r_ble_phy_update_ifs = 0x400018e8; -r_ble_phy_xcvr_state_get = 0x400018ec; -r_ble_plf_set_log_level = 0x400018f0; -r_ble_rtc_wake_up_cpu_init = 0x400018f4; -r_ble_rtc_wake_up_state_clr = 0x400018f8; -r_ble_vendor_hci_register = 0x400018fc; -r_bt_rf_coex_cfg_set = 0x40001900; -r_bt_rf_coex_coded_txrx_time_upper_lim = 0x40001904; -r_bt_rf_coex_dft_pti_set = 0x40001908; -r_bt_rf_coex_hook_deinit = 0x4000190c; -r_bt_rf_coex_hook_init = 0x40001910; -r_bt_rf_coex_hook_st_set = 0x40001914; -r_bt_rf_coex_hooks_p_set_default = 0x40001918; -r_btdm_disable_adv_delay = 0x4000191c; -r_btdm_switch_phy_coded = 0x40001920; -r_esp_wait_disabled = 0x40001924; -r_get_be16 = 0x40001928; -r_get_be24 = 0x4000192c; -r_get_be32 = 0x40001930; -r_get_be64 = 0x40001934; -r_get_le16 = 0x40001938; -r_get_le24 = 0x4000193c; -r_get_le32 = 0x40001940; -r_get_le64 = 0x40001944; -r_get_local_irk_offset = 0x40001948; -r_get_local_rpa_offset = 0x4000194c; -r_get_max_skip = 0x40001950; -r_get_peer_id_offset = 0x40001954; -r_get_peer_irk_offset = 0x40001958; -r_get_peer_rpa_offset = 0x4000195c; -r_hal_timer_disable_irq = 0x4000196c; -r_hal_timer_process = 0x40001978; -r_hal_timer_read = 0x4000197c; -r_hal_timer_read_tick = 0x40001980; -r_hal_timer_set_cb = 0x40001984; -r_hal_timer_start = 0x4000198c; -r_hal_timer_task_start = 0x40001998; -r_ll_assert = 0x4000199c; -r_mem_init_mbuf_pool = 0x400019a0; -r_mem_malloc_mbuf_pool = 0x400019a4; -r_mem_malloc_mbufpkt_pool = 0x400019a8; -r_mem_malloc_mempool = 0x400019ac; -r_mem_malloc_mempool_ext = 0x400019b0; -r_mem_malloc_mempool_gen = 0x400019b4; -r_mem_pullup_obj = 0x400019b8; -r_os_cputime_get32 = 0x400019c0; -r_os_cputime_ticks_to_usecs = 0x400019c4; -r_os_cputime_timer_init = 0x400019c8; -r_os_cputime_timer_relative = 0x400019cc; -r_os_cputime_timer_start = 0x400019d0; -r_os_cputime_timer_stop = 0x400019d4; -r_os_cputime_usecs_to_ticks = 0x400019d8; -r_os_mbuf_adj = 0x400019dc; -r_os_mbuf_appendfrom = 0x400019e4; -r_os_mbuf_cmpf = 0x400019e8; -r_os_mbuf_cmpm = 0x400019ec; -r_os_mbuf_concat = 0x400019f0; -r_os_mbuf_copydata = 0x400019f4; -r_os_mbuf_copyinto = 0x400019f8; -r_os_mbuf_dup = 0x400019fc; -r_os_mbuf_extend = 0x40001a00; -r_os_mbuf_free = 0x40001a04; -r_os_mbuf_free_chain = 0x40001a08; -r_os_mbuf_get = 0x40001a0c; -r_os_mbuf_get_pkthdr = 0x40001a10; -r_os_mbuf_leadingspace = 0x40001a14; -r_os_mbuf_len = 0x40001a18; -r_os_mbuf_off = 0x40001a1c; -r_os_mbuf_pack_chains = 0x40001a20; -r_os_mbuf_pool_init = 0x40001a24; -r_os_mbuf_prepend = 0x40001a28; -r_os_mbuf_prepend_pullup = 0x40001a2c; -r_os_mbuf_pullup = 0x40001a30; -r_os_mbuf_trailingspace = 0x40001a34; -r_os_mbuf_trim_front = 0x40001a38; -r_os_mbuf_widen = 0x40001a3c; -r_os_memblock_from = 0x40001a40; -r_os_memblock_get = 0x40001a44; -r_os_memblock_put_from_cb = 0x40001a4c; -r_os_mempool_clear = 0x40001a50; -r_os_mempool_ext_clear = 0x40001a54; -r_os_mempool_ext_init = 0x40001a58; -r_os_mempool_init = 0x40001a60; -r_os_mempool_is_sane = 0x40001a68; -r_os_mqueue_get = 0x40001a74; -r_os_mqueue_init = 0x40001a78; -r_os_mqueue_put = 0x40001a7c; -r_os_msys_count = 0x40001a80; -r_os_msys_get = 0x40001a84; -r_os_msys_get_pkthdr = 0x40001a88; -r_os_msys_num_free = 0x40001a8c; -r_os_msys_register = 0x40001a90; -r_os_msys_reset = 0x40001a94; -r_pri_phy_valid = 0x40001a98; -r_put_be16 = 0x40001a9c; -r_put_be24 = 0x40001aa0; -r_put_be32 = 0x40001aa4; -r_put_be64 = 0x40001aa8; -r_put_le16 = 0x40001aac; -r_put_le24 = 0x40001ab0; -r_put_le32 = 0x40001ab4; -r_put_le64 = 0x40001ab8; -r_rtc0_timer_handler = 0x40001abc; -r_sdkconfig_get_opts = 0x40001ac0; -r_sdkconfig_set_opts = 0x40001ac4; -r_sec_phy_valid = 0x40001ac8; -r_swap_buf = 0x40001acc; -r_swap_in_place = 0x40001ad0; -/* Data (.data, .bss, .rodata) */ -ble_lll_dtm_module_env_p = 0x3fcdffc4; -g_ble_lll_dtm_prbs15_data = 0x3ff4fee4; -g_ble_lll_dtm_prbs9_data = 0x3ff4fde4; -g_channel_rf_to_index = 0x3ff4fdbc; -g_ble_lll_rfmgmt_data = 0x3fcdff7c; -g_ble_sleep_enter_cb = 0x3fcdff78; -g_ble_sleep_exit_cb = 0x3fcdff74; -ble_lll_sched_env_p = 0x3fcdff70; -ble_ll_env_p = 0x3fcdff6c; -g_ble_ll_pdu_header_tx_time_ro = 0x3ff4fdb4; -ble_ll_adv_env_p = 0x3fcdff68; -ble_ll_conn_env_p = 0x3fcdff64; -ble_ll_conn_required_phy_mask = 0x3ff4fdb0; -ble_ll_valid_conn_phy_mask = 0x3ff4fdaf; -ble_ll_hci_env_p = 0x3fcdff60; -g_debug_le_private_key = 0x3ff4fd6c; -g_ecc_key = 0x3fcdfefc; -ble_ll_rand_env_p = 0x3fcdfef8; -ble_ll_resolv_env_p = 0x3fcdfef4; -g_ble_ll_resolve_hdr = 0x3fcdfeec; -g_device_mode_default = 0x3fcdfe68; -ble_ll_scan_classify_filter_aux_check_cb = 0x3fcdfee8; -ble_ll_scan_classify_filter_check_cb = 0x3fcdfee4; -ble_ll_scan_env_p = 0x3fcdfee0; -g_ble_ll_supp_cmds_ro = 0x3ff4fd3c; -ble_ll_sync_env_p = 0x3fcdfedc; -g_ble_sca_ppm_tbl_ro = 0x3ff4fd2c; -priv_config_opts = 0x3fcdfe48; -ble_hci_uart_reset_cmd = 0x3ff4fd28; -ble_hci_trans_env_p = 0x3fcdfed8; -ble_hci_trans_mode = 0x3fcdfe44; -ble_hci_trans_funcs_ptr = 0x3fcdfed4; -r_ble_lll_stub_funcs_ptr = 0x3fcdfed0; -r_ble_stub_funcs_ptr = 0x3fcdfecc; -r_ext_funcs_p = 0x3fcdfec8; -r_npl_funcs = 0x3fcdfec4; -ble_hw_env_p = 0x3fcdfec0; -ble_phy_module_env_p = 0x3fcdfebc; -g_ble_phy_chan_freq_ro = 0x3ff4fd00; -g_ble_phy_mode_pkt_start_off_ro = 0x3ff4fcf8; -g_ble_phy_rxtx_ifs_compensation_ro = 0x3ff4fce8; -g_ble_phy_t_rxaddrdelay_ro = 0x3ff4fce4; -g_ble_phy_t_rxenddelay_ro = 0x3ff4fce0; -g_ble_phy_t_txdelay_ro = 0x3ff4fcdc; -g_ble_phy_t_txenddelay_ro = 0x3ff4fcd8; -g_ble_phy_txrx_ifs_compensation_ro = 0x3ff4fcc8; -hal_timer_env_p = 0x3fcdfeb8; -r_osi_coex_funcs_p = 0x3fcdfeb4; -bt_rf_coex_hooks = 0x3fcdfeac; -bt_rf_coex_hooks_p = 0x3fcdfea8; -coex_hook_st_group_tab = 0x3ff4fcbc; -coex_hook_st_group_to_coex_schm_st_tab = 0x3ff4fcb8; -s_ble_act_count_by_group = 0x3fcdfea4; -s_ble_coex_st_map = 0x3fcdfe90; -bt_rf_coex_cfg_cb = 0x3fcdfe74; -bt_rf_coex_cfg_p = 0x3fcdfe70; -bt_rf_coex_cfg_rom = 0x3ff4fc9c; -bt_rf_coex_pti_dft_p = 0x3fcdfe6c; -bt_rf_coex_pti_dft_rom = 0x3fcdfe04; -conn_dynamic_pti_param_rom = 0x3ff4fc84; -conn_phy_coded_max_data_time_param_rom = 0x3ff4fc80; -ext_adv_dynamic_pti_param_rom = 0x3ff4fc4c; -ext_scan_dynamic_param_rom = 0x3ff4fc14; -legacy_adv_dynamic_pti_param_rom = 0x3ff4fbf4; -per_adv_dynamic_pti_param_rom = 0x3ff4fbd8; -sync_dynamic_param_rom = 0x3ff4fbc0; -g_ble_plf_log_level = 0x3fcdfe00; -g_msys_pool_list = 0x3fcdfdf8; -g_os_mempool_list = 0x3fcdfdf0; - - /*************************************** Group rom_pp ***************************************/ @@ -1532,7 +633,7 @@ ppGetTxframe = 0x40001bf8; ppMapTxQueue = 0x40001bfc; ppProcTxSecFrame = 0x40001c00; ppProcessRxPktHdr = 0x40001c04; -ppProcessTxQ = 0x40001c08; +/*ppProcessTxQ = 0x40001c08;*/ ppRecordBarRRC = 0x40001c0c; lmacRequestTxopQueue = 0x40001c10; lmacReleaseTxopQueue = 0x40001c14; @@ -1570,8 +671,8 @@ rcSetTxAmpduLimit = 0x40001c90; /* rcTxUpdatePer = 0x40001c94;*/ rcUpdateAckSnr = 0x40001c98; /*rcUpdateRate = 0x40001c9c;*/ -rcUpdateTxDone = 0x40001ca0; -rcUpdateTxDoneAmpdu2 = 0x40001ca4; +/*rcUpdateTxDone = 0x40001ca0;*/ +/*rcUpdateTxDoneAmpdu2 = 0x40001ca4;*/ rcUpSched = 0x40001ca8; rssi_margin = 0x40001cac; rx11NRate2AMPDULimit = 0x40001cb0; @@ -1698,7 +799,7 @@ dbg_lmac_rxtx_statis_dump = 0x40001e90; dbg_lmac_hw_statis_dump = 0x40001e94; dbg_lmac_diag_statis_dump = 0x40001e98; dbg_lmac_ps_statis_dump = 0x40001e9c; -pp_timer_do_process = 0x40001ea0; +/*pp_timer_do_process = 0x40001ea0;*/ rcUpdateAMPDUParam = 0x40001ea4; rcUpdatePhyMode = 0x40001ea8; rcGetHighestRateIdx = 0x40001eac; @@ -1915,7 +1016,7 @@ ieee80211_alloc_tx_buf = 0x40002108; /* ieee80211_send_nulldata = 0x40002110; */ /* ieee80211_setup_robust_mgmtframe = 0x40002114; */ ieee80211_encap_null_data = 0x4000211c; -ieee80211_send_deauth = 0x40002120; +//ieee80211_send_deauth_no_bss = 0x40002120; ieee80211_alloc_deauth = 0x40002124; ieee80211_send_proberesp = 0x40002128; ieee80211_getcapinfo = 0x40002130; @@ -1978,7 +1079,7 @@ coex_hw_timer_set = 0x4000219c; coex_schm_interval_set = 0x400021a0; coex_schm_lock = 0x400021a4; coex_schm_unlock = 0x400021a8; -coex_status_get = 0x400021ac; +/*coex_status_get = 0x400021ac;*/ coex_wifi_release = 0x400021b0; esp_coex_ble_conn_dynamic_prio_get = 0x400021b4; /*coex_hw_timer_tick_get = 0x400021b8;*/ diff --git a/components/esp_rom/esp32c2/ld/esp32c2.rom.mbedtls.eco4.ld b/components/esp_rom/esp32c2/ld/esp32c2.rom.mbedtls.eco4.ld new file mode 100644 index 0000000000..fe893c335a --- /dev/null +++ b/components/esp_rom/esp32c2/ld/esp32c2.rom.mbedtls.eco4.ld @@ -0,0 +1,231 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/*************************************** + Group eco4_rom_mbedtls + ***************************************/ + +/* Functions */ +mbedtls_mpi_init = 0x400026dc; +mbedtls_mpi_free = 0x400026e0; +mbedtls_mpi_grow = 0x400026e4; +mbedtls_mpi_shrink = 0x400026e8; +mbedtls_mpi_copy = 0x400026ec; +mbedtls_mpi_safe_cond_assign = 0x400026f0; +mbedtls_mpi_safe_cond_swap = 0x400026f4; +mbedtls_mpi_lset = 0x400026f8; +mbedtls_mpi_get_bit = 0x400026fc; +mbedtls_mpi_set_bit = 0x40002700; +mbedtls_mpi_lsb = 0x40002704; +mbedtls_mpi_bitlen = 0x40002708; +mbedtls_mpi_size = 0x4000270c; +mbedtls_mpi_read_binary = 0x40002710; +mbedtls_mpi_write_binary = 0x40002714; +mbedtls_mpi_shift_l = 0x40002718; +mbedtls_mpi_shift_r = 0x4000271c; +mbedtls_mpi_cmp_abs = 0x40002720; +mbedtls_mpi_cmp_mpi = 0x40002724; +mbedtls_mpi_lt_mpi_ct = 0x40002728; +mbedtls_mpi_cmp_int = 0x4000272c; +mbedtls_mpi_add_abs = 0x40002730; +mbedtls_mpi_sub_abs = 0x40002734; +mbedtls_mpi_add_mpi = 0x40002738; +mbedtls_mpi_sub_mpi = 0x4000273c; +mbedtls_mpi_add_int = 0x40002740; +mbedtls_mpi_sub_int = 0x40002744; +mbedtls_mpi_mul_mpi = 0x40002748; +mbedtls_mpi_mul_int = 0x4000274c; +mbedtls_mpi_div_mpi = 0x40002750; +mbedtls_mpi_div_int = 0x40002754; +mbedtls_mpi_mod_mpi = 0x40002758; +mbedtls_mpi_mod_int = 0x4000275c; +mbedtls_mpi_exp_mod = 0x40002760; +mbedtls_mpi_fill_random = 0x40002764; +mbedtls_mpi_gcd = 0x40002768; +mbedtls_mpi_inv_mod = 0x4000276c; +mbedtls_mpi_is_prime_ext = 0x40002770; + +/* Moved from mbedtls.ld to mbedtls.eco4 ld */ +mbedtls_cipher_init = 0x4000277c; +mbedtls_cipher_set_padding_mode = 0x40002780; +mbedtls_cipher_reset = 0x40002784; +mbedtls_cipher_finish = 0x40002788; +mbedtls_cipher_crypt = 0x4000278c; +mbedtls_cipher_cmac_starts = 0x40002790; +mbedtls_cipher_cmac_update = 0x40002794; +mbedtls_cipher_cmac_finish = 0x40002798; + +/*************************************** + Group eco4_rom_mbedtls + ***************************************/ + +/* Functions */ +rom_mbedtls_threading_set_alt = 0x40002c0c; +mbedtls_aes_crypt_cfb8 = 0x40002c10; +mbedtls_mpi_swap = 0x40002c14; +mbedtls_mpi_read_string = 0x40002c18; +mbedtls_mpi_write_string = 0x40002c1c; +mbedtls_mpi_read_binary_le = 0x40002c20; +mbedtls_mpi_write_binary_le = 0x40002c24; +mbedtls_mpi_random = 0x40002c28; +mbedtls_mpi_gen_prime = 0x40002c2c; +mbedtls_ecp_check_budget = 0x40002c30; +mbedtls_ecp_set_max_ops = 0x40002c34; +mbedtls_ecp_restart_is_enabled = 0x40002c38; +mbedtls_ecp_get_type = 0x40002c3c; +mbedtls_ecp_curve_list = 0x40002c40; +mbedtls_ecp_grp_id_list = 0x40002c44; +mbedtls_ecp_curve_info_from_grp_id = 0x40002c48; +mbedtls_ecp_curve_info_from_tls_id = 0x40002c4c; +mbedtls_ecp_curve_info_from_name = 0x40002c50; +mbedtls_ecp_point_init = 0x40002c54; +mbedtls_ecp_group_init = 0x40002c58; +mbedtls_ecp_keypair_init = 0x40002c5c; +mbedtls_ecp_point_free = 0x40002c60; +mbedtls_ecp_group_free = 0x40002c64; +mbedtls_ecp_keypair_free = 0x40002c68; +mbedtls_ecp_restart_init = 0x40002c6c; +mbedtls_ecp_restart_free = 0x40002c70; +mbedtls_ecp_copy = 0x40002c74; +mbedtls_ecp_group_copy = 0x40002c78; +mbedtls_ecp_set_zero = 0x40002c7c; +mbedtls_ecp_is_zero = 0x40002c80; +mbedtls_ecp_point_cmp = 0x40002c84; +mbedtls_ecp_point_read_string = 0x40002c88; +mbedtls_ecp_point_write_binary = 0x40002c8c; +mbedtls_ecp_point_read_binary = 0x40002c90; +mbedtls_ecp_tls_read_point = 0x40002c94; +mbedtls_ecp_tls_write_point = 0x40002c98; +mbedtls_ecp_group_load = 0x40002c9c; +mbedtls_ecp_tls_read_group = 0x40002ca0; +mbedtls_ecp_tls_read_group_id = 0x40002ca4; +mbedtls_ecp_tls_write_group = 0x40002ca8; +mbedtls_ecp_mul = 0x40002cac; +mbedtls_ecp_mul_restartable = 0x40002cb0; +mbedtls_ecp_muladd = 0x40002cb4; +mbedtls_ecp_muladd_restartable = 0x40002cb8; +mbedtls_ecp_check_pubkey = 0x40002cbc; +mbedtls_ecp_check_privkey = 0x40002cc0; +mbedtls_ecp_gen_privkey = 0x40002cc4; +mbedtls_ecp_gen_keypair_base = 0x40002cc8; +mbedtls_ecp_gen_keypair = 0x40002ccc; +mbedtls_ecp_gen_key = 0x40002cd0; +mbedtls_ecp_read_key = 0x40002cd4; +mbedtls_ecp_write_key_ext = 0x40002cd8; +mbedtls_ecp_check_pub_priv = 0x40002cdc; +mbedtls_ecp_export = 0x40002ce0; +mbedtls_asn1_get_enum = 0x40002ce4; +mbedtls_asn1_sequence_free = 0x40002ce8; +mbedtls_asn1_traverse_sequence_of = 0x40002cec; +mbedtls_asn1_find_named_data = 0x40002cf0; +mbedtls_asn1_free_named_data_list = 0x40002cf4; +mbedtls_asn1_free_named_data_list_shallow = 0x40002cf8; +mbedtls_asn1_write_raw_buffer = 0x40002cfc; +mbedtls_asn1_write_null = 0x40002d00; +mbedtls_asn1_write_oid = 0x40002d04; +mbedtls_asn1_write_algorithm_identifier = 0x40002d08; +mbedtls_asn1_write_bool = 0x40002d0c; +mbedtls_asn1_write_int = 0x40002d10; +mbedtls_asn1_write_enum = 0x40002d14; +mbedtls_asn1_write_tagged_string = 0x40002d18; +mbedtls_asn1_write_printable_string = 0x40002d1c; +mbedtls_asn1_write_utf8_string = 0x40002d20; +mbedtls_asn1_write_ia5_string = 0x40002d24; +mbedtls_asn1_write_bitstring = 0x40002d28; +mbedtls_asn1_write_named_bitstring = 0x40002d2c; +mbedtls_asn1_write_octet_string = 0x40002d30; +mbedtls_asn1_store_named_data = 0x40002d34; +mbedtls_ccm_starts = 0x40002d38; +mbedtls_ccm_set_lengths = 0x40002d3c; +mbedtls_ccm_update_ad = 0x40002d40; +mbedtls_ccm_update = 0x40002d44; +mbedtls_ccm_finish = 0x40002d48; +mbedtls_cipher_list = 0x40002d4c; +mbedtls_cipher_info_from_string = 0x40002d50; +mbedtls_cipher_info_from_type = 0x40002d54; +mbedtls_cipher_info_from_values = 0x40002d58; +mbedtls_cipher_free = 0x40002d5c; +mbedtls_cipher_setup = 0x40002d60; +mbedtls_cipher_setkey = 0x40002d64; +mbedtls_cipher_set_iv = 0x40002d68; +mbedtls_cipher_update_ad = 0x40002d6c; +mbedtls_cipher_update = 0x40002d70; +mbedtls_cipher_write_tag = 0x40002d74; +mbedtls_cipher_check_tag = 0x40002d78; +mbedtls_cipher_auth_encrypt_ext = 0x40002d7c; +mbedtls_cipher_auth_decrypt_ext = 0x40002d80; +mbedtls_cipher_cmac_reset = 0x40002d84; +mbedtls_cipher_cmac = 0x40002d88; +mbedtls_aes_cmac_prf_128 = 0x40002d8c; +mbedtls_ctr_drbg_set_prediction_resistance = 0x40002d90; +mbedtls_ctr_drbg_set_entropy_len = 0x40002d94; +mbedtls_ctr_drbg_set_nonce_len = 0x40002d98; +mbedtls_ctr_drbg_set_reseed_interval = 0x40002d9c; +mbedtls_ctr_drbg_update = 0x40002da0; +mbedtls_base64_encode = 0x40002da4; +mbedtls_rsa_init = 0x40002da8; +mbedtls_rsa_set_padding = 0x40002dac; +mbedtls_rsa_get_padding_mode = 0x40002db0; +mbedtls_rsa_get_md_alg = 0x40002db4; +mbedtls_rsa_import = 0x40002db8; +mbedtls_rsa_import_raw = 0x40002dbc; +mbedtls_rsa_complete = 0x40002dc0; +mbedtls_rsa_export = 0x40002dc4; +mbedtls_rsa_export_raw = 0x40002dc8; +mbedtls_rsa_export_crt = 0x40002dcc; +mbedtls_rsa_get_len = 0x40002dd0; +mbedtls_rsa_gen_key = 0x40002dd4; +mbedtls_rsa_check_pubkey = 0x40002dd8; +mbedtls_rsa_check_privkey = 0x40002ddc; +mbedtls_rsa_check_pub_priv = 0x40002de0; +mbedtls_rsa_public = 0x40002de4; +mbedtls_rsa_private = 0x40002de8; +mbedtls_rsa_pkcs1_encrypt = 0x40002dec; +mbedtls_rsa_rsaes_pkcs1_v15_encrypt = 0x40002df0; +mbedtls_rsa_rsaes_oaep_encrypt = 0x40002df4; +mbedtls_rsa_pkcs1_decrypt = 0x40002df8; +mbedtls_rsa_rsaes_pkcs1_v15_decrypt = 0x40002dfc; +mbedtls_rsa_rsaes_oaep_decrypt = 0x40002e00; +mbedtls_rsa_pkcs1_sign = 0x40002e04; +mbedtls_rsa_rsassa_pkcs1_v15_sign = 0x40002e08; +mbedtls_rsa_rsassa_pss_sign_ext = 0x40002e0c; +mbedtls_rsa_rsassa_pss_sign = 0x40002e10; +mbedtls_rsa_pkcs1_verify = 0x40002e14; +mbedtls_rsa_rsassa_pkcs1_v15_verify = 0x40002e18; +mbedtls_rsa_rsassa_pss_verify = 0x40002e1c; +mbedtls_rsa_rsassa_pss_verify_ext = 0x40002e20; +mbedtls_rsa_copy = 0x40002e24; +mbedtls_rsa_free = 0x40002e28; +mbedtls_ecdh_can_do = 0x40002e2c; +mbedtls_ecdh_gen_public = 0x40002e30; +mbedtls_ecdh_compute_shared = 0x40002e34; +mbedtls_ecdh_init = 0x40002e38; +mbedtls_ecdh_setup = 0x40002e3c; +mbedtls_ecdh_free = 0x40002e40; +mbedtls_ecdh_make_params = 0x40002e44; +mbedtls_ecdh_read_params = 0x40002e48; +mbedtls_ecdh_get_params = 0x40002e4c; +mbedtls_ecdh_make_public = 0x40002e50; +mbedtls_ecdh_read_public = 0x40002e54; +mbedtls_ecdh_calc_secret = 0x40002e58; +mbedtls_ecdh_enable_restart = 0x40002e5c; +mbedtls_ecdsa_can_do = 0x40002e60; +mbedtls_ecdsa_sign = 0x40002e64; +mbedtls_ecdsa_sign_det_ext = 0x40002e68; +mbedtls_ecdsa_sign_restartable = 0x40002e6c; +mbedtls_ecdsa_sign_det_restartable = 0x40002e70; +mbedtls_ecdsa_verify = 0x40002e74; +mbedtls_ecdsa_verify_restartable = 0x40002e78; +mbedtls_ecdsa_write_signature = 0x40002e7c; +mbedtls_ecdsa_write_signature_restartable = 0x40002e80; +mbedtls_ecdsa_read_signature = 0x40002e84; +mbedtls_ecdsa_read_signature_restartable = 0x40002e88; +mbedtls_ecdsa_genkey = 0x40002e8c; +mbedtls_ecdsa_from_keypair = 0x40002e90; +mbedtls_ecdsa_init = 0x40002e94; +mbedtls_ecdsa_free = 0x40002e98; +mbedtls_ecdsa_restart_init = 0x40002e9c; +mbedtls_ecdsa_restart_free = 0x40002ea0; diff --git a/components/esp_rom/esp32c2/ld/esp32c2.rom.mbedtls.ld b/components/esp_rom/esp32c2/ld/esp32c2.rom.mbedtls.ld index 54f24e751c..20182027d6 100644 --- a/components/esp_rom/esp32c2/ld/esp32c2.rom.mbedtls.ld +++ b/components/esp_rom/esp32c2/ld/esp32c2.rom.mbedtls.ld @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -43,14 +43,6 @@ mbedtls_asn1_write_mpi = 0x400026d4; mbedtls_base64_decode = 0x400026d8; mbedtls_ccm_star_encrypt_and_tag = 0x40002774; mbedtls_ccm_star_auth_decrypt = 0x40002778; -mbedtls_cipher_init = 0x4000277c; -mbedtls_cipher_set_padding_mode = 0x40002780; -mbedtls_cipher_reset = 0x40002784; -mbedtls_cipher_finish = 0x40002788; -mbedtls_cipher_crypt = 0x4000278c; -mbedtls_cipher_cmac_starts = 0x40002790; -mbedtls_cipher_cmac_update = 0x40002794; -mbedtls_cipher_cmac_finish = 0x40002798; mbedtls_ctr_drbg_init = 0x4000279c; mbedtls_ctr_drbg_seed = 0x400027a0; mbedtls_ctr_drbg_free = 0x400027a4; @@ -74,7 +66,7 @@ mbedtls_sha512_clone = 0x40002a50; mbedtls_sha512_starts = 0x40002a54; mbedtls_sha512_update = 0x40002a58; mbedtls_sha512_finish = 0x40002a5c; -mbedtls_internal_sha512_process = 0x40002a60; +/*mbedtls_internal_sha512_process = 0x40002a60;*/ mbedtls_sha512 = 0x40002a64; mbedtls_aes_xts_init = 0x40002b68; mbedtls_aes_xts_free = 0x40002b6c; @@ -95,7 +87,7 @@ mbedtls_md5_clone = 0x40002be0; mbedtls_md5_starts = 0x40002be4; mbedtls_md5_update = 0x40002be8; mbedtls_md5_finish = 0x40002bec; -mbedtls_internal_md5_process = 0x40002bf0; +/*mbedtls_internal_md5_process = 0x40002bf0;*/ mbedtls_md5 = 0x40002bf4; mbedtls_sha1 = 0x40002c08; /* Data (.data, .bss, .rodata) */ diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_50.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_50.ld new file mode 100644 index 0000000000..cf9e0c3e12 --- /dev/null +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_50.ld @@ -0,0 +1,75 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32c3.rom.ld for esp32c3 + * + * + * Generated from ./interface-esp32c3.yml md5sum 93b28a9e1fe42d212018eb4336849208 + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* extend adv */ +f_hci_le_set_ext_adv_param_cmd_handler = 0; +f_hci_le_set_adv_set_rand_addr_cmd_handler = 0; +f_hci_le_set_ext_adv_data_cmd_handler = 0; +f_hci_le_set_ext_scan_rsp_data_cmd_handler = 0; +f_hci_le_set_ext_adv_en_cmd_handler = 0; +f_hci_le_rd_max_adv_data_len_cmd_handler = 0; +f_hci_le_rd_nb_supp_adv_sets_cmd_handler = 0; +f_hci_le_rmv_adv_set_cmd_handler = 0; +f_hci_le_clear_adv_sets_cmd_handler = 0; +r_lld_adv_sync_info_set = 0; + +r_lld_ext_adv_dynamic_pti_process = 0; +r_lld_adv_ext_chain_construct = 0; +r_lld_adv_aux_evt_canceled_cbk = 0; +r_lld_adv_aux_evt_start_cbk = 0; +r_lld_adv_aux_ch_idx_set = 0; + +/* periodic adv */ +f_hci_le_set_per_adv_param_cmd_handler = 0; +f_hci_le_set_per_adv_data_cmd_handler = 0; +f_hci_le_set_per_adv_en_cmd_handler = 0; +r_lld_per_adv_ch_map_update = 0; +r_lld_per_adv_init = 0; + +/* PA list */ +f_hci_le_add_dev_to_per_adv_list_cmd_handler = 0; +f_hci_le_rmv_dev_from_per_adv_list_cmd_handler = 0; +f_hci_le_clear_per_adv_list_cmd_handler = 0; +f_hci_le_rd_per_adv_list_size_cmd_handler = 0; + +/* extend scan */ +f_hci_le_set_ext_scan_param_cmd_handler = 0; +f_hci_le_set_ext_scan_en_cmd_handler = 0; +r_lld_scan_process_pkt_rx_ext_adv = 0; +r_lld_scan_trunc_ind = 0; + +/* extend con */ +f_hci_le_ext_create_con_cmd_handler = 0; +r_lld_init_process_pkt_rx_adv_ext_ind = 0; +r_lld_init_process_pkt_rx_aux_connect_rsp = 0; + +/* PA sync */ +f_hci_le_per_adv_create_sync_cmd_handler = 0; +f_hci_le_per_adv_create_sync_cancel_cmd_handler = 0; +f_hci_le_per_adv_term_sync_cmd_handler = 0; +f_lld_per_adv_rx_end_ind_handler_hack = 0; +f_lld_sync_start_req_handler = 0; +f_lld_per_adv_rep_ind_handler = 0; +r_lld_sync_init = 0; + +/* phy update*/ +r_phy_upd_proc_start = 0; +f_llc_op_phy_upd_ind_handler = 0; +f_ll_phy_req_handler = 0; +f_ll_phy_rsp_handler = 0; +f_ll_phy_update_ind_handler = 0; +f_lld_phy_upd_cfm_handler = 0; +f_hci_le_set_phy_cmd_handler = 0; +llc_llcp_phy_update_ind_ack = 0; diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_cca.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_cca.ld new file mode 100644 index 0000000000..3bb1476472 --- /dev/null +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_cca.ld @@ -0,0 +1,32 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32c3.rom.ld for esp32c3 + * + * + * Generated from ./interface-esp32c3.yml md5sum 93b28a9e1fe42d212018eb4336849208 + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* SW CCA */ +r_lld_cca_con_evt_start_handle = 0; +r_lld_hw_cca_end_isr = 0; +r_lld_hw_cca_isr_eco = 0; +r_lld_cca_bb_sync_found_handle = 0; +r_lld_cca_data_reset = 0; +r_lld_cca_sw_init = 0; +r_lld_cca_con_evt_end_handle = 0; +r_lld_cca_alloc = 0; +r_lld_cca_sw_alloc = 0; +r_lld_cca_sw_free = 0; +r_lld_cca_free = 0; +r_cca_init = 0; +r_lld_hw_cca_evt_handler = 0; +r_lld_sw_cca_evt_handler = 0; +r_ble_sw_cca_check_isr = 0; +bt_bb_tx_cca_set = 0; diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_dtm.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_dtm.ld new file mode 100644 index 0000000000..aeede90250 --- /dev/null +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_dtm.ld @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32c3.rom.ld for esp32c3 + * + * + * Generated from ./interface-esp32c3.yml md5sum 93b28a9e1fe42d212018eb4336849208 + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* DTM */ +f_hci_le_rx_test_cmd_handler = 0; +f_hci_le_tx_test_cmd_handler = 0; +f_hci_le_enh_rx_test_cmd_handler = 0; +f_hci_le_enh_tx_test_cmd_handler = 0; +f_hci_le_test_end_cmd_handler = 0; +r_lld_test_init = 0; diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_master.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_master.ld new file mode 100644 index 0000000000..e7d2db0cbf --- /dev/null +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_master.ld @@ -0,0 +1,20 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32c3.rom.ld for esp32c3 + * + * + * Generated from ./interface-esp32c3.yml md5sum 93b28a9e1fe42d212018eb4336849208 + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* master */ +f_hci_le_create_con_cmd_handler = 0; +f_hci_le_create_con_cancel_cmd_handler = 0; +lld_init_end_ind_handler = 0; +r_lld_init_init = 0; diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_scan.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_scan.ld new file mode 100644 index 0000000000..b9a14d8e2b --- /dev/null +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_scan.ld @@ -0,0 +1,36 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32c3.rom.ld for esp32c3 + * + * + * Generated from ./interface-esp32c3.yml md5sum 93b28a9e1fe42d212018eb4336849208 + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + + +/* BLE scan */ +f_hci_le_set_scan_param_cmd_handler = 0; +f_hci_le_set_scan_en_cmd_handler = 0; +f_llm_scan_period_to_handler_hack = 1; +f_lld_adv_rep_ind_handler_hack = 0; +r_lld_scan_init = 0; +r_lld_scan_restart = 0; +f_lld_scan_end_ind_handler_hack = 0; +r_llm_env_adv_dup_filt_deinit_eco = 0; +llm_exception_list_init = 0; +llm_duplicate_list_init = 0; +f_hci_vendor_ble_update_duplicate_exceptional_list_cmd_handler = 0; +f_hci_vendor_ble_init_adv_flow_control_cmd_handler = 0; +f_hci_vendor_ble_update_adv_report_flow_control_cmd_handler = 0; +coex_schm_ble_scan_stop = 0; + +f_hci_le_set_ext_scan_param_cmd_handler = 0; +f_hci_le_set_ext_scan_en_cmd_handler = 0; +r_lld_scan_process_pkt_rx_ext_adv = 0; +r_lld_scan_trunc_ind = 0; diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_smp.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_smp.ld new file mode 100644 index 0000000000..15436088d7 --- /dev/null +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_smp.ld @@ -0,0 +1,44 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32c3.rom.ld for esp32c3 + * + * + * Generated from ./interface-esp32c3.yml md5sum 93b28a9e1fe42d212018eb4336849208 + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* SMP */ +f_ll_pause_enc_req_handler = 0; +f_ll_pause_enc_rsp_handler = 0; +f_ll_enc_req_handler = 0; +f_ll_enc_rsp_handler = 0; +f_ll_start_enc_req_handler = 0; +f_ll_start_enc_rsp_handler = 0; +f_hci_le_start_enc_cmd_handler = 0; +f_hci_le_ltk_req_reply_cmd_handler = 0; +f_hci_le_ltk_req_neg_reply_cmd_handler = 0; +f_llc_encrypt_ind_handler = 0; +f_llc_op_encrypt_ind_handler = 0; +f_hci_le_rd_local_p256_public_key_cmd_handler = 0; +f_hci_le_generate_dhkey_cmd_handler = 0; +f_hci_le_enc_cmd_handler = 0; +r_rwip_crypt_evt_handler = 0; + +/* LE ping */ +f_ll_ping_req_handler = 0; +f_ll_ping_rsp_handler = 0; +r_llc_le_ping_set = 0; +r_llc_le_ping_restart = 0; +f_llc_op_le_ping_ind_handler = 0; +f_llc_auth_payl_nearly_op_handler = 0; +f_llc_auth_payl_real_to_handler = 0; +f_llc_auth_payl_nearly_to_handler = 0; + +/* ecc */ +r_ecc_init = 0; diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_test.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_test.ld new file mode 100644 index 0000000000..0c821cf5ba --- /dev/null +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_test.ld @@ -0,0 +1,37 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32c3.rom.ld for esp32c3 + * + * + * Generated from ./interface-esp32c3.yml md5sum 93b28a9e1fe42d212018eb4336849208 + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + + +/* overwrite */ +lld_acl_rx_ind_handler = 0; +lld_con_estab_ind_handler = 0; +lld_adv_rep_ind_handler = 0; +llm_rpa_renew_to_handler = 0; +lld_scan_end_ind_handler = 0; +llm_scan_period_to_handler = 0; + +/* nvds */ +r_nvds_init = 0; +f_nvds_get = 0; +f_nvds_del = 0; +f_nvds_put = 0; + +/* controller flash */ +r_flash_init = 0; +r_flash_env_init = 0; +r_flash_env_deinit = 0; + +/* QA test */ +f_hci_vendor_ble_qa_test_cmd_handler = 0; diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.bt_funcs.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.bt_funcs.ld new file mode 100644 index 0000000000..89ea7c532c --- /dev/null +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.bt_funcs.ld @@ -0,0 +1,844 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32c3.rom.ld for esp32c3 + * + * + * Generated from ./interface-esp32c3.yml md5sum 93b28a9e1fe42d212018eb4336849208 + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/*************************************** + Group bluetooth + ***************************************/ + +/* Functions */ +bt_rf_coex_get_dft_cfg = 0x400008dc; +bt_rf_coex_hooks_p_set = 0x400008e0; +btdm_con_maxevtime_cal_impl = 0x400008e4; +btdm_controller_get_compile_version_impl = 0x400008e8; +btdm_controller_rom_data_init = 0x400008ec; +btdm_dis_privacy_err_report_impl = 0x400008f0; +btdm_disable_adv_delay_impl = 0x400008f4; +btdm_enable_scan_continue_impl = 0x400008f8; +btdm_enable_scan_forever_impl = 0x400008fc; +btdm_get_power_state_impl = 0x40000900; +btdm_get_prevent_sleep_flag_impl = 0x40000904; +btdm_power_state_active_impl = 0x40000908; +btdm_switch_phy_coded_impl = 0x4000090c; +hci_acl_data_handler = 0x40000910; +hci_disconnect_cmd_handler = 0x40000914; +hci_le_con_upd_cmd_handler = 0x40000918; +hci_le_ltk_req_neg_reply_cmd_handler = 0x4000091c; +hci_le_ltk_req_reply_cmd_handler = 0x40000920; +hci_le_rd_chnl_map_cmd_handler = 0x40000924; +hci_le_rd_phy_cmd_handler = 0x40000928; +hci_le_rd_rem_feats_cmd_handler = 0x4000092c; +hci_le_rem_con_param_req_neg_reply_cmd_handler = 0x40000930; +hci_le_rem_con_param_req_reply_cmd_handler = 0x40000934; +hci_le_set_data_len_cmd_handler = 0x40000938; +hci_le_set_phy_cmd_handler = 0x4000093c; +hci_le_start_enc_cmd_handler = 0x40000940; +hci_rd_auth_payl_to_cmd_handler = 0x40000944; +hci_rd_rem_ver_info_cmd_handler = 0x40000948; +hci_rd_rssi_cmd_handler = 0x4000094c; +hci_rd_tx_pwr_lvl_cmd_handler = 0x40000950; +hci_vs_set_pref_slave_evt_dur_cmd_handler = 0x40000954; +hci_vs_set_pref_slave_latency_cmd_handler = 0x40000958; +hci_wr_auth_payl_to_cmd_handler = 0x4000095c; +ll_channel_map_ind_handler = 0x40000960; +ll_connection_param_req_handler = 0x40000964; +ll_connection_param_rsp_handler = 0x40000968; +ll_connection_update_ind_handler = 0x4000096c; +ll_enc_req_handler = 0x40000970; +ll_enc_rsp_handler = 0x40000974; +ll_feature_req_handler = 0x40000978; +ll_feature_rsp_handler = 0x4000097c; +ll_length_req_handler = 0x40000980; +ll_length_rsp_handler = 0x40000984; +ll_min_used_channels_ind_handler = 0x40000988; +ll_pause_enc_req_handler = 0x4000098c; +ll_pause_enc_rsp_handler = 0x40000990; +ll_phy_req_handler = 0x40000994; +ll_phy_rsp_handler = 0x40000998; +ll_phy_update_ind_handler = 0x4000099c; +ll_ping_req_handler = 0x400009a0; +ll_ping_rsp_handler = 0x400009a4; +ll_slave_feature_req_handler = 0x400009a8; +ll_start_enc_req_handler = 0x400009ac; +ll_start_enc_rsp_handler = 0x400009b0; +ll_terminate_ind_handler = 0x400009b4; +ll_version_ind_handler = 0x400009b8; +llc_auth_payl_nearly_to_handler = 0x400009bc; +llc_auth_payl_real_to_handler = 0x400009c0; +llc_encrypt_ind_handler = 0x400009c4; +llc_hci_command_handler_wrapper = 0x400009c8; +llc_ll_connection_param_req_pdu_send = 0x400009cc; +llc_ll_connection_param_rsp_pdu_send = 0x400009d0; +llc_ll_connection_update_ind_pdu_send = 0x400009d4; +llc_ll_enc_req_pdu_send = 0x400009d8; +llc_ll_enc_rsp_pdu_send = 0x400009dc; +llc_ll_feature_req_pdu_send = 0x400009e0; +llc_ll_feature_rsp_pdu_send = 0x400009e4; +llc_ll_length_req_pdu_send = 0x400009e8; +llc_ll_length_rsp_pdu_send = 0x400009ec; +llc_ll_pause_enc_req_pdu_send = 0x400009f0; +llc_ll_pause_enc_rsp_pdu_send = 0x400009f4; +llc_ll_phy_req_pdu_send = 0x400009f8; +llc_ll_phy_rsp_pdu_send = 0x400009fc; +llc_ll_ping_req_pdu_send = 0x40000a00; +llc_ll_ping_rsp_pdu_send = 0x40000a04; +llc_ll_start_enc_req_pdu_send = 0x40000a08; +llc_ll_start_enc_rsp_pdu_send = 0x40000a0c; +llc_ll_terminate_ind_pdu_send = 0x40000a10; +llc_ll_unknown_rsp_pdu_send = 0x40000a14; +llc_llcp_ch_map_update_ind_pdu_send = 0x40000a18; +llc_llcp_phy_upd_ind_pdu_send = 0x40000a1c; +llc_llcp_version_ind_pdu_send = 0x40000a20; +llc_op_ch_map_upd_ind_handler = 0x40000a24; +llc_op_con_upd_ind_handler = 0x40000a28; +llc_op_disconnect_ind_handler = 0x40000a2c; +llc_op_dl_upd_ind_handler = 0x40000a30; +llc_op_encrypt_ind_handler = 0x40000a34; +llc_op_feats_exch_ind_handler = 0x40000a38; +llc_op_le_ping_ind_handler = 0x40000a3c; +llc_op_phy_upd_ind_handler = 0x40000a40; +llc_op_ver_exch_ind_handler = 0x40000a44; +llc_stopped_ind_handler = 0x40000a48; +lld_acl_rx_ind_handler = 0x40000a4c; +lld_acl_tx_cfm_handler = 0x40000a50; +lld_adv_end_ind_handler = 0x40000a54; +lld_adv_rep_ind_handler = 0x40000a58; +lld_ch_map_upd_cfm_handler = 0x40000a5c; +lld_con_estab_ind_handler = 0x40000a60; +lld_con_evt_sd_evt_time_set = 0x40000a64; +lld_con_offset_upd_ind_handler = 0x40000a68; +lld_con_param_upd_cfm_handler = 0x40000a6c; +lld_disc_ind_handler = 0x40000a70; +lld_init_end_ind_handler = 0x40000a74; +lld_llcp_rx_ind_handler_wrapper = 0x40000a78; +lld_llcp_tx_cfm_handler = 0x40000a7c; +lld_per_adv_end_ind_handler = 0x40000a80; +lld_per_adv_rep_ind_handler = 0x40000a84; +lld_per_adv_rx_end_ind_handler = 0x40000a88; +lld_phy_coded_500k_get = 0x40000a8c; +lld_phy_upd_cfm_handler = 0x40000a90; +lld_scan_end_ind_handler = 0x40000a94; +lld_scan_req_ind_handler = 0x40000a98; +lld_sync_start_req_handler = 0x40000a9c; +lld_test_end_ind_handler = 0x40000aa0; +lld_update_rxbuf_handler = 0x40000aa4; +llm_ch_map_update_ind_handler = 0x40000aa8; +llm_hci_command_handler_wrapper = 0x40000aac; +llm_scan_period_to_handler = 0x40000ab0; +r_Add2SelfBigHex256 = 0x40000ab4; +r_AddBigHex256 = 0x40000ab8; +r_AddBigHexModP256 = 0x40000abc; +r_AddP256 = 0x40000ac0; +r_AddPdiv2_256 = 0x40000ac4; +r_GF_Jacobian_Point_Addition256 = 0x40000ac8; +r_GF_Jacobian_Point_Double256 = 0x40000acc; +r_GF_Point_Jacobian_To_Affine256 = 0x40000ad0; +r_MultiplyBigHexByUint32_256 = 0x40000ad4; +r_MultiplyBigHexModP256 = 0x40000ad8; +r_MultiplyByU16ModP256 = 0x40000adc; +r_SubtractBigHex256 = 0x40000ae0; +r_SubtractBigHexMod256 = 0x40000ae4; +r_SubtractBigHexUint32_256 = 0x40000ae8; +r_SubtractFromSelfBigHex256 = 0x40000aec; +r_SubtractFromSelfBigHexSign256 = 0x40000af0; +r_aes_alloc = 0x40000af4; +r_aes_ccm_continue = 0x40000af8; +r_aes_ccm_process_e = 0x40000afc; +r_aes_ccm_xor_128_lsb = 0x40000b00; +r_aes_ccm_xor_128_msb = 0x40000b04; +r_aes_cmac_continue = 0x40000b08; +r_aes_cmac_start = 0x40000b0c; +r_aes_k1_continue = 0x40000b10; +r_aes_k2_continue = 0x40000b14; +r_aes_k3_continue = 0x40000b18; +r_aes_k4_continue = 0x40000b1c; +r_aes_shift_left_128 = 0x40000b20; +r_aes_start = 0x40000b24; +r_aes_xor_128 = 0x40000b28; +r_assert_err = 0x40000b2c; +r_assert_param = 0x40000b30; +r_assert_warn = 0x40000b34; +r_bigHexInversion256 = 0x40000b38; +r_ble_sw_cca_check_isr = 0x40000b3c; +r_ble_util_buf_acl_tx_alloc = 0x40000b40; +r_ble_util_buf_acl_tx_elt_get = 0x40000b44; +r_ble_util_buf_acl_tx_free = 0x40000b48; +r_ble_util_buf_acl_tx_free_in_isr = 0x40000b4c; +r_ble_util_buf_adv_tx_alloc = 0x40000b50; +r_ble_util_buf_adv_tx_free = 0x40000b54; +r_ble_util_buf_adv_tx_free_in_isr = 0x40000b58; +r_ble_util_buf_env_deinit = 0x40000b5c; +r_ble_util_buf_env_init = 0x40000b60; +r_ble_util_buf_get_rx_buf_nb = 0x40000b64; +r_ble_util_buf_get_rx_buf_size = 0x40000b68; +r_ble_util_buf_llcp_tx_alloc = 0x40000b6c; +r_ble_util_buf_llcp_tx_free = 0x40000b70; +r_ble_util_buf_rx_alloc = 0x40000b74; +r_ble_util_buf_rx_alloc_in_isr = 0x40000b78; +r_ble_util_buf_rx_free = 0x40000b7c; +r_ble_util_buf_rx_free_in_isr = 0x40000b80; +r_ble_util_buf_set_rx_buf_nb = 0x40000b84; +r_ble_util_buf_set_rx_buf_size = 0x40000b88; +r_ble_util_data_rx_buf_reset = 0x40000b8c; +r_bt_bb_get_intr_mask = 0x40000b90; +r_bt_bb_intr_clear = 0x40000b94; +r_bt_bb_intr_mask_set = 0x40000b98; +r_bt_rf_coex_cfg_set = 0x40000ba0; +r_bt_rf_coex_conn_dynamic_pti_en_get = 0x40000ba4; +r_bt_rf_coex_ext_adv_dynamic_pti_en_get = 0x40000bac; +r_bt_rf_coex_ext_scan_dynamic_pti_en_get = 0x40000bb0; +r_bt_rf_coex_legacy_adv_dynamic_pti_en_get = 0x40000bb4; +r_bt_rf_coex_per_adv_dynamic_pti_en_get = 0x40000bb8; +r_bt_rf_coex_pti_table_get = 0x40000bbc; +r_bt_rf_coex_st_param_get = 0x40000bc0; +r_bt_rf_coex_st_param_set = 0x40000bc4; +r_bt_rf_coex_sync_scan_dynamic_pti_en_get = 0x40000bc8; +r_bt_rma_apply_rule_cs_fmt = 0x40000bcc; +r_bt_rma_apply_rule_cs_idx = 0x40000bd0; +r_bt_rma_configure = 0x40000bd4; +r_bt_rma_deregister_rule_cs_fmt = 0x40000bd8; +r_bt_rma_deregister_rule_cs_idx = 0x40000bdc; +r_bt_rma_get_ant_by_act = 0x40000be0; +r_bt_rma_init = 0x40000be4; +r_bt_rma_register_rule_cs_fmt = 0x40000be8; +r_bt_rma_register_rule_cs_idx = 0x40000bec; +r_bt_rtp_apply_rule_cs_fmt = 0x40000bf0; +r_bt_rtp_apply_rule_cs_idx = 0x40000bf4; +r_bt_rtp_deregister_rule_cs_fmt = 0x40000bf8; +r_bt_rtp_deregister_rule_cs_idx = 0x40000bfc; +r_bt_rtp_init = 0x40000c04; +r_bt_rtp_register_rule_cs_fmt = 0x40000c08; +r_bt_rtp_register_rule_cs_idx = 0x40000c0c; +r_btdm_isr = 0x40000c10; +r_cali_phase_match_p = 0x40000c20; +r_cmp_abs_time = 0x40000c24; +r_cmp_dest_id = 0x40000c28; +r_cmp_timer_id = 0x40000c2c; +r_co_bdaddr_compare = 0x40000c30; +r_co_ble_pkt_dur_in_us = 0x40000c34; +r_co_list_extract = 0x40000c38; +r_co_list_extract_after = 0x40000c3c; +r_co_list_extract_sublist = 0x40000c40; +r_co_list_find = 0x40000c44; +r_co_list_init = 0x40000c48; +r_co_list_insert_after = 0x40000c4c; +r_co_list_insert_before = 0x40000c50; +r_co_list_merge = 0x40000c54; +r_co_list_pool_init = 0x40000c58; +r_co_list_pop_front = 0x40000c5c; +r_co_list_push_back = 0x40000c60; +r_co_list_push_back_sublist = 0x40000c64; +r_co_list_push_front = 0x40000c68; +r_co_list_size = 0x40000c6c; +r_co_nb_good_le_channels = 0x40000c70; +r_co_util_pack = 0x40000c74; +r_co_util_read_array_size = 0x40000c78; +r_co_util_unpack = 0x40000c7c; +r_dbg_env_deinit = 0x40000c80; +r_dbg_env_init = 0x40000c84; +r_dbg_platform_reset_complete = 0x40000c88; +r_dl_upd_proc_start = 0x40000c8c; +r_dump_data = 0x40000c90; +r_ecc_abort_key256_generation = 0x40000c94; +r_ecc_gen_new_public_key = 0x40000c98; +r_ecc_gen_new_secret_key = 0x40000c9c; +r_ecc_generate_key256 = 0x40000ca0; +r_ecc_get_debug_Keys = 0x40000ca4; +r_ecc_init = 0x40000ca8; +r_ecc_is_valid_point = 0x40000cac; +r_ecc_multiplication_event_handler = 0x40000cb0; +r_ecc_point_multiplication_win_256 = 0x40000cb4; +r_emi_alloc_em_mapping_by_offset = 0x40000cb8; +r_emi_base_reg_lut_show = 0x40000cbc; +r_emi_em_base_reg_show = 0x40000cc0; +r_emi_free_em_mapping_by_offset = 0x40000cc4; +r_emi_get_em_mapping_idx_by_offset = 0x40000cc8; +r_emi_get_mem_addr_by_offset = 0x40000ccc; +r_emi_overwrite_em_mapping_by_offset = 0x40000cd0; +r_esp_vendor_hci_command_handler = 0x40000cd4; +r_get_stack_usage = 0x40000cd8; +r_h4tl_acl_hdr_rx_evt_handler = 0x40000cdc; +r_h4tl_cmd_hdr_rx_evt_handler = 0x40000ce0; +r_h4tl_cmd_pld_rx_evt_handler = 0x40000ce4; +r_h4tl_eif_io_event_post = 0x40000ce8; +r_h4tl_eif_register = 0x40000cec; +r_h4tl_init = 0x40000cf0; +r_h4tl_out_of_sync = 0x40000cf4; +r_h4tl_out_of_sync_check = 0x40000cf8; +r_h4tl_read_hdr = 0x40000cfc; +r_h4tl_read_next_out_of_sync = 0x40000d00; +r_h4tl_read_payl = 0x40000d04; +r_h4tl_read_start = 0x40000d08; +r_h4tl_rx_acl_hdr_extract = 0x40000d0c; +r_h4tl_rx_cmd_hdr_extract = 0x40000d10; +r_h4tl_rx_done = 0x40000d14; +r_h4tl_start = 0x40000d18; +r_h4tl_stop = 0x40000d1c; +r_h4tl_tx_done = 0x40000d20; +r_h4tl_tx_evt_handler = 0x40000d24; +r_h4tl_write = 0x40000d28; +r_hci_acl_tx_data_alloc = 0x40000d2c; +r_hci_acl_tx_data_received = 0x40000d30; +r_hci_basic_cmd_send_2_controller = 0x40000d34; +r_hci_ble_adv_report_filter_check = 0x40000d38; +r_hci_ble_adv_report_tx_check = 0x40000d3c; +r_hci_ble_conhdl_register = 0x40000d40; +r_hci_ble_conhdl_unregister = 0x40000d44; +r_hci_build_acl_data = 0x40000d48; +r_hci_build_cc_evt = 0x40000d4c; +r_hci_build_cs_evt = 0x40000d50; +r_hci_build_evt = 0x40000d54; +r_hci_build_le_evt = 0x40000d58; +r_hci_cmd_get_max_param_size = 0x40000d5c; +r_hci_cmd_received = 0x40000d60; +r_hci_cmd_reject = 0x40000d64; +r_hci_evt_mask_check = 0x40000d68; +r_hci_evt_mask_set = 0x40000d6c; +r_hci_fc_acl_buf_size_set = 0x40000d70; +r_hci_fc_acl_en = 0x40000d74; +r_hci_fc_acl_packet_sent = 0x40000d78; +r_hci_fc_check_host_available_nb_acl_packets = 0x40000d7c; +r_hci_fc_host_nb_acl_pkts_complete = 0x40000d80; +r_hci_fc_init = 0x40000d84; +r_hci_look_for_cmd_desc = 0x40000d88; +r_hci_look_for_evt_desc = 0x40000d8c; +r_hci_look_for_le_evt_desc = 0x40000d90; +r_hci_look_for_le_evt_desc_esp = 0x40000d94; +r_hci_pack_bytes = 0x40000d98; +r_hci_send_2_controller = 0x40000da0; +r_hci_send_2_host = 0x40000da4; +r_hci_tl_c2h_data_flow_on = 0x40000da8; +r_hci_tl_cmd_hdr_rx_evt_handler = 0x40000dac; +r_hci_tl_cmd_pld_rx_evt_handler = 0x40000db0; +r_hci_tl_get_pkt = 0x40000db4; +r_hci_tl_hci_pkt_handler = 0x40000db8; +r_hci_tl_hci_tx_done_evt_handler = 0x40000dbc; +r_hci_tl_inc_nb_h2c_cmd_pkts = 0x40000dc0; +r_hci_tl_save_pkt = 0x40000dc4; +r_hci_tl_send = 0x40000dc8; +r_hci_tx_done = 0x40000dcc; +r_hci_tx_start = 0x40000dd0; +r_hci_tx_trigger = 0x40000dd4; +r_isValidSecretKey_256 = 0x40000dd8; +r_ke_check_malloc = 0x40000ddc; +r_ke_event_callback_set = 0x40000de0; +r_ke_event_clear = 0x40000de4; +r_ke_event_flush = 0x40000de8; +r_ke_event_get = 0x40000dec; +r_ke_event_get_all = 0x40000df0; +r_ke_event_init = 0x40000df4; +r_ke_event_schedule = 0x40000df8; +r_ke_event_set = 0x40000dfc; +r_ke_flush = 0x40000e00; +r_ke_free = 0x40000e04; +r_ke_handler_search = 0x40000e08; +r_ke_init = 0x40000e0c; +r_ke_is_free = 0x40000e10; +r_ke_malloc = 0x40000e14; +r_ke_mem_init = 0x40000e18; +r_ke_mem_is_empty = 0x40000e1c; +r_ke_mem_is_in_heap = 0x40000e20; +r_ke_msg_alloc = 0x40000e24; +r_ke_msg_dest_id_get = 0x40000e28; +r_ke_msg_discard = 0x40000e2c; +r_ke_msg_forward = 0x40000e30; +r_ke_msg_forward_new_id = 0x40000e34; +r_ke_msg_free = 0x40000e38; +r_ke_msg_in_queue = 0x40000e3c; +r_ke_msg_save = 0x40000e40; +r_ke_msg_send = 0x40000e44; +r_ke_msg_send_basic = 0x40000e48; +r_ke_msg_src_id_get = 0x40000e4c; +r_ke_queue_extract = 0x40000e50; +r_ke_queue_insert = 0x40000e54; +r_ke_sleep_check = 0x40000e58; +r_ke_state_get = 0x40000e5c; +r_ke_state_set = 0x40000e60; +r_ke_task_check = 0x40000e64; +r_ke_task_create = 0x40000e68; +r_ke_task_delete = 0x40000e6c; +r_ke_task_handler_get = 0x40000e70; +r_ke_task_init = 0x40000e74; +r_ke_task_msg_flush = 0x40000e78; +r_ke_task_saved_update = 0x40000e7c; +r_ke_time = 0x40000e84; +r_ke_time_cmp = 0x40000e88; +r_ke_time_past = 0x40000e8c; +r_ke_timer_active = 0x40000e90; +r_ke_timer_adjust_all = 0x40000e94; +r_ke_timer_clear = 0x40000e98; +r_ke_timer_init = 0x40000e9c; +r_ke_timer_schedule = 0x40000ea0; +r_ke_timer_set = 0x40000ea4; +r_led_init = 0x40000ea8; +r_led_set_all = 0x40000eac; +r_llc_aes_res_cb = 0x40000eb0; +r_llc_ch_map_up_proc_err_cb = 0x40000eb4; +r_llc_cleanup = 0x40000eb8; +r_llc_cmd_cmp_send = 0x40000ebc; +r_llc_cmd_stat_send = 0x40000ec0; +r_llc_con_move_cbk = 0x40000ec4; +r_llc_con_plan_set_update = 0x40000ec8; +r_llc_con_upd_param_in_range = 0x40000ecc; +r_llc_disconnect = 0x40000ed0; +r_llc_disconnect_end = 0x40000ed4; +r_llc_disconnect_proc_continue = 0x40000ed8; +r_llc_disconnect_proc_err_cb = 0x40000edc; +r_llc_dl_chg_check = 0x40000ee0; +r_llc_dle_proc_err_cb = 0x40000ee4; +r_llc_feats_exch_proc_err_cb = 0x40000ee8; +r_llc_hci_cmd_handler_tab_p_get = 0x40000eec; +r_llc_hci_con_param_req_evt_send = 0x40000ef4; +r_llc_hci_con_upd_info_send = 0x40000ef8; +r_llc_hci_disconnected_dis = 0x40000efc; +r_llc_hci_dl_upd_info_send = 0x40000f00; +r_llc_hci_enc_evt_send = 0x40000f04; +r_llc_hci_feats_info_send = 0x40000f08; +r_llc_hci_le_phy_upd_cmp_evt_send = 0x40000f0c; +r_llc_hci_ltk_request_evt_send = 0x40000f10; +r_llc_hci_nb_cmp_pkts_evt_send = 0x40000f14; +r_llc_hci_version_info_send = 0x40000f18; +r_llc_init_term_proc = 0x40000f1c; +r_llc_iv_skd_rand_gen = 0x40000f20; +r_llc_le_ping_proc_continue = 0x40000f24; +r_llc_le_ping_proc_err_cb = 0x40000f28; +/* r_llc_le_ping_restart = 0x40000f2c; */ +r_llc_le_ping_set = 0x40000f30; +r_llc_ll_pause_enc_rsp_ack_handler = 0x40000f34; +r_llc_ll_reject_ind_ack_handler = 0x40000f38; +r_llc_ll_reject_ind_pdu_send = 0x40000f3c; +r_llc_ll_start_enc_rsp_ack_handler = 0x40000f40; +r_llc_ll_terminate_ind_ack = 0x40000f44; +r_llc_ll_unknown_ind_handler = 0x40000f48; +r_llc_llcp_send = 0x40000f4c; +r_llc_llcp_state_set = 0x40000f50; +r_llc_llcp_trans_timer_set = 0x40000f54; +r_llc_llcp_tx_check = 0x40000f58; +r_llc_loc_con_upd_proc_err_cb = 0x40000f64; +r_llc_loc_dl_upd_proc_continue = 0x40000f68; +r_llc_loc_encrypt_proc_continue = 0x40000f6c; +r_llc_loc_encrypt_proc_err_cb = 0x40000f70; +r_llc_loc_feats_exch_proc_continue = 0x40000f74; +r_llc_loc_phy_upd_proc_err_cb = 0x40000f7c; +r_llc_msg_handler_tab_p_get = 0x40000f80; +r_llc_pref_param_compute = 0x40000f84; +r_llc_proc_collision_check = 0x40000f88; +r_llc_proc_err_ind = 0x40000f8c; +r_llc_proc_get = 0x40000f90; +r_llc_proc_id_get = 0x40000f94; +r_llc_proc_reg = 0x40000f98; +r_llc_proc_state_get = 0x40000f9c; +r_llc_proc_state_set = 0x40000fa0; +r_llc_proc_timer_pause_set = 0x40000fa4; +r_llc_proc_timer_set = 0x40000fa8; +r_llc_proc_unreg = 0x40000fac; +r_llc_rem_ch_map_proc_continue = 0x40000fb0; +r_llc_rem_con_upd_proc_err_cb = 0x40000fb8; +r_llc_rem_dl_upd_proc = 0x40000fbc; +r_llc_rem_encrypt_proc_continue = 0x40000fc0; +r_llc_rem_encrypt_proc_err_cb = 0x40000fc4; +r_llc_rem_phy_upd_proc_continue = 0x40000fc8; +r_llc_rem_phy_upd_proc_err_cb = 0x40000fcc; +r_llc_role_get = 0x40000fd0; +r_llc_sk_gen = 0x40000fd4; +r_llc_start = 0x40000fd8; +r_llc_stop = 0x40000fdc; +r_llc_ver_exch_loc_proc_continue = 0x40000fe0; +r_llc_ver_proc_err_cb = 0x40000fe4; +r_llcp_pdu_handler_tab_p_get = 0x40000fe8; +r_lld_aa_gen = 0x40000fec; +r_lld_adv_adv_data_set = 0x40000ff0; +r_lld_adv_adv_data_update = 0x40000ff4; +r_lld_adv_aux_ch_idx_set = 0x40000ff8; +r_lld_adv_aux_evt_canceled_cbk = 0x40000ffc; +r_lld_adv_aux_evt_start_cbk = 0x40001000; +r_lld_adv_coex_check_ext_adv_synced = 0x40001004; +r_lld_adv_coex_env_reset = 0x40001008; +r_lld_adv_duration_update = 0x4000100c; +r_lld_adv_dynamic_pti_process = 0x40001010; +r_lld_adv_end = 0x40001014; +r_lld_adv_evt_canceled_cbk = 0x40001018; +r_lld_adv_evt_start_cbk = 0x4000101c; +r_lld_adv_ext_chain_construct = 0x40001020; +r_lld_adv_ext_pkt_prepare = 0x40001024; +r_lld_adv_frm_cbk = 0x40001028; +r_lld_adv_frm_isr = 0x4000102c; +r_lld_adv_frm_skip_isr = 0x40001030; +r_lld_adv_init = 0x40001034; +r_lld_adv_pkt_rx = 0x40001038; +r_lld_adv_pkt_rx_connect_ind = 0x4000103c; +r_lld_adv_pkt_rx_send_scan_req_evt = 0x40001040; +r_lld_adv_rand_addr_update = 0x40001044; +r_lld_adv_restart = 0x40001048; +r_lld_adv_scan_rsp_data_set = 0x4000104c; +r_lld_adv_scan_rsp_data_update = 0x40001050; +r_lld_adv_set_tx_power = 0x40001054; +r_lld_adv_start = 0x40001058; +r_lld_adv_stop = 0x4000105c; +r_lld_adv_sync_info_set = 0x40001060; +r_lld_adv_sync_info_update = 0x40001064; +r_lld_calc_aux_rx = 0x40001068; +r_lld_cca_alloc = 0x4000106c; +r_lld_cca_data_reset = 0x40001070; +r_lld_cca_free = 0x40001074; +r_lld_ch_assess_data_get = 0x40001078; +r_lld_ch_idx_get = 0x4000107c; +r_lld_ch_map_set = 0x40001080; +r_lld_channel_assess = 0x40001084; +r_lld_con_activity_act_offset_compute = 0x40001088; +r_lld_con_activity_offset_compute = 0x4000108c; +r_lld_con_ch_map_update = 0x40001090; +r_lld_con_cleanup = 0x40001094; +r_lld_con_current_tx_power_get = 0x40001098; +r_lld_con_data_flow_set = 0x4000109c; +r_lld_con_data_len_update = 0x400010a0; +r_lld_con_data_tx = 0x400010a4; +r_lld_con_enc_key_load = 0x400010a8; +r_lld_con_event_counter_get = 0x400010ac; +r_lld_con_evt_canceled_cbk = 0x400010b0; +r_lld_con_evt_duration_min_get = 0x400010b4; +r_lld_con_evt_max_eff_time_cal = 0x400010b8; +r_lld_con_evt_sd_evt_time_get = 0x400010bc; +r_lld_con_evt_start_cbk = 0x400010c0; +r_lld_con_evt_time_update = 0x400010c4; +r_lld_con_free_all_tx_buf = 0x400010c8; +r_lld_con_frm_cbk = 0x400010cc; +r_lld_con_frm_isr = 0x400010d0; +r_lld_con_frm_skip_isr = 0x400010d4; +r_lld_con_init = 0x400010d8; +r_lld_con_llcp_tx = 0x400010dc; +r_lld_con_max_lat_calc = 0x400010e0; +r_lld_con_offset_get = 0x400010e4; +r_lld_con_param_update = 0x400010e8; +r_lld_con_phys_update = 0x400010ec; +r_lld_con_pref_slave_evt_dur_set = 0x400010f0; +r_lld_con_pref_slave_latency_set = 0x400010f4; +r_lld_con_rssi_get = 0x400010f8; +r_lld_con_rx = 0x400010fc; +/* r_lld_con_rx_channel_assess = 0x40001100; */ +r_lld_con_rx_enc = 0x40001104; +r_lld_con_rx_isr = 0x40001108; +r_lld_con_rx_link_info_check = 0x4000110c; +r_lld_con_rx_llcp_check = 0x40001110; +r_lld_con_rx_sync_time_update = 0x40001114; +r_lld_con_set_tx_power = 0x4000111c; +r_lld_con_start = 0x40001120; +r_lld_con_tx = 0x40001128; +r_lld_con_tx_enc = 0x4000112c; +r_lld_con_tx_isr = 0x40001130; +r_lld_con_tx_len_update = 0x40001134; +r_lld_con_tx_len_update_for_intv = 0x40001138; +r_lld_con_tx_len_update_for_rate = 0x4000113c; +r_lld_con_tx_prog = 0x40001140; +r_lld_conn_dynamic_pti_process = 0x40001144; +r_lld_continue_scan_rx_isr_end_process = 0x40001148; +r_lld_ext_scan_dynamic_pti_process = 0x4000114c; +r_lld_hw_cca_end_isr = 0x40001150; +r_lld_hw_cca_evt_handler = 0x40001154; +r_lld_hw_cca_isr = 0x40001158; +r_lld_init_cal_anchor_point = 0x4000115c; +r_lld_init_compute_winoffset = 0x40001160; +r_lld_init_connect_req_pack = 0x40001164; +r_lld_init_end = 0x40001168; +r_lld_init_evt_canceled_cbk = 0x4000116c; +r_lld_init_evt_start_cbk = 0x40001170; +r_lld_init_frm_cbk = 0x40001174; +r_lld_init_frm_eof_isr = 0x40001178; +r_lld_init_frm_skip_isr = 0x4000117c; +r_lld_init_init = 0x40001180; +r_lld_init_process_pkt_rx = 0x40001184; +r_lld_init_process_pkt_rx_adv_ext_ind = 0x40001188; +r_lld_init_process_pkt_rx_adv_ind_or_direct_ind = 0x4000118c; +r_lld_init_process_pkt_rx_aux_connect_rsp = 0x40001190; +r_lld_init_process_pkt_tx = 0x40001194; +r_lld_init_process_pkt_tx_cal_con_timestamp = 0x40001198; +r_lld_init_sched = 0x4000119c; +r_lld_init_set_tx_power = 0x400011a0; +r_lld_init_start = 0x400011a4; +r_lld_init_stop = 0x400011a8; +r_lld_instant_proc_end = 0x400011ac; +r_lld_per_adv_ch_map_update = 0x400011b4; +r_lld_per_adv_chain_construct = 0x400011b8; +r_lld_per_adv_cleanup = 0x400011bc; +r_lld_per_adv_coex_env_reset = 0x400011c0; +r_lld_per_adv_data_set = 0x400011c4; +r_lld_per_adv_data_update = 0x400011c8; +r_lld_per_adv_dynamic_pti_process = 0x400011cc; +r_lld_per_adv_evt_canceled_cbk = 0x400011d0; +r_lld_per_adv_evt_start_cbk = 0x400011d4; +r_lld_per_adv_ext_pkt_prepare = 0x400011d8; +r_lld_per_adv_frm_cbk = 0x400011dc; +r_lld_per_adv_frm_isr = 0x400011e0; +r_lld_per_adv_frm_skip_isr = 0x400011e4; +r_lld_per_adv_init = 0x400011e8; +r_lld_per_adv_init_info_get = 0x400011ec; +r_lld_per_adv_list_add = 0x400011f0; +r_lld_per_adv_list_rem = 0x400011f4; +r_lld_per_adv_set_tx_power = 0x400011fc; +r_lld_per_adv_start = 0x40001200; +r_lld_per_adv_stop = 0x40001204; +r_lld_per_adv_sync_info_get = 0x40001208; +r_lld_process_cca_data = 0x4000120c; +r_lld_ral_search = 0x40001210; +r_lld_read_clock = 0x40001214; +r_lld_res_list_add = 0x40001218; +r_lld_res_list_is_empty = 0x40001220; +r_lld_res_list_local_rpa_get = 0x40001224; +r_lld_res_list_peer_rpa_get = 0x40001228; +r_lld_res_list_peer_update = 0x4000122c; +/* r_lld_res_list_priv_mode_update = 0x40001230; */ +r_lld_reset_reg = 0x40001238; +r_lld_rpa_renew = 0x4000123c; +r_lld_rpa_renew_evt_canceled_cbk = 0x40001240; +r_lld_rpa_renew_evt_start_cbk = 0x40001244; +r_lld_rpa_renew_instant_cbk = 0x40001248; +r_lld_rxdesc_check = 0x4000124c; +r_lld_rxdesc_free = 0x40001250; +r_lld_scan_create_sync = 0x40001254; +r_lld_scan_create_sync_cancel = 0x40001258; +r_lld_scan_end = 0x4000125c; +r_lld_scan_evt_canceled_cbk = 0x40001260; +r_lld_scan_evt_start_cbk = 0x40001264; +r_lld_scan_frm_cbk = 0x40001268; +r_lld_scan_frm_eof_isr = 0x4000126c; +r_lld_scan_frm_rx_isr = 0x40001270; +r_lld_scan_frm_skip_isr = 0x40001274; +r_lld_scan_init = 0x40001278; +r_lld_scan_params_update = 0x4000127c; +r_lld_scan_process_pkt_rx_aux_adv_ind = 0x40001288; +r_lld_scan_process_pkt_rx_aux_chain_ind = 0x4000128c; +r_lld_scan_process_pkt_rx_aux_scan_rsp = 0x40001290; +r_lld_scan_process_pkt_rx_ext_adv = 0x40001294; +r_lld_scan_process_pkt_rx_ext_adv_ind = 0x40001298; +r_lld_scan_process_pkt_rx_legacy_adv = 0x4000129c; +r_lld_scan_restart = 0x400012a0; +r_lld_scan_sched = 0x400012a4; +r_lld_scan_set_tx_power = 0x400012a8; +r_lld_scan_start = 0x400012ac; +r_lld_scan_stop = 0x400012b0; +r_lld_scan_sync_accept = 0x400012b4; +r_lld_scan_sync_info_unpack = 0x400012b8; +r_lld_scan_trunc_ind = 0x400012bc; +r_lld_sw_cca_evt_handler = 0x400012c0; +r_lld_sw_cca_isr = 0x400012c4; +r_lld_sync_ch_map_update = 0x400012c8; +r_lld_sync_cleanup = 0x400012cc; +r_lld_sync_evt_canceled_cbk = 0x400012d0; +r_lld_sync_evt_start_cbk = 0x400012d4; +r_lld_sync_frm_cbk = 0x400012d8; +r_lld_sync_frm_eof_isr = 0x400012dc; +r_lld_sync_frm_rx_isr = 0x400012e0; +r_lld_sync_frm_skip_isr = 0x400012e4; +r_lld_sync_init = 0x400012e8; +r_lld_sync_process_pkt_rx = 0x400012ec; +r_lld_sync_process_pkt_rx_aux_sync_ind = 0x400012f0; +r_lld_sync_process_pkt_rx_pkt_check = 0x400012f4; +r_lld_sync_scan_dynamic_pti_process = 0x400012f8; +r_lld_sync_sched = 0x400012fc; +r_lld_sync_start = 0x40001300; +r_lld_sync_stop = 0x40001304; +r_lld_sync_trunc_ind = 0x40001308; +r_lld_test_cleanup = 0x4000130c; +r_lld_test_evt_canceled_cbk = 0x40001310; +r_lld_test_evt_start_cbk = 0x40001314; +r_lld_test_freq2chnl = 0x40001318; +r_lld_test_frm_cbk = 0x4000131c; +r_lld_test_frm_isr = 0x40001320; +r_lld_test_init = 0x40001324; +r_lld_test_rx_isr = 0x40001328; +r_lld_test_set_tx_power = 0x4000132c; +r_lld_test_start = 0x40001330; +/* r_lld_test_stop = 0x40001334; */ +r_lld_update_rxbuf = 0x40001338; +r_lld_update_rxbuf_isr = 0x4000133c; +r_lld_white_list_add = 0x40001340; +r_lld_white_list_rem = 0x40001344; +r_llm_activity_free_get = 0x40001348; +r_llm_activity_free_set = 0x4000134c; +r_llm_activity_syncing_get = 0x40001350; +r_llm_adv_con_len_check = 0x40001354; +r_llm_adv_hdl_to_id = 0x40001358; +r_llm_adv_rep_flow_control_check = 0x4000135c; +r_llm_adv_rep_flow_control_update = 0x40001360; +r_llm_adv_reports_list_check = 0x40001364; +r_llm_adv_set_all_release = 0x40001368; +r_llm_adv_set_dft_params = 0x4000136c; +r_llm_adv_set_release = 0x40001370; +r_llm_aes_res_cb = 0x40001374; +r_llm_ble_update_adv_flow_control = 0x40001378; +r_llm_ch_map_update = 0x4000137c; +r_llm_cmd_cmp_send = 0x40001380; +r_llm_cmd_stat_send = 0x40001384; +r_llm_dev_list_empty_entry = 0x40001388; +r_llm_dev_list_search = 0x4000138c; +r_llm_env_adv_dup_filt_deinit = 0x40001390; +r_llm_env_adv_dup_filt_init = 0x40001394; +r_llm_init_ble_adv_report_flow_contol = 0x40001398; +r_llm_is_dev_connected = 0x4000139c; +r_llm_is_dev_synced = 0x400013a0; +r_llm_is_non_con_act_ongoing_check = 0x400013a4; +r_llm_is_wl_accessible = 0x400013a8; +r_llm_le_evt_mask_check = 0x400013ac; +r_llm_link_disc = 0x400013b4; +r_llm_master_ch_map_get = 0x400013b8; +r_llm_msg_handler_tab_p_get = 0x400013bc; +r_llm_no_activity = 0x400013c0; +r_llm_per_adv_slot_dur = 0x400013c4; +r_llm_plan_elt_get = 0x400013c8; +r_llm_rx_path_comp_get = 0x400013cc; +r_llm_scan_start = 0x400013d0; +r_llm_scan_sync_acad_attach = 0x400013d4; +r_llm_scan_sync_acad_detach = 0x400013d8; +r_llm_send_adv_lost_event_to_host = 0x400013dc; +r_llm_tx_path_comp_get = 0x400013e0; +r_misc_deinit = 0x400013e4; +r_misc_free_em_buf_in_isr = 0x400013e8; +r_misc_init = 0x400013ec; +r_misc_msg_handler_tab_p_get = 0x400013f0; +r_notEqual256 = 0x400013f4; +r_phy_upd_proc_start = 0x400013f8; +r_platform_reset = 0x400013fc; +r_rf_em_init = 0x40001404; +r_rf_force_agc_enable = 0x40001408; +r_rf_reg_rd = 0x4000140c; +r_rf_reg_wr = 0x40001410; +r_rf_reset = 0x40001414; +r_rf_rssi_convert = 0x40001418; +r_rf_rw_v9_le_disable = 0x4000141c; +r_rf_rw_v9_le_enable = 0x40001420; +r_rf_sleep = 0x40001424; +r_rf_util_cs_fmt_convert = 0x40001430; +r_rw_crypto_aes_ccm = 0x40001434; +r_rw_crypto_aes_encrypt = 0x40001438; +r_rw_crypto_aes_init = 0x4000143c; +r_rw_crypto_aes_k1 = 0x40001440; +r_rw_crypto_aes_k2 = 0x40001444; +r_rw_crypto_aes_k3 = 0x40001448; +r_rw_crypto_aes_k4 = 0x4000144c; +r_rw_crypto_aes_rand = 0x40001450; +r_rw_crypto_aes_result_handler = 0x40001454; +r_rw_crypto_aes_s1 = 0x40001458; +r_rw_cryto_aes_cmac = 0x4000145c; +r_rw_v9_init_em_radio_table = 0x40001460; +r_rwble_sleep_enter = 0x40001468; +r_rwble_sleep_wakeup_end = 0x4000146c; +/* r_rwbtdm_isr_wrapper = 0x40001470; */ +r_rwip_active_check = 0x40001474; +r_rwip_aes_encrypt = 0x40001478; +/* r_rwip_assert = 0x4000147c; */ +r_rwip_crypt_evt_handler = 0x40001480; +r_rwip_crypt_isr_handler = 0x40001484; +r_rwip_eif_get = 0x40001488; +r_rwip_half_slot_2_lpcycles = 0x4000148c; +r_rwip_hus_2_lpcycles = 0x40001490; +r_rwip_isr = 0x40001494; +r_rwip_lpcycles_2_hus = 0x40001498; +r_rwip_prevent_sleep_clear = 0x4000149c; +r_rwip_prevent_sleep_set = 0x400014a0; +r_rwip_schedule = 0x400014a4; +r_rwip_sleep = 0x400014a8; +r_rwip_sw_int_handler = 0x400014ac; +r_rwip_sw_int_req = 0x400014b0; +r_rwip_time_get = 0x400014b4; +r_rwip_timer_10ms_handler = 0x400014b8; +r_rwip_timer_10ms_set = 0x400014bc; +r_rwip_timer_hs_handler = 0x400014c0; +r_rwip_timer_hs_set = 0x400014c4; +r_rwip_timer_hus_handler = 0x400014c8; +r_rwip_timer_hus_set = 0x400014cc; +r_rwip_wakeup = 0x400014d0; +/* r_rwip_wakeup_end = 0x400014d4; */ +r_rwip_wlcoex_set = 0x400014d8; +r_sch_alarm_clear = 0x400014dc; +r_sch_alarm_init = 0x400014e0; +r_sch_alarm_prog = 0x400014e4; +r_sch_alarm_set = 0x400014e8; +r_sch_alarm_timer_isr = 0x400014ec; +r_sch_arb_conflict_check = 0x400014f0; +r_sch_arb_elt_cancel = 0x400014f4; +r_sch_arb_init = 0x400014fc; +r_sch_arb_insert = 0x40001500; +r_sch_arb_prog_timer = 0x40001504; +r_sch_arb_remove = 0x40001508; +r_sch_arb_sw_isr = 0x4000150c; +r_sch_plan_chk = 0x40001510; +r_sch_plan_clock_wrap_offset_update = 0x40001514; +r_sch_plan_init = 0x40001518; +r_sch_plan_interval_req = 0x4000151c; +r_sch_plan_offset_max_calc = 0x40001520; +r_sch_plan_offset_req = 0x40001524; +r_sch_plan_position_range_compute = 0x40001528; +r_sch_plan_rem = 0x4000152c; +r_sch_plan_req = 0x40001530; +r_sch_prog_init = 0x4000153c; +r_sch_prog_push = 0x40001540; +r_sch_prog_rx_isr = 0x40001544; +r_sch_prog_skip_isr = 0x40001548; +r_sch_prog_tx_isr = 0x4000154c; +r_sch_slice_bg_add = 0x40001550; +r_sch_slice_bg_remove = 0x40001554; +r_sch_slice_compute = 0x40001558; +r_sch_slice_fg_add = 0x4000155c; +r_sch_slice_fg_remove = 0x40001560; +r_sch_slice_init = 0x40001564; +r_sch_slice_per_add = 0x40001568; +r_sch_slice_per_remove = 0x4000156c; +r_sdk_config_get_bt_sleep_enable = 0x40001570; +r_sdk_config_get_hl_derived_opts = 0x40001574; +r_sdk_config_get_opts = 0x40001578; +r_sdk_config_get_priv_opts = 0x4000157c; +r_sdk_config_set_bt_sleep_enable = 0x40001580; +r_sdk_config_set_hl_derived_opts = 0x40001584; +r_sdk_config_set_opts = 0x40001588; +r_specialModP256 = 0x4000158c; +r_unloaded_area_init = 0x40001590; +r_vhci_flow_off = 0x40001594; +r_vhci_flow_on = 0x40001598; +r_vhci_notify_host_send_available = 0x4000159c; +r_vhci_send_to_host = 0x400015a0; +r_vnd_hci_command_handler = 0x400015a4; +r_vshci_init = 0x400015a8; +vnd_hci_command_handler_wrapper = 0x400015ac; + +/* bluetooth hook funcs */ +r_llc_loc_encrypt_proc_continue_hook = 0x40001c60; +r_llc_loc_phy_upd_proc_continue_hook = 0x40001c64; +r_llc_rem_phy_upd_proc_continue_hook = 0x40001c68; +r_lld_scan_frm_eof_isr_hook = 0x40001c6c; +r_lld_scan_evt_start_cbk_hook = 0x40001c70; +r_lld_scan_process_pkt_rx_ext_adv_hook = 0x40001c78; +r_lld_scan_sched_hook = 0x40001c7c; +r_lld_adv_evt_start_cbk_hook = 0x40001c84; +r_lld_adv_aux_evt_start_cbk_hook = 0x40001c88; +r_lld_adv_frm_isr_hook = 0x40001c8c; +r_lld_adv_start_init_evt_param_hook = 0x40001c90; +r_lld_con_evt_canceled_cbk_hook = 0x40001c94; +r_lld_con_frm_isr_hook = 0x40001c98; +r_lld_con_tx_hook = 0x40001c9c; +r_lld_con_rx_hook = 0x40001ca0; +r_lld_con_evt_start_cbk_hook = 0x40001ca4; +r_lld_con_tx_prog_new_packet_hook = 0x40001cac; +r_lld_init_frm_eof_isr_hook = 0x40001cb0; +r_lld_init_evt_start_cbk_hook = 0x40001cb4; +r_lld_init_sched_hook = 0x40001cbc; +r_lld_init_process_pkt_tx_hook = 0x40001cc0; +r_lld_per_adv_evt_start_cbk_hook = 0x40001cc4; +r_lld_per_adv_frm_isr_hook = 0x40001cc8; +r_lld_per_adv_start_hook = 0x40001ccc; +r_lld_sync_frm_eof_isr_hook = 0x40001cd0; +r_lld_sync_evt_start_cbk_hook = 0x40001cd4; +r_lld_sync_start_hook = 0x40001cd8; +r_lld_sync_process_pkt_rx_pkt_check_hook = 0x40001cdc; +r_sch_arb_insert_hook = 0x40001ce0; +r_sch_plan_offset_req_hook = 0x40001ce4; diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld index 3568b2d6e8..edad2237dc 100644 --- a/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld @@ -44,38 +44,6 @@ ppProcTxCallback = 0x40001b30; ieee80211_gettid = 0x40001b34; -/*************************************** - Group eco3_bluetooth - ***************************************/ - -/* Functions */ -r_lld_legacy_adv_dynamic_pti_get = 0x40001b38; -r_lld_legacy_adv_dynamic_pti_process = 0x40001b3c; -r_lld_ext_adv_dynamic_pti_get = 0x40001b40; -r_lld_ext_adv_dynamic_aux_pti_process = 0x40001b44; -r_lld_ext_adv_dynamic_pti_process = 0x40001b48; -r_lld_adv_ext_pkt_prepare_set = 0x40001b4c; -r_lld_adv_ext_chain_connectable_construct = 0x40001b54; -r_lld_adv_pkt_rx_connect_post = 0x40001b5c; -r_lld_adv_start_init_evt_param = 0x40001b60; -r_lld_adv_start_set_cs = 0x40001b64; -/* r_lld_adv_start_update_filter_policy = 0x40001b68; */ -r_lld_adv_start_schedule_asap = 0x40001b6c; -r_lld_con_tx_prog_new_packet_coex = 0x40001b70; -r_lld_per_adv_dynamic_pti_get = 0x40001b78; -r_lld_per_adv_evt_start_chm_upd = 0x40001b7c; -r_lld_ext_scan_dynamic_pti_get = 0x40001b80; -r_lld_sync_insert = 0x40001b88; -r_sch_prog_ble_push = 0x40001b8c; -r_sch_prog_bt_push = 0x40001b90; -r_lld_init_evt_end_type_set = 0x40001b94; -r_lld_init_evt_end_type_get = 0x40001b98; -r_lld_adv_direct_adv_use_rpa_addr_state_set = 0x40001b9c; -r_lld_adv_direct_adv_use_rpa_addr_state_get = 0x40001ba0; -r_lld_init_evt_end_type_check_state_set = 0x40001ba4; -r_lld_init_evt_end_type_check_state_get = 0x40001ba8; - - /*************************************** Group eco3_phy ***************************************/ diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3_bt_funcs.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3_bt_funcs.ld new file mode 100644 index 0000000000..ae2b9ecdcc --- /dev/null +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3_bt_funcs.ld @@ -0,0 +1,41 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* +ESP32C3 ECO3 ROM address table +Version 3 API's imported from the ROM +*/ + + +/*************************************** + Group eco3_bluetooth + ***************************************/ + +/* Functions */ +r_lld_legacy_adv_dynamic_pti_get = 0x40001b38; +r_lld_legacy_adv_dynamic_pti_process = 0x40001b3c; +r_lld_ext_adv_dynamic_pti_get = 0x40001b40; +r_lld_ext_adv_dynamic_aux_pti_process = 0x40001b44; +r_lld_ext_adv_dynamic_pti_process = 0x40001b48; +r_lld_adv_ext_pkt_prepare_set = 0x40001b4c; +r_lld_adv_ext_chain_connectable_construct = 0x40001b54; +r_lld_adv_pkt_rx_connect_post = 0x40001b5c; +r_lld_adv_start_init_evt_param = 0x40001b60; +r_lld_adv_start_set_cs = 0x40001b64; +/* r_lld_adv_start_update_filter_policy = 0x40001b68; */ +r_lld_adv_start_schedule_asap = 0x40001b6c; +r_lld_con_tx_prog_new_packet_coex = 0x40001b70; +r_lld_per_adv_dynamic_pti_get = 0x40001b78; +r_lld_per_adv_evt_start_chm_upd = 0x40001b7c; +r_lld_ext_scan_dynamic_pti_get = 0x40001b80; +r_lld_sync_insert = 0x40001b88; +r_sch_prog_ble_push = 0x40001b8c; +r_sch_prog_bt_push = 0x40001b90; +r_lld_init_evt_end_type_set = 0x40001b94; +r_lld_init_evt_end_type_get = 0x40001b98; +r_lld_adv_direct_adv_use_rpa_addr_state_set = 0x40001b9c; +r_lld_adv_direct_adv_use_rpa_addr_state_get = 0x40001ba0; +r_lld_init_evt_end_type_check_state_set = 0x40001ba4; +r_lld_init_evt_end_type_check_state_get = 0x40001ba8; diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.eco7.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.eco7.ld index 893c20604a..41445a1b54 100644 --- a/components/esp_rom/esp32c3/ld/esp32c3.rom.eco7.ld +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.eco7.ld @@ -27,7 +27,7 @@ ppProcTxSecFrame = 0x400016dc; /*ppRxFragmentProc = 0x40001704;*/ /* rcGetSched = 0x40001764;*/ rcTxUpdatePer = 0x40001770; -rcUpdateTxDone = 0x4000177c; +/*rcUpdateTxDone = 0x4000177c;*/ wDevCheckBlockError = 0x400017b4; /* wDev_IndicateFrame = 0x400017c8;*/ wDev_ProcessFiq = 0x400017f0; @@ -93,132 +93,6 @@ rom1_phy_close_rf = 0x40001c18; uart_tx_switch = 0x40001c44; -/*************************************** - Group eco7_bluetooth - ***************************************/ - -/* Functions */ -r_lld_con_count_get = 0x40001c48; -r_lld_update_con_offset = 0x40001c4c; -r_lld_con_update_last_clock = 0x40001c50; -r_lld_con_llcp_ind_info_clear = 0x40001c54; -r_lld_con_update_terminte_info_init = 0x40001c58; -r_lld_con_terminate_max_evt_update = 0x40001c5c; -r_llc_pref_param_compute_eco = 0x40001ce8; -r_llc_hci_con_upd_info_send_eco = 0x40001cec; -r_llc_rem_encrypt_proc_continue_eco = 0x40001cf0; -r_llc_start_eco = 0x40001cf8; -r_lld_ext_adv_dynamic_aux_pti_process_eco = 0x40001cfc; -r_lld_adv_start_eco = 0x40001d04; -r_lld_con_evt_canceled_cbk_eco = 0x40001d08; -r_lld_con_evt_time_update_eco = 0x40001d0c; -r_lld_con_start_eco = 0x40001d10; -r_lld_con_frm_isr_eco = 0x40001d14; -r_lld_con_tx_eco = 0x40001d18; -r_lld_ext_scan_dynamic_pti_process_eco = 0x40001d28; -r_lld_scan_frm_eof_isr_eco = 0x40001d2c; -r_lld_sync_start_eco = 0x40001d30; -r_lld_sync_insert_eco = 0x40001d34; -r_llm_adv_rep_flow_control_update_eco = 0x40001d38; -r_llm_env_adv_dup_filt_init_eco = 0x40001d3c; -r_llm_env_adv_dup_filt_deinit_eco = 0x40001d40; -r_llm_adv_rep_flow_control_check_eco = 0x40001d44; -r_llm_scan_start_eco = 0x40001d48; -r_llm_update_duplicate_scan_count = 0x40001d4c; -r_llc_hci_command_handler_pre = 0x40001d50; -r_llc_hci_command_handler_get = 0x40001d54; -r_llc_hci_command_handler_search = 0x40001d58; -r_llc_llcp_pdu_handler_get_overwrite = 0x40001d5c; -r_llc_llcp_pdu_handler_pre = 0x40001d60; -r_llc_llcp_pdu_handler_end = 0x40001d64; -r_llc_con_conflict_check = 0x40001d6c; -r_sch_prog_hw_reset_try = 0x40001d70; -r_sch_prog_et_state_reset = 0x40001d74; -r_sch_prog_end_isr_handler = 0x40001d78; -r_sch_plan_conflict_check = 0x40001d7c; -r_rwble_isr_hw_fixed = 0x40001d80; -r_bt_bb_recorrect_is_dead = 0x40001d84; -r_bt_bb_restart_hw_recorrect = 0x40001d88; -r_ke_task_handler_pre = 0x40001da0; -r_ke_task_handler_end = 0x40001da4; -r_lld_scan_frm_skip_isr_eco = 0x40001db0; -r_lld_ext_scan_dynamic_pti_reset = 0x40001db4; -r_llc_rem_phy_upd_proc_continue_eco = 0x40001db8; -r_llm_get_preferred_phys = 0x40001dbc; -r_lld_hw_cca_isr_eco = 0x40001dc0; -r_lld_sw_cca_isr_eco = 0x40001dc4; -r_lld_cca_chan_prn_e = 0x40001dc8; -r_lld_cca_chan_prn_s = 0x40001dcc; -r_lld_cca_chan_sel_remap = 0x40001dd0; -r_lld_cca_chan_sel_1 = 0x40001dd4; -r_lld_cca_chan_sel_2 = 0x40001dd8; -r_lld_cca_set_thresh = 0x40001ddc; -r_lld_cca_con_start = 0x40001de0; -r_lld_cca_con_end = 0x40001de4; -r_lld_cca_chm_restore = 0x40001de8; -r_lld_cca_chan_unused_check = 0x40001dec; -r_lld_cca_chm_update_check = 0x40001df0; -r_lld_cca_busy_mode_handle = 0x40001df4; -r_lld_cca_lbt_handle = 0x40001df8; -r_lld_cca_scst_timeout_check = 0x40001dfc; -r_lld_cca_chan_avl_timeout_check = 0x40001e00; - -r_lld_con_start_hook = 0x40001ca8; - -/* ble Functions eco */ -r_bt_bb_isr = 0x40000b9c; -r_bt_rf_coex_conn_phy_coded_data_time_limit_en_get = 0x40000ba8; -r_bt_rtp_get_txpwr_idx_by_act = 0x40000c00; -r_btdm_task_post = 0x40000c14; -r_btdm_task_post_from_isr = 0x40000c18; -r_btdm_task_recycle = 0x40000c1c; -r_hci_register_vendor_desc_tab = 0x40000d9c; -r_ke_task_schedule = 0x40000e80; -r_llc_hci_command_handler = 0x40000ef0; -r_llc_loc_ch_map_proc_continue = 0x40000f5c; -r_llc_loc_con_upd_proc_continue = 0x40000f60; -r_llc_loc_phy_upd_proc_continue = 0x40000f78; -r_llc_rem_con_upd_proc_continue = 0x40000fb4; -r_lld_con_sched = 0x40001118; -r_lld_con_stop = 0x40001124; -r_lld_llcp_rx_ind_handler = 0x400011b0; -r_lld_per_adv_sched = 0x400011f8; -r_lld_scan_process_pkt_rx_adv_rep = 0x40001284; -r_register_esp_vendor_cmd_handler = 0x40001400; -r_rf_txpwr_cs_get = 0x40001428; -r_rf_txpwr_dbm_get = 0x4000142c; -r_sch_arb_event_start_isr = 0x400014f8; -r_sch_plan_set = 0x40001534; -r_sch_prog_end_isr = 0x40001538; -r_lld_adv_ext_chain_scannable_construct = 0x40001b58; - -r_lld_scan_process_pkt_rx = 0x40001280; -r_llm_le_features_get = 0x400013b0; - -/* ble functions rename */ -r_lld_init_start_hack = 0x400011a4; - -/* ble functions disable */ -/* -r_lld_adv_frm_isr_eco = 0x40001d00; -r_lld_res_list_clear = 0x40004638; -r_lld_res_list_rem = 0x40004680; -r_lld_adv_start_hook = 0x40001c80; -r_lld_con_evt_start_cbk_eco = 0x40001d1c; -r_lld_con_tx_prog_new_packet = 0x40001b74; -r_lld_adv_ext_chain_none_construct = 0x40001b50; -r_llc_llcp_send_eco = 0x40001cf4; -r_llc_llcp_channel_map_ind_ack = 0x40001d68; -r_rwble_isr = 0x40001464; -r_lld_scan_start_eco = 0x40001d24; -r_lld_scan_try_sched_eco = 0x40001dac; -r_lld_scan_start_hook = 0x40001c74; -r_lld_init_start_hook = 0x40001cb8; -r_lld_scan_evt_start_cbk_eco = 0x40001d20; -r_ke_task_handler_get_overwrite = 0x40001da8; -*/ - - /*************************************** Group eco7_phy ***************************************/ diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.eco7_bt_funcs.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.eco7_bt_funcs.ld new file mode 100644 index 0000000000..33b0ed595d --- /dev/null +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.eco7_bt_funcs.ld @@ -0,0 +1,130 @@ +/* + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/*************************************** + Group eco7_bluetooth + ***************************************/ + +/* Functions */ +r_lld_con_count_get = 0x40001c48; +r_lld_update_con_offset = 0x40001c4c; +r_lld_con_update_last_clock = 0x40001c50; +r_lld_con_llcp_ind_info_clear = 0x40001c54; +r_lld_con_update_terminte_info_init = 0x40001c58; +r_lld_con_terminate_max_evt_update = 0x40001c5c; +r_llc_pref_param_compute_eco = 0x40001ce8; +r_llc_hci_con_upd_info_send_eco = 0x40001cec; +r_llc_rem_encrypt_proc_continue_eco = 0x40001cf0; +r_llc_start_eco = 0x40001cf8; +r_lld_ext_adv_dynamic_aux_pti_process_eco = 0x40001cfc; +r_lld_adv_start_eco = 0x40001d04; +r_lld_con_evt_canceled_cbk_eco = 0x40001d08; +r_lld_con_evt_time_update_eco = 0x40001d0c; +r_lld_con_start_eco = 0x40001d10; +r_lld_con_frm_isr_eco = 0x40001d14; +r_lld_con_tx_eco = 0x40001d18; +r_lld_ext_scan_dynamic_pti_process_eco = 0x40001d28; +r_lld_scan_frm_eof_isr_eco = 0x40001d2c; +r_lld_sync_start_eco = 0x40001d30; +r_lld_sync_insert_eco = 0x40001d34; +r_llm_adv_rep_flow_control_update_eco = 0x40001d38; +r_llm_env_adv_dup_filt_init_eco = 0x40001d3c; +r_llm_env_adv_dup_filt_deinit_eco = 0x40001d40; +r_llm_adv_rep_flow_control_check_eco = 0x40001d44; +r_llm_scan_start_eco = 0x40001d48; +r_llm_update_duplicate_scan_count = 0x40001d4c; +r_llc_hci_command_handler_pre = 0x40001d50; +r_llc_hci_command_handler_get = 0x40001d54; +r_llc_hci_command_handler_search = 0x40001d58; +r_llc_llcp_pdu_handler_pre = 0x40001d60; +r_llc_llcp_pdu_handler_end = 0x40001d64; +r_llc_con_conflict_check = 0x40001d6c; +r_sch_prog_hw_reset_try = 0x40001d70; +r_sch_prog_et_state_reset = 0x40001d74; +r_sch_prog_end_isr_handler = 0x40001d78; +r_sch_plan_conflict_check = 0x40001d7c; +r_rwble_isr_hw_fixed = 0x40001d80; +r_bt_bb_recorrect_is_dead = 0x40001d84; +r_bt_bb_restart_hw_recorrect = 0x40001d88; +r_ke_task_handler_pre = 0x40001da0; +r_ke_task_handler_end = 0x40001da4; +r_lld_scan_frm_skip_isr_eco = 0x40001db0; +r_lld_ext_scan_dynamic_pti_reset = 0x40001db4; +r_llc_rem_phy_upd_proc_continue_eco = 0x40001db8; +r_llm_get_preferred_phys = 0x40001dbc; +r_lld_hw_cca_isr_eco = 0x40001dc0; +r_lld_sw_cca_isr_eco = 0x40001dc4; +r_lld_cca_chan_prn_e = 0x40001dc8; +r_lld_cca_chan_prn_s = 0x40001dcc; +r_lld_cca_chan_sel_remap = 0x40001dd0; +r_lld_cca_chan_sel_1 = 0x40001dd4; +r_lld_cca_chan_sel_2 = 0x40001dd8; +r_lld_cca_set_thresh = 0x40001ddc; +r_lld_cca_con_start = 0x40001de0; +r_lld_cca_con_end = 0x40001de4; +r_lld_cca_chm_restore = 0x40001de8; +r_lld_cca_chan_unused_check = 0x40001dec; +r_lld_cca_chm_update_check = 0x40001df0; +r_lld_cca_busy_mode_handle = 0x40001df4; +r_lld_cca_lbt_handle = 0x40001df8; +r_lld_cca_scst_timeout_check = 0x40001dfc; +r_lld_cca_chan_avl_timeout_check = 0x40001e00; + +r_lld_con_start_hook = 0x40001ca8; + +/* ble Functions eco */ +r_bt_bb_isr = 0x40000b9c; +r_bt_rf_coex_conn_phy_coded_data_time_limit_en_get = 0x40000ba8; +r_bt_rtp_get_txpwr_idx_by_act = 0x40000c00; +r_btdm_task_post = 0x40000c14; +r_btdm_task_post_from_isr = 0x40000c18; +r_btdm_task_recycle = 0x40000c1c; +r_ke_task_schedule = 0x40000e80; +r_llc_hci_command_handler = 0x40000ef0; +r_llc_loc_ch_map_proc_continue = 0x40000f5c; +r_llc_loc_con_upd_proc_continue = 0x40000f60; +r_llc_loc_phy_upd_proc_continue = 0x40000f78; +r_llc_rem_con_upd_proc_continue = 0x40000fb4; +r_lld_con_sched = 0x40001118; +r_lld_con_stop = 0x40001124; +r_lld_llcp_rx_ind_handler = 0x400011b0; +r_lld_per_adv_sched = 0x400011f8; +r_rf_txpwr_cs_get = 0x40001428; +r_rf_txpwr_dbm_get = 0x4000142c; +r_sch_arb_event_start_isr = 0x400014f8; +r_sch_plan_set = 0x40001534; +r_sch_prog_end_isr = 0x40001538; +r_lld_adv_ext_chain_scannable_construct = 0x40001b58; + +r_lld_scan_process_pkt_rx = 0x40001280; +r_llm_le_features_get = 0x400013b0; + +/* ble functions rename */ +r_lld_init_start_hack = 0x400011a4; + +/* ble functions disable */ +/* +r_lld_adv_frm_isr_eco = 0x40001d00; +r_lld_res_list_clear = 0x40004638; +r_lld_res_list_rem = 0x40004680; +r_lld_adv_start_hook = 0x40001c80; +r_lld_con_evt_start_cbk_eco = 0x40001d1c; +r_lld_con_tx_prog_new_packet = 0x40001b74; +r_lld_adv_ext_chain_none_construct = 0x40001b50; +r_llc_llcp_send_eco = 0x40001cf4; +r_llc_llcp_channel_map_ind_ack = 0x40001d68; +r_rwble_isr = 0x40001464; +r_lld_scan_start_eco = 0x40001d24; +r_lld_scan_try_sched_eco = 0x40001dac; +r_lld_scan_start_hook = 0x40001c74; +r_lld_init_start_hook = 0x40001cb8; +r_lld_scan_evt_start_cbk_eco = 0x40001d20; +r_ke_task_handler_get_overwrite = 0x40001da8; +r_hci_register_vendor_desc_tab = 0x40000d9c; +r_lld_scan_process_pkt_rx_adv_rep = 0x40001284; +r_register_esp_vendor_cmd_handler = 0x40001400; +r_llc_llcp_pdu_handler_get_overwrite = 0x40001d5c; +*/ diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.ld index ba38ae9609..be86aa0a4c 100644 --- a/components/esp_rom/esp32c3/ld/esp32c3.rom.ld +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.ld @@ -525,800 +525,6 @@ PROVIDE( g_usb_print = 0x3fcdffd0 ); /*************************************** Group bluetooth ***************************************/ - -/* Functions */ -bt_rf_coex_get_dft_cfg = 0x400008dc; -bt_rf_coex_hooks_p_set = 0x400008e0; -btdm_con_maxevtime_cal_impl = 0x400008e4; -btdm_controller_get_compile_version_impl = 0x400008e8; -btdm_controller_rom_data_init = 0x400008ec; -btdm_dis_privacy_err_report_impl = 0x400008f0; -btdm_disable_adv_delay_impl = 0x400008f4; -btdm_enable_scan_continue_impl = 0x400008f8; -btdm_enable_scan_forever_impl = 0x400008fc; -btdm_get_power_state_impl = 0x40000900; -btdm_get_prevent_sleep_flag_impl = 0x40000904; -btdm_power_state_active_impl = 0x40000908; -btdm_switch_phy_coded_impl = 0x4000090c; -hci_acl_data_handler = 0x40000910; -hci_disconnect_cmd_handler = 0x40000914; -hci_le_con_upd_cmd_handler = 0x40000918; -hci_le_ltk_req_neg_reply_cmd_handler = 0x4000091c; -hci_le_ltk_req_reply_cmd_handler = 0x40000920; -hci_le_rd_chnl_map_cmd_handler = 0x40000924; -hci_le_rd_phy_cmd_handler = 0x40000928; -hci_le_rd_rem_feats_cmd_handler = 0x4000092c; -hci_le_rem_con_param_req_neg_reply_cmd_handler = 0x40000930; -hci_le_rem_con_param_req_reply_cmd_handler = 0x40000934; -hci_le_set_data_len_cmd_handler = 0x40000938; -hci_le_set_phy_cmd_handler = 0x4000093c; -hci_le_start_enc_cmd_handler = 0x40000940; -hci_rd_auth_payl_to_cmd_handler = 0x40000944; -hci_rd_rem_ver_info_cmd_handler = 0x40000948; -hci_rd_rssi_cmd_handler = 0x4000094c; -hci_rd_tx_pwr_lvl_cmd_handler = 0x40000950; -hci_vs_set_pref_slave_evt_dur_cmd_handler = 0x40000954; -hci_vs_set_pref_slave_latency_cmd_handler = 0x40000958; -hci_wr_auth_payl_to_cmd_handler = 0x4000095c; -ll_channel_map_ind_handler = 0x40000960; -ll_connection_param_req_handler = 0x40000964; -ll_connection_param_rsp_handler = 0x40000968; -ll_connection_update_ind_handler = 0x4000096c; -ll_enc_req_handler = 0x40000970; -ll_enc_rsp_handler = 0x40000974; -ll_feature_req_handler = 0x40000978; -ll_feature_rsp_handler = 0x4000097c; -ll_length_req_handler = 0x40000980; -ll_length_rsp_handler = 0x40000984; -ll_min_used_channels_ind_handler = 0x40000988; -ll_pause_enc_req_handler = 0x4000098c; -ll_pause_enc_rsp_handler = 0x40000990; -ll_phy_req_handler = 0x40000994; -ll_phy_rsp_handler = 0x40000998; -ll_phy_update_ind_handler = 0x4000099c; -ll_ping_req_handler = 0x400009a0; -ll_ping_rsp_handler = 0x400009a4; -ll_slave_feature_req_handler = 0x400009a8; -ll_start_enc_req_handler = 0x400009ac; -ll_start_enc_rsp_handler = 0x400009b0; -ll_terminate_ind_handler = 0x400009b4; -ll_version_ind_handler = 0x400009b8; -llc_auth_payl_nearly_to_handler = 0x400009bc; -llc_auth_payl_real_to_handler = 0x400009c0; -llc_encrypt_ind_handler = 0x400009c4; -llc_hci_command_handler_wrapper = 0x400009c8; -llc_ll_connection_param_req_pdu_send = 0x400009cc; -llc_ll_connection_param_rsp_pdu_send = 0x400009d0; -llc_ll_connection_update_ind_pdu_send = 0x400009d4; -llc_ll_enc_req_pdu_send = 0x400009d8; -llc_ll_enc_rsp_pdu_send = 0x400009dc; -llc_ll_feature_req_pdu_send = 0x400009e0; -llc_ll_feature_rsp_pdu_send = 0x400009e4; -llc_ll_length_req_pdu_send = 0x400009e8; -llc_ll_length_rsp_pdu_send = 0x400009ec; -llc_ll_pause_enc_req_pdu_send = 0x400009f0; -llc_ll_pause_enc_rsp_pdu_send = 0x400009f4; -llc_ll_phy_req_pdu_send = 0x400009f8; -llc_ll_phy_rsp_pdu_send = 0x400009fc; -llc_ll_ping_req_pdu_send = 0x40000a00; -llc_ll_ping_rsp_pdu_send = 0x40000a04; -llc_ll_start_enc_req_pdu_send = 0x40000a08; -llc_ll_start_enc_rsp_pdu_send = 0x40000a0c; -llc_ll_terminate_ind_pdu_send = 0x40000a10; -llc_ll_unknown_rsp_pdu_send = 0x40000a14; -llc_llcp_ch_map_update_ind_pdu_send = 0x40000a18; -llc_llcp_phy_upd_ind_pdu_send = 0x40000a1c; -llc_llcp_version_ind_pdu_send = 0x40000a20; -llc_op_ch_map_upd_ind_handler = 0x40000a24; -llc_op_con_upd_ind_handler = 0x40000a28; -llc_op_disconnect_ind_handler = 0x40000a2c; -llc_op_dl_upd_ind_handler = 0x40000a30; -llc_op_encrypt_ind_handler = 0x40000a34; -llc_op_feats_exch_ind_handler = 0x40000a38; -llc_op_le_ping_ind_handler = 0x40000a3c; -llc_op_phy_upd_ind_handler = 0x40000a40; -llc_op_ver_exch_ind_handler = 0x40000a44; -llc_stopped_ind_handler = 0x40000a48; -lld_acl_rx_ind_handler = 0x40000a4c; -lld_acl_tx_cfm_handler = 0x40000a50; -lld_adv_end_ind_handler = 0x40000a54; -lld_adv_rep_ind_handler = 0x40000a58; -lld_ch_map_upd_cfm_handler = 0x40000a5c; -lld_con_estab_ind_handler = 0x40000a60; -lld_con_evt_sd_evt_time_set = 0x40000a64; -lld_con_offset_upd_ind_handler = 0x40000a68; -lld_con_param_upd_cfm_handler = 0x40000a6c; -lld_disc_ind_handler = 0x40000a70; -lld_init_end_ind_handler = 0x40000a74; -lld_llcp_rx_ind_handler_wrapper = 0x40000a78; -lld_llcp_tx_cfm_handler = 0x40000a7c; -lld_per_adv_end_ind_handler = 0x40000a80; -lld_per_adv_rep_ind_handler = 0x40000a84; -lld_per_adv_rx_end_ind_handler = 0x40000a88; -lld_phy_coded_500k_get = 0x40000a8c; -lld_phy_upd_cfm_handler = 0x40000a90; -lld_scan_end_ind_handler = 0x40000a94; -lld_scan_req_ind_handler = 0x40000a98; -lld_sync_start_req_handler = 0x40000a9c; -lld_test_end_ind_handler = 0x40000aa0; -lld_update_rxbuf_handler = 0x40000aa4; -llm_ch_map_update_ind_handler = 0x40000aa8; -llm_hci_command_handler_wrapper = 0x40000aac; -llm_scan_period_to_handler = 0x40000ab0; -r_Add2SelfBigHex256 = 0x40000ab4; -r_AddBigHex256 = 0x40000ab8; -r_AddBigHexModP256 = 0x40000abc; -r_AddP256 = 0x40000ac0; -r_AddPdiv2_256 = 0x40000ac4; -r_GF_Jacobian_Point_Addition256 = 0x40000ac8; -r_GF_Jacobian_Point_Double256 = 0x40000acc; -r_GF_Point_Jacobian_To_Affine256 = 0x40000ad0; -r_MultiplyBigHexByUint32_256 = 0x40000ad4; -r_MultiplyBigHexModP256 = 0x40000ad8; -r_MultiplyByU16ModP256 = 0x40000adc; -r_SubtractBigHex256 = 0x40000ae0; -r_SubtractBigHexMod256 = 0x40000ae4; -r_SubtractBigHexUint32_256 = 0x40000ae8; -r_SubtractFromSelfBigHex256 = 0x40000aec; -r_SubtractFromSelfBigHexSign256 = 0x40000af0; -r_aes_alloc = 0x40000af4; -r_aes_ccm_continue = 0x40000af8; -r_aes_ccm_process_e = 0x40000afc; -r_aes_ccm_xor_128_lsb = 0x40000b00; -r_aes_ccm_xor_128_msb = 0x40000b04; -r_aes_cmac_continue = 0x40000b08; -r_aes_cmac_start = 0x40000b0c; -r_aes_k1_continue = 0x40000b10; -r_aes_k2_continue = 0x40000b14; -r_aes_k3_continue = 0x40000b18; -r_aes_k4_continue = 0x40000b1c; -r_aes_shift_left_128 = 0x40000b20; -r_aes_start = 0x40000b24; -r_aes_xor_128 = 0x40000b28; -r_assert_err = 0x40000b2c; -r_assert_param = 0x40000b30; -r_assert_warn = 0x40000b34; -r_bigHexInversion256 = 0x40000b38; -r_ble_sw_cca_check_isr = 0x40000b3c; -r_ble_util_buf_acl_tx_alloc = 0x40000b40; -r_ble_util_buf_acl_tx_elt_get = 0x40000b44; -r_ble_util_buf_acl_tx_free = 0x40000b48; -r_ble_util_buf_acl_tx_free_in_isr = 0x40000b4c; -r_ble_util_buf_adv_tx_alloc = 0x40000b50; -r_ble_util_buf_adv_tx_free = 0x40000b54; -r_ble_util_buf_adv_tx_free_in_isr = 0x40000b58; -r_ble_util_buf_env_deinit = 0x40000b5c; -r_ble_util_buf_env_init = 0x40000b60; -r_ble_util_buf_get_rx_buf_nb = 0x40000b64; -r_ble_util_buf_get_rx_buf_size = 0x40000b68; -r_ble_util_buf_llcp_tx_alloc = 0x40000b6c; -r_ble_util_buf_llcp_tx_free = 0x40000b70; -r_ble_util_buf_rx_alloc = 0x40000b74; -r_ble_util_buf_rx_alloc_in_isr = 0x40000b78; -r_ble_util_buf_rx_free = 0x40000b7c; -r_ble_util_buf_rx_free_in_isr = 0x40000b80; -r_ble_util_buf_set_rx_buf_nb = 0x40000b84; -r_ble_util_buf_set_rx_buf_size = 0x40000b88; -r_ble_util_data_rx_buf_reset = 0x40000b8c; -r_bt_bb_get_intr_mask = 0x40000b90; -r_bt_bb_intr_clear = 0x40000b94; -r_bt_bb_intr_mask_set = 0x40000b98; -r_bt_rf_coex_cfg_set = 0x40000ba0; -r_bt_rf_coex_conn_dynamic_pti_en_get = 0x40000ba4; -r_bt_rf_coex_ext_adv_dynamic_pti_en_get = 0x40000bac; -r_bt_rf_coex_ext_scan_dynamic_pti_en_get = 0x40000bb0; -r_bt_rf_coex_legacy_adv_dynamic_pti_en_get = 0x40000bb4; -r_bt_rf_coex_per_adv_dynamic_pti_en_get = 0x40000bb8; -r_bt_rf_coex_pti_table_get = 0x40000bbc; -r_bt_rf_coex_st_param_get = 0x40000bc0; -r_bt_rf_coex_st_param_set = 0x40000bc4; -r_bt_rf_coex_sync_scan_dynamic_pti_en_get = 0x40000bc8; -r_bt_rma_apply_rule_cs_fmt = 0x40000bcc; -r_bt_rma_apply_rule_cs_idx = 0x40000bd0; -r_bt_rma_configure = 0x40000bd4; -r_bt_rma_deregister_rule_cs_fmt = 0x40000bd8; -r_bt_rma_deregister_rule_cs_idx = 0x40000bdc; -r_bt_rma_get_ant_by_act = 0x40000be0; -r_bt_rma_init = 0x40000be4; -r_bt_rma_register_rule_cs_fmt = 0x40000be8; -r_bt_rma_register_rule_cs_idx = 0x40000bec; -r_bt_rtp_apply_rule_cs_fmt = 0x40000bf0; -r_bt_rtp_apply_rule_cs_idx = 0x40000bf4; -r_bt_rtp_deregister_rule_cs_fmt = 0x40000bf8; -r_bt_rtp_deregister_rule_cs_idx = 0x40000bfc; -r_bt_rtp_init = 0x40000c04; -r_bt_rtp_register_rule_cs_fmt = 0x40000c08; -r_bt_rtp_register_rule_cs_idx = 0x40000c0c; -r_btdm_isr = 0x40000c10; -r_cali_phase_match_p = 0x40000c20; -r_cmp_abs_time = 0x40000c24; -r_cmp_dest_id = 0x40000c28; -r_cmp_timer_id = 0x40000c2c; -r_co_bdaddr_compare = 0x40000c30; -r_co_ble_pkt_dur_in_us = 0x40000c34; -r_co_list_extract = 0x40000c38; -r_co_list_extract_after = 0x40000c3c; -r_co_list_extract_sublist = 0x40000c40; -r_co_list_find = 0x40000c44; -r_co_list_init = 0x40000c48; -r_co_list_insert_after = 0x40000c4c; -r_co_list_insert_before = 0x40000c50; -r_co_list_merge = 0x40000c54; -r_co_list_pool_init = 0x40000c58; -r_co_list_pop_front = 0x40000c5c; -r_co_list_push_back = 0x40000c60; -r_co_list_push_back_sublist = 0x40000c64; -r_co_list_push_front = 0x40000c68; -r_co_list_size = 0x40000c6c; -r_co_nb_good_le_channels = 0x40000c70; -r_co_util_pack = 0x40000c74; -r_co_util_read_array_size = 0x40000c78; -r_co_util_unpack = 0x40000c7c; -r_dbg_env_deinit = 0x40000c80; -r_dbg_env_init = 0x40000c84; -r_dbg_platform_reset_complete = 0x40000c88; -r_dl_upd_proc_start = 0x40000c8c; -r_dump_data = 0x40000c90; -r_ecc_abort_key256_generation = 0x40000c94; -r_ecc_gen_new_public_key = 0x40000c98; -r_ecc_gen_new_secret_key = 0x40000c9c; -r_ecc_generate_key256 = 0x40000ca0; -r_ecc_get_debug_Keys = 0x40000ca4; -r_ecc_init = 0x40000ca8; -r_ecc_is_valid_point = 0x40000cac; -r_ecc_multiplication_event_handler = 0x40000cb0; -r_ecc_point_multiplication_win_256 = 0x40000cb4; -r_emi_alloc_em_mapping_by_offset = 0x40000cb8; -r_emi_base_reg_lut_show = 0x40000cbc; -r_emi_em_base_reg_show = 0x40000cc0; -r_emi_free_em_mapping_by_offset = 0x40000cc4; -r_emi_get_em_mapping_idx_by_offset = 0x40000cc8; -r_emi_get_mem_addr_by_offset = 0x40000ccc; -r_emi_overwrite_em_mapping_by_offset = 0x40000cd0; -r_esp_vendor_hci_command_handler = 0x40000cd4; -r_get_stack_usage = 0x40000cd8; -r_h4tl_acl_hdr_rx_evt_handler = 0x40000cdc; -r_h4tl_cmd_hdr_rx_evt_handler = 0x40000ce0; -r_h4tl_cmd_pld_rx_evt_handler = 0x40000ce4; -r_h4tl_eif_io_event_post = 0x40000ce8; -r_h4tl_eif_register = 0x40000cec; -r_h4tl_init = 0x40000cf0; -r_h4tl_out_of_sync = 0x40000cf4; -r_h4tl_out_of_sync_check = 0x40000cf8; -r_h4tl_read_hdr = 0x40000cfc; -r_h4tl_read_next_out_of_sync = 0x40000d00; -r_h4tl_read_payl = 0x40000d04; -r_h4tl_read_start = 0x40000d08; -r_h4tl_rx_acl_hdr_extract = 0x40000d0c; -r_h4tl_rx_cmd_hdr_extract = 0x40000d10; -r_h4tl_rx_done = 0x40000d14; -r_h4tl_start = 0x40000d18; -r_h4tl_stop = 0x40000d1c; -r_h4tl_tx_done = 0x40000d20; -r_h4tl_tx_evt_handler = 0x40000d24; -r_h4tl_write = 0x40000d28; -r_hci_acl_tx_data_alloc = 0x40000d2c; -r_hci_acl_tx_data_received = 0x40000d30; -r_hci_basic_cmd_send_2_controller = 0x40000d34; -r_hci_ble_adv_report_filter_check = 0x40000d38; -r_hci_ble_adv_report_tx_check = 0x40000d3c; -r_hci_ble_conhdl_register = 0x40000d40; -r_hci_ble_conhdl_unregister = 0x40000d44; -r_hci_build_acl_data = 0x40000d48; -r_hci_build_cc_evt = 0x40000d4c; -r_hci_build_cs_evt = 0x40000d50; -r_hci_build_evt = 0x40000d54; -r_hci_build_le_evt = 0x40000d58; -r_hci_cmd_get_max_param_size = 0x40000d5c; -r_hci_cmd_received = 0x40000d60; -r_hci_cmd_reject = 0x40000d64; -r_hci_evt_mask_check = 0x40000d68; -r_hci_evt_mask_set = 0x40000d6c; -r_hci_fc_acl_buf_size_set = 0x40000d70; -r_hci_fc_acl_en = 0x40000d74; -r_hci_fc_acl_packet_sent = 0x40000d78; -r_hci_fc_check_host_available_nb_acl_packets = 0x40000d7c; -r_hci_fc_host_nb_acl_pkts_complete = 0x40000d80; -r_hci_fc_init = 0x40000d84; -r_hci_look_for_cmd_desc = 0x40000d88; -r_hci_look_for_evt_desc = 0x40000d8c; -r_hci_look_for_le_evt_desc = 0x40000d90; -r_hci_look_for_le_evt_desc_esp = 0x40000d94; -r_hci_pack_bytes = 0x40000d98; -r_hci_send_2_controller = 0x40000da0; -r_hci_send_2_host = 0x40000da4; -r_hci_tl_c2h_data_flow_on = 0x40000da8; -r_hci_tl_cmd_hdr_rx_evt_handler = 0x40000dac; -r_hci_tl_cmd_pld_rx_evt_handler = 0x40000db0; -r_hci_tl_get_pkt = 0x40000db4; -r_hci_tl_hci_pkt_handler = 0x40000db8; -r_hci_tl_hci_tx_done_evt_handler = 0x40000dbc; -r_hci_tl_inc_nb_h2c_cmd_pkts = 0x40000dc0; -r_hci_tl_save_pkt = 0x40000dc4; -r_hci_tl_send = 0x40000dc8; -r_hci_tx_done = 0x40000dcc; -r_hci_tx_start = 0x40000dd0; -r_hci_tx_trigger = 0x40000dd4; -r_isValidSecretKey_256 = 0x40000dd8; -r_ke_check_malloc = 0x40000ddc; -r_ke_event_callback_set = 0x40000de0; -r_ke_event_clear = 0x40000de4; -r_ke_event_flush = 0x40000de8; -r_ke_event_get = 0x40000dec; -r_ke_event_get_all = 0x40000df0; -r_ke_event_init = 0x40000df4; -r_ke_event_schedule = 0x40000df8; -r_ke_event_set = 0x40000dfc; -r_ke_flush = 0x40000e00; -r_ke_free = 0x40000e04; -r_ke_handler_search = 0x40000e08; -r_ke_init = 0x40000e0c; -r_ke_is_free = 0x40000e10; -r_ke_malloc = 0x40000e14; -r_ke_mem_init = 0x40000e18; -r_ke_mem_is_empty = 0x40000e1c; -r_ke_mem_is_in_heap = 0x40000e20; -r_ke_msg_alloc = 0x40000e24; -r_ke_msg_dest_id_get = 0x40000e28; -r_ke_msg_discard = 0x40000e2c; -r_ke_msg_forward = 0x40000e30; -r_ke_msg_forward_new_id = 0x40000e34; -r_ke_msg_free = 0x40000e38; -r_ke_msg_in_queue = 0x40000e3c; -r_ke_msg_save = 0x40000e40; -r_ke_msg_send = 0x40000e44; -r_ke_msg_send_basic = 0x40000e48; -r_ke_msg_src_id_get = 0x40000e4c; -r_ke_queue_extract = 0x40000e50; -r_ke_queue_insert = 0x40000e54; -r_ke_sleep_check = 0x40000e58; -r_ke_state_get = 0x40000e5c; -r_ke_state_set = 0x40000e60; -r_ke_task_check = 0x40000e64; -r_ke_task_create = 0x40000e68; -r_ke_task_delete = 0x40000e6c; -r_ke_task_handler_get = 0x40000e70; -r_ke_task_init = 0x40000e74; -r_ke_task_msg_flush = 0x40000e78; -r_ke_task_saved_update = 0x40000e7c; -r_ke_time = 0x40000e84; -r_ke_time_cmp = 0x40000e88; -r_ke_time_past = 0x40000e8c; -r_ke_timer_active = 0x40000e90; -r_ke_timer_adjust_all = 0x40000e94; -r_ke_timer_clear = 0x40000e98; -r_ke_timer_init = 0x40000e9c; -r_ke_timer_schedule = 0x40000ea0; -r_ke_timer_set = 0x40000ea4; -r_led_init = 0x40000ea8; -r_led_set_all = 0x40000eac; -r_llc_aes_res_cb = 0x40000eb0; -r_llc_ch_map_up_proc_err_cb = 0x40000eb4; -r_llc_cleanup = 0x40000eb8; -r_llc_cmd_cmp_send = 0x40000ebc; -r_llc_cmd_stat_send = 0x40000ec0; -r_llc_con_move_cbk = 0x40000ec4; -r_llc_con_plan_set_update = 0x40000ec8; -r_llc_con_upd_param_in_range = 0x40000ecc; -r_llc_disconnect = 0x40000ed0; -r_llc_disconnect_end = 0x40000ed4; -r_llc_disconnect_proc_continue = 0x40000ed8; -r_llc_disconnect_proc_err_cb = 0x40000edc; -r_llc_dl_chg_check = 0x40000ee0; -r_llc_dle_proc_err_cb = 0x40000ee4; -r_llc_feats_exch_proc_err_cb = 0x40000ee8; -r_llc_hci_cmd_handler_tab_p_get = 0x40000eec; -r_llc_hci_con_param_req_evt_send = 0x40000ef4; -r_llc_hci_con_upd_info_send = 0x40000ef8; -r_llc_hci_disconnected_dis = 0x40000efc; -r_llc_hci_dl_upd_info_send = 0x40000f00; -r_llc_hci_enc_evt_send = 0x40000f04; -r_llc_hci_feats_info_send = 0x40000f08; -r_llc_hci_le_phy_upd_cmp_evt_send = 0x40000f0c; -r_llc_hci_ltk_request_evt_send = 0x40000f10; -r_llc_hci_nb_cmp_pkts_evt_send = 0x40000f14; -r_llc_hci_version_info_send = 0x40000f18; -r_llc_init_term_proc = 0x40000f1c; -r_llc_iv_skd_rand_gen = 0x40000f20; -r_llc_le_ping_proc_continue = 0x40000f24; -r_llc_le_ping_proc_err_cb = 0x40000f28; -/* r_llc_le_ping_restart = 0x40000f2c; */ -r_llc_le_ping_set = 0x40000f30; -r_llc_ll_pause_enc_rsp_ack_handler = 0x40000f34; -r_llc_ll_reject_ind_ack_handler = 0x40000f38; -r_llc_ll_reject_ind_pdu_send = 0x40000f3c; -r_llc_ll_start_enc_rsp_ack_handler = 0x40000f40; -r_llc_ll_terminate_ind_ack = 0x40000f44; -r_llc_ll_unknown_ind_handler = 0x40000f48; -r_llc_llcp_send = 0x40000f4c; -r_llc_llcp_state_set = 0x40000f50; -r_llc_llcp_trans_timer_set = 0x40000f54; -r_llc_llcp_tx_check = 0x40000f58; -r_llc_loc_con_upd_proc_err_cb = 0x40000f64; -r_llc_loc_dl_upd_proc_continue = 0x40000f68; -r_llc_loc_encrypt_proc_continue = 0x40000f6c; -r_llc_loc_encrypt_proc_err_cb = 0x40000f70; -r_llc_loc_feats_exch_proc_continue = 0x40000f74; -r_llc_loc_phy_upd_proc_err_cb = 0x40000f7c; -r_llc_msg_handler_tab_p_get = 0x40000f80; -r_llc_pref_param_compute = 0x40000f84; -r_llc_proc_collision_check = 0x40000f88; -r_llc_proc_err_ind = 0x40000f8c; -r_llc_proc_get = 0x40000f90; -r_llc_proc_id_get = 0x40000f94; -r_llc_proc_reg = 0x40000f98; -r_llc_proc_state_get = 0x40000f9c; -r_llc_proc_state_set = 0x40000fa0; -r_llc_proc_timer_pause_set = 0x40000fa4; -r_llc_proc_timer_set = 0x40000fa8; -r_llc_proc_unreg = 0x40000fac; -r_llc_rem_ch_map_proc_continue = 0x40000fb0; -r_llc_rem_con_upd_proc_err_cb = 0x40000fb8; -r_llc_rem_dl_upd_proc = 0x40000fbc; -r_llc_rem_encrypt_proc_continue = 0x40000fc0; -r_llc_rem_encrypt_proc_err_cb = 0x40000fc4; -r_llc_rem_phy_upd_proc_continue = 0x40000fc8; -r_llc_rem_phy_upd_proc_err_cb = 0x40000fcc; -r_llc_role_get = 0x40000fd0; -r_llc_sk_gen = 0x40000fd4; -r_llc_start = 0x40000fd8; -r_llc_stop = 0x40000fdc; -r_llc_ver_exch_loc_proc_continue = 0x40000fe0; -r_llc_ver_proc_err_cb = 0x40000fe4; -r_llcp_pdu_handler_tab_p_get = 0x40000fe8; -r_lld_aa_gen = 0x40000fec; -r_lld_adv_adv_data_set = 0x40000ff0; -r_lld_adv_adv_data_update = 0x40000ff4; -r_lld_adv_aux_ch_idx_set = 0x40000ff8; -r_lld_adv_aux_evt_canceled_cbk = 0x40000ffc; -r_lld_adv_aux_evt_start_cbk = 0x40001000; -r_lld_adv_coex_check_ext_adv_synced = 0x40001004; -r_lld_adv_coex_env_reset = 0x40001008; -r_lld_adv_duration_update = 0x4000100c; -r_lld_adv_dynamic_pti_process = 0x40001010; -r_lld_adv_end = 0x40001014; -r_lld_adv_evt_canceled_cbk = 0x40001018; -r_lld_adv_evt_start_cbk = 0x4000101c; -r_lld_adv_ext_chain_construct = 0x40001020; -r_lld_adv_ext_pkt_prepare = 0x40001024; -r_lld_adv_frm_cbk = 0x40001028; -r_lld_adv_frm_isr = 0x4000102c; -r_lld_adv_frm_skip_isr = 0x40001030; -r_lld_adv_init = 0x40001034; -r_lld_adv_pkt_rx = 0x40001038; -r_lld_adv_pkt_rx_connect_ind = 0x4000103c; -r_lld_adv_pkt_rx_send_scan_req_evt = 0x40001040; -r_lld_adv_rand_addr_update = 0x40001044; -r_lld_adv_restart = 0x40001048; -r_lld_adv_scan_rsp_data_set = 0x4000104c; -r_lld_adv_scan_rsp_data_update = 0x40001050; -r_lld_adv_set_tx_power = 0x40001054; -r_lld_adv_start = 0x40001058; -r_lld_adv_stop = 0x4000105c; -r_lld_adv_sync_info_set = 0x40001060; -r_lld_adv_sync_info_update = 0x40001064; -r_lld_calc_aux_rx = 0x40001068; -r_lld_cca_alloc = 0x4000106c; -r_lld_cca_data_reset = 0x40001070; -r_lld_cca_free = 0x40001074; -r_lld_ch_assess_data_get = 0x40001078; -r_lld_ch_idx_get = 0x4000107c; -r_lld_ch_map_set = 0x40001080; -r_lld_channel_assess = 0x40001084; -r_lld_con_activity_act_offset_compute = 0x40001088; -r_lld_con_activity_offset_compute = 0x4000108c; -r_lld_con_ch_map_update = 0x40001090; -r_lld_con_cleanup = 0x40001094; -r_lld_con_current_tx_power_get = 0x40001098; -r_lld_con_data_flow_set = 0x4000109c; -r_lld_con_data_len_update = 0x400010a0; -r_lld_con_data_tx = 0x400010a4; -r_lld_con_enc_key_load = 0x400010a8; -r_lld_con_event_counter_get = 0x400010ac; -r_lld_con_evt_canceled_cbk = 0x400010b0; -r_lld_con_evt_duration_min_get = 0x400010b4; -r_lld_con_evt_max_eff_time_cal = 0x400010b8; -r_lld_con_evt_sd_evt_time_get = 0x400010bc; -r_lld_con_evt_start_cbk = 0x400010c0; -r_lld_con_evt_time_update = 0x400010c4; -r_lld_con_free_all_tx_buf = 0x400010c8; -r_lld_con_frm_cbk = 0x400010cc; -r_lld_con_frm_isr = 0x400010d0; -r_lld_con_frm_skip_isr = 0x400010d4; -r_lld_con_init = 0x400010d8; -r_lld_con_llcp_tx = 0x400010dc; -r_lld_con_max_lat_calc = 0x400010e0; -r_lld_con_offset_get = 0x400010e4; -r_lld_con_param_update = 0x400010e8; -r_lld_con_phys_update = 0x400010ec; -r_lld_con_pref_slave_evt_dur_set = 0x400010f0; -r_lld_con_pref_slave_latency_set = 0x400010f4; -r_lld_con_rssi_get = 0x400010f8; -r_lld_con_rx = 0x400010fc; -/* r_lld_con_rx_channel_assess = 0x40001100; */ -r_lld_con_rx_enc = 0x40001104; -r_lld_con_rx_isr = 0x40001108; -r_lld_con_rx_link_info_check = 0x4000110c; -r_lld_con_rx_llcp_check = 0x40001110; -r_lld_con_rx_sync_time_update = 0x40001114; -r_lld_con_set_tx_power = 0x4000111c; -r_lld_con_start = 0x40001120; -r_lld_con_tx = 0x40001128; -r_lld_con_tx_enc = 0x4000112c; -r_lld_con_tx_isr = 0x40001130; -r_lld_con_tx_len_update = 0x40001134; -r_lld_con_tx_len_update_for_intv = 0x40001138; -r_lld_con_tx_len_update_for_rate = 0x4000113c; -r_lld_con_tx_prog = 0x40001140; -r_lld_conn_dynamic_pti_process = 0x40001144; -r_lld_continue_scan_rx_isr_end_process = 0x40001148; -r_lld_ext_scan_dynamic_pti_process = 0x4000114c; -r_lld_hw_cca_end_isr = 0x40001150; -r_lld_hw_cca_evt_handler = 0x40001154; -r_lld_hw_cca_isr = 0x40001158; -r_lld_init_cal_anchor_point = 0x4000115c; -r_lld_init_compute_winoffset = 0x40001160; -r_lld_init_connect_req_pack = 0x40001164; -r_lld_init_end = 0x40001168; -r_lld_init_evt_canceled_cbk = 0x4000116c; -r_lld_init_evt_start_cbk = 0x40001170; -r_lld_init_frm_cbk = 0x40001174; -r_lld_init_frm_eof_isr = 0x40001178; -r_lld_init_frm_skip_isr = 0x4000117c; -r_lld_init_init = 0x40001180; -r_lld_init_process_pkt_rx = 0x40001184; -r_lld_init_process_pkt_rx_adv_ext_ind = 0x40001188; -r_lld_init_process_pkt_rx_adv_ind_or_direct_ind = 0x4000118c; -r_lld_init_process_pkt_rx_aux_connect_rsp = 0x40001190; -r_lld_init_process_pkt_tx = 0x40001194; -r_lld_init_process_pkt_tx_cal_con_timestamp = 0x40001198; -r_lld_init_sched = 0x4000119c; -r_lld_init_set_tx_power = 0x400011a0; -r_lld_init_start = 0x400011a4; -r_lld_init_stop = 0x400011a8; -r_lld_instant_proc_end = 0x400011ac; -r_lld_per_adv_ch_map_update = 0x400011b4; -r_lld_per_adv_chain_construct = 0x400011b8; -r_lld_per_adv_cleanup = 0x400011bc; -r_lld_per_adv_coex_env_reset = 0x400011c0; -r_lld_per_adv_data_set = 0x400011c4; -r_lld_per_adv_data_update = 0x400011c8; -r_lld_per_adv_dynamic_pti_process = 0x400011cc; -r_lld_per_adv_evt_canceled_cbk = 0x400011d0; -r_lld_per_adv_evt_start_cbk = 0x400011d4; -r_lld_per_adv_ext_pkt_prepare = 0x400011d8; -r_lld_per_adv_frm_cbk = 0x400011dc; -r_lld_per_adv_frm_isr = 0x400011e0; -r_lld_per_adv_frm_skip_isr = 0x400011e4; -r_lld_per_adv_init = 0x400011e8; -r_lld_per_adv_init_info_get = 0x400011ec; -r_lld_per_adv_list_add = 0x400011f0; -r_lld_per_adv_list_rem = 0x400011f4; -r_lld_per_adv_set_tx_power = 0x400011fc; -r_lld_per_adv_start = 0x40001200; -r_lld_per_adv_stop = 0x40001204; -r_lld_per_adv_sync_info_get = 0x40001208; -r_lld_process_cca_data = 0x4000120c; -r_lld_ral_search = 0x40001210; -r_lld_read_clock = 0x40001214; -r_lld_res_list_add = 0x40001218; -r_lld_res_list_is_empty = 0x40001220; -r_lld_res_list_local_rpa_get = 0x40001224; -r_lld_res_list_peer_rpa_get = 0x40001228; -r_lld_res_list_peer_update = 0x4000122c; -/* r_lld_res_list_priv_mode_update = 0x40001230; */ -r_lld_reset_reg = 0x40001238; -r_lld_rpa_renew = 0x4000123c; -r_lld_rpa_renew_evt_canceled_cbk = 0x40001240; -r_lld_rpa_renew_evt_start_cbk = 0x40001244; -r_lld_rpa_renew_instant_cbk = 0x40001248; -r_lld_rxdesc_check = 0x4000124c; -r_lld_rxdesc_free = 0x40001250; -r_lld_scan_create_sync = 0x40001254; -r_lld_scan_create_sync_cancel = 0x40001258; -r_lld_scan_end = 0x4000125c; -r_lld_scan_evt_canceled_cbk = 0x40001260; -r_lld_scan_evt_start_cbk = 0x40001264; -r_lld_scan_frm_cbk = 0x40001268; -r_lld_scan_frm_eof_isr = 0x4000126c; -r_lld_scan_frm_rx_isr = 0x40001270; -r_lld_scan_frm_skip_isr = 0x40001274; -r_lld_scan_init = 0x40001278; -r_lld_scan_params_update = 0x4000127c; -r_lld_scan_process_pkt_rx_aux_adv_ind = 0x40001288; -r_lld_scan_process_pkt_rx_aux_chain_ind = 0x4000128c; -r_lld_scan_process_pkt_rx_aux_scan_rsp = 0x40001290; -r_lld_scan_process_pkt_rx_ext_adv = 0x40001294; -r_lld_scan_process_pkt_rx_ext_adv_ind = 0x40001298; -r_lld_scan_process_pkt_rx_legacy_adv = 0x4000129c; -r_lld_scan_restart = 0x400012a0; -r_lld_scan_sched = 0x400012a4; -r_lld_scan_set_tx_power = 0x400012a8; -r_lld_scan_start = 0x400012ac; -r_lld_scan_stop = 0x400012b0; -r_lld_scan_sync_accept = 0x400012b4; -r_lld_scan_sync_info_unpack = 0x400012b8; -r_lld_scan_trunc_ind = 0x400012bc; -r_lld_sw_cca_evt_handler = 0x400012c0; -r_lld_sw_cca_isr = 0x400012c4; -r_lld_sync_ch_map_update = 0x400012c8; -r_lld_sync_cleanup = 0x400012cc; -r_lld_sync_evt_canceled_cbk = 0x400012d0; -r_lld_sync_evt_start_cbk = 0x400012d4; -r_lld_sync_frm_cbk = 0x400012d8; -r_lld_sync_frm_eof_isr = 0x400012dc; -r_lld_sync_frm_rx_isr = 0x400012e0; -r_lld_sync_frm_skip_isr = 0x400012e4; -r_lld_sync_init = 0x400012e8; -r_lld_sync_process_pkt_rx = 0x400012ec; -r_lld_sync_process_pkt_rx_aux_sync_ind = 0x400012f0; -r_lld_sync_process_pkt_rx_pkt_check = 0x400012f4; -r_lld_sync_scan_dynamic_pti_process = 0x400012f8; -r_lld_sync_sched = 0x400012fc; -r_lld_sync_start = 0x40001300; -r_lld_sync_stop = 0x40001304; -r_lld_sync_trunc_ind = 0x40001308; -r_lld_test_cleanup = 0x4000130c; -r_lld_test_evt_canceled_cbk = 0x40001310; -r_lld_test_evt_start_cbk = 0x40001314; -r_lld_test_freq2chnl = 0x40001318; -r_lld_test_frm_cbk = 0x4000131c; -r_lld_test_frm_isr = 0x40001320; -r_lld_test_init = 0x40001324; -r_lld_test_rx_isr = 0x40001328; -r_lld_test_set_tx_power = 0x4000132c; -r_lld_test_start = 0x40001330; -/* r_lld_test_stop = 0x40001334; */ -r_lld_update_rxbuf = 0x40001338; -r_lld_update_rxbuf_isr = 0x4000133c; -r_lld_white_list_add = 0x40001340; -r_lld_white_list_rem = 0x40001344; -r_llm_activity_free_get = 0x40001348; -r_llm_activity_free_set = 0x4000134c; -r_llm_activity_syncing_get = 0x40001350; -r_llm_adv_con_len_check = 0x40001354; -r_llm_adv_hdl_to_id = 0x40001358; -r_llm_adv_rep_flow_control_check = 0x4000135c; -r_llm_adv_rep_flow_control_update = 0x40001360; -r_llm_adv_reports_list_check = 0x40001364; -r_llm_adv_set_all_release = 0x40001368; -r_llm_adv_set_dft_params = 0x4000136c; -r_llm_adv_set_release = 0x40001370; -r_llm_aes_res_cb = 0x40001374; -r_llm_ble_update_adv_flow_control = 0x40001378; -r_llm_ch_map_update = 0x4000137c; -r_llm_cmd_cmp_send = 0x40001380; -r_llm_cmd_stat_send = 0x40001384; -r_llm_dev_list_empty_entry = 0x40001388; -r_llm_dev_list_search = 0x4000138c; -r_llm_env_adv_dup_filt_deinit = 0x40001390; -r_llm_env_adv_dup_filt_init = 0x40001394; -r_llm_init_ble_adv_report_flow_contol = 0x40001398; -r_llm_is_dev_connected = 0x4000139c; -r_llm_is_dev_synced = 0x400013a0; -r_llm_is_non_con_act_ongoing_check = 0x400013a4; -r_llm_is_wl_accessible = 0x400013a8; -r_llm_le_evt_mask_check = 0x400013ac; -r_llm_link_disc = 0x400013b4; -r_llm_master_ch_map_get = 0x400013b8; -r_llm_msg_handler_tab_p_get = 0x400013bc; -r_llm_no_activity = 0x400013c0; -r_llm_per_adv_slot_dur = 0x400013c4; -r_llm_plan_elt_get = 0x400013c8; -r_llm_rx_path_comp_get = 0x400013cc; -r_llm_scan_start = 0x400013d0; -r_llm_scan_sync_acad_attach = 0x400013d4; -r_llm_scan_sync_acad_detach = 0x400013d8; -r_llm_send_adv_lost_event_to_host = 0x400013dc; -r_llm_tx_path_comp_get = 0x400013e0; -r_misc_deinit = 0x400013e4; -r_misc_free_em_buf_in_isr = 0x400013e8; -r_misc_init = 0x400013ec; -r_misc_msg_handler_tab_p_get = 0x400013f0; -r_notEqual256 = 0x400013f4; -r_phy_upd_proc_start = 0x400013f8; -r_platform_reset = 0x400013fc; -r_rf_em_init = 0x40001404; -r_rf_force_agc_enable = 0x40001408; -r_rf_reg_rd = 0x4000140c; -r_rf_reg_wr = 0x40001410; -r_rf_reset = 0x40001414; -r_rf_rssi_convert = 0x40001418; -r_rf_rw_v9_le_disable = 0x4000141c; -r_rf_rw_v9_le_enable = 0x40001420; -r_rf_sleep = 0x40001424; -r_rf_util_cs_fmt_convert = 0x40001430; -r_rw_crypto_aes_ccm = 0x40001434; -r_rw_crypto_aes_encrypt = 0x40001438; -r_rw_crypto_aes_init = 0x4000143c; -r_rw_crypto_aes_k1 = 0x40001440; -r_rw_crypto_aes_k2 = 0x40001444; -r_rw_crypto_aes_k3 = 0x40001448; -r_rw_crypto_aes_k4 = 0x4000144c; -r_rw_crypto_aes_rand = 0x40001450; -r_rw_crypto_aes_result_handler = 0x40001454; -r_rw_crypto_aes_s1 = 0x40001458; -r_rw_cryto_aes_cmac = 0x4000145c; -r_rw_v9_init_em_radio_table = 0x40001460; -r_rwble_sleep_enter = 0x40001468; -r_rwble_sleep_wakeup_end = 0x4000146c; -/* r_rwbtdm_isr_wrapper = 0x40001470; */ -r_rwip_active_check = 0x40001474; -r_rwip_aes_encrypt = 0x40001478; -/* r_rwip_assert = 0x4000147c; */ -r_rwip_crypt_evt_handler = 0x40001480; -r_rwip_crypt_isr_handler = 0x40001484; -r_rwip_eif_get = 0x40001488; -r_rwip_half_slot_2_lpcycles = 0x4000148c; -r_rwip_hus_2_lpcycles = 0x40001490; -r_rwip_isr = 0x40001494; -r_rwip_lpcycles_2_hus = 0x40001498; -r_rwip_prevent_sleep_clear = 0x4000149c; -r_rwip_prevent_sleep_set = 0x400014a0; -r_rwip_schedule = 0x400014a4; -r_rwip_sleep = 0x400014a8; -r_rwip_sw_int_handler = 0x400014ac; -r_rwip_sw_int_req = 0x400014b0; -r_rwip_time_get = 0x400014b4; -r_rwip_timer_10ms_handler = 0x400014b8; -r_rwip_timer_10ms_set = 0x400014bc; -r_rwip_timer_hs_handler = 0x400014c0; -r_rwip_timer_hs_set = 0x400014c4; -r_rwip_timer_hus_handler = 0x400014c8; -r_rwip_timer_hus_set = 0x400014cc; -r_rwip_wakeup = 0x400014d0; -/* r_rwip_wakeup_end = 0x400014d4; */ -r_rwip_wlcoex_set = 0x400014d8; -r_sch_alarm_clear = 0x400014dc; -r_sch_alarm_init = 0x400014e0; -r_sch_alarm_prog = 0x400014e4; -r_sch_alarm_set = 0x400014e8; -r_sch_alarm_timer_isr = 0x400014ec; -r_sch_arb_conflict_check = 0x400014f0; -r_sch_arb_elt_cancel = 0x400014f4; -r_sch_arb_init = 0x400014fc; -r_sch_arb_insert = 0x40001500; -r_sch_arb_prog_timer = 0x40001504; -r_sch_arb_remove = 0x40001508; -r_sch_arb_sw_isr = 0x4000150c; -r_sch_plan_chk = 0x40001510; -r_sch_plan_clock_wrap_offset_update = 0x40001514; -r_sch_plan_init = 0x40001518; -r_sch_plan_interval_req = 0x4000151c; -r_sch_plan_offset_max_calc = 0x40001520; -r_sch_plan_offset_req = 0x40001524; -r_sch_plan_position_range_compute = 0x40001528; -r_sch_plan_rem = 0x4000152c; -r_sch_plan_req = 0x40001530; -r_sch_prog_init = 0x4000153c; -r_sch_prog_push = 0x40001540; -r_sch_prog_rx_isr = 0x40001544; -r_sch_prog_skip_isr = 0x40001548; -r_sch_prog_tx_isr = 0x4000154c; -r_sch_slice_bg_add = 0x40001550; -r_sch_slice_bg_remove = 0x40001554; -r_sch_slice_compute = 0x40001558; -r_sch_slice_fg_add = 0x4000155c; -r_sch_slice_fg_remove = 0x40001560; -r_sch_slice_init = 0x40001564; -r_sch_slice_per_add = 0x40001568; -r_sch_slice_per_remove = 0x4000156c; -r_sdk_config_get_bt_sleep_enable = 0x40001570; -r_sdk_config_get_hl_derived_opts = 0x40001574; -r_sdk_config_get_opts = 0x40001578; -r_sdk_config_get_priv_opts = 0x4000157c; -r_sdk_config_set_bt_sleep_enable = 0x40001580; -r_sdk_config_set_hl_derived_opts = 0x40001584; -r_sdk_config_set_opts = 0x40001588; -r_specialModP256 = 0x4000158c; -r_unloaded_area_init = 0x40001590; -r_vhci_flow_off = 0x40001594; -r_vhci_flow_on = 0x40001598; -r_vhci_notify_host_send_available = 0x4000159c; -r_vhci_send_to_host = 0x400015a0; -r_vnd_hci_command_handler = 0x400015a4; -r_vshci_init = 0x400015a8; -vnd_hci_command_handler_wrapper = 0x400015ac; /* Data (.data, .bss, .rodata) */ bt_rf_coex_cfg_p = 0x3fcdffcc; bt_rf_coex_hooks_p = 0x3fcdffc8; @@ -1462,38 +668,6 @@ rwip_coex_cfg = 0x3ff1eeac; rwip_priority = 0x3ff1ee94; veryBigHexP256 = 0x3ff1ee48; -/* bluetooth hook funcs */ -r_llc_loc_encrypt_proc_continue_hook = 0x40001c60; -r_llc_loc_phy_upd_proc_continue_hook = 0x40001c64; -r_llc_rem_phy_upd_proc_continue_hook = 0x40001c68; -r_lld_scan_frm_eof_isr_hook = 0x40001c6c; -r_lld_scan_evt_start_cbk_hook = 0x40001c70; -r_lld_scan_process_pkt_rx_ext_adv_hook = 0x40001c78; -r_lld_scan_sched_hook = 0x40001c7c; -r_lld_adv_evt_start_cbk_hook = 0x40001c84; -r_lld_adv_aux_evt_start_cbk_hook = 0x40001c88; -r_lld_adv_frm_isr_hook = 0x40001c8c; -r_lld_adv_start_init_evt_param_hook = 0x40001c90; -r_lld_con_evt_canceled_cbk_hook = 0x40001c94; -r_lld_con_frm_isr_hook = 0x40001c98; -r_lld_con_tx_hook = 0x40001c9c; -r_lld_con_rx_hook = 0x40001ca0; -r_lld_con_evt_start_cbk_hook = 0x40001ca4; -r_lld_con_tx_prog_new_packet_hook = 0x40001cac; -r_lld_init_frm_eof_isr_hook = 0x40001cb0; -r_lld_init_evt_start_cbk_hook = 0x40001cb4; -r_lld_init_sched_hook = 0x40001cbc; -r_lld_init_process_pkt_tx_hook = 0x40001cc0; -r_lld_per_adv_evt_start_cbk_hook = 0x40001cc4; -r_lld_per_adv_frm_isr_hook = 0x40001cc8; -r_lld_per_adv_start_hook = 0x40001ccc; -r_lld_sync_frm_eof_isr_hook = 0x40001cd0; -r_lld_sync_evt_start_cbk_hook = 0x40001cd4; -r_lld_sync_start_hook = 0x40001cd8; -r_lld_sync_process_pkt_rx_pkt_check_hook = 0x40001cdc; -r_sch_arb_insert_hook = 0x40001ce0; -r_sch_plan_offset_req_hook = 0x40001ce4; - /*************************************** Group rom_pp ***************************************/ @@ -1571,7 +745,7 @@ ppEnqueueTxDone = 0x400016cc; ppGetTxQFirstAvail_Locked = 0x400016d0; ppGetTxframe = 0x400016d4; ppProcessRxPktHdr = 0x400016e0; -ppProcessTxQ = 0x400016e4; +/*ppProcessTxQ = 0x400016e4;*/ ppRecordBarRRC = 0x400016e8; lmacRequestTxopQueue = 0x400016ec; lmacReleaseTxopQueue = 0x400016f0; @@ -1609,7 +783,7 @@ rcSetTxAmpduLimit = 0x4000176c; rcUpdateAckSnr = 0x40001774; /*rcUpdateRate = 0x40001778;*/ /* rcUpdateTxDone = 0x4000177c; */ -rcUpdateTxDoneAmpdu2 = 0x40001780; +/*rcUpdateTxDoneAmpdu2 = 0x40001780;*/ rcUpSched = 0x40001784; rssi_margin = 0x40001788; rx11NRate2AMPDULimit = 0x4000178c; @@ -1772,7 +946,7 @@ coex_hw_timer_set = 0x400018e0; coex_schm_interval_set = 0x400018e4; coex_schm_lock = 0x400018e8; coex_schm_unlock = 0x400018ec; -coex_status_get = 0x400018f0; +/*coex_status_get = 0x400018f0;*/ coex_wifi_release = 0x400018f4; esp_coex_ble_conn_dynamic_prio_get = 0x400018f8; /* Data (.data, .bss, .rodata) */ diff --git a/components/esp_rom/esp32c6/ld/esp32c6.rom.coexist.ld b/components/esp_rom/esp32c6/ld/esp32c6.rom.coexist.ld index 5ff011973e..46e175e179 100644 --- a/components/esp_rom/esp32c6/ld/esp32c6.rom.coexist.ld +++ b/components/esp_rom/esp32c6/ld/esp32c6.rom.coexist.ld @@ -35,7 +35,7 @@ coex_hw_timer_set = 0x40000b30; coex_schm_interval_set = 0x40000b34; coex_schm_lock = 0x40000b38; coex_schm_unlock = 0x40000b3c; -coex_status_get = 0x40000b40; +/*coex_status_get = 0x40000b40;*/ coex_wifi_release = 0x40000b44; esp_coex_ble_conn_dynamic_prio_get = 0x40000b48; /* Data (.data, .bss, .rodata) */ diff --git a/components/esp_rom/esp32c6/ld/esp32c6.rom.net80211.ld b/components/esp_rom/esp32c6/ld/esp32c6.rom.net80211.ld index 7a73b4d5a7..362cc49b70 100644 --- a/components/esp_rom/esp32c6/ld/esp32c6.rom.net80211.ld +++ b/components/esp_rom/esp32c6/ld/esp32c6.rom.net80211.ld @@ -37,7 +37,7 @@ ieee80211_ampdu_start_age_timer = 0x40000b84; ieee80211_is_tx_allowed = 0x40000b8c; ieee80211_output_pending_eb = 0x40000b90; /*ieee80211_output_process = 0x40000b94;*/ -ieee80211_set_tx_desc = 0x40000b98; +/*ieee80211_set_tx_desc = 0x40000b98;*/ //sta_input = 0x40000b9c; wifi_get_macaddr = 0x40000ba0; wifi_rf_phy_disable = 0x40000ba4; diff --git a/components/esp_rom/esp32c6/ld/esp32c6.rom.pp.ld b/components/esp_rom/esp32c6/ld/esp32c6.rom.pp.ld index 69faa174c1..9177c2a5ea 100644 --- a/components/esp_rom/esp32c6/ld/esp32c6.rom.pp.ld +++ b/components/esp_rom/esp32c6/ld/esp32c6.rom.pp.ld @@ -130,8 +130,8 @@ rcSetTxAmpduLimit = 0x40000d88; rcTxUpdatePer = 0x40000d8c; rcUpdateAckSnr = 0x40000d90; /*rcUpdateRate = 0x40000d94;*/ -rcUpdateTxDone = 0x40000d98; -rcUpdateTxDoneAmpdu2 = 0x40000d9c; +/*rcUpdateTxDone = 0x40000d98;*/ +/*rcUpdateTxDoneAmpdu2 = 0x40000d9c;*/ rcUpSched = 0x40000da0; rssi_margin = 0x40000da4; rx11NRate2AMPDULimit = 0x40000da8; diff --git a/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_50.ld b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_50.ld new file mode 100644 index 0000000000..10cc038cc3 --- /dev/null +++ b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_50.ld @@ -0,0 +1,75 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32s3.rom.ld for esp32s3 + * + * + * Generated from ./interface-esp32s3.yml md5sum 39c4ce259b11323b9404c192b01b712b + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* extend adv */ +f_hci_le_set_ext_adv_param_cmd_handler = 0x40000000; +f_hci_le_set_adv_set_rand_addr_cmd_handler = 0x40000000; +f_hci_le_set_ext_adv_data_cmd_handler = 0x40000000; +f_hci_le_set_ext_scan_rsp_data_cmd_handler = 0x40000000; +f_hci_le_set_ext_adv_en_cmd_handler = 0x40000000; +f_hci_le_rd_max_adv_data_len_cmd_handler = 0x40000000; +f_hci_le_rd_nb_supp_adv_sets_cmd_handler = 0x40000000; +f_hci_le_rmv_adv_set_cmd_handler = 0x40000000; +f_hci_le_clear_adv_sets_cmd_handler = 0x40000000; +r_lld_adv_sync_info_set = 0x40000000; + +r_lld_ext_adv_dynamic_pti_process = 0x40000000; +r_lld_adv_ext_chain_construct = 0x40000000; +r_lld_adv_aux_evt_canceled_cbk = 0x40000000; +r_lld_adv_aux_evt_start_cbk = 0x40000000; +r_lld_adv_aux_ch_idx_set = 0x40000000; + +/* periodic adv */ +f_hci_le_set_per_adv_param_cmd_handler = 0x40000000; +f_hci_le_set_per_adv_data_cmd_handler = 0x40000000; +f_hci_le_set_per_adv_en_cmd_handler = 0x40000000; +r_lld_per_adv_ch_map_update = 0x40000000; +r_lld_per_adv_init = 0x40000000; + +/* PA list */ +f_hci_le_add_dev_to_per_adv_list_cmd_handler = 0x40000000; +f_hci_le_rmv_dev_from_per_adv_list_cmd_handler = 0x40000000; +f_hci_le_clear_per_adv_list_cmd_handler = 0x40000000; +f_hci_le_rd_per_adv_list_size_cmd_handler = 0x40000000; + +/* extend scan */ +f_hci_le_set_ext_scan_param_cmd_handler = 0x40000000; +f_hci_le_set_ext_scan_en_cmd_handler = 0x40000000; +r_lld_scan_process_pkt_rx_ext_adv = 0x40000000; +r_lld_scan_trunc_ind = 0x40000000; + +/* extend con */ +f_hci_le_ext_create_con_cmd_handler = 0x40000000; +r_lld_init_process_pkt_rx_adv_ext_ind = 0x40000000; +r_lld_init_process_pkt_rx_aux_connect_rsp = 0x40000000; + +/* PA sync */ +f_hci_le_per_adv_create_sync_cmd_handler = 0x40000000; +f_hci_le_per_adv_create_sync_cancel_cmd_handler = 0x40000000; +f_hci_le_per_adv_term_sync_cmd_handler = 0x40000000; +f_lld_per_adv_rx_end_ind_handler_hack = 0x40000000; +f_lld_sync_start_req_handler = 0x40000000; +f_lld_per_adv_rep_ind_handler = 0x40000000; +r_lld_sync_init = 0x40000000; + +/* phy update*/ +r_phy_upd_proc_start = 0x40000000; +f_llc_op_phy_upd_ind_handler = 0x40000000; +f_ll_phy_req_handler = 0x40000000; +f_ll_phy_rsp_handler = 0x40000000; +f_ll_phy_update_ind_handler = 0x40000000; +f_lld_phy_upd_cfm_handler = 0x40000000; +f_hci_le_set_phy_cmd_handler = 0x40000000; +llc_llcp_phy_update_ind_ack = 0x40000000; diff --git a/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_cca.ld b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_cca.ld new file mode 100644 index 0000000000..74d2dca0e3 --- /dev/null +++ b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_cca.ld @@ -0,0 +1,32 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32s3.rom.ld for esp32s3 + * + * + * Generated from ./interface-esp32s3.yml md5sum 39c4ce259b11323b9404c192b01b712b + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* SW CCA */ +r_lld_cca_con_evt_start_handle = 0x40000000; +r_lld_hw_cca_end_isr = 0x40000000; +r_lld_hw_cca_isr_eco = 0x40000000; +r_lld_cca_bb_sync_found_handle = 0x40000000; +r_lld_cca_data_reset = 0x40000000; +r_lld_cca_sw_init = 0x40000000; +r_lld_cca_con_evt_end_handle = 0x40000000; +r_lld_cca_alloc = 0x40000000; +r_lld_cca_sw_alloc = 0x40000000; +r_lld_cca_sw_free = 0x40000000; +r_lld_cca_free = 0x40000000; +r_cca_init = 0x40000000; +r_lld_hw_cca_evt_handler = 0x40000000; +r_lld_sw_cca_evt_handler = 0x40000000; +r_ble_sw_cca_check_isr = 0x40000000; +bt_bb_tx_cca_set = 0x40000000; diff --git a/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_dtm.ld b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_dtm.ld new file mode 100644 index 0000000000..e08545c717 --- /dev/null +++ b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_dtm.ld @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32s3.rom.ld for esp32s3 + * + * + * Generated from ./interface-esp32s3.yml md5sum 39c4ce259b11323b9404c192b01b712b + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* DTM */ +f_hci_le_rx_test_cmd_handler = 0x40000000; +f_hci_le_tx_test_cmd_handler = 0x40000000; +f_hci_le_enh_rx_test_cmd_handler = 0x40000000; +f_hci_le_enh_tx_test_cmd_handler = 0x40000000; +f_hci_le_test_end_cmd_handler = 0x40000000; +r_lld_test_init = 0x40000000; diff --git a/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_master.ld b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_master.ld new file mode 100644 index 0000000000..498330a680 --- /dev/null +++ b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_master.ld @@ -0,0 +1,20 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32s3.rom.ld for esp32s3 + * + * + * Generated from ./interface-esp32s3.yml md5sum 39c4ce259b11323b9404c192b01b712b + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* master */ +f_hci_le_create_con_cmd_handler = 0x40000000; +f_hci_le_create_con_cancel_cmd_handler = 0x40000000; +lld_init_end_ind_handler = 0x40000000; +r_lld_init_init = 0x40000000; diff --git a/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_scan.ld b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_scan.ld new file mode 100644 index 0000000000..c3c8414e51 --- /dev/null +++ b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_scan.ld @@ -0,0 +1,37 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32s3.rom.ld for esp32s3 + * + * + * Generated from ./interface-esp32s3.yml md5sum 39c4ce259b11323b9404c192b01b712b + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + + +/* BLE scan */ + +f_hci_le_set_scan_param_cmd_handler = 0x40000000; +f_hci_le_set_scan_en_cmd_handler = 0x40000000; +f_llm_scan_period_to_handler_hack = 0x40000000; +f_lld_adv_rep_ind_handler_hack = 0x40000000; +r_lld_scan_init = 0x40000000; +r_lld_scan_restart = 0x40000000; +f_lld_scan_end_ind_handler_hack = 0x40000000; +r_llm_env_adv_dup_filt_deinit_eco = 0x40000000; +llm_exception_list_init = 0x40000000; +llm_duplicate_list_init = 0x40000000; +f_hci_vendor_ble_update_duplicate_exceptional_list_cmd_handler = 0x40000000; +f_hci_vendor_ble_init_adv_flow_control_cmd_handler = 0x40000000; +f_hci_vendor_ble_update_adv_report_flow_control_cmd_handler = 0x40000000; +coex_schm_ble_scan_stop = 0x40000000; + +f_hci_le_set_ext_scan_param_cmd_handler = 0x40000000; +f_hci_le_set_ext_scan_en_cmd_handler = 0x40000000; +r_lld_scan_process_pkt_rx_ext_adv = 0x40000000; +r_lld_scan_trunc_ind = 0x40000000; diff --git a/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_smp.ld b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_smp.ld new file mode 100644 index 0000000000..78d1fb9784 --- /dev/null +++ b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_smp.ld @@ -0,0 +1,44 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32s3.rom.ld for esp32s3 + * + * + * Generated from ./interface-esp32s3.yml md5sum 39c4ce259b11323b9404c192b01b712b + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* SMP */ +f_ll_pause_enc_req_handler = 0x40000000; +f_ll_pause_enc_rsp_handler = 0x40000000; +f_ll_enc_req_handler = 0x40000000; +f_ll_enc_rsp_handler = 0x40000000; +f_ll_start_enc_req_handler = 0x40000000; +f_ll_start_enc_rsp_handler = 0x40000000; +f_hci_le_start_enc_cmd_handler = 0x40000000; +f_hci_le_ltk_req_reply_cmd_handler = 0x40000000; +f_hci_le_ltk_req_neg_reply_cmd_handler = 0x40000000; +f_llc_encrypt_ind_handler = 0x40000000; +f_llc_op_encrypt_ind_handler = 0x40000000; +f_hci_le_rd_local_p256_public_key_cmd_handler = 0x40000000; +f_hci_le_generate_dhkey_cmd_handler = 0x40000000; +f_hci_le_enc_cmd_handler = 0x40000000; +r_rwip_crypt_evt_handler = 0x40000000; + +/* LE ping */ +f_ll_ping_req_handler = 0x40000000; +f_ll_ping_rsp_handler = 0x40000000; +r_llc_le_ping_set = 0x40000000; +r_llc_le_ping_restart = 0x40000000; +f_llc_op_le_ping_ind_handler = 0x40000000; +f_llc_auth_payl_nearly_op_handler = 0x40000000; +f_llc_auth_payl_real_to_handler = 0x40000000; +f_llc_auth_payl_nearly_to_handler = 0x40000000; + +/* ecc */ +r_ecc_init = 0x40000000; diff --git a/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_test.ld b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_test.ld new file mode 100644 index 0000000000..1c0a6b59f0 --- /dev/null +++ b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_test.ld @@ -0,0 +1,37 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32s3.rom.ld for esp32s3 + * + * + * Generated from ./interface-esp32s3.yml md5sum 39c4ce259b11323b9404c192b01b712b + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + + +/* overwrite */ +lld_acl_rx_ind_handler = 0x40000000; +lld_con_estab_ind_handler = 0x40000000; +lld_adv_rep_ind_handler = 0x40000000; +llm_rpa_renew_to_handler = 0x40000000; +lld_scan_end_ind_handler = 0x40000000; +llm_scan_period_to_handler = 0x40000000; + +/* nvds */ +r_nvds_init = 0x40000000; +f_nvds_get = 0x40000000; +f_nvds_del = 0x40000000; +f_nvds_put = 0x40000000; + +/* controller flash */ +r_flash_init = 0x40000000; +r_flash_env_init = 0x40000000; +r_flash_env_deinit = 0x40000000; + +/* QA test */ +f_hci_vendor_ble_qa_test_cmd_handler = 0x40000000; diff --git a/components/esp_rom/esp32s3/ld/esp32s3.rom.bt_funcs.ld b/components/esp_rom/esp32s3/ld/esp32s3.rom.bt_funcs.ld new file mode 100644 index 0000000000..4111d0e8ac --- /dev/null +++ b/components/esp_rom/esp32s3/ld/esp32s3.rom.bt_funcs.ld @@ -0,0 +1,870 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32s3.rom.ld for esp32s3 + * + * + * Generated from ./interface-esp32s3.yml md5sum 39c4ce259b11323b9404c192b01b712b + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/*************************************** + Group bluetooth + ***************************************/ + +/* Functions */ +bt_rf_coex_get_dft_cfg = 0x40002a78; +bt_rf_coex_hooks_p_set = 0x40002a84; +btdm_con_maxevtime_cal_impl = 0x40002a90; +btdm_controller_get_compile_version_impl = 0x40002a9c; +btdm_controller_rom_data_init = 0x40002aa8; +btdm_dis_privacy_err_report_impl = 0x40002ab4; +btdm_disable_adv_delay_impl = 0x40002ac0; +btdm_enable_scan_continue_impl = 0x40002acc; +btdm_enable_scan_forever_impl = 0x40002ad8; +btdm_get_power_state_impl = 0x40002ae4; +btdm_get_prevent_sleep_flag_impl = 0x40002af0; +btdm_power_state_active_impl = 0x40002afc; +btdm_switch_phy_coded_impl = 0x40002b08; +hci_acl_data_handler = 0x40002b14; +hci_disconnect_cmd_handler = 0x40002b20; +hci_le_con_upd_cmd_handler = 0x40002b2c; +hci_le_ltk_req_neg_reply_cmd_handler = 0x40002b38; +hci_le_ltk_req_reply_cmd_handler = 0x40002b44; +hci_le_rd_chnl_map_cmd_handler = 0x40002b50; +hci_le_rd_phy_cmd_handler = 0x40002b5c; +hci_le_rd_rem_feats_cmd_handler = 0x40002b68; +hci_le_rem_con_param_req_neg_reply_cmd_handler = 0x40002b74; +hci_le_rem_con_param_req_reply_cmd_handler = 0x40002b80; +hci_le_set_data_len_cmd_handler = 0x40002b8c; +hci_le_set_phy_cmd_handler = 0x40002b98; +hci_le_start_enc_cmd_handler = 0x40002ba4; +hci_rd_auth_payl_to_cmd_handler = 0x40002bb0; +hci_rd_rem_ver_info_cmd_handler = 0x40002bbc; +hci_rd_rssi_cmd_handler = 0x40002bc8; +hci_rd_tx_pwr_lvl_cmd_handler = 0x40002bd4; +hci_vs_set_pref_slave_evt_dur_cmd_handler = 0x40002be0; +hci_vs_set_pref_slave_latency_cmd_handler = 0x40002bec; +hci_wr_auth_payl_to_cmd_handler = 0x40002bf8; +ll_channel_map_ind_handler = 0x40002c04; +ll_connection_param_req_handler = 0x40002c10; +ll_connection_param_rsp_handler = 0x40002c1c; +ll_connection_update_ind_handler = 0x40002c28; +ll_enc_req_handler = 0x40002c34; +ll_enc_rsp_handler = 0x40002c40; +ll_feature_req_handler = 0x40002c4c; +ll_feature_rsp_handler = 0x40002c58; +ll_length_req_handler = 0x40002c64; +ll_length_rsp_handler = 0x40002c70; +ll_min_used_channels_ind_handler = 0x40002c7c; +ll_pause_enc_req_handler = 0x40002c88; +ll_pause_enc_rsp_handler = 0x40002c94; +ll_phy_req_handler = 0x40002ca0; +ll_phy_rsp_handler = 0x40002cac; +ll_phy_update_ind_handler = 0x40002cb8; +ll_ping_req_handler = 0x40002cc4; +ll_ping_rsp_handler = 0x40002cd0; +ll_slave_feature_req_handler = 0x40002cdc; +ll_start_enc_req_handler = 0x40002ce8; +ll_start_enc_rsp_handler = 0x40002cf4; +ll_terminate_ind_handler = 0x40002d00; +ll_version_ind_handler = 0x40002d0c; +llc_auth_payl_nearly_to_handler = 0x40002d18; +llc_auth_payl_real_to_handler = 0x40002d24; +llc_encrypt_ind_handler = 0x40002d30; +llc_hci_command_handler_wrapper = 0x40002d3c; +llc_ll_connection_param_req_pdu_send = 0x40002d48; +llc_ll_connection_param_rsp_pdu_send = 0x40002d54; +llc_ll_connection_update_ind_pdu_send = 0x40002d60; +llc_ll_enc_req_pdu_send = 0x40002d6c; +llc_ll_enc_rsp_pdu_send = 0x40002d78; +llc_ll_feature_req_pdu_send = 0x40002d84; +llc_ll_feature_rsp_pdu_send = 0x40002d90; +llc_ll_length_req_pdu_send = 0x40002d9c; +llc_ll_length_rsp_pdu_send = 0x40002da8; +llc_ll_pause_enc_req_pdu_send = 0x40002db4; +llc_ll_pause_enc_rsp_pdu_send = 0x40002dc0; +llc_ll_phy_req_pdu_send = 0x40002dcc; +llc_ll_phy_rsp_pdu_send = 0x40002dd8; +llc_ll_ping_req_pdu_send = 0x40002de4; +llc_ll_ping_rsp_pdu_send = 0x40002df0; +llc_ll_start_enc_req_pdu_send = 0x40002dfc; +llc_ll_start_enc_rsp_pdu_send = 0x40002e08; +llc_ll_terminate_ind_pdu_send = 0x40002e14; +llc_ll_unknown_rsp_pdu_send = 0x40002e20; +llc_llcp_ch_map_update_ind_pdu_send = 0x40002e2c; +llc_llcp_phy_upd_ind_pdu_send = 0x40002e38; +llc_llcp_version_ind_pdu_send = 0x40002e44; +llc_op_ch_map_upd_ind_handler = 0x40002e50; +llc_op_con_upd_ind_handler = 0x40002e5c; +llc_op_disconnect_ind_handler = 0x40002e68; +llc_op_dl_upd_ind_handler = 0x40002e74; +llc_op_encrypt_ind_handler = 0x40002e80; +llc_op_feats_exch_ind_handler = 0x40002e8c; +llc_op_le_ping_ind_handler = 0x40002e98; +llc_op_phy_upd_ind_handler = 0x40002ea4; +llc_op_ver_exch_ind_handler = 0x40002eb0; +llc_stopped_ind_handler = 0x40002ebc; +lld_acl_rx_ind_handler = 0x40002ec8; +lld_acl_tx_cfm_handler = 0x40002ed4; +lld_adv_end_ind_handler = 0x40002ee0; +lld_adv_rep_ind_handler = 0x40002eec; +lld_ch_map_upd_cfm_handler = 0x40002ef8; +lld_con_estab_ind_handler = 0x40002f04; +lld_con_evt_sd_evt_time_set = 0x40002f10; +lld_con_offset_upd_ind_handler = 0x40002f1c; +lld_con_param_upd_cfm_handler = 0x40002f28; +lld_disc_ind_handler = 0x40002f34; +lld_init_end_ind_handler = 0x40002f40; +lld_llcp_rx_ind_handler_wrapper = 0x40002f4c; +lld_llcp_tx_cfm_handler = 0x40002f58; +lld_per_adv_end_ind_handler = 0x40002f64; +lld_per_adv_rep_ind_handler = 0x40002f70; +lld_per_adv_rx_end_ind_handler = 0x40002f7c; +lld_phy_coded_500k_get = 0x40002f88; +lld_phy_upd_cfm_handler = 0x40002f94; +lld_scan_end_ind_handler = 0x40002fa0; +lld_scan_req_ind_handler = 0x40002fac; +lld_sync_start_req_handler = 0x40002fb8; +lld_test_end_ind_handler = 0x40002fc4; +lld_update_rxbuf_handler = 0x40002fd0; +llm_ch_map_update_ind_handler = 0x40002fdc; +llm_hci_command_handler_wrapper = 0x40002fe8; +llm_scan_period_to_handler = 0x40002ff4; +r_Add2SelfBigHex256 = 0x40003000; +r_AddBigHex256 = 0x4000300c; +r_AddBigHexModP256 = 0x40003018; +r_AddP256 = 0x40003024; +r_AddPdiv2_256 = 0x40003030; +r_GF_Jacobian_Point_Addition256 = 0x4000303c; +r_GF_Jacobian_Point_Double256 = 0x40003048; +r_GF_Point_Jacobian_To_Affine256 = 0x40003054; +r_MultiplyBigHexByUint32_256 = 0x40003060; +r_MultiplyBigHexModP256 = 0x4000306c; +r_MultiplyByU16ModP256 = 0x40003078; +r_SubtractBigHex256 = 0x40003084; +r_SubtractBigHexMod256 = 0x40003090; +r_SubtractBigHexUint32_256 = 0x4000309c; +r_SubtractFromSelfBigHex256 = 0x400030a8; +r_SubtractFromSelfBigHexSign256 = 0x400030b4; +r_aes_alloc = 0x400030c0; +r_aes_ccm_continue = 0x400030cc; +r_aes_ccm_process_e = 0x400030d8; +r_aes_ccm_xor_128_lsb = 0x400030e4; +r_aes_ccm_xor_128_msb = 0x400030f0; +r_aes_cmac_continue = 0x400030fc; +r_aes_cmac_start = 0x40003108; +r_aes_k1_continue = 0x40003114; +r_aes_k2_continue = 0x40003120; +r_aes_k3_continue = 0x4000312c; +r_aes_k4_continue = 0x40003138; +r_aes_shift_left_128 = 0x40003144; +r_aes_start = 0x40003150; +r_aes_xor_128 = 0x4000315c; +r_assert_err = 0x40003168; +r_assert_param = 0x40003174; +r_assert_warn = 0x40003180; +r_bigHexInversion256 = 0x4000318c; +r_ble_sw_cca_check_isr = 0x40003198; +r_ble_util_buf_acl_tx_alloc = 0x400031a4; +r_ble_util_buf_acl_tx_elt_get = 0x400031b0; +r_ble_util_buf_acl_tx_free = 0x400031bc; +r_ble_util_buf_acl_tx_free_in_isr = 0x400031c8; +r_ble_util_buf_adv_tx_alloc = 0x400031d4; +r_ble_util_buf_adv_tx_free = 0x400031e0; +r_ble_util_buf_adv_tx_free_in_isr = 0x400031ec; +r_ble_util_buf_env_deinit = 0x400031f8; +r_ble_util_buf_env_init = 0x40003204; +r_ble_util_buf_get_rx_buf_nb = 0x40003210; +r_ble_util_buf_get_rx_buf_size = 0x4000321c; +r_ble_util_buf_llcp_tx_alloc = 0x40003228; +r_ble_util_buf_llcp_tx_free = 0x40003234; +r_ble_util_buf_rx_alloc = 0x40003240; +r_ble_util_buf_rx_alloc_in_isr = 0x4000324c; +r_ble_util_buf_rx_free = 0x40003258; +r_ble_util_buf_rx_free_in_isr = 0x40003264; +r_ble_util_buf_set_rx_buf_nb = 0x40003270; +r_ble_util_buf_set_rx_buf_size = 0x4000327c; +r_ble_util_data_rx_buf_reset = 0x40003288; +r_bt_bb_get_intr_mask = 0x40003294; +r_bt_bb_intr_clear = 0x400032a0; +r_bt_bb_intr_mask_set = 0x400032ac; +r_bt_rf_coex_cfg_set = 0x400032c4; +r_bt_rf_coex_conn_dynamic_pti_en_get = 0x400032d0; +r_bt_rf_coex_ext_adv_dynamic_pti_en_get = 0x400032e8; +r_bt_rf_coex_ext_scan_dynamic_pti_en_get = 0x400032f4; +r_bt_rf_coex_legacy_adv_dynamic_pti_en_get = 0x40003300; +r_bt_rf_coex_per_adv_dynamic_pti_en_get = 0x4000330c; +r_bt_rf_coex_pti_table_get = 0x40003318; +r_bt_rf_coex_st_param_get = 0x40003324; +r_bt_rf_coex_st_param_set = 0x40003330; +r_bt_rf_coex_sync_scan_dynamic_pti_en_get = 0x4000333c; +r_bt_rma_apply_rule_cs_fmt = 0x40003348; +r_bt_rma_apply_rule_cs_idx = 0x40003354; +r_bt_rma_configure = 0x40003360; +r_bt_rma_deregister_rule_cs_fmt = 0x4000336c; +r_bt_rma_deregister_rule_cs_idx = 0x40003378; +r_bt_rma_get_ant_by_act = 0x40003384; +r_bt_rma_init = 0x40003390; +r_bt_rma_register_rule_cs_fmt = 0x4000339c; +r_bt_rma_register_rule_cs_idx = 0x400033a8; +r_bt_rtp_apply_rule_cs_fmt = 0x400033b4; +r_bt_rtp_apply_rule_cs_idx = 0x400033c0; +r_bt_rtp_deregister_rule_cs_fmt = 0x400033cc; +r_bt_rtp_deregister_rule_cs_idx = 0x400033d8; +r_bt_rtp_init = 0x400033f0; +r_bt_rtp_register_rule_cs_fmt = 0x400033fc; +r_bt_rtp_register_rule_cs_idx = 0x40003408; +r_btdm_isr = 0x40003414; +r_cali_phase_match_p = 0x40003444; +r_cmp_abs_time = 0x40003450; +r_cmp_dest_id = 0x4000345c; +r_cmp_timer_id = 0x40003468; +r_co_bdaddr_compare = 0x40003474; +r_co_ble_pkt_dur_in_us = 0x40003480; +r_co_list_extract = 0x4000348c; +r_co_list_extract_after = 0x40003498; +r_co_list_extract_sublist = 0x400034a4; +r_co_list_find = 0x400034b0; +r_co_list_init = 0x400034bc; +r_co_list_insert_after = 0x400034c8; +r_co_list_insert_before = 0x400034d4; +r_co_list_merge = 0x400034e0; +r_co_list_pool_init = 0x400034ec; +r_co_list_pop_front = 0x400034f8; +r_co_list_push_back = 0x40003504; +r_co_list_push_back_sublist = 0x40003510; +r_co_list_push_front = 0x4000351c; +r_co_list_size = 0x40003528; +r_co_nb_good_le_channels = 0x40003534; +r_co_util_pack = 0x40003540; +r_co_util_read_array_size = 0x4000354c; +r_co_util_unpack = 0x40003558; +r_dbg_env_deinit = 0x40003564; +r_dbg_env_init = 0x40003570; +r_dbg_platform_reset_complete = 0x4000357c; +r_dl_upd_proc_start = 0x40003588; +r_dump_data = 0x40003594; +r_ecc_abort_key256_generation = 0x400035a0; +r_ecc_gen_new_public_key = 0x400035ac; +r_ecc_gen_new_secret_key = 0x400035b8; +r_ecc_generate_key256 = 0x400035c4; +r_ecc_get_debug_Keys = 0x400035d0; +r_ecc_init = 0x400035dc; +r_ecc_is_valid_point = 0x400035e8; +r_ecc_multiplication_event_handler = 0x400035f4; +r_ecc_point_multiplication_win_256 = 0x40003600; +r_emi_alloc_em_mapping_by_offset = 0x4000360c; +r_emi_base_reg_lut_show = 0x40003618; +r_emi_em_base_reg_show = 0x40003624; +r_emi_free_em_mapping_by_offset = 0x40003630; +r_emi_get_em_mapping_idx_by_offset = 0x4000363c; +r_emi_get_mem_addr_by_offset = 0x40003648; +r_emi_overwrite_em_mapping_by_offset = 0x40003654; +r_esp_vendor_hci_command_handler = 0x40003660; +r_get_stack_usage = 0x4000366c; +r_h4tl_acl_hdr_rx_evt_handler = 0x40003678; +r_h4tl_cmd_hdr_rx_evt_handler = 0x40003684; +r_h4tl_cmd_pld_rx_evt_handler = 0x40003690; +r_h4tl_eif_io_event_post = 0x4000369c; +r_h4tl_eif_register = 0x400036a8; +r_h4tl_init = 0x400036b4; +r_h4tl_out_of_sync = 0x400036c0; +r_h4tl_out_of_sync_check = 0x400036cc; +r_h4tl_read_hdr = 0x400036d8; +r_h4tl_read_next_out_of_sync = 0x400036e4; +r_h4tl_read_payl = 0x400036f0; +r_h4tl_read_start = 0x400036fc; +r_h4tl_rx_acl_hdr_extract = 0x40003708; +r_h4tl_rx_cmd_hdr_extract = 0x40003714; +r_h4tl_rx_done = 0x40003720; +r_h4tl_start = 0x4000372c; +r_h4tl_stop = 0x40003738; +r_h4tl_tx_done = 0x40003744; +r_h4tl_tx_evt_handler = 0x40003750; +r_h4tl_write = 0x4000375c; +r_hci_acl_tx_data_alloc = 0x40003768; +r_hci_acl_tx_data_received = 0x40003774; +r_hci_basic_cmd_send_2_controller = 0x40003780; +r_hci_ble_adv_report_filter_check = 0x4000378c; +r_hci_ble_adv_report_tx_check = 0x40003798; +r_hci_ble_conhdl_register = 0x400037a4; +r_hci_ble_conhdl_unregister = 0x400037b0; +r_hci_build_acl_data = 0x400037bc; +r_hci_build_cc_evt = 0x400037c8; +r_hci_build_cs_evt = 0x400037d4; +r_hci_build_evt = 0x400037e0; +r_hci_build_le_evt = 0x400037ec; +r_hci_cmd_get_max_param_size = 0x400037f8; +r_hci_cmd_received = 0x40003804; +r_hci_cmd_reject = 0x40003810; +r_hci_evt_mask_check = 0x4000381c; +r_hci_evt_mask_set = 0x40003828; +r_hci_fc_acl_buf_size_set = 0x40003834; +r_hci_fc_acl_en = 0x40003840; +r_hci_fc_acl_packet_sent = 0x4000384c; +r_hci_fc_check_host_available_nb_acl_packets = 0x40003858; +r_hci_fc_host_nb_acl_pkts_complete = 0x40003864; +r_hci_fc_init = 0x40003870; +r_hci_look_for_cmd_desc = 0x4000387c; +r_hci_look_for_evt_desc = 0x40003888; +r_hci_look_for_le_evt_desc = 0x40003894; +r_hci_look_for_le_evt_desc_esp = 0x400038a0; +r_hci_pack_bytes = 0x400038ac; +r_hci_send_2_controller = 0x400038c4; +r_hci_send_2_host = 0x400038d0; +r_hci_tl_c2h_data_flow_on = 0x400038dc; +r_hci_tl_cmd_hdr_rx_evt_handler = 0x400038e8; +r_hci_tl_cmd_pld_rx_evt_handler = 0x400038f4; +r_hci_tl_get_pkt = 0x40003900; +r_hci_tl_hci_pkt_handler = 0x4000390c; +r_hci_tl_hci_tx_done_evt_handler = 0x40003918; +r_hci_tl_inc_nb_h2c_cmd_pkts = 0x40003924; +r_hci_tl_save_pkt = 0x40003930; +r_hci_tl_send = 0x4000393c; +r_hci_tx_done = 0x40003948; +r_hci_tx_start = 0x40003954; +r_hci_tx_trigger = 0x40003960; +r_isValidSecretKey_256 = 0x4000396c; +r_ke_check_malloc = 0x40003978; +r_ke_event_callback_set = 0x40003984; +r_ke_event_clear = 0x40003990; +r_ke_event_flush = 0x4000399c; +r_ke_event_get = 0x400039a8; +r_ke_event_get_all = 0x400039b4; +r_ke_event_init = 0x400039c0; +r_ke_event_schedule = 0x400039cc; +r_ke_event_set = 0x400039d8; +r_ke_flush = 0x400039e4; +r_ke_free = 0x400039f0; +r_ke_handler_search = 0x400039fc; +r_ke_init = 0x40003a08; +r_ke_is_free = 0x40003a14; +r_ke_malloc = 0x40003a20; +r_ke_mem_init = 0x40003a2c; +r_ke_mem_is_empty = 0x40003a38; +r_ke_mem_is_in_heap = 0x40003a44; +r_ke_msg_alloc = 0x40003a50; +r_ke_msg_dest_id_get = 0x40003a5c; +r_ke_msg_discard = 0x40003a68; +r_ke_msg_forward = 0x40003a74; +r_ke_msg_forward_new_id = 0x40003a80; +r_ke_msg_free = 0x40003a8c; +r_ke_msg_in_queue = 0x40003a98; +r_ke_msg_save = 0x40003aa4; +r_ke_msg_send = 0x40003ab0; +r_ke_msg_send_basic = 0x40003abc; +r_ke_msg_src_id_get = 0x40003ac8; +r_ke_queue_extract = 0x40003ad4; +r_ke_queue_insert = 0x40003ae0; +r_ke_sleep_check = 0x40003aec; +r_ke_state_get = 0x40003af8; +r_ke_state_set = 0x40003b04; +r_ke_task_check = 0x40003b10; +r_ke_task_create = 0x40003b1c; +r_ke_task_delete = 0x40003b28; +r_ke_task_handler_get = 0x40003b34; +r_ke_task_init = 0x40003b40; +r_ke_task_msg_flush = 0x40003b4c; +r_ke_task_saved_update = 0x40003b58; +r_ke_time = 0x40003b70; +r_ke_time_cmp = 0x40003b7c; +r_ke_time_past = 0x40003b88; +r_ke_timer_active = 0x40003b94; +r_ke_timer_adjust_all = 0x40003ba0; +r_ke_timer_clear = 0x40003bac; +r_ke_timer_init = 0x40003bb8; +r_ke_timer_schedule = 0x40003bc4; +r_ke_timer_set = 0x40003bd0; +r_led_init = 0x40003bdc; +r_led_set_all = 0x40003be8; +r_llc_aes_res_cb = 0x40003bf4; +r_llc_ch_map_up_proc_err_cb = 0x40003c00; +r_llc_cleanup = 0x40003c0c; +r_llc_cmd_cmp_send = 0x40003c18; +r_llc_cmd_stat_send = 0x40003c24; +r_llc_con_move_cbk = 0x40003c30; +r_llc_con_plan_set_update = 0x40003c3c; +r_llc_con_upd_param_in_range = 0x40003c48; +r_llc_disconnect = 0x40003c54; +r_llc_disconnect_end = 0x40003c60; +r_llc_disconnect_proc_continue = 0x40003c6c; +r_llc_disconnect_proc_err_cb = 0x40003c78; +r_llc_dl_chg_check = 0x40003c84; +r_llc_dle_proc_err_cb = 0x40003c90; +r_llc_feats_exch_proc_err_cb = 0x40003c9c; +r_llc_hci_cmd_handler_tab_p_get = 0x40003ca8; +r_llc_hci_con_param_req_evt_send = 0x40003cc0; +r_llc_hci_con_upd_info_send = 0x40003ccc; +r_llc_hci_disconnected_dis = 0x40003cd8; +r_llc_hci_dl_upd_info_send = 0x40003ce4; +r_llc_hci_enc_evt_send = 0x40003cf0; +r_llc_hci_feats_info_send = 0x40003cfc; +r_llc_hci_le_phy_upd_cmp_evt_send = 0x40003d08; +r_llc_hci_ltk_request_evt_send = 0x40003d14; +r_llc_hci_nb_cmp_pkts_evt_send = 0x40003d20; +r_llc_hci_version_info_send = 0x40003d2c; +r_llc_init_term_proc = 0x40003d38; +r_llc_iv_skd_rand_gen = 0x40003d44; +r_llc_le_ping_proc_continue = 0x40003d50; +r_llc_le_ping_proc_err_cb = 0x40003d5c; +/* r_llc_le_ping_restart = 0x40003d68; */ +r_llc_le_ping_set = 0x40003d74; +r_llc_ll_pause_enc_rsp_ack_handler = 0x40003d80; +r_llc_ll_reject_ind_ack_handler = 0x40003d8c; +r_llc_ll_reject_ind_pdu_send = 0x40003d98; +r_llc_ll_start_enc_rsp_ack_handler = 0x40003da4; +r_llc_ll_terminate_ind_ack = 0x40003db0; +r_llc_ll_unknown_ind_handler = 0x40003dbc; +r_llc_llcp_send = 0x40003dc8; +r_llc_llcp_state_set = 0x40003dd4; +r_llc_llcp_trans_timer_set = 0x40003de0; +r_llc_llcp_tx_check = 0x40003dec; +/* r_llc_loc_ch_map_proc_continue = 0x40003df8; */ +r_llc_loc_con_upd_proc_err_cb = 0x40003e10; +r_llc_loc_dl_upd_proc_continue = 0x40003e1c; +r_llc_loc_encrypt_proc_continue = 0x40003e28; +r_llc_loc_encrypt_proc_err_cb = 0x40003e34; +r_llc_loc_feats_exch_proc_continue = 0x40003e40; +r_llc_loc_phy_upd_proc_err_cb = 0x40003e58; +r_llc_msg_handler_tab_p_get = 0x40003e64; +r_llc_pref_param_compute = 0x40003e70; +r_llc_proc_collision_check = 0x40003e7c; +r_llc_proc_err_ind = 0x40003e88; +r_llc_proc_get = 0x40003e94; +r_llc_proc_id_get = 0x40003ea0; +r_llc_proc_reg = 0x40003eac; +r_llc_proc_state_get = 0x40003eb8; +r_llc_proc_state_set = 0x40003ec4; +r_llc_proc_timer_pause_set = 0x40003ed0; +r_llc_proc_timer_set = 0x40003edc; +r_llc_proc_unreg = 0x40003ee8; +r_llc_rem_ch_map_proc_continue = 0x40003ef4; +r_llc_rem_con_upd_proc_err_cb = 0x40003f0c; +r_llc_rem_dl_upd_proc = 0x40003f18; +r_llc_rem_encrypt_proc_continue = 0x40003f24; +r_llc_rem_encrypt_proc_err_cb = 0x40003f30; +r_llc_rem_phy_upd_proc_continue = 0x40003f3c; +r_llc_rem_phy_upd_proc_err_cb = 0x40003f48; +r_llc_role_get = 0x40003f54; +r_llc_sk_gen = 0x40003f60; +r_llc_start = 0x40003f6c; +r_llc_stop = 0x40003f78; +r_llc_ver_exch_loc_proc_continue = 0x40003f84; +r_llc_ver_proc_err_cb = 0x40003f90; +r_llcp_pdu_handler_tab_p_get = 0x40003f9c; +r_lld_aa_gen = 0x40003fa8; +r_lld_adv_adv_data_set = 0x40003fb4; +r_lld_adv_adv_data_update = 0x40003fc0; +r_lld_adv_aux_ch_idx_set = 0x40003fcc; +r_lld_adv_aux_evt_canceled_cbk = 0x40003fd8; +r_lld_adv_aux_evt_start_cbk = 0x40003fe4; +r_lld_adv_coex_check_ext_adv_synced = 0x40003ff0; +r_lld_adv_coex_env_reset = 0x40003ffc; +r_lld_adv_duration_update = 0x40004008; +r_lld_adv_dynamic_pti_process = 0x40004014; +r_lld_adv_end = 0x40004020; +r_lld_adv_evt_canceled_cbk = 0x4000402c; +r_lld_adv_evt_start_cbk = 0x40004038; +r_lld_adv_ext_chain_construct = 0x40004044; +r_lld_adv_ext_pkt_prepare = 0x40004050; +r_lld_adv_frm_cbk = 0x4000405c; +r_lld_adv_frm_isr = 0x40004068; +r_lld_adv_frm_skip_isr = 0x40004074; +r_lld_adv_init = 0x40004080; +r_lld_adv_pkt_rx = 0x4000408c; +r_lld_adv_pkt_rx_connect_ind = 0x40004098; +r_lld_adv_pkt_rx_send_scan_req_evt = 0x400040a4; +r_lld_adv_rand_addr_update = 0x400040b0; +r_lld_adv_restart = 0x400040bc; +r_lld_adv_scan_rsp_data_set = 0x400040c8; +r_lld_adv_scan_rsp_data_update = 0x400040d4; +r_lld_adv_set_tx_power = 0x400040e0; +r_lld_adv_start = 0x400040ec; +r_lld_adv_stop = 0x400040f8; +r_lld_adv_sync_info_set = 0x40004104; +r_lld_adv_sync_info_update = 0x40004110; +r_lld_calc_aux_rx = 0x4000411c; +r_lld_cca_alloc = 0x40004128; +r_lld_cca_data_reset = 0x40004134; +r_lld_cca_free = 0x40004140; +r_lld_ch_assess_data_get = 0x4000414c; +r_lld_ch_idx_get = 0x40004158; +r_lld_ch_map_set = 0x40004164; +r_lld_channel_assess = 0x40004170; +r_lld_con_activity_act_offset_compute = 0x4000417c; +r_lld_con_activity_offset_compute = 0x40004188; +r_lld_con_ch_map_update = 0x40004194; +r_lld_con_cleanup = 0x400041a0; +r_lld_con_current_tx_power_get = 0x400041ac; +r_lld_con_data_flow_set = 0x400041b8; +r_lld_con_data_len_update = 0x400041c4; +r_lld_con_data_tx = 0x400041d0; +r_lld_con_enc_key_load = 0x400041dc; +r_lld_con_event_counter_get = 0x400041e8; +r_lld_con_evt_canceled_cbk = 0x400041f4; +r_lld_con_evt_duration_min_get = 0x40004200; +r_lld_con_evt_max_eff_time_cal = 0x4000420c; +r_lld_con_evt_sd_evt_time_get = 0x40004218; +r_lld_con_evt_start_cbk = 0x40004224; +r_lld_con_evt_time_update = 0x40004230; +r_lld_con_free_all_tx_buf = 0x4000423c; +r_lld_con_frm_cbk = 0x40004248; +r_lld_con_frm_isr = 0x40004254; +r_lld_con_frm_skip_isr = 0x40004260; +r_lld_con_init = 0x4000426c; +r_lld_con_llcp_tx = 0x40004278; +r_lld_con_max_lat_calc = 0x40004284; +r_lld_con_offset_get = 0x40004290; +r_lld_con_param_update = 0x4000429c; +r_lld_con_phys_update = 0x400042a8; +r_lld_con_pref_slave_evt_dur_set = 0x400042b4; +r_lld_con_pref_slave_latency_set = 0x400042c0; +r_lld_con_rssi_get = 0x400042cc; +r_lld_con_rx = 0x400042d8; +/* r_lld_con_rx_channel_assess = 0x400042e4; */ +r_lld_con_rx_enc = 0x400042f0; +r_lld_con_rx_isr = 0x400042fc; +r_lld_con_rx_link_info_check = 0x40004308; +r_lld_con_rx_llcp_check = 0x40004314; +r_lld_con_rx_sync_time_update = 0x40004320; +r_lld_con_set_tx_power = 0x40004338; +r_lld_con_start = 0x40004344; +r_lld_con_tx = 0x4000435c; +r_lld_con_tx_enc = 0x40004368; +r_lld_con_tx_isr = 0x40004374; +r_lld_con_tx_len_update = 0x40004380; +r_lld_con_tx_len_update_for_intv = 0x4000438c; +r_lld_con_tx_len_update_for_rate = 0x40004398; +r_lld_con_tx_prog = 0x400043a4; +r_lld_conn_dynamic_pti_process = 0x400043b0; +r_lld_continue_scan_rx_isr_end_process = 0x400043bc; +r_lld_ext_scan_dynamic_pti_process = 0x400043c8; +r_lld_hw_cca_end_isr = 0x400043d4; +r_lld_hw_cca_evt_handler = 0x400043e0; +r_lld_hw_cca_isr = 0x400043ec; +r_lld_init_cal_anchor_point = 0x400043f8; +r_lld_init_compute_winoffset = 0x40004404; +r_lld_init_connect_req_pack = 0x40004410; +r_lld_init_end = 0x4000441c; +r_lld_init_evt_canceled_cbk = 0x40004428; +r_lld_init_evt_start_cbk = 0x40004434; +r_lld_init_frm_cbk = 0x40004440; +r_lld_init_frm_eof_isr = 0x4000444c; +r_lld_init_frm_skip_isr = 0x40004458; +r_lld_init_init = 0x40004464; +r_lld_init_process_pkt_rx = 0x40004470; +r_lld_init_process_pkt_rx_adv_ext_ind = 0x4000447c; +r_lld_init_process_pkt_rx_adv_ind_or_direct_ind = 0x40004488; +r_lld_init_process_pkt_rx_aux_connect_rsp = 0x40004494; +r_lld_init_process_pkt_tx = 0x400044a0; +r_lld_init_process_pkt_tx_cal_con_timestamp = 0x400044ac; +r_lld_init_sched = 0x400044b8; +r_lld_init_set_tx_power = 0x400044c4; +r_lld_init_start = 0x400044d0; +r_lld_init_stop = 0x400044dc; +r_lld_instant_proc_end = 0x400044e8; +r_lld_per_adv_ch_map_update = 0x40004500; +r_lld_per_adv_chain_construct = 0x4000450c; +r_lld_per_adv_cleanup = 0x40004518; +r_lld_per_adv_coex_env_reset = 0x40004524; +r_lld_per_adv_data_set = 0x40004530; +r_lld_per_adv_data_update = 0x4000453c; +r_lld_per_adv_dynamic_pti_process = 0x40004548; +r_lld_per_adv_evt_canceled_cbk = 0x40004554; +r_lld_per_adv_evt_start_cbk = 0x40004560; +r_lld_per_adv_ext_pkt_prepare = 0x4000456c; +r_lld_per_adv_frm_cbk = 0x40004578; +r_lld_per_adv_frm_isr = 0x40004584; +r_lld_per_adv_frm_skip_isr = 0x40004590; +r_lld_per_adv_init = 0x4000459c; +r_lld_per_adv_init_info_get = 0x400045a8; +r_lld_per_adv_list_add = 0x400045b4; +r_lld_per_adv_list_rem = 0x400045c0; +r_lld_per_adv_set_tx_power = 0x400045d8; +r_lld_per_adv_start = 0x400045e4; +r_lld_per_adv_stop = 0x400045f0; +r_lld_per_adv_sync_info_get = 0x400045fc; +r_lld_process_cca_data = 0x40004608; +r_lld_ral_search = 0x40004614; +r_lld_read_clock = 0x40004620; +r_lld_res_list_add = 0x4000462c; +r_lld_res_list_is_empty = 0x40004644; +r_lld_res_list_local_rpa_get = 0x40004650; +r_lld_res_list_peer_rpa_get = 0x4000465c; +r_lld_res_list_peer_update = 0x40004668; +/* r_lld_res_list_priv_mode_update = 0x40004674; */ +r_lld_reset_reg = 0x4000468c; +r_lld_rpa_renew = 0x40004698; +r_lld_rpa_renew_evt_canceled_cbk = 0x400046a4; +r_lld_rpa_renew_evt_start_cbk = 0x400046b0; +r_lld_rpa_renew_instant_cbk = 0x400046bc; +r_lld_rxdesc_check = 0x400046c8; +r_lld_rxdesc_free = 0x400046d4; +r_lld_scan_create_sync = 0x400046e0; +r_lld_scan_create_sync_cancel = 0x400046ec; +r_lld_scan_end = 0x400046f8; +r_lld_scan_evt_canceled_cbk = 0x40004704; +r_lld_scan_evt_start_cbk = 0x40004710; +r_lld_scan_frm_cbk = 0x4000471c; +r_lld_scan_frm_eof_isr = 0x40004728; +r_lld_scan_frm_rx_isr = 0x40004734; +r_lld_scan_frm_skip_isr = 0x40004740; +r_lld_scan_init = 0x4000474c; +r_lld_scan_params_update = 0x40004758; +r_lld_scan_process_pkt_rx_aux_adv_ind = 0x4000477c; +r_lld_scan_process_pkt_rx_aux_chain_ind = 0x40004788; +r_lld_scan_process_pkt_rx_aux_scan_rsp = 0x40004794; +r_lld_scan_process_pkt_rx_ext_adv = 0x400047a0; +r_lld_scan_process_pkt_rx_ext_adv_ind = 0x400047ac; +r_lld_scan_process_pkt_rx_legacy_adv = 0x400047b8; +r_lld_scan_restart = 0x400047c4; +r_lld_scan_sched = 0x400047d0; +r_lld_scan_set_tx_power = 0x400047dc; +r_lld_scan_start = 0x400047e8; +r_lld_scan_stop = 0x400047f4; +r_lld_scan_sync_accept = 0x40004800; +r_lld_scan_sync_info_unpack = 0x4000480c; +r_lld_scan_trunc_ind = 0x40004818; +r_lld_sw_cca_evt_handler = 0x40004824; +r_lld_sw_cca_isr = 0x40004830; +r_lld_sync_ch_map_update = 0x4000483c; +r_lld_sync_cleanup = 0x40004848; +r_lld_sync_evt_canceled_cbk = 0x40004854; +r_lld_sync_evt_start_cbk = 0x40004860; +r_lld_sync_frm_cbk = 0x4000486c; +r_lld_sync_frm_eof_isr = 0x40004878; +r_lld_sync_frm_rx_isr = 0x40004884; +r_lld_sync_frm_skip_isr = 0x40004890; +r_lld_sync_init = 0x4000489c; +r_lld_sync_process_pkt_rx = 0x400048a8; +r_lld_sync_process_pkt_rx_aux_sync_ind = 0x400048b4; +r_lld_sync_process_pkt_rx_pkt_check = 0x400048c0; +r_lld_sync_scan_dynamic_pti_process = 0x400048cc; +r_lld_sync_sched = 0x400048d8; +r_lld_sync_start = 0x400048e4; +r_lld_sync_stop = 0x400048f0; +r_lld_sync_trunc_ind = 0x400048fc; +r_lld_test_cleanup = 0x40004908; +r_lld_test_evt_canceled_cbk = 0x40004914; +r_lld_test_evt_start_cbk = 0x40004920; +r_lld_test_freq2chnl = 0x4000492c; +r_lld_test_frm_cbk = 0x40004938; +r_lld_test_frm_isr = 0x40004944; +r_lld_test_init = 0x40004950; +r_lld_test_rx_isr = 0x4000495c; +r_lld_test_set_tx_power = 0x40004968; +r_lld_test_start = 0x40004974; +/* r_lld_test_stop = 0x40004980;*/ +r_lld_update_rxbuf = 0x4000498c; +r_lld_update_rxbuf_isr = 0x40004998; +r_lld_white_list_add = 0x400049a4; +r_lld_white_list_rem = 0x400049b0; +r_llm_activity_free_get = 0x400049bc; +r_llm_activity_free_set = 0x400049c8; +r_llm_activity_syncing_get = 0x400049d4; +r_llm_adv_con_len_check = 0x400049e0; +r_llm_adv_hdl_to_id = 0x400049ec; +r_llm_adv_rep_flow_control_check = 0x400049f8; +r_llm_adv_rep_flow_control_update = 0x40004a04; +r_llm_adv_reports_list_check = 0x40004a10; +r_llm_adv_set_all_release = 0x40004a1c; +r_llm_adv_set_dft_params = 0x40004a28; +r_llm_adv_set_release = 0x40004a34; +r_llm_aes_res_cb = 0x40004a40; +r_llm_ble_update_adv_flow_control = 0x40004a4c; +r_llm_ch_map_update = 0x40004a58; +r_llm_cmd_cmp_send = 0x40004a64; +r_llm_cmd_stat_send = 0x40004a70; +r_llm_dev_list_empty_entry = 0x40004a7c; +r_llm_dev_list_search = 0x40004a88; +r_llm_env_adv_dup_filt_deinit = 0x40004a94; +r_llm_env_adv_dup_filt_init = 0x40004aa0; +r_llm_init_ble_adv_report_flow_contol = 0x40004aac; +r_llm_is_dev_connected = 0x40004ab8; +r_llm_is_dev_synced = 0x40004ac4; +r_llm_is_non_con_act_ongoing_check = 0x40004ad0; +r_llm_is_wl_accessible = 0x40004adc; +r_llm_le_evt_mask_check = 0x40004ae8; +r_llm_link_disc = 0x40004b00; +r_llm_master_ch_map_get = 0x40004b0c; +r_llm_msg_handler_tab_p_get = 0x40004b18; +r_llm_no_activity = 0x40004b24; +r_llm_per_adv_slot_dur = 0x40004b30; +r_llm_plan_elt_get = 0x40004b3c; +r_llm_rx_path_comp_get = 0x40004b48; +r_llm_scan_start = 0x40004b54; +r_llm_scan_sync_acad_attach = 0x40004b60; +r_llm_scan_sync_acad_detach = 0x40004b6c; +r_llm_send_adv_lost_event_to_host = 0x40004b78; +r_llm_tx_path_comp_get = 0x40004b84; +r_misc_deinit = 0x40004b90; +r_misc_free_em_buf_in_isr = 0x40004b9c; +r_misc_init = 0x40004ba8; +r_misc_msg_handler_tab_p_get = 0x40004bb4; +r_notEqual256 = 0x40004bc0; +r_phy_upd_proc_start = 0x40004bcc; +r_platform_reset = 0x40004bd8; +r_rf_em_init = 0x40004bf0; +r_rf_force_agc_enable = 0x40004bfc; +r_rf_reg_rd = 0x40004c08; +r_rf_reg_wr = 0x40004c14; +r_rf_reset = 0x40004c20; +r_rf_rssi_convert = 0x40004c2c; +r_rf_rw_v9_le_disable = 0x40004c38; +r_rf_rw_v9_le_enable = 0x40004c44; +r_rf_sleep = 0x40004c50; +r_rf_util_cs_fmt_convert = 0x40004c74; +r_rw_crypto_aes_ccm = 0x40004c80; +r_rw_crypto_aes_encrypt = 0x40004c8c; +r_rw_crypto_aes_init = 0x40004c98; +r_rw_crypto_aes_k1 = 0x40004ca4; +r_rw_crypto_aes_k2 = 0x40004cb0; +r_rw_crypto_aes_k3 = 0x40004cbc; +r_rw_crypto_aes_k4 = 0x40004cc8; +r_rw_crypto_aes_rand = 0x40004cd4; +r_rw_crypto_aes_result_handler = 0x40004ce0; +r_rw_crypto_aes_s1 = 0x40004cec; +r_rw_cryto_aes_cmac = 0x40004cf8; +r_rw_v9_init_em_radio_table = 0x40004d04; +r_rwble_sleep_enter = 0x40004d1c; +r_rwble_sleep_wakeup_end = 0x40004d28; +/* r_rwbtdm_isr_wrapper = 0x40004d34; */ +r_rwip_active_check = 0x40004d40; +r_rwip_aes_encrypt = 0x40004d4c; +/* r_rwip_assert = 0x40004d58; */ +r_rwip_crypt_evt_handler = 0x40004d64; +r_rwip_crypt_isr_handler = 0x40004d70; +r_rwip_eif_get = 0x40004d7c; +r_rwip_half_slot_2_lpcycles = 0x40004d88; +r_rwip_hus_2_lpcycles = 0x40004d94; +r_rwip_isr = 0x40004da0; +r_rwip_lpcycles_2_hus = 0x40004dac; +r_rwip_prevent_sleep_clear = 0x40004db8; +r_rwip_prevent_sleep_set = 0x40004dc4; +r_rwip_schedule = 0x40004dd0; +r_rwip_sleep = 0x40004ddc; +r_rwip_sw_int_handler = 0x40004de8; +r_rwip_sw_int_req = 0x40004df4; +r_rwip_time_get = 0x40004e00; +r_rwip_timer_10ms_handler = 0x40004e0c; +r_rwip_timer_10ms_set = 0x40004e18; +r_rwip_timer_hs_handler = 0x40004e24; +r_rwip_timer_hs_set = 0x40004e30; +r_rwip_timer_hus_handler = 0x40004e3c; +r_rwip_timer_hus_set = 0x40004e48; +r_rwip_wakeup = 0x40004e54; +/* r_rwip_wakeup_end = 0x40004e60; */ +r_rwip_wlcoex_set = 0x40004e6c; +r_sch_alarm_clear = 0x40004e78; +r_sch_alarm_init = 0x40004e84; +r_sch_alarm_prog = 0x40004e90; +r_sch_alarm_set = 0x40004e9c; +r_sch_alarm_timer_isr = 0x40004ea8; +r_sch_arb_conflict_check = 0x40004eb4; +r_sch_arb_elt_cancel = 0x40004ec0; +r_sch_arb_init = 0x40004ed8; +r_sch_arb_insert = 0x40004ee4; +r_sch_arb_prog_timer = 0x40004ef0; +r_sch_arb_remove = 0x40004efc; +r_sch_arb_sw_isr = 0x40004f08; +r_sch_plan_chk = 0x40004f14; +r_sch_plan_clock_wrap_offset_update = 0x40004f20; +r_sch_plan_init = 0x40004f2c; +r_sch_plan_interval_req = 0x40004f38; +r_sch_plan_offset_max_calc = 0x40004f44; +r_sch_plan_offset_req = 0x40004f50; +r_sch_plan_position_range_compute = 0x40004f5c; +r_sch_plan_rem = 0x40004f68; +r_sch_plan_req = 0x40004f74; +r_sch_prog_init = 0x40004f98; +r_sch_prog_push = 0x40004fa4; +r_sch_prog_rx_isr = 0x40004fb0; +r_sch_prog_skip_isr = 0x40004fbc; +r_sch_prog_tx_isr = 0x40004fc8; +r_sch_slice_bg_add = 0x40004fd4; +r_sch_slice_bg_remove = 0x40004fe0; +r_sch_slice_compute = 0x40004fec; +r_sch_slice_fg_add = 0x40004ff8; +r_sch_slice_fg_remove = 0x40005004; +r_sch_slice_init = 0x40005010; +r_sch_slice_per_add = 0x4000501c; +r_sch_slice_per_remove = 0x40005028; +r_sdk_config_get_bt_sleep_enable = 0x40005034; +r_sdk_config_get_hl_derived_opts = 0x40005040; +r_sdk_config_get_opts = 0x4000504c; +r_sdk_config_get_priv_opts = 0x40005058; +r_sdk_config_set_bt_sleep_enable = 0x40005064; +r_sdk_config_set_hl_derived_opts = 0x40005070; +r_sdk_config_set_opts = 0x4000507c; +r_specialModP256 = 0x40005088; +r_unloaded_area_init = 0x40005094; +r_vhci_flow_off = 0x400050a0; +r_vhci_flow_on = 0x400050ac; +r_vhci_notify_host_send_available = 0x400050b8; +r_vhci_send_to_host = 0x400050c4; +r_vnd_hci_command_handler = 0x400050d0; +r_vshci_init = 0x400050dc; +vnd_hci_command_handler_wrapper = 0x400050e8; +r_lld_legacy_adv_dynamic_pti_get = 0x400050f4; +r_lld_legacy_adv_dynamic_pti_process = 0x40005100; +r_lld_ext_adv_dynamic_pti_get = 0x4000510c; +r_lld_ext_adv_dynamic_aux_pti_process = 0x40005118; +r_lld_ext_adv_dynamic_pti_process = 0x40005124; +r_lld_adv_ext_pkt_prepare_set = 0x40005130; +r_lld_adv_ext_chain_connectable_construct = 0x40005148; +r_lld_adv_pkt_rx_connect_post = 0x40005160; +r_lld_adv_start_init_evt_param = 0x4000516c; +r_lld_adv_start_set_cs = 0x40005178; +/* r_lld_adv_start_update_filter_policy = 0x40005184; */ +r_lld_adv_start_schedule_asap = 0x40005190; +r_lld_con_tx_prog_new_packet_coex = 0x4000519c; +r_lld_per_adv_dynamic_pti_get = 0x400051b4; +r_lld_per_adv_evt_start_chm_upd = 0x400051c0; +r_lld_ext_scan_dynamic_pti_get = 0x400051cc; +r_lld_sync_insert = 0x400051e4; +r_sch_prog_ble_push = 0x400051f0; +r_sch_prog_bt_push = 0x400051fc; +r_lld_init_evt_end_type_set = 0x40005208; +r_lld_init_evt_end_type_get = 0x40005214; +r_lld_adv_direct_adv_use_rpa_addr_state_set = 0x40005220; +r_lld_adv_direct_adv_use_rpa_addr_state_get = 0x4000522c; +r_lld_init_evt_end_type_check_state_set = 0x40005238; +r_lld_init_evt_end_type_check_state_get = 0x40005244; + +/* bluetooth hook funcs */ +r_llc_loc_encrypt_proc_continue_hook = 0x40001c60; +r_llc_loc_phy_upd_proc_continue_hook = 0x40001c64; +r_llc_rem_phy_upd_proc_continue_hook = 0x40001c68; +r_lld_scan_frm_eof_isr_hook = 0x40001c6c; +r_lld_scan_evt_start_cbk_hook = 0x40001c70; +r_lld_scan_process_pkt_rx_ext_adv_hook = 0x40001c78; +r_lld_scan_sched_hook = 0x40001c7c; +r_lld_adv_evt_start_cbk_hook = 0x40001c84; +r_lld_adv_aux_evt_start_cbk_hook = 0x40001c88; +r_lld_adv_frm_isr_hook = 0x40001c8c; +r_lld_adv_start_init_evt_param_hook = 0x40001c90; +r_lld_con_evt_canceled_cbk_hook = 0x40001c94; +r_lld_con_frm_isr_hook = 0x40001c98; +r_lld_con_tx_hook = 0x40001c9c; +r_lld_con_rx_hook = 0x40001ca0; +r_lld_con_evt_start_cbk_hook = 0x40001ca4; +r_lld_con_tx_prog_new_packet_hook = 0x40001cac; +r_lld_init_frm_eof_isr_hook = 0x40001cb0; +r_lld_init_evt_start_cbk_hook = 0x40001cb4; +r_lld_init_sched_hook = 0x40001cbc; +r_lld_init_process_pkt_tx_hook = 0x40001cc0; +r_lld_per_adv_evt_start_cbk_hook = 0x40001cc4; +r_lld_per_adv_frm_isr_hook = 0x40001cc8; +r_lld_per_adv_start_hook = 0x40001ccc; +r_lld_sync_frm_eof_isr_hook = 0x40001cd0; +r_lld_sync_evt_start_cbk_hook = 0x40001cd4; +r_lld_sync_start_hook = 0x40001cd8; +r_lld_sync_process_pkt_rx_pkt_check_hook = 0x40001cdc; +r_sch_arb_insert_hook = 0x40001ce0; +r_sch_plan_offset_req_hook = 0x40001ce4; diff --git a/components/esp_rom/esp32s3/ld/esp32s3.rom.ld b/components/esp_rom/esp32s3/ld/esp32s3.rom.ld index e561e313d9..1bcd4b244e 100644 --- a/components/esp_rom/esp32s3/ld/esp32s3.rom.ld +++ b/components/esp_rom/esp32s3/ld/esp32s3.rom.ld @@ -799,825 +799,6 @@ rom_usb_osglue = 0x3fceffac; Group bluetooth ***************************************/ -/* Functions */ -bt_rf_coex_get_dft_cfg = 0x40002a78; -bt_rf_coex_hooks_p_set = 0x40002a84; -btdm_con_maxevtime_cal_impl = 0x40002a90; -btdm_controller_get_compile_version_impl = 0x40002a9c; -btdm_controller_rom_data_init = 0x40002aa8; -btdm_dis_privacy_err_report_impl = 0x40002ab4; -btdm_disable_adv_delay_impl = 0x40002ac0; -btdm_enable_scan_continue_impl = 0x40002acc; -btdm_enable_scan_forever_impl = 0x40002ad8; -btdm_get_power_state_impl = 0x40002ae4; -btdm_get_prevent_sleep_flag_impl = 0x40002af0; -btdm_power_state_active_impl = 0x40002afc; -btdm_switch_phy_coded_impl = 0x40002b08; -hci_acl_data_handler = 0x40002b14; -hci_disconnect_cmd_handler = 0x40002b20; -hci_le_con_upd_cmd_handler = 0x40002b2c; -hci_le_ltk_req_neg_reply_cmd_handler = 0x40002b38; -hci_le_ltk_req_reply_cmd_handler = 0x40002b44; -hci_le_rd_chnl_map_cmd_handler = 0x40002b50; -hci_le_rd_phy_cmd_handler = 0x40002b5c; -hci_le_rd_rem_feats_cmd_handler = 0x40002b68; -hci_le_rem_con_param_req_neg_reply_cmd_handler = 0x40002b74; -hci_le_rem_con_param_req_reply_cmd_handler = 0x40002b80; -hci_le_set_data_len_cmd_handler = 0x40002b8c; -hci_le_set_phy_cmd_handler = 0x40002b98; -hci_le_start_enc_cmd_handler = 0x40002ba4; -hci_rd_auth_payl_to_cmd_handler = 0x40002bb0; -hci_rd_rem_ver_info_cmd_handler = 0x40002bbc; -hci_rd_rssi_cmd_handler = 0x40002bc8; -hci_rd_tx_pwr_lvl_cmd_handler = 0x40002bd4; -hci_vs_set_pref_slave_evt_dur_cmd_handler = 0x40002be0; -hci_vs_set_pref_slave_latency_cmd_handler = 0x40002bec; -hci_wr_auth_payl_to_cmd_handler = 0x40002bf8; -ll_channel_map_ind_handler = 0x40002c04; -ll_connection_param_req_handler = 0x40002c10; -ll_connection_param_rsp_handler = 0x40002c1c; -ll_connection_update_ind_handler = 0x40002c28; -ll_enc_req_handler = 0x40002c34; -ll_enc_rsp_handler = 0x40002c40; -ll_feature_req_handler = 0x40002c4c; -ll_feature_rsp_handler = 0x40002c58; -ll_length_req_handler = 0x40002c64; -ll_length_rsp_handler = 0x40002c70; -ll_min_used_channels_ind_handler = 0x40002c7c; -ll_pause_enc_req_handler = 0x40002c88; -ll_pause_enc_rsp_handler = 0x40002c94; -ll_phy_req_handler = 0x40002ca0; -ll_phy_rsp_handler = 0x40002cac; -ll_phy_update_ind_handler = 0x40002cb8; -ll_ping_req_handler = 0x40002cc4; -ll_ping_rsp_handler = 0x40002cd0; -ll_slave_feature_req_handler = 0x40002cdc; -ll_start_enc_req_handler = 0x40002ce8; -ll_start_enc_rsp_handler = 0x40002cf4; -ll_terminate_ind_handler = 0x40002d00; -ll_version_ind_handler = 0x40002d0c; -llc_auth_payl_nearly_to_handler = 0x40002d18; -llc_auth_payl_real_to_handler = 0x40002d24; -llc_encrypt_ind_handler = 0x40002d30; -llc_hci_command_handler_wrapper = 0x40002d3c; -llc_ll_connection_param_req_pdu_send = 0x40002d48; -llc_ll_connection_param_rsp_pdu_send = 0x40002d54; -llc_ll_connection_update_ind_pdu_send = 0x40002d60; -llc_ll_enc_req_pdu_send = 0x40002d6c; -llc_ll_enc_rsp_pdu_send = 0x40002d78; -llc_ll_feature_req_pdu_send = 0x40002d84; -llc_ll_feature_rsp_pdu_send = 0x40002d90; -llc_ll_length_req_pdu_send = 0x40002d9c; -llc_ll_length_rsp_pdu_send = 0x40002da8; -llc_ll_pause_enc_req_pdu_send = 0x40002db4; -llc_ll_pause_enc_rsp_pdu_send = 0x40002dc0; -llc_ll_phy_req_pdu_send = 0x40002dcc; -llc_ll_phy_rsp_pdu_send = 0x40002dd8; -llc_ll_ping_req_pdu_send = 0x40002de4; -llc_ll_ping_rsp_pdu_send = 0x40002df0; -llc_ll_start_enc_req_pdu_send = 0x40002dfc; -llc_ll_start_enc_rsp_pdu_send = 0x40002e08; -llc_ll_terminate_ind_pdu_send = 0x40002e14; -llc_ll_unknown_rsp_pdu_send = 0x40002e20; -llc_llcp_ch_map_update_ind_pdu_send = 0x40002e2c; -llc_llcp_phy_upd_ind_pdu_send = 0x40002e38; -llc_llcp_version_ind_pdu_send = 0x40002e44; -llc_op_ch_map_upd_ind_handler = 0x40002e50; -llc_op_con_upd_ind_handler = 0x40002e5c; -llc_op_disconnect_ind_handler = 0x40002e68; -llc_op_dl_upd_ind_handler = 0x40002e74; -llc_op_encrypt_ind_handler = 0x40002e80; -llc_op_feats_exch_ind_handler = 0x40002e8c; -llc_op_le_ping_ind_handler = 0x40002e98; -llc_op_phy_upd_ind_handler = 0x40002ea4; -llc_op_ver_exch_ind_handler = 0x40002eb0; -llc_stopped_ind_handler = 0x40002ebc; -lld_acl_rx_ind_handler = 0x40002ec8; -lld_acl_tx_cfm_handler = 0x40002ed4; -lld_adv_end_ind_handler = 0x40002ee0; -lld_adv_rep_ind_handler = 0x40002eec; -lld_ch_map_upd_cfm_handler = 0x40002ef8; -lld_con_estab_ind_handler = 0x40002f04; -lld_con_evt_sd_evt_time_set = 0x40002f10; -lld_con_offset_upd_ind_handler = 0x40002f1c; -lld_con_param_upd_cfm_handler = 0x40002f28; -lld_disc_ind_handler = 0x40002f34; -lld_init_end_ind_handler = 0x40002f40; -lld_llcp_rx_ind_handler_wrapper = 0x40002f4c; -lld_llcp_tx_cfm_handler = 0x40002f58; -lld_per_adv_end_ind_handler = 0x40002f64; -lld_per_adv_rep_ind_handler = 0x40002f70; -lld_per_adv_rx_end_ind_handler = 0x40002f7c; -lld_phy_coded_500k_get = 0x40002f88; -lld_phy_upd_cfm_handler = 0x40002f94; -lld_scan_end_ind_handler = 0x40002fa0; -lld_scan_req_ind_handler = 0x40002fac; -lld_sync_start_req_handler = 0x40002fb8; -lld_test_end_ind_handler = 0x40002fc4; -lld_update_rxbuf_handler = 0x40002fd0; -llm_ch_map_update_ind_handler = 0x40002fdc; -llm_hci_command_handler_wrapper = 0x40002fe8; -llm_scan_period_to_handler = 0x40002ff4; -r_Add2SelfBigHex256 = 0x40003000; -r_AddBigHex256 = 0x4000300c; -r_AddBigHexModP256 = 0x40003018; -r_AddP256 = 0x40003024; -r_AddPdiv2_256 = 0x40003030; -r_GF_Jacobian_Point_Addition256 = 0x4000303c; -r_GF_Jacobian_Point_Double256 = 0x40003048; -r_GF_Point_Jacobian_To_Affine256 = 0x40003054; -r_MultiplyBigHexByUint32_256 = 0x40003060; -r_MultiplyBigHexModP256 = 0x4000306c; -r_MultiplyByU16ModP256 = 0x40003078; -r_SubtractBigHex256 = 0x40003084; -r_SubtractBigHexMod256 = 0x40003090; -r_SubtractBigHexUint32_256 = 0x4000309c; -r_SubtractFromSelfBigHex256 = 0x400030a8; -r_SubtractFromSelfBigHexSign256 = 0x400030b4; -r_aes_alloc = 0x400030c0; -r_aes_ccm_continue = 0x400030cc; -r_aes_ccm_process_e = 0x400030d8; -r_aes_ccm_xor_128_lsb = 0x400030e4; -r_aes_ccm_xor_128_msb = 0x400030f0; -r_aes_cmac_continue = 0x400030fc; -r_aes_cmac_start = 0x40003108; -r_aes_k1_continue = 0x40003114; -r_aes_k2_continue = 0x40003120; -r_aes_k3_continue = 0x4000312c; -r_aes_k4_continue = 0x40003138; -r_aes_shift_left_128 = 0x40003144; -r_aes_start = 0x40003150; -r_aes_xor_128 = 0x4000315c; -r_assert_err = 0x40003168; -r_assert_param = 0x40003174; -r_assert_warn = 0x40003180; -r_bigHexInversion256 = 0x4000318c; -r_ble_sw_cca_check_isr = 0x40003198; -r_ble_util_buf_acl_tx_alloc = 0x400031a4; -r_ble_util_buf_acl_tx_elt_get = 0x400031b0; -r_ble_util_buf_acl_tx_free = 0x400031bc; -r_ble_util_buf_acl_tx_free_in_isr = 0x400031c8; -r_ble_util_buf_adv_tx_alloc = 0x400031d4; -r_ble_util_buf_adv_tx_free = 0x400031e0; -r_ble_util_buf_adv_tx_free_in_isr = 0x400031ec; -r_ble_util_buf_env_deinit = 0x400031f8; -r_ble_util_buf_env_init = 0x40003204; -r_ble_util_buf_get_rx_buf_nb = 0x40003210; -r_ble_util_buf_get_rx_buf_size = 0x4000321c; -r_ble_util_buf_llcp_tx_alloc = 0x40003228; -r_ble_util_buf_llcp_tx_free = 0x40003234; -r_ble_util_buf_rx_alloc = 0x40003240; -r_ble_util_buf_rx_alloc_in_isr = 0x4000324c; -r_ble_util_buf_rx_free = 0x40003258; -r_ble_util_buf_rx_free_in_isr = 0x40003264; -r_ble_util_buf_set_rx_buf_nb = 0x40003270; -r_ble_util_buf_set_rx_buf_size = 0x4000327c; -r_ble_util_data_rx_buf_reset = 0x40003288; -r_bt_bb_get_intr_mask = 0x40003294; -r_bt_bb_intr_clear = 0x400032a0; -r_bt_bb_intr_mask_set = 0x400032ac; -r_bt_rf_coex_cfg_set = 0x400032c4; -r_bt_rf_coex_conn_dynamic_pti_en_get = 0x400032d0; -r_bt_rf_coex_ext_adv_dynamic_pti_en_get = 0x400032e8; -r_bt_rf_coex_ext_scan_dynamic_pti_en_get = 0x400032f4; -r_bt_rf_coex_legacy_adv_dynamic_pti_en_get = 0x40003300; -r_bt_rf_coex_per_adv_dynamic_pti_en_get = 0x4000330c; -r_bt_rf_coex_pti_table_get = 0x40003318; -r_bt_rf_coex_st_param_get = 0x40003324; -r_bt_rf_coex_st_param_set = 0x40003330; -r_bt_rf_coex_sync_scan_dynamic_pti_en_get = 0x4000333c; -r_bt_rma_apply_rule_cs_fmt = 0x40003348; -r_bt_rma_apply_rule_cs_idx = 0x40003354; -r_bt_rma_configure = 0x40003360; -r_bt_rma_deregister_rule_cs_fmt = 0x4000336c; -r_bt_rma_deregister_rule_cs_idx = 0x40003378; -r_bt_rma_get_ant_by_act = 0x40003384; -r_bt_rma_init = 0x40003390; -r_bt_rma_register_rule_cs_fmt = 0x4000339c; -r_bt_rma_register_rule_cs_idx = 0x400033a8; -r_bt_rtp_apply_rule_cs_fmt = 0x400033b4; -r_bt_rtp_apply_rule_cs_idx = 0x400033c0; -r_bt_rtp_deregister_rule_cs_fmt = 0x400033cc; -r_bt_rtp_deregister_rule_cs_idx = 0x400033d8; -r_bt_rtp_init = 0x400033f0; -r_bt_rtp_register_rule_cs_fmt = 0x400033fc; -r_bt_rtp_register_rule_cs_idx = 0x40003408; -r_btdm_isr = 0x40003414; -r_cali_phase_match_p = 0x40003444; -r_cmp_abs_time = 0x40003450; -r_cmp_dest_id = 0x4000345c; -r_cmp_timer_id = 0x40003468; -r_co_bdaddr_compare = 0x40003474; -r_co_ble_pkt_dur_in_us = 0x40003480; -r_co_list_extract = 0x4000348c; -r_co_list_extract_after = 0x40003498; -r_co_list_extract_sublist = 0x400034a4; -r_co_list_find = 0x400034b0; -r_co_list_init = 0x400034bc; -r_co_list_insert_after = 0x400034c8; -r_co_list_insert_before = 0x400034d4; -r_co_list_merge = 0x400034e0; -r_co_list_pool_init = 0x400034ec; -r_co_list_pop_front = 0x400034f8; -r_co_list_push_back = 0x40003504; -r_co_list_push_back_sublist = 0x40003510; -r_co_list_push_front = 0x4000351c; -r_co_list_size = 0x40003528; -r_co_nb_good_le_channels = 0x40003534; -r_co_util_pack = 0x40003540; -r_co_util_read_array_size = 0x4000354c; -r_co_util_unpack = 0x40003558; -r_dbg_env_deinit = 0x40003564; -r_dbg_env_init = 0x40003570; -r_dbg_platform_reset_complete = 0x4000357c; -r_dl_upd_proc_start = 0x40003588; -r_dump_data = 0x40003594; -r_ecc_abort_key256_generation = 0x400035a0; -r_ecc_gen_new_public_key = 0x400035ac; -r_ecc_gen_new_secret_key = 0x400035b8; -r_ecc_generate_key256 = 0x400035c4; -r_ecc_get_debug_Keys = 0x400035d0; -r_ecc_init = 0x400035dc; -r_ecc_is_valid_point = 0x400035e8; -r_ecc_multiplication_event_handler = 0x400035f4; -r_ecc_point_multiplication_win_256 = 0x40003600; -r_emi_alloc_em_mapping_by_offset = 0x4000360c; -r_emi_base_reg_lut_show = 0x40003618; -r_emi_em_base_reg_show = 0x40003624; -r_emi_free_em_mapping_by_offset = 0x40003630; -r_emi_get_em_mapping_idx_by_offset = 0x4000363c; -r_emi_get_mem_addr_by_offset = 0x40003648; -r_emi_overwrite_em_mapping_by_offset = 0x40003654; -r_esp_vendor_hci_command_handler = 0x40003660; -r_get_stack_usage = 0x4000366c; -r_h4tl_acl_hdr_rx_evt_handler = 0x40003678; -r_h4tl_cmd_hdr_rx_evt_handler = 0x40003684; -r_h4tl_cmd_pld_rx_evt_handler = 0x40003690; -r_h4tl_eif_io_event_post = 0x4000369c; -r_h4tl_eif_register = 0x400036a8; -r_h4tl_init = 0x400036b4; -r_h4tl_out_of_sync = 0x400036c0; -r_h4tl_out_of_sync_check = 0x400036cc; -r_h4tl_read_hdr = 0x400036d8; -r_h4tl_read_next_out_of_sync = 0x400036e4; -r_h4tl_read_payl = 0x400036f0; -r_h4tl_read_start = 0x400036fc; -r_h4tl_rx_acl_hdr_extract = 0x40003708; -r_h4tl_rx_cmd_hdr_extract = 0x40003714; -r_h4tl_rx_done = 0x40003720; -r_h4tl_start = 0x4000372c; -r_h4tl_stop = 0x40003738; -r_h4tl_tx_done = 0x40003744; -r_h4tl_tx_evt_handler = 0x40003750; -r_h4tl_write = 0x4000375c; -r_hci_acl_tx_data_alloc = 0x40003768; -r_hci_acl_tx_data_received = 0x40003774; -r_hci_basic_cmd_send_2_controller = 0x40003780; -r_hci_ble_adv_report_filter_check = 0x4000378c; -r_hci_ble_adv_report_tx_check = 0x40003798; -r_hci_ble_conhdl_register = 0x400037a4; -r_hci_ble_conhdl_unregister = 0x400037b0; -r_hci_build_acl_data = 0x400037bc; -r_hci_build_cc_evt = 0x400037c8; -r_hci_build_cs_evt = 0x400037d4; -r_hci_build_evt = 0x400037e0; -r_hci_build_le_evt = 0x400037ec; -r_hci_cmd_get_max_param_size = 0x400037f8; -r_hci_cmd_received = 0x40003804; -r_hci_cmd_reject = 0x40003810; -r_hci_evt_mask_check = 0x4000381c; -r_hci_evt_mask_set = 0x40003828; -r_hci_fc_acl_buf_size_set = 0x40003834; -r_hci_fc_acl_en = 0x40003840; -r_hci_fc_acl_packet_sent = 0x4000384c; -r_hci_fc_check_host_available_nb_acl_packets = 0x40003858; -r_hci_fc_host_nb_acl_pkts_complete = 0x40003864; -r_hci_fc_init = 0x40003870; -r_hci_look_for_cmd_desc = 0x4000387c; -r_hci_look_for_evt_desc = 0x40003888; -r_hci_look_for_le_evt_desc = 0x40003894; -r_hci_look_for_le_evt_desc_esp = 0x400038a0; -r_hci_pack_bytes = 0x400038ac; -r_hci_send_2_controller = 0x400038c4; -r_hci_send_2_host = 0x400038d0; -r_hci_tl_c2h_data_flow_on = 0x400038dc; -r_hci_tl_cmd_hdr_rx_evt_handler = 0x400038e8; -r_hci_tl_cmd_pld_rx_evt_handler = 0x400038f4; -r_hci_tl_get_pkt = 0x40003900; -r_hci_tl_hci_pkt_handler = 0x4000390c; -r_hci_tl_hci_tx_done_evt_handler = 0x40003918; -r_hci_tl_inc_nb_h2c_cmd_pkts = 0x40003924; -r_hci_tl_save_pkt = 0x40003930; -r_hci_tl_send = 0x4000393c; -r_hci_tx_done = 0x40003948; -r_hci_tx_start = 0x40003954; -r_hci_tx_trigger = 0x40003960; -r_isValidSecretKey_256 = 0x4000396c; -r_ke_check_malloc = 0x40003978; -r_ke_event_callback_set = 0x40003984; -r_ke_event_clear = 0x40003990; -r_ke_event_flush = 0x4000399c; -r_ke_event_get = 0x400039a8; -r_ke_event_get_all = 0x400039b4; -r_ke_event_init = 0x400039c0; -r_ke_event_schedule = 0x400039cc; -r_ke_event_set = 0x400039d8; -r_ke_flush = 0x400039e4; -r_ke_free = 0x400039f0; -r_ke_handler_search = 0x400039fc; -r_ke_init = 0x40003a08; -r_ke_is_free = 0x40003a14; -r_ke_malloc = 0x40003a20; -r_ke_mem_init = 0x40003a2c; -r_ke_mem_is_empty = 0x40003a38; -r_ke_mem_is_in_heap = 0x40003a44; -r_ke_msg_alloc = 0x40003a50; -r_ke_msg_dest_id_get = 0x40003a5c; -r_ke_msg_discard = 0x40003a68; -r_ke_msg_forward = 0x40003a74; -r_ke_msg_forward_new_id = 0x40003a80; -r_ke_msg_free = 0x40003a8c; -r_ke_msg_in_queue = 0x40003a98; -r_ke_msg_save = 0x40003aa4; -r_ke_msg_send = 0x40003ab0; -r_ke_msg_send_basic = 0x40003abc; -r_ke_msg_src_id_get = 0x40003ac8; -r_ke_queue_extract = 0x40003ad4; -r_ke_queue_insert = 0x40003ae0; -r_ke_sleep_check = 0x40003aec; -r_ke_state_get = 0x40003af8; -r_ke_state_set = 0x40003b04; -r_ke_task_check = 0x40003b10; -r_ke_task_create = 0x40003b1c; -r_ke_task_delete = 0x40003b28; -r_ke_task_handler_get = 0x40003b34; -r_ke_task_init = 0x40003b40; -r_ke_task_msg_flush = 0x40003b4c; -r_ke_task_saved_update = 0x40003b58; -r_ke_time = 0x40003b70; -r_ke_time_cmp = 0x40003b7c; -r_ke_time_past = 0x40003b88; -r_ke_timer_active = 0x40003b94; -r_ke_timer_adjust_all = 0x40003ba0; -r_ke_timer_clear = 0x40003bac; -r_ke_timer_init = 0x40003bb8; -r_ke_timer_schedule = 0x40003bc4; -r_ke_timer_set = 0x40003bd0; -r_led_init = 0x40003bdc; -r_led_set_all = 0x40003be8; -r_llc_aes_res_cb = 0x40003bf4; -r_llc_ch_map_up_proc_err_cb = 0x40003c00; -r_llc_cleanup = 0x40003c0c; -r_llc_cmd_cmp_send = 0x40003c18; -r_llc_cmd_stat_send = 0x40003c24; -r_llc_con_move_cbk = 0x40003c30; -r_llc_con_plan_set_update = 0x40003c3c; -r_llc_con_upd_param_in_range = 0x40003c48; -r_llc_disconnect = 0x40003c54; -r_llc_disconnect_end = 0x40003c60; -r_llc_disconnect_proc_continue = 0x40003c6c; -r_llc_disconnect_proc_err_cb = 0x40003c78; -r_llc_dl_chg_check = 0x40003c84; -r_llc_dle_proc_err_cb = 0x40003c90; -r_llc_feats_exch_proc_err_cb = 0x40003c9c; -r_llc_hci_cmd_handler_tab_p_get = 0x40003ca8; -r_llc_hci_con_param_req_evt_send = 0x40003cc0; -r_llc_hci_con_upd_info_send = 0x40003ccc; -r_llc_hci_disconnected_dis = 0x40003cd8; -r_llc_hci_dl_upd_info_send = 0x40003ce4; -r_llc_hci_enc_evt_send = 0x40003cf0; -r_llc_hci_feats_info_send = 0x40003cfc; -r_llc_hci_le_phy_upd_cmp_evt_send = 0x40003d08; -r_llc_hci_ltk_request_evt_send = 0x40003d14; -r_llc_hci_nb_cmp_pkts_evt_send = 0x40003d20; -r_llc_hci_version_info_send = 0x40003d2c; -r_llc_init_term_proc = 0x40003d38; -r_llc_iv_skd_rand_gen = 0x40003d44; -r_llc_le_ping_proc_continue = 0x40003d50; -r_llc_le_ping_proc_err_cb = 0x40003d5c; -/* r_llc_le_ping_restart = 0x40003d68; */ -r_llc_le_ping_set = 0x40003d74; -r_llc_ll_pause_enc_rsp_ack_handler = 0x40003d80; -r_llc_ll_reject_ind_ack_handler = 0x40003d8c; -r_llc_ll_reject_ind_pdu_send = 0x40003d98; -r_llc_ll_start_enc_rsp_ack_handler = 0x40003da4; -r_llc_ll_terminate_ind_ack = 0x40003db0; -r_llc_ll_unknown_ind_handler = 0x40003dbc; -r_llc_llcp_send = 0x40003dc8; -r_llc_llcp_state_set = 0x40003dd4; -r_llc_llcp_trans_timer_set = 0x40003de0; -r_llc_llcp_tx_check = 0x40003dec; -/* r_llc_loc_ch_map_proc_continue = 0x40003df8; */ -r_llc_loc_con_upd_proc_err_cb = 0x40003e10; -r_llc_loc_dl_upd_proc_continue = 0x40003e1c; -r_llc_loc_encrypt_proc_continue = 0x40003e28; -r_llc_loc_encrypt_proc_err_cb = 0x40003e34; -r_llc_loc_feats_exch_proc_continue = 0x40003e40; -r_llc_loc_phy_upd_proc_err_cb = 0x40003e58; -r_llc_msg_handler_tab_p_get = 0x40003e64; -r_llc_pref_param_compute = 0x40003e70; -r_llc_proc_collision_check = 0x40003e7c; -r_llc_proc_err_ind = 0x40003e88; -r_llc_proc_get = 0x40003e94; -r_llc_proc_id_get = 0x40003ea0; -r_llc_proc_reg = 0x40003eac; -r_llc_proc_state_get = 0x40003eb8; -r_llc_proc_state_set = 0x40003ec4; -r_llc_proc_timer_pause_set = 0x40003ed0; -r_llc_proc_timer_set = 0x40003edc; -r_llc_proc_unreg = 0x40003ee8; -r_llc_rem_ch_map_proc_continue = 0x40003ef4; -r_llc_rem_con_upd_proc_err_cb = 0x40003f0c; -r_llc_rem_dl_upd_proc = 0x40003f18; -r_llc_rem_encrypt_proc_continue = 0x40003f24; -r_llc_rem_encrypt_proc_err_cb = 0x40003f30; -r_llc_rem_phy_upd_proc_continue = 0x40003f3c; -r_llc_rem_phy_upd_proc_err_cb = 0x40003f48; -r_llc_role_get = 0x40003f54; -r_llc_sk_gen = 0x40003f60; -r_llc_start = 0x40003f6c; -r_llc_stop = 0x40003f78; -r_llc_ver_exch_loc_proc_continue = 0x40003f84; -r_llc_ver_proc_err_cb = 0x40003f90; -r_llcp_pdu_handler_tab_p_get = 0x40003f9c; -r_lld_aa_gen = 0x40003fa8; -r_lld_adv_adv_data_set = 0x40003fb4; -r_lld_adv_adv_data_update = 0x40003fc0; -r_lld_adv_aux_ch_idx_set = 0x40003fcc; -r_lld_adv_aux_evt_canceled_cbk = 0x40003fd8; -r_lld_adv_aux_evt_start_cbk = 0x40003fe4; -r_lld_adv_coex_check_ext_adv_synced = 0x40003ff0; -r_lld_adv_coex_env_reset = 0x40003ffc; -r_lld_adv_duration_update = 0x40004008; -r_lld_adv_dynamic_pti_process = 0x40004014; -r_lld_adv_end = 0x40004020; -r_lld_adv_evt_canceled_cbk = 0x4000402c; -r_lld_adv_evt_start_cbk = 0x40004038; -r_lld_adv_ext_chain_construct = 0x40004044; -r_lld_adv_ext_pkt_prepare = 0x40004050; -r_lld_adv_frm_cbk = 0x4000405c; -r_lld_adv_frm_isr = 0x40004068; -r_lld_adv_frm_skip_isr = 0x40004074; -r_lld_adv_init = 0x40004080; -r_lld_adv_pkt_rx = 0x4000408c; -r_lld_adv_pkt_rx_connect_ind = 0x40004098; -r_lld_adv_pkt_rx_send_scan_req_evt = 0x400040a4; -r_lld_adv_rand_addr_update = 0x400040b0; -r_lld_adv_restart = 0x400040bc; -r_lld_adv_scan_rsp_data_set = 0x400040c8; -r_lld_adv_scan_rsp_data_update = 0x400040d4; -r_lld_adv_set_tx_power = 0x400040e0; -r_lld_adv_start = 0x400040ec; -r_lld_adv_stop = 0x400040f8; -r_lld_adv_sync_info_set = 0x40004104; -r_lld_adv_sync_info_update = 0x40004110; -r_lld_calc_aux_rx = 0x4000411c; -r_lld_cca_alloc = 0x40004128; -r_lld_cca_data_reset = 0x40004134; -r_lld_cca_free = 0x40004140; -r_lld_ch_assess_data_get = 0x4000414c; -r_lld_ch_idx_get = 0x40004158; -r_lld_ch_map_set = 0x40004164; -r_lld_channel_assess = 0x40004170; -r_lld_con_activity_act_offset_compute = 0x4000417c; -r_lld_con_activity_offset_compute = 0x40004188; -r_lld_con_ch_map_update = 0x40004194; -r_lld_con_cleanup = 0x400041a0; -r_lld_con_current_tx_power_get = 0x400041ac; -r_lld_con_data_flow_set = 0x400041b8; -r_lld_con_data_len_update = 0x400041c4; -r_lld_con_data_tx = 0x400041d0; -r_lld_con_enc_key_load = 0x400041dc; -r_lld_con_event_counter_get = 0x400041e8; -r_lld_con_evt_canceled_cbk = 0x400041f4; -r_lld_con_evt_duration_min_get = 0x40004200; -r_lld_con_evt_max_eff_time_cal = 0x4000420c; -r_lld_con_evt_sd_evt_time_get = 0x40004218; -r_lld_con_evt_start_cbk = 0x40004224; -r_lld_con_evt_time_update = 0x40004230; -r_lld_con_free_all_tx_buf = 0x4000423c; -r_lld_con_frm_cbk = 0x40004248; -r_lld_con_frm_isr = 0x40004254; -r_lld_con_frm_skip_isr = 0x40004260; -r_lld_con_init = 0x4000426c; -r_lld_con_llcp_tx = 0x40004278; -r_lld_con_max_lat_calc = 0x40004284; -r_lld_con_offset_get = 0x40004290; -r_lld_con_param_update = 0x4000429c; -r_lld_con_phys_update = 0x400042a8; -r_lld_con_pref_slave_evt_dur_set = 0x400042b4; -r_lld_con_pref_slave_latency_set = 0x400042c0; -r_lld_con_rssi_get = 0x400042cc; -r_lld_con_rx = 0x400042d8; -/* r_lld_con_rx_channel_assess = 0x400042e4; */ -r_lld_con_rx_enc = 0x400042f0; -r_lld_con_rx_isr = 0x400042fc; -r_lld_con_rx_link_info_check = 0x40004308; -r_lld_con_rx_llcp_check = 0x40004314; -r_lld_con_rx_sync_time_update = 0x40004320; -r_lld_con_set_tx_power = 0x40004338; -r_lld_con_start = 0x40004344; -r_lld_con_tx = 0x4000435c; -r_lld_con_tx_enc = 0x40004368; -r_lld_con_tx_isr = 0x40004374; -r_lld_con_tx_len_update = 0x40004380; -r_lld_con_tx_len_update_for_intv = 0x4000438c; -r_lld_con_tx_len_update_for_rate = 0x40004398; -r_lld_con_tx_prog = 0x400043a4; -r_lld_conn_dynamic_pti_process = 0x400043b0; -r_lld_continue_scan_rx_isr_end_process = 0x400043bc; -r_lld_ext_scan_dynamic_pti_process = 0x400043c8; -r_lld_hw_cca_end_isr = 0x400043d4; -r_lld_hw_cca_evt_handler = 0x400043e0; -r_lld_hw_cca_isr = 0x400043ec; -r_lld_init_cal_anchor_point = 0x400043f8; -r_lld_init_compute_winoffset = 0x40004404; -r_lld_init_connect_req_pack = 0x40004410; -r_lld_init_end = 0x4000441c; -r_lld_init_evt_canceled_cbk = 0x40004428; -r_lld_init_evt_start_cbk = 0x40004434; -r_lld_init_frm_cbk = 0x40004440; -r_lld_init_frm_eof_isr = 0x4000444c; -r_lld_init_frm_skip_isr = 0x40004458; -r_lld_init_init = 0x40004464; -r_lld_init_process_pkt_rx = 0x40004470; -r_lld_init_process_pkt_rx_adv_ext_ind = 0x4000447c; -r_lld_init_process_pkt_rx_adv_ind_or_direct_ind = 0x40004488; -r_lld_init_process_pkt_rx_aux_connect_rsp = 0x40004494; -r_lld_init_process_pkt_tx = 0x400044a0; -r_lld_init_process_pkt_tx_cal_con_timestamp = 0x400044ac; -r_lld_init_sched = 0x400044b8; -r_lld_init_set_tx_power = 0x400044c4; -r_lld_init_start = 0x400044d0; -r_lld_init_stop = 0x400044dc; -r_lld_instant_proc_end = 0x400044e8; -r_lld_per_adv_ch_map_update = 0x40004500; -r_lld_per_adv_chain_construct = 0x4000450c; -r_lld_per_adv_cleanup = 0x40004518; -r_lld_per_adv_coex_env_reset = 0x40004524; -r_lld_per_adv_data_set = 0x40004530; -r_lld_per_adv_data_update = 0x4000453c; -r_lld_per_adv_dynamic_pti_process = 0x40004548; -r_lld_per_adv_evt_canceled_cbk = 0x40004554; -r_lld_per_adv_evt_start_cbk = 0x40004560; -r_lld_per_adv_ext_pkt_prepare = 0x4000456c; -r_lld_per_adv_frm_cbk = 0x40004578; -r_lld_per_adv_frm_isr = 0x40004584; -r_lld_per_adv_frm_skip_isr = 0x40004590; -r_lld_per_adv_init = 0x4000459c; -r_lld_per_adv_init_info_get = 0x400045a8; -r_lld_per_adv_list_add = 0x400045b4; -r_lld_per_adv_list_rem = 0x400045c0; -r_lld_per_adv_set_tx_power = 0x400045d8; -r_lld_per_adv_start = 0x400045e4; -r_lld_per_adv_stop = 0x400045f0; -r_lld_per_adv_sync_info_get = 0x400045fc; -r_lld_process_cca_data = 0x40004608; -r_lld_ral_search = 0x40004614; -r_lld_read_clock = 0x40004620; -r_lld_res_list_add = 0x4000462c; -r_lld_res_list_is_empty = 0x40004644; -r_lld_res_list_local_rpa_get = 0x40004650; -r_lld_res_list_peer_rpa_get = 0x4000465c; -r_lld_res_list_peer_update = 0x40004668; -/* r_lld_res_list_priv_mode_update = 0x40004674; */ -r_lld_reset_reg = 0x4000468c; -r_lld_rpa_renew = 0x40004698; -r_lld_rpa_renew_evt_canceled_cbk = 0x400046a4; -r_lld_rpa_renew_evt_start_cbk = 0x400046b0; -r_lld_rpa_renew_instant_cbk = 0x400046bc; -r_lld_rxdesc_check = 0x400046c8; -r_lld_rxdesc_free = 0x400046d4; -r_lld_scan_create_sync = 0x400046e0; -r_lld_scan_create_sync_cancel = 0x400046ec; -r_lld_scan_end = 0x400046f8; -r_lld_scan_evt_canceled_cbk = 0x40004704; -r_lld_scan_evt_start_cbk = 0x40004710; -r_lld_scan_frm_cbk = 0x4000471c; -r_lld_scan_frm_eof_isr = 0x40004728; -r_lld_scan_frm_rx_isr = 0x40004734; -r_lld_scan_frm_skip_isr = 0x40004740; -r_lld_scan_init = 0x4000474c; -r_lld_scan_params_update = 0x40004758; -r_lld_scan_process_pkt_rx_aux_adv_ind = 0x4000477c; -r_lld_scan_process_pkt_rx_aux_chain_ind = 0x40004788; -r_lld_scan_process_pkt_rx_aux_scan_rsp = 0x40004794; -r_lld_scan_process_pkt_rx_ext_adv = 0x400047a0; -r_lld_scan_process_pkt_rx_ext_adv_ind = 0x400047ac; -r_lld_scan_process_pkt_rx_legacy_adv = 0x400047b8; -r_lld_scan_restart = 0x400047c4; -r_lld_scan_sched = 0x400047d0; -r_lld_scan_set_tx_power = 0x400047dc; -r_lld_scan_start = 0x400047e8; -r_lld_scan_stop = 0x400047f4; -r_lld_scan_sync_accept = 0x40004800; -r_lld_scan_sync_info_unpack = 0x4000480c; -r_lld_scan_trunc_ind = 0x40004818; -r_lld_sw_cca_evt_handler = 0x40004824; -r_lld_sw_cca_isr = 0x40004830; -r_lld_sync_ch_map_update = 0x4000483c; -r_lld_sync_cleanup = 0x40004848; -r_lld_sync_evt_canceled_cbk = 0x40004854; -r_lld_sync_evt_start_cbk = 0x40004860; -r_lld_sync_frm_cbk = 0x4000486c; -r_lld_sync_frm_eof_isr = 0x40004878; -r_lld_sync_frm_rx_isr = 0x40004884; -r_lld_sync_frm_skip_isr = 0x40004890; -r_lld_sync_init = 0x4000489c; -r_lld_sync_process_pkt_rx = 0x400048a8; -r_lld_sync_process_pkt_rx_aux_sync_ind = 0x400048b4; -r_lld_sync_process_pkt_rx_pkt_check = 0x400048c0; -r_lld_sync_scan_dynamic_pti_process = 0x400048cc; -r_lld_sync_sched = 0x400048d8; -r_lld_sync_start = 0x400048e4; -r_lld_sync_stop = 0x400048f0; -r_lld_sync_trunc_ind = 0x400048fc; -r_lld_test_cleanup = 0x40004908; -r_lld_test_evt_canceled_cbk = 0x40004914; -r_lld_test_evt_start_cbk = 0x40004920; -r_lld_test_freq2chnl = 0x4000492c; -r_lld_test_frm_cbk = 0x40004938; -r_lld_test_frm_isr = 0x40004944; -r_lld_test_init = 0x40004950; -r_lld_test_rx_isr = 0x4000495c; -r_lld_test_set_tx_power = 0x40004968; -r_lld_test_start = 0x40004974; -/* r_lld_test_stop = 0x40004980;*/ -r_lld_update_rxbuf = 0x4000498c; -r_lld_update_rxbuf_isr = 0x40004998; -r_lld_white_list_add = 0x400049a4; -r_lld_white_list_rem = 0x400049b0; -r_llm_activity_free_get = 0x400049bc; -r_llm_activity_free_set = 0x400049c8; -r_llm_activity_syncing_get = 0x400049d4; -r_llm_adv_con_len_check = 0x400049e0; -r_llm_adv_hdl_to_id = 0x400049ec; -r_llm_adv_rep_flow_control_check = 0x400049f8; -r_llm_adv_rep_flow_control_update = 0x40004a04; -r_llm_adv_reports_list_check = 0x40004a10; -r_llm_adv_set_all_release = 0x40004a1c; -r_llm_adv_set_dft_params = 0x40004a28; -r_llm_adv_set_release = 0x40004a34; -r_llm_aes_res_cb = 0x40004a40; -r_llm_ble_update_adv_flow_control = 0x40004a4c; -r_llm_ch_map_update = 0x40004a58; -r_llm_cmd_cmp_send = 0x40004a64; -r_llm_cmd_stat_send = 0x40004a70; -r_llm_dev_list_empty_entry = 0x40004a7c; -r_llm_dev_list_search = 0x40004a88; -r_llm_env_adv_dup_filt_deinit = 0x40004a94; -r_llm_env_adv_dup_filt_init = 0x40004aa0; -r_llm_init_ble_adv_report_flow_contol = 0x40004aac; -r_llm_is_dev_connected = 0x40004ab8; -r_llm_is_dev_synced = 0x40004ac4; -r_llm_is_non_con_act_ongoing_check = 0x40004ad0; -r_llm_is_wl_accessible = 0x40004adc; -r_llm_le_evt_mask_check = 0x40004ae8; -r_llm_link_disc = 0x40004b00; -r_llm_master_ch_map_get = 0x40004b0c; -r_llm_msg_handler_tab_p_get = 0x40004b18; -r_llm_no_activity = 0x40004b24; -r_llm_per_adv_slot_dur = 0x40004b30; -r_llm_plan_elt_get = 0x40004b3c; -r_llm_rx_path_comp_get = 0x40004b48; -r_llm_scan_start = 0x40004b54; -r_llm_scan_sync_acad_attach = 0x40004b60; -r_llm_scan_sync_acad_detach = 0x40004b6c; -r_llm_send_adv_lost_event_to_host = 0x40004b78; -r_llm_tx_path_comp_get = 0x40004b84; -r_misc_deinit = 0x40004b90; -r_misc_free_em_buf_in_isr = 0x40004b9c; -r_misc_init = 0x40004ba8; -r_misc_msg_handler_tab_p_get = 0x40004bb4; -r_notEqual256 = 0x40004bc0; -r_phy_upd_proc_start = 0x40004bcc; -r_platform_reset = 0x40004bd8; -r_rf_em_init = 0x40004bf0; -r_rf_force_agc_enable = 0x40004bfc; -r_rf_reg_rd = 0x40004c08; -r_rf_reg_wr = 0x40004c14; -r_rf_reset = 0x40004c20; -r_rf_rssi_convert = 0x40004c2c; -r_rf_rw_v9_le_disable = 0x40004c38; -r_rf_rw_v9_le_enable = 0x40004c44; -r_rf_sleep = 0x40004c50; -r_rf_util_cs_fmt_convert = 0x40004c74; -r_rw_crypto_aes_ccm = 0x40004c80; -r_rw_crypto_aes_encrypt = 0x40004c8c; -r_rw_crypto_aes_init = 0x40004c98; -r_rw_crypto_aes_k1 = 0x40004ca4; -r_rw_crypto_aes_k2 = 0x40004cb0; -r_rw_crypto_aes_k3 = 0x40004cbc; -r_rw_crypto_aes_k4 = 0x40004cc8; -r_rw_crypto_aes_rand = 0x40004cd4; -r_rw_crypto_aes_result_handler = 0x40004ce0; -r_rw_crypto_aes_s1 = 0x40004cec; -r_rw_cryto_aes_cmac = 0x40004cf8; -r_rw_v9_init_em_radio_table = 0x40004d04; -r_rwble_sleep_enter = 0x40004d1c; -r_rwble_sleep_wakeup_end = 0x40004d28; -/* r_rwbtdm_isr_wrapper = 0x40004d34; */ -r_rwip_active_check = 0x40004d40; -r_rwip_aes_encrypt = 0x40004d4c; -/* r_rwip_assert = 0x40004d58; */ -r_rwip_crypt_evt_handler = 0x40004d64; -r_rwip_crypt_isr_handler = 0x40004d70; -r_rwip_eif_get = 0x40004d7c; -r_rwip_half_slot_2_lpcycles = 0x40004d88; -r_rwip_hus_2_lpcycles = 0x40004d94; -r_rwip_isr = 0x40004da0; -r_rwip_lpcycles_2_hus = 0x40004dac; -r_rwip_prevent_sleep_clear = 0x40004db8; -r_rwip_prevent_sleep_set = 0x40004dc4; -r_rwip_schedule = 0x40004dd0; -r_rwip_sleep = 0x40004ddc; -r_rwip_sw_int_handler = 0x40004de8; -r_rwip_sw_int_req = 0x40004df4; -r_rwip_time_get = 0x40004e00; -r_rwip_timer_10ms_handler = 0x40004e0c; -r_rwip_timer_10ms_set = 0x40004e18; -r_rwip_timer_hs_handler = 0x40004e24; -r_rwip_timer_hs_set = 0x40004e30; -r_rwip_timer_hus_handler = 0x40004e3c; -r_rwip_timer_hus_set = 0x40004e48; -r_rwip_wakeup = 0x40004e54; -/* r_rwip_wakeup_end = 0x40004e60; */ -r_rwip_wlcoex_set = 0x40004e6c; -r_sch_alarm_clear = 0x40004e78; -r_sch_alarm_init = 0x40004e84; -r_sch_alarm_prog = 0x40004e90; -r_sch_alarm_set = 0x40004e9c; -r_sch_alarm_timer_isr = 0x40004ea8; -r_sch_arb_conflict_check = 0x40004eb4; -r_sch_arb_elt_cancel = 0x40004ec0; -r_sch_arb_init = 0x40004ed8; -r_sch_arb_insert = 0x40004ee4; -r_sch_arb_prog_timer = 0x40004ef0; -r_sch_arb_remove = 0x40004efc; -r_sch_arb_sw_isr = 0x40004f08; -r_sch_plan_chk = 0x40004f14; -r_sch_plan_clock_wrap_offset_update = 0x40004f20; -r_sch_plan_init = 0x40004f2c; -r_sch_plan_interval_req = 0x40004f38; -r_sch_plan_offset_max_calc = 0x40004f44; -r_sch_plan_offset_req = 0x40004f50; -r_sch_plan_position_range_compute = 0x40004f5c; -r_sch_plan_rem = 0x40004f68; -r_sch_plan_req = 0x40004f74; -r_sch_prog_init = 0x40004f98; -r_sch_prog_push = 0x40004fa4; -r_sch_prog_rx_isr = 0x40004fb0; -r_sch_prog_skip_isr = 0x40004fbc; -r_sch_prog_tx_isr = 0x40004fc8; -r_sch_slice_bg_add = 0x40004fd4; -r_sch_slice_bg_remove = 0x40004fe0; -r_sch_slice_compute = 0x40004fec; -r_sch_slice_fg_add = 0x40004ff8; -r_sch_slice_fg_remove = 0x40005004; -r_sch_slice_init = 0x40005010; -r_sch_slice_per_add = 0x4000501c; -r_sch_slice_per_remove = 0x40005028; -r_sdk_config_get_bt_sleep_enable = 0x40005034; -r_sdk_config_get_hl_derived_opts = 0x40005040; -r_sdk_config_get_opts = 0x4000504c; -r_sdk_config_get_priv_opts = 0x40005058; -r_sdk_config_set_bt_sleep_enable = 0x40005064; -r_sdk_config_set_hl_derived_opts = 0x40005070; -r_sdk_config_set_opts = 0x4000507c; -r_specialModP256 = 0x40005088; -r_unloaded_area_init = 0x40005094; -r_vhci_flow_off = 0x400050a0; -r_vhci_flow_on = 0x400050ac; -r_vhci_notify_host_send_available = 0x400050b8; -r_vhci_send_to_host = 0x400050c4; -r_vnd_hci_command_handler = 0x400050d0; -r_vshci_init = 0x400050dc; -vnd_hci_command_handler_wrapper = 0x400050e8; -r_lld_legacy_adv_dynamic_pti_get = 0x400050f4; -r_lld_legacy_adv_dynamic_pti_process = 0x40005100; -r_lld_ext_adv_dynamic_pti_get = 0x4000510c; -r_lld_ext_adv_dynamic_aux_pti_process = 0x40005118; -r_lld_ext_adv_dynamic_pti_process = 0x40005124; -r_lld_adv_ext_pkt_prepare_set = 0x40005130; -r_lld_adv_ext_chain_connectable_construct = 0x40005148; -r_lld_adv_pkt_rx_connect_post = 0x40005160; -r_lld_adv_start_init_evt_param = 0x4000516c; -r_lld_adv_start_set_cs = 0x40005178; -/* r_lld_adv_start_update_filter_policy = 0x40005184; */ -r_lld_adv_start_schedule_asap = 0x40005190; -r_lld_con_tx_prog_new_packet_coex = 0x4000519c; -r_lld_per_adv_dynamic_pti_get = 0x400051b4; -r_lld_per_adv_evt_start_chm_upd = 0x400051c0; -r_lld_ext_scan_dynamic_pti_get = 0x400051cc; -r_lld_sync_insert = 0x400051e4; -r_sch_prog_ble_push = 0x400051f0; -r_sch_prog_bt_push = 0x400051fc; -r_lld_init_evt_end_type_set = 0x40005208; -r_lld_init_evt_end_type_get = 0x40005214; -r_lld_adv_direct_adv_use_rpa_addr_state_set = 0x40005220; -r_lld_adv_direct_adv_use_rpa_addr_state_get = 0x4000522c; -r_lld_init_evt_end_type_check_state_set = 0x40005238; -r_lld_init_evt_end_type_check_state_get = 0x40005244; /* Data (.data, .bss, .rodata) */ bt_rf_coex_cfg_p = 0x3fceffa8; bt_rf_coex_hooks_p = 0x3fceffa4; @@ -1761,38 +942,6 @@ rwip_coex_cfg = 0x3ff1eebe; rwip_priority = 0x3ff1eea8; veryBigHexP256 = 0x3ff1ee5c; -/* bluetooth hook funcs */ -r_llc_loc_encrypt_proc_continue_hook = 0x40001c60; -r_llc_loc_phy_upd_proc_continue_hook = 0x40001c64; -r_llc_rem_phy_upd_proc_continue_hook = 0x40001c68; -r_lld_scan_frm_eof_isr_hook = 0x40001c6c; -r_lld_scan_evt_start_cbk_hook = 0x40001c70; -r_lld_scan_process_pkt_rx_ext_adv_hook = 0x40001c78; -r_lld_scan_sched_hook = 0x40001c7c; -r_lld_adv_evt_start_cbk_hook = 0x40001c84; -r_lld_adv_aux_evt_start_cbk_hook = 0x40001c88; -r_lld_adv_frm_isr_hook = 0x40001c8c; -r_lld_adv_start_init_evt_param_hook = 0x40001c90; -r_lld_con_evt_canceled_cbk_hook = 0x40001c94; -r_lld_con_frm_isr_hook = 0x40001c98; -r_lld_con_tx_hook = 0x40001c9c; -r_lld_con_rx_hook = 0x40001ca0; -r_lld_con_evt_start_cbk_hook = 0x40001ca4; -r_lld_con_tx_prog_new_packet_hook = 0x40001cac; -r_lld_init_frm_eof_isr_hook = 0x40001cb0; -r_lld_init_evt_start_cbk_hook = 0x40001cb4; -r_lld_init_sched_hook = 0x40001cbc; -r_lld_init_process_pkt_tx_hook = 0x40001cc0; -r_lld_per_adv_evt_start_cbk_hook = 0x40001cc4; -r_lld_per_adv_frm_isr_hook = 0x40001cc8; -r_lld_per_adv_start_hook = 0x40001ccc; -r_lld_sync_frm_eof_isr_hook = 0x40001cd0; -r_lld_sync_evt_start_cbk_hook = 0x40001cd4; -r_lld_sync_start_hook = 0x40001cd8; -r_lld_sync_process_pkt_rx_pkt_check_hook = 0x40001cdc; -r_sch_arb_insert_hook = 0x40001ce0; -r_sch_plan_offset_req_hook = 0x40001ce4; - /*************************************** Group rom_pp ***************************************/ @@ -1874,7 +1023,7 @@ ppGetTxQFirstAvail_Locked = 0x400055b0; ppGetTxframe = 0x400055bc; /*ppMapTxQueue = 0x400055c8;*/ ppProcessRxPktHdr = 0x400055e0; -ppProcessTxQ = 0x400055ec; +/*ppProcessTxQ = 0x400055ec;*/ ppRecordBarRRC = 0x400055f8; lmacRequestTxopQueue = 0x40005604; lmacReleaseTxopQueue = 0x40005610; @@ -1913,7 +1062,7 @@ rcSetTxAmpduLimit = 0x40005784; rcUpdateAckSnr = 0x4000579c; /*rcUpdateRate = 0x400057a8;*/ /* rcUpdateTxDone = 0x400057b4; */ -rcUpdateTxDoneAmpdu2 = 0x400057c0; +/*rcUpdateTxDoneAmpdu2 = 0x400057c0;*/ rcUpSched = 0x400057cc; rssi_margin = 0x400057d8; rx11NRate2AMPDULimit = 0x400057e4; @@ -2081,7 +1230,7 @@ coex_hw_timer_set = 0x40005c04; coex_schm_interval_set = 0x40005c10; coex_schm_lock = 0x40005c1c; coex_schm_unlock = 0x40005c28; -coex_status_get = 0x40005c34; +/*coex_status_get = 0x40005c34;*/ coex_wifi_release = 0x40005c40; esp_coex_ble_conn_dynamic_prio_get = 0x40005c4c; /* Data (.data, .bss, .rodata) */ diff --git a/components/esp_rom/include/esp_rom_gpio.h b/components/esp_rom/include/esp_rom_gpio.h index ce4bb76516..2ba66c211d 100644 --- a/components/esp_rom/include/esp_rom_gpio.h +++ b/components/esp_rom/include/esp_rom_gpio.h @@ -1,16 +1,8 @@ -// Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2010-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -74,6 +66,7 @@ void esp_rom_gpio_connect_in_signal(uint32_t gpio_num, uint32_t signal_idx, bool * @brief Combine a peripheral signal which tagged as output attribute with a GPIO. * * @note There's no limitation on the number of signals that a GPIO can combine with. + * @note Internally, the signal will be connected first, then output will be enabled on the pad. * * @param gpio_num GPIO number * @param signal_idx Peripheral signal index (tagged as output attribute) diff --git a/components/esp_rom/patches/esp_rom_gpio.c b/components/esp_rom/patches/esp_rom_gpio.c new file mode 100644 index 0000000000..bf8bef623c --- /dev/null +++ b/components/esp_rom/patches/esp_rom_gpio.c @@ -0,0 +1,28 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "sdkconfig.h" +#include "esp_attr.h" +#include "esp_rom_gpio.h" +#include "soc/gpio_reg.h" + +#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 +// On such targets, the ROM code for this function enabled output for the pad first, and then connected the signal +// This could result in an undesired glitch at the pad +IRAM_ATTR void esp_rom_gpio_connect_out_signal(uint32_t gpio_num, uint32_t signal_idx, bool out_inv, bool oen_inv) +{ + uint32_t value = signal_idx << GPIO_FUNC0_OUT_SEL_S; + if (out_inv) { + value |= GPIO_FUNC0_OUT_INV_SEL_M; + } + if (oen_inv) { + value |= GPIO_FUNC0_OEN_INV_SEL_M; + } + REG_WRITE(GPIO_FUNC0_OUT_SEL_CFG_REG + (gpio_num * 4), value); + + REG_WRITE(GPIO_ENABLE_W1TS_REG, (1 << gpio_num)); +} +#endif diff --git a/components/esp_rom/patches/esp_rom_systimer.c b/components/esp_rom/patches/esp_rom_systimer.c index 1b71b6f7f7..168b6527be 100644 --- a/components/esp_rom/patches/esp_rom_systimer.c +++ b/components/esp_rom/patches/esp_rom_systimer.c @@ -11,7 +11,7 @@ #if CONFIG_HAL_SYSTIMER_USE_ROM_IMPL -#if CONFIG_IDF_TARGET_ESP32C2 +#if CONFIG_IDF_TARGET_ESP32C2 && (CONFIG_ESP32C2_REV_MIN_FULL < 200) void systimer_hal_init(systimer_hal_context_t *hal) { hal->dev = &SYSTIMER; @@ -62,7 +62,7 @@ void systimer_hal_counter_value_advance(systimer_hal_context_t *hal, uint32_t co systimer_ll_set_counter_value(hal->dev, counter_id, new_count.val); systimer_ll_apply_counter_value(hal->dev, counter_id); } -#endif // CONFIG_IDF_TARGET_ESP32C2 +#endif // CONFIG_IDF_TARGET_ESP32C2 && (CONFIG_ESP32C2_REV_MIN_FULL < 200) #if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 void systimer_hal_init(systimer_hal_context_t *hal) diff --git a/components/esp_rom/patches/esp_rom_uart.c b/components/esp_rom/patches/esp_rom_uart.c index bae29dd553..fa0cd14351 100644 --- a/components/esp_rom/patches/esp_rom_uart.c +++ b/components/esp_rom/patches/esp_rom_uart.c @@ -30,9 +30,9 @@ IRAM_ATTR void esp_rom_uart_set_clock_baudrate(uint8_t uart_no, uint32_t clock_h #if CONFIG_IDF_TARGET_ESP32C3 /** - * The ESP32-C3 ROM has released two versions, one is the ECO3 version, - * and the other is the version before ECO3 (include ECO0 ECO1 ECO2). - * These two versions of the ROM code do not list uart_tx_switch wrap + * The ESP32-C3 ROM has released three versions, ECO7 (v1.1), ECO3, and + * the version before ECO3 (include ECO0 ECO1 ECO2). + * These three versions of the ROM code do not list uart_tx_switch wrap * function in the ROM interface, so here use the uart_tx_switch direct * address instead. */ @@ -43,6 +43,8 @@ IRAM_ATTR void esp_rom_uart_set_as_console(uint8_t uart_no) if (efuse_hal_chip_revision() < 3) { uart_tx_switch = (rom_func_t)0x4004b8ca; + } else if (efuse_hal_chip_revision() >= 101) { + uart_tx_switch = (rom_func_t)0x40001c44; } else { uart_tx_switch = (rom_func_t)0x4004c166; } diff --git a/components/esp_system/fpga_overrides.c b/components/esp_system/fpga_overrides.c index 24e5e2f909..9e448019e9 100644 --- a/components/esp_system/fpga_overrides.c +++ b/components/esp_system/fpga_overrides.c @@ -64,14 +64,18 @@ void IRAM_ATTR bootloader_fill_random(void *buffer, size_t length) } } -void esp_clk_init(void) +void esp_rtc_init(void) { - s_warn(); #if SOC_PMU_SUPPORTED pmu_init(); #endif } +void esp_clk_init(void) +{ + s_warn(); +} + void esp_perip_clk_init(void) { diff --git a/components/esp_system/ld/esp32s2/memory.ld.in b/components/esp_system/ld/esp32s2/memory.ld.in index 86ef48f600..e9d6819065 100644 --- a/components/esp_system/ld/esp32s2/memory.ld.in +++ b/components/esp_system/ld/esp32s2/memory.ld.in @@ -127,8 +127,7 @@ _data_seg_org = ORIGIN(rtc_data_seg); /* The lines below define location alias for .rtc.data section based on Kconfig option. When the option is not defined then use slow memory segment - else the data will be placed in fast memory segment - TODO: check whether the rtc_data_location is correct for esp32s2 - IDF-761 */ + else the data will be placed in fast memory segment */ #ifndef CONFIG_ESP32S2_RTCDATA_IN_FAST_MEM REGION_ALIAS("rtc_data_location", rtc_slow_seg ); #else diff --git a/components/esp_system/ld/esp32s2/sections.ld.in b/components/esp_system/ld/esp32s2/sections.ld.in index 681e686c85..be8cb86367 100644 --- a/components/esp_system/ld/esp32s2/sections.ld.in +++ b/components/esp_system/ld/esp32s2/sections.ld.in @@ -247,7 +247,7 @@ SECTIONS _noinit_end = ABSOLUTE(.); } > dram0_0_seg - /* external memory bss, from any global variable with EXT_RAM_BSS_ATTR attribute*/ + /* External Memory BSS. (Variables with EXT_RAM_BSS_ATTR attribute). */ .ext_ram.bss (NOLOAD) : { _ext_ram_bss_start = ABSOLUTE(.); @@ -258,6 +258,20 @@ SECTIONS _ext_ram_bss_end = ABSOLUTE(.); } > extern_ram_seg + /** + * This section holds data that won't be initialised when startup. + * This section locates in External RAM region. + */ + .ext_ram_noinit (NOLOAD) : + { + _ext_ram_noinit_start = ABSOLUTE(.); + + *(.ext_ram_noinit*) + + . = ALIGN(4); + _ext_ram_noinit_end = ABSOLUTE(.); + } > extern_ram_seg + /* Shared RAM */ .dram0.bss (NOLOAD) : { diff --git a/components/esp_system/ld/esp32s3/sections.ld.in b/components/esp_system/ld/esp32s3/sections.ld.in index 850305ee69..23780af5c4 100644 --- a/components/esp_system/ld/esp32s3/sections.ld.in +++ b/components/esp_system/ld/esp32s3/sections.ld.in @@ -421,6 +421,20 @@ SECTIONS _ext_ram_bss_end = ABSOLUTE(.); } > extern_ram_seg + /** + * This section holds data that won't be initialised when startup. + * This section locates in External RAM region. + */ + .ext_ram_noinit (NOLOAD) : + { + _ext_ram_noinit_start = ABSOLUTE(.); + + *(.ext_ram_noinit*) + + . = ALIGN(4); + _ext_ram_noinit_end = ABSOLUTE(.); + } > extern_ram_seg + /* Marks the end of IRAM code segment */ .iram0.text_end (NOLOAD) : { diff --git a/components/esp_system/panic.c b/components/esp_system/panic.c index 45351535cd..5b16fb1f60 100644 --- a/components/esp_system/panic.c +++ b/components/esp_system/panic.c @@ -221,7 +221,7 @@ static inline void disable_all_wdts(void) wdt_hal_write_protect_enable(&wdt0_context); #if SOC_TIMER_GROUPS >= 2 - //Interupt WDT is the Main Watchdog Timer of Timer Group 1 + //Interrupt WDT is the Main Watchdog Timer of Timer Group 1 wdt_hal_write_protect_disable(&wdt1_context); wdt_hal_disable(&wdt1_context); wdt_hal_write_protect_enable(&wdt1_context); @@ -296,17 +296,17 @@ void esp_panic_handler(panic_info_t *info) // in debug mode. #if CONFIG_ESP_DEBUG_OCDAWARE if (esp_cpu_dbgr_is_attached()) { - char *panic_reason_str = NULL; - if (info->pseudo_excause) { - panic_reason_str = (char *)info->reason; - } else if (g_panic_abort && strlen(g_panic_abort_details)) { - panic_reason_str = g_panic_abort_details; - } - if (panic_reason_str) { - /* OpenOCD will print the halt cause when target is stopped at the below breakpoint (info->addr) */ - long args[] = {(long)panic_reason_str, strlen(panic_reason_str)}; - semihosting_call_noerrno(ESP_SEMIHOSTING_SYS_PANIC_REASON, args); - } + char *panic_reason_str = NULL; + if (info->pseudo_excause) { + panic_reason_str = (char *)info->reason; + } else if (g_panic_abort) { + panic_reason_str = g_panic_abort_details; + } + if (panic_reason_str) { + /* OpenOCD will print the halt cause when target is stopped at the below breakpoint (info->addr) */ + long args[] = {(long)panic_reason_str, strlen(panic_reason_str)}; + semihosting_call_noerrno(ESP_SEMIHOSTING_SYS_PANIC_REASON, args); + } panic_print_str("Setting breakpoint at 0x"); panic_print_hex((uint32_t)info->addr); panic_print_str(" and returning...\r\n"); diff --git a/components/esp_system/port/cpu_start.c b/components/esp_system/port/cpu_start.c index 0d8696c4cb..c975932f14 100644 --- a/components/esp_system/port/cpu_start.c +++ b/components/esp_system/port/cpu_start.c @@ -13,6 +13,7 @@ #include "esp_log.h" #include "esp_chip_info.h" +#include "esp_app_format.h" #include "esp_efuse.h" #include "esp_private/cache_err_int.h" @@ -44,7 +45,6 @@ #include "soc/assist_debug_reg.h" #include "soc/system_reg.h" #include "esp32s3/rom/opi_flash.h" -#include "hal/cache_hal.h" #elif CONFIG_IDF_TARGET_ESP32C3 #include "esp32c3/rtc.h" #include "esp32c3/rom/cache.h" @@ -82,6 +82,7 @@ #include "esp_private/sleep_gpio.h" #include "hal/wdt_hal.h" #include "soc/rtc.h" +#include "hal/cache_hal.h" #include "hal/cache_ll.h" #include "hal/efuse_ll.h" #include "soc/periph_defs.h" @@ -259,6 +260,17 @@ static void start_other_core(void) } } +#if CONFIG_IDF_TARGET_ESP32 +static void restore_app_mmu_from_pro_mmu(void) +{ + const int mmu_reg_num = 2048; + volatile uint32_t* from = (uint32_t*)DR_REG_FLASH_MMU_TABLE_PRO; + volatile uint32_t* to = (uint32_t*)DR_REG_FLASH_MMU_TABLE_APP; + for (int i = 0; i < mmu_reg_num; i++) { + *(to++) = *(from++); + } +} +#endif // This function is needed to make the multicore app runnable on a unicore bootloader (built with FREERTOS UNICORE). // It does some cache settings for other CPUs. void IRAM_ATTR do_multicore_settings(void) @@ -270,9 +282,11 @@ void IRAM_ATTR do_multicore_settings(void) Cache_Read_Disable(1); Cache_Flush(1); DPORT_REG_SET_BIT(DPORT_APP_CACHE_CTRL1_REG, DPORT_APP_CACHE_MMU_IA_CLR); + mmu_init(1); DPORT_REG_CLR_BIT(DPORT_APP_CACHE_CTRL1_REG, DPORT_APP_CACHE_MMU_IA_CLR); // We do not enable cache for CPU1 now because it will be done later in start_other_core(). } + restore_app_mmu_from_pro_mmu(); #endif cache_bus_mask_t cache_bus_mask_core0 = cache_ll_l1_get_enabled_bus(0); @@ -360,6 +374,11 @@ void IRAM_ATTR call_start_cpu0(void) #endif #endif // !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP +#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP + //cache hal ctx needs to be initialised + cache_hal_init(); +#endif + // When the APP is loaded into ram for execution, some hardware initialization behaviors // in the bootloader are still necessary #if CONFIG_APP_BUILD_TYPE_RAM @@ -444,6 +463,10 @@ void IRAM_ATTR call_start_cpu0(void) // For Octal flash, it's hard to implement a read_id function in OPI mode for all vendors. // So we have to read it here in SPI mode, before entering the OPI mode. bootloader_flash_update_id(); + + // Configure the power related stuff. After this the MSPI timing tuning can be done. + esp_rtc_init(); + /** * This function initialise the Flash chip to the user-defined settings. * @@ -452,14 +475,9 @@ void IRAM_ATTR call_start_cpu0(void) * In this stage, we re-configure the Flash (and MSPI) to required configuration */ spi_flash_init_chip_state(); - - // In earlier version of ESP-IDF, the PLL provided by bootloader is not stable enough. - // Do calibration again here so that we can use better clock for the timing tuning. -#if CONFIG_ESP_SYSTEM_BBPLL_RECALIB - rtc_clk_recalib_bbpll(); -#endif #if SOC_MEMSPI_SRC_FREQ_120M - // This function needs to be called when PLL is enabled + // This function needs to be called when PLL is enabled. Needs to be called after spi_flash_init_chip_state in case + // some state of flash is modified. mspi_timing_flash_tuning(); #endif @@ -662,9 +680,14 @@ void IRAM_ATTR call_start_cpu0(void) bootloader_flash_unlock(); #else - // This assumes that DROM is the first segment in the application binary, i.e. that we can read - // the binary header through cache by accessing SOC_DROM_LOW address. - hal_memcpy(&fhdr, (void *) SOC_DROM_LOW, sizeof(fhdr)); + // We can access the image header through the cache by reading from the memory-mapped virtual DROM start offset + uint32_t fhdr_src_addr = (uint32_t)(&_rodata_reserved_start) - sizeof(esp_image_header_t) - sizeof(esp_image_segment_header_t); + hal_memcpy(&fhdr, (void *) fhdr_src_addr, sizeof(fhdr)); + if (fhdr.magic != ESP_IMAGE_HEADER_MAGIC) { + ESP_EARLY_LOGE(TAG, "Invalid app image header"); + abort(); + } + #endif // CONFIG_APP_BUILD_TYPE_RAM && !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP diff --git a/components/esp_system/port/include/esp_clk_internal.h b/components/esp_system/port/include/esp_clk_internal.h index b69d7cfcea..72b6b20b92 100644 --- a/components/esp_system/port/include/esp_clk_internal.h +++ b/components/esp_system/port/include/esp_clk_internal.h @@ -18,6 +18,15 @@ extern "C" { * Private clock-related functions */ +/** + * @brief Initialize rtc-related settings + * + * Called from cpu_start.c, not intended to be called from other places. + * This function configures the power related stuff. + * After this the MSPI timing tuning can be done. + */ +void esp_rtc_init(void); + /** * @brief Initialize clock-related settings * diff --git a/components/esp_system/port/soc/esp32/clk.c b/components/esp_system/port/soc/esp32/clk.c index 3357e14f4d..9f46a2ff69 100644 --- a/components/esp_system/port/soc/esp32/clk.c +++ b/components/esp_system/port/soc/esp32/clk.c @@ -106,11 +106,14 @@ static void select_rtc_slow_clk(slow_clk_sel_t slow_clk) esp_clk_slowclk_cal_set(cal_val); } - __attribute__((weak)) void esp_clk_init(void) +void esp_rtc_init(void) { rtc_config_t cfg = RTC_CONFIG_DEFAULT(); rtc_init(cfg); +} +__attribute__((weak)) void esp_clk_init(void) +{ #if (CONFIG_APP_COMPATIBLE_PRE_V2_1_BOOTLOADERS || CONFIG_APP_INIT_CLK) /* Check the bootloader set the XTAL frequency. diff --git a/components/esp_system/port/soc/esp32c2/clk.c b/components/esp_system/port/soc/esp32c2/clk.c index 207673d853..d6d0879f7c 100644 --- a/components/esp_system/port/soc/esp32c2/clk.c +++ b/components/esp_system/port/soc/esp32c2/clk.c @@ -48,12 +48,19 @@ typedef enum { } slow_clk_sel_t; static void select_rtc_slow_clk(slow_clk_sel_t slow_clk); +static __attribute__((unused)) void recalib_bbpll(void); static const char *TAG = "clk"; - __attribute__((weak)) void esp_clk_init(void) +void esp_rtc_init(void) { +#if CONFIG_ESP_SYSTEM_BBPLL_RECALIB + // In earlier version of ESP-IDF, the PLL provided by bootloader is not stable enough. + // Do calibration again here so that we can use better clock for the timing tuning. + recalib_bbpll(); +#endif + #if !CONFIG_IDF_ENV_FPGA rtc_config_t cfg = RTC_CONFIG_DEFAULT(); soc_reset_reason_t rst_reas; @@ -62,7 +69,12 @@ static const char *TAG = "clk"; cfg.cali_ocode = 1; } rtc_init(cfg); +#endif +} +__attribute__((weak)) void esp_clk_init(void) +{ +#if !CONFIG_IDF_ENV_FPGA #ifndef CONFIG_XTAL_FREQ_AUTO assert(rtc_clk_xtal_freq_get() == CONFIG_XTAL_FREQ); #endif @@ -263,3 +275,21 @@ __attribute__((weak)) void esp_perip_clk_init(void) */ periph_module_enable(PERIPH_TIMG0_MODULE); } + +// Workaround for bootloader not calibrated well issue. +// Placed in IRAM because disabling BBPLL may influence the cache +static void IRAM_ATTR NOINLINE_ATTR recalib_bbpll(void) +{ + rtc_cpu_freq_config_t old_config; + rtc_clk_cpu_freq_get_config(&old_config); + + // There are two paths we arrive here: 1. CPU reset. 2. Other reset reasons. + // - For other reasons, the bootloader will set CPU source to BBPLL and enable it. But there are calibration issues. + // Turn off the BBPLL and do calibration again to fix the issue. + // - For CPU reset, the CPU source will be set to XTAL, while the BBPLL is kept to meet USB Serial JTAG's + // requirements. In this case, we don't touch BBPLL to avoid USJ disconnection. + if (old_config.source == SOC_CPU_CLK_SRC_PLL) { + rtc_clk_cpu_freq_set_xtal(); + rtc_clk_cpu_freq_set_config(&old_config); + } +} diff --git a/components/esp_system/port/soc/esp32c3/clk.c b/components/esp_system/port/soc/esp32c3/clk.c index bdafbc973b..02b4168237 100644 --- a/components/esp_system/port/soc/esp32c3/clk.c +++ b/components/esp_system/port/soc/esp32c3/clk.c @@ -54,7 +54,7 @@ static void select_rtc_slow_clk(slow_clk_sel_t slow_clk); static const char *TAG = "clk"; - __attribute__((weak)) void esp_clk_init(void) +void esp_rtc_init(void) { #if !CONFIG_IDF_ENV_FPGA rtc_config_t cfg = RTC_CONFIG_DEFAULT(); @@ -68,7 +68,10 @@ static const char *TAG = "clk"; cfg.cali_ocode = 1; } rtc_init(cfg); +} +__attribute__((weak)) void esp_clk_init(void) +{ assert(rtc_clk_xtal_freq_get() == RTC_XTAL_FREQ_40M); bool rc_fast_d256_is_enabled = rtc_clk_8md256_enabled(); diff --git a/components/esp_system/port/soc/esp32c6/clk.c b/components/esp_system/port/soc/esp32c6/clk.c index ed9de21041..9d08655489 100644 --- a/components/esp_system/port/soc/esp32c6/clk.c +++ b/components/esp_system/port/soc/esp32c6/clk.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -34,18 +34,30 @@ #define SLOW_CLK_CAL_CYCLES CONFIG_RTC_CLK_CAL_CYCLES static void select_rtc_slow_clk(soc_rtc_slow_clk_src_t rtc_slow_clk_src); +static __attribute__((unused)) void recalib_bbpll(void); static const char *TAG = "clk"; -__attribute__((weak)) void esp_clk_init(void) +void esp_rtc_init(void) { +#if CONFIG_ESP_SYSTEM_BBPLL_RECALIB + // In earlier version of ESP-IDF, the PLL provided by bootloader is not stable enough. + // Do calibration again here so that we can use better clock for the timing tuning. + recalib_bbpll(); +#endif + #if !CONFIG_IDF_ENV_FPGA pmu_init(); if (esp_rom_get_reset_reason(0) == RESET_REASON_CHIP_POWER_ON) { esp_ocode_calib_init(); } +#endif +} +__attribute__((weak)) void esp_clk_init(void) +{ +#if !CONFIG_IDF_ENV_FPGA assert(rtc_clk_xtal_freq_get() == RTC_XTAL_FREQ_40M); rtc_clk_8m_enable(true); @@ -67,6 +79,7 @@ __attribute__((weak)) void esp_clk_init(void) wdt_hal_write_protect_enable(&rtc_wdt_ctx); #endif + modem_clock_deselect_all_module_lp_clock_source(); #if defined(CONFIG_RTC_CLK_SRC_EXT_CRYS) select_rtc_slow_clk(SOC_RTC_SLOW_CLK_SRC_XTAL32K); #elif defined(CONFIG_RTC_CLK_SRC_EXT_OSC) @@ -148,6 +161,15 @@ static void select_rtc_slow_clk(soc_rtc_slow_clk_src_t rtc_slow_clk_src) } rtc_clk_slow_src_set(rtc_slow_clk_src); + // Disable unused clock sources after clock source switching is complete. + // Regardless of the clock source selection, the internal 136K clock source will always keep on. + if (rtc_slow_clk_src != SOC_RTC_SLOW_CLK_SRC_XTAL32K && rtc_slow_clk_src != SOC_RTC_SLOW_CLK_SRC_OSC_SLOW) { + rtc_clk_32k_enable(false); + } + if (rtc_slow_clk_src != SOC_RTC_SLOW_CLK_SRC_RC32K) { + rtc_clk_rc32k_enable(false); + } + if (SLOW_CLK_CAL_CYCLES > 0) { /* TODO: 32k XTAL oscillator has some frequency drift at startup. * Improve calibration routine to wait until the frequency is stable. @@ -299,3 +321,21 @@ __attribute__((weak)) void esp_perip_clk_init(void) */ periph_module_enable(PERIPH_TIMG0_MODULE); } + +// Workaround for bootloader not calibrated well issue. +// Placed in IRAM because disabling BBPLL may influence the cache +static void IRAM_ATTR NOINLINE_ATTR recalib_bbpll(void) +{ + rtc_cpu_freq_config_t old_config; + rtc_clk_cpu_freq_get_config(&old_config); + + // There are two paths we arrive here: 1. CPU reset. 2. Other reset reasons. + // - For other reasons, the bootloader will set CPU source to BBPLL and enable it. But there are calibration issues. + // Turn off the BBPLL and do calibration again to fix the issue. + // - For CPU reset, the CPU source will be set to XTAL, while the BBPLL is kept to meet USB Serial JTAG's + // requirements. In this case, we don't touch BBPLL to avoid USJ disconnection. + if (old_config.source == SOC_CPU_CLK_SRC_PLL) { + rtc_clk_cpu_freq_set_xtal(); + rtc_clk_cpu_freq_set_config(&old_config); + } +} diff --git a/components/esp_system/port/soc/esp32h2/clk.c b/components/esp_system/port/soc/esp32h2/clk.c index 8ced39f8e4..33e91a2f31 100644 --- a/components/esp_system/port/soc/esp32h2/clk.c +++ b/components/esp_system/port/soc/esp32h2/clk.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -21,6 +21,7 @@ #include "soc/i2s_reg.h" #include "soc/pcr_reg.h" #include "hal/wdt_hal.h" +#include "esp_private/esp_modem_clock.h" #include "esp_private/periph_ctrl.h" #include "esp_private/esp_clk.h" #include "esp_private/esp_pmu.h" @@ -37,15 +38,27 @@ #define MHZ (1000000) static void select_rtc_slow_clk(soc_rtc_slow_clk_src_t rtc_slow_clk_src); +static __attribute__((unused)) void recalib_bbpll(void); static const char *TAG = "clk"; - __attribute__((weak)) void esp_clk_init(void) +void esp_rtc_init(void) { +#if CONFIG_ESP_SYSTEM_BBPLL_RECALIB + // In earlier version of ESP-IDF, the PLL provided by bootloader is not stable enough. + // Do calibration again here so that we can use better clock for the timing tuning. + recalib_bbpll(); +#endif + #if !CONFIG_IDF_ENV_FPGA pmu_init(); +#endif +} +__attribute__((weak)) void esp_clk_init(void) +{ +#if !CONFIG_IDF_ENV_FPGA assert(rtc_clk_xtal_freq_get() == RTC_XTAL_FREQ_32M); rtc_clk_8m_enable(true); @@ -69,6 +82,7 @@ static const char *TAG = "clk"; wdt_hal_write_protect_enable(&rtc_wdt_ctx); #endif + modem_clock_deselect_all_module_lp_clock_source(); #if defined(CONFIG_RTC_CLK_SRC_EXT_CRYS) select_rtc_slow_clk(SOC_RTC_SLOW_CLK_SRC_XTAL32K); #elif defined(CONFIG_RTC_CLK_SRC_EXT_OSC) @@ -153,6 +167,15 @@ static void select_rtc_slow_clk(soc_rtc_slow_clk_src_t rtc_slow_clk_src) } rtc_clk_slow_src_set(rtc_slow_clk_src); + // Disable unused clock sources after clock source switching is complete. + // Regardless of the clock source selection, the internal 136K clock source will always keep on. + if (rtc_slow_clk_src != SOC_RTC_SLOW_CLK_SRC_XTAL32K && rtc_slow_clk_src != SOC_RTC_SLOW_CLK_SRC_OSC_SLOW) { + rtc_clk_32k_enable(false); + } + if (rtc_slow_clk_src != SOC_RTC_SLOW_CLK_SRC_RC32K) { + rtc_clk_rc32k_enable(false); + } + if (SLOW_CLK_CAL_CYCLES > 0) { /* TODO: 32k XTAL oscillator has some frequency drift at startup. * Improve calibration routine to wait until the frequency is stable. @@ -296,3 +319,21 @@ __attribute__((weak)) void esp_perip_clk_init(void) */ periph_module_enable(PERIPH_TIMG0_MODULE); } + +// Workaround for bootloader not calibrated well issue. +// Placed in IRAM because disabling BBPLL may influence the cache +static void IRAM_ATTR NOINLINE_ATTR recalib_bbpll(void) +{ + rtc_cpu_freq_config_t old_config; + rtc_clk_cpu_freq_get_config(&old_config); + + // There are two paths we arrive here: 1. CPU reset. 2. Other reset reasons. + // - For other reasons, the bootloader will set CPU source to BBPLL and enable it. But there are calibration issues. + // Turn off the BBPLL and do calibration again to fix the issue. Flash_PLL comes from the same source as PLL. + // - For CPU reset, the CPU source will be set to XTAL, while the BBPLL is kept to meet USB Serial JTAG's + // requirements. In this case, we don't touch BBPLL to avoid USJ disconnection. + if (old_config.source == SOC_CPU_CLK_SRC_PLL || old_config.source == SOC_CPU_CLK_SRC_FLASH_PLL) { + rtc_clk_cpu_freq_set_xtal(); + rtc_clk_cpu_freq_set_config(&old_config); + } +} diff --git a/components/esp_system/port/soc/esp32s2/clk.c b/components/esp_system/port/soc/esp32s2/clk.c index a833604d8f..55a06ea83c 100644 --- a/components/esp_system/port/soc/esp32s2/clk.c +++ b/components/esp_system/port/soc/esp32s2/clk.c @@ -60,7 +60,7 @@ typedef enum { static void select_rtc_slow_clk(slow_clk_sel_t slow_clk); - __attribute__((weak)) void esp_clk_init(void) +void esp_rtc_init(void) { rtc_config_t cfg = RTC_CONFIG_DEFAULT(); soc_reset_reason_t rst_reas = esp_rom_get_reset_reason(0); @@ -74,7 +74,10 @@ static void select_rtc_slow_clk(slow_clk_sel_t slow_clk); } } rtc_init(cfg); +} +__attribute__((weak)) void esp_clk_init(void) +{ bool rc_fast_d256_is_enabled = rtc_clk_8md256_enabled(); rtc_clk_8m_enable(true, rc_fast_d256_is_enabled); rtc_clk_fast_src_set(SOC_RTC_FAST_CLK_SRC_RC_FAST); diff --git a/components/esp_system/port/soc/esp32s3/clk.c b/components/esp_system/port/soc/esp32s3/clk.c index 7b0c2c80dc..6f54d990cf 100644 --- a/components/esp_system/port/soc/esp32s3/clk.c +++ b/components/esp_system/port/soc/esp32s3/clk.c @@ -52,9 +52,16 @@ typedef enum { } slow_clk_sel_t; static void select_rtc_slow_clk(slow_clk_sel_t slow_clk); +static __attribute__((unused)) void recalib_bbpll(void); - __attribute__((weak)) void esp_clk_init(void) +void esp_rtc_init(void) { +#if CONFIG_ESP_SYSTEM_BBPLL_RECALIB + // In earlier version of ESP-IDF, the PLL provided by bootloader is not stable enough. + // Do calibration again here so that we can use better clock for the timing tuning. + recalib_bbpll(); +#endif + rtc_config_t cfg = RTC_CONFIG_DEFAULT(); soc_reset_reason_t rst_reas; rst_reas = esp_rom_get_reset_reason(0); @@ -63,7 +70,10 @@ static void select_rtc_slow_clk(slow_clk_sel_t slow_clk); cfg.cali_ocode = 1; } rtc_init(cfg); +} +__attribute__((weak)) void esp_clk_init(void) +{ assert(rtc_clk_xtal_freq_get() == RTC_XTAL_FREQ_40M); bool rc_fast_d256_is_enabled = rtc_clk_8md256_enabled(); @@ -323,3 +333,21 @@ __attribute__((weak)) void esp_perip_clk_init(void) */ periph_module_enable(PERIPH_TIMG0_MODULE); } + +// Workaround for bootloader not calibrated well issue. +// Placed in IRAM because disabling BBPLL may influence the cache +static void IRAM_ATTR NOINLINE_ATTR recalib_bbpll(void) +{ + rtc_cpu_freq_config_t old_config; + rtc_clk_cpu_freq_get_config(&old_config); + + // There are two paths we arrive here: 1. CPU reset. 2. Other reset reasons. + // - For other reasons, the bootloader will set CPU source to BBPLL and enable it. But there are calibration issues. + // Turn off the BBPLL and do calibration again to fix the issue. + // - For CPU reset, the CPU source will be set to XTAL, while the BBPLL is kept to meet USB Serial JTAG's + // requirements. In this case, we don't touch BBPLL to avoid USJ disconnection. + if (old_config.source == SOC_CPU_CLK_SRC_PLL) { + rtc_clk_cpu_freq_set_xtal(); + rtc_clk_cpu_freq_set_config(&old_config); + } +} diff --git a/components/esp_wifi/Kconfig b/components/esp_wifi/Kconfig index b173d31f5c..d77ae6aa9c 100644 --- a/components/esp_wifi/Kconfig +++ b/components/esp_wifi/Kconfig @@ -11,8 +11,8 @@ menu "Wi-Fi" int "Max number of WiFi static RX buffers" range 2 25 if !SOC_WIFI_HE_SUPPORT range 2 128 if SOC_WIFI_HE_SUPPORT - default 10 if !SPIRAM_TRY_ALLOCATE_WIFI_LWIP - default 16 if SPIRAM_TRY_ALLOCATE_WIFI_LWIP + default 10 if !(SPIRAM_TRY_ALLOCATE_WIFI_LWIP && !SPIRAM_IGNORE_NOTFOUND) + default 16 if (SPIRAM_TRY_ALLOCATE_WIFI_LWIP && !SPIRAM_IGNORE_NOTFOUND) help Set the number of WiFi static RX buffers. Each buffer takes approximately 1.6KB of RAM. The static rx buffers are allocated when esp_wifi_init is called, they are not freed @@ -63,7 +63,7 @@ menu "Wi-Fi" bool "Static" config ESP_WIFI_DYNAMIC_TX_BUFFER bool "Dynamic" - depends on !SPIRAM_USE_MALLOC + depends on !(SPIRAM_TRY_ALLOCATE_WIFI_LWIP && !SPIRAM_IGNORE_NOTFOUND) endchoice config ESP_WIFI_TX_BUFFER_TYPE @@ -88,8 +88,8 @@ menu "Wi-Fi" config ESP_WIFI_CACHE_TX_BUFFER_NUM int "Max number of WiFi cache TX buffers" - depends on SPIRAM - range 16 128 + depends on (SPIRAM_TRY_ALLOCATE_WIFI_LWIP && !SPIRAM_IGNORE_NOTFOUND) + range 0 128 default 32 help Set the number of WiFi cache TX buffer number. @@ -186,19 +186,19 @@ menu "Wi-Fi" depends on ESP_WIFI_AMPDU_RX_ENABLED range 2 32 if !SOC_WIFI_HE_SUPPORT range 2 64 if SOC_WIFI_HE_SUPPORT - default 6 if !SPIRAM_TRY_ALLOCATE_WIFI_LWIP - default 16 if SPIRAM_TRY_ALLOCATE_WIFI_LWIP + default 6 if !(SPIRAM_TRY_ALLOCATE_WIFI_LWIP && !SPIRAM_IGNORE_NOTFOUND) + default 16 if (SPIRAM_TRY_ALLOCATE_WIFI_LWIP && !SPIRAM_IGNORE_NOTFOUND) help Set the size of WiFi Block Ack RX window. Generally a bigger value means higher throughput and better compatibility but more memory. Most of time we should NOT change the default value unless special reason, e.g. test the maximum UDP RX throughput with iperf etc. For iperf test in shieldbox, the - recommended value is 9~12. If PSRAM is used and WiFi memory is prefered to allocat in PSRAM first, + recommended value is 9~12. If PSRAM is used and WiFi memory is preferred to allocate in PSRAM first, the default and minimum value should be 16 to achieve better throughput and compatibility with both stations and APs. config ESP_WIFI_AMSDU_TX_ENABLED bool "WiFi AMSDU TX" - depends on SPIRAM + depends on (ESP_WIFI_CACHE_TX_BUFFER_NUM >= 2) default n help Select this option to enable AMSDU TX feature @@ -249,7 +249,10 @@ menu "Wi-Fi" range 6 32 default 32 help - Set the number of WiFi management short buffer. + Set the maximum number of Wi-Fi management short buffers. These buffers are dynamically allocated, + with their size determined by the length of the management packet to be sent. When a management + packet is less than 64 bytes, the Wi-Fi driver classifies it as a short management packet and + assigns it to one of these buffers. config ESP_WIFI_IRAM_OPT bool "WiFi IRAM speed optimization" diff --git a/components/esp_wifi/esp32/esp_adapter.c b/components/esp_wifi/esp32/esp_adapter.c index 726255c2a3..25f2dda393 100644 --- a/components/esp_wifi/esp32/esp_adapter.c +++ b/components/esp_wifi/esp32/esp_adapter.c @@ -45,6 +45,9 @@ #include "esp_rom_sys.h" #include "esp32/rom/ets_sys.h" #include "private/esp_modem_wrapper.h" +#if __has_include("esp_psram.h") +#include "esp_psram.h" +#endif #define TAG "esp_adapter" @@ -256,36 +259,31 @@ static int32_t IRAM_ATTR mutex_unlock_wrapper(void *mutex) static void * queue_create_wrapper(uint32_t queue_len, uint32_t item_size) { -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0) - /* - * Since release/v5.1, FreeRTOS has been updated to always use internal memory (i.e., DRAM) - * for dynamic memory allocation. Calling FreeRTOS creation functions (e.g., xTaskCreate(), xQueueCreate()) - * will guarantee that the memory allocated for those tasks/objects is from internal memory. - * For more details, please refer to the Migration Guide in release/v5.1. - */ -#if CONFIG_SPIRAM_USE_MALLOC - /* Use xQueueCreateWithCaps() to allocate from SPIRAM */ - return (void *)xQueueCreateWithCaps(queue_len, item_size, MALLOC_CAP_SPIRAM); -#else - return (void *)xQueueCreate(queue_len, item_size); -#endif -#else - return (void *)xQueueCreate(queue_len, item_size); -#endif + StaticQueue_t *queue_buffer = heap_caps_malloc_prefer(sizeof(StaticQueue_t) + (queue_len * item_size), 2, + MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM, + MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL); + if (!queue_buffer) { + return NULL; + } + QueueHandle_t queue_handle = xQueueCreateStatic(queue_len, item_size, (uint8_t *)queue_buffer + sizeof(StaticQueue_t), + queue_buffer); + if (!queue_handle) { + free(queue_buffer); + return NULL; + } + + return (void *)queue_handle; } static void queue_delete_wrapper(void *queue) { if (queue) { -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0) -#if CONFIG_SPIRAM_USE_MALLOC - vQueueDeleteWithCaps(queue); -#else + StaticQueue_t *queue_buffer = NULL; + xQueueGetStaticBuffers(queue, NULL, &queue_buffer); vQueueDelete(queue); -#endif -#else - vQueueDelete(queue); -#endif + if (queue_buffer) { + free(queue_buffer); + } } } @@ -450,7 +448,7 @@ static void coex_disable_wrapper(void) static IRAM_ATTR uint32_t coex_status_get_wrapper(void) { #if CONFIG_SW_COEXIST_ENABLE - return coex_status_get(); + return coex_status_get(COEX_STATUS_GET_WIFI_BITMAP); #else return 0; #endif diff --git a/components/esp_wifi/esp32c2/esp_adapter.c b/components/esp_wifi/esp32c2/esp_adapter.c index 22aadef0c2..32a09b2295 100644 --- a/components/esp_wifi/esp32c2/esp_adapter.c +++ b/components/esp_wifi/esp32c2/esp_adapter.c @@ -384,7 +384,7 @@ static void coex_disable_wrapper(void) static IRAM_ATTR uint32_t coex_status_get_wrapper(void) { #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE - return coex_status_get(); + return coex_status_get(COEX_STATUS_GET_WIFI_BITMAP); #else return 0; #endif diff --git a/components/esp_wifi/esp32c3/esp_adapter.c b/components/esp_wifi/esp32c3/esp_adapter.c index d08b7467ed..bb403dd5d7 100644 --- a/components/esp_wifi/esp32c3/esp_adapter.c +++ b/components/esp_wifi/esp32c3/esp_adapter.c @@ -401,7 +401,7 @@ static void coex_disable_wrapper(void) static IRAM_ATTR uint32_t coex_status_get_wrapper(void) { #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE - return coex_status_get(); + return coex_status_get(COEX_STATUS_GET_WIFI_BITMAP); #else return 0; #endif diff --git a/components/esp_wifi/esp32c6/esp_adapter.c b/components/esp_wifi/esp32c6/esp_adapter.c index e6e5cbf711..de5b1b94c4 100644 --- a/components/esp_wifi/esp32c6/esp_adapter.c +++ b/components/esp_wifi/esp32c6/esp_adapter.c @@ -390,7 +390,7 @@ static void coex_disable_wrapper(void) static IRAM_ATTR uint32_t coex_status_get_wrapper(void) { #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE - return coex_status_get(); + return coex_status_get(COEX_STATUS_GET_WIFI_BITMAP); #else return 0; #endif diff --git a/components/esp_wifi/esp32s2/esp_adapter.c b/components/esp_wifi/esp32s2/esp_adapter.c index 347ac0c94f..e99c379fe9 100644 --- a/components/esp_wifi/esp32s2/esp_adapter.c +++ b/components/esp_wifi/esp32s2/esp_adapter.c @@ -46,6 +46,9 @@ #include "esp_rom_sys.h" #include "esp32s2/rom/ets_sys.h" #include "private/esp_modem_wrapper.h" +#if __has_include("esp_psram.h") +#include "esp_psram.h" +#endif #define TAG "esp_adapter" @@ -247,36 +250,31 @@ static int32_t IRAM_ATTR mutex_unlock_wrapper(void *mutex) static void * queue_create_wrapper(uint32_t queue_len, uint32_t item_size) { -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0) - /* - * Since release/v5.1, FreeRTOS has been updated to always use internal memory (i.e., DRAM) - * for dynamic memory allocation. Calling FreeRTOS creation functions (e.g., xTaskCreate(), xQueueCreate()) - * will guarantee that the memory allocated for those tasks/objects is from internal memory. - * For more details, please refer to the Migration Guide in release/v5.1. - */ -#if CONFIG_SPIRAM_USE_MALLOC - /* Use xQueueCreateWithCaps() to allocate from SPIRAM */ - return (void *)xQueueCreateWithCaps(queue_len, item_size, MALLOC_CAP_SPIRAM); -#else - return (void *)xQueueCreate(queue_len, item_size); -#endif -#else - return (void *)xQueueCreate(queue_len, item_size); -#endif + StaticQueue_t *queue_buffer = heap_caps_malloc_prefer(sizeof(StaticQueue_t) + (queue_len * item_size), 2, + MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM, + MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL); + if (!queue_buffer) { + return NULL; + } + QueueHandle_t queue_handle = xQueueCreateStatic(queue_len, item_size, (uint8_t *)queue_buffer + sizeof(StaticQueue_t), + queue_buffer); + if (!queue_handle) { + free(queue_buffer); + return NULL; + } + + return (void *)queue_handle; } static void queue_delete_wrapper(void *queue) { if (queue) { -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0) -#if CONFIG_SPIRAM_USE_MALLOC - vQueueDeleteWithCaps(queue); -#else + StaticQueue_t *queue_buffer = NULL; + xQueueGetStaticBuffers(queue, NULL, &queue_buffer); vQueueDelete(queue); -#endif -#else - vQueueDelete(queue); -#endif + if (queue_buffer) { + free(queue_buffer); + } } } @@ -441,7 +439,7 @@ static void coex_disable_wrapper(void) static IRAM_ATTR uint32_t coex_status_get_wrapper(void) { #if CONFIG_EXTERNAL_COEX_ENABLE - return coex_status_get(); + return coex_status_get(COEX_STATUS_GET_WIFI_BITMAP); #else return 0; #endif diff --git a/components/esp_wifi/esp32s3/esp_adapter.c b/components/esp_wifi/esp32s3/esp_adapter.c index d565b3ba3d..692fa7b958 100644 --- a/components/esp_wifi/esp32s3/esp_adapter.c +++ b/components/esp_wifi/esp32s3/esp_adapter.c @@ -47,6 +47,9 @@ #include "esp_rom_sys.h" #include "esp32s3/rom/ets_sys.h" #include "private/esp_modem_wrapper.h" +#if __has_include("esp_psram.h") +#include "esp_psram.h" +#endif #define TAG "esp_adapter" @@ -250,36 +253,31 @@ static int32_t IRAM_ATTR mutex_unlock_wrapper(void *mutex) static void * queue_create_wrapper(uint32_t queue_len, uint32_t item_size) { -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0) - /* - * Since release/v5.1, FreeRTOS has been updated to always use internal memory (i.e., DRAM) - * for dynamic memory allocation. Calling FreeRTOS creation functions (e.g., xTaskCreate(), xQueueCreate()) - * will guarantee that the memory allocated for those tasks/objects is from internal memory. - * For more details, please refer to the Migration Guide in release/v5.1. - */ -#if CONFIG_SPIRAM_USE_MALLOC - /* Use xQueueCreateWithCaps() to allocate from SPIRAM */ - return (void *)xQueueCreateWithCaps(queue_len, item_size, MALLOC_CAP_SPIRAM); -#else - return (void *)xQueueCreate(queue_len, item_size); -#endif -#else - return (void *)xQueueCreate(queue_len, item_size); -#endif + StaticQueue_t *queue_buffer = heap_caps_malloc_prefer(sizeof(StaticQueue_t) + (queue_len * item_size), 2, + MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM, + MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL); + if (!queue_buffer) { + return NULL; + } + QueueHandle_t queue_handle = xQueueCreateStatic(queue_len, item_size, (uint8_t *)queue_buffer + sizeof(StaticQueue_t), + queue_buffer); + if (!queue_handle) { + free(queue_buffer); + return NULL; + } + + return (void *)queue_handle; } static void queue_delete_wrapper(void *queue) { if (queue) { -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0) -#if CONFIG_SPIRAM_USE_MALLOC - vQueueDeleteWithCaps(queue); -#else + StaticQueue_t *queue_buffer = NULL; + xQueueGetStaticBuffers(queue, NULL, &queue_buffer); vQueueDelete(queue); -#endif -#else - vQueueDelete(queue); -#endif + if (queue_buffer) { + free(queue_buffer); + } } } @@ -458,7 +456,7 @@ static void coex_disable_wrapper(void) static IRAM_ATTR uint32_t coex_status_get_wrapper(void) { #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE - return coex_status_get(); + return coex_status_get(COEX_STATUS_GET_WIFI_BITMAP); #else return 0; #endif diff --git a/components/esp_wifi/include/esp_now.h b/components/esp_wifi/include/esp_now.h index 3e8e8e299d..0e3dd85ab6 100644 --- a/components/esp_wifi/include/esp_now.h +++ b/components/esp_wifi/include/esp_now.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -48,7 +48,8 @@ extern "C" { #define ESP_NOW_MAX_TOTAL_PEER_NUM 20 /*!< Maximum number of ESPNOW total peers */ #define ESP_NOW_MAX_ENCRYPT_PEER_NUM 6 /*!< Maximum number of ESPNOW encrypted peers */ -#define ESP_NOW_MAX_DATA_LEN 250 /*!< Maximum length of ESPNOW data which is sent very time */ +#define ESP_NOW_MAX_IE_DATA_LEN 250 /**< Maximum data length in a vendor-specific element */ +#define ESP_NOW_MAX_DATA_LEN ESP_NOW_MAX_IE_DATA_LEN /**< Maximum length of data sent in each ESPNOW transmission for v1.0 */ /** * @brief Status of sending ESPNOW data . @@ -134,7 +135,10 @@ esp_err_t esp_now_init(void); esp_err_t esp_now_deinit(void); /** - * @brief Get the version of ESPNOW + * @brief Get the version of ESPNOW. Currently, ESPNOW supports one version: v1.0. + * + * The v1.0 devices can receive packets if the packet length is less than or equal to ESP_NOW_MAX_IE_DATA_LEN. + * For packets exceeding this length, the v1.0 devices will discard the packet entirely. * * @param version ESPNOW version * diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index d517c380e8..df19f53017 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -126,7 +126,7 @@ typedef struct { #define WIFI_STATIC_TX_BUFFER_NUM 0 #endif -#if CONFIG_SPIRAM +#ifdef CONFIG_ESP_WIFI_CACHE_TX_BUFFER_NUM #define WIFI_CACHE_TX_BUFFER_NUM CONFIG_ESP_WIFI_CACHE_TX_BUFFER_NUM #else #define WIFI_CACHE_TX_BUFFER_NUM 0 @@ -220,10 +220,10 @@ extern const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs; #define WIFI_ENABLE_WPA3_SAE 0 #endif -#if CONFIG_SPIRAM -#define WIFI_ENABLE_SPIRAM (1<<1) +#if WIFI_CACHE_TX_BUFFER_NUM > 0 +#define WIFI_ENABLE_CACHE_TX_BUFFER (1<<1) #else -#define WIFI_ENABLE_SPIRAM 0 +#define WIFI_ENABLE_CACHE_TX_BUFFER 0 #endif #if CONFIG_ESP_WIFI_FTM_INITIATOR_SUPPORT @@ -273,7 +273,7 @@ extern const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs; /* Set additional WiFi features and capabilities */ #define WIFI_FEATURE_CAPS (WIFI_ENABLE_WPA3_SAE | \ - WIFI_ENABLE_SPIRAM | \ + WIFI_ENABLE_CACHE_TX_BUFFER | \ WIFI_FTM_INITIATOR | \ WIFI_FTM_RESPONDER | \ WIFI_ENABLE_GCMP | \ diff --git a/components/esp_wifi/include/esp_wifi_he.h b/components/esp_wifi/include/esp_wifi_he.h index 67880654ab..28da491264 100644 --- a/components/esp_wifi/include/esp_wifi_he.h +++ b/components/esp_wifi/include/esp_wifi_he.h @@ -143,6 +143,15 @@ esp_err_t esp_wifi_enable_rx_statistics(bool rx_stats, bool rx_mu_stats); */ esp_err_t esp_wifi_enable_tx_statistics(esp_wifi_aci_t aci, bool tx_stats); +/** + * @brief Set WiFi TWT config + * + * @param[in] config pointer to the WiFi TWT configure structure. + * + * @return + * - ESP_OK: succeed + */ +esp_err_t esp_wifi_sta_twt_config(wifi_twt_config_t *config); #ifdef __cplusplus } diff --git a/components/esp_wifi/include/esp_wifi_he_types.h b/components/esp_wifi/include/esp_wifi_he_types.h index 397cd088f5..4e49c90a78 100644 --- a/components/esp_wifi/include/esp_wifi_he_types.h +++ b/components/esp_wifi/include/esp_wifi_he_types.h @@ -252,6 +252,7 @@ typedef enum { /** Argument structure for twt configuration */ typedef struct { bool post_wakeup_event; /**< post twt wakeup event */ + bool twt_enable_keep_alive; /**< twt enable send qos null to keep alive */ } wifi_twt_config_t; /** Argument structure for WIFI_EVENT_TWT_WAKEUP event */ diff --git a/components/esp_wifi/include/esp_wifi_types.h b/components/esp_wifi/include/esp_wifi_types.h index da626fdb9b..691b075920 100644 --- a/components/esp_wifi/include/esp_wifi_types.h +++ b/components/esp_wifi/include/esp_wifi_types.h @@ -77,10 +77,13 @@ typedef enum { WIFI_REASON_UNSPECIFIED = 1, WIFI_REASON_AUTH_EXPIRE = 2, WIFI_REASON_AUTH_LEAVE = 3, - WIFI_REASON_ASSOC_EXPIRE = 4, + WIFI_REASON_ASSOC_EXPIRE = 4, /* Deprecated, will be removed in next IDF major release */ + WIFI_REASON_DISASSOC_DUE_TO_INACTIVITY = 4, WIFI_REASON_ASSOC_TOOMANY = 5, - WIFI_REASON_NOT_AUTHED = 6, - WIFI_REASON_NOT_ASSOCED = 7, + WIFI_REASON_NOT_AUTHED = 6, /* Deprecated, will be removed in next IDF major release */ + WIFI_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6, + WIFI_REASON_NOT_ASSOCED = 7, /* Deprecated, will be removed in next IDF major release */ + WIFI_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7, WIFI_REASON_ASSOC_LEAVE = 8, WIFI_REASON_ASSOC_NOT_AUTHED = 9, WIFI_REASON_DISASSOC_PWRCAP_BAD = 10, @@ -293,8 +296,8 @@ typedef struct { uint8_t ssid_hidden; /**< Broadcast SSID or not, default 0, broadcast the SSID */ uint8_t max_connection; /**< Max number of stations allowed to connect in */ uint16_t beacon_interval; /**< Beacon interval which should be multiples of 100. Unit: TU(time unit, 1 TU = 1024 us). Range: 100 ~ 60000. Default value: 100 */ - uint8_t csa_count; /**< Channel Switch Announcement Count. Notify the station that the channel will switch after the csa_count beacon intervals. Default value: 3 */ - uint8_t dtim_period; /**< Dtim period of soft-AP. Default value: 2 */ + uint8_t csa_count; /**< Channel Switch Announcement Count. Notify the station that the channel will switch after the csa_count beacon intervals. Range: 1 ~ 30. Default value: 3 */ + uint8_t dtim_period; /**< Dtim period of soft-AP. Range: 1 ~ 10. Default value: 1 */ wifi_cipher_type_t pairwise_cipher; /**< Pairwise cipher of SoftAP, group cipher will be derived using this. Cipher values are valid starting from WIFI_CIPHER_TYPE_TKIP, enum values before that will be considered as invalid and default cipher suites(TKIP+CCMP) will be used. Valid cipher suites in softAP mode are WIFI_CIPHER_TYPE_TKIP, WIFI_CIPHER_TYPE_CCMP and WIFI_CIPHER_TYPE_TKIP_CCMP. */ bool ftm_responder; /**< Enable FTM Responder mode */ wifi_pmf_config_t pmf_cfg; /**< Configuration for Protected Management Frame */ @@ -884,6 +887,7 @@ typedef enum { WIFI_EVENT_STA_BEACON_TIMEOUT, /**< Station beacon timeout */ WIFI_EVENT_CONNECTIONLESS_MODULE_WAKE_INTERVAL_START, /**< Connectionless module wake interval start */ + /* Add next events after this only */ WIFI_EVENT_AP_WPS_RG_SUCCESS, /**< Soft-AP wps succeeds in registrar mode */ WIFI_EVENT_AP_WPS_RG_FAILED, /**< Soft-AP wps fails in registrar mode */ diff --git a/components/esp_wifi/src/wifi_init.c b/components/esp_wifi/src/wifi_init.c index 7361f366fd..0619a4bc23 100644 --- a/components/esp_wifi/src/wifi_init.c +++ b/components/esp_wifi/src/wifi_init.c @@ -579,3 +579,19 @@ void nan_sm_handle_event(void *p1, int p2) } #endif + +#if CONFIG_IDF_TARGET_ESP32C2 +#if CONFIG_ESP32C2_REV_MIN_FULL < 200 +void esp32c2_eco4_rom_ptr_init(void) +{ + /* Do not remove, stub to overwrite weak link in Wi-Fi Lib */ +} +#endif +#endif + +#ifndef CONFIG_ESP_WIFI_SLP_SAMPLE_BEACON_FEATURE +void pm_beacon_offset_funcs_init(void) +{ + /* Do not remove, stub to overwrite weak link in Wi-Fi Lib */ +} +#endif diff --git a/components/esp_wifi/src/wifi_netif.c b/components/esp_wifi/src/wifi_netif.c index 4fe30acfce..2f9b12dfac 100644 --- a/components/esp_wifi/src/wifi_netif.c +++ b/components/esp_wifi/src/wifi_netif.c @@ -69,7 +69,7 @@ static esp_err_t wifi_transmit(void *h, void *buffer, size_t len) static esp_err_t wifi_transmit_wrap(void *h, void *buffer, size_t len, void *netstack_buf) { wifi_netif_driver_t driver = h; -#if CONFIG_SPIRAM +#if CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP && !CONFIG_SPIRAM_IGNORE_NOTFOUND return esp_wifi_internal_tx_by_ref(driver->wifi_if, buffer, len, netstack_buf); #else return esp_wifi_internal_tx(driver->wifi_if, buffer, len); @@ -114,6 +114,9 @@ wifi_netif_driver_t esp_wifi_create_if_driver(wifi_interface_t wifi_if) esp_err_t esp_wifi_get_if_mac(wifi_netif_driver_t ifx, uint8_t mac[6]) { + if (ifx == NULL || mac == NULL) { + return ESP_ERR_INVALID_ARG; + } wifi_interface_t wifi_interface = ifx->wifi_if; return esp_wifi_get_mac(wifi_interface, mac); @@ -123,7 +126,7 @@ bool esp_wifi_is_if_ready_when_started(wifi_netif_driver_t ifx) { #ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT // WiFi rxcb to be register wifi rxcb on start for AP only, station gets it registered on connect event - return (ifx->wifi_if == WIFI_IF_AP); + return (ifx && ifx->wifi_if == WIFI_IF_AP); #else return false; #endif @@ -131,6 +134,9 @@ bool esp_wifi_is_if_ready_when_started(wifi_netif_driver_t ifx) esp_err_t esp_wifi_register_if_rxcb(wifi_netif_driver_t ifx, esp_netif_receive_t fn, void * arg) { + if (ifx == NULL || fn == NULL || arg == NULL) { + return ESP_ERR_INVALID_ARG; + } if (ifx->base.netif != arg) { ESP_LOGE(TAG, "Invalid argument: supplied netif=%p does not equal to interface netif=%p", arg, ifx->base.netif); return ESP_ERR_INVALID_ARG; diff --git a/components/esp_wifi/test_apps/wifi_connect/pytest_wifi_connect.py b/components/esp_wifi/test_apps/wifi_connect/pytest_wifi_connect.py index b53cf631f7..1e85a967eb 100644 --- a/components/esp_wifi/test_apps/wifi_connect/pytest_wifi_connect.py +++ b/components/esp_wifi/test_apps/wifi_connect/pytest_wifi_connect.py @@ -1,8 +1,7 @@ # SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Unlicense OR CC0-1.0 - import pytest -from idf_unity_tester import CaseTester +from pytest_embedded_idf.unity_tester import CaseTester @pytest.mark.esp32 diff --git a/components/esp_wifi/wifi_apps/src/nan_app.c b/components/esp_wifi/wifi_apps/src/nan_app.c index c3eb2f0673..32403b02b0 100644 --- a/components/esp_wifi/wifi_apps/src/nan_app.c +++ b/components/esp_wifi/wifi_apps/src/nan_app.c @@ -672,7 +672,7 @@ void esp_nan_app_deinit(void) } if (s_nan_data_lock) { - os_semphr_delete(s_nan_data_lock); + os_mutex_delete(s_nan_data_lock); s_nan_data_lock = NULL; } } diff --git a/components/hal/Kconfig b/components/hal/Kconfig index 8c3452ba4e..264fbb6a96 100644 --- a/components/hal/Kconfig +++ b/components/hal/Kconfig @@ -103,4 +103,13 @@ menu "Hardware Abstraction Layer (HAL) and Low Level (LL)" help Enable this option to place SPI slave hal layer functions into IRAM. + config HAL_ECDSA_GEN_SIG_CM + bool "Enable countermeasure for ECDSA signature generation" + default n + # ToDo - IDF-11051 + help + Enable this option to apply the countermeasure for ECDSA signature operation + This countermeasure masks the real ECDSA sign operation + under dummy sign operations to add randomness in the generated power signature. + endmenu diff --git a/components/hal/ecdsa_hal.c b/components/hal/ecdsa_hal.c index 6d495d5279..31c782ba85 100644 --- a/components/hal/ecdsa_hal.c +++ b/components/hal/ecdsa_hal.c @@ -9,6 +9,11 @@ #include "hal/ecdsa_hal.h" #include "hal/efuse_hal.h" +#if CONFIG_HAL_ECDSA_GEN_SIG_CM +#include "esp_fault.h" +#include "esp_random.h" +#endif + #define ECDSA_HAL_P192_COMPONENT_LEN 24 #define ECDSA_HAL_P256_COMPONENT_LEN 32 @@ -26,23 +31,9 @@ bool ecdsa_hal_get_operation_result(void) return ecdsa_ll_get_operation_result(); } -void ecdsa_hal_gen_signature(ecdsa_hal_config_t *conf, const uint8_t *hash, - uint8_t *r_out, uint8_t *s_out, uint16_t len) +static void ecdsa_hal_gen_signature_inner(const uint8_t *hash, uint8_t *r_out, + uint8_t *s_out, uint16_t len) { - if (len != ECDSA_HAL_P192_COMPONENT_LEN && len != ECDSA_HAL_P256_COMPONENT_LEN) { - HAL_ASSERT(false && "Incorrect length"); - } - - if (conf->sha_mode == ECDSA_Z_USER_PROVIDED && hash == NULL) { - HAL_ASSERT(false && "Mismatch in SHA configuration"); - } - - if (ecdsa_ll_get_state() != ECDSA_STATE_IDLE) { - HAL_ASSERT(false && "Incorrect ECDSA state"); - } - - configure_ecdsa_periph(conf); - ecdsa_ll_set_stage(ECDSA_STAGE_START_CALC); while(ecdsa_ll_get_state() != ECDSA_STATE_LOAD) { @@ -67,6 +58,63 @@ void ecdsa_hal_gen_signature(ecdsa_hal_config_t *conf, const uint8_t *hash, } } +#if CONFIG_HAL_ECDSA_GEN_SIG_CM +__attribute__((optimize("O0"))) static void ecdsa_hal_gen_signature_with_countermeasure(const uint8_t *hash, uint8_t *r_out, + uint8_t *s_out, uint16_t len) +{ + uint8_t tmp_r_out[32] = {}; + uint8_t tmp_s_out[32] = {}; + uint8_t tmp_hash[64] = {}; + + uint8_t dummy_op_count_prior = esp_random() % ECDSA_SIGN_MAX_DUMMY_OP_COUNT; + uint8_t dummy_op_count_later = ECDSA_SIGN_MAX_DUMMY_OP_COUNT - dummy_op_count_prior; + ESP_FAULT_ASSERT((dummy_op_count_prior != 0) || (dummy_op_count_later != 0)); + ESP_FAULT_ASSERT(dummy_op_count_prior + dummy_op_count_later == ECDSA_SIGN_MAX_DUMMY_OP_COUNT); + + esp_fill_random(tmp_hash, 64); + /* Dummy ecdsa signature operations prior to the actual one */ + for (int i = 0; i < dummy_op_count_prior; i++) { + ecdsa_hal_gen_signature_inner(tmp_hash + ((6 * i) % 32), (uint8_t *) tmp_r_out, (uint8_t *) tmp_s_out, len); + } + + /* Actual ecdsa signature operation */ + ecdsa_hal_gen_signature_inner(hash, r_out, s_out, len); + + /* Dummy ecdsa signature operations after the actual one */ + for (int i = 0; i < dummy_op_count_later; i++) { + ecdsa_hal_gen_signature_inner(tmp_hash + ((6 * i) % 32), (uint8_t *)tmp_r_out, (uint8_t *)tmp_s_out, len); + } + +} +#endif /* CONFIG_HAL_ECDSA_GEN_SIG_CM */ + + + +void ecdsa_hal_gen_signature(ecdsa_hal_config_t *conf, const uint8_t *hash, + uint8_t *r_out, uint8_t *s_out, uint16_t len) +{ + if (len != ECDSA_HAL_P192_COMPONENT_LEN && len != ECDSA_HAL_P256_COMPONENT_LEN) { + HAL_ASSERT(false && "Incorrect length"); + } + + if (conf->sha_mode == ECDSA_Z_USER_PROVIDED && hash == NULL) { + HAL_ASSERT(false && "Mismatch in SHA configuration"); + } + + if (ecdsa_ll_get_state() != ECDSA_STATE_IDLE) { + HAL_ASSERT(false && "Incorrect ECDSA state"); + } + + configure_ecdsa_periph(conf); + +#if CONFIG_HAL_ECDSA_GEN_SIG_CM + ecdsa_hal_gen_signature_with_countermeasure(hash, r_out, s_out, len); +#else /* CONFIG_HAL_ECDSA_GEN_SIG_CM */ + ecdsa_hal_gen_signature_inner(hash, r_out, s_out, len); +#endif /* !CONFIG_HAL_ECDSA_GEN_SIG_CM */ + +} + int ecdsa_hal_verify_signature(ecdsa_hal_config_t *conf, const uint8_t *hash, const uint8_t *r, const uint8_t *s, const uint8_t *pub_x, const uint8_t *pub_y, uint16_t len) { diff --git a/components/hal/esp32/cache_hal_esp32.c b/components/hal/esp32/cache_hal_esp32.c index fdfdfde6e6..7d96676ee7 100644 --- a/components/hal/esp32/cache_hal_esp32.c +++ b/components/hal/esp32/cache_hal_esp32.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -8,6 +8,11 @@ static uint32_t s_cache_status[2]; +void cache_hal_init(void) +{ + //for compatibility +} + void cache_hal_suspend(cache_type_t type) { s_cache_status[0] = cache_ll_l1_get_enabled_bus(0); diff --git a/components/hal/esp32/include/hal/i2s_ll.h b/components/hal/esp32/include/hal/i2s_ll.h index 5f33bf4277..552cde83c8 100644 --- a/components/hal/esp32/include/hal/i2s_ll.h +++ b/components/hal/esp32/include/hal/i2s_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -81,7 +81,7 @@ static inline void i2s_ll_dma_enable_auto_write_back(i2s_dev_t *hw, bool en) } /** - * @brief I2S DMA generate EOF event on data in FIFO poped out + * @brief I2S DMA generate EOF event on data in FIFO popped out * * @param hw Peripheral I2S hardware instance address. * @param en True to enable, False to disable @@ -314,11 +314,6 @@ static inline void i2s_ll_set_raw_mclk_div(i2s_dev_t *hw, uint32_t mclk_div, uin */ static inline void i2s_ll_tx_set_mclk(i2s_dev_t *hw, const i2s_ll_mclk_div_t *mclk_div) { - /* Workaround for inaccurate clock while switching from a relatively low sample rate to a high sample rate - * Set to particular coefficients first then update to the target coefficients, - * otherwise the clock division might be inaccurate. - * the general idea is to set a value that unlike to calculate from the regular decimal */ - i2s_ll_set_raw_mclk_div(hw, 7, 47, 3); i2s_ll_set_raw_mclk_div(hw, mclk_div->integ, mclk_div->denom, mclk_div->numer); } @@ -623,7 +618,7 @@ static inline void i2s_ll_tx_set_bits_mod(i2s_dev_t *hw, uint32_t val) } /** - * @brief Congfigure TX chan bit and audio data bit, on ESP32, sample_bit should equals to data_bit + * @brief Configure TX chan bit and audio data bit, on ESP32, sample_bit should equals to data_bit * * @param hw Peripheral I2S hardware instance address. * @param chan_bit The chan bit width @@ -636,7 +631,7 @@ static inline void i2s_ll_tx_set_sample_bit(i2s_dev_t *hw, uint8_t chan_bit, int } /** - * @brief Congfigure RX chan bit and audio data bit, on ESP32, sample_bit should equals to data_bit + * @brief Configure RX chan bit and audio data bit, on ESP32, sample_bit should equals to data_bit * * @param hw Peripheral I2S hardware instance address. * @param chan_bit The chan bit width diff --git a/components/hal/esp32c3/include/hal/clk_tree_ll.h b/components/hal/esp32c3/include/hal/clk_tree_ll.h index 24b7798f75..1d117e4df7 100644 --- a/components/hal/esp32c3/include/hal/clk_tree_ll.h +++ b/components/hal/esp32c3/include/hal/clk_tree_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -84,17 +84,18 @@ static inline __attribute__((always_inline)) void clk_ll_bbpll_disable(void) */ static inline __attribute__((always_inline)) void clk_ll_xtal32k_enable(clk_ll_xtal32k_enable_mode_t mode) { - // Configure xtal32k - clk_ll_xtal32k_config_t cfg = CLK_LL_XTAL32K_CONFIG_DEFAULT(); - REG_SET_FIELD(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_DAC_XTAL_32K, cfg.dac); - REG_SET_FIELD(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_DRES_XTAL_32K, cfg.dres); - REG_SET_FIELD(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_DGM_XTAL_32K, cfg.dgm); - REG_SET_FIELD(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_DBUF_XTAL_32K, cfg.dbuf); - // Enable xtal32k xpd status - SET_PERI_REG_MASK(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_XPD_XTAL_32K); if (mode == CLK_LL_XTAL32K_ENABLE_MODE_EXTERNAL) { - /* TODO ESP32-C3 IDF-2408:: external 32k source may need different settings */ - ; + SET_PERI_REG_MASK(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_XTAL32K_GPIO_SEL); + } else { + // Configure xtal32k + CLEAR_PERI_REG_MASK(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_XTAL32K_GPIO_SEL); + clk_ll_xtal32k_config_t cfg = CLK_LL_XTAL32K_CONFIG_DEFAULT(); + REG_SET_FIELD(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_DAC_XTAL_32K, cfg.dac); + REG_SET_FIELD(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_DRES_XTAL_32K, cfg.dres); + REG_SET_FIELD(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_DGM_XTAL_32K, cfg.dgm); + REG_SET_FIELD(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_DBUF_XTAL_32K, cfg.dbuf); + // Enable xtal32k xpd status + SET_PERI_REG_MASK(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_XPD_XTAL_32K); } } diff --git a/components/hal/esp32c3/include/hal/i2s_ll.h b/components/hal/esp32c3/include/hal/i2s_ll.h index e007248f49..d056b140ef 100644 --- a/components/hal/esp32c3/include/hal/i2s_ll.h +++ b/components/hal/esp32c3/include/hal/i2s_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -31,6 +31,7 @@ extern "C" { #define I2S_LL_MCLK_DIVIDER_BIT_WIDTH (9) #define I2S_LL_MCLK_DIVIDER_MAX ((1 << I2S_LL_MCLK_DIVIDER_BIT_WIDTH) - 1) +#define I2S_LL_SLOT_FRAME_BIT_MAX 128 // Up-to 128 bits in one frame, determined by MAX(half_sample_bits) * 2 #define I2S_LL_PLL_F160M_CLK_FREQ (160 * 1000000) // PLL_F160M_CLK: 160MHz #define I2S_LL_DEFAULT_PLL_CLK_FREQ I2S_LL_PLL_F160M_CLK_FREQ // The default PLL clock frequency while using I2S_CLK_SRC_DEFAULT @@ -258,15 +259,21 @@ static inline void i2s_ll_tx_set_bck_div_num(i2s_dev_t *hw, uint32_t val) */ static inline void i2s_ll_tx_set_raw_clk_div(i2s_dev_t *hw, uint32_t div_int, uint32_t x, uint32_t y, uint32_t z, uint32_t yn1) { - /* Set the integer part of mclk division */ + /* Workaround for the double division issue. + * The division coefficients must be set in particular sequence. + * And it has to switch to a small division first before setting the target division. */ + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->tx_clkm_conf, tx_clkm_div_num, 2); + hw->tx_clkm_div_conf.tx_clkm_div_yn1 = 0; + hw->tx_clkm_div_conf.tx_clkm_div_y = 1; + hw->tx_clkm_div_conf.tx_clkm_div_z = 0; + hw->tx_clkm_div_conf.tx_clkm_div_x = 0; + + /* Set the target mclk division coefficients */ + hw->tx_clkm_div_conf.tx_clkm_div_yn1 = yn1; + hw->tx_clkm_div_conf.tx_clkm_div_z = z; + hw->tx_clkm_div_conf.tx_clkm_div_y = y; + hw->tx_clkm_div_conf.tx_clkm_div_x = x; HAL_FORCE_MODIFY_U32_REG_FIELD(hw->tx_clkm_conf, tx_clkm_div_num, div_int); - /* Set the decimal part of the mclk division */ - typeof(hw->tx_clkm_div_conf) div = {}; - div.tx_clkm_div_x = x; - div.tx_clkm_div_y = y; - div.tx_clkm_div_z = z; - div.tx_clkm_div_yn1 = yn1; - hw->tx_clkm_div_conf.val = div.val; } /** @@ -281,15 +288,21 @@ static inline void i2s_ll_tx_set_raw_clk_div(i2s_dev_t *hw, uint32_t div_int, ui */ static inline void i2s_ll_rx_set_raw_clk_div(i2s_dev_t *hw, uint32_t div_int, uint32_t x, uint32_t y, uint32_t z, uint32_t yn1) { - /* Set the integer part of mclk division */ + /* Workaround for the double division issue. + * The division coefficients must be set in particular sequence. + * And it has to switch to a small division first before setting the target division. */ + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->rx_clkm_conf, rx_clkm_div_num, 2); + hw->rx_clkm_div_conf.rx_clkm_div_yn1 = 0; + hw->rx_clkm_div_conf.rx_clkm_div_y = 1; + hw->rx_clkm_div_conf.rx_clkm_div_z = 0; + hw->rx_clkm_div_conf.rx_clkm_div_x = 0; + + /* Set the target mclk division coefficients */ + hw->rx_clkm_div_conf.rx_clkm_div_yn1 = yn1; + hw->rx_clkm_div_conf.rx_clkm_div_z = z; + hw->rx_clkm_div_conf.rx_clkm_div_y = y; + hw->rx_clkm_div_conf.rx_clkm_div_x = x; HAL_FORCE_MODIFY_U32_REG_FIELD(hw->rx_clkm_conf, rx_clkm_div_num, div_int); - /* Set the decimal part of the mclk division */ - typeof(hw->rx_clkm_div_conf) div = {}; - div.rx_clkm_div_x = x; - div.rx_clkm_div_y = y; - div.rx_clkm_div_z = z; - div.rx_clkm_div_yn1 = yn1; - hw->rx_clkm_div_conf.val = div.val; } /** @@ -300,12 +313,6 @@ static inline void i2s_ll_rx_set_raw_clk_div(i2s_dev_t *hw, uint32_t div_int, ui */ static inline void i2s_ll_tx_set_mclk(i2s_dev_t *hw, const i2s_ll_mclk_div_t *mclk_div) { - /* Workaround for inaccurate clock while switching from a relatively low sample rate to a high sample rate - * Set to particular coefficients first then update to the target coefficients, - * otherwise the clock division might be inaccurate. - * the general idea is to set a value that impossible to calculate from the regular decimal */ - i2s_ll_tx_set_raw_clk_div(hw, 7, 317, 7, 3, 0); - uint32_t div_x = 0; uint32_t div_y = 0; uint32_t div_z = 0; @@ -340,12 +347,6 @@ static inline void i2s_ll_rx_set_bck_div_num(i2s_dev_t *hw, uint32_t val) */ static inline void i2s_ll_rx_set_mclk(i2s_dev_t *hw, const i2s_ll_mclk_div_t *mclk_div) { - /* Workaround for inaccurate clock while switching from a relatively low sample rate to a high sample rate - * Set to particular coefficients first then update to the target coefficients, - * otherwise the clock division might be inaccurate. - * the general idea is to set a value that impossible to calculate from the regular decimal */ - i2s_ll_rx_set_raw_clk_div(hw, 7, 317, 7, 3, 0); - uint32_t div_x = 0; uint32_t div_y = 0; uint32_t div_z = 0; @@ -440,7 +441,7 @@ static inline void i2s_ll_rx_set_eof_num(i2s_dev_t *hw, int eof_num) } /** - * @brief Congfigure TX chan bit and audio data bit + * @brief Configure TX chan bit and audio data bit * * @param hw Peripheral I2S hardware instance address. * @param chan_bit The chan bit width @@ -453,7 +454,7 @@ static inline void i2s_ll_tx_set_sample_bit(i2s_dev_t *hw, uint8_t chan_bit, int } /** - * @brief Congfigure RX chan bit and audio data bit + * @brief Configure RX chan bit and audio data bit * * @param hw Peripheral I2S hardware instance address. * @param chan_bit The chan bit width @@ -853,11 +854,11 @@ static inline void i2s_ll_tx_set_pdm_fpfs(i2s_dev_t *hw, uint32_t fp, uint32_t f } /** - * @brief Get I2S TX PDM fp configuration paramater + * @brief Get I2S TX PDM fp configuration parameter * * @param hw Peripheral I2S hardware instance address. * @return - * - fp configuration paramater + * - fp configuration parameter */ static inline uint32_t i2s_ll_tx_get_pdm_fp(i2s_dev_t *hw) { @@ -865,11 +866,11 @@ static inline uint32_t i2s_ll_tx_get_pdm_fp(i2s_dev_t *hw) } /** - * @brief Get I2S TX PDM fs configuration paramater + * @brief Get I2S TX PDM fs configuration parameter * * @param hw Peripheral I2S hardware instance address. * @return - * - fs configuration paramater + * - fs configuration parameter */ static inline uint32_t i2s_ll_tx_get_pdm_fs(i2s_dev_t *hw) { @@ -895,7 +896,7 @@ static inline void i2s_ll_rx_enable_pdm(i2s_dev_t *hw, bool pdm_enable) * @brief Configura TX a/u-law decompress or compress * * @param hw Peripheral I2S hardware instance address. - * @param pcm_cfg PCM configuration paramater + * @param pcm_cfg PCM configuration parameter */ static inline void i2s_ll_tx_set_pcm_type(i2s_dev_t *hw, i2s_pcm_compress_t pcm_cfg) { @@ -907,7 +908,7 @@ static inline void i2s_ll_tx_set_pcm_type(i2s_dev_t *hw, i2s_pcm_compress_t pcm_ * @brief Configure RX a/u-law decompress or compress * * @param hw Peripheral I2S hardware instance address. - * @param pcm_cfg PCM configuration paramater + * @param pcm_cfg PCM configuration parameter */ static inline void i2s_ll_rx_set_pcm_type(i2s_dev_t *hw, i2s_pcm_compress_t pcm_cfg) { @@ -1079,7 +1080,7 @@ static inline void i2s_ll_tx_pdm_dma_take_mode(i2s_dev_t *hw, bool is_mono, bool * @param is_mono The DMA data only has one slot (mono) or contains two slots (stereo) * @param is_copy Whether the un-selected slot copies the data from the selected one * If not, the un-selected slot will transmit the data from 'conf_single_data' - * @param mask The slot mask to selet the slot + * @param mask The slot mask to select the slot */ static inline void i2s_ll_tx_pdm_slot_mode(i2s_dev_t *hw, bool is_mono, bool is_copy, i2s_pdm_slot_mask_t mask) { diff --git a/components/hal/esp32c6/include/hal/gpio_ll.h b/components/hal/esp32c6/include/hal/gpio_ll.h index 0ff9b15722..5eab4a953b 100644 --- a/components/hal/esp32c6/include/hal/gpio_ll.h +++ b/components/hal/esp32c6/include/hal/gpio_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -91,6 +91,15 @@ static inline void gpio_ll_pullup_en(gpio_dev_t *hw, uint32_t gpio_num) __attribute__((always_inline)) static inline void gpio_ll_pullup_dis(gpio_dev_t *hw, uint32_t gpio_num) { + // The pull-up value of the USB pins are controlled by the pins’ pull-up value together with USB pull-up value + // USB DP pin is default to PU enabled + // Note that esp32c6 has supported USB_EXCHG_PINS feature. If this efuse is burnt, the gpio pin + // which should be checked is USB_INT_PHY0_DM_GPIO_NUM instead. + // TODO: read the specific efuse with efuse_ll.h + if (gpio_num == USB_DP_GPIO_NUM) { + SET_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_PAD_PULL_OVERRIDE); + CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_DP_PULLUP); + } REG_CLR_BIT(IO_MUX_GPIO0_REG + (gpio_num * 4), FUN_PU); } @@ -114,15 +123,6 @@ static inline void gpio_ll_pulldown_en(gpio_dev_t *hw, uint32_t gpio_num) __attribute__((always_inline)) static inline void gpio_ll_pulldown_dis(gpio_dev_t *hw, uint32_t gpio_num) { - // The pull-up value of the USB pins are controlled by the pins’ pull-up value together with USB pull-up value - // USB DP pin is default to PU enabled - // Note that esp32c6 has supported USB_EXCHG_PINS feature. If this efuse is burnt, the gpio pin - // which should be checked is USB_DM_GPIO_NUM instead. - // TODO: read the specific efuse with efuse_ll.h - if (gpio_num == USB_DP_GPIO_NUM) { - SET_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_PAD_PULL_OVERRIDE); - CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_DP_PULLUP); - } REG_CLR_BIT(IO_MUX_GPIO0_REG + (gpio_num * 4), FUN_PD); } diff --git a/components/hal/esp32c6/include/hal/i2s_ll.h b/components/hal/esp32c6/include/hal/i2s_ll.h index c36e5d7ea6..9bd862c163 100644 --- a/components/hal/esp32c6/include/hal/i2s_ll.h +++ b/components/hal/esp32c6/include/hal/i2s_ll.h @@ -32,6 +32,7 @@ extern "C" { #define I2S_LL_MCLK_DIVIDER_BIT_WIDTH (9) #define I2S_LL_MCLK_DIVIDER_MAX ((1 << I2S_LL_MCLK_DIVIDER_BIT_WIDTH) - 1) +#define I2S_LL_SLOT_FRAME_BIT_MAX 128 // Up-to 128 bits in one frame, determined by MAX(half_sample_bits) * 2 #define I2S_LL_PLL_F160M_CLK_FREQ (160 * 1000000) // PLL_F160M_CLK: 160MHz #define I2S_LL_DEFAULT_PLL_CLK_FREQ I2S_LL_PLL_F160M_CLK_FREQ // The default PLL clock frequency while using I2S_CLK_SRC_DEFAULT @@ -270,13 +271,21 @@ static inline void i2s_ll_tx_set_bck_div_num(i2s_dev_t *hw, uint32_t val) static inline void i2s_ll_tx_set_raw_clk_div(i2s_dev_t *hw, uint32_t div_int, uint32_t x, uint32_t y, uint32_t z, uint32_t yn1) { (void)hw; + /* Workaround for the double division issue. + * The division coefficients must be set in particular sequence. + * And it has to switch to a small division first before setting the target division. */ + HAL_FORCE_MODIFY_U32_REG_FIELD(PCR.i2s_tx_clkm_conf, i2s_tx_clkm_div_num, 2); + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_yn1 = 0; + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_y = 1; + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_z = 0; + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_x = 0; + + /* Set the target mclk division coefficients */ + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_yn1 = yn1; + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_z = z; + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_y = y; + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_x = x; HAL_FORCE_MODIFY_U32_REG_FIELD(PCR.i2s_tx_clkm_conf, i2s_tx_clkm_div_num, div_int); - typeof(PCR.i2s_tx_clkm_div_conf) div = {}; - div.i2s_tx_clkm_div_x = x; - div.i2s_tx_clkm_div_y = y; - div.i2s_tx_clkm_div_z = z; - div.i2s_tx_clkm_div_yn1 = yn1; - PCR.i2s_tx_clkm_div_conf.val = div.val; } /** @@ -292,13 +301,21 @@ static inline void i2s_ll_tx_set_raw_clk_div(i2s_dev_t *hw, uint32_t div_int, ui static inline void i2s_ll_rx_set_raw_clk_div(i2s_dev_t *hw, uint32_t div_int, uint32_t x, uint32_t y, uint32_t z, uint32_t yn1) { (void)hw; + /* Workaround for the double division issue. + * The division coefficients must be set in particular sequence. + * And it has to switch to a small division first before setting the target division. */ + HAL_FORCE_MODIFY_U32_REG_FIELD(PCR.i2s_rx_clkm_conf, i2s_rx_clkm_div_num, 2); + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_yn1 = 0; + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_y = 1; + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_z = 0; + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_x = 0; + + /* Set the target mclk division coefficients */ + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_yn1 = yn1; + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_z = z; + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_y = y; + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_x = x; HAL_FORCE_MODIFY_U32_REG_FIELD(PCR.i2s_rx_clkm_conf, i2s_rx_clkm_div_num, div_int); - typeof(PCR.i2s_rx_clkm_div_conf) div = {}; - div.i2s_rx_clkm_div_x = x; - div.i2s_rx_clkm_div_y = y; - div.i2s_rx_clkm_div_z = z; - div.i2s_rx_clkm_div_yn1 = yn1; - PCR.i2s_rx_clkm_div_conf.val = div.val; } /** @@ -309,12 +326,6 @@ static inline void i2s_ll_rx_set_raw_clk_div(i2s_dev_t *hw, uint32_t div_int, ui */ static inline void i2s_ll_tx_set_mclk(i2s_dev_t *hw, const i2s_ll_mclk_div_t *mclk_div) { - /* Workaround for inaccurate clock while switching from a relatively low sample rate to a high sample rate - * Set to particular coefficients first then update to the target coefficients, - * otherwise the clock division might be inaccurate. - * the general idea is to set a value that impossible to calculate from the regular decimal */ - i2s_ll_tx_set_raw_clk_div(hw, 7, 317, 7, 3, 0); - uint32_t div_x = 0; uint32_t div_y = 0; uint32_t div_z = 0; @@ -349,12 +360,6 @@ static inline void i2s_ll_rx_set_bck_div_num(i2s_dev_t *hw, uint32_t val) */ static inline void i2s_ll_rx_set_mclk(i2s_dev_t *hw, const i2s_ll_mclk_div_t *mclk_div) { - /* Workaround for inaccurate clock while switching from a relatively low sample rate to a high sample rate - * Set to particular coefficients first then update to the target coefficients, - * otherwise the clock division might be inaccurate. - * the general idea is to set a value that impossible to calculate from the regular decimal */ - i2s_ll_rx_set_raw_clk_div(hw, 7, 317, 7, 3, 0); - uint32_t div_x = 0; uint32_t div_y = 0; uint32_t div_z = 0; diff --git a/components/hal/esp32c6/include/hal/uart_ll.h b/components/hal/esp32c6/include/hal/uart_ll.h index a4ebddf6e1..bfa2559b72 100644 --- a/components/hal/esp32c6/include/hal/uart_ll.h +++ b/components/hal/esp32c6/include/hal/uart_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -366,7 +366,7 @@ FORCE_INLINE_ATTR void uart_ll_txfifo_rst(uart_dev_t *hw) */ FORCE_INLINE_ATTR uint32_t uart_ll_get_rxfifo_len(uart_dev_t *hw) { - return hw->status.rxfifo_cnt; + return HAL_FORCE_READ_U32_REG_FIELD(hw->status, rxfifo_cnt); } /** @@ -378,7 +378,7 @@ FORCE_INLINE_ATTR uint32_t uart_ll_get_rxfifo_len(uart_dev_t *hw) */ FORCE_INLINE_ATTR uint32_t uart_ll_get_txfifo_len(uart_dev_t *hw) { - return UART_LL_FIFO_DEF_LEN - hw->status.txfifo_cnt; + return UART_LL_FIFO_DEF_LEN - HAL_FORCE_READ_U32_REG_FIELD(hw->status, txfifo_cnt); } /** @@ -453,7 +453,7 @@ FORCE_INLINE_ATTR void uart_ll_get_parity(uart_dev_t *hw, uart_parity_t *parity_ */ FORCE_INLINE_ATTR void uart_ll_set_rxfifo_full_thr(uart_dev_t *hw, uint16_t full_thrhd) { - hw->conf1.rxfifo_full_thrhd = full_thrhd; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->conf1, rxfifo_full_thrhd, full_thrhd); } /** @@ -467,7 +467,7 @@ FORCE_INLINE_ATTR void uart_ll_set_rxfifo_full_thr(uart_dev_t *hw, uint16_t full */ FORCE_INLINE_ATTR void uart_ll_set_txfifo_empty_thr(uart_dev_t *hw, uint16_t empty_thrhd) { - hw->conf1.txfifo_empty_thrhd = empty_thrhd; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->conf1, txfifo_empty_thrhd, empty_thrhd); } /** @@ -531,7 +531,7 @@ FORCE_INLINE_ATTR void uart_ll_set_hw_flow_ctrl(uart_dev_t *hw, uart_hw_flowcont { //only when UART_HW_FLOWCTRL_RTS is set , will the rx_thresh value be set. if (flow_ctrl & UART_HW_FLOWCTRL_RTS) { - hw->hwfc_conf_sync.rx_flow_thrhd = rx_thrs; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->hwfc_conf_sync, rx_flow_thrhd, rx_thrs); hw->hwfc_conf_sync.rx_flow_en = 1; } else { hw->hwfc_conf_sync.rx_flow_en = 0; @@ -577,8 +577,8 @@ FORCE_INLINE_ATTR void uart_ll_set_sw_flow_ctrl(uart_dev_t *hw, uart_sw_flowctrl if (sw_flow_ctrl_en) { hw->swfc_conf0_sync.xonoff_del = 1; hw->swfc_conf0_sync.sw_flow_con_en = 1; - hw->swfc_conf1.xon_threshold = flow_ctrl->xon_thrd; - hw->swfc_conf1.xoff_threshold = flow_ctrl->xoff_thrd; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->swfc_conf1, xon_threshold, flow_ctrl->xon_thrd); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->swfc_conf1, xoff_threshold, flow_ctrl->xoff_thrd); HAL_FORCE_MODIFY_U32_REG_FIELD(hw->swfc_conf0_sync, xon_char, flow_ctrl->xon_char); HAL_FORCE_MODIFY_U32_REG_FIELD(hw->swfc_conf0_sync, xoff_char, flow_ctrl->xoff_char); } else { @@ -855,7 +855,7 @@ FORCE_INLINE_ATTR void uart_ll_get_data_bit_num(uart_dev_t *hw, uart_word_length */ FORCE_INLINE_ATTR bool uart_ll_is_tx_idle(uart_dev_t *hw) { - return ((hw->status.txfifo_cnt == 0) && (hw->fsm_status.st_utx_out == 0)); + return ((HAL_FORCE_READ_U32_REG_FIELD(hw->status, txfifo_cnt) == 0) && (hw->fsm_status.st_utx_out == 0)); } /** diff --git a/components/hal/esp32h2/include/hal/brownout_ll.h b/components/hal/esp32h2/include/hal/brownout_ll.h index f0b3d63263..c6048ccaa3 100644 --- a/components/hal/esp32h2/include/hal/brownout_ll.h +++ b/components/hal/esp32h2/include/hal/brownout_ll.h @@ -63,7 +63,9 @@ static inline void brownout_ll_reset_config(bool reset_ena, uint32_t reset_wait, */ static inline void brownout_ll_set_threshold(uint8_t threshold) { - REGI2C_WRITE_MASK(I2C_BOD, I2C_BOD_THRESHOLD, threshold); + REGI2C_WRITE_MASK(I2C_BOD, I2C_BOD_THRESHOLD_L, threshold); + REGI2C_WRITE_MASK(I2C_BOD, I2C_BOD_THRESHOLD_H, threshold); + } /** diff --git a/components/hal/esp32h2/include/hal/gpio_ll.h b/components/hal/esp32h2/include/hal/gpio_ll.h index 70d5e1a477..f1eebcbeb9 100644 --- a/components/hal/esp32h2/include/hal/gpio_ll.h +++ b/components/hal/esp32h2/include/hal/gpio_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -90,6 +90,15 @@ static inline void gpio_ll_pullup_en(gpio_dev_t *hw, gpio_num_t gpio_num) __attribute__((always_inline)) static inline void gpio_ll_pullup_dis(gpio_dev_t *hw, gpio_num_t gpio_num) { + // The pull-up value of the USB pins are controlled by the pins’ pull-up value together with USB pull-up value + // USB DP pin is default to PU enabled + // Note that esp32h2 has supported USB_EXCHG_PINS feature. If this efuse is burnt, the gpio pin + // which should be checked is USB_INT_PHY0_DM_GPIO_NUM instead. + // TODO: read the specific efuse with efuse_ll.h + if (gpio_num == USB_DP_GPIO_NUM) { + SET_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_PAD_PULL_OVERRIDE); + CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_DP_PULLUP); + } REG_CLR_BIT(IO_MUX_GPIO0_REG + (gpio_num * 4), FUN_PU); } @@ -113,15 +122,6 @@ static inline void gpio_ll_pulldown_en(gpio_dev_t *hw, gpio_num_t gpio_num) __attribute__((always_inline)) static inline void gpio_ll_pulldown_dis(gpio_dev_t *hw, gpio_num_t gpio_num) { - // The pull-up value of the USB pins are controlled by the pins’ pull-up value together with USB pull-up value - // USB DP pin is default to PU enabled - // Note that esp32h2 has supported USB_EXCHG_PINS feature. If this efuse is burnt, the gpio pin - // which should be checked is USB_DM_GPIO_NUM instead. - // TODO: read the specific efuse with efuse_ll.h - if (gpio_num == USB_DP_GPIO_NUM) { - SET_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_PAD_PULL_OVERRIDE); - CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_DP_PULLUP); - } REG_CLR_BIT(IO_MUX_GPIO0_REG + (gpio_num * 4), FUN_PD); } diff --git a/components/hal/esp32h2/include/hal/i2s_ll.h b/components/hal/esp32h2/include/hal/i2s_ll.h index 2d7b4fce29..2d3c97c152 100644 --- a/components/hal/esp32h2/include/hal/i2s_ll.h +++ b/components/hal/esp32h2/include/hal/i2s_ll.h @@ -32,6 +32,7 @@ extern "C" { #define I2S_LL_MCLK_DIVIDER_BIT_WIDTH (9) #define I2S_LL_MCLK_DIVIDER_MAX ((1 << I2S_LL_MCLK_DIVIDER_BIT_WIDTH) - 1) +#define I2S_LL_SLOT_FRAME_BIT_MAX 512 // Up-to 512 bits in one frame, determined by MAX(half_sample_bits) * 2 #define I2S_LL_PLL_F96M_CLK_FREQ (96 * 1000000) // PLL_F96M_CLK: 96MHz #define I2S_LL_PLL_F64M_CLK_FREQ (64 * 1000000) // PLL_F64M_CLK: 64MHz @@ -277,13 +278,21 @@ static inline void i2s_ll_tx_set_bck_div_num(i2s_dev_t *hw, uint32_t val) static inline void i2s_ll_tx_set_raw_clk_div(i2s_dev_t *hw, uint32_t div_int, uint32_t x, uint32_t y, uint32_t z, uint32_t yn1) { (void)hw; + /* Workaround for the double division issue. + * The division coefficients must be set in particular sequence. + * And it has to switch to a small division first before setting the target division. */ + HAL_FORCE_MODIFY_U32_REG_FIELD(PCR.i2s_tx_clkm_conf, i2s_tx_clkm_div_num, 2); + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_yn1 = 0; + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_y = 1; + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_z = 0; + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_x = 0; + + /* Set the target mclk division coefficients */ + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_yn1 = yn1; + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_z = z; + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_y = y; + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_x = x; HAL_FORCE_MODIFY_U32_REG_FIELD(PCR.i2s_tx_clkm_conf, i2s_tx_clkm_div_num, div_int); - typeof(PCR.i2s_tx_clkm_div_conf) div = {}; - div.i2s_tx_clkm_div_x = x; - div.i2s_tx_clkm_div_y = y; - div.i2s_tx_clkm_div_z = z; - div.i2s_tx_clkm_div_yn1 = yn1; - PCR.i2s_tx_clkm_div_conf.val = div.val; } /** @@ -299,13 +308,21 @@ static inline void i2s_ll_tx_set_raw_clk_div(i2s_dev_t *hw, uint32_t div_int, ui static inline void i2s_ll_rx_set_raw_clk_div(i2s_dev_t *hw, uint32_t div_int, uint32_t x, uint32_t y, uint32_t z, uint32_t yn1) { (void)hw; + /* Workaround for the double division issue. + * The division coefficients must be set in particular sequence. + * And it has to switch to a small division first before setting the target division. */ + HAL_FORCE_MODIFY_U32_REG_FIELD(PCR.i2s_rx_clkm_conf, i2s_rx_clkm_div_num, 2); + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_yn1 = 0; + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_y = 1; + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_z = 0; + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_x = 0; + + /* Set the target mclk division coefficients */ + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_yn1 = yn1; + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_z = z; + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_y = y; + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_x = x; HAL_FORCE_MODIFY_U32_REG_FIELD(PCR.i2s_rx_clkm_conf, i2s_rx_clkm_div_num, div_int); - typeof(PCR.i2s_rx_clkm_div_conf) div = {}; - div.i2s_rx_clkm_div_x = x; - div.i2s_rx_clkm_div_y = y; - div.i2s_rx_clkm_div_z = z; - div.i2s_rx_clkm_div_yn1 = yn1; - PCR.i2s_rx_clkm_div_conf.val = div.val; } /** @@ -316,12 +333,6 @@ static inline void i2s_ll_rx_set_raw_clk_div(i2s_dev_t *hw, uint32_t div_int, ui */ static inline void i2s_ll_tx_set_mclk(i2s_dev_t *hw, const i2s_ll_mclk_div_t *mclk_div) { - /* Workaround for inaccurate clock while switching from a relatively low sample rate to a high sample rate - * Set to particular coefficients first then update to the target coefficients, - * otherwise the clock division might be inaccurate. - * the general idea is to set a value that impossible to calculate from the regular decimal */ - i2s_ll_tx_set_raw_clk_div(hw, 8, 1, 1, 73, 1); - uint32_t div_x = 0; uint32_t div_y = 0; uint32_t div_z = 0; @@ -356,12 +367,6 @@ static inline void i2s_ll_rx_set_bck_div_num(i2s_dev_t *hw, uint32_t val) */ static inline void i2s_ll_rx_set_mclk(i2s_dev_t *hw, const i2s_ll_mclk_div_t *mclk_div) { - /* Workaround for inaccurate clock while switching from a relatively low sample rate to a high sample rate - * Set to particular coefficients first then update to the target coefficients, - * otherwise the clock division might be inaccurate. - * the general idea is to set a value that impossible to calculate from the regular decimal */ - i2s_ll_rx_set_raw_clk_div(hw, 8, 1, 1, 73, 1); - uint32_t div_x = 0; uint32_t div_y = 0; uint32_t div_z = 0; diff --git a/components/hal/esp32h2/include/hal/uart_ll.h b/components/hal/esp32h2/include/hal/uart_ll.h index 504fd4a47a..7de6f960dc 100644 --- a/components/hal/esp32h2/include/hal/uart_ll.h +++ b/components/hal/esp32h2/include/hal/uart_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -387,7 +387,7 @@ FORCE_INLINE_ATTR void uart_ll_txfifo_rst(uart_dev_t *hw) */ FORCE_INLINE_ATTR uint32_t uart_ll_get_rxfifo_len(uart_dev_t *hw) { - return hw->status.rxfifo_cnt; + return HAL_FORCE_READ_U32_REG_FIELD(hw->status, rxfifo_cnt); } /** @@ -399,7 +399,7 @@ FORCE_INLINE_ATTR uint32_t uart_ll_get_rxfifo_len(uart_dev_t *hw) */ FORCE_INLINE_ATTR uint32_t uart_ll_get_txfifo_len(uart_dev_t *hw) { - return UART_LL_FIFO_DEF_LEN - hw->status.txfifo_cnt; + return UART_LL_FIFO_DEF_LEN - HAL_FORCE_READ_U32_REG_FIELD(hw->status, txfifo_cnt); } /** @@ -474,7 +474,7 @@ FORCE_INLINE_ATTR void uart_ll_get_parity(uart_dev_t *hw, uart_parity_t *parity_ */ FORCE_INLINE_ATTR void uart_ll_set_rxfifo_full_thr(uart_dev_t *hw, uint16_t full_thrhd) { - hw->conf1.rxfifo_full_thrhd = full_thrhd; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->conf1, rxfifo_full_thrhd, full_thrhd); } /** @@ -488,7 +488,7 @@ FORCE_INLINE_ATTR void uart_ll_set_rxfifo_full_thr(uart_dev_t *hw, uint16_t full */ FORCE_INLINE_ATTR void uart_ll_set_txfifo_empty_thr(uart_dev_t *hw, uint16_t empty_thrhd) { - hw->conf1.txfifo_empty_thrhd = empty_thrhd; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->conf1, txfifo_empty_thrhd, empty_thrhd); } /** @@ -552,7 +552,7 @@ FORCE_INLINE_ATTR void uart_ll_set_hw_flow_ctrl(uart_dev_t *hw, uart_hw_flowcont { //only when UART_HW_FLOWCTRL_RTS is set , will the rx_thresh value be set. if (flow_ctrl & UART_HW_FLOWCTRL_RTS) { - hw->hwfc_conf_sync.rx_flow_thrhd = rx_thrs; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->hwfc_conf_sync, rx_flow_thrhd, rx_thrs); hw->hwfc_conf_sync.rx_flow_en = 1; } else { hw->hwfc_conf_sync.rx_flow_en = 0; @@ -598,8 +598,8 @@ FORCE_INLINE_ATTR void uart_ll_set_sw_flow_ctrl(uart_dev_t *hw, uart_sw_flowctrl if (sw_flow_ctrl_en) { hw->swfc_conf0_sync.xonoff_del = 1; hw->swfc_conf0_sync.sw_flow_con_en = 1; - hw->swfc_conf1.xon_threshold = flow_ctrl->xon_thrd; - hw->swfc_conf1.xoff_threshold = flow_ctrl->xoff_thrd; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->swfc_conf1, xon_threshold, flow_ctrl->xon_thrd); + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->swfc_conf1, xoff_threshold, flow_ctrl->xoff_thrd); HAL_FORCE_MODIFY_U32_REG_FIELD(hw->swfc_conf0_sync, xon_char, flow_ctrl->xon_char); HAL_FORCE_MODIFY_U32_REG_FIELD(hw->swfc_conf0_sync, xoff_char, flow_ctrl->xoff_char); } else { @@ -864,7 +864,7 @@ FORCE_INLINE_ATTR void uart_ll_get_data_bit_num(uart_dev_t *hw, uart_word_length */ FORCE_INLINE_ATTR bool uart_ll_is_tx_idle(uart_dev_t *hw) { - return ((hw->status.txfifo_cnt == 0) && (hw->fsm_status.st_utx_out == 0)); + return ((HAL_FORCE_READ_U32_REG_FIELD(hw->status, txfifo_cnt) == 0) && (hw->fsm_status.st_utx_out == 0)); } /** diff --git a/components/hal/esp32s2/include/hal/i2s_ll.h b/components/hal/esp32s2/include/hal/i2s_ll.h index 1329c9e5c6..eb12347cb0 100644 --- a/components/hal/esp32s2/include/hal/i2s_ll.h +++ b/components/hal/esp32s2/include/hal/i2s_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -78,7 +78,7 @@ static inline void i2s_ll_dma_enable_auto_write_back(i2s_dev_t *hw, bool en) } /** - * @brief I2S DMA generate EOF event on data in FIFO poped out + * @brief I2S DMA generate EOF event on data in FIFO popped out * * @param hw Peripheral I2S hardware instance address. * @param en True to enable, False to disable @@ -305,11 +305,6 @@ static inline void i2s_ll_set_raw_mclk_div(i2s_dev_t *hw, uint32_t mclk_div, uin */ static inline void i2s_ll_tx_set_mclk(i2s_dev_t *hw, const i2s_ll_mclk_div_t *mclk_div) { - /* Workaround for inaccurate clock while switching from a relatively low sample rate to a high sample rate - * Set to particular coefficients first then update to the target coefficients, - * otherwise the clock division might be inaccurate. - * the general idea is to set a value that unlike to calculate from the regular decimal */ - i2s_ll_set_raw_mclk_div(hw, 7, 47, 3); i2s_ll_set_raw_mclk_div(hw, mclk_div->integ, mclk_div->denom, mclk_div->numer); } @@ -646,7 +641,7 @@ static inline void i2s_ll_rx_set_eof_num(i2s_dev_t *hw, uint32_t eof_num) } /** - * @brief Congfigure TX chan bit and audio data bit, on ESP32-S2, sample_bit should equals to data_bit + * @brief Configure TX chan bit and audio data bit, on ESP32-S2, sample_bit should equals to data_bit * * @param hw Peripheral I2S hardware instance address. * @param chan_bit The chan bit width @@ -659,7 +654,7 @@ static inline void i2s_ll_tx_set_sample_bit(i2s_dev_t *hw, uint8_t chan_bit, int } /** - * @brief Congfigure RX chan bit and audio data bit, on ESP32-S2, sample_bit should equals to data_bit + * @brief Configure RX chan bit and audio data bit, on ESP32-S2, sample_bit should equals to data_bit * * @param hw Peripheral I2S hardware instance address. * @param chan_bit The chan bit width diff --git a/components/hal/esp32s3/include/hal/clk_tree_ll.h b/components/hal/esp32s3/include/hal/clk_tree_ll.h index 4de0d26099..f2170a70f5 100644 --- a/components/hal/esp32s3/include/hal/clk_tree_ll.h +++ b/components/hal/esp32s3/include/hal/clk_tree_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -86,17 +86,18 @@ static inline __attribute__((always_inline)) void clk_ll_bbpll_disable(void) */ static inline __attribute__((always_inline)) void clk_ll_xtal32k_enable(clk_ll_xtal32k_enable_mode_t mode) { - // Configure xtal32k - clk_ll_xtal32k_config_t cfg = CLK_LL_XTAL32K_CONFIG_DEFAULT(); - REG_SET_FIELD(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_DAC_XTAL_32K, cfg.dac); - REG_SET_FIELD(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_DRES_XTAL_32K, cfg.dres); - REG_SET_FIELD(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_DGM_XTAL_32K, cfg.dgm); - REG_SET_FIELD(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_DBUF_XTAL_32K, cfg.dbuf); - // Enable xtal32k xpd status - SET_PERI_REG_MASK(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_XPD_XTAL_32K); if (mode == CLK_LL_XTAL32K_ENABLE_MODE_EXTERNAL) { - /* TODO: external 32k oscillator may need different settings */ - ; + SET_PERI_REG_MASK(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_XTAL32K_GPIO_SEL); + } else { + // Configure xtal32k + CLEAR_PERI_REG_MASK(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_XTAL32K_GPIO_SEL); + clk_ll_xtal32k_config_t cfg = CLK_LL_XTAL32K_CONFIG_DEFAULT(); + REG_SET_FIELD(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_DAC_XTAL_32K, cfg.dac); + REG_SET_FIELD(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_DRES_XTAL_32K, cfg.dres); + REG_SET_FIELD(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_DGM_XTAL_32K, cfg.dgm); + REG_SET_FIELD(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_DBUF_XTAL_32K, cfg.dbuf); + // Enable xtal32k xpd status + SET_PERI_REG_MASK(RTC_CNTL_EXT_XTL_CONF_REG, RTC_CNTL_XPD_XTAL_32K); } } diff --git a/components/hal/esp32s3/include/hal/i2s_ll.h b/components/hal/esp32s3/include/hal/i2s_ll.h index 02de004fbe..f5fab4c40b 100644 --- a/components/hal/esp32s3/include/hal/i2s_ll.h +++ b/components/hal/esp32s3/include/hal/i2s_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -32,6 +32,7 @@ extern "C" { #define I2S_LL_MCLK_DIVIDER_BIT_WIDTH (9) #define I2S_LL_MCLK_DIVIDER_MAX ((1 << I2S_LL_MCLK_DIVIDER_BIT_WIDTH) - 1) +#define I2S_LL_SLOT_FRAME_BIT_MAX 128 // Up-to 128 bits in one frame, determined by MAX(half_sample_bits) * 2 #define I2S_LL_PLL_F160M_CLK_FREQ (160 * 1000000) // PLL_F160M_CLK: 160MHz #define I2S_LL_DEFAULT_PLL_CLK_FREQ I2S_LL_PLL_F160M_CLK_FREQ // The default PLL clock frequency while using I2S_CLK_SRC_DEFAULT @@ -258,15 +259,21 @@ static inline void i2s_ll_tx_set_bck_div_num(i2s_dev_t *hw, uint32_t val) */ static inline void i2s_ll_tx_set_raw_clk_div(i2s_dev_t *hw, uint32_t div_int, uint32_t x, uint32_t y, uint32_t z, uint32_t yn1) { - /* Set the integer part of mclk division */ + /* Workaround for the double division issue. + * The division coefficients must be set in particular sequence. + * And it has to switch to a small division first before setting the target division. */ + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->tx_clkm_conf, tx_clkm_div_num, 2); + hw->tx_clkm_div_conf.tx_clkm_div_yn1 = 0; + hw->tx_clkm_div_conf.tx_clkm_div_y = 1; + hw->tx_clkm_div_conf.tx_clkm_div_z = 0; + hw->tx_clkm_div_conf.tx_clkm_div_x = 0; + + /* Set the target mclk division coefficients */ + hw->tx_clkm_div_conf.tx_clkm_div_yn1 = yn1; + hw->tx_clkm_div_conf.tx_clkm_div_z = z; + hw->tx_clkm_div_conf.tx_clkm_div_y = y; + hw->tx_clkm_div_conf.tx_clkm_div_x = x; HAL_FORCE_MODIFY_U32_REG_FIELD(hw->tx_clkm_conf, tx_clkm_div_num, div_int); - /* Set the decimal part of the mclk division */ - typeof(hw->tx_clkm_div_conf) div = {}; - div.tx_clkm_div_x = x; - div.tx_clkm_div_y = y; - div.tx_clkm_div_z = z; - div.tx_clkm_div_yn1 = yn1; - hw->tx_clkm_div_conf.val = div.val; } /** @@ -281,15 +288,21 @@ static inline void i2s_ll_tx_set_raw_clk_div(i2s_dev_t *hw, uint32_t div_int, ui */ static inline void i2s_ll_rx_set_raw_clk_div(i2s_dev_t *hw, uint32_t div_int, uint32_t x, uint32_t y, uint32_t z, uint32_t yn1) { - /* Set the integer part of mclk division */ + /* Workaround for the double division issue. + * The division coefficients must be set in particular sequence. + * And it has to switch to a small division first before setting the target division. */ + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->rx_clkm_conf, rx_clkm_div_num, 2); + hw->rx_clkm_div_conf.rx_clkm_div_yn1 = 0; + hw->rx_clkm_div_conf.rx_clkm_div_y = 1; + hw->rx_clkm_div_conf.rx_clkm_div_z = 0; + hw->rx_clkm_div_conf.rx_clkm_div_x = 0; + + /* Set the target mclk division coefficients */ + hw->rx_clkm_div_conf.rx_clkm_div_yn1 = yn1; + hw->rx_clkm_div_conf.rx_clkm_div_z = z; + hw->rx_clkm_div_conf.rx_clkm_div_y = y; + hw->rx_clkm_div_conf.rx_clkm_div_x = x; HAL_FORCE_MODIFY_U32_REG_FIELD(hw->rx_clkm_conf, rx_clkm_div_num, div_int); - /* Set the decimal part of the mclk division */ - typeof(hw->rx_clkm_div_conf) div = {}; - div.rx_clkm_div_x = x; - div.rx_clkm_div_y = y; - div.rx_clkm_div_z = z; - div.rx_clkm_div_yn1 = yn1; - hw->rx_clkm_div_conf.val = div.val; } /** @@ -300,12 +313,6 @@ static inline void i2s_ll_rx_set_raw_clk_div(i2s_dev_t *hw, uint32_t div_int, ui */ static inline void i2s_ll_tx_set_mclk(i2s_dev_t *hw, const i2s_ll_mclk_div_t *mclk_div) { - /* Workaround for inaccurate clock while switching from a relatively low sample rate to a high sample rate - * Set to particular coefficients first then update to the target coefficients, - * otherwise the clock division might be inaccurate. - * the general idea is to set a value that impossible to calculate from the regular decimal */ - i2s_ll_tx_set_raw_clk_div(hw, 7, 317, 7, 3, 0); - uint32_t div_x = 0; uint32_t div_y = 0; uint32_t div_z = 0; @@ -340,12 +347,6 @@ static inline void i2s_ll_rx_set_bck_div_num(i2s_dev_t *hw, uint32_t val) */ static inline void i2s_ll_rx_set_mclk(i2s_dev_t *hw, const i2s_ll_mclk_div_t *mclk_div) { - /* Workaround for inaccurate clock while switching from a relatively low sample rate to a high sample rate - * Set to particular coefficients first then update to the target coefficients, - * otherwise the clock division might be inaccurate. - * the general idea is to set a value that impossible to calculate from the regular decimal */ - i2s_ll_rx_set_raw_clk_div(hw, 7, 317, 7, 3, 0); - uint32_t div_x = 0; uint32_t div_y = 0; uint32_t div_z = 0; @@ -441,7 +442,7 @@ static inline void i2s_ll_rx_set_eof_num(i2s_dev_t *hw, int eof_num) } /** - * @brief Congfigure TX chan bit and audio data bit + * @brief Configure TX chan bit and audio data bit * * @param hw Peripheral I2S hardware instance address. * @param chan_bit The chan bit width @@ -454,7 +455,7 @@ static inline void i2s_ll_tx_set_sample_bit(i2s_dev_t *hw, uint8_t chan_bit, int } /** - * @brief Congfigure RX chan bit and audio data bit + * @brief Configure RX chan bit and audio data bit * * @param hw Peripheral I2S hardware instance address. * @param chan_bit The chan bit width @@ -757,11 +758,11 @@ static inline void i2s_ll_tx_set_pdm_fpfs(i2s_dev_t *hw, uint32_t fp, uint32_t f } /** - * @brief Get I2S TX PDM fp configuration paramater + * @brief Get I2S TX PDM fp configuration parameter * * @param hw Peripheral I2S hardware instance address. * @return - * - fp configuration paramater + * - fp configuration parameter */ static inline uint32_t i2s_ll_tx_get_pdm_fp(i2s_dev_t *hw) { @@ -769,11 +770,11 @@ static inline uint32_t i2s_ll_tx_get_pdm_fp(i2s_dev_t *hw) } /** - * @brief Get I2S TX PDM fs configuration paramater + * @brief Get I2S TX PDM fs configuration parameter * * @param hw Peripheral I2S hardware instance address. * @return - * - fs configuration paramater + * - fs configuration parameter */ static inline uint32_t i2s_ll_tx_get_pdm_fs(i2s_dev_t *hw) { @@ -894,7 +895,7 @@ static inline void i2s_ll_tx_set_pdm_sd_dither2(i2s_dev_t *hw, uint32_t dither2) * @brief Configure RX PDM downsample * * @param hw Peripheral I2S hardware instance address. - * @param dsr PDM downsample configuration paramater + * @param dsr PDM downsample configuration parameter */ static inline void i2s_ll_rx_set_pdm_dsr(i2s_dev_t *hw, i2s_pdm_dsr_t dsr) { @@ -916,7 +917,7 @@ static inline void i2s_ll_rx_get_pdm_dsr(i2s_dev_t *hw, i2s_pdm_dsr_t *dsr) * @brief Configura TX a/u-law decompress or compress * * @param hw Peripheral I2S hardware instance address. - * @param pcm_cfg PCM configuration paramater + * @param pcm_cfg PCM configuration parameter */ static inline void i2s_ll_tx_set_pcm_type(i2s_dev_t *hw, i2s_pcm_compress_t pcm_cfg) { @@ -928,7 +929,7 @@ static inline void i2s_ll_tx_set_pcm_type(i2s_dev_t *hw, i2s_pcm_compress_t pcm_ * @brief Configure RX a/u-law decompress or compress * * @param hw Peripheral I2S hardware instance address. - * @param pcm_cfg PCM configuration paramater + * @param pcm_cfg PCM configuration parameter */ static inline void i2s_ll_rx_set_pcm_type(i2s_dev_t *hw, i2s_pcm_compress_t pcm_cfg) { @@ -1100,7 +1101,7 @@ static inline void i2s_ll_tx_pdm_dma_take_mode(i2s_dev_t *hw, bool is_mono, bool * @param is_mono The DMA data only has one slot (mono) or contains two slots (stereo) * @param is_copy Whether the un-selected slot copies the data from the selected one * If not, the un-selected slot will transmit the data from 'conf_single_data' - * @param mask The slot mask to selet the slot + * @param mask The slot mask to select the slot */ static inline void i2s_ll_tx_pdm_slot_mode(i2s_dev_t *hw, bool is_mono, bool is_copy, i2s_pdm_slot_mask_t mask) { diff --git a/components/hal/i2s_hal.c b/components/hal/i2s_hal.c index 9b7c275281..2e8e32162b 100644 --- a/components/hal/i2s_hal.c +++ b/components/hal/i2s_hal.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -282,8 +282,8 @@ void i2s_hal_tdm_set_tx_slot(i2s_hal_context_t *hal, bool is_slave, const i2s_ha uint32_t msk = slot_cfg->tdm.slot_mask; /* Get the maximum slot number */ cnt = 32 - __builtin_clz(msk); - /* There should be at least 2 slots in total even for mono mode */ - cnt = cnt < 2 ? 2 : cnt; + /* Except PCM short format (ws_width = 1), there should be at least 2 slots in total even for mono mode */ + cnt = ((cnt < 2) && (slot_cfg->tdm.ws_width != 1)) ? 2 : cnt; uint32_t total_slot = slot_cfg->tdm.total_slot > cnt ? slot_cfg->tdm.total_slot : cnt; i2s_ll_tx_reset(hal->dev); i2s_ll_tx_set_slave_mod(hal->dev, is_slave); //TX Slave @@ -316,8 +316,8 @@ void i2s_hal_tdm_set_rx_slot(i2s_hal_context_t *hal, bool is_slave, const i2s_ha uint32_t msk = slot_cfg->tdm.slot_mask; /* Get the maximum slot number */ cnt = 32 - __builtin_clz(msk); - /* There should be at least 2 slots in total even for mono mode */ - cnt = cnt < 2 ? 2 : cnt; + /* Except PCM short format (ws_width = 1), there should be at least 2 slots in total even for mono mode */ + cnt = ((cnt < 2) && (slot_cfg->tdm.ws_width != 1)) ? 2 : cnt; uint32_t total_slot = slot_cfg->tdm.total_slot > cnt ? slot_cfg->tdm.total_slot : cnt; i2s_ll_rx_reset(hal->dev); i2s_ll_rx_set_slave_mod(hal->dev, is_slave); //RX Slave diff --git a/components/hal/include/hal/ecdsa_hal.h b/components/hal/include/hal/ecdsa_hal.h index 2e60642b7c..3dfd48233b 100644 --- a/components/hal/include/hal/ecdsa_hal.h +++ b/components/hal/include/hal/ecdsa_hal.h @@ -15,11 +15,23 @@ #include #include #include "hal/ecdsa_types.h" +#include "sdkconfig.h" #ifdef __cplusplus extern "C" { #endif +#if CONFIG_HAL_ECDSA_GEN_SIG_CM + +#define ECDSA_SIGN_MAX_DUMMY_OP_COUNT 0x7 + +/* This value defines the maximum dummy operation count for the ECDSA signature countermeasure. + Higher the number, better the countermeasure's effectiveness against attacks. + At the same time higher number leads to slower performance. + After the countermeasure is enabled, hardware ECDSA signature operation + shall take time approximately equal to original time multiplied by this number. + If you observe that the reduced performance is affecting your use-case then you may try reducing this time to the minimum. */ +#endif /* CONFIG_HAL_ECDSA_GEN_SIG_CM */ /* * ECDSA peripheral config structure */ diff --git a/components/hal/include/hal/ieee802154_common_ll.h b/components/hal/include/hal/ieee802154_common_ll.h index 86ac495ac4..d27b9f4624 100644 --- a/components/hal/include/hal/ieee802154_common_ll.h +++ b/components/hal/include/hal/ieee802154_common_ll.h @@ -271,6 +271,16 @@ static inline void ieee802154_ll_set_power(uint8_t power) IEEE802154.txpower.power = power; } +static inline void ieee802154_ll_set_ack_timeout(uint32_t timeout) +{ + IEEE802154.ack_timeout.timeout = timeout; +} + +static inline uint32_t ieee802154_ll_get_ack_timeout(void) +{ + return IEEE802154.ack_timeout.timeout; +} + static inline void ieee802154_ll_set_multipan_panid(ieee802154_ll_multipan_index_t index, uint16_t panid) { IEEE802154.conf.multipan_mask |= BIT(index); diff --git a/components/hal/include/hal/spi_slave_hal.h b/components/hal/include/hal/spi_slave_hal.h index 9d7ceec37e..84d3f4a19d 100644 --- a/components/hal/include/hal/spi_slave_hal.h +++ b/components/hal/include/hal/spi_slave_hal.h @@ -134,7 +134,7 @@ void spi_slave_hal_store_result(spi_slave_hal_context_t *hal); * Get the length of last transaction, in bits. Should be called after ``spi_slave_hal_store_result``. * * Note that if last transaction is longer than configured before, the return - * value will be truncated to the configured length. + * value still the actual length. * * @param hal Context of the HAL layer. * diff --git a/components/hal/include/hal/twai_types.h b/components/hal/include/hal/twai_types.h index 7f3789fe2b..1fd9115d88 100644 --- a/components/hal/include/hal/twai_types.h +++ b/components/hal/include/hal/twai_types.h @@ -64,26 +64,24 @@ extern "C" { #define TWAI_TIMING_CONFIG_20KBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 400000, .brp = 0, .tseg_1 = 15, .tseg_2 = 4, .sjw = 3, .triple_sampling = false} #endif // (SOC_TWAI_BRP_MAX > 128) || (CONFIG_ESP32_REV_MIN_FULL >= 200) -#if CONFIG_XTAL_FREQ == 32 // TWAI_CLK_SRC_XTAL = 32M -#define TWAI_TIMING_CONFIG_25KBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 400000, .brp = 0, .tseg_1 = 11, .tseg_2 = 4, .sjw = 3, .triple_sampling = false} -#define TWAI_TIMING_CONFIG_50KBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 1000000, .brp = 0, .tseg_1 = 15, .tseg_2 = 4, .sjw = 3, .triple_sampling = false} -#define TWAI_TIMING_CONFIG_100KBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 2000000, .brp = 0, .tseg_1 = 15, .tseg_2 = 4, .sjw = 3, .triple_sampling = false} -#define TWAI_TIMING_CONFIG_125KBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 4000000, .brp = 0, .tseg_1 = 23, .tseg_2 = 8, .sjw = 3, .triple_sampling = false} -#define TWAI_TIMING_CONFIG_250KBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 4000000, .brp = 0, .tseg_1 = 11, .tseg_2 = 4, .sjw = 3, .triple_sampling = false} -#define TWAI_TIMING_CONFIG_500KBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 8000000, .brp = 0, .tseg_1 = 11, .tseg_2 = 4, .sjw = 3, .triple_sampling = false} -#define TWAI_TIMING_CONFIG_800KBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 16000000, .brp = 0, .tseg_1 = 15, .tseg_2 = 4, .sjw = 3, .triple_sampling = false} -#define TWAI_TIMING_CONFIG_1MBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 16000000, .brp = 0, .tseg_1 = 11, .tseg_2 = 4, .sjw = 3, .triple_sampling = false} - -#elif CONFIG_XTAL_FREQ == 40 // TWAI_CLK_SRC_XTAL = 40M +#if SOC_TWAI_CLK_SUPPORT_XTAL +#define TWAI_TIMING_CONFIG_25KBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 500000, .brp = 0, .tseg_1 = 15, .tseg_2 = 4, .sjw = 3, .triple_sampling = false} +#else // APB80M #define TWAI_TIMING_CONFIG_25KBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 625000, .brp = 0, .tseg_1 = 16, .tseg_2 = 8, .sjw = 3, .triple_sampling = false} +#endif #define TWAI_TIMING_CONFIG_50KBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 1000000, .brp = 0, .tseg_1 = 15, .tseg_2 = 4, .sjw = 3, .triple_sampling = false} #define TWAI_TIMING_CONFIG_100KBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 2000000, .brp = 0, .tseg_1 = 15, .tseg_2 = 4, .sjw = 3, .triple_sampling = false} -#define TWAI_TIMING_CONFIG_125KBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 2500000, .brp = 0, .tseg_1 = 15, .tseg_2 = 4, .sjw = 3, .triple_sampling = false} -#define TWAI_TIMING_CONFIG_250KBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 5000000, .brp = 0, .tseg_1 = 15, .tseg_2 = 4, .sjw = 3, .triple_sampling = false} +#define TWAI_TIMING_CONFIG_125KBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 2000000, .brp = 0, .tseg_1 = 11, .tseg_2 = 4, .sjw = 3, .triple_sampling = false} +#define TWAI_TIMING_CONFIG_250KBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 4000000, .brp = 0, .tseg_1 = 11, .tseg_2 = 4, .sjw = 2, .triple_sampling = false} +#if SOC_TWAI_CLK_SUPPORT_XTAL && CONFIG_XTAL_FREQ == 40 // TWAI_CLK_SRC_XTAL = 40M #define TWAI_TIMING_CONFIG_500KBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 10000000, .brp = 0, .tseg_1 = 15, .tseg_2 = 4, .sjw = 3, .triple_sampling = false} #define TWAI_TIMING_CONFIG_800KBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 20000000, .brp = 0, .tseg_1 = 16, .tseg_2 = 8, .sjw = 3, .triple_sampling = false} #define TWAI_TIMING_CONFIG_1MBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 20000000, .brp = 0, .tseg_1 = 15, .tseg_2 = 4, .sjw = 3, .triple_sampling = false} -#endif //CONFIG_XTAL_FREQ +#else // 32M, 48M, APB80M +#define TWAI_TIMING_CONFIG_500KBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 8000000, .brp = 0, .tseg_1 = 11, .tseg_2 = 4, .sjw = 2, .triple_sampling = false} +#define TWAI_TIMING_CONFIG_800KBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 8000000, .brp = 0, .tseg_1 = 6, .tseg_2 = 3, .sjw = 1, .triple_sampling = false} +#define TWAI_TIMING_CONFIG_1MBITS() {.clk_src = TWAI_CLK_SRC_DEFAULT, .quanta_resolution_hz = 8000000, .brp = 0, .tseg_1 = 5, .tseg_2 = 2, .sjw = 1, .triple_sampling = false} +#endif /** * @brief Initializer macro for filter configuration to accept all IDs diff --git a/components/hal/spi_slave_hal_iram.c b/components/hal/spi_slave_hal_iram.c index 505de92723..66c07a640d 100644 --- a/components/hal/spi_slave_hal_iram.c +++ b/components/hal/spi_slave_hal_iram.c @@ -89,7 +89,7 @@ void spi_slave_hal_store_result(spi_slave_hal_context_t *hal) } if (!hal->use_dma && hal->rx_buffer) { //Copy result out - spi_ll_read_buffer(hal->hw, hal->rx_buffer, hal->bitlen); + spi_ll_read_buffer(hal->hw, hal->rx_buffer, (hal->rcv_bitlen > hal->bitlen) ? hal->bitlen : hal->rcv_bitlen); } } diff --git a/components/mbedtls/CMakeLists.txt b/components/mbedtls/CMakeLists.txt index 9cb83d4445..2a483c8c61 100644 --- a/components/mbedtls/CMakeLists.txt +++ b/components/mbedtls/CMakeLists.txt @@ -12,6 +12,10 @@ endif() set(mbedtls_srcs "") set(mbedtls_include_dirs "port/include" "mbedtls/include" "mbedtls/library") +if(CONFIG_MBEDTLS_USE_CRYPTO_ROM_IMPL) + list(APPEND mbedtls_include_dirs "port/mbedtls_rom") +endif() + if(CONFIG_MBEDTLS_CERTIFICATE_BUNDLE) list(APPEND mbedtls_srcs "esp_crt_bundle/esp_crt_bundle.c") list(APPEND mbedtls_include_dirs "esp_crt_bundle/include") @@ -86,7 +90,18 @@ idf_build_get_property(python PYTHON) set(Python3_EXECUTABLE ${python}) # Needed to for include_next includes to work from within mbedtls -include_directories("${COMPONENT_DIR}/port/include") +set(include_dirs "${COMPONENT_DIR}/port/include") + +if(CONFIG_MBEDTLS_CERTIFICATE_BUNDLE) + list(APPEND include_dirs "${COMPONENT_DIR}/esp_crt_bundle/include") +endif() + +include_directories(${include_dirs}) + +# Needed to for mbedtls_rom includes to work from within mbedtls +if(CONFIG_MBEDTLS_USE_CRYPTO_ROM_IMPL) + include_directories("${COMPONENT_DIR}/port/mbedtls_rom") +endif() # Import mbedtls library targets add_subdirectory(mbedtls) @@ -257,6 +272,9 @@ if(CONFIG_MBEDTLS_HARDWARE_ECDSA_SIGN OR CONFIG_MBEDTLS_HARDWARE_ECDSA_VERIFY) if(CONFIG_MBEDTLS_HARDWARE_ECDSA_VERIFY) target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=mbedtls_ecdsa_verify") + target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=mbedtls_ecdsa_verify_restartable") + target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=mbedtls_ecdsa_read_signature") + target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=mbedtls_ecdsa_read_signature_restartable") endif() endif() @@ -308,6 +326,19 @@ if(CONFIG_ESP_TLS_USE_DS_PERIPHERAL) set_property(TARGET mbedcrypto APPEND PROPERTY LINK_INTERFACE_MULTIPLICITY 6) endif() +# Additional optional dependencies for the mbedcrypto library +function(mbedcrypto_optional_deps component_name) + idf_build_get_property(components BUILD_COMPONENTS) + if(${component_name} IN_LIST components) + idf_component_get_property(lib_name ${component_name} COMPONENT_LIB) + target_link_libraries(mbedcrypto PRIVATE ${lib_name}) + endif() +endfunction() + +if(CONFIG_MBEDTLS_HARDWARE_ECDSA_SIGN_CONSTANT_TIME_CM) + mbedcrypto_optional_deps(esp_timer idf::esp_timer) +endif() + # Link esp-cryptoauthlib to mbedtls if(CONFIG_ATCA_MBEDTLS_ECDSA) idf_component_optional_requires(PRIVATE espressif__esp-cryptoauthlib esp-cryptoauthlib) diff --git a/components/mbedtls/Kconfig b/components/mbedtls/Kconfig index a50c6a1441..402b65232a 100644 --- a/components/mbedtls/Kconfig +++ b/components/mbedtls/Kconfig @@ -511,6 +511,37 @@ menu "mbedTLS" The key should be burnt in little endian format. espefuse.py utility handles it internally but care needs to be taken while burning using esp_efuse APIs + menu "Enable Software Countermeasure for ECDSA signing using on-chip ECDSA peripheral" + depends on MBEDTLS_HARDWARE_ECDSA_SIGN + depends on IDF_TARGET_ESP32H2 + config MBEDTLS_HARDWARE_ECDSA_SIGN_MASKING_CM + bool "Mask original ECDSA sign operation under dummy sign operations" + select HAL_ECDSA_GEN_SIG_CM + # ToDo: IDF-11051 + default y + help + The ECDSA peripheral before ECO5 does not offer constant time ECDSA sign operation. + This time can be observed through power profiling of the device, + making the ECDSA private key vulnerable to side-channel timing attacks. + This countermeasure masks the real ECDSA sign operation + under dummy sign operations to add randomness in the generated power signature. + It is highly recommended to also enable Secure Boot for the device in addition to this countermeasure + so that only trusted software can execute on the device. + + config MBEDTLS_HARDWARE_ECDSA_SIGN_CONSTANT_TIME_CM + bool "Make ECDSA signature operation pseudo constant time for software" + default y + help + This option adds a delay after the actual ECDSA signature operation + so that the entire operation appears to be constant time for the software. + This fix helps in protecting the device only in case of remote timing attack on the ECDSA private key. + For e.g., When an interface is exposed by the device to perform ECDSA signature + of an arbitrary message. + The signature time would appear to be constant to the external entity after enabling + this option. + + endmenu + config MBEDTLS_HARDWARE_ECDSA_VERIFY bool "Enable ECDSA signature verification using on-chip ECDSA peripheral" default y @@ -599,6 +630,14 @@ menu "mbedTLS" help Enable MBEDTLS_SHA512_C adds support for SHA-384 and SHA-512. + config MBEDTLS_SHA3_C + bool "Enable the SHA3 cryptographic hash algorithm" + default n + help + Enabling MBEDTLS_SHA3_C adds support for SHA3. + Enabling this configuration option increases the flash footprint + by almost 4KB. + choice MBEDTLS_TLS_MODE bool "TLS Protocol Role" default MBEDTLS_TLS_SERVER_AND_CLIENT @@ -1018,12 +1057,12 @@ menu "mbedTLS" config MBEDTLS_ECP_FIXED_POINT_OPTIM bool "Enable fixed-point multiplication optimisations" depends on MBEDTLS_ECP_C - default y + default n help This configuration option enables optimizations to speedup (about 3 ~ 4 times) the ECP fixed point multiplication using pre-computed tables in the flash memory. - Disabling this configuration option saves flash footprint (about 29KB if all Elliptic Curve selected) - in the application binary. + Enabling this configuration option increases the flash footprint + (about 29KB if all Elliptic Curve selected) in the application binary. # end of Elliptic Curve options @@ -1084,22 +1123,26 @@ menu "mbedTLS" config MBEDTLS_USE_CRYPTO_ROM_IMPL bool "Use ROM implementation of the crypto algorithm" - depends on ESP_ROM_HAS_MBEDTLS_CRYPTO_LIB && IDF_EXPERIMENTAL_FEATURES + depends on ESP_ROM_HAS_MBEDTLS_CRYPTO_LIB default "n" select MBEDTLS_SHA512_C select MBEDTLS_AES_C select MBEDTLS_CCM_C + select MBEDTLS_CMAC_C select MBEDTLS_ROM_MD5 select MBEDTLS_HARDWARE_SHA + select MBEDTLS_ECP_RESTARTABLE + select MBEDTLS_THREADING_C help Enable this flag to use mbedtls crypto algorithm from ROM instead of ESP-IDF. This configuration option saves flash footprint in the application binary. - Note that the version of mbedtls crypto algorithm library in ROM is v2.16.12. - We have done the security analysis of the mbedtls revision in ROM (v2.16.12) + Note that the version of mbedtls crypto algorithm library in ROM(ECO1~ECO3) is v2.16.12, + and the version of mbedtls crypto algorithm library in ROM(ECO4) is v3.6.0. + We have done the security analysis of the mbedtls revision in ROM (ECO1~ECO4) and ensured that affected symbols have been patched (removed). If in the future mbedtls revisions there are security issues that also affects the version in - ROM (v2.16.12) then we shall patch the relevant symbols. This would increase + ROM (ECO1~ECO4) then we shall patch the relevant symbols. This would increase the flash footprint and hence care must be taken to keep some reserved space for the application binary in flash layout. diff --git a/components/mbedtls/esp_crt_bundle/esp_crt_bundle.c b/components/mbedtls/esp_crt_bundle/esp_crt_bundle.c index 2da3850087..e1b042b8c2 100644 --- a/components/mbedtls/esp_crt_bundle/esp_crt_bundle.c +++ b/components/mbedtls/esp_crt_bundle/esp_crt_bundle.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -15,8 +15,7 @@ static const char *TAG = "esp-x509-crt-bundle"; /* a dummy certificate so that * cacert_ptr passes non-NULL check during handshake */ -static mbedtls_x509_crt s_dummy_crt; - +static const mbedtls_x509_crt s_dummy_crt; extern const uint8_t x509_crt_imported_bundle_bin_start[] asm("_binary_x509_crt_bundle_start"); extern const uint8_t x509_crt_imported_bundle_bin_end[] asm("_binary_x509_crt_bundle_end"); @@ -218,8 +217,7 @@ esp_err_t esp_crt_bundle_attach(void *conf) * cacert_ptr passes non-NULL check during handshake */ mbedtls_ssl_config *ssl_conf = (mbedtls_ssl_config *)conf; - mbedtls_x509_crt_init(&s_dummy_crt); - mbedtls_ssl_conf_ca_chain(ssl_conf, &s_dummy_crt, NULL); + mbedtls_ssl_conf_ca_chain(ssl_conf, (mbedtls_x509_crt*)&s_dummy_crt, NULL); mbedtls_ssl_conf_verify(ssl_conf, esp_crt_verify_callback, NULL); } @@ -239,3 +237,8 @@ esp_err_t esp_crt_bundle_set(const uint8_t *x509_bundle, size_t bundle_size) { return esp_crt_bundle_init(x509_bundle, bundle_size); } + +bool esp_crt_bundle_in_use(const mbedtls_x509_crt* ca_chain) +{ + return ((ca_chain == &s_dummy_crt) ? true : false); +} diff --git a/components/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h b/components/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h index 49069185b3..61c09f0bd0 100644 --- a/components/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h +++ b/components/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -27,7 +27,7 @@ extern "C" { * * @return * - ESP_OK if adding certificates was successful. - * - Other if an error occured or an action must be taken by the calling process. + * - Other if an error occurred or an action must be taken by the calling process. */ esp_err_t esp_crt_bundle_attach(void *conf); @@ -55,10 +55,19 @@ void esp_crt_bundle_detach(mbedtls_ssl_config *conf); * * @return * - ESP_OK if adding certificates was successful. - * - Other if an error occured or an action must be taken by the calling process. + * - Other if an error occurred or an action must be taken by the calling process. */ esp_err_t esp_crt_bundle_set(const uint8_t *x509_bundle, size_t bundle_size); +/** + * @brief Check if the given CA certificate chain is the default "dummy" + * certificate chain attached by the esp_crt_bundle + * + * @param ca_chain A pointer to the CA chain. + * @return true if the ca_chain is the dummy CA chain attached by esp_crt_bundle + * @return false otherwise + */ +bool esp_crt_bundle_in_use(const mbedtls_x509_crt* ca_chain); #ifdef __cplusplus } diff --git a/components/mbedtls/port/aes/esp_aes_gcm.c b/components/mbedtls/port/aes/esp_aes_gcm.c index 9798fe475c..17c2ec84df 100644 --- a/components/mbedtls/port/aes/esp_aes_gcm.c +++ b/components/mbedtls/port/aes/esp_aes_gcm.c @@ -192,11 +192,11 @@ static int gcm_gen_table( esp_gcm_context *ctx ) * last4[x] = x times P^128 * where x and last4[x] are seen as elements of GF(2^128) as in [MGV] */ -static const uint64_t last4[16] = { - 0x0000, 0x1c20, 0x3840, 0x2460, - 0x7080, 0x6ca0, 0x48c0, 0x54e0, - 0xe100, 0xfd20, 0xd940, 0xc560, - 0x9180, 0x8da0, 0xa9c0, 0xb5e0 +static const uint32_t last4[16] = { + 0x00000000, 0x1c200000, 0x38400000, 0x24600000, + 0x70800000, 0x6ca00000, 0x48c00000, 0x54e00000, + 0xe1000000, 0xfd200000, 0xd9400000, 0xc5600000, + 0x91800000, 0x8da00000, 0xa9c00000, 0xb5e00000 }; /* Based on MbedTLS's implemenation * @@ -211,28 +211,33 @@ static void gcm_mult( esp_gcm_context *ctx, const unsigned char x[16], uint64_t zh, zl; lo = x[15] & 0xf; + hi = x[15] >> 4; zh = ctx->HH[lo]; zl = ctx->HL[lo]; - for ( i = 15; i >= 0; i-- ) { + rem = (unsigned char) zl & 0xf; + zl = ( zh << 60 ) | ( zl >> 4 ); + zh = ( zh >> 4 ); + zh ^= (uint64_t) last4[rem] << 32; + zh ^= ctx->HH[hi]; + zl ^= ctx->HL[hi]; + + for ( i = 14; i >= 0; i-- ) { lo = x[i] & 0xf; hi = x[i] >> 4; - if ( i != 15 ) { - rem = (unsigned char) zl & 0xf; - zl = ( zh << 60 ) | ( zl >> 4 ); - zh = ( zh >> 4 ); - zh ^= (uint64_t) last4[rem] << 48; - zh ^= ctx->HH[lo]; - zl ^= ctx->HL[lo]; - - } + rem = (unsigned char) zl & 0xf; + zl = ( zh << 60 ) | ( zl >> 4 ); + zh = ( zh >> 4 ); + zh ^= (uint64_t) last4[rem] << 32; + zh ^= ctx->HH[lo]; + zl ^= ctx->HL[lo]; rem = (unsigned char) zl & 0xf; zl = ( zh << 60 ) | ( zl >> 4 ); zh = ( zh >> 4 ); - zh ^= (uint64_t) last4[rem] << 48; + zh ^= (uint64_t) last4[rem] << 32; zh ^= ctx->HH[hi]; zl ^= ctx->HL[hi]; } diff --git a/components/mbedtls/port/dynamic/esp_mbedtls_dynamic_impl.c b/components/mbedtls/port/dynamic/esp_mbedtls_dynamic_impl.c index a5ea9fb337..d76f6b5049 100644 --- a/components/mbedtls/port/dynamic/esp_mbedtls_dynamic_impl.c +++ b/components/mbedtls/port/dynamic/esp_mbedtls_dynamic_impl.c @@ -1,11 +1,16 @@ /* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include #include "esp_mbedtls_dynamic_impl.h" +#include "sdkconfig.h" + +#if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE +#include "esp_crt_bundle.h" +#endif #define COUNTER_SIZE (8) #define CACHE_IV_SIZE (16) @@ -532,7 +537,18 @@ void esp_mbedtls_free_cacert(mbedtls_ssl_context *ssl) if (ssl->MBEDTLS_PRIVATE(conf)->MBEDTLS_PRIVATE(ca_chain)) { mbedtls_ssl_config *conf = (mbedtls_ssl_config * )mbedtls_ssl_context_get_config(ssl); +#if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE + /* In case of mbedtls certificate bundle, we attach a "static const" + * dummy cert, thus we need to avoid the write operations (memset()) + * performed by `mbedtls_x509_crt_free()` + */ + if (!esp_crt_bundle_in_use(conf->MBEDTLS_PRIVATE(ca_chain))) { + mbedtls_x509_crt_free(conf->MBEDTLS_PRIVATE(ca_chain)); + } +#else mbedtls_x509_crt_free(conf->MBEDTLS_PRIVATE(ca_chain)); +#endif + conf->MBEDTLS_PRIVATE(ca_chain) = NULL; } } diff --git a/components/mbedtls/port/dynamic/esp_mbedtls_dynamic_impl.h b/components/mbedtls/port/dynamic/esp_mbedtls_dynamic_impl.h index 72641b3a54..ad7a716be5 100644 --- a/components/mbedtls/port/dynamic/esp_mbedtls_dynamic_impl.h +++ b/components/mbedtls/port/dynamic/esp_mbedtls_dynamic_impl.h @@ -24,6 +24,7 @@ #include "mbedtls/ssl.h" #include "mbedtls/platform.h" #include "esp_log.h" +#include "sdkconfig.h" #define TRACE_CHECK(_fn, _state) \ ({ \ diff --git a/components/mbedtls/port/ecdsa/ecdsa_alt.c b/components/mbedtls/port/ecdsa/ecdsa_alt.c index 25048afc82..8f9158c372 100644 --- a/components/mbedtls/port/ecdsa/ecdsa_alt.c +++ b/components/mbedtls/port/ecdsa/ecdsa_alt.c @@ -10,6 +10,7 @@ #include "mbedtls/ecp.h" #include "mbedtls/error.h" #include "mbedtls/ecdsa.h" +#include "mbedtls/asn1.h" #include "mbedtls/asn1write.h" #include "mbedtls/platform_util.h" #include "esp_private/periph_ctrl.h" @@ -20,6 +21,28 @@ #define ECDSA_SHA_LEN 32 #define MAX_ECDSA_COMPONENT_LEN 32 +#if CONFIG_MBEDTLS_HARDWARE_ECDSA_SIGN_CONSTANT_TIME_CM +#include "esp_timer.h" + +#if CONFIG_ESP_CRYPTO_DPA_PROTECTION_LEVEL_HIGH +/* + * This is the maximum time (in us) required for performing 1 ECDSA signature + * in this configuration along some additional margin considerations + */ +#define ECDSA_MAX_SIG_TIME 24000 +#else /* CONFIG_ESP_CRYPTO_DPA_PROTECTION_LEVEL_HIGH */ +#define ECDSA_MAX_SIG_TIME 17500 +#endif /* !CONFIG_ESP_CRYPTO_DPA_PROTECTION_LEVEL_HIGH */ + +#if CONFIG_MBEDTLS_HARDWARE_ECDSA_SIGN_MASKING_CM +#define DUMMY_OP_COUNT ECDSA_SIGN_MAX_DUMMY_OP_COUNT +#else /* CONFIG_MBEDTLS_HARDWARE_ECDSA_SIGN_MASKING_CM */ +#define DUMMY_OP_COUNT 0 +#endif /* !CONFIG_MBEDTLS_HARDWARE_ECDSA_SIGN_MASKING_CM */ +#define ECDSA_CM_FIXED_SIG_TIME ECDSA_MAX_SIG_TIME * (DUMMY_OP_COUNT + 1) + +#endif /* CONFIG_MBEDTLS_HARDWARE_ECDSA_SIGN_CONSTANT_TIME_CM */ + __attribute__((unused)) static const char *TAG = "ecdsa_alt"; static void esp_ecdsa_acquire_hardware(void) @@ -148,8 +171,16 @@ static int esp_ecdsa_sign(mbedtls_ecp_group *grp, mbedtls_mpi* r, mbedtls_mpi* s .efuse_key_blk = d->MBEDTLS_PRIVATE(n), }; +#if CONFIG_MBEDTLS_HARDWARE_ECDSA_SIGN_CONSTANT_TIME_CM + uint64_t sig_time = esp_timer_get_time(); +#endif ecdsa_hal_gen_signature(&conf, sha_le, r_le, s_le, len); - +#if CONFIG_MBEDTLS_HARDWARE_ECDSA_SIGN_CONSTANT_TIME_CM + sig_time = esp_timer_get_time() - sig_time; + if (sig_time < ECDSA_CM_FIXED_SIG_TIME) { + esp_rom_delay_us(ECDSA_CM_FIXED_SIG_TIME - sig_time); + } +#endif process_again = !ecdsa_hal_get_operation_result() || !memcmp(r_le, zeroes, len) || !memcmp(s_le, zeroes, len); @@ -387,6 +418,37 @@ static int esp_ecdsa_verify(mbedtls_ecp_group *grp, return ret; } +/* + * Verify ECDSA signature of hashed message + */ +extern int __real_mbedtls_ecdsa_verify_restartable(mbedtls_ecp_group *grp, + const unsigned char *buf, size_t blen, + const mbedtls_ecp_point *Q, + const mbedtls_mpi *r, + const mbedtls_mpi *s, + mbedtls_ecdsa_restart_ctx *rs_ctx); + +int __wrap_mbedtls_ecdsa_verify_restartable(mbedtls_ecp_group *grp, + const unsigned char *buf, size_t blen, + const mbedtls_ecp_point *Q, + const mbedtls_mpi *r, + const mbedtls_mpi *s, + mbedtls_ecdsa_restart_ctx *rs_ctx); + +int __wrap_mbedtls_ecdsa_verify_restartable(mbedtls_ecp_group *grp, + const unsigned char *buf, size_t blen, + const mbedtls_ecp_point *Q, + const mbedtls_mpi *r, + const mbedtls_mpi *s, + mbedtls_ecdsa_restart_ctx *rs_ctx) +{ + if ((grp->id == MBEDTLS_ECP_DP_SECP192R1 || grp->id == MBEDTLS_ECP_DP_SECP256R1) && blen == ECDSA_SHA_LEN) { + return esp_ecdsa_verify(grp, buf, blen, Q, r, s); + } else { + return __real_mbedtls_ecdsa_verify_restartable(grp, buf, blen, Q, r, s, rs_ctx); + } +} + /* * Verify ECDSA signature of hashed message */ @@ -408,10 +470,84 @@ int __wrap_mbedtls_ecdsa_verify(mbedtls_ecp_group *grp, const mbedtls_mpi *r, const mbedtls_mpi *s) { - if (grp->id == MBEDTLS_ECP_DP_SECP192R1 || grp->id == MBEDTLS_ECP_DP_SECP256R1) { - return esp_ecdsa_verify(grp, buf, blen, Q, r, s); - } else { - return __real_mbedtls_ecdsa_verify(grp, buf, blen, Q, r, s); + return __wrap_mbedtls_ecdsa_verify_restartable(grp, buf, blen, Q, r, s, NULL); +} + + +int __real_mbedtls_ecdsa_read_signature_restartable(mbedtls_ecdsa_context *ctx, + const unsigned char *hash, size_t hlen, + const unsigned char *sig, size_t slen, + mbedtls_ecdsa_restart_ctx *rs_ctx); + +int __wrap_mbedtls_ecdsa_read_signature_restartable(mbedtls_ecdsa_context *ctx, + const unsigned char *hash, size_t hlen, + const unsigned char *sig, size_t slen, + mbedtls_ecdsa_restart_ctx *rs_ctx); + +int __wrap_mbedtls_ecdsa_read_signature_restartable(mbedtls_ecdsa_context *ctx, + const unsigned char *hash, size_t hlen, + const unsigned char *sig, size_t slen, + mbedtls_ecdsa_restart_ctx *rs_ctx) +{ + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + unsigned char *p = (unsigned char *) sig; + const unsigned char *end = sig + slen; + size_t len; + mbedtls_mpi r, s; + mbedtls_mpi_init(&r); + mbedtls_mpi_init(&s); + + if ((ret = mbedtls_asn1_get_tag(&p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE)) != 0) { + ret += MBEDTLS_ERR_ECP_BAD_INPUT_DATA; + goto cleanup; + } + + if (p + len != end) { + ret = MBEDTLS_ERROR_ADD(MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH); + goto cleanup; + } + + if ((ret = mbedtls_asn1_get_mpi(&p, end, &r)) != 0 || + (ret = mbedtls_asn1_get_mpi(&p, end, &s)) != 0) { + ret += MBEDTLS_ERR_ECP_BAD_INPUT_DATA; + goto cleanup; + } + + if ((ret = __wrap_mbedtls_ecdsa_verify_restartable(&ctx->MBEDTLS_PRIVATE(grp), hash, hlen, + &ctx->MBEDTLS_PRIVATE(Q), &r, &s, NULL)) != 0) { + goto cleanup; + } + + /* At this point we know that the buffer starts with a valid signature. + * Return 0 if the buffer just contains the signature, and a specific + * error code if the valid signature is followed by more data. */ + if (p != end) { + ret = MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH; } + +cleanup: + mbedtls_mpi_free(&r); + mbedtls_mpi_free(&s); + + return ret; +} + + +int __real_mbedtls_ecdsa_read_signature(mbedtls_ecdsa_context *ctx, + const unsigned char *hash, size_t hlen, + const unsigned char *sig, size_t slen); + +int __wrap_mbedtls_ecdsa_read_signature(mbedtls_ecdsa_context *ctx, + const unsigned char *hash, size_t hlen, + const unsigned char *sig, size_t slen); + +int __wrap_mbedtls_ecdsa_read_signature(mbedtls_ecdsa_context *ctx, + const unsigned char *hash, size_t hlen, + const unsigned char *sig, size_t slen) +{ + return __wrap_mbedtls_ecdsa_read_signature_restartable( + ctx, hash, hlen, sig, slen, NULL); } #endif /* CONFIG_MBEDTLS_HARDWARE_ECDSA_VERIFY */ diff --git a/components/mbedtls/port/include/mbedtls/esp_config.h b/components/mbedtls/port/include/mbedtls/esp_config.h index 5e7717a3a5..2b771298aa 100644 --- a/components/mbedtls/port/include/mbedtls/esp_config.h +++ b/components/mbedtls/port/include/mbedtls/esp_config.h @@ -2521,6 +2521,21 @@ #undef MBEDTLS_SHA512_C #endif +/** + * \def MBEDTLS_SHA3_C + * + * Enable the SHA3 cryptographic hash algorithm. + * + * Module: library/sha3.c + * + * This module adds support for SHA3. + */ +#ifdef CONFIG_MBEDTLS_SHA3_C +#define MBEDTLS_SHA3_C +#else +#undef MBEDTLS_SHA3_C +#endif + /** * \def MBEDTLS_SSL_CACHE_C * diff --git a/components/mbedtls/port/mbedtls_rom/mbedtls_rom_osi.c b/components/mbedtls/port/mbedtls_rom/mbedtls_rom_osi.c index 78fb4d479e..d29d03e966 100644 --- a/components/mbedtls/port/mbedtls_rom/mbedtls_rom_osi.c +++ b/components/mbedtls/port/mbedtls_rom/mbedtls_rom_osi.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -10,6 +10,8 @@ #include MBEDTLS_CONFIG_FILE #endif +#include "soc/chip_revision.h" +#include "hal/efuse_hal.h" #include "mbedtls/platform.h" #include "mbedtls_rom_osi.h" @@ -17,9 +19,13 @@ void mbedtls_rom_osi_functions_init(void); static void mbedtls_rom_mutex_init( mbedtls_threading_mutex_t *mutex ) { -#if (!defined(CONFIG_MBEDTLS_THREADING_C)) - ((void) mutex); - return; + if (mutex == NULL) { + return; + } + +#if defined(MBEDTLS_THREADING_ALT) + mutex->mutex = xSemaphoreCreateMutex(); + assert(mutex->mutex != NULL); #else mbedtls_mutex_init(mutex); #endif @@ -27,9 +33,12 @@ static void mbedtls_rom_mutex_init( mbedtls_threading_mutex_t *mutex ) static void mbedtls_rom_mutex_free( mbedtls_threading_mutex_t *mutex ) { -#if (!defined(CONFIG_MBEDTLS_THREADING_C)) - ((void) mutex); - return; + if (mutex == NULL) { + return; + } + +#if defined(MBEDTLS_THREADING_ALT) + vSemaphoreDelete(mutex->mutex); #else mbedtls_mutex_free(mutex); #endif @@ -37,8 +46,14 @@ static void mbedtls_rom_mutex_free( mbedtls_threading_mutex_t *mutex ) static int mbedtls_rom_mutex_lock( mbedtls_threading_mutex_t *mutex ) { -#if (!defined(CONFIG_MBEDTLS_THREADING_C)) - ((void) mutex); + if (mutex == NULL) { + return MBEDTLS_ERR_THREADING_BAD_INPUT_DATA; + } + +#if defined(MBEDTLS_THREADING_ALT) + if (xSemaphoreTake(mutex->mutex, portMAX_DELAY) != pdTRUE) { + return MBEDTLS_ERR_THREADING_MUTEX_ERROR; + } return 0; #else return mbedtls_mutex_lock(mutex); @@ -47,8 +62,14 @@ static int mbedtls_rom_mutex_lock( mbedtls_threading_mutex_t *mutex ) static int mbedtls_rom_mutex_unlock( mbedtls_threading_mutex_t *mutex ) { -#if (!defined(CONFIG_MBEDTLS_THREADING_C)) - ((void) mutex); + if (mutex == NULL) { + return MBEDTLS_ERR_THREADING_BAD_INPUT_DATA; + } + +#if defined(MBEDTLS_THREADING_ALT) + if (xSemaphoreGive(mutex->mutex) != pdTRUE) { + return MBEDTLS_ERR_THREADING_MUTEX_ERROR; + } return 0; #else return mbedtls_mutex_unlock(mutex); @@ -81,7 +102,7 @@ static const mbedtls_rom_funcs_t mbedtls_rom_funcs_table = { ._rom_mbedtls_asn1_write_len = mbedtls_asn1_write_len, ._rom_mbedtls_asn1_write_tag = mbedtls_asn1_write_tag, ._rom_mbedtls_asn1_write_mpi = mbedtls_asn1_write_mpi, - /* base64 moudle */ + /* base64 module */ ._rom_mbedtls_base64_decode = mbedtls_base64_decode, /* bignum module */ ._rom_mbedtls_mpi_init = mbedtls_mpi_init, @@ -179,9 +200,269 @@ static const mbedtls_rom_funcs_t mbedtls_rom_funcs_table = { ._mbedtls_internal_sha256_process = mbedtls_internal_sha256_process, }; +/* This structure can be automatically generated by the script with rom.mbedtls.ld. */ +static const mbedtls_rom_eco4_funcs_t mbedtls_rom_eco4_funcs_table = { + /* Fill the ROM functions into mbedtls rom function table. */ + /* aes module */ + ._rom_mbedtls_aes_init = mbedtls_aes_init, + ._rom_mbedtls_aes_free = mbedtls_aes_free, + ._rom_mbedtls_aes_setkey_enc = mbedtls_aes_setkey_enc, + ._rom_mbedtls_aes_setkey_dec = mbedtls_aes_setkey_dec, + ._rom_mbedtls_aes_crypt_ecb = mbedtls_aes_crypt_ecb, + ._rom_mbedtls_aes_crypt_cbc = mbedtls_aes_crypt_cbc, + ._rom_mbedtls_internal_aes_encrypt = mbedtls_internal_aes_encrypt, + ._rom_mbedtls_internal_aes_decrypt = mbedtls_internal_aes_decrypt, + /* asn1 module */ + ._rom_mbedtls_asn1_get_len = mbedtls_asn1_get_len, + ._rom_mbedtls_asn1_get_tag = mbedtls_asn1_get_tag, + ._rom_mbedtls_asn1_get_bool = mbedtls_asn1_get_bool, + ._rom_mbedtls_asn1_get_int = mbedtls_asn1_get_int, + ._rom_mbedtls_asn1_get_bitstring = mbedtls_asn1_get_bitstring, + ._rom_mbedtls_asn1_get_bitstring_null = mbedtls_asn1_get_bitstring_null, + ._rom_mbedtls_asn1_get_sequence_of = mbedtls_asn1_get_sequence_of, + ._rom_mbedtls_asn1_get_mpi = mbedtls_asn1_get_mpi, + ._rom_mbedtls_asn1_get_alg = mbedtls_asn1_get_alg, + ._rom_mbedtls_asn1_get_alg_null = mbedtls_asn1_get_alg_null, + ._rom_mbedtls_asn1_write_len = mbedtls_asn1_write_len, + ._rom_mbedtls_asn1_write_tag = mbedtls_asn1_write_tag, + ._rom_mbedtls_asn1_write_mpi = mbedtls_asn1_write_mpi, + /* base64 module */ + ._rom_mbedtls_base64_decode = mbedtls_base64_decode, + /* bignum module */ + ._rom_mbedtls_mpi_init = mbedtls_mpi_init, + ._rom_mbedtls_mpi_free = mbedtls_mpi_free, + ._rom_mbedtls_mpi_grow = mbedtls_mpi_grow, + ._rom_mbedtls_mpi_shrink = mbedtls_mpi_shrink, + ._rom_mbedtls_mpi_copy = mbedtls_mpi_copy, + ._rom_mbedtls_mpi_safe_cond_assign = mbedtls_mpi_safe_cond_assign, + ._rom_mbedtls_mpi_safe_cond_swap = mbedtls_mpi_safe_cond_swap, + ._rom_mbedtls_mpi_lset = mbedtls_mpi_lset, + ._rom_mbedtls_mpi_get_bit = mbedtls_mpi_get_bit, + ._rom_mbedtls_mpi_set_bit = mbedtls_mpi_set_bit, + ._rom_mbedtls_mpi_lsb = mbedtls_mpi_lsb, + ._rom_mbedtls_mpi_bitlen = mbedtls_mpi_bitlen, + ._rom_mbedtls_mpi_size = mbedtls_mpi_size, + ._rom_mbedtls_mpi_read_binary = mbedtls_mpi_read_binary, + ._rom_mbedtls_mpi_write_binary = mbedtls_mpi_write_binary, + ._rom_mbedtls_mpi_shift_l = mbedtls_mpi_shift_l, + ._rom_mbedtls_mpi_shift_r = mbedtls_mpi_shift_r, + ._rom_mbedtls_mpi_cmp_abs = mbedtls_mpi_cmp_abs, + ._rom_mbedtls_mpi_cmp_mpi = mbedtls_mpi_cmp_mpi, + ._rom_mbedtls_mpi_lt_mpi_ct = mbedtls_mpi_lt_mpi_ct, + ._rom_mbedtls_mpi_cmp_int = mbedtls_mpi_cmp_int, + ._rom_mbedtls_mpi_add_abs = mbedtls_mpi_add_abs, + ._rom_mbedtls_mpi_sub_abs = mbedtls_mpi_sub_abs, + ._rom_mbedtls_mpi_add_mpi = mbedtls_mpi_add_mpi, + ._rom_mbedtls_mpi_sub_mpi = mbedtls_mpi_sub_mpi, + ._rom_mbedtls_mpi_add_int = mbedtls_mpi_add_int, + ._rom_mbedtls_mpi_sub_int = mbedtls_mpi_sub_int, + ._rom_mbedtls_mpi_mul_mpi = mbedtls_mpi_mul_mpi, + ._rom_mbedtls_mpi_mul_int = mbedtls_mpi_mul_int, + ._rom_mbedtls_mpi_div_mpi = mbedtls_mpi_div_mpi, + ._rom_mbedtls_mpi_div_int = mbedtls_mpi_div_int, + ._rom_mbedtls_mpi_mod_mpi = mbedtls_mpi_mod_mpi, + ._rom_mbedtls_mpi_mod_int = mbedtls_mpi_mod_int, + ._rom_mbedtls_mpi_exp_mod = mbedtls_mpi_exp_mod, + ._rom_mbedtls_mpi_fill_random = mbedtls_mpi_fill_random, + ._rom_mbedtls_mpi_gcd = mbedtls_mpi_gcd, + ._rom_mbedtls_mpi_inv_mod = mbedtls_mpi_inv_mod, + ._rom_mbedtls_mpi_is_prime_ext = mbedtls_mpi_is_prime_ext, + /* ccm module */ + ._rom_mbedtls_ccm_star_encrypt_and_tag = mbedtls_ccm_star_encrypt_and_tag, + ._rom_mbedtls_ccm_star_auth_decrypt = mbedtls_ccm_star_auth_decrypt, + /* cipher module */ + ._rom_mbedtls_cipher_init = mbedtls_cipher_init, + ._rom_mbedtls_cipher_set_padding_mode = mbedtls_cipher_set_padding_mode, + ._rom_mbedtls_cipher_reset = mbedtls_cipher_reset, + ._rom_mbedtls_cipher_finish = mbedtls_cipher_finish, + ._rom_mbedtls_cipher_crypt = mbedtls_cipher_crypt, + ._rom_mbedtls_cipher_cmac_starts = mbedtls_cipher_cmac_starts, + ._rom_mbedtls_cipher_cmac_update = mbedtls_cipher_cmac_update, + ._rom_mbedtls_cipher_cmac_finish = mbedtls_cipher_cmac_finish, + /* ctr drbg module */ + ._rom_mbedtls_ctr_drbg_init = mbedtls_ctr_drbg_init, + ._rom_mbedtls_ctr_drbg_seed = mbedtls_ctr_drbg_seed, + ._rom_mbedtls_ctr_drbg_free = mbedtls_ctr_drbg_free, + ._rom_mbedtls_ctr_drbg_reseed = mbedtls_ctr_drbg_reseed, + ._rom_mbedtls_ctr_drbg_random_with_add = mbedtls_ctr_drbg_random_with_add, + ._rom_mbedtls_ctr_drbg_random = mbedtls_ctr_drbg_random, + /* sha1 module */ + ._rom_mbedtls_sha1_init = mbedtls_sha1_init, + ._rom_mbedtls_sha1_free = mbedtls_sha1_free, + ._rom_mbedtls_sha1_clone = mbedtls_sha1_clone, + ._rom_mbedtls_sha1_starts = mbedtls_sha1_starts, + ._rom_mbedtls_sha1_finish = mbedtls_sha1_finish, + /* sha256 module */ + ._rom_mbedtls_sha256_init = mbedtls_sha256_init, + ._rom_mbedtls_sha256_free = mbedtls_sha256_free, + ._rom_mbedtls_sha256_clone = mbedtls_sha256_clone, + ._rom_mbedtls_sha256_starts = mbedtls_sha256_starts, + ._rom_mbedtls_sha256_finish = mbedtls_sha256_finish, + ._rom_mbedtls_sha256 = mbedtls_sha256, + /* sha512 module */ + ._rom_mbedtls_sha512_init = mbedtls_sha512_init, + ._rom_mbedtls_sha512_free = mbedtls_sha512_free, + ._rom_mbedtls_sha512_clone = mbedtls_sha512_clone, + ._rom_mbedtls_sha512_starts = mbedtls_sha512_starts, + ._rom_mbedtls_sha512_update = mbedtls_sha512_update, + ._rom_mbedtls_sha512_finish = mbedtls_sha512_finish, + //._rom_mbedtls_internal_sha512_process = mbedtls_internal_sha512_process, + ._rom_mbedtls_sha512 = mbedtls_sha512, + + ._rom_mbedtls_aes_xts_init = mbedtls_aes_xts_init, + ._rom_mbedtls_aes_xts_free = mbedtls_aes_xts_free, + ._rom_mbedtls_aes_xts_setkey_enc = mbedtls_aes_xts_setkey_enc, + ._rom_mbedtls_aes_xts_setkey_dec = mbedtls_aes_xts_setkey_dec, + ._rom_mbedtls_aes_crypt_xts = mbedtls_aes_crypt_xts, + ._rom_mbedtls_aes_crypt_cfb128 = mbedtls_aes_crypt_cfb128, + ._rom_mbedtls_aes_crypt_ofb = mbedtls_aes_crypt_ofb, + ._rom_mbedtls_aes_crypt_ctr = mbedtls_aes_crypt_ctr, + ._rom_mbedtls_ccm_init = mbedtls_ccm_init, + ._rom_mbedtls_ccm_setkey = mbedtls_ccm_setkey, + ._rom_mbedtls_ccm_free = mbedtls_ccm_free, + ._rom_mbedtls_ccm_encrypt_and_tag = mbedtls_ccm_encrypt_and_tag, + ._rom_mbedtls_ccm_auth_decrypt = mbedtls_ccm_auth_decrypt, + ._rom_mbedtls_md5_init = mbedtls_md5_init, + ._rom_mbedtls_md5_free = mbedtls_md5_free, + ._rom_mbedtls_md5_clone = mbedtls_md5_clone, + ._rom_mbedtls_md5_starts = mbedtls_md5_starts, + ._rom_mbedtls_md5_update = mbedtls_md5_update, + ._rom_mbedtls_md5_finish = mbedtls_md5_finish, + ._rom_mbedtls_md5 = mbedtls_md5, + ._rom_mbedtls_sha1 = mbedtls_sha1, + + // eco4 rom mbedtls functions + ._rom_mbedtls_aes_crypt_cfb8 = mbedtls_aes_crypt_cfb8, + ._rom_mbedtls_mpi_swap = mbedtls_mpi_swap, + ._rom_mbedtls_mpi_read_string = mbedtls_mpi_read_string, + ._rom_mbedtls_mpi_write_string = mbedtls_mpi_write_string, + ._rom_mbedtls_mpi_read_binary_le = mbedtls_mpi_read_binary_le, + ._rom_mbedtls_mpi_write_binary_le = mbedtls_mpi_write_binary_le, + ._rom_mbedtls_mpi_random = mbedtls_mpi_random, + ._rom_mbedtls_mpi_gen_prime = mbedtls_mpi_gen_prime, + ._rom_mbedtls_ecp_check_budget = mbedtls_ecp_check_budget, + ._rom_mbedtls_ecp_set_max_ops = mbedtls_ecp_set_max_ops, + ._rom_mbedtls_ecp_restart_is_enabled = mbedtls_ecp_restart_is_enabled, + ._rom_mbedtls_ecp_get_type = mbedtls_ecp_get_type, + ._rom_mbedtls_ecp_curve_list = mbedtls_ecp_curve_list, + ._rom_mbedtls_ecp_grp_id_list = mbedtls_ecp_grp_id_list, + ._rom_mbedtls_ecp_curve_info_from_grp_id = mbedtls_ecp_curve_info_from_grp_id, + ._rom_mbedtls_ecp_curve_info_from_tls_id = mbedtls_ecp_curve_info_from_tls_id, + ._rom_mbedtls_ecp_curve_info_from_name = mbedtls_ecp_curve_info_from_name, + ._rom_mbedtls_ecp_point_init = mbedtls_ecp_point_init, + ._rom_mbedtls_ecp_group_init = mbedtls_ecp_group_init, + ._rom_mbedtls_ecp_keypair_init = mbedtls_ecp_keypair_init, + ._rom_mbedtls_ecp_point_free = mbedtls_ecp_point_free, + ._rom_mbedtls_ecp_group_free = mbedtls_ecp_group_free, + ._rom_mbedtls_ecp_keypair_free = mbedtls_ecp_keypair_free, + ._rom_mbedtls_ecp_restart_init = mbedtls_ecp_restart_init, + ._rom_mbedtls_ecp_restart_free = mbedtls_ecp_restart_free, + ._rom_mbedtls_ecp_copy = mbedtls_ecp_copy, + ._rom_mbedtls_ecp_group_copy = mbedtls_ecp_group_copy, + ._rom_mbedtls_ecp_set_zero = mbedtls_ecp_set_zero, + ._rom_mbedtls_ecp_is_zero = mbedtls_ecp_is_zero, + ._rom_mbedtls_ecp_point_cmp = mbedtls_ecp_point_cmp, + ._rom_mbedtls_ecp_point_read_string = mbedtls_ecp_point_read_string, + ._rom_mbedtls_ecp_point_write_binary = mbedtls_ecp_point_write_binary, + ._rom_mbedtls_ecp_point_read_binary = mbedtls_ecp_point_read_binary, + ._rom_mbedtls_ecp_tls_read_point = mbedtls_ecp_tls_read_point, + ._rom_mbedtls_ecp_tls_write_point = mbedtls_ecp_tls_write_point, + ._rom_mbedtls_ecp_group_load = mbedtls_ecp_group_load, + ._rom_mbedtls_ecp_tls_read_group = mbedtls_ecp_tls_read_group, + ._rom_mbedtls_ecp_tls_read_group_id = mbedtls_ecp_tls_read_group_id, + ._rom_mbedtls_ecp_tls_write_group = mbedtls_ecp_tls_write_group, + ._rom_mbedtls_ecp_mul = mbedtls_ecp_mul, + ._rom_mbedtls_ecp_mul_restartable = mbedtls_ecp_mul_restartable, + ._rom_mbedtls_ecp_muladd = mbedtls_ecp_muladd, + ._rom_mbedtls_ecp_muladd_restartable = mbedtls_ecp_muladd_restartable, + ._rom_mbedtls_ecp_check_pubkey = mbedtls_ecp_check_pubkey, + ._rom_mbedtls_ecp_check_privkey = mbedtls_ecp_check_privkey, + ._rom_mbedtls_ecp_gen_privkey = mbedtls_ecp_gen_privkey, + ._rom_mbedtls_ecp_gen_keypair_base = mbedtls_ecp_gen_keypair_base, + ._rom_mbedtls_ecp_gen_keypair = mbedtls_ecp_gen_keypair, + ._rom_mbedtls_ecp_gen_key = mbedtls_ecp_gen_key, + ._rom_mbedtls_ecp_read_key = mbedtls_ecp_read_key, + ._rom_mbedtls_ecp_write_key_ext = mbedtls_ecp_write_key_ext, + ._rom_mbedtls_ecp_check_pub_priv = mbedtls_ecp_check_pub_priv, + ._rom_mbedtls_ecp_export = mbedtls_ecp_export, + ._rom_mbedtls_asn1_get_enum = mbedtls_asn1_get_enum, + ._rom_mbedtls_asn1_sequence_free = mbedtls_asn1_sequence_free, + ._rom_mbedtls_asn1_traverse_sequence_of = mbedtls_asn1_traverse_sequence_of, + ._rom_mbedtls_asn1_find_named_data = mbedtls_asn1_find_named_data, + ._rom_mbedtls_asn1_free_named_data_list = mbedtls_asn1_free_named_data_list, + ._rom_mbedtls_asn1_free_named_data_list_shallow = mbedtls_asn1_free_named_data_list_shallow, + ._rom_mbedtls_asn1_write_raw_buffer = mbedtls_asn1_write_raw_buffer, + ._rom_mbedtls_asn1_write_null = mbedtls_asn1_write_null, + ._rom_mbedtls_asn1_write_oid = mbedtls_asn1_write_oid, + ._rom_mbedtls_asn1_write_algorithm_identifier = mbedtls_asn1_write_algorithm_identifier, + ._rom_mbedtls_asn1_write_bool = mbedtls_asn1_write_bool, + ._rom_mbedtls_asn1_write_int = mbedtls_asn1_write_int, + ._rom_mbedtls_asn1_write_enum = mbedtls_asn1_write_enum, + ._rom_mbedtls_asn1_write_tagged_string = mbedtls_asn1_write_tagged_string, + ._rom_mbedtls_asn1_write_printable_string = mbedtls_asn1_write_printable_string, + ._rom_mbedtls_asn1_write_utf8_string = mbedtls_asn1_write_utf8_string, + ._rom_mbedtls_asn1_write_ia5_string = mbedtls_asn1_write_ia5_string, + ._rom_mbedtls_asn1_write_bitstring = mbedtls_asn1_write_bitstring, + ._rom_mbedtls_asn1_write_named_bitstring = mbedtls_asn1_write_named_bitstring, + ._rom_mbedtls_asn1_write_octet_string = mbedtls_asn1_write_octet_string, + ._rom_mbedtls_asn1_store_named_data = mbedtls_asn1_store_named_data, + ._rom_mbedtls_ccm_starts = mbedtls_ccm_starts, + ._rom_mbedtls_ccm_set_lengths = mbedtls_ccm_set_lengths, + ._rom_mbedtls_ccm_update_ad = mbedtls_ccm_update_ad, + ._rom_mbedtls_ccm_update = mbedtls_ccm_update, + ._rom_mbedtls_ccm_finish = mbedtls_ccm_finish, + ._rom_mbedtls_cipher_list = mbedtls_cipher_list, + ._rom_mbedtls_cipher_info_from_string = mbedtls_cipher_info_from_string, + ._rom_mbedtls_cipher_info_from_type = mbedtls_cipher_info_from_type, + ._rom_mbedtls_cipher_info_from_values = mbedtls_cipher_info_from_values, + ._rom_mbedtls_cipher_free = mbedtls_cipher_free, + ._rom_mbedtls_cipher_setup = mbedtls_cipher_setup, + ._rom_mbedtls_cipher_setkey = mbedtls_cipher_setkey, + ._rom_mbedtls_cipher_set_iv = mbedtls_cipher_set_iv, + ._rom_mbedtls_cipher_update_ad = mbedtls_cipher_update_ad, + ._rom_mbedtls_cipher_update = mbedtls_cipher_update, + ._rom_mbedtls_cipher_write_tag = mbedtls_cipher_write_tag, + ._rom_mbedtls_cipher_check_tag = mbedtls_cipher_check_tag, + ._rom_mbedtls_cipher_auth_encrypt_ext = mbedtls_cipher_auth_encrypt_ext, + ._rom_mbedtls_cipher_auth_decrypt_ext = mbedtls_cipher_auth_decrypt_ext, + ._rom_mbedtls_cipher_cmac_reset = mbedtls_cipher_cmac_reset, + ._rom_mbedtls_cipher_cmac = mbedtls_cipher_cmac, + ._rom_mbedtls_aes_cmac_prf_128 = mbedtls_aes_cmac_prf_128, + ._rom_mbedtls_ctr_drbg_set_prediction_resistance = mbedtls_ctr_drbg_set_prediction_resistance, + ._rom_mbedtls_ctr_drbg_set_entropy_len = mbedtls_ctr_drbg_set_entropy_len, + ._rom_mbedtls_ctr_drbg_set_nonce_len = mbedtls_ctr_drbg_set_nonce_len, + ._rom_mbedtls_ctr_drbg_set_reseed_interval = mbedtls_ctr_drbg_set_reseed_interval, + ._rom_mbedtls_ctr_drbg_update = mbedtls_ctr_drbg_update, + ._rom_mbedtls_base64_encode = mbedtls_base64_encode, + + /* Fill the SHA hardware functions into mbedtls rom function table */ + ._rom_mbedtls_sha1_update = mbedtls_sha1_update, + ._rom_mbedtls_sha256_update = mbedtls_sha256_update, + + //memory calloc free + ._rom_mbedtls_mem_calloc = MBEDTLS_PLATFORM_STD_CALLOC, + ._rom_mbedtls_mem_free = MBEDTLS_PLATFORM_STD_FREE, +}; + __attribute__((constructor)) void mbedtls_rom_osi_functions_init(void) { - /* Initialize the pointer of mbedtls rom osi function table. */ - extern mbedtls_rom_funcs_t *mbedtls_rom_osi_funcs_ptr; - mbedtls_rom_osi_funcs_ptr = (mbedtls_rom_funcs_t *)&mbedtls_rom_funcs_table; + /* Export the rom mbedtls functions table pointer */ + extern void *mbedtls_rom_osi_funcs_ptr; + +#if defined(MBEDTLS_THREADING_ALT) + mbedtls_threading_set_alt(mbedtls_rom_mutex_init, mbedtls_rom_mutex_free, mbedtls_rom_mutex_lock, mbedtls_rom_mutex_unlock); +#endif + + unsigned chip_version = efuse_hal_chip_revision(); + if ( ESP_CHIP_REV_ABOVE(chip_version, 200) ) { + /* Initialize the rom function mbedtls_threading_set_alt on chip rev2.0 with rom eco4 */ + _rom_mbedtls_threading_set_alt_t rom_mbedtls_threading_set_alt = (_rom_mbedtls_threading_set_alt_t)0x40002c0c; + rom_mbedtls_threading_set_alt(mbedtls_rom_mutex_init, mbedtls_rom_mutex_free, mbedtls_rom_mutex_lock, mbedtls_rom_mutex_unlock); + + /* Initialize the pointer of rom eco4 mbedtls functions table. */ + mbedtls_rom_osi_funcs_ptr = (mbedtls_rom_eco4_funcs_t *)&mbedtls_rom_eco4_funcs_table; + } else { + /* Initialize the pointer of rom mbedtls functions table. */ + mbedtls_rom_osi_funcs_ptr = (mbedtls_rom_funcs_t *)&mbedtls_rom_funcs_table; + } } diff --git a/components/mbedtls/port/mbedtls_rom/mbedtls_rom_osi.h b/components/mbedtls/port/mbedtls_rom/mbedtls_rom_osi.h index 42dddc325c..b612adfa55 100644 --- a/components/mbedtls/port/mbedtls_rom/mbedtls_rom_osi.h +++ b/components/mbedtls/port/mbedtls_rom/mbedtls_rom_osi.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -23,6 +23,7 @@ #include "mbedtls/entropy.h" #include "mbedtls/hmac_drbg.h" #include "mbedtls/md.h" +#include "mbedtls/md5.h" #include "mbedtls/oid.h" #include "mbedtls/pem.h" #include "mbedtls/pkcs12.h" @@ -43,11 +44,14 @@ extern "C" { #endif #if (!defined(CONFIG_MBEDTLS_THREADING_C)) -typedef struct mbedtls_threading_mutex_t { - int dummy; -} mbedtls_threading_mutex_t; +#error CONFIG_MBEDTLS_THREADING_C #endif +typedef void (*_rom_mbedtls_threading_set_alt_t)(void (*mutex_init)(mbedtls_threading_mutex_t *), + void (*mutex_free)(mbedtls_threading_mutex_t *), + int (*mutex_lock)(mbedtls_threading_mutex_t *), + int (*mutex_unlock)(mbedtls_threading_mutex_t *)); + typedef struct mbedtls_rom_funcs { void (*_rom_mbedtls_aes_init)( mbedtls_aes_context *ctx ); int (*_rom_ssl_write_client_hello)( mbedtls_ssl_context *ssl ); @@ -404,6 +408,254 @@ typedef struct mbedtls_rom_funcs { int (*_mbedtls_x509_time_is_future)( const mbedtls_x509_time *from ); } mbedtls_rom_funcs_t; +typedef struct mbedtls_rom_eco4_funcs { + // aes module + void (*_rom_mbedtls_aes_init)(mbedtls_aes_context *ctx); + void (*_rom_mbedtls_aes_free)(mbedtls_aes_context *ctx); + void (*_rom_mbedtls_aes_xts_init)(mbedtls_aes_xts_context *ctx); + void (*_rom_mbedtls_aes_xts_free)(mbedtls_aes_xts_context *ctx); + int (*_rom_mbedtls_aes_setkey_enc)(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits); + int (*_rom_mbedtls_aes_setkey_dec)(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits); + int (*_rom_mbedtls_aes_xts_setkey_enc)(mbedtls_aes_xts_context *ctx, const unsigned char *key, unsigned int keybits); + int (*_rom_mbedtls_aes_xts_setkey_dec)(mbedtls_aes_xts_context *ctx, const unsigned char *key, unsigned int keybits); + int (*_rom_mbedtls_aes_crypt_ecb)(mbedtls_aes_context *ctx, int mode, const unsigned char input[16], unsigned char output[16]); + int (*_rom_mbedtls_aes_crypt_cbc)(mbedtls_aes_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output); + int (*_rom_mbedtls_aes_crypt_xts)(mbedtls_aes_xts_context *ctx, int mode, size_t length, const unsigned char data_unit[16], const unsigned char *input, unsigned char *output); + int (*_rom_mbedtls_aes_crypt_cfb128)(mbedtls_aes_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[16], const unsigned char *input, unsigned char *output); + int (*_rom_mbedtls_aes_crypt_ofb)(mbedtls_aes_context *ctx, size_t length, size_t *iv_off, unsigned char iv[16], const unsigned char *input, unsigned char *output); + int (*_rom_mbedtls_aes_crypt_ctr)(mbedtls_aes_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[16], unsigned char stream_block[16], const unsigned char *input, unsigned char *output); + int (*_rom_mbedtls_internal_aes_encrypt)(mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16]); + int (*_rom_mbedtls_internal_aes_decrypt)(mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16]); + // md5 module + void (*_rom_mbedtls_md5_init)(mbedtls_md5_context *ctx); + void (*_rom_mbedtls_md5_free)(mbedtls_md5_context *ctx); + void (*_rom_mbedtls_md5_clone)(mbedtls_md5_context *dst, const mbedtls_md5_context *src); + int (*_rom_mbedtls_md5_starts)(mbedtls_md5_context *ctx); + int (*_rom_mbedtls_md5_update)(mbedtls_md5_context *ctx, const unsigned char *input, size_t ilen); + int (*_rom_mbedtls_md5_finish)(mbedtls_md5_context *ctx, unsigned char output[16]); + int (*_rom_mbedtls_md5)(const unsigned char *input, size_t ilen, unsigned char output[16]); + // bignum module + void (*_rom_mbedtls_mpi_init)(mbedtls_mpi *X); + void (*_rom_mbedtls_mpi_free)(mbedtls_mpi *X); + int (*_rom_mbedtls_mpi_grow)(mbedtls_mpi *X, size_t nblimbs); + int (*_rom_mbedtls_mpi_shrink)(mbedtls_mpi *X, size_t nblimbs); + int (*_rom_mbedtls_mpi_copy)(mbedtls_mpi *X, const mbedtls_mpi *Y); + int (*_rom_mbedtls_mpi_safe_cond_assign)(mbedtls_mpi *X, const mbedtls_mpi *Y, unsigned char assign); + int (*_rom_mbedtls_mpi_safe_cond_swap)(mbedtls_mpi *X, mbedtls_mpi *Y, unsigned char swap); + int (*_rom_mbedtls_mpi_lset)(mbedtls_mpi *X, mbedtls_mpi_sint z); + int (*_rom_mbedtls_mpi_get_bit)(const mbedtls_mpi *X, size_t pos); + int (*_rom_mbedtls_mpi_set_bit)(mbedtls_mpi *X, size_t pos, unsigned char val); + size_t (*_rom_mbedtls_mpi_lsb)(const mbedtls_mpi *X); + size_t (*_rom_mbedtls_mpi_bitlen)(const mbedtls_mpi *X); + size_t (*_rom_mbedtls_mpi_size)(const mbedtls_mpi *X); + int (*_rom_mbedtls_mpi_read_binary)(mbedtls_mpi *X, const unsigned char *buf, size_t buflen); + int (*_rom_mbedtls_mpi_write_binary)(const mbedtls_mpi *X, unsigned char *buf, size_t buflen); + int (*_rom_mbedtls_mpi_shift_l)(mbedtls_mpi *X, size_t count); + int (*_rom_mbedtls_mpi_shift_r)(mbedtls_mpi *X, size_t count); + int (*_rom_mbedtls_mpi_cmp_abs)(const mbedtls_mpi *X, const mbedtls_mpi *Y); + int (*_rom_mbedtls_mpi_cmp_mpi)(const mbedtls_mpi *X, const mbedtls_mpi *Y); + int (*_rom_mbedtls_mpi_lt_mpi_ct)(const mbedtls_mpi *X, const mbedtls_mpi *Y, unsigned *ret); + int (*_rom_mbedtls_mpi_cmp_int)(const mbedtls_mpi *X, mbedtls_mpi_sint z); + int (*_rom_mbedtls_mpi_add_abs)(mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B); + int (*_rom_mbedtls_mpi_sub_abs)(mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B); + int (*_rom_mbedtls_mpi_add_mpi)(mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B); + int (*_rom_mbedtls_mpi_sub_mpi)(mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B); + int (*_rom_mbedtls_mpi_add_int)(mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint b); + int (*_rom_mbedtls_mpi_sub_int)(mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint b); + int (*_rom_mbedtls_mpi_mul_mpi)(mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B); + int (*_rom_mbedtls_mpi_mul_int)(mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_uint b); + int (*_rom_mbedtls_mpi_div_mpi)(mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, const mbedtls_mpi *B); + int (*_rom_mbedtls_mpi_div_int)(mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, mbedtls_mpi_sint b); + int (*_rom_mbedtls_mpi_mod_mpi)(mbedtls_mpi *R, const mbedtls_mpi *A, const mbedtls_mpi *B); + int (*_rom_mbedtls_mpi_mod_int)(mbedtls_mpi_uint *r, const mbedtls_mpi *A, mbedtls_mpi_sint b); + int (*_rom_mbedtls_mpi_exp_mod)(mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *E, const mbedtls_mpi *N, mbedtls_mpi *prec_RR); + int (*_rom_mbedtls_mpi_fill_random)(mbedtls_mpi *X, size_t size, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng); + int (*_rom_mbedtls_mpi_gcd)(mbedtls_mpi *G, const mbedtls_mpi *A, const mbedtls_mpi *B); + int (*_rom_mbedtls_mpi_inv_mod)(mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *N); + int (*_rom_mbedtls_mpi_is_prime_ext)(const mbedtls_mpi *X, int rounds, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng); + // sha1 sha256 sha512 module + void (*_rom_mbedtls_sha1_init)(mbedtls_sha1_context *ctx); + void (*_rom_mbedtls_sha1_free)(mbedtls_sha1_context *ctx); + void (*_rom_mbedtls_sha1_clone)(mbedtls_sha1_context *dst, const mbedtls_sha1_context *src); + int (*_rom_mbedtls_sha1_starts)(mbedtls_sha1_context *ctx); + int (*_rom_mbedtls_sha1_finish)(mbedtls_sha1_context *ctx, unsigned char output[20]); + int (*_rom_mbedtls_sha1)(const unsigned char *input, size_t ilen, unsigned char output[20]); + void (*_rom_mbedtls_sha256_init)(mbedtls_sha256_context *ctx); + void (*_rom_mbedtls_sha256_free)(mbedtls_sha256_context *ctx); + void (*_rom_mbedtls_sha256_clone)(mbedtls_sha256_context *dst, const mbedtls_sha256_context *src); + int (*_rom_mbedtls_sha256_starts)(mbedtls_sha256_context *ctx, int is224); + int (*_rom_mbedtls_sha256_finish)(mbedtls_sha256_context *ctx, unsigned char *output); + int (*_rom_mbedtls_sha256)(const unsigned char *input, size_t ilen, unsigned char *output, int is224); + void (*_rom_mbedtls_sha512_init)(mbedtls_sha512_context *ctx); + void (*_rom_mbedtls_sha512_free)(mbedtls_sha512_context *ctx); + void (*_rom_mbedtls_sha512_clone)(mbedtls_sha512_context *dst, const mbedtls_sha512_context *src); + int (*_rom_mbedtls_sha512_starts)(mbedtls_sha512_context *ctx, int is384); + int (*_rom_mbedtls_sha512_update)(mbedtls_sha512_context *ctx, const unsigned char *input, size_t ilen); + int (*_rom_mbedtls_sha512_finish)(mbedtls_sha512_context *ctx, unsigned char *output); + int (*_rom_mbedtls_sha512)(const unsigned char *input, size_t ilen, unsigned char *output, int is384); + // ecp module + // asn1 module + int (*_rom_mbedtls_asn1_get_len)(unsigned char **p, const unsigned char *end, size_t *len); + int (*_rom_mbedtls_asn1_get_tag)(unsigned char **p, const unsigned char *end, size_t *len, int tag); + int (*_rom_mbedtls_asn1_get_bool)(unsigned char **p, const unsigned char *end, int *val); + int (*_rom_mbedtls_asn1_get_int)(unsigned char **p, const unsigned char *end, int *val); + int (*_rom_mbedtls_asn1_get_bitstring)(unsigned char **p, const unsigned char *end, mbedtls_asn1_bitstring *bs); + int (*_rom_mbedtls_asn1_get_bitstring_null)(unsigned char **p, const unsigned char *end, size_t *len); + int (*_rom_mbedtls_asn1_get_sequence_of)(unsigned char **p, const unsigned char *end, mbedtls_asn1_sequence *cur, int tag); + int (*_rom_mbedtls_asn1_get_mpi)(unsigned char **p, const unsigned char *end, mbedtls_mpi *X); + int (*_rom_mbedtls_asn1_get_alg)(unsigned char **p, const unsigned char *end, mbedtls_asn1_buf *alg, mbedtls_asn1_buf *params); + int (*_rom_mbedtls_asn1_get_alg_null)(unsigned char **p, const unsigned char *end, mbedtls_asn1_buf *alg); + // asn1write module + int (*_rom_mbedtls_asn1_write_len)(unsigned char **p, const unsigned char *start, size_t len); + int (*_rom_mbedtls_asn1_write_tag)(unsigned char **p, const unsigned char *start, unsigned char tag); + int (*_rom_mbedtls_asn1_write_mpi)(unsigned char **p, const unsigned char *start, const mbedtls_mpi *X); + // ccm module + void (*_rom_mbedtls_ccm_init)(mbedtls_ccm_context *ctx); + int (*_rom_mbedtls_ccm_setkey)(mbedtls_ccm_context *ctx, mbedtls_cipher_id_t cipher, const unsigned char *key, unsigned int keybits); + void (*_rom_mbedtls_ccm_free)(mbedtls_ccm_context *ctx); + int (*_rom_mbedtls_ccm_encrypt_and_tag)(mbedtls_ccm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *ad, size_t ad_len, const unsigned char *input, unsigned char *output, unsigned char *tag, size_t tag_len); + int (*_rom_mbedtls_ccm_star_encrypt_and_tag)(mbedtls_ccm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *ad, size_t ad_len, const unsigned char *input, unsigned char *output, unsigned char *tag, size_t tag_len); + int (*_rom_mbedtls_ccm_auth_decrypt)(mbedtls_ccm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *ad, size_t ad_len, const unsigned char *input, unsigned char *output, const unsigned char *tag, size_t tag_len); + int (*_rom_mbedtls_ccm_star_auth_decrypt)(mbedtls_ccm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *ad, size_t ad_len, const unsigned char *input, unsigned char *output, const unsigned char *tag, size_t tag_len); + // cipher module + void (*_rom_mbedtls_cipher_init)(mbedtls_cipher_context_t *ctx); + int (*_rom_mbedtls_cipher_set_padding_mode)(mbedtls_cipher_context_t *ctx, mbedtls_cipher_padding_t mode); + int (*_rom_mbedtls_cipher_reset)(mbedtls_cipher_context_t *ctx); + int (*_rom_mbedtls_cipher_finish)(mbedtls_cipher_context_t *ctx, unsigned char *output, size_t *olen); + int (*_rom_mbedtls_cipher_crypt)(mbedtls_cipher_context_t *ctx, const unsigned char *iv, size_t iv_len, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen); + int (*_rom_mbedtls_cipher_cmac_starts)(mbedtls_cipher_context_t *ctx, const unsigned char *key, size_t keybits); + int (*_rom_mbedtls_cipher_cmac_update)(mbedtls_cipher_context_t *ctx, const unsigned char *input, size_t ilen); + int (*_rom_mbedtls_cipher_cmac_finish)(mbedtls_cipher_context_t *ctx, unsigned char *output); + // ctr drbg module + void (*_rom_mbedtls_ctr_drbg_init)(mbedtls_ctr_drbg_context *ctx); + int (*_rom_mbedtls_ctr_drbg_seed)(mbedtls_ctr_drbg_context *ctx, int (*f_entropy)(void *, unsigned char *, size_t), void *p_entropy, const unsigned char *custom, size_t len); + void (*_rom_mbedtls_ctr_drbg_free)(mbedtls_ctr_drbg_context *ctx); + int (*_rom_mbedtls_ctr_drbg_reseed)(mbedtls_ctr_drbg_context *ctx, const unsigned char *additional, size_t len); + int (*_rom_mbedtls_ctr_drbg_random_with_add)(void *p_rng, unsigned char *output, size_t output_len, const unsigned char *additional, size_t add_len); + int (*_rom_mbedtls_ctr_drbg_random)(void *p_rng, unsigned char *output, size_t output_len); + // base64 module + int (*_rom_mbedtls_base64_decode)(unsigned char *dst, size_t dlen, size_t *olen, const unsigned char *src, size_t slen); + //*******************************************************************************************************************************************************************// + // aes module + int (*_rom_mbedtls_aes_crypt_cfb8)(mbedtls_aes_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output); + // md5 module + // bignum module + void (*_rom_mbedtls_mpi_swap)(mbedtls_mpi *X, mbedtls_mpi *Y); + int (*_rom_mbedtls_mpi_read_string)(mbedtls_mpi *X, int radix, const char *s); + int (*_rom_mbedtls_mpi_write_string)(const mbedtls_mpi *X, int radix, char *buf, size_t buflen, size_t *olen); + int (*_rom_mbedtls_mpi_read_binary_le)(mbedtls_mpi *X, const unsigned char *buf, size_t buflen); + int (*_rom_mbedtls_mpi_write_binary_le)(const mbedtls_mpi *X, unsigned char *buf, size_t buflen); + int (*_rom_mbedtls_mpi_random)(mbedtls_mpi *X, mbedtls_mpi_sint min, const mbedtls_mpi *N, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng); + int (*_rom_mbedtls_mpi_gen_prime)(mbedtls_mpi *X, size_t nbits, int flags, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng); + // ecp module + int (*_rom_mbedtls_ecp_check_budget)(const mbedtls_ecp_group *grp, mbedtls_ecp_restart_ctx *rs_ctx, unsigned ops); + void (*_rom_mbedtls_ecp_set_max_ops)(unsigned max_ops); + int (*_rom_mbedtls_ecp_restart_is_enabled)(void); + mbedtls_ecp_curve_type (*_rom_mbedtls_ecp_get_type)(const mbedtls_ecp_group *grp); + const mbedtls_ecp_curve_info *(*_rom_mbedtls_ecp_curve_list)(void); + const mbedtls_ecp_group_id *(*_rom_mbedtls_ecp_grp_id_list)(void); + const mbedtls_ecp_curve_info *(*_rom_mbedtls_ecp_curve_info_from_grp_id)(mbedtls_ecp_group_id grp_id); + const mbedtls_ecp_curve_info *(*_rom_mbedtls_ecp_curve_info_from_tls_id)(uint16_t tls_id); + const mbedtls_ecp_curve_info *(*_rom_mbedtls_ecp_curve_info_from_name)(const char *name); + void (*_rom_mbedtls_ecp_point_init)(mbedtls_ecp_point *pt); + void (*_rom_mbedtls_ecp_group_init)(mbedtls_ecp_group *grp); + void (*_rom_mbedtls_ecp_keypair_init)(mbedtls_ecp_keypair *key); + void (*_rom_mbedtls_ecp_point_free)(mbedtls_ecp_point *pt); + void (*_rom_mbedtls_ecp_group_free)(mbedtls_ecp_group *grp); + void (*_rom_mbedtls_ecp_keypair_free)(mbedtls_ecp_keypair *key); + void (*_rom_mbedtls_ecp_restart_init)(mbedtls_ecp_restart_ctx *ctx); + void (*_rom_mbedtls_ecp_restart_free)(mbedtls_ecp_restart_ctx *ctx); + int (*_rom_mbedtls_ecp_copy)(mbedtls_ecp_point *P, const mbedtls_ecp_point *Q); + int (*_rom_mbedtls_ecp_group_copy)(mbedtls_ecp_group *dst, const mbedtls_ecp_group *src); + int (*_rom_mbedtls_ecp_set_zero)(mbedtls_ecp_point *pt); + int (*_rom_mbedtls_ecp_is_zero)(mbedtls_ecp_point *pt); + int (*_rom_mbedtls_ecp_point_cmp)(const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q); + int (*_rom_mbedtls_ecp_point_read_string)(mbedtls_ecp_point *P, int radix, const char *x, const char *y); + int (*_rom_mbedtls_ecp_point_write_binary)(const mbedtls_ecp_group *grp, const mbedtls_ecp_point *P, int format, size_t *olen, unsigned char *buf, size_t buflen); + int (*_rom_mbedtls_ecp_point_read_binary)(const mbedtls_ecp_group *grp, mbedtls_ecp_point *P, const unsigned char *buf, size_t ilen); + int (*_rom_mbedtls_ecp_tls_read_point)(const mbedtls_ecp_group *grp, mbedtls_ecp_point *pt, const unsigned char **buf, size_t len); + int (*_rom_mbedtls_ecp_tls_write_point)(const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt, int format, size_t *olen, unsigned char *buf, size_t blen); + int (*_rom_mbedtls_ecp_group_load)(mbedtls_ecp_group *grp, mbedtls_ecp_group_id id); + int (*_rom_mbedtls_ecp_tls_read_group)(mbedtls_ecp_group *grp, const unsigned char **buf, size_t len); + int (*_rom_mbedtls_ecp_tls_read_group_id)(mbedtls_ecp_group_id *grp, const unsigned char **buf, size_t len); + int (*_rom_mbedtls_ecp_tls_write_group)(const mbedtls_ecp_group *grp, size_t *olen, unsigned char *buf, size_t blen); + int (*_rom_mbedtls_ecp_mul)(mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_mpi *m, const mbedtls_ecp_point *P, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng); + int (*_rom_mbedtls_ecp_mul_restartable)(mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_mpi *m, const mbedtls_ecp_point *P, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, mbedtls_ecp_restart_ctx *rs_ctx); + int (*_rom_mbedtls_ecp_muladd)(mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_mpi *m, const mbedtls_ecp_point *P, const mbedtls_mpi *n, const mbedtls_ecp_point *Q); + int (*_rom_mbedtls_ecp_muladd_restartable)( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_mpi *m, const mbedtls_ecp_point *P, const mbedtls_mpi *n, const mbedtls_ecp_point *Q, mbedtls_ecp_restart_ctx *rs_ctx); + int (*_rom_mbedtls_ecp_check_pubkey)(const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt); + int (*_rom_mbedtls_ecp_check_privkey)(const mbedtls_ecp_group *grp, const mbedtls_mpi *d); + int (*_rom_mbedtls_ecp_gen_privkey)(const mbedtls_ecp_group *grp, mbedtls_mpi *d, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng); + int (*_rom_mbedtls_ecp_gen_keypair_base)(mbedtls_ecp_group *grp, const mbedtls_ecp_point *G, mbedtls_mpi *d, mbedtls_ecp_point *Q, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng); + int (*_rom_mbedtls_ecp_gen_keypair)(mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp_point *Q, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng); + int (*_rom_mbedtls_ecp_gen_key)(mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng); + int (*_rom_mbedtls_ecp_read_key)(mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key, const unsigned char *buf, size_t buflen); + int (*_rom_mbedtls_ecp_write_key_ext)(const mbedtls_ecp_keypair *key, size_t *olen, unsigned char *buf, size_t buflen); + int (*_rom_mbedtls_ecp_check_pub_priv)( const mbedtls_ecp_keypair *pub, const mbedtls_ecp_keypair *prv, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng); + int (*_rom_mbedtls_ecp_export)(const mbedtls_ecp_keypair *key, mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp_point *Q); + // asn1 module + int (*_rom_mbedtls_asn1_get_enum)(unsigned char **p, const unsigned char *end, int *val); + void (*_rom_mbedtls_asn1_sequence_free)(mbedtls_asn1_sequence *seq); + int (*_rom_mbedtls_asn1_traverse_sequence_of)( unsigned char **p, const unsigned char *end, unsigned char tag_must_mask, unsigned char tag_must_val, unsigned char tag_may_mask, unsigned char tag_may_val, int (*cb)(void *ctx, int tag, unsigned char *start, size_t len), void *ctx); + const mbedtls_asn1_named_data *(*_rom_mbedtls_asn1_find_named_data)(const mbedtls_asn1_named_data *list, const char *oid, size_t len); + void (*_rom_mbedtls_asn1_free_named_data_list)(mbedtls_asn1_named_data **head); + void (*_rom_mbedtls_asn1_free_named_data_list_shallow)(mbedtls_asn1_named_data *name); + // asn1write module + int (*_rom_mbedtls_asn1_write_raw_buffer)(unsigned char **p, const unsigned char *start, const unsigned char *buf, size_t size); + int (*_rom_mbedtls_asn1_write_null)(unsigned char **p, const unsigned char *start); + int (*_rom_mbedtls_asn1_write_oid)(unsigned char **p, const unsigned char *start, const char *oid, size_t oid_len); + int (*_rom_mbedtls_asn1_write_algorithm_identifier)(unsigned char **p, const unsigned char *start, const char *oid, size_t oid_len, size_t par_len); + int (*_rom_mbedtls_asn1_write_bool)(unsigned char **p, const unsigned char *start, int boolean); + int (*_rom_mbedtls_asn1_write_int)(unsigned char **p, const unsigned char *start, int val); + int (*_rom_mbedtls_asn1_write_enum)(unsigned char **p, const unsigned char *start, int val); + int (*_rom_mbedtls_asn1_write_tagged_string)(unsigned char **p, const unsigned char *start, int tag, const char *text, size_t text_len); + int (*_rom_mbedtls_asn1_write_printable_string)(unsigned char **p, const unsigned char *start, const char *text, size_t text_len); + int (*_rom_mbedtls_asn1_write_utf8_string)(unsigned char **p, const unsigned char *start, const char *text, size_t text_len); + int (*_rom_mbedtls_asn1_write_ia5_string)(unsigned char **p, const unsigned char *start, const char *text, size_t text_len); + int (*_rom_mbedtls_asn1_write_bitstring)(unsigned char **p, const unsigned char *start, const unsigned char *buf, size_t bits); + int (*_rom_mbedtls_asn1_write_named_bitstring)(unsigned char **p, const unsigned char *start, const unsigned char *buf, size_t bits); + int (*_rom_mbedtls_asn1_write_octet_string)(unsigned char **p, const unsigned char *start, const unsigned char *buf, size_t size); + mbedtls_asn1_named_data *(*_rom_mbedtls_asn1_store_named_data)(mbedtls_asn1_named_data **list, const char *oid, size_t oid_len, const unsigned char *val, size_t val_len); + // ccm module + int (*_rom_mbedtls_ccm_starts)(mbedtls_ccm_context *ctx, int mode, const unsigned char *iv, size_t iv_len); + int (*_rom_mbedtls_ccm_set_lengths)(mbedtls_ccm_context *ctx, size_t total_ad_len, size_t plaintext_len, size_t tag_len); + int (*_rom_mbedtls_ccm_update_ad)(mbedtls_ccm_context *ctx, const unsigned char *ad, size_t ad_len); + int (*_rom_mbedtls_ccm_update)(mbedtls_ccm_context *ctx, const unsigned char *input, size_t input_len, unsigned char *output, size_t output_size, size_t *output_len); + int (*_rom_mbedtls_ccm_finish)(mbedtls_ccm_context *ctx, unsigned char *tag, size_t tag_len); + // cipher module + const int *(*_rom_mbedtls_cipher_list)(void); + const mbedtls_cipher_info_t *(*_rom_mbedtls_cipher_info_from_string)(const char *cipher_name); + const mbedtls_cipher_info_t *(*_rom_mbedtls_cipher_info_from_type)(const mbedtls_cipher_type_t cipher_type); + const mbedtls_cipher_info_t *(*_rom_mbedtls_cipher_info_from_values)(const mbedtls_cipher_id_t cipher_id, int key_bitlen, const mbedtls_cipher_mode_t mode); + void (*_rom_mbedtls_cipher_free)(mbedtls_cipher_context_t *ctx); + int (*_rom_mbedtls_cipher_setup)(mbedtls_cipher_context_t *ctx, const mbedtls_cipher_info_t *cipher_info); + int (*_rom_mbedtls_cipher_setkey)(mbedtls_cipher_context_t *ctx, const unsigned char *key, int key_bitlen, const mbedtls_operation_t operation); + int (*_rom_mbedtls_cipher_set_iv)(mbedtls_cipher_context_t *ctx, const unsigned char *iv, size_t iv_len); + int (*_rom_mbedtls_cipher_update_ad)(mbedtls_cipher_context_t *ctx, const unsigned char *ad, size_t ad_len); + int (*_rom_mbedtls_cipher_update)(mbedtls_cipher_context_t *ctx, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen); + int (*_rom_mbedtls_cipher_write_tag)(mbedtls_cipher_context_t *ctx, unsigned char *tag, size_t tag_len); + int (*_rom_mbedtls_cipher_check_tag)(mbedtls_cipher_context_t *ctx, const unsigned char *tag, size_t tag_len); + int (*_rom_mbedtls_cipher_auth_encrypt_ext)(mbedtls_cipher_context_t *ctx, const unsigned char *iv, size_t iv_len, const unsigned char *ad, size_t ad_len, const unsigned char *input, size_t ilen, unsigned char *output, size_t output_len, size_t *olen, size_t tag_len); + int (*_rom_mbedtls_cipher_auth_decrypt_ext)(mbedtls_cipher_context_t *ctx, const unsigned char *iv, size_t iv_len, const unsigned char *ad, size_t ad_len, const unsigned char *input, size_t ilen, unsigned char *output, size_t output_len, size_t *olen, size_t tag_len); + int (*_rom_mbedtls_cipher_cmac_reset)(mbedtls_cipher_context_t *ctx); + int (*_rom_mbedtls_cipher_cmac)(const mbedtls_cipher_info_t *cipher_info, const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char *output); + int (*_rom_mbedtls_aes_cmac_prf_128)(const unsigned char *key, size_t key_len, const unsigned char *input, size_t in_len, unsigned char output[16]); + // ctr drbg module + void (*_rom_mbedtls_ctr_drbg_set_prediction_resistance)(mbedtls_ctr_drbg_context *ctx, int resistance); + void (*_rom_mbedtls_ctr_drbg_set_entropy_len)(mbedtls_ctr_drbg_context *ctx, size_t len); + int (*_rom_mbedtls_ctr_drbg_set_nonce_len)(mbedtls_ctr_drbg_context *ctx, size_t len); + void (*_rom_mbedtls_ctr_drbg_set_reseed_interval)(mbedtls_ctr_drbg_context *ctx, int interval); + int (*_rom_mbedtls_ctr_drbg_update)(mbedtls_ctr_drbg_context *ctx, const unsigned char *additional, size_t add_len); + // base64 module + int (*_rom_mbedtls_base64_encode)(unsigned char *dst, size_t dlen, size_t *olen, const unsigned char *src, size_t slen); + // sha1 sha256 sha512 module + int (*_rom_mbedtls_sha1_update)(mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen); + int (*_rom_mbedtls_sha256_update)(mbedtls_sha256_context *ctx, const unsigned char *input, size_t ilen); + // memory calloc free + void *(*_rom_mbedtls_mem_calloc)(size_t n, size_t size); + void (*_rom_mbedtls_mem_free)(void *ptr); +} mbedtls_rom_eco4_funcs_t; + #define STRUCT_OFFSET_CHECK(x, y, z) _Static_assert((offsetof(x,y)==(z)), "The variables type of "#x" before "#y" should be "#z) #define STRUCT_SIZE_CHECK(x, y) _Static_assert((sizeof(x)==(y)), "The sizeof "#x" should be "#y) @@ -420,6 +672,10 @@ typedef struct mbedtls_rom_funcs { STRUCT_OFFSET_CHECK(mbedtls_sha1_context, total, 0); STRUCT_OFFSET_CHECK(mbedtls_sha1_context, state, 8); STRUCT_OFFSET_CHECK(mbedtls_sha1_context, buffer, 28); +STRUCT_OFFSET_CHECK(mbedtls_sha1_context, first_block, 92); +STRUCT_OFFSET_CHECK(mbedtls_sha1_context, mode, 96); +STRUCT_OFFSET_CHECK(mbedtls_sha1_context, sha_state, 100); +STRUCT_SIZE_CHECK(mbedtls_sha1_context, 104); #if (!defined(MBEDTLS_SHA1_C)) || \ (!defined(MBEDTLS_SHA1_ALT)) || \ (defined(MBEDTLS_SHA1_PROCESS_ALT)) diff --git a/components/mbedtls/port/mbedtls_rom/threading_alt.h b/components/mbedtls/port/mbedtls_rom/threading_alt.h new file mode 100644 index 0000000000..6dc3349da1 --- /dev/null +++ b/components/mbedtls/port/mbedtls_rom/threading_alt.h @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once + +#include "freertos/FreeRTOS.h" +#include "freertos/semphr.h" + +typedef struct mbedtls_threading_mutex_t { + SemaphoreHandle_t mutex; + /* is_valid is 0 after a failed init or a free, and nonzero after a + * successful init. This field is not considered part of the public + * API of Mbed TLS and may change without notice. */ + char is_valid; +} mbedtls_threading_mutex_t; + +extern void mbedtls_threading_set_alt(void (*mutex_init)(mbedtls_threading_mutex_t *), + void (*mutex_free)(mbedtls_threading_mutex_t *), + int (*mutex_lock)(mbedtls_threading_mutex_t *), + int (*mutex_unlock)(mbedtls_threading_mutex_t *)); diff --git a/components/mbedtls/test_apps/sdkconfig.ci.rom_impl b/components/mbedtls/test_apps/sdkconfig.ci.rom_impl index 552cc7c973..4f79484e47 100644 --- a/components/mbedtls/test_apps/sdkconfig.ci.rom_impl +++ b/components/mbedtls/test_apps/sdkconfig.ci.rom_impl @@ -1,3 +1,2 @@ CONFIG_IDF_TARGET="esp32c2" -CONFIG_IDF_EXPERIMENTAL_FEATURES=y CONFIG_MBEDTLS_USE_CRYPTO_ROM_IMPL=y diff --git a/components/soc/esp32/include/soc/Kconfig.soc_caps.in b/components/soc/esp32/include/soc/Kconfig.soc_caps.in index a2c5772ee6..b16d12e807 100644 --- a/components/soc/esp32/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32/include/soc/Kconfig.soc_caps.in @@ -283,6 +283,14 @@ config SOC_GPIO_VALID_GPIO_MASK hex default 0xFFFFFFFFFF +config SOC_GPIO_IN_RANGE_MAX + int + default 39 + +config SOC_GPIO_OUT_RANGE_MAX + int + default 33 + config SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK hex default 0xEF0FEA diff --git a/components/soc/esp32/include/soc/soc_caps.h b/components/soc/esp32/include/soc/soc_caps.h index 6f3aec51fa..569fc87e5b 100644 --- a/components/soc/esp32/include/soc/soc_caps.h +++ b/components/soc/esp32/include/soc/soc_caps.h @@ -169,6 +169,9 @@ // GPIO >= 34 are input only #define SOC_GPIO_VALID_OUTPUT_GPIO_MASK (SOC_GPIO_VALID_GPIO_MASK & ~(0ULL | BIT34 | BIT35 | BIT36 | BIT37 | BIT38 | BIT39)) +#define SOC_GPIO_IN_RANGE_MAX 39 +#define SOC_GPIO_OUT_RANGE_MAX 33 + // digital I/O pad powered by VDD3P3_CPU or VDD_SPI(GPIO_NUM: 1, 3, 5, 6, 7, 8, 9, 10, 11, 16, 17, 18, 19, 21, 22, 23) #define SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK 0xEF0FEAULL diff --git a/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in index 231e4b17a1..513a4426a3 100644 --- a/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in @@ -239,6 +239,14 @@ config SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP bool default y +config SOC_GPIO_IN_RANGE_MAX + int + default 20 + +config SOC_GPIO_OUT_RANGE_MAX + int + default 20 + config SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK int default 0 diff --git a/components/soc/esp32c2/include/soc/soc_caps.h b/components/soc/esp32c2/include/soc/soc_caps.h index e1aa1e2509..836bf0b71a 100644 --- a/components/soc/esp32c2/include/soc/soc_caps.h +++ b/components/soc/esp32c2/include/soc/soc_caps.h @@ -119,6 +119,10 @@ #define SOC_GPIO_VALID_GPIO_MASK ((1U< 80Mhz. config SPI_FLASH_HPM_ENA @@ -101,6 +101,17 @@ menu "Main Flash configuration" Also refer to `Concurrency Constraints for Flash on SPI1` > `Flash Auto Suspend Feature` before enabling this option. + config SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND + bool "Enable XMC-C series flash chip suspend feature anyway" + default n + help + XMC-C series is regarded as not qualified for the Suspend feature, since its specification + has a tRS >= 1ms restriction. We strongly do not suggest using it for the Suspend feature. + However, if your product in field has enabled this feature, you may still enable this + config option to keep the legacy behavior. + + For new users, DO NOT enable this config. + endmenu endmenu @@ -235,7 +246,7 @@ menu "SPI Flash driver" Please use this configuration together with ``SPI_FLASH_ERASE_YIELD_DURATION_MS`` and ``SPI_FLASH_ERASE_YIELD_TICKS`` after carefully checking flash datasheet to avoid a watchdog timeout. - For more information, please check `SPI Flash API` reference documenation + For more information, please check `SPI Flash API` reference documentation under section `OS Function`. config SPI_FLASH_ERASE_YIELD_DURATION_MS @@ -337,7 +348,7 @@ menu "SPI Flash driver" config SPI_FLASH_SUPPORT_BOYA_CHIP bool "BOYA" - # ESP32 doens't usually use this chip, default n to save iram. + # ESP32 doesn't usually use this chip, default n to save iram. default y if SPI_FLASH_VENDOR_BOYA_SUPPORTED default n help @@ -347,7 +358,7 @@ menu "SPI Flash driver" config SPI_FLASH_SUPPORT_TH_CHIP bool "TH" - # ESP32 doens't usually use this chip, default n to save iram. + # ESP32 doesn't usually use this chip, default n to save iram. default y if SPI_FLASH_VENDOR_TH_SUPPORTED default n help diff --git a/components/spi_flash/flash_ops.c b/components/spi_flash/flash_ops.c index bbc1d6ee3a..ddf950b40f 100644 --- a/components/spi_flash/flash_ops.c +++ b/components/spi_flash/flash_ops.c @@ -149,8 +149,18 @@ void IRAM_ATTR esp_mspi_pin_init(void) #endif /* Reserve the GPIO pins */ uint64_t reserve_pin_mask = 0; + uint8_t mspi_io; for (esp_mspi_io_t i = 0; i < ESP_MSPI_IO_MAX; i++) { - reserve_pin_mask |= BIT64(esp_mspi_get_io(i)); +#if SOC_SPI_MEM_SUPPORT_OPI_MODE + if (!bootloader_flash_is_octal_mode_enabled() + && i >= ESP_MSPI_IO_DQS && i <= ESP_MSPI_IO_D7) { + continue; + } +#endif + mspi_io = esp_mspi_get_io(i); + if (mspi_io < 64) { // 'reserve_pin_mask' have 64 bits length + reserve_pin_mask |= BIT64(mspi_io); + } } esp_gpio_reserve_pins(reserve_pin_mask); } diff --git a/components/spi_flash/include/spi_flash/spi_flash_defs.h b/components/spi_flash/include/spi_flash/spi_flash_defs.h index 08247c619b..7a8bf432f7 100644 --- a/components/spi_flash/include/spi_flash/spi_flash_defs.h +++ b/components/spi_flash/include/spi_flash/spi_flash_defs.h @@ -53,6 +53,8 @@ #define CMD_RST_EN 0x66 #define CMD_RST_DEV 0x99 +#define CMD_RDSFDP 0x5A /* Read the SFDP of the flash */ + #define SPI_FLASH_DIO_ADDR_BITLEN 24 #define SPI_FLASH_DIO_DUMMY_BITLEN 4 #define SPI_FLASH_QIO_ADDR_BITLEN 24 diff --git a/components/spi_flash/spi_flash_chip_generic.c b/components/spi_flash/spi_flash_chip_generic.c index 7bf62abcf1..49ff8f8d63 100644 --- a/components/spi_flash/spi_flash_chip_generic.c +++ b/components/spi_flash/spi_flash_chip_generic.c @@ -510,7 +510,7 @@ esp_err_t spi_flash_chip_generic_write_encrypted(esp_flash_t *chip, const void * return ESP_ERR_NOT_SUPPORTED; } - /* Check if the buffer and length can qualify the requirments */ + /* Check if the buffer and length can qualify the requirements */ if (esp_flash_encryption->flash_encryption_check(address, length) != true) { return ESP_ERR_NOT_SUPPORTED; } @@ -599,8 +599,39 @@ spi_flash_caps_t spi_flash_chip_generic_get_caps(esp_flash_t *chip) // 32M-bits address support // flash suspend support - // Only `XMC` support suspend for now. + // XMC-D support suspend + if (chip->chip_id >> 16 == 0x46) { + caps_flags |= SPI_FLASH_CHIP_CAP_SUSPEND; + } + + // XMC-D support suspend (some D series flash chip begin with 0x20, difference checked by SFDP) if (chip->chip_id >> 16 == 0x20) { + uint8_t data = 0; + spi_flash_trans_t t = { + .command = CMD_RDSFDP, + .address_bitlen = 24, + .address = 0x32, + .mosi_len = 0, + .mosi_data = 0, + .miso_len = 1, + .miso_data = &data, + .dummy_bitlen = 8, + }; + chip->host->driver->common_command(chip->host, &t); + if((data & 0x8) == 0x8) { + caps_flags |= SPI_FLASH_CHIP_CAP_SUSPEND; + } + } + +#if CONFIG_SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND + // XMC-C suspend has big risk. But can enable this anyway. + if (chip->chip_id >> 16 == 0x20) { + caps_flags |= SPI_FLASH_CHIP_CAP_SUSPEND; + } +#endif + + // FM support suspend + if (chip->chip_id >> 16 == 0xa1) { caps_flags |= SPI_FLASH_CHIP_CAP_SUSPEND; } // flash read unique id. diff --git a/components/spi_flash/spi_flash_hpm_enable.c b/components/spi_flash/spi_flash_hpm_enable.c index 6e306d2f02..38c034e355 100644 --- a/components/spi_flash/spi_flash_hpm_enable.c +++ b/components/spi_flash/spi_flash_hpm_enable.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -114,7 +114,7 @@ static void spi_flash_enable_high_performance_send_cmd(void) { uint32_t dummy = 24; bootloader_flash_execute_command_common(CMD_HPMEN, 0, 0, dummy, 0, 0, 0); - // Delay for T(HPM) refering to datasheet. + // Delay for T(HPM) referring to datasheet. esp_rom_delay_us(20); } @@ -149,6 +149,9 @@ static esp_err_t spi_flash_hpm_probe_chip_with_dummy(uint32_t flash_id) // XMC chips. case 0x204017: case 0x204018: + case 0x464016: + case 0x464017: + case 0x464018: break; // GD chips. case 0xC84017: @@ -397,7 +400,7 @@ bool spi_flash_hpm_dummy_adjust(void) //-----------------------generic functions-------------------------------------// /** - * @brief Default dummy for almost all flash chips. If your flash does't need to reconfigure dummy, + * @brief Default dummy for almost all flash chips. If your flash doesn't need to reconfigure dummy, * just call this function. */ void __attribute__((weak)) spi_flash_hpm_get_dummy_generic(spi_flash_hpm_dummy_conf_t *dummy_conf) diff --git a/components/spi_flash/spi_flash_os_func_noos.c b/components/spi_flash/spi_flash_os_func_noos.c index d24c02b82b..32b3b4726c 100644 --- a/components/spi_flash/spi_flash_os_func_noos.c +++ b/components/spi_flash/spi_flash_os_func_noos.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -8,59 +8,21 @@ #include "sdkconfig.h" #include "esp_flash.h" #include "esp_attr.h" - #include "esp_rom_sys.h" -#if CONFIG_IDF_TARGET_ESP32 -#include "esp32/rom/cache.h" -#elif CONFIG_IDF_TARGET_ESP32S2 -#include "esp32s2/rom/cache.h" -#elif CONFIG_IDF_TARGET_ESP32S3 -#include "esp32s3/rom/ets_sys.h" -#include "esp32s3/rom/cache.h" -#elif CONFIG_IDF_TARGET_ESP32C3 -#include "esp32c3/rom/ets_sys.h" -#include "esp32c3/rom/cache.h" -#elif CONFIG_IDF_TARGET_ESP32C2 -#include "esp32c2/rom/ets_sys.h" -#include "esp32c2/rom/cache.h" -#elif CONFIG_IDF_TARGET_ESP32C6 -#include "esp32c6/rom/ets_sys.h" -#include "esp32c6/rom/cache.h" -#elif CONFIG_IDF_TARGET_ESP32H2 -#include "esp32h2/rom/ets_sys.h" -#include "esp32h2/rom/cache.h" -#endif - -#include "esp_attr.h" - -#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 -typedef struct { - uint32_t icache_autoload; - uint32_t dcache_autoload; -} spi_noos_arg_t; - -static DRAM_ATTR spi_noos_arg_t spi_arg = { 0 }; -#elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 -typedef struct { - uint32_t icache_autoload; -} spi_noos_arg_t; - -static DRAM_ATTR spi_noos_arg_t spi_arg = { 0 }; -#endif +#include "rom/cache.h" +#include "hal/cache_hal.h" +#include "hal/cache_ll.h" +#include "soc/soc_caps.h" static IRAM_ATTR esp_err_t start(void *arg) { #if CONFIG_IDF_TARGET_ESP32 Cache_Read_Disable(0); -#if CONFIG_SMP Cache_Read_Disable(1); +#else + cache_hal_suspend(CACHE_TYPE_ALL); #endif -#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 - spi_arg.icache_autoload = Cache_Suspend_ICache(); - spi_arg.dcache_autoload = Cache_Suspend_DCache(); -#elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 - spi_arg.icache_autoload = Cache_Suspend_ICache(); -#endif + return ESP_OK; } @@ -68,17 +30,11 @@ static IRAM_ATTR esp_err_t end(void *arg) { #if CONFIG_IDF_TARGET_ESP32 Cache_Read_Enable(0); -#if CONFIG_SMP Cache_Read_Enable(1); +#else + cache_hal_resume(CACHE_TYPE_ALL); #endif -#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 - Cache_Invalidate_ICache_All(); - Cache_Resume_ICache(spi_arg.icache_autoload); - Cache_Resume_DCache(spi_arg.dcache_autoload); -#elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 - Cache_Invalidate_ICache_All(); - Cache_Resume_ICache(spi_arg.icache_autoload); -#endif + return ESP_OK; } @@ -107,12 +63,8 @@ const DRAM_ATTR esp_flash_os_functions_t esp_flash_noos_functions = { }; esp_err_t IRAM_ATTR esp_flash_app_disable_os_functions(esp_flash_t* chip) -{ +{ chip->os_func = &esp_flash_noos_functions; -#if !CONFIG_IDF_TARGET_ESP32 - chip->os_func_data = &spi_arg; -#endif - return ESP_OK; } diff --git a/components/spi_flash/test/test_read_write.c b/components/spi_flash/test/test_read_write.c index d7cd12c2c7..928b1891f0 100644 --- a/components/spi_flash/test/test_read_write.c +++ b/components/spi_flash/test/test_read_write.c @@ -224,9 +224,8 @@ static void IRAM_ATTR test_write(int dst_off, int src_off, int len) } ESP_ERROR_CHECK(esp_flash_write(NULL, src_buf + src_off, start + dst_off, len)); - fix_rom_func(); - spi_flash_disable_interrupts_caches_and_other_cpu(); + fix_rom_func(); esp_rom_spiflash_result_t rc = esp_rom_spiflash_read(start, dst_buf, sizeof(dst_buf)); spi_flash_enable_interrupts_caches_and_other_cpu(); TEST_ASSERT_EQUAL_HEX(rc, ESP_ROM_SPIFLASH_RESULT_OK); diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_common.c b/components/wpa_supplicant/esp_supplicant/src/esp_common.c index 0c74341c57..5c84511d87 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_common.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_common.c @@ -406,7 +406,7 @@ void esp_supplicant_common_deinit(void) s_supplicant_evt_queue = NULL; } if (s_supplicant_api_lock) { - os_semphr_delete(s_supplicant_api_lock); + os_mutex_delete(s_supplicant_api_lock); s_supplicant_api_lock = NULL; } } else if (esp_supplicant_post_evt(SIG_SUPPLICANT_DEL_TASK, 0) != 0) { diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c b/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c index 659eaa6987..2f6e74e86c 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c @@ -86,7 +86,7 @@ static uint8_t esp_dpp_deinit_auth(void) static void esp_dpp_call_cb(esp_supp_dpp_event_t evt, void *data) { - if ( evt == ESP_SUPP_DPP_FAIL && s_dpp_ctx.dpp_auth) { + if (s_dpp_ctx.dpp_auth) { esp_dpp_deinit_auth(); } s_dpp_ctx.dpp_event_cb(evt, data); @@ -177,6 +177,7 @@ static void esp_dpp_rx_auth_req(struct action_rx_param *rx_param, uint8_t *dpp_d own_bi, rx_param->channel, (const u8 *)&rx_param->action_frm->u.public_action.v, dpp_data, len); os_memcpy(s_dpp_ctx.dpp_auth->peer_mac_addr, rx_param->sa, ETH_ALEN); + wpa_printf(MSG_DEBUG, "DPP: Sending authentication response."); esp_dpp_send_action_frame(rx_param->sa, wpabuf_head(s_dpp_ctx.dpp_auth->resp_msg), wpabuf_len(s_dpp_ctx.dpp_auth->resp_msg), rx_param->channel, OFFCHAN_TX_WAIT_TIME); @@ -473,7 +474,7 @@ static void esp_dpp_task(void *pvParameters ) s_dpp_evt_queue = NULL; if (s_dpp_api_lock) { - os_semphr_delete(s_dpp_api_lock); + os_mutex_delete(s_dpp_api_lock); s_dpp_api_lock = NULL; } @@ -704,7 +705,7 @@ esp_err_t esp_supp_dpp_init(esp_supp_dpp_event_cb_t cb) return ESP_FAIL; } if (s_dpp_ctx.dpp_global) { - wpa_printf(MSG_ERROR, "DPP: failed to init as init already done."); + wpa_printf(MSG_ERROR, "DPP: failed to init as init already done. Please deinit first and retry."); return ESP_FAIL; } diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_eap_client.c b/components/wpa_supplicant/esp_supplicant/src/esp_eap_client.c index 12701161de..cd37fa734c 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_eap_client.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_eap_client.c @@ -242,7 +242,7 @@ void wpa2_task(void *pvParameters ) break; } else { if (s_wifi_wpa2_sync_sem) { - wpa_printf(MSG_DEBUG, "EAP: wifi->EAP api completed sig(%" PRId32 ")", e->sig); + wpa_printf(MSG_DEBUG, "EAP: wifi->EAP api completed"); os_semphr_give(s_wifi_wpa2_sync_sem); } else { wpa_printf(MSG_ERROR, "EAP: null wifi->EAP sync sem"); @@ -255,7 +255,7 @@ void wpa2_task(void *pvParameters ) wpa_printf(MSG_DEBUG, "EAP: task deleted"); s_wpa2_queue = NULL; if (s_wifi_wpa2_sync_sem) { - wpa_printf(MSG_DEBUG, "EAP: wifi->EAP api completed sig(%" PRId32 ")", e->sig); + wpa_printf(MSG_DEBUG, "EAP: wifi->EAP api completed"); os_semphr_give(s_wifi_wpa2_sync_sem); } else { wpa_printf(MSG_ERROR, "EAP: null wifi->EAP sync sem"); @@ -590,7 +590,7 @@ static int eap_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len, uint8_t *bss break; case EAP_CODE_SUCCESS: if (sm->eapKeyData) { - wpa_set_pmk(sm->eapKeyData, NULL, false); + wpa_set_pmk(sm->eapKeyData, 0, NULL, false); os_free(sm->eapKeyData); sm->eapKeyData = NULL; wpa_printf(MSG_INFO, ">>>>>EAP FINISH"); @@ -725,7 +725,7 @@ static int eap_peer_sm_init(void) gEapSm = sm; #ifdef USE_WPA2_TASK - s_wpa2_queue = os_queue_create(SIG_WPA2_MAX, sizeof(s_wpa2_queue)); + s_wpa2_queue = os_queue_create(SIG_WPA2_MAX, sizeof(ETSEvent)); ret = os_task_create(wpa2_task, "wpa2T", WPA2_TASK_STACK_SIZE, NULL, WPA2_TASK_PRIORITY, &s_wpa2_task_hdl); if (ret != TRUE) { wpa_printf(MSG_ERROR, "wps enable: failed to create task"); @@ -782,7 +782,7 @@ static void eap_peer_sm_deinit(void) } if (s_wpa2_data_lock) { - os_semphr_delete(s_wpa2_data_lock); + os_mutex_delete(s_wpa2_data_lock); s_wpa2_data_lock = NULL; wpa_printf(MSG_DEBUG, "EAP: eap_peer_sm_deinit: free data lock"); } diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_hostap.c b/components/wpa_supplicant/esp_supplicant/src/esp_hostap.c index 172ae2f072..8c1015e10a 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_hostap.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_hostap.c @@ -7,6 +7,7 @@ #include "utils/includes.h" #include "utils/common.h" +#include "utils/eloop.h" #include "crypto/sha1.h" #include "common/ieee802_11_defs.h" #include "common/eapol_common.h" @@ -19,7 +20,11 @@ #include "esp_wifi_types.h" #include "esp_wpa3_i.h" #include "esp_wps.h" +#include "esp_wps_i.h" +#include "ap/sta_info.h" +#include "common/sae.h" +#include "ap/ieee802_11.h" #define WIFI_PASSWORD_LEN_MAX 65 struct hostapd_data *global_hapd; @@ -238,6 +243,9 @@ bool hostap_deinit(void *data) esp_wifi_unset_appie_internal(WIFI_APPIE_WPA); esp_wifi_unset_appie_internal(WIFI_APPIE_ASSOC_RESP); +#ifdef CONFIG_WPS_REGISTRAR + wifi_ap_wps_disable_internal(); +#endif #ifdef CONFIG_SAE wpa3_hostap_auth_deinit(); /* Wait till lock is released by wpa3 task */ @@ -318,3 +326,143 @@ u16 esp_send_assoc_resp(struct hostapd_data *hapd, const u8 *addr, os_free(reply); return res; } + +uint8_t wpa_status_to_reason_code(int status) +{ + switch (status) { + case WLAN_STATUS_INVALID_IE: + return WLAN_REASON_INVALID_IE; + case WLAN_STATUS_GROUP_CIPHER_NOT_VALID: + return WLAN_REASON_GROUP_CIPHER_NOT_VALID; + case WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID: + return WLAN_REASON_PAIRWISE_CIPHER_NOT_VALID; + case WLAN_STATUS_AKMP_NOT_VALID: + return WLAN_REASON_AKMP_NOT_VALID; + case WLAN_STATUS_CIPHER_REJECTED_PER_POLICY: + return WLAN_REASON_CIPHER_SUITE_REJECTED; + case WLAN_STATUS_INVALID_PMKID: + return WLAN_REASON_INVALID_PMKID; + case WLAN_STATUS_INVALID_MDIE: + return WLAN_REASON_INVALID_MDE; + default: + return WLAN_REASON_UNSPECIFIED; + } +} + +bool hostap_new_assoc_sta(struct sta_info *sta, uint8_t *bssid, uint8_t *wpa_ie, + uint8_t wpa_ie_len, uint8_t *rsnxe, uint8_t rsnxe_len, + bool *pmf_enable, int subtype, uint8_t *pairwise_cipher, uint8_t *reason) +{ + struct hostapd_data *hapd = (struct hostapd_data*)esp_wifi_get_hostap_private_internal(); + enum wpa_validate_result res = WPA_IE_OK; + int status = WLAN_STATUS_SUCCESS; + bool omit_rsnxe = false; + + if (!sta || !bssid || !wpa_ie) { + return false; + } + + if (hapd) { + if (hapd->wpa_auth->conf.wpa) { + if (sta->wpa_sm) { + wpa_auth_sta_deinit(sta->wpa_sm); + } + + sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth, bssid); + wpa_printf(MSG_DEBUG, "init wpa sm=%p", sta->wpa_sm); + + if (sta->wpa_sm == NULL) { + status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; + goto send_resp; + } + + res = wpa_validate_wpa_ie(hapd->wpa_auth, sta->wpa_sm, wpa_ie, wpa_ie_len, rsnxe, rsnxe_len); + +#ifdef CONFIG_SAE + if (wpa_auth_uses_sae(sta->wpa_sm) && sta->sae && + sta->sae->state == SAE_ACCEPTED) { + wpa_auth_add_sae_pmkid(sta->wpa_sm, sta->sae->pmkid); + } +#endif /* CONFIG_SAE */ + + status = wpa_res_to_status_code(res); + +send_resp: + if (!rsnxe) { + omit_rsnxe = true; + } + + if (esp_send_assoc_resp(hapd, bssid, status, omit_rsnxe, subtype) != WLAN_STATUS_SUCCESS) { + status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; + } + + if (status != WLAN_STATUS_SUCCESS) { + *reason = wpa_status_to_reason_code(status); + return false; + } + + //Check whether AP uses Management Frame Protection for this connection + *pmf_enable = wpa_auth_uses_mfp(sta->wpa_sm); + *pairwise_cipher = GET_BIT_POSITION(sta->wpa_sm->pairwise); + } + + wpa_auth_sta_associated(hapd->wpa_auth, sta->wpa_sm); + } + + return true; +} + +#ifdef CONFIG_WPS_REGISTRAR +static void ap_free_sta_timeout(void *ctx, void *data) +{ + struct hostapd_data *hapd = (struct hostapd_data *) ctx; + u8 *addr = (u8 *) data; + struct sta_info *sta = ap_get_sta(hapd, addr); + + if (sta) { + ap_free_sta(hapd, sta); + } + + os_free(addr); +} +#endif + +bool wpa_ap_remove(u8* bssid) +{ + struct hostapd_data *hapd = hostapd_get_hapd_data(); + + if (!hapd) { + return false; + } + struct sta_info *sta = ap_get_sta(hapd, bssid); + if (!sta) { + return false; + } + +#ifdef CONFIG_SAE + if (sta->lock) { + if (os_semphr_take(sta->lock, 0)) { + ap_free_sta(hapd, sta); + } else { + sta->remove_pending = true; + } + return true; + } +#endif /* CONFIG_SAE */ + +#ifdef CONFIG_WPS_REGISTRAR + wpa_printf(MSG_DEBUG, "wps_status=%d", wps_get_status()); + if (wps_get_status() == WPS_STATUS_PENDING) { + u8 *addr = os_malloc(ETH_ALEN); + + if (!addr) { + return false; + } + os_memcpy(addr, sta->addr, ETH_ALEN); + eloop_register_timeout(0, 10000, ap_free_sta_timeout, hapd, addr); + } else +#endif + ap_free_sta(hapd, sta); + + return true; +} diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h b/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h index 6be0bb3358..0057f1578c 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h @@ -57,6 +57,7 @@ typedef enum { } wifi_appie_ram_t; enum { + /* this enum is in C2 ROM, do not change before WPA3_AUTH_OWE */ NONE_AUTH = 0x01, WPA_AUTH_UNSPEC = 0x02, WPA_AUTH_PSK = 0x03, @@ -72,6 +73,7 @@ enum { WPA2_AUTH_ENT_SHA384_SUITE_B = 0x0d, WPA2_AUTH_FT_PSK = 0x0e, WPA3_AUTH_OWE = 0x0f, + /* this enum is in C2 ROM, do not change before WPA3_AUTH_OWE */ WPA2_AUTH_INVALID }; @@ -140,6 +142,7 @@ struct wpa_funcs { void (*wpa_config_done)(void); uint8_t *(*owe_build_dhie)(uint16_t group); int (*owe_process_assoc_resp)(const u8 *rsn_ie, size_t rsn_len, const uint8_t *dh_ie, size_t dh_len); + void (*wpa_sta_clear_curr_pmksa)(void); }; struct wpa2_funcs { diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wpa3.c b/components/wpa_supplicant/esp_supplicant/src/esp_wpa3.c index bc445ef9c4..778314d36d 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wpa3.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wpa3.c @@ -236,6 +236,60 @@ static u8 *wpa3_build_sae_msg(u8 *bssid, u32 sae_msg_type, size_t *sae_msg_len) return buf; } +static int wpa3_sae_is_group_enabled(int group) +{ + int *groups = NULL; + int default_groups[] = { 19, 0 }; + int i; + + if (!groups) { + groups = default_groups; + } + + for (i = 0; groups[i] > 0; i++) { + if (groups[i] == group) { + return 1; + } + } + + return 0; +} + +static int wpa3_check_sae_rejected_groups(const struct wpabuf *groups) +{ + size_t i, count, len; + const u8 *pos; + + if (!groups) { + return 0; + } + + pos = wpabuf_head(groups); + len = wpabuf_len(groups); + if (len & 1) { + wpa_printf(MSG_DEBUG, + "SAE: Invalid length of the Rejected Groups element payload: %zu", + len); + return 1; + } + count = len / 2; + for (i = 0; i < count; i++) { + int enabled; + u16 group; + + group = WPA_GET_LE16(pos); + pos += 2; + enabled = wpa3_sae_is_group_enabled(group); + wpa_printf(MSG_DEBUG, "SAE: Rejected group %u is %s", + group, enabled ? "enabled" : "disabled"); + if (enabled) { + return 1; + } + } + + return 0; +} + static int wpa3_parse_sae_commit(u8 *buf, u32 len, u16 status) { int ret; @@ -272,6 +326,9 @@ static int wpa3_parse_sae_commit(u8 *buf, u32 len, u16 status) wpa_printf(MSG_ERROR, "wpa3: could not parse commit(%d)", ret); return ret; } + if (g_sae_data.tmp && wpa3_check_sae_rejected_groups(g_sae_data.tmp->peer_rejected_groups)) { + return -1; + } ret = sae_process_commit(&g_sae_data); if (ret) { @@ -296,7 +353,7 @@ static int wpa3_parse_sae_confirm(u8 *buf, u32 len) } g_sae_data.state = SAE_ACCEPTED; - wpa_set_pmk(g_sae_data.pmk, g_sae_data.pmkid, true); + wpa_set_pmk(g_sae_data.pmk, g_sae_data.pmk_len, g_sae_data.pmkid, true); return ESP_OK; } @@ -358,16 +415,19 @@ int wpa3_hostap_post_evt(uint32_t evt_id, uint32_t data) if (g_wpa3_hostap_evt_queue == NULL) { WPA3_HOSTAP_AUTH_API_UNLOCK(); os_free(evt); + wpa_printf(MSG_DEBUG, "hostap evt queue NULL"); return ESP_FAIL; } } else { os_free(evt); + wpa_printf(MSG_DEBUG, "g_wpa3_hostap_auth_api_lock not found"); return ESP_FAIL; } if (evt->id == SIG_WPA3_RX_CONFIRM || evt->id == SIG_TASK_DEL) { /* prioritising confirm for completing handshake for committed sta */ if (os_queue_send_to_front(g_wpa3_hostap_evt_queue, &evt, 0) != pdPASS) { WPA3_HOSTAP_AUTH_API_UNLOCK(); + wpa_printf(MSG_DEBUG, "failed to add msg to queue front"); os_free(evt); return ESP_FAIL; } @@ -375,6 +435,7 @@ int wpa3_hostap_post_evt(uint32_t evt_id, uint32_t data) if (os_queue_send(g_wpa3_hostap_evt_queue, &evt, 0) != pdPASS) { WPA3_HOSTAP_AUTH_API_UNLOCK(); os_free(evt); + wpa_printf(MSG_DEBUG, "failed to send msg to queue"); return ESP_FAIL; } } @@ -577,6 +638,9 @@ bool wpa3_hostap_auth_deinit(void) static int wpa3_hostap_handle_auth(u8 *buf, size_t len, u32 auth_transaction, u16 status, u8 *bssid) { struct hostapd_data *hapd = (struct hostapd_data *)esp_wifi_get_hostap_private_internal(); + if (!hapd) { + return ESP_FAIL; + } struct sta_info *sta = ap_get_sta(hapd, bssid); if (auth_transaction == SAE_MSG_COMMIT) { if (sta && sta->sae_commit_processing) { diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c b/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c index 4ee3c9729a..bfe971a97d 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c @@ -174,14 +174,14 @@ bool wpa_ap_rx_eapol(void *hapd_data, void *sm_data, u8 *data, size_t data_len) void wpa_ap_get_peer_spp_msg(void *sm_data, bool *spp_cap, bool *spp_req) { - struct wpa_state_machine *sm = (struct wpa_state_machine *)sm_data; + struct sta_info *sta = sm_data; - if (!sm) { + if (!sta || !sta->wpa_sm) { return; } - *spp_cap = sm->spp_sup.capable; - *spp_req = sm->spp_sup.require; + *spp_cap = sta->wpa_sm->spp_sup.capable; + *spp_req = sta->wpa_sm->spp_sup.require; } bool wpa_deattach(void) @@ -253,8 +253,8 @@ static void wpa_sta_disconnected_cb(uint8_t reason_code) { switch (reason_code) { case WIFI_REASON_AUTH_EXPIRE: - case WIFI_REASON_NOT_AUTHED: - case WIFI_REASON_NOT_ASSOCED: + case WIFI_REASON_CLASS2_FRAME_FROM_NONAUTH_STA: + case WIFI_REASON_CLASS3_FRAME_FROM_NONASSOC_STA: case WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT: case WIFI_REASON_INVALID_PMKID: case WIFI_REASON_AUTH_FAIL: @@ -323,6 +323,7 @@ static bool hostap_sta_join(void **sta, u8 *bssid, u8 *wpa_ie, u8 wpa_ie_len, u8 { struct sta_info *sta_info = NULL; struct hostapd_data *hapd = hostapd_get_hapd_data(); + uint8_t reason = WLAN_REASON_PREV_AUTH_NOT_VALID; if (!hapd) { goto fail; @@ -381,7 +382,7 @@ static bool hostap_sta_join(void **sta, u8 *bssid, u8 *wpa_ie, u8 wpa_ie_len, u8 goto fail; } #endif - if (wpa_ap_join(sta_info, bssid, wpa_ie, wpa_ie_len, rsnxe, rsnxe_len, pmf_enable, subtype, pairwise_cipher)) { + if (hostap_new_assoc_sta(sta_info, bssid, wpa_ie, wpa_ie_len, rsnxe, rsnxe_len, pmf_enable, subtype, pairwise_cipher, &reason)) { goto done; } else { goto fail; @@ -402,7 +403,7 @@ static bool hostap_sta_join(void **sta, u8 *bssid, u8 *wpa_ie, u8 wpa_ie_len, u8 os_semphr_give(sta_info->lock); } #endif /* CONFIG_SAE */ - esp_wifi_ap_deauth_internal(bssid, WLAN_REASON_PREV_AUTH_NOT_VALID); + esp_wifi_ap_deauth_internal(bssid, reason); return false; } #endif @@ -443,6 +444,7 @@ int esp_supplicant_init(void) wpa_cb->wpa_config_bss = NULL;//wpa_config_bss; wpa_cb->wpa_michael_mic_failure = wpa_michael_mic_failure; wpa_cb->wpa_config_done = wpa_config_done; + wpa_cb->wpa_sta_clear_curr_pmksa = wpa_sta_clear_curr_pmksa; esp_wifi_register_wpa3_ap_cb(wpa_cb); esp_wifi_register_wpa3_cb(wpa_cb); @@ -471,6 +473,9 @@ int esp_supplicant_deinit(void) esp_supplicant_unset_all_appie(); eloop_destroy(); wpa_cb = NULL; +#if CONFIG_ESP_WIFI_WAPI_PSK + esp_wifi_internal_wapi_deinit(); +#endif return esp_wifi_unregister_wpa_cb_internal(); } diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wps.c b/components/wpa_supplicant/esp_supplicant/src/esp_wps.c index da744db4b8..a6b3bb6d8b 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wps.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wps.c @@ -70,6 +70,7 @@ void wifi_station_wps_msg_timeout(void *data, void *user_ctx); void wifi_station_wps_eapol_start_handle(void *data, void *user_ctx); void wifi_station_wps_success(void *data, void *user_ctx); void wifi_station_wps_timeout(void *data, void *user_ctx); +int wps_delete_timer(void); struct wps_sm *gWpsSm = NULL; static wps_factory_information_t *s_factory_info = NULL; @@ -416,11 +417,11 @@ wps_parse_scan_result(struct wps_scan_ie *scan) wpabuf_free(buf); if (scan->ssid[1] > SSID_MAX_LEN) { return false; - } + } esp_wifi_enable_sta_privacy_internal(); - os_memset(sm->ssid[0], 0, SSID_MAX_LEN); - os_memcpy(sm->ssid[0], (char *)&scan->ssid[2], (int)scan->ssid[1]); - sm->ssid_len[0] = scan->ssid[1]; + os_memset(sm->creds[0].ssid, 0, SSID_MAX_LEN); + os_memcpy(sm->creds[0].ssid, (char *)&scan->ssid[2], (int)scan->ssid[1]); + sm->creds[0].ssid_len = scan->ssid[1]; if (scan->bssid && memcmp(sm->bssid, scan->bssid, ETH_ALEN) != 0) { wpa_printf(MSG_INFO, "sm BSSid: "MACSTR " scan BSSID " MACSTR, MAC2STR(sm->bssid), MAC2STR(scan->bssid)); @@ -434,7 +435,7 @@ wps_parse_scan_result(struct wps_scan_ie *scan) wps_build_ic_appie_wps_ar(); } } - wpa_printf(MSG_DEBUG, "wps discover [%s]", (char *)sm->ssid); + wpa_printf(MSG_DEBUG, "wps discover [%s]", (char *)sm->creds[0].ssid); sm->channel = scan->chan; return true; @@ -589,15 +590,15 @@ int wps_process_wps_mX_req(u8 *ubuf, int len, enum wps_process_res *res) if (sm->state == WAIT_START) { if (expd->opcode != WSC_Start) { wpa_printf(MSG_DEBUG, "EAP-WSC: Unexpected Op-Code %d " - "in WAIT_START state", expd->opcode); - return ESP_FAIL; + "in WAIT_START state", expd->opcode); + return ESP_ERR_INVALID_STATE; } wpa_printf(MSG_DEBUG, "EAP-WSC: Received start"); sm->state = WPA_MESG; - } else if (expd->opcode == WSC_Start){ + } else if (expd->opcode == WSC_Start) { wpa_printf(MSG_DEBUG, "EAP-WSC: Unexpected Op-Code %d", - expd->opcode); - return ESP_FAIL; + expd->opcode); + return ESP_ERR_INVALID_STATE; } flag = *(u8 *)(ubuf + sizeof(struct eap_expand)); @@ -762,8 +763,7 @@ static int wps_sm_init(struct wps_sm *sm) sm->scan_cnt = 0; sm->discover_ssid_cnt = 0; os_bzero(sm->bssid, ETH_ALEN); - os_bzero(sm->ssid, sizeof(sm->ssid)); - os_bzero(sm->ssid_len, sizeof(sm->ssid_len)); + os_bzero(sm->creds, sizeof(sm->creds)); sm->ap_cred_cnt = 0; return 0; @@ -804,7 +804,12 @@ int wps_finish(void) if (sm->wps->state == WPS_FINISHED) { wpa_printf(MSG_DEBUG, "wps finished------>"); wps_set_status(WPS_STATUS_SUCCESS); - wps_stop_connection_timers(sm); + /* WPS finished, dequeue all timers */ + wps_delete_timer(); + + esp_wifi_unset_appie_internal(WIFI_APPIE_WPS_PR); + esp_wifi_unset_appie_internal(WIFI_APPIE_WPS_AR); + esp_wifi_set_wps_cb_internal(NULL); if (sm->ap_cred_cnt == 1) { wifi_config_t *config = os_zalloc(sizeof(wifi_config_t)); @@ -814,12 +819,21 @@ int wps_finish(void) } esp_wifi_get_config(WIFI_IF_STA, config); - os_memcpy(config->sta.ssid, sm->ssid[0], sm->ssid_len[0]); - os_memcpy(config->sta.password, sm->key[0], sm->key_len[0]); + esp_wifi_disconnect(); + os_memcpy(config->sta.ssid, sm->creds[0].ssid, sm->creds[0].ssid_len); + os_memcpy(config->sta.password, sm->creds[0].key, sm->creds[0].key_len); os_memcpy(config->sta.bssid, sm->bssid, ETH_ALEN); +#ifndef CONFIG_WPS_STRICT + /* Some APs support AES in WPA IE, enable connection with them */ + if (sm->creds[0].auth_type == WPS_AUTH_WPAPSK && + (sm->creds[0].encr_type & WPS_ENCR_AES)) { + config->sta.threshold.authmode = WIFI_AUTH_WPA_PSK; + } +#endif config->sta.bssid_set = 0; config->sta.sae_pwe_h2e = 0; esp_wifi_set_config(WIFI_IF_STA, config); + esp_wifi_connect(); os_free(config); } @@ -832,8 +846,7 @@ int wps_finish(void) if (sm->ignore_sel_reg) { sm->discover_ssid_cnt = 0; esp_wifi_disconnect(); - os_bzero(sm->ssid, sizeof(sm->ssid)); - os_bzero(sm->ssid_len, sizeof(sm->ssid_len)); + os_bzero(sm->creds, sizeof(sm->creds)); wps_add_discard_ap(sm->bssid); } else { ret = wps_stop_process(WPS_FAIL_REASON_NORMAL); @@ -890,7 +903,7 @@ int wps_start_msg_timer(void) ret = 0; } else if (sm->wps->state == RECV_M2) { msg_timeout = 5; - wpa_printf(MSG_DEBUG, "start msg timer RECV_M2 %" PRId32 " ms", msg_timeout); + wpa_printf(MSG_DEBUG, "start msg timer RECV_M2 %" PRId32 " s", msg_timeout); eloop_cancel_timeout(wifi_station_wps_msg_timeout, NULL, NULL); eloop_register_timeout(msg_timeout, 0, wifi_station_wps_msg_timeout, NULL, NULL); ret = 0; @@ -1056,6 +1069,8 @@ int wps_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len) wpa_printf(MSG_DEBUG, "sm->wps->state = %d", sm->wps->state); wps_start_msg_timer(); } + } else if (ret == ESP_ERR_INVALID_STATE) { + ret = ESP_OK; } else { ret = ESP_FAIL; } @@ -1283,8 +1298,7 @@ wifi_station_wps_msg_timeout_internal(void) if (sm->ignore_sel_reg) { esp_wifi_disconnect(); wps_add_discard_ap(sm->bssid); - os_bzero(sm->ssid, sizeof(sm->ssid)); - os_bzero(sm->ssid_len, sizeof(sm->ssid_len)); + os_bzero(sm->creds, sizeof(sm->creds)); os_bzero(sm->bssid, ETH_ALEN); sm->discover_ssid_cnt = 0; wifi_wps_scan(NULL, NULL); @@ -1314,8 +1328,8 @@ void wifi_station_wps_success_internal(void) if (sm->ap_cred_cnt > 1) { evt.ap_cred_cnt = sm->ap_cred_cnt; for (i = 0; i < MAX_WPS_AP_CRED; i++) { - os_memcpy(evt.ap_cred[i].ssid, sm->ssid[i], sm->ssid_len[i]); - os_memcpy(evt.ap_cred[i].passphrase, sm->key[i], sm->key_len[i]); + os_memcpy(evt.ap_cred[i].ssid, sm->creds[i].ssid, sm->creds[i].ssid_len); + os_memcpy(evt.ap_cred[i].passphrase, sm->creds[i].key, sm->creds[i].key_len); } esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_SUCCESS, &evt, sizeof(evt), OS_BLOCK); @@ -1353,17 +1367,13 @@ void wifi_station_wps_eapol_start_handle(void *data, void *user_ctx) static int save_credentials_cb(void *ctx, const struct wps_credential *cred) { - if (!gWpsSm || !cred || gWpsSm->ap_cred_cnt > 2) { + struct wps_credential *creds; + if (!gWpsSm || !cred || gWpsSm->ap_cred_cnt >= MAX_CRED_COUNT) { return ESP_FAIL; } - os_memset(gWpsSm->ssid[gWpsSm->ap_cred_cnt], 0x00, sizeof(gWpsSm->ssid[gWpsSm->ap_cred_cnt])); - os_memset(gWpsSm->key[gWpsSm->ap_cred_cnt], 0x00, sizeof(gWpsSm->key[gWpsSm->ap_cred_cnt])); - - os_memcpy(gWpsSm->ssid[gWpsSm->ap_cred_cnt], cred->ssid, cred->ssid_len); - gWpsSm->ssid_len[gWpsSm->ap_cred_cnt] = cred->ssid_len; - os_memcpy(gWpsSm->key[gWpsSm->ap_cred_cnt], cred->key, cred->key_len); - gWpsSm->key_len[gWpsSm->ap_cred_cnt] = cred->key_len; + creds = &gWpsSm->creds[gWpsSm->ap_cred_cnt]; + memcpy(creds, cred, sizeof(*creds)); gWpsSm->ap_cred_cnt++; @@ -1616,14 +1626,15 @@ wifi_wps_scan_done(void *arg, ETS_STATUS status) esp_wifi_disconnect(); os_memcpy(wifi_config.sta.bssid, sm->bssid, ETH_ALEN); - os_memcpy(wifi_config.sta.ssid, (char *)sm->ssid[0], sm->ssid_len[0]); + os_memcpy(wifi_config.sta.ssid, (char *)sm->creds[0].ssid, sm->creds[0].ssid_len); wifi_config.sta.bssid_set = 1; wifi_config.sta.channel = sm->channel; wpa_printf(MSG_INFO, "WPS: connecting to %s, bssid=" MACSTR, - (char *)sm->ssid[0], MAC2STR(wifi_config.sta.bssid)); + (char *)sm->creds[0].ssid, MAC2STR(wifi_config.sta.bssid)); esp_wifi_set_config(0, &wifi_config); wpa_printf(MSG_DEBUG, "WPS: neg start"); + wifi_config.sta.failure_retry_cnt = 2; esp_wifi_connect(); sm->state = WAIT_START; eloop_cancel_timeout(wifi_station_wps_msg_timeout, NULL, NULL); @@ -1735,6 +1746,11 @@ int wps_task_deinit(void) wps_rxq_deinit(); } + if (s_wps_data_lock) { + os_mutex_delete(s_wps_data_lock); + s_wps_data_lock = NULL; + } + return ESP_OK; } @@ -1767,7 +1783,7 @@ int wps_task_init(void) } os_bzero(s_wps_sig_cnt, SIG_WPS_NUM); - s_wps_queue = os_queue_create(SIG_WPS_NUM, sizeof(s_wps_queue)); + s_wps_queue = os_queue_create(SIG_WPS_NUM, sizeof(ETSEvent)); if (!s_wps_queue) { wpa_printf(MSG_ERROR, "wps task init: failed to alloc queue"); goto _wps_no_mem; diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wps_i.h b/components/wpa_supplicant/esp_supplicant/src/esp_wps_i.h index e7d030f37a..1b413a128b 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wps_i.h +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wps_i.h @@ -6,6 +6,8 @@ #include "esp_wifi_driver.h" #include "esp_wps.h" +#include "wps/wps.h" +#include "wps/wps_attr_parse.h" /* WPS message flag */ enum wps_msg_flag { @@ -57,15 +59,6 @@ struct discard_ap_list_t{ u8 bssid[6]; }; -#ifndef MAX_PASSPHRASE_LEN -#define MAX_PASSPHRASE_LEN 64 -#endif - -#ifndef MAX_CRED_COUNT -#define MAX_CRED_COUNT 10 -#endif - -#define WPS_OUTBUF_SIZE 500 struct wps_sm { u8 state; struct wps_config *wps_cfg; @@ -75,10 +68,7 @@ struct wps_sm { u8 identity_len; u8 ownaddr[ETH_ALEN]; u8 bssid[ETH_ALEN]; - u8 ssid[MAX_CRED_COUNT][SSID_MAX_LEN]; - u8 ssid_len[MAX_CRED_COUNT]; - char key[MAX_CRED_COUNT][MAX_PASSPHRASE_LEN]; - u8 key_len[MAX_CRED_COUNT]; + struct wps_credential creds[MAX_CRED_COUNT]; u8 ap_cred_cnt; struct wps_device_data *dev; u8 uuid[16]; @@ -147,3 +137,4 @@ static inline int wps_set_status(uint32_t status) bool is_wps_enabled(void); int wps_init_cfg_pin(struct wps_config *cfg); void wifi_station_wps_eapol_start_handle(void *data, void *user_ctx); +int wifi_ap_wps_disable_internal(void); diff --git a/components/wpa_supplicant/port/eloop.c b/components/wpa_supplicant/port/eloop.c index 74eacb5804..c1c71f274b 100644 --- a/components/wpa_supplicant/port/eloop.c +++ b/components/wpa_supplicant/port/eloop.c @@ -6,7 +6,7 @@ * See README for more details. */ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -19,21 +19,21 @@ #include "esp_wifi_driver.h" struct eloop_timeout { - struct dl_list list; - struct os_reltime time; - void *eloop_data; - void *user_data; - eloop_timeout_handler handler; + struct dl_list list; + struct os_reltime time; + void *eloop_data; + void *user_data; + eloop_timeout_handler handler; #ifdef ELOOP_DEBUG - char func_name[100]; - int line; + char func_name[100]; + int line; #endif }; struct eloop_data { - struct dl_list timeout; - ETSTimer eloop_timer; - bool eloop_started; + struct dl_list timeout; + ETSTimer eloop_timer; + bool eloop_started; }; #define ELOOP_LOCK() os_mutex_lock(eloop_data_lock) @@ -45,364 +45,368 @@ static struct eloop_data eloop; static int eloop_run_wrapper(void *data) { - eloop_run(); - return 0; + eloop_run(); + return 0; } static void eloop_run_timer(void *args) { - /* Execute timers in pptask context to make it thread safe */ - wifi_ipc_config_t cfg; + /* Execute timers in pptask context to make it thread safe */ + wifi_ipc_config_t cfg; - cfg.fn = eloop_run_wrapper; - cfg.arg = NULL; - cfg.arg_size = 0; - esp_wifi_ipc_internal(&cfg, false); + cfg.fn = eloop_run_wrapper; + cfg.arg = NULL; + cfg.arg_size = 0; + esp_wifi_ipc_internal(&cfg, false); } int eloop_init(void) { - os_memset(&eloop, 0, sizeof(eloop)); - dl_list_init(&eloop.timeout); - os_timer_disarm(&eloop.eloop_timer); - os_timer_setfn(&eloop.eloop_timer, (ETSTimerFunc *)eloop_run_timer, NULL); + os_memset(&eloop, 0, sizeof(eloop)); + dl_list_init(&eloop.timeout); + os_timer_disarm(&eloop.eloop_timer); + os_timer_setfn(&eloop.eloop_timer, (ETSTimerFunc *)eloop_run_timer, NULL); - eloop_data_lock = os_recursive_mutex_create(); + eloop_data_lock = os_recursive_mutex_create(); - if (!eloop_data_lock) { - wpa_printf(MSG_ERROR, "failed to create eloop data loop"); - return -1; - } - eloop.eloop_started = true; + if (!eloop_data_lock) { + wpa_printf(MSG_ERROR, "failed to create eloop data loop"); + return -1; + } + eloop.eloop_started = true; - return 0; + return 0; } #ifdef ELOOP_DEBUG int eloop_register_timeout_debug(unsigned int secs, unsigned int usecs, - eloop_timeout_handler handler, void *eloop_data, - void *user_data, const char *func, int line) + eloop_timeout_handler handler, void *eloop_data, + void *user_data, const char *func, int line) #else int eloop_register_timeout(unsigned int secs, unsigned int usecs, - eloop_timeout_handler handler, - void *eloop_data, void *user_data) + eloop_timeout_handler handler, + void *eloop_data, void *user_data) #endif { - struct eloop_timeout *timeout, *tmp; - os_time_t now_sec; + struct eloop_timeout *timeout, *tmp; + os_time_t now_sec; #ifdef ELOOP_DEBUG - int count = 0; + int count = 0; #endif - timeout = os_zalloc(sizeof(*timeout)); - if (timeout == NULL) - return -1; - if (os_get_reltime(&timeout->time) < 0) { - os_free(timeout); - return -1; - } - now_sec = timeout->time.sec; - timeout->time.sec += secs; - if (timeout->time.sec < now_sec) - goto overflow; - timeout->time.usec += usecs; - while (timeout->time.usec >= 1000000) { - timeout->time.sec++; - timeout->time.usec -= 1000000; - } - if (timeout->time.sec < now_sec) - goto overflow; - timeout->eloop_data = eloop_data; - timeout->user_data = user_data; - timeout->handler = handler; + timeout = os_zalloc(sizeof(*timeout)); + if (timeout == NULL) { + return -1; + } + if (os_get_reltime(&timeout->time) < 0) { + os_free(timeout); + return -1; + } + now_sec = timeout->time.sec; + timeout->time.sec += secs; + if (timeout->time.sec < now_sec) { + goto overflow; + } + timeout->time.usec += usecs; + while (timeout->time.usec >= 1000000) { + timeout->time.sec++; + timeout->time.usec -= 1000000; + } + if (timeout->time.sec < now_sec) { + goto overflow; + } + timeout->eloop_data = eloop_data; + timeout->user_data = user_data; + timeout->handler = handler; #ifdef ELOOP_DEBUG - os_strlcpy(timeout->func_name, func, 100); - timeout->line = line; + os_strlcpy(timeout->func_name, func, 100); + timeout->line = line; #endif - /* Maintain timeouts in order of increasing time */ - dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { - if (os_reltime_before(&timeout->time, &tmp->time)) { - ELOOP_LOCK(); - dl_list_add(tmp->list.prev, &timeout->list); - ELOOP_UNLOCK(); - goto run; - } + /* Maintain timeouts in order of increasing time */ + dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { + if (os_reltime_before(&timeout->time, &tmp->time)) { + ELOOP_LOCK(); + dl_list_add(tmp->list.prev, &timeout->list); + ELOOP_UNLOCK(); + goto run; + } #ifdef ELOOP_DEBUG - count++; + count++; #endif - } - ELOOP_LOCK(); - dl_list_add_tail(&eloop.timeout, &timeout->list); - ELOOP_UNLOCK(); + } + ELOOP_LOCK(); + dl_list_add_tail(&eloop.timeout, &timeout->list); + ELOOP_UNLOCK(); run: #ifdef ELOOP_DEBUG - wpa_printf(MSG_DEBUG, "ELOOP: Added one timer from %s:%d to call %p, current order=%d", - timeout->func_name, line, timeout->handler, count); + wpa_printf(MSG_DEBUG, "ELOOP: Added one timer from %s:%d to call %p, current order=%d", + timeout->func_name, line, timeout->handler, count); #endif - ELOOP_LOCK(); - os_timer_disarm(&eloop.eloop_timer); - os_timer_arm(&eloop.eloop_timer, 0, 0); - ELOOP_UNLOCK(); + ELOOP_LOCK(); + os_timer_disarm(&eloop.eloop_timer); + os_timer_arm(&eloop.eloop_timer, 0, 0); + ELOOP_UNLOCK(); - return 0; + return 0; overflow: - /* - * Integer overflow - assume long enough timeout to be assumed - * to be infinite, i.e., the timeout would never happen. - */ - wpa_printf(MSG_DEBUG, - "ELOOP: Too long timeout (secs=%u usecs=%u) to ever happen - ignore it", - secs,usecs); - os_free(timeout); - return 0; + /* + * Integer overflow - assume long enough timeout to be assumed + * to be infinite, i.e., the timeout would never happen. + */ + wpa_printf(MSG_DEBUG, + "ELOOP: Too long timeout (secs=%u usecs=%u) to ever happen - ignore it", + secs, usecs); + os_free(timeout); + return 0; } static bool timeout_exists(struct eloop_timeout *old) { - struct eloop_timeout *timeout, *prev; - dl_list_for_each_safe(timeout, prev, &eloop.timeout, - struct eloop_timeout, list) { - if (old == timeout) - return true; - } - - return false; + struct eloop_timeout *timeout, *prev; + dl_list_for_each_safe(timeout, prev, &eloop.timeout, + struct eloop_timeout, list) { + if (old == timeout) { + return true; + } + } + + return false; } static void eloop_remove_timeout(struct eloop_timeout *timeout) { - bool timeout_present = false; - ELOOP_LOCK(); - /* Make sure timeout still exists(Another context may have deleted this) */ - timeout_present = timeout_exists(timeout); - if (timeout_present) - dl_list_del(&timeout->list); - ELOOP_UNLOCK(); - if (timeout_present) - os_free(timeout); + bool timeout_present = false; + ELOOP_LOCK(); + /* Make sure timeout still exists(Another context may have deleted this) */ + timeout_present = timeout_exists(timeout); + if (timeout_present) { + dl_list_del(&timeout->list); + } + ELOOP_UNLOCK(); + if (timeout_present) { + os_free(timeout); + } } #ifdef ELOOP_DEBUG int eloop_cancel_timeout_debug(eloop_timeout_handler handler, void *eloop_data, - void *user_data, const char *func, int line) + void *user_data, const char *func, int line) #else int eloop_cancel_timeout(eloop_timeout_handler handler, - void *eloop_data, void *user_data) + void *eloop_data, void *user_data) #endif { - struct eloop_timeout *timeout, *prev; - int removed = 0; - - dl_list_for_each_safe(timeout, prev, &eloop.timeout, - struct eloop_timeout, list) { - if (timeout->handler == handler && - (timeout->eloop_data == eloop_data || - eloop_data == ELOOP_ALL_CTX) && - (timeout->user_data == user_data || - user_data == ELOOP_ALL_CTX)) { - eloop_remove_timeout(timeout); - removed++; - } - } + struct eloop_timeout *timeout, *prev; + int removed = 0; + + dl_list_for_each_safe(timeout, prev, &eloop.timeout, + struct eloop_timeout, list) { + if (timeout->handler == handler && + (timeout->eloop_data == eloop_data || + eloop_data == ELOOP_ALL_CTX) && + (timeout->user_data == user_data || + user_data == ELOOP_ALL_CTX)) { + eloop_remove_timeout(timeout); + removed++; + } + } #ifdef ELOOP_DEBUG - wpa_printf(MSG_DEBUG, "ELOOP: %s:%d called to remove timer handler=%p, removed count=%d", - func, line, handler, removed); + wpa_printf(MSG_DEBUG, "ELOOP: %s:%d called to remove timer handler=%p, removed count=%d", + func, line, handler, removed); #endif - return removed; + return removed; } - int eloop_cancel_timeout_one(eloop_timeout_handler handler, - void *eloop_data, void *user_data, - struct os_reltime *remaining) + void *eloop_data, void *user_data, + struct os_reltime *remaining) { - struct eloop_timeout *timeout, *prev; - int removed = 0; - struct os_reltime now; - - os_get_reltime(&now); - remaining->sec = remaining->usec = 0; - - dl_list_for_each_safe(timeout, prev, &eloop.timeout, - struct eloop_timeout, list) { - if (timeout->handler == handler && - (timeout->eloop_data == eloop_data) && - (timeout->user_data == user_data)) { - removed = 1; - if (os_reltime_before(&now, &timeout->time)) - os_reltime_sub(&timeout->time, &now, remaining); - eloop_remove_timeout(timeout); - break; - } - } - return removed; + struct eloop_timeout *timeout, *prev; + int removed = 0; + struct os_reltime now; + + os_get_reltime(&now); + remaining->sec = remaining->usec = 0; + + dl_list_for_each_safe(timeout, prev, &eloop.timeout, + struct eloop_timeout, list) { + if (timeout->handler == handler && + (timeout->eloop_data == eloop_data) && + (timeout->user_data == user_data)) { + removed = 1; + if (os_reltime_before(&now, &timeout->time)) { + os_reltime_sub(&timeout->time, &now, remaining); + } + eloop_remove_timeout(timeout); + break; + } + } + return removed; } - int eloop_is_timeout_registered(eloop_timeout_handler handler, - void *eloop_data, void *user_data) + void *eloop_data, void *user_data) { - struct eloop_timeout *tmp; + struct eloop_timeout *tmp; - dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { - if (tmp->handler == handler && - tmp->eloop_data == eloop_data && - tmp->user_data == user_data) - return 1; - } + dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { + if (tmp->handler == handler && + tmp->eloop_data == eloop_data && + tmp->user_data == user_data) { + return 1; + } + } - return 0; + return 0; } - int eloop_deplete_timeout(unsigned int req_secs, unsigned int req_usecs, - eloop_timeout_handler handler, void *eloop_data, - void *user_data) + eloop_timeout_handler handler, void *eloop_data, + void *user_data) { - struct os_reltime now, requested, remaining; - struct eloop_timeout *tmp; - - dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { - if (tmp->handler == handler && - tmp->eloop_data == eloop_data && - tmp->user_data == user_data) { - requested.sec = req_secs; - requested.usec = req_usecs; - os_get_reltime(&now); - os_reltime_sub(&tmp->time, &now, &remaining); - if (os_reltime_before(&requested, &remaining)) { - eloop_cancel_timeout(handler, eloop_data, - user_data); - eloop_register_timeout(requested.sec, - requested.usec, - handler, eloop_data, - user_data); - return 1; - } - return 0; - } - } - - return -1; + struct os_reltime now, requested, remaining; + struct eloop_timeout *tmp; + + dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { + if (tmp->handler == handler && + tmp->eloop_data == eloop_data && + tmp->user_data == user_data) { + requested.sec = req_secs; + requested.usec = req_usecs; + os_get_reltime(&now); + os_reltime_sub(&tmp->time, &now, &remaining); + if (os_reltime_before(&requested, &remaining)) { + eloop_cancel_timeout(handler, eloop_data, + user_data); + eloop_register_timeout(requested.sec, + requested.usec, + handler, eloop_data, + user_data); + return 1; + } + return 0; + } + } + + return -1; } - int eloop_replenish_timeout(unsigned int req_secs, unsigned int req_usecs, - eloop_timeout_handler handler, void *eloop_data, - void *user_data) + eloop_timeout_handler handler, void *eloop_data, + void *user_data) { - struct os_reltime now, requested, remaining; - struct eloop_timeout *tmp; - - dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { - if (tmp->handler == handler && - tmp->eloop_data == eloop_data && - tmp->user_data == user_data) { - requested.sec = req_secs; - requested.usec = req_usecs; - os_get_reltime(&now); - os_reltime_sub(&tmp->time, &now, &remaining); - if (os_reltime_before(&remaining, &requested)) { - eloop_cancel_timeout(handler, eloop_data, - user_data); - eloop_register_timeout(requested.sec, - requested.usec, - handler, eloop_data, - user_data); - return 1; - } - return 0; - } - } - - return -1; + struct os_reltime now, requested, remaining; + struct eloop_timeout *tmp; + + dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { + if (tmp->handler == handler && + tmp->eloop_data == eloop_data && + tmp->user_data == user_data) { + requested.sec = req_secs; + requested.usec = req_usecs; + os_get_reltime(&now); + os_reltime_sub(&tmp->time, &now, &remaining); + if (os_reltime_before(&remaining, &requested)) { + eloop_cancel_timeout(handler, eloop_data, + user_data); + eloop_register_timeout(requested.sec, + requested.usec, + handler, eloop_data, + user_data); + return 1; + } + return 0; + } + } + + return -1; } void eloop_run(void) { - struct os_reltime tv, now; - - while (!dl_list_empty(&eloop.timeout)) { - struct eloop_timeout *timeout; - - timeout = dl_list_first(&eloop.timeout, struct eloop_timeout, - list); - if (timeout) { - os_get_reltime(&now); - if (os_reltime_before(&now, &timeout->time)) { - /* we don't need to process it rn, do it later */ - uint32_t ms; - os_reltime_sub(&timeout->time, &now, &tv); - ms = tv.sec * 1000 + tv.usec / 1000; - ELOOP_LOCK(); - os_timer_disarm(&eloop.eloop_timer); - os_timer_arm(&eloop.eloop_timer, ms, 0); - ELOOP_UNLOCK(); - goto out; - } - } - - /* check if some registered timeouts have occurred */ - timeout = dl_list_first(&eloop.timeout, struct eloop_timeout, - list); - if (timeout) { - os_get_reltime(&now); - if (!os_reltime_before(&now, &timeout->time)) { - void *eloop_data = timeout->eloop_data; - void *user_data = timeout->user_data; - eloop_timeout_handler handler = - timeout->handler; + struct os_reltime tv, now; + + while (!dl_list_empty(&eloop.timeout)) { + struct eloop_timeout *timeout; + + timeout = dl_list_first(&eloop.timeout, struct eloop_timeout, + list); + if (timeout) { + os_get_reltime(&now); + if (os_reltime_before(&now, &timeout->time)) { + /* we don't need to process it rn, do it later */ + uint32_t ms; + os_reltime_sub(&timeout->time, &now, &tv); + ms = tv.sec * 1000 + tv.usec / 1000; + ELOOP_LOCK(); + os_timer_disarm(&eloop.eloop_timer); + os_timer_arm(&eloop.eloop_timer, ms, 0); + ELOOP_UNLOCK(); + goto out; + } + } + + /* check if some registered timeouts have occurred */ + timeout = dl_list_first(&eloop.timeout, struct eloop_timeout, + list); + if (timeout) { + os_get_reltime(&now); + if (!os_reltime_before(&now, &timeout->time)) { + void *eloop_data = timeout->eloop_data; + void *user_data = timeout->user_data; + eloop_timeout_handler handler = + timeout->handler; #ifdef ELOOP_DEBUG - char fn_name[100] = {0}; - int line = timeout->line; - os_strlcpy(fn_name, timeout->func_name, 100); + char fn_name[100] = {0}; + int line = timeout->line; + os_strlcpy(fn_name, timeout->func_name, 100); #endif - eloop_remove_timeout(timeout); + eloop_remove_timeout(timeout); #ifdef ELOOP_DEBUG - wpa_printf(MSG_DEBUG, "ELOOP: Running timer fn:%p scheduled by %s:%d ", - handler, fn_name, line); + wpa_printf(MSG_DEBUG, "ELOOP: Running timer fn:%p scheduled by %s:%d ", + handler, fn_name, line); #endif - handler(eloop_data, user_data); - } - } - } + handler(eloop_data, user_data); + } + } + } out: - return; + return; } void eloop_destroy(void) { - struct eloop_timeout *timeout, *prev; - struct os_reltime now; - - if (!eloop.eloop_started) { - return; - } - os_get_reltime(&now); - dl_list_for_each_safe(timeout, prev, &eloop.timeout, - struct eloop_timeout, list) { - int sec, usec; - sec = timeout->time.sec - now.sec; - usec = timeout->time.usec - now.usec; - if (timeout->time.usec < now.usec) { - sec--; - usec += 1000000; - } - wpa_printf(MSG_INFO, "ELOOP: remaining timeout: %d.%06d " - "eloop_data=%p user_data=%p handler=%p", - sec, usec, timeout->eloop_data, timeout->user_data, - timeout->handler); - eloop_remove_timeout(timeout); - } - if (eloop_data_lock) { - os_semphr_delete(eloop_data_lock); - eloop_data_lock = NULL; - } - os_timer_disarm(&eloop.eloop_timer); - os_timer_done(&eloop.eloop_timer); - os_memset(&eloop, 0, sizeof(eloop)); + struct eloop_timeout *timeout, *prev; + struct os_reltime now; + + if (!eloop.eloop_started) { + return; + } + os_get_reltime(&now); + dl_list_for_each_safe(timeout, prev, &eloop.timeout, + struct eloop_timeout, list) { + int sec, usec; + sec = timeout->time.sec - now.sec; + usec = timeout->time.usec - now.usec; + if (timeout->time.usec < now.usec) { + sec--; + usec += 1000000; + } + wpa_printf(MSG_INFO, "ELOOP: remaining timeout: %d.%06d " + "eloop_data=%p user_data=%p handler=%p", + sec, usec, timeout->eloop_data, timeout->user_data, + timeout->handler); + eloop_remove_timeout(timeout); + } + if (eloop_data_lock) { + os_mutex_delete(eloop_data_lock); + eloop_data_lock = NULL; + } + os_timer_disarm(&eloop.eloop_timer); + os_timer_done(&eloop.eloop_timer); + os_memset(&eloop, 0, sizeof(eloop)); } diff --git a/components/wpa_supplicant/src/ap/ap_config.h b/components/wpa_supplicant/src/ap/ap_config.h index 486d802a11..1d11dd4816 100644 --- a/components/wpa_supplicant/src/ap/ap_config.h +++ b/components/wpa_supplicant/src/ap/ap_config.h @@ -382,9 +382,9 @@ const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf, const u8 *addr, const u8 *prev_psk); int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf); struct sta_info; -bool wpa_ap_join(struct sta_info *sta, uint8_t *bssid, uint8_t *wpa_ie, +bool hostap_new_assoc_sta(struct sta_info *sta, uint8_t *bssid, uint8_t *wpa_ie, uint8_t wpa_ie_len,uint8_t *rsnxe, uint8_t rsnxe_len, - bool *pmf_enable, int subtype, uint8_t *pairwise_cipher); + bool *pmf_enable, int subtype, uint8_t *pairwise_cipher, uint8_t *reason); bool wpa_ap_remove(u8* bssid); #endif /* HOSTAPD_CONFIG_H */ diff --git a/components/wpa_supplicant/src/ap/ieee802_11.c b/components/wpa_supplicant/src/ap/ieee802_11.c index e8dbc7f067..9fad4fd34d 100644 --- a/components/wpa_supplicant/src/ap/ieee802_11.c +++ b/components/wpa_supplicant/src/ap/ieee802_11.c @@ -402,6 +402,65 @@ static int sae_status_success(struct hostapd_data *hapd, u16 status_code) } +static int sae_is_group_enabled(struct hostapd_data *hapd, int group) +{ + int *groups = NULL; + int default_groups[] = { 19, 0 }; + int i; + + if (!groups) { + groups = default_groups; + } + + for (i = 0; groups[i] > 0; i++) { + if (groups[i] == group) + return 1; + } + + return 0; +} + + +static int check_sae_rejected_groups(struct hostapd_data *hapd, + struct sae_data *sae) +{ + const struct wpabuf *groups; + size_t i, count, len; + const u8 *pos; + + if (!sae->tmp) + return 0; + groups = sae->tmp->peer_rejected_groups; + if (!groups) + return 0; + + pos = wpabuf_head(groups); + len = wpabuf_len(groups); + if (len & 1) { + wpa_printf(MSG_DEBUG, + "SAE: Invalid length of the Rejected Groups element payload: %zu", + len); + return 1; + } + + count = len / 2; + for (i = 0; i < count; i++) { + int enabled; + u16 group; + + group = WPA_GET_LE16(pos); + pos += 2; + enabled = sae_is_group_enabled(hapd, group); + wpa_printf(MSG_DEBUG, "SAE: Rejected group %u is %s", + group, enabled ? "enabled" : "disabled"); + if (enabled) + return 1; + } + + return 0; +} + + int handle_auth_sae(struct hostapd_data *hapd, struct sta_info *sta, u8 *buf, size_t len, u8 *bssid, u16 auth_transaction, u16 status) @@ -495,6 +554,11 @@ int handle_auth_sae(struct hostapd_data *hapd, struct sta_info *sta, goto remove_sta; } + if (check_sae_rejected_groups(hapd, sta->sae)) { + resp = WLAN_STATUS_UNSPECIFIED_FAILURE; + goto reply; + } + if (resp != WLAN_STATUS_SUCCESS) { goto reply; } diff --git a/components/wpa_supplicant/src/ap/wpa_auth.c b/components/wpa_supplicant/src/ap/wpa_auth.c index 513ec9fa82..58748a85ff 100644 --- a/components/wpa_supplicant/src/ap/wpa_auth.c +++ b/components/wpa_supplicant/src/ap/wpa_auth.c @@ -13,7 +13,6 @@ #include "common/ieee802_11_defs.h" #include "common/sae.h" #include "ap/sta_info.h" -#include "ap/ieee802_11.h" #include "ap/wpa_auth.h" #include "ap/wpa_auth_i.h" #include "ap/wpa_auth_ie.h" @@ -36,7 +35,6 @@ #include "esp_wifi.h" #include "esp_private/wifi.h" #include "esp_wpas_glue.h" -#include "esp_wps_i.h" #include "esp_hostap.h" #define STATE_MACHINE_DATA struct wpa_state_machine @@ -2557,97 +2555,6 @@ void wpa_deinit(struct wpa_authenticator *wpa_auth) } -#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT -bool wpa_ap_join(struct sta_info *sta, uint8_t *bssid, uint8_t *wpa_ie, - uint8_t wpa_ie_len, uint8_t *rsnxe, uint8_t rsnxe_len, - bool *pmf_enable, int subtype, uint8_t *pairwise_cipher) -{ - struct hostapd_data *hapd = (struct hostapd_data*)esp_wifi_get_hostap_private_internal(); - enum wpa_validate_result status_code = WPA_IE_OK; - int resp = WLAN_STATUS_SUCCESS; - bool omit_rsnxe = false; - - if (!sta || !bssid || !wpa_ie) { - return false; - } - - if (hapd) { - if (hapd->wpa_auth->conf.wpa) { - if (sta->wpa_sm){ - wpa_auth_sta_deinit(sta->wpa_sm); - } - - sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth, bssid); - wpa_printf( MSG_DEBUG, "init wpa sm=%p", sta->wpa_sm); - - if (sta->wpa_sm == NULL) { - resp = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; - goto send_resp; - } - - status_code = wpa_validate_wpa_ie(hapd->wpa_auth, sta->wpa_sm, wpa_ie, wpa_ie_len, rsnxe, rsnxe_len); - -#ifdef CONFIG_SAE - if (wpa_auth_uses_sae(sta->wpa_sm) && sta->sae && - sta->sae->state == SAE_ACCEPTED) { - wpa_auth_add_sae_pmkid(sta->wpa_sm, sta->sae->pmkid); - } -#endif /* CONFIG_SAE */ - - resp = wpa_res_to_status_code(status_code); - -send_resp: - if (!rsnxe) { - omit_rsnxe = true; - } - - if (esp_send_assoc_resp(hapd, bssid, resp, omit_rsnxe, subtype) != WLAN_STATUS_SUCCESS) { - resp = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; - } - - if (resp != WLAN_STATUS_SUCCESS) { - return false; - } - - //Check whether AP uses Management Frame Protection for this connection - *pmf_enable = wpa_auth_uses_mfp(sta->wpa_sm); - *pairwise_cipher = GET_BIT_POSITION(sta->wpa_sm->pairwise); - } - - wpa_auth_sta_associated(hapd->wpa_auth, sta->wpa_sm); - } - - return true; -} - -bool wpa_ap_remove(u8* bssid) -{ - struct hostapd_data *hapd = hostapd_get_hapd_data(); - - if (!hapd) { - return false; - } - struct sta_info *sta = ap_get_sta(hapd, bssid); - if (!sta) { - return false; - } - -#ifdef CONFIG_SAE - if (sta->lock) { - if (os_semphr_take(sta->lock, 0)) { - ap_free_sta(hapd, sta); - } else { - sta->remove_pending = true; - } - return true; - } -#endif /* CONFIG_SAE */ - ap_free_sta(hapd, sta); - - return true; -} -#endif /* CONFIG_ESP_WIFI_SOFTAP_SUPPORT */ - void wpa_auth_pmksa_remove(struct wpa_authenticator *wpa_auth, const u8 *sta_addr) { diff --git a/components/wpa_supplicant/src/common/defs.h b/components/wpa_supplicant/src/common/defs.h index 6799370dec..26c8d5f17b 100644 --- a/components/wpa_supplicant/src/common/defs.h +++ b/components/wpa_supplicant/src/common/defs.h @@ -48,6 +48,7 @@ typedef enum { FALSE = 0, TRUE = 1 } Boolean; #define WPA_KEY_MGMT_IEEE8021X_SUITE_B BIT(16) #define WPA_KEY_MGMT_IEEE8021X_SUITE_B_192 BIT(17) #define WPA_KEY_MGMT_OWE BIT(22) +#define WPA_KEY_MGMT_DPP BIT(23) static inline int wpa_key_mgmt_wpa_ieee8021x(int akm) { diff --git a/components/wpa_supplicant/src/common/ieee802_11_defs.h b/components/wpa_supplicant/src/common/ieee802_11_defs.h index 3c7eab6a44..ec1b0ac444 100644 --- a/components/wpa_supplicant/src/common/ieee802_11_defs.h +++ b/components/wpa_supplicant/src/common/ieee802_11_defs.h @@ -186,6 +186,8 @@ #define WLAN_REASON_INVALID_RSN_IE_CAPAB 22 #define WLAN_REASON_IEEE_802_1X_AUTH_FAILED 23 #define WLAN_REASON_CIPHER_SUITE_REJECTED 24 +#define WLAN_REASON_INVALID_PMKID 49 +#define WLAN_REASON_INVALID_MDE 50 /* Information Element IDs (IEEE Std 802.11-2016, 9.4.2.1, Table 9-77) */ #define WLAN_EID_SSID 0 diff --git a/components/wpa_supplicant/src/common/sae.c b/components/wpa_supplicant/src/common/sae.c index e97f99d449..a533c92346 100644 --- a/components/wpa_supplicant/src/common/sae.c +++ b/components/wpa_supplicant/src/common/sae.c @@ -314,7 +314,7 @@ static int sae_derive_pwe_ecc(struct sae_data *sae, const u8 *addr1, if (dragonfly_get_random_qr_qnr(sae->tmp->prime, &qr, &qnr) < 0 || crypto_bignum_to_bin(qr, qr_bin, sizeof(qr_bin), prime_len) < 0 || crypto_bignum_to_bin(qnr, qnr_bin, sizeof(qnr_bin), prime_len) < 0) - goto fail; + goto fail; wpa_hexdump_ascii_key(MSG_DEBUG, "SAE: password", password, password_len); @@ -1542,7 +1542,7 @@ static int sae_derive_keys(struct sae_data *sae, const u8 *k) * zero padding it from left to the length of the order (in full * octets). */ if (crypto_bignum_to_bin(tmp, val, sizeof(val), - sae->tmp->order_len) < 0) { + sae->tmp->order_len) < 0) { goto fail; } wpa_hexdump(MSG_DEBUG, "SAE: PMKID", val, SAE_PMKID_LEN); @@ -1568,7 +1568,9 @@ static int sae_derive_keys(struct sae_data *sae, const u8 *k) forced_memzero(keyseed, sizeof(keyseed)); os_memcpy(sae->tmp->kck, keys, hash_len); + sae->tmp->kck_len = hash_len; os_memcpy(sae->pmk, keys + hash_len, SAE_PMK_LEN); + sae->pmk_len = SAE_PMK_LEN; os_memcpy(sae->pmkid, val, SAE_PMKID_LEN); #ifdef CONFIG_SAE_PK @@ -1581,7 +1583,7 @@ static int sae_derive_keys(struct sae_data *sae, const u8 *k) #endif /* CONFIG_SAE_PK */ forced_memzero(keys, sizeof(keys)); wpa_hexdump_key(MSG_DEBUG, "SAE: KCK", - sae->tmp->kck, SAE_KCK_LEN); + sae->tmp->kck, sae->tmp->kck_len); wpa_hexdump_key(MSG_DEBUG, "SAE: PMK", sae->pmk, SAE_PMK_LEN); ret = 0; @@ -2016,8 +2018,11 @@ static int sae_parse_rejected_groups(struct sae_data *sae, wpa_hexdump(MSG_DEBUG, "SAE: Possible elements at the end of the frame", *pos, end - *pos); - if (!sae_is_rejected_groups_elem(*pos, end)) + if (!sae_is_rejected_groups_elem(*pos, end)) { + wpabuf_free(sae->tmp->peer_rejected_groups); + sae->tmp->peer_rejected_groups = NULL; return WLAN_STATUS_SUCCESS; + } epos = *pos; epos++; /* skip IE type */ @@ -2027,6 +2032,12 @@ static int sae_parse_rejected_groups(struct sae_data *sae, epos++; /* skip ext ID */ len--; + if (len & 1) { + wpa_printf(MSG_DEBUG, + "SAE: Invalid length of the Rejected Groups element payload: %u", + len); + return WLAN_STATUS_UNSPECIFIED_FAILURE; + } wpabuf_free(sae->tmp->peer_rejected_groups); sae->tmp->peer_rejected_groups = wpabuf_alloc(len); if (!sae->tmp->peer_rejected_groups) @@ -2077,6 +2088,9 @@ u16 sae_parse_commit(struct sae_data *sae, const u8 *data, size_t len, res = sae_parse_rejected_groups(sae, &pos, end); if (res != WLAN_STATUS_SUCCESS) return res; + } else { + wpabuf_free(sae->tmp->peer_rejected_groups); + sae->tmp->peer_rejected_groups = NULL; } /* Optional Anti-Clogging Token Container element */ @@ -2144,7 +2158,7 @@ static int sae_cn_confirm(struct sae_data *sae, const u8 *sc, len[3] = sae->tmp->prime_len; addr[4] = element2; len[4] = element2_len; - return hkdf_extract(SAE_KCK_LEN, sae->tmp->kck, SAE_KCK_LEN, + return hkdf_extract(SAE_KCK_LEN, sae->tmp->kck, sae->tmp->kck_len, 5, addr, len, confirm); } @@ -2207,10 +2221,12 @@ static int sae_cn_confirm_ffc(struct sae_data *sae, const u8 *sc, int sae_write_confirm(struct sae_data *sae, struct wpabuf *buf) { const u8 *sc; + size_t hash_len; if (sae->tmp == NULL) return ESP_FAIL; + hash_len = sae->tmp->kck_len; /* Send-Confirm */ sc = wpabuf_put(buf, 0); wpabuf_put_le16(buf, sae->send_confirm); @@ -2222,7 +2238,7 @@ int sae_write_confirm(struct sae_data *sae, struct wpabuf *buf) sae->tmp->own_commit_element_ecc, sae->peer_commit_scalar, sae->tmp->peer_commit_element_ecc, - wpabuf_put(buf, SHA256_MAC_LEN))) { + wpabuf_put(buf, hash_len))) { wpa_printf(MSG_ERROR, "SAE: failed generate SAE confirm (ecc)"); return ESP_FAIL; } @@ -2231,7 +2247,7 @@ int sae_write_confirm(struct sae_data *sae, struct wpabuf *buf) sae->tmp->own_commit_element_ffc, sae->peer_commit_scalar, sae->tmp->peer_commit_element_ffc, - wpabuf_put(buf, SHA256_MAC_LEN))) { + wpabuf_put(buf, hash_len))) { wpa_printf(MSG_ERROR, "SAE: failed generate SAE confirm (ffc)"); return ESP_FAIL; } @@ -2243,11 +2259,12 @@ int sae_write_confirm(struct sae_data *sae, struct wpabuf *buf) int sae_check_confirm(struct sae_data *sae, const u8 *data, size_t len) { u8 verifier[SAE_MAX_HASH_LEN]; - size_t hash_len= SAE_KCK_LEN; + size_t hash_len; - if (!sae->tmp) + if (!sae->tmp) { return ESP_FAIL; - + } + hash_len = sae->tmp->kck_len; if (len < 2 + hash_len) { wpa_printf(MSG_DEBUG, "SAE: Too short confirm message"); return ESP_FAIL; diff --git a/components/wpa_supplicant/src/common/sae.h b/components/wpa_supplicant/src/common/sae.h index 77a834cdcd..5d2086b0c2 100644 --- a/components/wpa_supplicant/src/common/sae.h +++ b/components/wpa_supplicant/src/common/sae.h @@ -42,7 +42,8 @@ struct sae_pk { }; struct sae_temporary_data { - u8 kck[SAE_KCK_LEN]; + u8 kck[SAE_MAX_HASH_LEN]; + size_t kck_len; struct crypto_bignum *own_commit_scalar; struct crypto_bignum *own_commit_element_ffc; struct crypto_ec_point *own_commit_element_ecc; @@ -108,14 +109,15 @@ struct sae_data { enum sae_state state; u16 send_confirm; u8 pmk[SAE_PMK_LEN]; + size_t pmk_len; u8 pmkid[SAE_PMKID_LEN]; struct crypto_bignum *peer_commit_scalar; + struct crypto_bignum *peer_commit_scalar_accepted; int group; unsigned int sync; /* protocol instance variable: Sync */ u16 rc; /* protocol instance variable: Rc (received send-confirm) */ struct sae_temporary_data *tmp; - struct crypto_bignum *peer_commit_scalar_accepted; unsigned int h2e:1; unsigned int pk:1; }; diff --git a/components/wpa_supplicant/src/common/wnm_sta.c b/components/wpa_supplicant/src/common/wnm_sta.c index 4d2c7752e5..f3110ee126 100644 --- a/components/wpa_supplicant/src/common/wnm_sta.c +++ b/components/wpa_supplicant/src/common/wnm_sta.c @@ -691,8 +691,10 @@ int wnm_scan_process(struct wpa_supplicant *wpa_s, int reply_on_fail) enum mbo_transition_reject_reason reason = MBO_TRANSITION_REJECT_REASON_UNSPECIFIED; - if (!wpa_s->wnm_neighbor_report_elements) + if (!wpa_s->wnm_neighbor_report_elements) { + wpa_printf(MSG_INFO, "WNM: Neighbor report not available"); return 0; + } wpa_dbg(wpa_s, MSG_DEBUG, "WNM: Process scan results for BSS Transition Management"); @@ -706,7 +708,7 @@ int wnm_scan_process(struct wpa_supplicant *wpa_s, int reply_on_fail) /* Compare the Neighbor Report and scan results */ bss = compare_scan_neighbor_results(wpa_s, 0, &reason); if (!bss) { - wpa_printf(MSG_DEBUG, "WNM: No BSS transition candidate match found"); + wpa_printf(MSG_INFO, "WNM: No BSS transition candidate match found"); status = WNM_BSS_TM_REJECT_NO_SUITABLE_CANDIDATES; goto send_bss_resp_fail; } diff --git a/components/wpa_supplicant/src/common/wpa_common.c b/components/wpa_supplicant/src/common/wpa_common.c index 8cfc1fec83..9a0a0d1fe9 100644 --- a/components/wpa_supplicant/src/common/wpa_common.c +++ b/components/wpa_supplicant/src/common/wpa_common.c @@ -235,27 +235,39 @@ int wpa_ft_parse_ies(const u8 *ies, size_t ies_len, #endif /* CONFIG_IEEE80211R */ -static unsigned int wpa_kck_len(int akmp) +static unsigned int wpa_kck_len(int akmp, size_t pmk_len) { - if (akmp == WPA_KEY_MGMT_IEEE8021X_SUITE_B_192) + switch (akmp) { + case WPA_KEY_MGMT_IEEE8021X_SUITE_B_192: return 24; - return 16; + case WPA_KEY_MGMT_OWE: + return pmk_len / 2; + default: + return 16; + } } -static unsigned int wpa_kek_len(int akmp) +static unsigned int wpa_kek_len(int akmp, size_t pmk_len) { - if (akmp == WPA_KEY_MGMT_IEEE8021X_SUITE_B_192) + switch (akmp) { + case WPA_KEY_MGMT_IEEE8021X_SUITE_B_192: return 32; - return 16; + case WPA_KEY_MGMT_OWE: + return pmk_len <= 32 ? 16 : 32; + default: + return 16; + } } -unsigned int wpa_mic_len(int akmp) +unsigned int wpa_mic_len(int akmp, size_t pmk_len) { - if (akmp == WPA_KEY_MGMT_IEEE8021X_SUITE_B_192) + switch (akmp) { + case WPA_KEY_MGMT_IEEE8021X_SUITE_B_192: return 24; - - return 16; + default: + return 16; + } } static int rsn_selector_to_bitfield(const u8 *s) @@ -783,8 +795,8 @@ int wpa_pmk_r1_to_ptk(const u8 *pmk_r1, const u8 *snonce, const u8 *anonce, os_memcpy(pos, sta_addr, ETH_ALEN); pos += ETH_ALEN; - ptk->kck_len = wpa_kck_len(akmp); - ptk->kek_len = wpa_kek_len(akmp); + ptk->kck_len = wpa_kck_len(akmp, PMK_LEN); + ptk->kek_len = wpa_kek_len(akmp, PMK_LEN); ptk->tk_len = wpa_cipher_key_len(cipher); ptk_len = ptk->kck_len + ptk->kek_len + ptk->tk_len; @@ -826,8 +838,6 @@ int wpa_pmk_r1_to_ptk(const u8 *pmk_r1, const u8 *snonce, const u8 *anonce, #endif /* CONFIG_IEEE80211R */ - - /** * wpa_use_akm_defined - Is AKM-defined Key Descriptor Version used * @akmp: WPA_KEY_MGMT_* used in key derivation @@ -835,15 +845,27 @@ int wpa_pmk_r1_to_ptk(const u8 *pmk_r1, const u8 *snonce, const u8 *anonce, */ int wpa_use_akm_defined(int akmp){ - int ret = 0; - if(wpa_key_mgmt_sae(akmp)) - ret = 1; - return ret; + return akmp == WPA_KEY_MGMT_OSEN || + akmp == WPA_KEY_MGMT_OWE || + akmp == WPA_KEY_MGMT_DPP || + wpa_key_mgmt_sae(akmp) || + wpa_key_mgmt_suite_b(akmp); } +/** + * wpa_use_aes_key_wrap - Is AES Keywrap algorithm used for EAPOL-Key Key Data + * @akmp: WPA_KEY_MGMT_* used in key derivation + * Returns: 1 if AES Keywrap is used; 0 otherwise + * + * Note: AKM 00-0F-AC:1 and 00-0F-AC:2 have special rules for selecting whether + * to use AES Keywrap based on the negotiated pairwise cipher. This function + * does not cover those special cases. + */ int wpa_use_aes_key_wrap(int akmp) { return akmp == WPA_KEY_MGMT_OSEN || + akmp == WPA_KEY_MGMT_OWE || + akmp == WPA_KEY_MGMT_DPP || wpa_key_mgmt_ft(akmp) || wpa_key_mgmt_sha256(akmp) || wpa_key_mgmt_sae(akmp) || @@ -936,6 +958,35 @@ int wpa_eapol_key_mic(const u8 *key, size_t key_len, int akmp, int ver, return 0; } +u32 wpa_akm_to_suite(int akm) +{ +#ifdef CONFIG_IEEE80211R + if (akm & WPA_KEY_MGMT_FT_IEEE8021X) + return RSN_AUTH_KEY_MGMT_FT_802_1X; + if (akm & WPA_KEY_MGMT_FT_PSK) + return RSN_AUTH_KEY_MGMT_FT_PSK; +#endif /* CONFIG_IEEE80211R */ + if (akm & WPA_KEY_MGMT_IEEE8021X_SHA256) + return RSN_AUTH_KEY_MGMT_802_1X_SHA256; + if (akm & WPA_KEY_MGMT_IEEE8021X) + return RSN_AUTH_KEY_MGMT_UNSPEC_802_1X; + if (akm & WPA_KEY_MGMT_PSK_SHA256) + return RSN_AUTH_KEY_MGMT_PSK_SHA256; + if (akm & WPA_KEY_MGMT_PSK) + return RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X; + if (akm & WPA_KEY_MGMT_IEEE8021X_SUITE_B) + return RSN_AUTH_KEY_MGMT_802_1X_SUITE_B; + if (akm & WPA_KEY_MGMT_IEEE8021X_SUITE_B_192) + return RSN_AUTH_KEY_MGMT_802_1X_SUITE_B_192; + if (akm & WPA_KEY_MGMT_SAE) + return RSN_AUTH_KEY_MGMT_SAE; + if (akm & WPA_KEY_MGMT_FT_SAE) + return RSN_AUTH_KEY_MGMT_FT_SAE; + if (akm & WPA_KEY_MGMT_OWE) + return RSN_AUTH_KEY_MGMT_OWE; + return 0; +} + int wpa_compare_rsn_ie(int ft_initial_assoc, const u8 *ie1, size_t ie1len, const u8 *ie2, size_t ie2len) @@ -1099,6 +1150,7 @@ int wpa_pmk_to_ptk(const u8 *pmk, size_t pmk_len, const char *label, return -1; } u8 data[2 * ETH_ALEN + 2 * WPA_NONCE_LEN]; + size_t data_len = 2 * ETH_ALEN + 2 * WPA_NONCE_LEN; u8 tmp[WPA_KCK_MAX_LEN + WPA_KEK_MAX_LEN + WPA_TK_MAX_LEN]; size_t ptk_len; @@ -1120,24 +1172,24 @@ int wpa_pmk_to_ptk(const u8 *pmk, size_t pmk_len, const char *label, WPA_NONCE_LEN); } - ptk->kck_len = wpa_kck_len(akmp); - ptk->kek_len = wpa_kek_len(akmp); + ptk->kck_len = wpa_kck_len(akmp, pmk_len); + ptk->kek_len = wpa_kek_len(akmp, pmk_len); ptk->tk_len = wpa_cipher_key_len(cipher); ptk_len = ptk->kck_len + ptk->kek_len + ptk->tk_len; #if defined(CONFIG_SUITEB192) if (wpa_key_mgmt_sha384(akmp)) { wpa_printf(MSG_DEBUG, "WPA: PTK derivation using PRF(SHA384)"); - if (sha384_prf(pmk, pmk_len, label, data, sizeof(data), + if (sha384_prf(pmk, pmk_len, label, data, data_len, tmp, ptk_len) < 0) return -1; } else #endif if (wpa_key_mgmt_sha256(akmp)) - sha256_prf(pmk, pmk_len, label, data, sizeof(data), + sha256_prf(pmk, pmk_len, label, data, data_len, tmp, ptk_len); else - sha1_prf(pmk, pmk_len, label, data, sizeof(data), tmp, ptk_len); + sha1_prf(pmk, pmk_len, label, data, data_len, tmp, ptk_len); wpa_printf(MSG_DEBUG, "WPA: PTK derivation - A1=" MACSTR " A2=" MACSTR"\n", MAC2STR(addr1), MAC2STR(addr2)); diff --git a/components/wpa_supplicant/src/common/wpa_common.h b/components/wpa_supplicant/src/common/wpa_common.h index 92f5c140d7..23c7e58a49 100644 --- a/components/wpa_supplicant/src/common/wpa_common.h +++ b/components/wpa_supplicant/src/common/wpa_common.h @@ -399,6 +399,7 @@ int wpa_parse_wpa_ie(const u8 *wpa_ie, size_t wpa_ie_len, int wpa_parse_wpa_ie_rsnxe(const u8 *rsnxe_ie, size_t rsnxe_ie_len, struct wpa_ie_data *data); +u32 wpa_akm_to_suite(int akm); int wpa_compare_rsn_ie(int ft_initial_assoc, const u8 *ie1, size_t ie1len, const u8 *ie2, size_t ie2len); @@ -450,7 +451,9 @@ int wpa_parse_wpa_ie_wpa(const u8 *wpa_ie, size_t wpa_ie_len, struct wpa_ie_data *data); int rsn_cipher_put_suites(u8 *pos, int ciphers); -unsigned int wpa_mic_len(int akmp); +unsigned int wpa_mic_len(int akmp, size_t pmk_len); +int wpa_use_akm_defined(int akmp); +int wpa_use_aes_key_wrap(int akmp); int wpa_use_akm_defined(int akmp); int wpa_use_aes_key_wrap(int akmp); diff --git a/components/wpa_supplicant/src/rsn_supp/wpa.c b/components/wpa_supplicant/src/rsn_supp/wpa.c index e4c26f8c23..ee4c584cc9 100644 --- a/components/wpa_supplicant/src/rsn_supp/wpa.c +++ b/components/wpa_supplicant/src/rsn_supp/wpa.c @@ -260,7 +260,7 @@ void wpa_eapol_key_send(struct wpa_sm *sm, const u8 *kck, size_t kck_len, goto out; } wpa_hexdump_key(MSG_DEBUG, "WPA: KCK", kck, kck_len); - wpa_hexdump(MSG_DEBUG, "WPA: Derived Key MIC", key_mic, wpa_mic_len(sm->key_mgmt)); + wpa_hexdump(MSG_DEBUG, "WPA: Derived Key MIC", key_mic, wpa_mic_len(sm->key_mgmt, sm->pmk_len)); wpa_hexdump(MSG_MSGDUMP, "WPA: TX EAPOL-Key", msg, msg_len); wpa_sm_ether_send(sm, dest, proto, msg, msg_len); out: @@ -302,7 +302,7 @@ static void wpa_sm_key_request(struct wpa_sm *sm, int error, int pairwise) return; } - mic_len = wpa_mic_len(sm->key_mgmt); + mic_len = wpa_mic_len(sm->key_mgmt, sm->pmk_len); hdrlen = mic_len == 24 ? sizeof(*reply192) : sizeof(*reply); rbuf = wpa_sm_alloc_eapol(sm, IEEE802_1X_TYPE_EAPOL_KEY, NULL, hdrlen, &rlen, (void *) &reply); @@ -424,11 +424,24 @@ static int wpa_supplicant_get_pmk(struct wpa_sm *sm, //eapol_sm_notify_cached(sm->eapol); #ifdef CONFIG_IEEE80211R sm->xxkey_len = 0; +#ifdef CONFIG_WPA3_SAE + if ((sm->key_mgmt == WPA_KEY_MGMT_FT_SAE) && + sm->pmk_len == PMK_LEN) { + /* Need to allow FT key derivation to proceed with + * PMK from SAE being used as the XXKey in cases where + * the PMKID in msg 1/4 matches the PMKSA entry that was + * just added based on SAE authentication for the + * initial mobility domain association. */ + os_memcpy(sm->xxkey, sm->pmk, sm->pmk_len); + sm->xxkey_len = sm->pmk_len; + } +#endif /* CONFIG_WPA3_SAE */ + #endif /* CONFIG_IEEE80211R */ } else if (wpa_key_mgmt_wpa_ieee8021x(sm->key_mgmt)) { int res = 0, pmk_len; /* For ESP_SUPPLICANT this is already set using wpa_set_pmk*/ - //res = eapol_sm_get_key(sm->eapol, sm->pmk, PMK_LEN); + //res = eapol_sm_get_key(sm->eapol, 0, sm->pmk, PMK_LEN); if (wpa_key_mgmt_sha384(sm->key_mgmt)) pmk_len = PMK_LEN_SUITE_B_192; else @@ -586,7 +599,7 @@ int wpa_supplicant_send_2_of_4(struct wpa_sm *sm, const unsigned char *dst, #endif /* CONFIG_IEEE80211R */ wpa_hexdump(MSG_MSGDUMP, "WPA: WPA IE for msg 2/4\n", wpa_ie, wpa_ie_len); - mic_len = wpa_mic_len(sm->key_mgmt); + mic_len = wpa_mic_len(sm->key_mgmt, sm->pmk_len); hdrlen = mic_len == 24 ? sizeof(*reply192) : sizeof(*reply); rbuf = wpa_sm_alloc_eapol(sm, IEEE802_1X_TYPE_EAPOL_KEY, NULL, hdrlen + wpa_ie_len, @@ -1208,7 +1221,7 @@ static int wpa_supplicant_send_4_of_4(struct wpa_sm *sm, const unsigned char *ds struct wpa_eapol_key_192 *reply192; u8 *rbuf, *key_mic; - mic_len = wpa_mic_len(sm->key_mgmt); + mic_len = wpa_mic_len(sm->key_mgmt, sm->pmk_len); hdrlen = mic_len == 24 ? sizeof(*reply192) : sizeof(*reply); rbuf = wpa_sm_alloc_eapol(sm, IEEE802_1X_TYPE_EAPOL_KEY, NULL, @@ -1577,7 +1590,7 @@ static int wpa_supplicant_send_2_of_2(struct wpa_sm *sm, struct wpa_eapol_key_192 *reply192; u8 *rbuf, *key_mic; - mic_len = wpa_mic_len(sm->key_mgmt); + mic_len = wpa_mic_len(sm->key_mgmt, sm->pmk_len); hdrlen = mic_len == 24 ? sizeof(*reply192) : sizeof(*reply); rbuf = wpa_sm_alloc_eapol(sm, IEEE802_1X_TYPE_EAPOL_KEY, NULL, @@ -1686,7 +1699,7 @@ static int wpa_supplicant_verify_eapol_key_mic(struct wpa_sm *sm, { u8 mic[WPA_EAPOL_KEY_MIC_MAX_LEN]; int ok = 0; - size_t mic_len = wpa_mic_len(sm->key_mgmt); + size_t mic_len = wpa_mic_len(sm->key_mgmt, sm->pmk_len); os_memcpy(mic, key->key_mic, mic_len); if (sm->tptk_set) { @@ -1757,10 +1770,7 @@ static int wpa_supplicant_decrypt_key_data(struct wpa_sm *sm, } } else if (ver == WPA_KEY_INFO_TYPE_HMAC_SHA1_AES || ver == WPA_KEY_INFO_TYPE_AES_128_CMAC || - sm->key_mgmt == WPA_KEY_MGMT_OSEN || - wpa_key_mgmt_suite_b(sm->key_mgmt) || - sm->key_mgmt == WPA_KEY_MGMT_SAE || - sm->key_mgmt == WPA_KEY_MGMT_OWE) { + wpa_use_aes_key_wrap(sm->key_mgmt)) { u8 *buf; if (*key_data_len < 8 || *key_data_len % 8) { wpa_printf(MSG_DEBUG, "WPA: Unsupported " @@ -1863,7 +1873,7 @@ int wpa_sm_rx_eapol(u8 *src_addr, u8 *buf, u32 len) size_t mic_len, keyhdrlen; u8 *key_data; - mic_len = wpa_mic_len(sm->key_mgmt); + mic_len = wpa_mic_len(sm->key_mgmt, sm->pmk_len); keyhdrlen = mic_len == 24 ? sizeof(*key192) : sizeof(*key); if (len < sizeof(*hdr) + keyhdrlen) { @@ -1927,20 +1937,14 @@ int wpa_sm_rx_eapol(u8 *src_addr, u8 *buf, u32 len) if (ver != WPA_KEY_INFO_TYPE_HMAC_MD5_RC4 && #ifdef CONFIG_IEEE80211W ver != WPA_KEY_INFO_TYPE_AES_128_CMAC && -#ifdef CONFIG_WPA3_SAE - sm->key_mgmt != WPA_KEY_MGMT_SAE && -#endif - !wpa_key_mgmt_suite_b(sm->key_mgmt) && -#ifdef CONFIG_OWE_STA - sm->key_mgmt != WPA_KEY_MGMT_OWE && -#endif /* CONFIG_OWE_STA */ #endif - ver != WPA_KEY_INFO_TYPE_HMAC_SHA1_AES) { + ver != WPA_KEY_INFO_TYPE_HMAC_SHA1_AES && + !wpa_use_akm_defined(sm->key_mgmt)) { wpa_printf(MSG_DEBUG, "WPA: Unsupported EAPOL-Key descriptor " "version %d.", ver); goto out; } - if (wpa_key_mgmt_suite_b(sm->key_mgmt) && + if (wpa_use_akm_defined(sm->key_mgmt) && ver != WPA_KEY_INFO_TYPE_AKM_DEFINED) { wpa_msg(NULL, MSG_INFO, "RSN: Unsupported EAPOL-Key descriptor version %d (expected AKM defined = 0)", @@ -1951,20 +1955,15 @@ int wpa_sm_rx_eapol(u8 *src_addr, u8 *buf, u32 len) #ifdef CONFIG_IEEE80211W if (wpa_key_mgmt_sha256(sm->key_mgmt)) { if (ver != WPA_KEY_INFO_TYPE_AES_128_CMAC && - sm->key_mgmt != WPA_KEY_MGMT_OSEN && - !wpa_key_mgmt_suite_b(sm->key_mgmt) && - sm->key_mgmt != WPA_KEY_MGMT_SAE && - sm->key_mgmt != WPA_KEY_MGMT_OWE) { + !wpa_use_akm_defined(sm->key_mgmt)) { goto out; } } else #endif if (sm->pairwise_cipher == WPA_CIPHER_CCMP && - !wpa_key_mgmt_suite_b(sm->key_mgmt) && - ver != WPA_KEY_INFO_TYPE_HMAC_SHA1_AES && - sm->key_mgmt != WPA_KEY_MGMT_SAE && - sm->key_mgmt != WPA_KEY_MGMT_OWE) { + !wpa_use_akm_defined(sm->key_mgmt) && + ver != WPA_KEY_INFO_TYPE_HMAC_SHA1_AES) { wpa_printf(MSG_DEBUG, "WPA: CCMP is used, but EAPOL-Key " "descriptor version (%d) is not 2.", ver); if (sm->group_cipher != WPA_CIPHER_CCMP && @@ -1985,7 +1984,7 @@ int wpa_sm_rx_eapol(u8 *src_addr, u8 *buf, u32 len) #ifdef CONFIG_GCMP if (sm->pairwise_cipher == WPA_CIPHER_GCMP && - !wpa_key_mgmt_suite_b(sm->key_mgmt) && + !wpa_use_akm_defined(sm->key_mgmt) && ver != WPA_KEY_INFO_TYPE_HMAC_SHA1_AES) { wpa_msg(NULL, MSG_INFO, "WPA: GCMP is used, but EAPOL-Key " @@ -2308,13 +2307,15 @@ void wpa_set_profile(u32 wpa_proto, u8 auth_mode) } } -void wpa_set_pmk(uint8_t *pmk, const u8 *pmkid, bool cache_pmksa) +void wpa_set_pmk(uint8_t *pmk, size_t pmk_length, const u8 *pmkid, bool cache_pmksa) { struct wpa_sm *sm = &gWpaSm; int pmk_len; if (wpa_key_mgmt_sha384(sm->key_mgmt)) pmk_len = PMK_LEN_SUITE_B_192; + else if (wpa_key_mgmt_sae(sm->key_mgmt)) + pmk_len = pmk_length; else pmk_len = PMK_LEN; diff --git a/components/wpa_supplicant/src/rsn_supp/wpa.h b/components/wpa_supplicant/src/rsn_supp/wpa.h index 4f7a768fc6..257735d270 100644 --- a/components/wpa_supplicant/src/rsn_supp/wpa.h +++ b/components/wpa_supplicant/src/rsn_supp/wpa.h @@ -38,7 +38,7 @@ struct l2_ethhdr { void wpa_sm_set_state(enum wpa_states state); -void wpa_set_pmk(uint8_t *pmk, const u8 *pmkid, bool cache_pmksa); +void wpa_set_pmk(uint8_t *pmk, size_t pmk_length, const u8 *pmkid, bool cache_pmksa); int wpa_michael_mic_failure(u16 isunicast); diff --git a/components/wpa_supplicant/src/rsn_supp/wpa_ie.c b/components/wpa_supplicant/src/rsn_supp/wpa_ie.c index 12b40ba6c6..2fc2307d71 100644 --- a/components/wpa_supplicant/src/rsn_supp/wpa_ie.c +++ b/components/wpa_supplicant/src/rsn_supp/wpa_ie.c @@ -51,6 +51,7 @@ static int wpa_gen_wpa_ie_wpa(u8 *wpa_ie, size_t wpa_ie_len, { u8 *pos; struct wpa_ie_hdr *hdr; + u32 suite; if (wpa_ie_len < sizeof(*hdr) + WPA_SELECTOR_LEN + 2 + WPA_SELECTOR_LEN + 2 + WPA_SELECTOR_LEN) @@ -62,34 +63,26 @@ static int wpa_gen_wpa_ie_wpa(u8 *wpa_ie, size_t wpa_ie_len, WPA_PUT_LE16(hdr->version, WPA_VERSION); pos = (u8 *) (hdr + 1); - if (group_cipher == WPA_CIPHER_CCMP) { - RSN_SELECTOR_PUT(pos, WPA_CIPHER_SUITE_CCMP); - } else if (group_cipher == WPA_CIPHER_TKIP) { - RSN_SELECTOR_PUT(pos, WPA_CIPHER_SUITE_TKIP); - } else if (group_cipher == WPA_CIPHER_WEP104) { - RSN_SELECTOR_PUT(pos, WPA_CIPHER_SUITE_WEP104); - } else if (group_cipher == WPA_CIPHER_WEP40) { - RSN_SELECTOR_PUT(pos, WPA_CIPHER_SUITE_WEP40); - } else { - wpa_printf(MSG_DEBUG, "Invalid group cipher (%d).", + suite = wpa_cipher_to_suite(WPA_PROTO_WPA, group_cipher); + if (suite == 0) { + wpa_printf(MSG_WARNING, "Invalid group cipher (%d).", group_cipher); return -1; } + RSN_SELECTOR_PUT(pos, suite); pos += WPA_SELECTOR_LEN; *pos++ = 1; *pos++ = 0; - if (pairwise_cipher == WPA_CIPHER_CCMP) { - RSN_SELECTOR_PUT(pos, WPA_CIPHER_SUITE_CCMP); - } else if (pairwise_cipher == WPA_CIPHER_TKIP) { - RSN_SELECTOR_PUT(pos, WPA_CIPHER_SUITE_TKIP); - } else if (pairwise_cipher == WPA_CIPHER_NONE) { - RSN_SELECTOR_PUT(pos, WPA_CIPHER_SUITE_NONE); - } else { - wpa_printf(MSG_DEBUG, "Invalid pairwise cipher (%d).", + suite = wpa_cipher_to_suite(WPA_PROTO_WPA, pairwise_cipher); + if (suite == 0 || + (!wpa_cipher_valid_pairwise(pairwise_cipher) && + pairwise_cipher != WPA_CIPHER_NONE)) { + wpa_printf(MSG_WARNING, "Invalid pairwise cipher (%d).", pairwise_cipher); return -1; } + RSN_SELECTOR_PUT(pos, suite); pos += WPA_SELECTOR_LEN; *pos++ = 1; diff --git a/components/wpa_supplicant/src/wps/wps_attr_parse.h b/components/wpa_supplicant/src/wps/wps_attr_parse.h index 4de27b26d4..ea5c1106ab 100644 --- a/components/wpa_supplicant/src/wps/wps_attr_parse.h +++ b/components/wpa_supplicant/src/wps/wps_attr_parse.h @@ -84,7 +84,11 @@ struct wps_parse_attr { u16 oob_dev_password_len; /* attributes that can occur multiple times */ +#ifdef ESP_SUPPLICANT +#define MAX_CRED_COUNT MAX_WPS_AP_CRED +#else #define MAX_CRED_COUNT 10 +#endif #define MAX_REQ_DEV_TYPE_COUNT 10 unsigned int num_cred; diff --git a/components/xtensa/trax/test/gdbinit b/components/xtensa/trax/test/gdbinit index 05496f4c6e..5f589bdcd5 100644 --- a/components/xtensa/trax/test/gdbinit +++ b/components/xtensa/trax/test/gdbinit @@ -3,7 +3,7 @@ set confirm off # Start OpenOCD and run to the entry function file test.elf -target remote | openocd -c "log_output openocd.log; set ESP_RTOS none; set ESP_FLASH_SIZE 0; set ESP32_ONLYCPU 1" -f board/esp32-ethernet-kit-3.3v.cfg -c "gdb_port pipe; init; reset halt" +target remote | openocd -c "log_output openocd.log; set ESP_RTOS none; set ESP_FLASH_SIZE 0; set ESP_ONLYCPU 1" -f board/esp32-ethernet-kit-3.3v.cfg -c "gdb_port pipe; init; reset halt" thb entry c diff --git a/zephyr/esp32c3/CMakeLists.txt b/zephyr/esp32c3/CMakeLists.txt index 81d9633a83..db9ccfebee 100644 --- a/zephyr/esp32c3/CMakeLists.txt +++ b/zephyr/esp32c3/CMakeLists.txt @@ -392,6 +392,18 @@ if(CONFIG_SOC_SERIES_ESP32C3) ../port/phy/phy_stubs.c ) + if (CONFIG_SOC_ESP32C3_REV_1_1) + set(ECO_BT_LD_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../../components/esp_rom/${CONFIG_SOC_SERIES}/ld/${CONFIG_SOC_SERIES}.rom.eco7_bt_funcs.ld) + else() + set(ECO_BT_LD_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../../components/esp_rom/${CONFIG_SOC_SERIES}/ld/${CONFIG_SOC_SERIES}.rom.eco3_bt_funcs.ld) + endif() + + zephyr_link_libraries( + gcc + -T${CMAKE_CURRENT_SOURCE_DIR}/../../components/esp_rom/${CONFIG_SOC_SERIES}/ld/${CONFIG_SOC_SERIES}.rom.bt_funcs.ld + -T${ECO_BT_LD_FILE} + ) + zephyr_link_libraries_ifndef( CONFIG_BUILD_ONLY_NO_BLOBS ## ble diff --git a/zephyr/esp32c3/src/bt/esp_bt_adapter.c b/zephyr/esp32c3/src/bt/esp_bt_adapter.c index b5d040c08d..6edfc7bdfe 100644 --- a/zephyr/esp32c3/src/bt/esp_bt_adapter.c +++ b/zephyr/esp32c3/src/bt/esp_bt_adapter.c @@ -229,10 +229,9 @@ extern bool API_vhci_host_check_send_available(void); extern void API_vhci_host_send_packet(uint8_t *data, uint16_t len); extern int API_vhci_host_register_callback(const esp_vhci_host_callback_t *callback); /* TX power */ -extern int ble_txpwr_set(int power_type, int power_level); -extern int ble_txpwr_get(int power_type); +extern int ble_txpwr_set(int power_type, uint16_t handle, int power_level); +extern int ble_txpwr_get(int power_type, uint16_t handle); -extern uint16_t l2c_ble_link_get_tx_buf_num(void); extern void coex_pti_v2(void); extern bool btdm_deep_sleep_mem_init(void); @@ -248,6 +247,7 @@ extern void ets_backup_dma_copy(uint32_t reg, uint32_t mem_addr, uint32_t num, b #endif extern void btdm_cca_feature_enable(void); +extern void btdm_aa_check_enhance_enable(void); static int interrupt_alloc_wrapper(int cpu_id, int source, isr_handler_t handler, void *arg, void **ret_handle); static int interrupt_free_wrapper(void *handle); @@ -465,7 +465,7 @@ static int interrupt_alloc_wrapper(int cpu_id, int source, isr_handler_t handler } static int interrupt_free_wrapper(void *handle) -{ +{ /* TODO: implement esp_intr_free() for ESP32-C3 */ return ESP_OK; } @@ -826,10 +826,6 @@ static void btdm_sleep_enter_phase2_wrapper(void) } else { assert(0); } - - if (s_lp_stat.pm_lock_released == 0) { - s_lp_stat.pm_lock_released = 1; - } } } @@ -897,6 +893,15 @@ static bool async_wakeup_request(int event) semphr_take_wrapper(s_wakeup_req_sem, OSI_FUNCS_TIME_BLOCKING); } break; + case BTDM_ASYNC_WAKEUP_REQ_COEX: + if (!btdm_power_state_active()) { + do_wakeup_request = true; + btdm_wakeup_request(); + if (s_lp_cntl.wakeup_timer_required && s_lp_stat.wakeup_timer_started) { + esp_timer_stop(s_btdm_slp_tmr); + s_lp_stat.wakeup_timer_started = 0; + } + } default: break; } @@ -916,6 +921,9 @@ static void async_wakeup_request_end(int event) case BTDM_ASYNC_WAKEUP_SRC_DISA: allow_to_sleep = true; break; + case BTDM_ASYNC_WAKEUP_REQ_COEX: + allow_to_sleep = false; + break; default: allow_to_sleep = true; break; @@ -956,6 +964,9 @@ static void btdm_funcs_table_ready_wrapper(void) #if BT_BLE_CCA_MODE == 2 btdm_cca_feature_enable(); #endif +#if BLE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED + btdm_aa_check_enhance_enable(); +#endif } bool bt_async_wakeup_request(void) @@ -1045,79 +1056,11 @@ static void IRAM_ATTR btdm_mac_bb_power_up_cb(void) } #endif -esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) +// init low-power control resources +static esp_err_t btdm_low_power_mode_init(esp_bt_controller_config_t *cfg) { - esp_err_t err = ESP_FAIL; - - if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) { - return ESP_ERR_INVALID_STATE; - } - - if (cfg == NULL) { - return ESP_ERR_INVALID_ARG; - } - - if (cfg->controller_task_prio != CONFIG_ESP32_BT_CONTROLLER_TASK_PRIO - || cfg->controller_task_stack_size < CONFIG_ESP32_BT_CONTROLLER_STACK_SIZE) { - LOG_ERR("Invalid controller task prioriy or stack size"); - return ESP_ERR_INVALID_ARG; - } - - if (cfg->bluetooth_mode != ESP_BT_MODE_BLE) { - LOG_ERR("%s controller only support BLE only mode", __func__); - return ESP_ERR_NOT_SUPPORTED; - } + esp_err_t err = ESP_OK; - if (cfg->bluetooth_mode & ESP_BT_MODE_BLE) { - if ((cfg->ble_max_act <= 0) || (cfg->ble_max_act > BT_CTRL_BLE_MAX_ACT_LIMIT)) { - LOG_ERR("Invalid value of ble_max_act"); - return ESP_ERR_INVALID_ARG; - } - } - - if (cfg->sleep_mode == ESP_BT_SLEEP_MODE_1) { - if (cfg->sleep_clock == ESP_BT_SLEEP_CLOCK_NONE) { - LOG_ERR("SLEEP_MODE_1 enabled but sleep clock not configured"); - return ESP_ERR_INVALID_ARG; - } - } - - // overwrite some parameters - cfg->magic = ESP_BT_CTRL_CONFIG_MAGIC_VAL; - -#if CONFIG_MAC_BB_PD - esp_mac_bb_pd_mem_init(); -#endif - esp_phy_modem_init(); - esp_bt_power_domain_on(); - - btdm_controller_mem_init(); - -#if CONFIG_MAC_BB_PD - if (esp_register_mac_bb_pd_callback(btdm_mac_bb_power_down_cb) != 0) { - err = ESP_ERR_INVALID_ARG; - goto error; - } - - if (esp_register_mac_bb_pu_callback(btdm_mac_bb_power_up_cb) != 0) { - err = ESP_ERR_INVALID_ARG; - goto error; - } -#endif - - osi_funcs_p = (struct osi_funcs_t *)malloc_internal_wrapper(sizeof(struct osi_funcs_t)); - if (osi_funcs_p == NULL) { - return ESP_ERR_NO_MEM; - } - - memcpy(osi_funcs_p, &osi_funcs_ro, sizeof(struct osi_funcs_t)); - if (btdm_osi_funcs_register(osi_funcs_p) != 0) { - return ESP_ERR_INVALID_ARG; - } - - LOG_INF("BT controller compile version [%s]", btdm_controller_get_compile_version()); - - // init low-power control resources do { // set default values for global states or resources s_lp_stat.val = 0; @@ -1128,13 +1071,14 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) // configure and initialize resources s_lp_cntl.enable = (cfg->sleep_mode == ESP_BT_SLEEP_MODE_1) ? 1 : 0; + s_lp_cntl.lpclk_sel = (cfg->sleep_mode == ESP_BT_SLEEP_MODE_1) ? cfg->sleep_clock : ESP_BT_SLEEP_CLOCK_MAIN_XTAL; s_lp_cntl.no_light_sleep = 0; if (s_lp_cntl.enable) { -#if (CONFIG_MAC_BB_PD) +#if CONFIG_MAC_BB_PD if (!btdm_deep_sleep_mem_init()) { err = ESP_ERR_NO_MEM; - goto error; + break; } s_lp_cntl.mac_bb_pd = 1; #endif @@ -1142,69 +1086,65 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) s_wakeup_req_sem = semphr_create_wrapper(1, 0); if (s_wakeup_req_sem == NULL) { err = ESP_ERR_NO_MEM; - goto error; + break; } btdm_vnd_offload_task_register(BTDM_VND_OL_SIG_WAKEUP_TMR, btdm_sleep_exit_phase0); - } - if (s_lp_cntl.wakeup_timer_required) { - esp_timer_create_args_t create_args = { - .callback = btdm_slp_tmr_callback, - .arg = NULL, - .name = "btSlp", - }; - if ((err = esp_timer_create(&create_args, &s_btdm_slp_tmr)) != ESP_OK) { - goto error; + if (s_lp_cntl.wakeup_timer_required) { + esp_timer_create_args_t create_args = { + .callback = btdm_slp_tmr_callback, + .arg = NULL, + .name = "btSlp", + }; + if ((err = esp_timer_create(&create_args, &s_btdm_slp_tmr)) != ESP_OK) { + break; + } } - } - // set default bluetooth sleep clock cycle and its fractional bits - btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT; - btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac); + // set default bluetooth sleep clock cycle and its fractional bits + btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT; + btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac); - // set default bluetooth sleep clock source - s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value -#if CONFIG_BT_CTRL_LPCLK_SEL_EXT_32K_XTAL - // check whether or not EXT_CRYS is working - if (rtc_clk_slow_freq_get() == SOC_RTC_SLOW_CLK_SRC_XTAL32K) { - s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL32K; // External 32 kHz XTAL - } else { - LOG_WRN("32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock\n" - "light sleep mode will not be able to apply when bluetooth is enabled"); + if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_EXT_32K_XTAL) { // External 32 kHz XTAL + // check whether or not EXT_CRYS is working + if (rtc_clk_slow_src_get() != SOC_RTC_SLOW_CLK_SRC_XTAL32K) { + LOG_WRN("32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock"); + s_lp_cntl.lpclk_sel = ESP_BT_SLEEP_CLOCK_MAIN_XTAL; #if !CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP - s_lp_cntl.no_light_sleep = 1; + s_lp_cntl.no_light_sleep = 1; #endif - } -#elif (CONFIG_BT_CTRL_LPCLK_SEL_MAIN_XTAL) - LOG_WRN("Bluetooth will use main XTAL as Bluetooth sleep clock."); + } + } else if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_RTC_SLOW) { // Internal 136kHz RC oscillator + if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_RC_SLOW) { + LOG_WRN("Internal 136kHz RC oscillator. The accuracy of this clock is a lot larger than 500ppm which is " + "required in Bluetooth communication, so don't select this option in scenarios such as BLE connection state."); + } else { + LOG_WRN("Internal 136kHz RC oscillator not detected."); + assert(0); + } + } else if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_MAIN_XTAL) { + LOG_INF("Bluetooth will use main XTAL as Bluetooth sleep clock."); #if !CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP - s_lp_cntl.no_light_sleep = 1; + s_lp_cntl.no_light_sleep = 1; #endif -#elif (CONFIG_BT_CTRL_LPCLK_SEL_RTC_SLOW) - // check whether or not EXT_CRYS is working - if (rtc_clk_slow_freq_get() == SOC_RTC_SLOW_CLK_SRC_RC_SLOW) { - s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_RTC_SLOW; // Internal 150 kHz RC oscillator - LOG_WRN("Internal 150kHz RC osciallator. The accuracy of this clock is a lot larger than 500ppm which is " - "required in Bluetooth communication, so don't select this option in scenarios such as BLE connection state."); + } } else { - LOG_WRN("Internal 150kHz RC oscillator not detected."); - assert(0); + s_lp_cntl.no_light_sleep = 1; } -#endif bool select_src_ret __attribute__((unused)); bool set_div_ret __attribute__((unused)); - if (s_lp_cntl.lpclk_sel == BTDM_LPCLK_SEL_XTAL) { + if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_MAIN_XTAL) { #ifdef CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP - esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_ON)); + esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_ON); s_lp_cntl.main_xtal_pu = 1; #endif select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL); - set_div_ret = btdm_lpclk_set_div(rtc_clk_xtal_freq_get() / MHZ(1)); + set_div_ret = btdm_lpclk_set_div(esp_clk_xtal_freq() / MHZ(1)); assert(select_src_ret && set_div_ret); btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT; btdm_lpcycle_us = 1 << (btdm_lpcycle_us_frac); - } else if (s_lp_cntl.lpclk_sel == BTDM_LPCLK_SEL_XTAL32K) { + } else if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_EXT_32K_XTAL) { select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL32K); set_div_ret = btdm_lpclk_set_div(0); assert(select_src_ret && set_div_ret); @@ -1212,7 +1152,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) btdm_lpcycle_us = (RTC_CLK_CAL_FRACT > 15) ? (1000000 << (RTC_CLK_CAL_FRACT - 15)) : (1000000 >> (15 - RTC_CLK_CAL_FRACT)); assert(btdm_lpcycle_us != 0); - } else if (s_lp_cntl.lpclk_sel == BTDM_LPCLK_SEL_RTC_SLOW) { + } else if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_RTC_SLOW) { select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_RTC_SLOW); set_div_ret = btdm_lpclk_set_div(0); assert(select_src_ret && set_div_ret); @@ -1220,13 +1160,96 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) btdm_lpcycle_us = esp_clk_slowclk_cal_get(); } else { err = ESP_ERR_INVALID_ARG; - goto error; + break; } #if CONFIG_SW_COEXIST_ENABLE coex_update_lpclk_interval(); #endif + } while (0); + return err; +} + +esp_bt_sleep_clock_t esp_bt_get_lpclk_src(void) +{ + if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_INITED && + btdm_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED) { + return ESP_BT_SLEEP_CLOCK_NONE; + } + + return s_lp_cntl.lpclk_sel; +} + +esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) +{ + esp_err_t err = ESP_FAIL; + + if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) { + return ESP_ERR_INVALID_STATE; + } + + if (cfg == NULL) { + return ESP_ERR_INVALID_ARG; + } + + if (cfg->controller_task_prio != CONFIG_ESP32_BT_CONTROLLER_TASK_PRIO + || cfg->controller_task_stack_size < CONFIG_ESP32_BT_CONTROLLER_STACK_SIZE) { + LOG_ERR("Invalid controller task prioriy or stack size"); + return ESP_ERR_INVALID_ARG; + } + + if (cfg->bluetooth_mode != ESP_BT_MODE_BLE) { + LOG_ERR("%s controller only support BLE only mode", __func__); + return ESP_ERR_NOT_SUPPORTED; + } + + if (cfg->bluetooth_mode & ESP_BT_MODE_BLE) { + if ((cfg->ble_max_act <= 0) || (cfg->ble_max_act > BT_CTRL_BLE_MAX_ACT_LIMIT)) { + LOG_ERR("Invalid value of ble_max_act"); + return ESP_ERR_INVALID_ARG; + } + } + + if (cfg->sleep_mode == ESP_BT_SLEEP_MODE_1) { + if (cfg->sleep_clock == ESP_BT_SLEEP_CLOCK_NONE) { + LOG_ERR("SLEEP_MODE_1 enabled but sleep clock not configured"); + return ESP_ERR_INVALID_ARG; + } + if (cfg->sleep_clock > ESP_BT_SLEEP_CLOCK_RTC_SLOW) { + LOG_ERR("SLEEP_MODE_1 is enabled but this sleep clock is not supported"); + return ESP_ERR_INVALID_ARG; + } + } + + // overwrite some parameters + cfg->magic = ESP_BT_CTRL_CONFIG_MAGIC_VAL; + +#if CONFIG_MAC_BB_PD + esp_mac_bb_pd_mem_init(); +#endif + esp_phy_modem_init(); + esp_bt_power_domain_on(); + + btdm_controller_mem_init(); + + osi_funcs_p = (struct osi_funcs_t *)malloc_internal_wrapper(sizeof(struct osi_funcs_t)); + if (osi_funcs_p == NULL) { + return ESP_ERR_NO_MEM; + } + + memcpy(osi_funcs_p, &osi_funcs_ro, sizeof(struct osi_funcs_t)); + if (btdm_osi_funcs_register(osi_funcs_p) != 0) { + return ESP_ERR_INVALID_ARG; + } + + LOG_INF("BT controller compile version [%s]", btdm_controller_get_compile_version()); + + if ((err = btdm_low_power_mode_init(cfg)) != ESP_OK) { + LOG_ERR("Low power module initialization failed"); + goto error; + } + #if CONFIG_SW_COEXIST_ENABLE coex_init(); #endif @@ -1234,14 +1257,10 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) periph_module_enable(PERIPH_BT_MODULE); periph_module_reset(PERIPH_BT_MODULE); - esp_phy_enable(PHY_MODEM_BT); - s_lp_stat.phy_enabled = 1; - if (btdm_controller_init(cfg) != 0) { err = ESP_ERR_NO_MEM; goto error; } - coex_pti_v2(); btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED; @@ -1267,70 +1286,61 @@ esp_err_t esp_bt_controller_deinit(void) return ESP_OK; } -static void bt_controller_deinit_internal(void) +// deinit low power control resources +static void btdm_low_power_mode_deinit(void) { - periph_module_disable(PERIPH_BT_MODULE); - - if (s_lp_stat.phy_enabled) { - esp_phy_disable(PHY_MODEM_BT); - s_lp_stat.phy_enabled = 0; - } - - // deinit low power control resources - do { - #if CONFIG_MAC_BB_PD - if (s_lp_cntl.mac_bb_pd) { - btdm_deep_sleep_mem_deinit(); - s_lp_cntl.mac_bb_pd = 0; - } + if (s_lp_cntl.mac_bb_pd) { + btdm_deep_sleep_mem_deinit(); + s_lp_cntl.mac_bb_pd = 0; + } #endif - if (s_lp_cntl.wakeup_timer_required) { - if (s_lp_stat.wakeup_timer_started) { - esp_timer_stop(s_btdm_slp_tmr); - } - s_lp_stat.wakeup_timer_started = 0; - esp_timer_delete(s_btdm_slp_tmr); - s_btdm_slp_tmr = NULL; + if (s_lp_cntl.wakeup_timer_required && s_btdm_slp_tmr != NULL) { + if (s_lp_stat.wakeup_timer_started) { + esp_timer_stop(s_btdm_slp_tmr); } + s_lp_stat.wakeup_timer_started = 0; + esp_timer_delete(s_btdm_slp_tmr); + s_btdm_slp_tmr = NULL; + } - if (s_lp_cntl.enable) { - btdm_vnd_offload_task_deregister(BTDM_VND_OL_SIG_WAKEUP_TMR); - if (s_wakeup_req_sem != NULL) { - semphr_delete_wrapper(s_wakeup_req_sem); - s_wakeup_req_sem = NULL; - } + if (s_lp_cntl.enable) { + btdm_vnd_offload_task_deregister(BTDM_VND_OL_SIG_WAKEUP_TMR); + if (s_wakeup_req_sem != NULL) { + semphr_delete_wrapper(s_wakeup_req_sem); + s_wakeup_req_sem = NULL; } + } - if (s_lp_cntl.lpclk_sel == BTDM_LPCLK_SEL_XTAL) { + if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_MAIN_XTAL) { #ifdef CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP - if (s_lp_cntl.main_xtal_pu) { - esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_OFF); - s_lp_cntl.main_xtal_pu = 0; - } + if (s_lp_cntl.main_xtal_pu) { + esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_OFF); + s_lp_cntl.main_xtal_pu = 0; + } #endif - btdm_lpclk_select_src(BTDM_LPCLK_SEL_RTC_SLOW); - btdm_lpclk_set_div(0); + btdm_lpclk_select_src(BTDM_LPCLK_SEL_RTC_SLOW); + btdm_lpclk_set_div(0); #if CONFIG_SW_COEXIST_ENABLE - coex_update_lpclk_interval(); + coex_update_lpclk_interval(); #endif - } + } - btdm_lpcycle_us = 0; - } while (0); + btdm_lpcycle_us = 0; +} -#if CONFIG_MAC_BB_PD - esp_unregister_mac_bb_pd_callback(btdm_mac_bb_power_down_cb); - esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb); -#endif +static void bt_controller_deinit_internal(void) +{ + periph_module_disable(PERIPH_BT_MODULE); + + btdm_low_power_mode_deinit(); esp_bt_power_domain_off(); #if CONFIG_MAC_BB_PD esp_mac_bb_pd_mem_deinit(); #endif esp_phy_modem_deinit(); - if (osi_funcs_p != NULL) { esp_bt_free(osi_funcs_p); osi_funcs_p = NULL; @@ -1352,22 +1362,45 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode) return ESP_ERR_INVALID_ARG; } + /* Enable PHY when enabling controller to reduce power dissipation after controller init + * Notice the init order: esp_phy_enable() -> bt_bb_v2_init_cmplx() -> coex_pti_v2() + */ + esp_phy_enable(PHY_MODEM_BT); + s_lp_stat.phy_enabled = 1; + #if CONFIG_SW_COEXIST_ENABLE coex_enable(); #endif // enable low power mode do { +#if CONFIG_MAC_BB_PD + if (esp_register_mac_bb_pd_callback(btdm_mac_bb_power_down_cb) != 0) { + ret = ESP_ERR_INVALID_ARG; + goto error; + } + + if (esp_register_mac_bb_pu_callback(btdm_mac_bb_power_up_cb) != 0) { + ret = ESP_ERR_INVALID_ARG; + goto error; + } +#endif + if (s_lp_cntl.enable) { btdm_controller_enable_sleep(true); } } while (0); + // Disable pll track by default in BLE controller on ESP32-C3 and ESP32-S3 + sdk_config_extend_set_pll_track(false); + if (btdm_controller_enable(mode) != 0) { ret = ESP_ERR_INVALID_STATE; goto error; } + coex_pti_v2(); + btdm_controller_status = ESP_BT_CONTROLLER_STATUS_ENABLED; return ret; @@ -1375,13 +1408,20 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode) error: // disable low power mode do { +#if CONFIG_MAC_BB_PD + esp_unregister_mac_bb_pd_callback(btdm_mac_bb_power_down_cb); + esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb); +#endif btdm_controller_enable_sleep(false); } while (0); #if CONFIG_SW_COEXIST_ENABLE coex_disable(); #endif - + if (s_lp_stat.phy_enabled) { + esp_phy_disable(PHY_MODEM_BT); + s_lp_stat.phy_enabled = 0; + } return ret; } @@ -1400,9 +1440,21 @@ esp_err_t esp_bt_controller_disable(void) #if CONFIG_SW_COEXIST_ENABLE coex_disable(); #endif + if (s_lp_stat.phy_enabled) { + esp_phy_disable(PHY_MODEM_BT); + s_lp_stat.phy_enabled = 0; + } btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED; + // disable low power mode + do { +#if CONFIG_MAC_BB_PD + esp_unregister_mac_bb_pd_callback(btdm_mac_bb_power_down_cb); + esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb); +#endif + } while (0); + return ESP_OK; } @@ -1411,16 +1463,89 @@ esp_bt_controller_status_t esp_bt_controller_get_status(void) return btdm_controller_status; } +static int enh_power_type_get(esp_ble_power_type_t power_type) +{ + switch (power_type) { + case ESP_BLE_PWR_TYPE_ADV: + return ESP_BLE_ENHANCED_PWR_TYPE_ADV; + case ESP_BLE_PWR_TYPE_SCAN: + return ESP_BLE_ENHANCED_PWR_TYPE_SCAN; + case ESP_BLE_PWR_TYPE_CONN_HDL0: + case ESP_BLE_PWR_TYPE_CONN_HDL1: + case ESP_BLE_PWR_TYPE_CONN_HDL2: + case ESP_BLE_PWR_TYPE_CONN_HDL3: + case ESP_BLE_PWR_TYPE_CONN_HDL4: + case ESP_BLE_PWR_TYPE_CONN_HDL5: + case ESP_BLE_PWR_TYPE_CONN_HDL6: + case ESP_BLE_PWR_TYPE_CONN_HDL7: + case ESP_BLE_PWR_TYPE_CONN_HDL8: + return ESP_BLE_ENHANCED_PWR_TYPE_CONN; + case ESP_BLE_PWR_TYPE_DEFAULT: + return ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT; + default: + break; + } + + return power_type; +} + /* extra functions */ esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level) +{ + esp_err_t stat = ESP_FAIL; + uint16_t handle = BLE_PWR_HDL_INVL; + int enh_pwr_type = enh_power_type_get(power_type); + + if (power_type > ESP_BLE_PWR_TYPE_DEFAULT) { + return ESP_ERR_NOT_SUPPORTED; + } + + if (enh_pwr_type == ESP_BLE_ENHANCED_PWR_TYPE_CONN) { + handle = power_type; + } + + if (ble_txpwr_set(enh_pwr_type, handle, power_level) == 0) { + stat = ESP_OK; + } + + return stat; +} + +esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type) +{ + esp_power_level_t lvl; + uint16_t handle = BLE_PWR_HDL_INVL; + int enh_pwr_type = enh_power_type_get(power_type); + + if (power_type > ESP_BLE_PWR_TYPE_DEFAULT) { + return ESP_PWR_LVL_INVALID; + } + + if (enh_pwr_type == ESP_BLE_ENHANCED_PWR_TYPE_CONN) { + handle = power_type; + } + + lvl = (esp_power_level_t)ble_txpwr_get(enh_pwr_type, handle); + + return lvl; +} + +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) { esp_err_t stat = ESP_FAIL; switch (power_type) { - case ESP_BLE_PWR_TYPE_ADV: - case ESP_BLE_PWR_TYPE_SCAN: - case ESP_BLE_PWR_TYPE_DEFAULT: - if (ble_txpwr_set(power_type, power_level) == 0) { + case ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT: + case ESP_BLE_ENHANCED_PWR_TYPE_SCAN: + case ESP_BLE_ENHANCED_PWR_TYPE_INIT: + if (ble_txpwr_set(power_type, BLE_PWR_HDL_INVL, power_level) == 0) { + stat = ESP_OK; + } + break; + case ESP_BLE_ENHANCED_PWR_TYPE_ADV: + case ESP_BLE_ENHANCED_PWR_TYPE_CONN: + if (ble_txpwr_set(power_type, handle, power_level) == 0) { stat = ESP_OK; } break; @@ -1432,33 +1557,26 @@ esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_ return stat; } -esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type) +esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, + uint16_t handle) { - esp_power_level_t lvl; + int tx_level = 0; switch (power_type) { - case ESP_BLE_PWR_TYPE_ADV: - case ESP_BLE_PWR_TYPE_SCAN: - lvl = (esp_power_level_t)ble_txpwr_get(power_type); + case ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT: + case ESP_BLE_ENHANCED_PWR_TYPE_SCAN: + case ESP_BLE_ENHANCED_PWR_TYPE_INIT: + tx_level = ble_txpwr_get(power_type, BLE_PWR_HDL_INVL); break; - case ESP_BLE_PWR_TYPE_CONN_HDL0: - case ESP_BLE_PWR_TYPE_CONN_HDL1: - case ESP_BLE_PWR_TYPE_CONN_HDL2: - case ESP_BLE_PWR_TYPE_CONN_HDL3: - case ESP_BLE_PWR_TYPE_CONN_HDL4: - case ESP_BLE_PWR_TYPE_CONN_HDL5: - case ESP_BLE_PWR_TYPE_CONN_HDL6: - case ESP_BLE_PWR_TYPE_CONN_HDL7: - case ESP_BLE_PWR_TYPE_CONN_HDL8: - case ESP_BLE_PWR_TYPE_DEFAULT: - lvl = (esp_power_level_t)ble_txpwr_get(ESP_BLE_PWR_TYPE_DEFAULT); + case ESP_BLE_ENHANCED_PWR_TYPE_ADV: + case ESP_BLE_ENHANCED_PWR_TYPE_CONN: + tx_level = ble_txpwr_get(power_type, handle); break; default: - lvl = ESP_PWR_LVL_INVALID; - break; + return ESP_PWR_LVL_INVALID; } - return lvl; + return (esp_power_level_t)tx_level; } esp_err_t esp_bt_sleep_enable (void) @@ -1518,11 +1636,6 @@ int IRAM_ATTR esp_bt_h4tl_eif_io_event_notify(int event) return btdm_hci_tl_io_event_post(event); } -uint16_t esp_bt_get_tx_buf_num(void) -{ - return l2c_ble_link_get_tx_buf_num(); -} - static void coex_wifi_sleep_set_hook(bool sleep) { @@ -1558,4 +1671,4 @@ static void * coex_schm_curr_phase_get_wrapper(void) #else return NULL; #endif -} \ No newline at end of file +} diff --git a/zephyr/esp32c3/src/wifi/esp_wifi_adapter.c b/zephyr/esp32c3/src/wifi/esp_wifi_adapter.c index d9c5065509..231148d64f 100644 --- a/zephyr/esp32c3/src/wifi/esp_wifi_adapter.c +++ b/zephyr/esp32c3/src/wifi/esp_wifi_adapter.c @@ -478,16 +478,15 @@ static int get_time_wrapper(void *t) uint32_t esp_coex_common_clk_slowclk_cal_get_wrapper(void) { - /* The bit width of WiFi light sleep clock calibration is 12 while the one of - * system is 19. It should shift 19 - 12 = 7. - */ - if (GET_PERI_REG_MASK(SYSTEM_BT_LPCK_DIV_FRAC_REG, SYSTEM_LPCLK_SEL_XTAL)) { - uint64_t time_per_us = 1000000ULL; - return (((time_per_us << RTC_CLK_CAL_FRACT) / (MHZ(1))) >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH)); - } - - return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH)); - + /* The bit width of WiFi light sleep clock calibration is 12 while the one of + * system is 19. It should shift 19 - 12 = 7. + */ + if (GET_PERI_REG_MASK(SYSTEM_BT_LPCK_DIV_FRAC_REG, SYSTEM_LPCLK_SEL_XTAL)) { + uint64_t time_per_us = 1000000ULL; + return (((time_per_us << RTC_CLK_CAL_FRACT) / (MHZ(1))) >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH)); + } else { + return (esp_clk_slowclk_cal_get() >> (RTC_CLK_CAL_FRACT - SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH)); + } } static void *IRAM_ATTR malloc_internal_wrapper(size_t size) diff --git a/zephyr/esp32c6/CMakeLists.txt b/zephyr/esp32c6/CMakeLists.txt index 385fb919aa..95c4c2fe17 100644 --- a/zephyr/esp32c6/CMakeLists.txt +++ b/zephyr/esp32c6/CMakeLists.txt @@ -349,6 +349,7 @@ if(CONFIG_SOC_SERIES_ESP32C6) ## esp-idf wifi libs refer gcc libs symbols, so linked in libgcc gcc -L${CMAKE_CURRENT_SOURCE_DIR}/../blobs/lib/${CONFIG_SOC_SERIES} + -T${CMAKE_CURRENT_SOURCE_DIR}/../../components/esp_rom/${CONFIG_SOC_SERIES}/ld/${CONFIG_SOC_SERIES}.rom.coexist.ld -T${CMAKE_CURRENT_SOURCE_DIR}/../../components/esp_rom/${CONFIG_SOC_SERIES}/ld/${CONFIG_SOC_SERIES}.rom.pp.ld -T${CMAKE_CURRENT_SOURCE_DIR}/../../components/esp_rom/${CONFIG_SOC_SERIES}/ld/${CONFIG_SOC_SERIES}.rom.phy.ld -T${CMAKE_CURRENT_SOURCE_DIR}/../../components/esp_rom/${CONFIG_SOC_SERIES}/ld/${CONFIG_SOC_SERIES}.rom.net80211.ld diff --git a/zephyr/esp32s3/CMakeLists.txt b/zephyr/esp32s3/CMakeLists.txt index bd43dc07b2..c7e0d360e6 100644 --- a/zephyr/esp32s3/CMakeLists.txt +++ b/zephyr/esp32s3/CMakeLists.txt @@ -424,6 +424,11 @@ if(CONFIG_SOC_SERIES_ESP32S3) ../port/phy/phy_stubs.c ) + zephyr_link_libraries( + gcc + -T${CMAKE_CURRENT_SOURCE_DIR}/../../components/esp_rom/${CONFIG_SOC_SERIES}/ld/${CONFIG_SOC_SERIES}.rom.bt_funcs.ld + ) + zephyr_link_libraries_ifndef( CONFIG_BUILD_ONLY_NO_BLOBS ## ble diff --git a/zephyr/esp32s3/src/bt/esp_bt_adapter.c b/zephyr/esp32s3/src/bt/esp_bt_adapter.c index 7e966933a8..4608de99b8 100644 --- a/zephyr/esp32s3/src/bt/esp_bt_adapter.c +++ b/zephyr/esp32s3/src/bt/esp_bt_adapter.c @@ -229,10 +229,9 @@ extern bool API_vhci_host_check_send_available(void); extern void API_vhci_host_send_packet(uint8_t *data, uint16_t len); extern int API_vhci_host_register_callback(const esp_vhci_host_callback_t *callback); /* TX power */ -extern int ble_txpwr_set(int power_type, int power_level); -extern int ble_txpwr_get(int power_type); +extern int ble_txpwr_set(int power_type, uint16_t handle, int power_level); +extern int ble_txpwr_get(int power_type, uint16_t handle); -extern uint16_t l2c_ble_link_get_tx_buf_num(void); extern void coex_pti_v2(void); extern bool btdm_deep_sleep_mem_init(void); @@ -465,7 +464,7 @@ static int interrupt_alloc_wrapper(int cpu_id, int source, intr_handler_t handle } static int interrupt_free_wrapper(void *handle) -{ +{ return esp_intr_free((struct intr_handle_data_t *)handle); } @@ -821,10 +820,6 @@ static void btdm_sleep_enter_phase2_wrapper(void) } else { assert(0); } - - if (s_lp_stat.pm_lock_released == 0) { - s_lp_stat.pm_lock_released = 1; - } } } @@ -875,13 +870,6 @@ static void IRAM_ATTR btdm_slp_tmr_callback(void *arg) { } -static void btdm_funcs_table_ready_wrapper(void) -{ -#if BT_BLE_CCA_MODE == 2 - btdm_cca_feature_enable(); -#endif -} - static bool async_wakeup_request(int event) { if (s_lp_cntl.enable == 0) { @@ -899,6 +887,15 @@ static bool async_wakeup_request(int event) semphr_take_wrapper(s_wakeup_req_sem, OSI_FUNCS_TIME_BLOCKING); } break; + case BTDM_ASYNC_WAKEUP_REQ_COEX: + if (!btdm_power_state_active()) { + do_wakeup_request = true; + btdm_wakeup_request(); + if (s_lp_cntl.wakeup_timer_required && s_lp_stat.wakeup_timer_started) { + esp_timer_stop(s_btdm_slp_tmr); + s_lp_stat.wakeup_timer_started = 0; + } + } default: break; } @@ -918,6 +915,9 @@ static void async_wakeup_request_end(int event) case BTDM_ASYNC_WAKEUP_SRC_DISA: allow_to_sleep = true; break; + case BTDM_ASYNC_WAKEUP_REQ_COEX: + allow_to_sleep = false; + break; default: allow_to_sleep = true; break; @@ -953,15 +953,26 @@ static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status) #endif } -static uint32_t coex_schm_interval_get_wrapper(void) +static void btdm_funcs_table_ready_wrapper(void) { -#if CONFIG_SW_COEXIST_ENABLE - return coex_schm_interval_get(); -#else - return 0; +#if BT_BLE_CCA_MODE == 2 + btdm_cca_feature_enable(); +#endif +#if BLE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED + btdm_aa_check_enhance_enable(); #endif } +bool bt_async_wakeup_request(void) +{ + return async_wakeup_request(BTDM_ASYNC_WAKEUP_SRC_VHCI); +} + +void bt_wakeup_request_end(void) +{ + async_wakeup_request_end(BTDM_ASYNC_WAKEUP_SRC_VHCI); +} + static bool coex_bt_wakeup_request(void) { return async_wakeup_request(BTDM_ASYNC_WAKEUP_REQ_COEX); @@ -1039,79 +1050,11 @@ static void IRAM_ATTR btdm_mac_bb_power_up_cb(void) } #endif -esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) +// init low-power control resources +static esp_err_t btdm_low_power_mode_init(esp_bt_controller_config_t *cfg) { - esp_err_t err = ESP_FAIL; - - if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) { - return ESP_ERR_INVALID_STATE; - } - - if (cfg == NULL) { - return ESP_ERR_INVALID_ARG; - } - - if (cfg->controller_task_prio != CONFIG_ESP32_BT_CONTROLLER_TASK_PRIO - || cfg->controller_task_stack_size < CONFIG_ESP32_BT_CONTROLLER_STACK_SIZE) { - LOG_ERR("Invalid controller task prioriy or stack size"); - return ESP_ERR_INVALID_ARG; - } - - if (cfg->bluetooth_mode != ESP_BT_MODE_BLE) { - LOG_ERR("%s controller only support BLE only mode", __func__); - return ESP_ERR_NOT_SUPPORTED; - } - - if (cfg->bluetooth_mode & ESP_BT_MODE_BLE) { - if ((cfg->ble_max_act <= 0) || (cfg->ble_max_act > BT_CTRL_BLE_MAX_ACT_LIMIT)) { - LOG_ERR("Invalid value of ble_max_act"); - return ESP_ERR_INVALID_ARG; - } - } - - if (cfg->sleep_mode == ESP_BT_SLEEP_MODE_1) { - if (cfg->sleep_clock == ESP_BT_SLEEP_CLOCK_NONE) { - LOG_ERR("SLEEP_MODE_1 enabled but sleep clock not configured"); - return ESP_ERR_INVALID_ARG; - } - } - - // overwrite some parameters - cfg->magic = ESP_BT_CTRL_CONFIG_MAGIC_VAL; - -#if CONFIG_MAC_BB_PD - esp_mac_bb_pd_mem_init(); -#endif - esp_phy_modem_init(); - esp_bt_power_domain_on(); - - btdm_controller_mem_init(); - -#if CONFIG_MAC_BB_PD - if (esp_register_mac_bb_pd_callback(btdm_mac_bb_power_down_cb) != 0) { - err = ESP_ERR_INVALID_ARG; - goto error; - } - - if (esp_register_mac_bb_pu_callback(btdm_mac_bb_power_up_cb) != 0) { - err = ESP_ERR_INVALID_ARG; - goto error; - } -#endif + esp_err_t err = ESP_OK; - osi_funcs_p = (struct osi_funcs_t *)malloc_internal_wrapper(sizeof(struct osi_funcs_t)); - if (osi_funcs_p == NULL) { - return ESP_ERR_NO_MEM; - } - - memcpy(osi_funcs_p, &osi_funcs_ro, sizeof(struct osi_funcs_t)); - if (btdm_osi_funcs_register(osi_funcs_p) != 0) { - return ESP_ERR_INVALID_ARG; - } - - LOG_INF("BT controller compile version [%s]", btdm_controller_get_compile_version()); - - // init low-power control resources do { // set default values for global states or resources s_lp_stat.val = 0; @@ -1122,13 +1065,14 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) // configure and initialize resources s_lp_cntl.enable = (cfg->sleep_mode == ESP_BT_SLEEP_MODE_1) ? 1 : 0; + s_lp_cntl.lpclk_sel = (cfg->sleep_mode == ESP_BT_SLEEP_MODE_1) ? cfg->sleep_clock : ESP_BT_SLEEP_CLOCK_MAIN_XTAL; s_lp_cntl.no_light_sleep = 0; if (s_lp_cntl.enable) { -#if (CONFIG_MAC_BB_PD) +#if CONFIG_MAC_BB_PD if (!btdm_deep_sleep_mem_init()) { err = ESP_ERR_NO_MEM; - goto error; + break; } s_lp_cntl.mac_bb_pd = 1; #endif @@ -1136,69 +1080,65 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) s_wakeup_req_sem = semphr_create_wrapper(1, 0); if (s_wakeup_req_sem == NULL) { err = ESP_ERR_NO_MEM; - goto error; + break; } btdm_vnd_offload_task_register(BTDM_VND_OL_SIG_WAKEUP_TMR, btdm_sleep_exit_phase0); - } - if (s_lp_cntl.wakeup_timer_required) { - esp_timer_create_args_t create_args = { - .callback = btdm_slp_tmr_callback, - .arg = NULL, - .name = "btSlp", - }; - if ((err = esp_timer_create(&create_args, &s_btdm_slp_tmr)) != ESP_OK) { - goto error; + if (s_lp_cntl.wakeup_timer_required) { + esp_timer_create_args_t create_args = { + .callback = btdm_slp_tmr_callback, + .arg = NULL, + .name = "btSlp", + }; + if ((err = esp_timer_create(&create_args, &s_btdm_slp_tmr)) != ESP_OK) { + break; + } } - } - // set default bluetooth sleep clock cycle and its fractional bits - btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT; - btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac); + // set default bluetooth sleep clock cycle and its fractional bits + btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT; + btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac); - // set default bluetooth sleep clock source - s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value -#if CONFIG_BT_CTRL_LPCLK_SEL_EXT_32K_XTAL - // check whether or not EXT_CRYS is working - if (rtc_clk_slow_freq_get() == SOC_RTC_SLOW_CLK_SRC_XTAL32K) { - s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL32K; // External 32 kHz XTAL - } else { - LOG_WRN("32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock\n" - "light sleep mode will not be able to apply when bluetooth is enabled"); + if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_EXT_32K_XTAL) { // External 32 kHz XTAL + // check whether or not EXT_CRYS is working + if (rtc_clk_slow_src_get() != SOC_RTC_SLOW_CLK_SRC_XTAL32K) { + LOG_WRN("32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock"); + s_lp_cntl.lpclk_sel = ESP_BT_SLEEP_CLOCK_MAIN_XTAL; #if !CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP - s_lp_cntl.no_light_sleep = 1; + s_lp_cntl.no_light_sleep = 1; #endif - } -#elif (CONFIG_BT_CTRL_LPCLK_SEL_MAIN_XTAL) - LOG_WRN("Bluetooth will use main XTAL as Bluetooth sleep clock."); + } + } else if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_RTC_SLOW) { // Internal 136kHz RC oscillator + if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_RC_SLOW) { + LOG_WRN("Internal 136kHz RC oscillator. The accuracy of this clock is a lot larger than 500ppm which is " + "required in Bluetooth communication, so don't select this option in scenarios such as BLE connection state."); + } else { + LOG_WRN("Internal 136kHz RC oscillator not detected."); + assert(0); + } + } else if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_MAIN_XTAL) { + LOG_INF("Bluetooth will use main XTAL as Bluetooth sleep clock."); #if !CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP - s_lp_cntl.no_light_sleep = 1; + s_lp_cntl.no_light_sleep = 1; #endif -#elif (CONFIG_BT_CTRL_LPCLK_SEL_RTC_SLOW) - // check whether or not EXT_CRYS is working - if (rtc_clk_slow_freq_get() == SOC_RTC_SLOW_CLK_SRC_RC_SLOW) { - s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_RTC_SLOW; // Internal 150 kHz RC oscillator - LOG_WRN("Internal 150kHz RC osciallator. The accuracy of this clock is a lot larger than 500ppm which is " - "required in Bluetooth communication, so don't select this option in scenarios such as BLE connection state."); + } } else { - LOG_WRN("Internal 150kHz RC oscillator not detected."); - assert(0); + s_lp_cntl.no_light_sleep = 1; } -#endif bool select_src_ret __attribute__((unused)); bool set_div_ret __attribute__((unused)); - if (s_lp_cntl.lpclk_sel == BTDM_LPCLK_SEL_XTAL) { + if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_MAIN_XTAL) { #ifdef CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP - esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_ON)); + esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_ON); s_lp_cntl.main_xtal_pu = 1; #endif select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL); - set_div_ret = btdm_lpclk_set_div(rtc_clk_xtal_freq_get() / MHZ(1)); + set_div_ret = btdm_lpclk_set_div(esp_clk_xtal_freq() / MHZ(1)); assert(select_src_ret && set_div_ret); btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT; btdm_lpcycle_us = 1 << (btdm_lpcycle_us_frac); - } else if (s_lp_cntl.lpclk_sel == BTDM_LPCLK_SEL_XTAL32K) { + } else if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_EXT_32K_XTAL) { select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL32K); set_div_ret = btdm_lpclk_set_div(0); assert(select_src_ret && set_div_ret); @@ -1206,7 +1146,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) btdm_lpcycle_us = (RTC_CLK_CAL_FRACT > 15) ? (1000000 << (RTC_CLK_CAL_FRACT - 15)) : (1000000 >> (15 - RTC_CLK_CAL_FRACT)); assert(btdm_lpcycle_us != 0); - } else if (s_lp_cntl.lpclk_sel == BTDM_LPCLK_SEL_RTC_SLOW) { + } else if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_RTC_SLOW) { select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_RTC_SLOW); set_div_ret = btdm_lpclk_set_div(0); assert(select_src_ret && set_div_ret); @@ -1214,13 +1154,96 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) btdm_lpcycle_us = esp_clk_slowclk_cal_get(); } else { err = ESP_ERR_INVALID_ARG; - goto error; + break; } #if CONFIG_SW_COEXIST_ENABLE coex_update_lpclk_interval(); #endif + } while (0); + return err; +} + +esp_bt_sleep_clock_t esp_bt_get_lpclk_src(void) +{ + if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_INITED && + btdm_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED) { + return ESP_BT_SLEEP_CLOCK_NONE; + } + + return s_lp_cntl.lpclk_sel; +} + +esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) +{ + esp_err_t err = ESP_FAIL; + + if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) { + return ESP_ERR_INVALID_STATE; + } + + if (cfg == NULL) { + return ESP_ERR_INVALID_ARG; + } + + if (cfg->controller_task_prio != CONFIG_ESP32_BT_CONTROLLER_TASK_PRIO + || cfg->controller_task_stack_size < CONFIG_ESP32_BT_CONTROLLER_STACK_SIZE) { + LOG_ERR("Invalid controller task prioriy or stack size"); + return ESP_ERR_INVALID_ARG; + } + + if (cfg->bluetooth_mode != ESP_BT_MODE_BLE) { + LOG_ERR("%s controller only support BLE only mode", __func__); + return ESP_ERR_NOT_SUPPORTED; + } + + if (cfg->bluetooth_mode & ESP_BT_MODE_BLE) { + if ((cfg->ble_max_act <= 0) || (cfg->ble_max_act > BT_CTRL_BLE_MAX_ACT_LIMIT)) { + LOG_ERR("Invalid value of ble_max_act"); + return ESP_ERR_INVALID_ARG; + } + } + + if (cfg->sleep_mode == ESP_BT_SLEEP_MODE_1) { + if (cfg->sleep_clock == ESP_BT_SLEEP_CLOCK_NONE) { + LOG_ERR("SLEEP_MODE_1 enabled but sleep clock not configured"); + return ESP_ERR_INVALID_ARG; + } + if (cfg->sleep_clock > ESP_BT_SLEEP_CLOCK_RTC_SLOW) { + LOG_ERR("SLEEP_MODE_1 is enabled but this sleep clock is not supported"); + return ESP_ERR_INVALID_ARG; + } + } + + // overwrite some parameters + cfg->magic = ESP_BT_CTRL_CONFIG_MAGIC_VAL; + +#if CONFIG_MAC_BB_PD + esp_mac_bb_pd_mem_init(); +#endif + esp_phy_modem_init(); + esp_bt_power_domain_on(); + + btdm_controller_mem_init(); + + osi_funcs_p = (struct osi_funcs_t *)malloc_internal_wrapper(sizeof(struct osi_funcs_t)); + if (osi_funcs_p == NULL) { + return ESP_ERR_NO_MEM; + } + + memcpy(osi_funcs_p, &osi_funcs_ro, sizeof(struct osi_funcs_t)); + if (btdm_osi_funcs_register(osi_funcs_p) != 0) { + return ESP_ERR_INVALID_ARG; + } + + LOG_INF("BT controller compile version [%s]", btdm_controller_get_compile_version()); + + if ((err = btdm_low_power_mode_init(cfg)) != ESP_OK) { + LOG_ERR("Low power module initialization failed"); + goto error; + } + #if CONFIG_SW_COEXIST_ENABLE coex_init(); #endif @@ -1228,14 +1251,10 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) periph_module_enable(PERIPH_BT_MODULE); periph_module_reset(PERIPH_BT_MODULE); - esp_phy_enable(PHY_MODEM_BT); - s_lp_stat.phy_enabled = 1; - if (btdm_controller_init(cfg) != 0) { err = ESP_ERR_NO_MEM; goto error; } - coex_pti_v2(); btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED; @@ -1261,70 +1280,61 @@ esp_err_t esp_bt_controller_deinit(void) return ESP_OK; } -static void bt_controller_deinit_internal(void) +// deinit low power control resources +static void btdm_low_power_mode_deinit(void) { - periph_module_disable(PERIPH_BT_MODULE); - - if (s_lp_stat.phy_enabled) { - esp_phy_disable(PHY_MODEM_BT); - s_lp_stat.phy_enabled = 0; - } - - // deinit low power control resources - do { - #if CONFIG_MAC_BB_PD - if (s_lp_cntl.mac_bb_pd) { - btdm_deep_sleep_mem_deinit(); - s_lp_cntl.mac_bb_pd = 0; - } + if (s_lp_cntl.mac_bb_pd) { + btdm_deep_sleep_mem_deinit(); + s_lp_cntl.mac_bb_pd = 0; + } #endif - if (s_lp_cntl.wakeup_timer_required) { - if (s_lp_stat.wakeup_timer_started) { - esp_timer_stop(s_btdm_slp_tmr); - } - s_lp_stat.wakeup_timer_started = 0; - esp_timer_delete(s_btdm_slp_tmr); - s_btdm_slp_tmr = NULL; + if (s_lp_cntl.wakeup_timer_required && s_btdm_slp_tmr != NULL) { + if (s_lp_stat.wakeup_timer_started) { + esp_timer_stop(s_btdm_slp_tmr); } + s_lp_stat.wakeup_timer_started = 0; + esp_timer_delete(s_btdm_slp_tmr); + s_btdm_slp_tmr = NULL; + } - if (s_lp_cntl.enable) { - btdm_vnd_offload_task_deregister(BTDM_VND_OL_SIG_WAKEUP_TMR); - if (s_wakeup_req_sem != NULL) { - semphr_delete_wrapper(s_wakeup_req_sem); - s_wakeup_req_sem = NULL; - } + if (s_lp_cntl.enable) { + btdm_vnd_offload_task_deregister(BTDM_VND_OL_SIG_WAKEUP_TMR); + if (s_wakeup_req_sem != NULL) { + semphr_delete_wrapper(s_wakeup_req_sem); + s_wakeup_req_sem = NULL; } + } - if (s_lp_cntl.lpclk_sel == BTDM_LPCLK_SEL_XTAL) { + if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_MAIN_XTAL) { #ifdef CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP - if (s_lp_cntl.main_xtal_pu) { - esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_OFF); - s_lp_cntl.main_xtal_pu = 0; - } + if (s_lp_cntl.main_xtal_pu) { + esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_OFF); + s_lp_cntl.main_xtal_pu = 0; + } #endif - btdm_lpclk_select_src(BTDM_LPCLK_SEL_RTC_SLOW); - btdm_lpclk_set_div(0); + btdm_lpclk_select_src(BTDM_LPCLK_SEL_RTC_SLOW); + btdm_lpclk_set_div(0); #if CONFIG_SW_COEXIST_ENABLE - coex_update_lpclk_interval(); + coex_update_lpclk_interval(); #endif - } + } - btdm_lpcycle_us = 0; - } while (0); + btdm_lpcycle_us = 0; +} -#if CONFIG_MAC_BB_PD - esp_unregister_mac_bb_pd_callback(btdm_mac_bb_power_down_cb); - esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb); -#endif +static void bt_controller_deinit_internal(void) +{ + periph_module_disable(PERIPH_BT_MODULE); + + btdm_low_power_mode_deinit(); esp_bt_power_domain_off(); #if CONFIG_MAC_BB_PD esp_mac_bb_pd_mem_deinit(); #endif esp_phy_modem_deinit(); - if (osi_funcs_p != NULL) { esp_bt_free(osi_funcs_p); osi_funcs_p = NULL; @@ -1346,22 +1356,45 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode) return ESP_ERR_INVALID_ARG; } + /* Enable PHY when enabling controller to reduce power dissipation after controller init + * Notice the init order: esp_phy_enable() -> bt_bb_v2_init_cmplx() -> coex_pti_v2() + */ + esp_phy_enable(PHY_MODEM_BT); + s_lp_stat.phy_enabled = 1; + #if CONFIG_SW_COEXIST_ENABLE coex_enable(); #endif // enable low power mode do { +#if CONFIG_MAC_BB_PD + if (esp_register_mac_bb_pd_callback(btdm_mac_bb_power_down_cb) != 0) { + ret = ESP_ERR_INVALID_ARG; + goto error; + } + + if (esp_register_mac_bb_pu_callback(btdm_mac_bb_power_up_cb) != 0) { + ret = ESP_ERR_INVALID_ARG; + goto error; + } +#endif + if (s_lp_cntl.enable) { btdm_controller_enable_sleep(true); } } while (0); + // Disable pll track by default in BLE controller on ESP32-C3 and ESP32-S3 + sdk_config_extend_set_pll_track(false); + if (btdm_controller_enable(mode) != 0) { ret = ESP_ERR_INVALID_STATE; goto error; } + coex_pti_v2(); + btdm_controller_status = ESP_BT_CONTROLLER_STATUS_ENABLED; return ret; @@ -1369,13 +1402,20 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode) error: // disable low power mode do { +#if CONFIG_MAC_BB_PD + esp_unregister_mac_bb_pd_callback(btdm_mac_bb_power_down_cb); + esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb); +#endif btdm_controller_enable_sleep(false); } while (0); #if CONFIG_SW_COEXIST_ENABLE coex_disable(); #endif - + if (s_lp_stat.phy_enabled) { + esp_phy_disable(PHY_MODEM_BT); + s_lp_stat.phy_enabled = 0; + } return ret; } @@ -1394,9 +1434,21 @@ esp_err_t esp_bt_controller_disable(void) #if CONFIG_SW_COEXIST_ENABLE coex_disable(); #endif + if (s_lp_stat.phy_enabled) { + esp_phy_disable(PHY_MODEM_BT); + s_lp_stat.phy_enabled = 0; + } btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED; + // disable low power mode + do { +#if CONFIG_MAC_BB_PD + esp_unregister_mac_bb_pd_callback(btdm_mac_bb_power_down_cb); + esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb); +#endif + } while (0); + return ESP_OK; } @@ -1405,16 +1457,89 @@ esp_bt_controller_status_t esp_bt_controller_get_status(void) return btdm_controller_status; } +static int enh_power_type_get(esp_ble_power_type_t power_type) +{ + switch (power_type) { + case ESP_BLE_PWR_TYPE_ADV: + return ESP_BLE_ENHANCED_PWR_TYPE_ADV; + case ESP_BLE_PWR_TYPE_SCAN: + return ESP_BLE_ENHANCED_PWR_TYPE_SCAN; + case ESP_BLE_PWR_TYPE_CONN_HDL0: + case ESP_BLE_PWR_TYPE_CONN_HDL1: + case ESP_BLE_PWR_TYPE_CONN_HDL2: + case ESP_BLE_PWR_TYPE_CONN_HDL3: + case ESP_BLE_PWR_TYPE_CONN_HDL4: + case ESP_BLE_PWR_TYPE_CONN_HDL5: + case ESP_BLE_PWR_TYPE_CONN_HDL6: + case ESP_BLE_PWR_TYPE_CONN_HDL7: + case ESP_BLE_PWR_TYPE_CONN_HDL8: + return ESP_BLE_ENHANCED_PWR_TYPE_CONN; + case ESP_BLE_PWR_TYPE_DEFAULT: + return ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT; + default: + break; + } + + return power_type; +} + /* extra functions */ esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level) +{ + esp_err_t stat = ESP_FAIL; + uint16_t handle = BLE_PWR_HDL_INVL; + int enh_pwr_type = enh_power_type_get(power_type); + + if (power_type > ESP_BLE_PWR_TYPE_DEFAULT) { + return ESP_ERR_NOT_SUPPORTED; + } + + if (enh_pwr_type == ESP_BLE_ENHANCED_PWR_TYPE_CONN) { + handle = power_type; + } + + if (ble_txpwr_set(enh_pwr_type, handle, power_level) == 0) { + stat = ESP_OK; + } + + return stat; +} + +esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type) +{ + esp_power_level_t lvl; + uint16_t handle = BLE_PWR_HDL_INVL; + int enh_pwr_type = enh_power_type_get(power_type); + + if (power_type > ESP_BLE_PWR_TYPE_DEFAULT) { + return ESP_PWR_LVL_INVALID; + } + + if (enh_pwr_type == ESP_BLE_ENHANCED_PWR_TYPE_CONN) { + handle = power_type; + } + + lvl = (esp_power_level_t)ble_txpwr_get(enh_pwr_type, handle); + + return lvl; +} + +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) { esp_err_t stat = ESP_FAIL; switch (power_type) { - case ESP_BLE_PWR_TYPE_ADV: - case ESP_BLE_PWR_TYPE_SCAN: - case ESP_BLE_PWR_TYPE_DEFAULT: - if (ble_txpwr_set(power_type, power_level) == 0) { + case ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT: + case ESP_BLE_ENHANCED_PWR_TYPE_SCAN: + case ESP_BLE_ENHANCED_PWR_TYPE_INIT: + if (ble_txpwr_set(power_type, BLE_PWR_HDL_INVL, power_level) == 0) { + stat = ESP_OK; + } + break; + case ESP_BLE_ENHANCED_PWR_TYPE_ADV: + case ESP_BLE_ENHANCED_PWR_TYPE_CONN: + if (ble_txpwr_set(power_type, handle, power_level) == 0) { stat = ESP_OK; } break; @@ -1426,33 +1551,26 @@ esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_ return stat; } -esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type) +esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t power_type, + uint16_t handle) { - esp_power_level_t lvl; + int tx_level = 0; switch (power_type) { - case ESP_BLE_PWR_TYPE_ADV: - case ESP_BLE_PWR_TYPE_SCAN: - lvl = (esp_power_level_t)ble_txpwr_get(power_type); + case ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT: + case ESP_BLE_ENHANCED_PWR_TYPE_SCAN: + case ESP_BLE_ENHANCED_PWR_TYPE_INIT: + tx_level = ble_txpwr_get(power_type, BLE_PWR_HDL_INVL); break; - case ESP_BLE_PWR_TYPE_CONN_HDL0: - case ESP_BLE_PWR_TYPE_CONN_HDL1: - case ESP_BLE_PWR_TYPE_CONN_HDL2: - case ESP_BLE_PWR_TYPE_CONN_HDL3: - case ESP_BLE_PWR_TYPE_CONN_HDL4: - case ESP_BLE_PWR_TYPE_CONN_HDL5: - case ESP_BLE_PWR_TYPE_CONN_HDL6: - case ESP_BLE_PWR_TYPE_CONN_HDL7: - case ESP_BLE_PWR_TYPE_CONN_HDL8: - case ESP_BLE_PWR_TYPE_DEFAULT: - lvl = (esp_power_level_t)ble_txpwr_get(ESP_BLE_PWR_TYPE_DEFAULT); + case ESP_BLE_ENHANCED_PWR_TYPE_ADV: + case ESP_BLE_ENHANCED_PWR_TYPE_CONN: + tx_level = ble_txpwr_get(power_type, handle); break; default: - lvl = ESP_PWR_LVL_INVALID; - break; + return ESP_PWR_LVL_INVALID; } - return lvl; + return (esp_power_level_t)tx_level; } esp_err_t esp_bt_sleep_enable (void) @@ -1512,14 +1630,23 @@ int IRAM_ATTR esp_bt_h4tl_eif_io_event_notify(int event) return btdm_hci_tl_io_event_post(event); } -uint16_t esp_bt_get_tx_buf_num(void) +static void coex_wifi_sleep_set_hook(bool sleep) { - return l2c_ble_link_get_tx_buf_num(); + } -static void coex_wifi_sleep_set_hook(bool sleep) +static void esp_bt_free(void *mem) { + esp_bt_free_func(mem); +} +static uint32_t coex_schm_interval_get_wrapper(void) +{ +#if CONFIG_SW_COEXIST_ENABLE + return coex_schm_interval_get(); +#else + return 0; +#endif } static uint8_t coex_schm_curr_period_get_wrapper(void) @@ -1539,8 +1666,3 @@ static void * coex_schm_curr_phase_get_wrapper(void) return NULL; #endif } - -static void esp_bt_free(void *mem) -{ - esp_bt_free_func(mem); -} diff --git a/zephyr/module.yml b/zephyr/module.yml index 2f6f945a72..d05db8e747 100644 --- a/zephyr/module.yml +++ b/zephyr/module.yml @@ -29,12 +29,20 @@ blobs: url: https://github.com/espressif/esp32-bt-lib/raw/f21a9ef6a4af418621fab356755151d309aae568/esp32/libbtdm_app.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-bt-lib - - path: lib/esp32/libespnow.a - sha256: c2a06be04ba3661e75a6586f503a4e90c359143fca483a0b21e06398955a7ffa + - path: lib/esp32/libnet80211.a + sha256: 9fc7594af18103569deabb6f9c27b0a4cee4b18a444c7c5951d0c7ffb478bbdd type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32/libespnow.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32/libnet80211.a + description: "Binary libraries supporting the ESP32 series RF subsystems" + doc-url: https://github.com/espressif/esp32-wifi-lib + - path: lib/esp32/libpp.a + sha256: 6c7a49fbe7a3c17d4b3701d25d267b4be2ddff7560943a1a268e3a77fb939edc + type: lib + version: '1.0' + license-path: zephyr/blobs/license.txt + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32/libpp.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - path: lib/esp32/libsmartconfig.a @@ -45,12 +53,12 @@ blobs: url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32/libsmartconfig.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32/libmesh.a - sha256: 8afd09f6bad9b5ea08a0c24c2074d2acd161e87f10eb1646e7d92f1ec8a70a53 + - path: lib/esp32/libwapi.a + sha256: 43f6974ef4d159650f6683699926c9bb987c41ceaf9ade297901e2dbf34d6648 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32/libmesh.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32/libwapi.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - path: lib/esp32/libcore.a @@ -61,36 +69,36 @@ blobs: url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32/libcore.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32/libnet80211.a - sha256: 9fc7594af18103569deabb6f9c27b0a4cee4b18a444c7c5951d0c7ffb478bbdd + - path: lib/esp32/libespnow.a + sha256: c2a06be04ba3661e75a6586f503a4e90c359143fca483a0b21e06398955a7ffa type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32/libnet80211.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32/libespnow.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32/libwapi.a - sha256: 43f6974ef4d159650f6683699926c9bb987c41ceaf9ade297901e2dbf34d6648 + - path: lib/esp32/libmesh.a + sha256: 8afd09f6bad9b5ea08a0c24c2074d2acd161e87f10eb1646e7d92f1ec8a70a53 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32/libwapi.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32/libmesh.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32/libpp.a - sha256: 6c7a49fbe7a3c17d4b3701d25d267b4be2ddff7560943a1a268e3a77fb939edc + - path: lib/esp32s2/libnet80211.a + sha256: 78baf55e8d579bafdfb94ec1bf30ef9c4ac363704db809b35ce305e38bd18c4d type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32/libpp.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s2/libnet80211.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32s2/libespnow.a - sha256: d7244a63df57d066a9617c708126dd1cbe8eb9571852dce21b7eaa951b41b099 + - path: lib/esp32s2/libpp.a + sha256: 18eec6b9068c7f5c303fb2dcad3471f53aa7a08e0d61732bb91f5ef168557d85 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s2/libespnow.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s2/libpp.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - path: lib/esp32s2/libsmartconfig.a @@ -101,12 +109,12 @@ blobs: url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s2/libsmartconfig.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32s2/libmesh.a - sha256: 5d24b1a1263a168a66f1649c7ba2eb157632709ac0982532d01d10f99fbf9109 + - path: lib/esp32s2/libwapi.a + sha256: 2119b7883ccb7cb4c95958edecc3c4a1a6c113a1a7e0ddea1f1d6d971755a85a type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s2/libmesh.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s2/libwapi.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - path: lib/esp32s2/libcore.a @@ -117,36 +125,36 @@ blobs: url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s2/libcore.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32s2/libnet80211.a - sha256: 78baf55e8d579bafdfb94ec1bf30ef9c4ac363704db809b35ce305e38bd18c4d + - path: lib/esp32s2/libespnow.a + sha256: d7244a63df57d066a9617c708126dd1cbe8eb9571852dce21b7eaa951b41b099 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s2/libnet80211.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s2/libespnow.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32s2/libwapi.a - sha256: 2119b7883ccb7cb4c95958edecc3c4a1a6c113a1a7e0ddea1f1d6d971755a85a + - path: lib/esp32s2/libmesh.a + sha256: 5d24b1a1263a168a66f1649c7ba2eb157632709ac0982532d01d10f99fbf9109 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s2/libwapi.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s2/libmesh.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32s2/libpp.a - sha256: 18eec6b9068c7f5c303fb2dcad3471f53aa7a08e0d61732bb91f5ef168557d85 + - path: lib/esp32c2/libnet80211.a + sha256: 2a4b12be6582562676379fd396626755518e490bb65470a17e67142a699b64f6 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s2/libpp.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c2/libnet80211.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32c2/libespnow.a - sha256: 2f879870d98f9e1f6c0a77ae35a64c5d573a8c31342c1a6aa94f2204b91a1f91 + - path: lib/esp32c2/libpp.a + sha256: 8dd51ae7434ca270706fc2dfaff1249f56949aa6a7c83422ddedd405d09181a4 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c2/libespnow.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c2/libpp.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - path: lib/esp32c2/libsmartconfig.a @@ -165,28 +173,28 @@ blobs: url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c2/libcore.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32c2/libnet80211.a - sha256: 2a4b12be6582562676379fd396626755518e490bb65470a17e67142a699b64f6 + - path: lib/esp32c2/libespnow.a + sha256: 2f879870d98f9e1f6c0a77ae35a64c5d573a8c31342c1a6aa94f2204b91a1f91 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c2/libnet80211.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c2/libespnow.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32c2/libpp.a - sha256: 8dd51ae7434ca270706fc2dfaff1249f56949aa6a7c83422ddedd405d09181a4 + - path: lib/esp32c3/libnet80211.a + sha256: 1eca83486e151440f235ab2939585407ca495cd2f85e92d3e1c1b9782278ffe6 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c2/libpp.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c3/libnet80211.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32c3/libespnow.a - sha256: 8af0c4683dce803135e3f0b7ec5ae788211dff03c7da72d34afe06c60136f38e + - path: lib/esp32c3/libpp.a + sha256: 40c3da79e1b67239c3ddfe64a1fcf64067bc5aac0a2ba6e92252d0da3a5b7ef1 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c3/libespnow.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c3/libpp.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - path: lib/esp32c3/libsmartconfig.a @@ -197,12 +205,12 @@ blobs: url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c3/libsmartconfig.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32c3/libmesh.a - sha256: b275bd101d069bf2da8f9050bac35f3c5d57d0a16482f9affa44694c5163e4dd + - path: lib/esp32c3/libwapi.a + sha256: d1b3b28ad16e2f2bdb9243e2c8015b68d92c79aec3a143f6c71bcb17f7b19c2e type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c3/libmesh.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c3/libwapi.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - path: lib/esp32c3/libcore.a @@ -213,36 +221,36 @@ blobs: url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c3/libcore.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32c3/libnet80211.a - sha256: 1eca83486e151440f235ab2939585407ca495cd2f85e92d3e1c1b9782278ffe6 + - path: lib/esp32c3/libespnow.a + sha256: 8af0c4683dce803135e3f0b7ec5ae788211dff03c7da72d34afe06c60136f38e type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c3/libnet80211.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c3/libespnow.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32c3/libwapi.a - sha256: d1b3b28ad16e2f2bdb9243e2c8015b68d92c79aec3a143f6c71bcb17f7b19c2e + - path: lib/esp32c3/libmesh.a + sha256: b275bd101d069bf2da8f9050bac35f3c5d57d0a16482f9affa44694c5163e4dd type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c3/libwapi.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c3/libmesh.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32c3/libpp.a - sha256: 40c3da79e1b67239c3ddfe64a1fcf64067bc5aac0a2ba6e92252d0da3a5b7ef1 + - path: lib/esp32s3/libnet80211.a + sha256: 4e7cb09868c64558955f0ffbf06da393105c3fb7c011ad423e75d7907cd6fa25 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c3/libpp.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s3/libnet80211.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32s3/libespnow.a - sha256: 4b3f90973fcd4cf982eaa2ac6b28f1fbdad90c136338d3aca322bbbffa1c59a7 + - path: lib/esp32s3/libpp.a + sha256: 127425fdcc245c9d85a4f3881a72a555bb9c7beb908952f963a11b1490bcc5ea type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s3/libespnow.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s3/libpp.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - path: lib/esp32s3/libsmartconfig.a @@ -253,12 +261,12 @@ blobs: url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s3/libsmartconfig.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32s3/libmesh.a - sha256: e3908898be037988c3d0c7e9f5a81052b582789af164caadb405e038ae1a5e08 + - path: lib/esp32s3/libwapi.a + sha256: 0505024add80c843919f48ddc609e7a34b989db238cede3759d4ab81f411d55e type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s3/libmesh.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s3/libwapi.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - path: lib/esp32s3/libcore.a @@ -269,36 +277,36 @@ blobs: url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s3/libcore.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32s3/libnet80211.a - sha256: 4e7cb09868c64558955f0ffbf06da393105c3fb7c011ad423e75d7907cd6fa25 + - path: lib/esp32s3/libespnow.a + sha256: 4b3f90973fcd4cf982eaa2ac6b28f1fbdad90c136338d3aca322bbbffa1c59a7 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s3/libnet80211.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s3/libespnow.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32s3/libwapi.a - sha256: 0505024add80c843919f48ddc609e7a34b989db238cede3759d4ab81f411d55e + - path: lib/esp32s3/libmesh.a + sha256: e3908898be037988c3d0c7e9f5a81052b582789af164caadb405e038ae1a5e08 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s3/libwapi.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s3/libmesh.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32s3/libpp.a - sha256: 127425fdcc245c9d85a4f3881a72a555bb9c7beb908952f963a11b1490bcc5ea + - path: lib/esp32c6/libnet80211.a + sha256: b06054e8510e16b2a86cb96ba385bab681e1dc8c8873d71c2f3828e012118d2a type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32s3/libpp.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c6/libnet80211.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32c6/libespnow.a - sha256: 700a2f8b159904e930a01c6a54e6e99bf40a6a9f0ac710920b78344308fa7f44 + - path: lib/esp32c6/libpp.a + sha256: 31cc31102a30672ad9b0fdbed4d7723856b176d43c14916e638f96de1aafe6f2 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c6/libespnow.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c6/libpp.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - path: lib/esp32c6/libsmartconfig.a @@ -309,12 +317,12 @@ blobs: url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c6/libsmartconfig.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32c6/libmesh.a - sha256: e488468a05483441a26240f524b1a0d7050517543f4d75bc3e084e3853fb58ff + - path: lib/esp32c6/libwapi.a + sha256: 5dabf2a75de4c48bf034d7c638006dd9cd20b029e1842a391af8e07731524252 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c6/libmesh.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c6/libwapi.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - path: lib/esp32c6/libcore.a @@ -325,30 +333,30 @@ blobs: url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c6/libcore.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32c6/libnet80211.a - sha256: b06054e8510e16b2a86cb96ba385bab681e1dc8c8873d71c2f3828e012118d2a + - path: lib/esp32c6/libespnow.a + sha256: 700a2f8b159904e930a01c6a54e6e99bf40a6a9f0ac710920b78344308fa7f44 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c6/libnet80211.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c6/libespnow.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32c6/libwapi.a - sha256: 5dabf2a75de4c48bf034d7c638006dd9cd20b029e1842a391af8e07731524252 + - path: lib/esp32c6/libmesh.a + sha256: e488468a05483441a26240f524b1a0d7050517543f4d75bc3e084e3853fb58ff type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c6/libwapi.a + url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c6/libmesh.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp32-wifi-lib - - path: lib/esp32c6/libpp.a - sha256: 31cc31102a30672ad9b0fdbed4d7723856b176d43c14916e638f96de1aafe6f2 + - path: lib/esp32/libbttestmode.a + sha256: fd512e3155947f8b95ac8500556fda9d349011e37d0039b22a6ccce68d014dc8 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp32-wifi-lib/raw/6020d3b9b22eeb4fa94a95a15555d0da699fbdf3/esp32c6/libpp.a + url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32/libbttestmode.a description: "Binary libraries supporting the ESP32 series RF subsystems" - doc-url: https://github.com/espressif/esp32-wifi-lib + doc-url: https://github.com/espressif/esp-phy-lib - path: lib/esp32/librftest.a sha256: 7e55e69f139f692687191f5c20bdbf08bf675851ae27e6baf95ea68bfc04bc20 type: lib @@ -357,28 +365,28 @@ blobs: url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32/librftest.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - - path: lib/esp32/libphy.a - sha256: cc9a7460d24dbaeafba1a984767b09299ce1177e694cb642e3277a7fedb6236d + - path: lib/esp32/librtc.a + sha256: 544b27be485381ededfbd689f783e4fa591d185c7d5d5435dc9abee1ecd6a79a type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32/libphy.a + url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32/librtc.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - - path: lib/esp32/librtc.a - sha256: 544b27be485381ededfbd689f783e4fa591d185c7d5d5435dc9abee1ecd6a79a + - path: lib/esp32/libphy.a + sha256: cc9a7460d24dbaeafba1a984767b09299ce1177e694cb642e3277a7fedb6236d type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32/librtc.a + url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32/libphy.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - - path: lib/esp32/libbttestmode.a - sha256: fd512e3155947f8b95ac8500556fda9d349011e37d0039b22a6ccce68d014dc8 + - path: lib/esp32s2/librftest.a + sha256: c10b9731d942b1f4975d80e7ded102bd5fbab7d67479789bdc21ec0d968a9ea2 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32/libbttestmode.a + url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32s2/librftest.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - path: lib/esp32s2/librfate.a @@ -389,28 +397,28 @@ blobs: url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32s2/librfate.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - - path: lib/esp32s2/librftest.a - sha256: c10b9731d942b1f4975d80e7ded102bd5fbab7d67479789bdc21ec0d968a9ea2 + - path: lib/esp32s2/libphy.a + sha256: 17d2af4c10de68d47080d23d9aa7441fc13a7c7c46167ddfaa09e04d98216def type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32s2/librftest.a + url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32s2/libphy.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - - path: lib/esp32s2/libphy.a - sha256: 17d2af4c10de68d47080d23d9aa7441fc13a7c7c46167ddfaa09e04d98216def + - path: lib/esp32c2/libbttestmode.a + sha256: d217aed665e98680dd69f223afad6ac7677b552448c78a180dfdf01dbab266e3 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32s2/libphy.a + url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c2/libbttestmode.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - - path: lib/esp32c2/librfate.a - sha256: 054123ea022429e79f75562ef1dfe6dd21a4868ed427aa01cdb7de846a995fe1 + - path: lib/esp32c2/libbtbb.a + sha256: 2927f2453abb49b08b4156651c42806e37a02c6f18b1b6de460da77ed16082b5 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c2/librfate.a + url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c2/libbtbb.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - path: lib/esp32c2/librftest.a @@ -421,36 +429,36 @@ blobs: url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c2/librftest.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - - path: lib/esp32c2/libphy.a - sha256: e3438a148025c452b9d694533a45bdeb99ac8d8d7563964089d70a8c44e6c007 + - path: lib/esp32c2/librfate.a + sha256: 054123ea022429e79f75562ef1dfe6dd21a4868ed427aa01cdb7de846a995fe1 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c2/libphy.a + url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c2/librfate.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - - path: lib/esp32c2/libbtbb.a - sha256: 2927f2453abb49b08b4156651c42806e37a02c6f18b1b6de460da77ed16082b5 + - path: lib/esp32c2/libphy.a + sha256: e3438a148025c452b9d694533a45bdeb99ac8d8d7563964089d70a8c44e6c007 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c2/libbtbb.a + url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c2/libphy.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - - path: lib/esp32c2/libbttestmode.a - sha256: d217aed665e98680dd69f223afad6ac7677b552448c78a180dfdf01dbab266e3 + - path: lib/esp32c3/libbttestmode.a + sha256: 6cd881b54ff7fbe12ca87059e54bbc5a9e3eea868a7fa66a4b5f1006865f1ebd type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c2/libbttestmode.a + url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c3/libbttestmode.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - - path: lib/esp32c3/librfate.a - sha256: 1481da61f9a8f2278772233ff90043b4bafdd3c692a168186aa8a4fac63eab76 + - path: lib/esp32c3/libbtbb.a + sha256: 3b0ba2c4e66029cb41815309674cb51e98342755b4c4c680c13b3a88ea2329b2 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c3/librfate.a + url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c3/libbtbb.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - path: lib/esp32c3/librftest.a @@ -461,36 +469,36 @@ blobs: url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c3/librftest.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - - path: lib/esp32c3/libphy.a - sha256: 75ef0f7d268fc7b74c9887631b329cadc44f8dd8a707211a5191f550a790969f + - path: lib/esp32c3/librfate.a + sha256: 1481da61f9a8f2278772233ff90043b4bafdd3c692a168186aa8a4fac63eab76 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c3/libphy.a + url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c3/librfate.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - - path: lib/esp32c3/libbtbb.a - sha256: 3b0ba2c4e66029cb41815309674cb51e98342755b4c4c680c13b3a88ea2329b2 + - path: lib/esp32c3/libphy.a + sha256: 75ef0f7d268fc7b74c9887631b329cadc44f8dd8a707211a5191f550a790969f type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c3/libbtbb.a + url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c3/libphy.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - - path: lib/esp32c3/libbttestmode.a - sha256: 6cd881b54ff7fbe12ca87059e54bbc5a9e3eea868a7fa66a4b5f1006865f1ebd + - path: lib/esp32s3/libbttestmode.a + sha256: 14495d9ed96eabe3862fa53163b1d2f993cbf35636ce02839eca177558cfef67 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c3/libbttestmode.a + url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32s3/libbttestmode.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - - path: lib/esp32s3/librfate.a - sha256: b451caa66762e21b1516865fee89105027085ecdb95484ad61e9b649b56ddc6f + - path: lib/esp32s3/libbtbb.a + sha256: 62749de05c432584f207f3c3b660617620eb35cca9bbe4716f90175fb09ac029 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32s3/librfate.a + url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32s3/libbtbb.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - path: lib/esp32s3/librftest.a @@ -501,36 +509,36 @@ blobs: url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32s3/librftest.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - - path: lib/esp32s3/libphy.a - sha256: 95560823fa3e3cc08858327fabf7146a10914485ff2e5ff2046de852241f9581 + - path: lib/esp32s3/librfate.a + sha256: b451caa66762e21b1516865fee89105027085ecdb95484ad61e9b649b56ddc6f type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32s3/libphy.a + url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32s3/librfate.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - - path: lib/esp32s3/libbtbb.a - sha256: 62749de05c432584f207f3c3b660617620eb35cca9bbe4716f90175fb09ac029 + - path: lib/esp32s3/libphy.a + sha256: 95560823fa3e3cc08858327fabf7146a10914485ff2e5ff2046de852241f9581 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32s3/libbtbb.a + url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32s3/libphy.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - - path: lib/esp32s3/libbttestmode.a - sha256: 14495d9ed96eabe3862fa53163b1d2f993cbf35636ce02839eca177558cfef67 + - path: lib/esp32c6/libbttestmode.a + sha256: 74769e32f99e3cf0ffa730f05bebb86959fe84c657ab96c132556bd1dfbf1923 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32s3/libbttestmode.a + url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c6/libbttestmode.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - - path: lib/esp32c6/librfate.a - sha256: 378d2384f06bf4b147ebd88009257fa8a364c5b187f3b84df00b3ae6670333fe + - path: lib/esp32c6/libbtbb.a + sha256: 575038f1b9c2764d34f91335ec5fe9e94e0744e10598874b5f3f62805c22ead3 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c6/librfate.a + url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c6/libbtbb.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - path: lib/esp32c6/librftest.a @@ -541,27 +549,19 @@ blobs: url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c6/librftest.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - - path: lib/esp32c6/libphy.a - sha256: 057f877aa851bf5996966734b7947d3da9bfef3db3ad33f0fd07e050e65e5849 - type: lib - version: '1.0' - license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c6/libphy.a - description: "Binary libraries supporting the ESP32 series RF subsystems" - doc-url: https://github.com/espressif/esp-phy-lib - - path: lib/esp32c6/libbtbb.a - sha256: 575038f1b9c2764d34f91335ec5fe9e94e0744e10598874b5f3f62805c22ead3 + - path: lib/esp32c6/librfate.a + sha256: 378d2384f06bf4b147ebd88009257fa8a364c5b187f3b84df00b3ae6670333fe type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c6/libbtbb.a + url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c6/librfate.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib - - path: lib/esp32c6/libbttestmode.a - sha256: 74769e32f99e3cf0ffa730f05bebb86959fe84c657ab96c132556bd1dfbf1923 + - path: lib/esp32c6/libphy.a + sha256: 057f877aa851bf5996966734b7947d3da9bfef3db3ad33f0fd07e050e65e5849 type: lib version: '1.0' license-path: zephyr/blobs/license.txt - url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c6/libbttestmode.a + url: https://github.com/espressif/esp-phy-lib/raw/06e7625de197bc12797dd701d6762229bca01826/esp32c6/libphy.a description: "Binary libraries supporting the ESP32 series RF subsystems" doc-url: https://github.com/espressif/esp-phy-lib diff --git a/zephyr/port/bluetooth/bt_stubs.c b/zephyr/port/bluetooth/bt_stubs.c index 6dd83653ed..8dd15a7962 100644 --- a/zephyr/port/bluetooth/bt_stubs.c +++ b/zephyr/port/bluetooth/bt_stubs.c @@ -104,6 +104,11 @@ uint8_t btdm_sleep_clock_sync(void) return 0; } +void sdk_config_extend_set_pll_track(bool enable) +{ + // No-op +} + bool btdm_lpclk_select_src(uint32_t sel) { return true; diff --git a/zephyr/scripts/submodules.txt b/zephyr/scripts/submodules.txt index 71762a7165..2c41b6b103 100644 --- a/zephyr/scripts/submodules.txt +++ b/zephyr/scripts/submodules.txt @@ -1,3 +1,4 @@ +aa8d03a0ff51c166267207e54002613bcedc576e components/bt/controller/lib_esp32c6/esp32c6-bt-lib https://github.com/espressif/esp32c6-bt-lib ef1dfc518572e9cda55f13906e32207b40ee280b components/bt/controller/lib_esp32c3_family https://github.com/espressif/esp32c3-bt-lib f21a9ef6a4af418621fab356755151d309aae568 components/bt/controller/lib_esp32 https://github.com/espressif/esp32-bt-lib 6020d3b9b22eeb4fa94a95a15555d0da699fbdf3 components/esp_wifi/lib https://github.com/espressif/esp32-wifi-lib