mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 17:19:09 -04:00
change(ble): Supported cuttable architecture for ble
This commit is contained in:
parent
472320a7a3
commit
c2449607dc
@ -91,6 +91,7 @@ if(CONFIG_BT_ENABLED)
|
|||||||
endif()
|
endif()
|
||||||
set(ldscripts "linker_esp32c2.lf")
|
set(ldscripts "linker_esp32c2.lf")
|
||||||
else()
|
else()
|
||||||
|
list(APPEND srcs "controller/${target_name}/ble.c")
|
||||||
list(APPEND ldscripts "linker_esp_ble_controller.lf")
|
list(APPEND ldscripts "linker_esp_ble_controller.lf")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -283,110 +283,116 @@ config BT_LE_CONTROLLER_TASK_STACK_SIZE
|
|||||||
help
|
help
|
||||||
This configures stack size of NimBLE controller task
|
This configures stack size of NimBLE controller task
|
||||||
|
|
||||||
menuconfig BT_LE_CONTROLLER_LOG_ENABLED
|
menu "Controller debug features"
|
||||||
bool "Controller log enable"
|
menuconfig BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default n
|
bool "Controller log enable"
|
||||||
help
|
default n
|
||||||
Enable controller log
|
help
|
||||||
|
Enable controller log
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
config BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||||
bool "enable controller log module"
|
bool "enable controller log module"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default y
|
default y
|
||||||
help
|
help
|
||||||
Enable controller log module
|
Enable controller log module
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_HCI_ENABLED
|
config BT_LE_CONTROLLER_LOG_HCI_ENABLED
|
||||||
bool "enable HCI log module"
|
bool "enable HCI log module"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default y
|
default y
|
||||||
help
|
help
|
||||||
Enable hci log module
|
Enable hci log module
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
config BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||||
bool "Controller log dump mode only"
|
bool "Controller log dump mode only"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default y
|
default y
|
||||||
help
|
help
|
||||||
Only operate in dump mode
|
Only operate in dump mode
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
config BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||||
bool "Output ble controller logs to SPI bus (Experimental)"
|
bool "Output ble controller logs to SPI bus (Experimental)"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||||
select BT_BLE_LOG_SPI_OUT_ENABLED
|
select BT_BLE_LOG_SPI_OUT_ENABLED
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
Output ble controller logs to SPI bus
|
Output ble controller logs to SPI bus
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
config BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||||
bool "Store ble controller logs to flash(Experimental)"
|
bool "Store ble controller logs to flash(Experimental)"
|
||||||
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
Store ble controller logs to flash memory.
|
Store ble controller logs to flash memory.
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_PARTITION_SIZE
|
config BT_LE_CONTROLLER_LOG_PARTITION_SIZE
|
||||||
int "size of ble controller log partition(Multiples of 4K)"
|
int "size of ble controller log partition(Multiples of 4K)"
|
||||||
depends on BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
depends on BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||||
default 65536
|
default 65536
|
||||||
help
|
help
|
||||||
The size of ble controller log partition shall be a multiples of 4K.
|
The size of ble controller log partition shall be a multiples of 4K.
|
||||||
The name of log partition shall be "bt_ctrl_log".
|
The name of log partition shall be "bt_ctrl_log".
|
||||||
The partition type shall be ESP_PARTITION_TYPE_DATA.
|
The partition type shall be ESP_PARTITION_TYPE_DATA.
|
||||||
The partition sub_type shall be ESP_PARTITION_SUBTYPE_ANY.
|
The partition sub_type shall be ESP_PARTITION_SUBTYPE_ANY.
|
||||||
|
|
||||||
config BT_LE_LOG_CTRL_BUF1_SIZE
|
config BT_LE_LOG_CTRL_BUF1_SIZE
|
||||||
int "size of the first BLE controller LOG buffer"
|
int "size of the first BLE controller LOG buffer"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default 4096
|
default 4096
|
||||||
help
|
help
|
||||||
Configure the size of the first BLE controller LOG buffer.
|
Configure the size of the first BLE controller LOG buffer.
|
||||||
|
|
||||||
config BT_LE_LOG_CTRL_BUF2_SIZE
|
config BT_LE_LOG_CTRL_BUF2_SIZE
|
||||||
int "size of the second BLE controller LOG buffer"
|
int "size of the second BLE controller LOG buffer"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default 1024
|
default 1024
|
||||||
help
|
help
|
||||||
Configure the size of the second BLE controller LOG buffer.
|
Configure the size of the second BLE controller LOG buffer.
|
||||||
|
|
||||||
config BT_LE_LOG_HCI_BUF_SIZE
|
config BT_LE_LOG_HCI_BUF_SIZE
|
||||||
int "size of the BLE HCI LOG buffer"
|
int "size of the BLE HCI LOG buffer"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default 4096
|
default 4096
|
||||||
help
|
help
|
||||||
Configure the size of the BLE HCI LOG buffer.
|
Configure the size of the BLE HCI LOG buffer.
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||||
bool "Enable wrap panic handler"
|
bool "Enable wrap panic handler"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
Wrap esp_panic_handler to get controller logs when PC pointer exception crashes.
|
Wrap esp_panic_handler to get controller logs when PC pointer exception crashes.
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
config BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
||||||
bool "Enable esp_task_wdt_isr_user_handler implementation"
|
bool "Enable esp_task_wdt_isr_user_handler implementation"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
Implement esp_task_wdt_isr_user_handler to get controller logs when task wdt issue is triggered.
|
Implement esp_task_wdt_isr_user_handler to get controller logs when task wdt issue is triggered.
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL
|
config BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL
|
||||||
int "The output level of controller log"
|
int "The output level of controller log"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
range 0 5
|
range 0 5
|
||||||
default 1
|
default 1
|
||||||
help
|
help
|
||||||
The output level of controller log.
|
The output level of controller log.
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH
|
config BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH
|
||||||
hex "The switch of module log output"
|
hex "The switch of module log output"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
range 0 0xFFFFFFFF
|
range 0 0xFFFFFFFF
|
||||||
default 0xFFFFFFFF
|
default 0xFFFFFFFF
|
||||||
help
|
help
|
||||||
The switch of module log output, this is an unsigned 32-bit hexadecimal value.
|
The switch of module log output, this is an unsigned 32-bit hexadecimal value.
|
||||||
|
|
||||||
|
config BT_LE_ERROR_SIM_ENABLED
|
||||||
|
bool "Enable controller features for internal testing"
|
||||||
|
default n
|
||||||
|
endmenu
|
||||||
|
|
||||||
config BT_LE_LL_RESOLV_LIST_SIZE
|
config BT_LE_LL_RESOLV_LIST_SIZE
|
||||||
int "BLE LL Resolving list size"
|
int "BLE LL Resolving list size"
|
||||||
|
106
components/bt/controller/esp32c5/ble.c
Normal file
106
components/bt/controller/esp32c5/ble.c
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
#include "esp_bt_cfg.h"
|
||||||
|
|
||||||
|
/* External functions or variables
|
||||||
|
************************************************************************
|
||||||
|
*/
|
||||||
|
int base_stack_initEnv(void);
|
||||||
|
void base_stack_deinitEnv(void);
|
||||||
|
int base_stack_enable(void);
|
||||||
|
void base_stack_disable(void);
|
||||||
|
|
||||||
|
int conn_stack_initEnv(void);
|
||||||
|
void conn_stack_deinitEnv(void);
|
||||||
|
int conn_stack_enable(void);
|
||||||
|
void conn_stack_disable(void);
|
||||||
|
|
||||||
|
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
int conn_errorSim_initEnv(void);
|
||||||
|
void conn_errorSim_deinitEnv(void);
|
||||||
|
int conn_errorSim_enable(void);
|
||||||
|
void conn_errorSim_disable(void);
|
||||||
|
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
|
||||||
|
/* Local functions definition
|
||||||
|
***************************************************************************
|
||||||
|
*/
|
||||||
|
int ble_stack_initEnv(void)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = base_stack_initEnv();
|
||||||
|
if (rc) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
rc = conn_stack_initEnv();
|
||||||
|
if (rc) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
rc = conn_errorSim_initEnv();
|
||||||
|
if (rc) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ble_stack_deinitEnv(void)
|
||||||
|
{
|
||||||
|
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
conn_errorSim_deinitEnv();
|
||||||
|
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
conn_stack_deinitEnv();
|
||||||
|
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
|
||||||
|
base_stack_deinitEnv();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ble_stack_enable(void)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = base_stack_enable();
|
||||||
|
if (rc) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
rc = conn_stack_enable();
|
||||||
|
if (rc) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
rc = conn_errorSim_enable();
|
||||||
|
if (rc) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ble_stack_disable(void)
|
||||||
|
{
|
||||||
|
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
conn_errorSim_disable();
|
||||||
|
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
conn_stack_disable();
|
||||||
|
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
|
||||||
|
base_stack_disable();
|
||||||
|
}
|
12
components/bt/controller/esp32c5/ble_priv.h
Normal file
12
components/bt/controller/esp32c5/ble_priv.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
int ble_stack_initEnv(void);
|
||||||
|
|
||||||
|
void ble_stack_deinitEnv(void);
|
||||||
|
|
||||||
|
int ble_stack_enable(void);
|
||||||
|
|
||||||
|
void ble_stack_disable(void);
|
@ -34,6 +34,7 @@
|
|||||||
#include "os/endian.h"
|
#include "os/endian.h"
|
||||||
|
|
||||||
#include "esp_bt.h"
|
#include "esp_bt.h"
|
||||||
|
#include "ble_priv.h"
|
||||||
#include "esp_intr_alloc.h"
|
#include "esp_intr_alloc.h"
|
||||||
#include "esp_sleep.h"
|
#include "esp_sleep.h"
|
||||||
#include "esp_pm.h"
|
#include "esp_pm.h"
|
||||||
@ -945,13 +946,19 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
|||||||
goto modem_deint;
|
goto modem_deint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||||
|
|
||||||
ret = r_ble_controller_init(cfg);
|
ret = r_ble_controller_init(cfg);
|
||||||
if (ret != ESP_OK) {
|
if (ret != ESP_OK) {
|
||||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "r_ble_controller_init failed %d", ret);
|
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "r_ble_controller_init failed %d", ret);
|
||||||
goto modem_deint;
|
goto modem_deint;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
ret = ble_stack_initEnv();
|
||||||
|
if (ret != ESP_OK) {
|
||||||
|
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_stack_initEnv failed %d", ret);
|
||||||
|
goto free_controller;
|
||||||
|
}
|
||||||
|
|
||||||
ble_controller_scan_duplicate_config();
|
ble_controller_scan_duplicate_config();
|
||||||
|
|
||||||
@ -991,6 +998,7 @@ free_controller:
|
|||||||
hci_transport_deinit();
|
hci_transport_deinit();
|
||||||
controller_sleep_deinit();
|
controller_sleep_deinit();
|
||||||
os_msys_deinit();
|
os_msys_deinit();
|
||||||
|
ble_stack_deinitEnv();
|
||||||
r_ble_controller_deinit();
|
r_ble_controller_deinit();
|
||||||
modem_deint:
|
modem_deint:
|
||||||
esp_ble_unregister_bb_funcs();
|
esp_ble_unregister_bb_funcs();
|
||||||
@ -1028,6 +1036,7 @@ esp_err_t esp_bt_controller_deinit(void)
|
|||||||
// modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
// modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||||
|
|
||||||
|
ble_stack_deinitEnv();
|
||||||
r_ble_controller_deinit();
|
r_ble_controller_deinit();
|
||||||
esp_ble_unregister_bb_funcs();
|
esp_ble_unregister_bb_funcs();
|
||||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
@ -1081,6 +1090,12 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
|||||||
r_ble_ll_scan_start_time_init_compensation(500);
|
r_ble_ll_scan_start_time_init_compensation(500);
|
||||||
r_priv_sdk_config_insert_proc_time_set(500);
|
r_priv_sdk_config_insert_proc_time_set(500);
|
||||||
#endif // CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
#endif // CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||||
|
|
||||||
|
if (ble_stack_enable() != 0) {
|
||||||
|
ret = ESP_FAIL;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if (r_ble_controller_enable(mode) != 0) {
|
if (r_ble_controller_enable(mode) != 0) {
|
||||||
ret = ESP_FAIL;
|
ret = ESP_FAIL;
|
||||||
goto error;
|
goto error;
|
||||||
@ -1089,6 +1104,7 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
|||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
ble_stack_disable();
|
||||||
#if CONFIG_SW_COEXIST_ENABLE
|
#if CONFIG_SW_COEXIST_ENABLE
|
||||||
coex_disable();
|
coex_disable();
|
||||||
#endif
|
#endif
|
||||||
@ -1112,6 +1128,7 @@ esp_err_t esp_bt_controller_disable(void)
|
|||||||
if (r_ble_controller_disable() != 0) {
|
if (r_ble_controller_disable() != 0) {
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
ble_stack_disable();
|
||||||
#if CONFIG_SW_COEXIST_ENABLE
|
#if CONFIG_SW_COEXIST_ENABLE
|
||||||
coex_disable();
|
coex_disable();
|
||||||
#endif
|
#endif
|
||||||
|
@ -315,110 +315,116 @@ config BT_LE_CONTROLLER_TASK_STACK_SIZE
|
|||||||
help
|
help
|
||||||
This configures stack size of NimBLE controller task
|
This configures stack size of NimBLE controller task
|
||||||
|
|
||||||
menuconfig BT_LE_CONTROLLER_LOG_ENABLED
|
menu "Controller debug features"
|
||||||
bool "Controller log enable"
|
menuconfig BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default n
|
bool "Controller log enable"
|
||||||
help
|
default n
|
||||||
Enable controller log
|
help
|
||||||
|
Enable controller log
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
config BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||||
bool "enable controller log module"
|
bool "enable controller log module"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default y
|
default y
|
||||||
help
|
help
|
||||||
Enable controller log module
|
Enable controller log module
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_HCI_ENABLED
|
config BT_LE_CONTROLLER_LOG_HCI_ENABLED
|
||||||
bool "enable HCI log module"
|
bool "enable HCI log module"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default y
|
default y
|
||||||
help
|
help
|
||||||
Enable hci log module
|
Enable hci log module
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
config BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||||
bool "Controller log dump mode only"
|
bool "Controller log dump mode only"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default y
|
default y
|
||||||
help
|
help
|
||||||
Only operate in dump mode
|
Only operate in dump mode
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
config BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||||
bool "Output ble controller logs to SPI bus (Experimental)"
|
bool "Output ble controller logs to SPI bus (Experimental)"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||||
select BT_BLE_LOG_SPI_OUT_ENABLED
|
select BT_BLE_LOG_SPI_OUT_ENABLED
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
Output ble controller logs to SPI bus
|
Output ble controller logs to SPI bus
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
config BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||||
bool "Store ble controller logs to flash(Experimental)"
|
bool "Store ble controller logs to flash(Experimental)"
|
||||||
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
Store ble controller logs to flash memory.
|
Store ble controller logs to flash memory.
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_PARTITION_SIZE
|
config BT_LE_CONTROLLER_LOG_PARTITION_SIZE
|
||||||
int "size of ble controller log partition(Multiples of 4K)"
|
int "size of ble controller log partition(Multiples of 4K)"
|
||||||
depends on BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
depends on BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||||
default 65536
|
default 65536
|
||||||
help
|
help
|
||||||
The size of ble controller log partition shall be a multiples of 4K.
|
The size of ble controller log partition shall be a multiples of 4K.
|
||||||
The name of log partition shall be "bt_ctrl_log".
|
The name of log partition shall be "bt_ctrl_log".
|
||||||
The partition type shall be ESP_PARTITION_TYPE_DATA.
|
The partition type shall be ESP_PARTITION_TYPE_DATA.
|
||||||
The partition sub_type shall be ESP_PARTITION_SUBTYPE_ANY.
|
The partition sub_type shall be ESP_PARTITION_SUBTYPE_ANY.
|
||||||
|
|
||||||
config BT_LE_LOG_CTRL_BUF1_SIZE
|
config BT_LE_LOG_CTRL_BUF1_SIZE
|
||||||
int "size of the first BLE controller LOG buffer"
|
int "size of the first BLE controller LOG buffer"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default 4096
|
default 4096
|
||||||
help
|
help
|
||||||
Configure the size of the first BLE controller LOG buffer.
|
Configure the size of the first BLE controller LOG buffer.
|
||||||
|
|
||||||
config BT_LE_LOG_CTRL_BUF2_SIZE
|
config BT_LE_LOG_CTRL_BUF2_SIZE
|
||||||
int "size of the second BLE controller LOG buffer"
|
int "size of the second BLE controller LOG buffer"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default 1024
|
default 1024
|
||||||
help
|
help
|
||||||
Configure the size of the second BLE controller LOG buffer.
|
Configure the size of the second BLE controller LOG buffer.
|
||||||
|
|
||||||
config BT_LE_LOG_HCI_BUF_SIZE
|
config BT_LE_LOG_HCI_BUF_SIZE
|
||||||
int "size of the BLE HCI LOG buffer"
|
int "size of the BLE HCI LOG buffer"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default 4096
|
default 4096
|
||||||
help
|
help
|
||||||
Configure the size of the BLE HCI LOG buffer.
|
Configure the size of the BLE HCI LOG buffer.
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||||
bool "Enable wrap panic handler"
|
bool "Enable wrap panic handler"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
Wrap esp_panic_handler to get controller logs when PC pointer exception crashes.
|
Wrap esp_panic_handler to get controller logs when PC pointer exception crashes.
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
config BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
||||||
bool "Enable esp_task_wdt_isr_user_handler implementation"
|
bool "Enable esp_task_wdt_isr_user_handler implementation"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
Implement esp_task_wdt_isr_user_handler to get controller logs when task wdt issue is triggered.
|
Implement esp_task_wdt_isr_user_handler to get controller logs when task wdt issue is triggered.
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL
|
config BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL
|
||||||
int "The output level of controller log"
|
int "The output level of controller log"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
range 0 5
|
range 0 5
|
||||||
default 1
|
default 1
|
||||||
help
|
help
|
||||||
The output level of controller log.
|
The output level of controller log.
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH
|
config BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH
|
||||||
hex "The switch of module log output"
|
hex "The switch of module log output"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
range 0 0xFFFFFFFF
|
range 0 0xFFFFFFFF
|
||||||
default 0xFFFFFFFF
|
default 0xFFFFFFFF
|
||||||
help
|
help
|
||||||
The switch of module log output, this is an unsigned 32-bit hexadecimal value.
|
The switch of module log output, this is an unsigned 32-bit hexadecimal value.
|
||||||
|
|
||||||
|
config BT_LE_ERROR_SIM_ENABLED
|
||||||
|
bool "Enable controller features for internal testing"
|
||||||
|
default n
|
||||||
|
endmenu
|
||||||
|
|
||||||
config BT_LE_LL_RESOLV_LIST_SIZE
|
config BT_LE_LL_RESOLV_LIST_SIZE
|
||||||
int "BLE LL Resolving list size"
|
int "BLE LL Resolving list size"
|
||||||
|
106
components/bt/controller/esp32c6/ble.c
Normal file
106
components/bt/controller/esp32c6/ble.c
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
#include "esp_bt_cfg.h"
|
||||||
|
|
||||||
|
/* External functions or variables
|
||||||
|
************************************************************************
|
||||||
|
*/
|
||||||
|
int base_stack_initEnv(void);
|
||||||
|
void base_stack_deinitEnv(void);
|
||||||
|
int base_stack_enable(void);
|
||||||
|
void base_stack_disable(void);
|
||||||
|
|
||||||
|
int conn_stack_initEnv(void);
|
||||||
|
void conn_stack_deinitEnv(void);
|
||||||
|
int conn_stack_enable(void);
|
||||||
|
void conn_stack_disable(void);
|
||||||
|
|
||||||
|
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
int conn_errorSim_initEnv(void);
|
||||||
|
void conn_errorSim_deinitEnv(void);
|
||||||
|
int conn_errorSim_enable(void);
|
||||||
|
void conn_errorSim_disable(void);
|
||||||
|
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
|
||||||
|
/* Local functions definition
|
||||||
|
***************************************************************************
|
||||||
|
*/
|
||||||
|
int ble_stack_initEnv(void)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = base_stack_initEnv();
|
||||||
|
if (rc) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
rc = conn_stack_initEnv();
|
||||||
|
if (rc) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
rc = conn_errorSim_initEnv();
|
||||||
|
if (rc) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ble_stack_deinitEnv(void)
|
||||||
|
{
|
||||||
|
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
conn_errorSim_deinitEnv();
|
||||||
|
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
conn_stack_deinitEnv();
|
||||||
|
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
|
||||||
|
base_stack_deinitEnv();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ble_stack_enable(void)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = base_stack_enable();
|
||||||
|
if (rc) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
rc = conn_stack_enable();
|
||||||
|
if (rc) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
rc = conn_errorSim_enable();
|
||||||
|
if (rc) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ble_stack_disable(void)
|
||||||
|
{
|
||||||
|
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
conn_errorSim_disable();
|
||||||
|
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
conn_stack_disable();
|
||||||
|
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
|
||||||
|
base_stack_disable();
|
||||||
|
}
|
12
components/bt/controller/esp32c6/ble_priv.h
Normal file
12
components/bt/controller/esp32c6/ble_priv.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
int ble_stack_initEnv(void);
|
||||||
|
|
||||||
|
void ble_stack_deinitEnv(void);
|
||||||
|
|
||||||
|
int ble_stack_enable(void);
|
||||||
|
|
||||||
|
void ble_stack_disable(void);
|
@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#include "esp_bt.h"
|
#include "esp_bt.h"
|
||||||
#include "esp_intr_alloc.h"
|
#include "esp_intr_alloc.h"
|
||||||
|
#include "ble_priv.h"
|
||||||
#include "esp_sleep.h"
|
#include "esp_sleep.h"
|
||||||
#include "esp_pm.h"
|
#include "esp_pm.h"
|
||||||
#ifdef CONFIG_ESP_PHY_ENABLED
|
#ifdef CONFIG_ESP_PHY_ENABLED
|
||||||
@ -963,13 +964,19 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
|||||||
goto modem_deint;
|
goto modem_deint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||||
|
|
||||||
ret = r_ble_controller_init(cfg);
|
ret = r_ble_controller_init(cfg);
|
||||||
if (ret != ESP_OK) {
|
if (ret != ESP_OK) {
|
||||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "r_ble_controller_init failed %d", ret);
|
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "r_ble_controller_init failed %d", ret);
|
||||||
goto modem_deint;
|
goto modem_deint;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
ret = ble_stack_initEnv();
|
||||||
|
if (ret != ESP_OK) {
|
||||||
|
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_stack_initEnv failed %d", ret);
|
||||||
|
goto free_controller;
|
||||||
|
}
|
||||||
|
|
||||||
ble_controller_scan_duplicate_config();
|
ble_controller_scan_duplicate_config();
|
||||||
|
|
||||||
@ -1012,6 +1019,7 @@ free_controller:
|
|||||||
hci_transport_deinit();
|
hci_transport_deinit();
|
||||||
controller_sleep_deinit();
|
controller_sleep_deinit();
|
||||||
os_msys_deinit();
|
os_msys_deinit();
|
||||||
|
ble_stack_deinitEnv();
|
||||||
r_ble_controller_deinit();
|
r_ble_controller_deinit();
|
||||||
modem_deint:
|
modem_deint:
|
||||||
esp_ble_unregister_bb_funcs();
|
esp_ble_unregister_bb_funcs();
|
||||||
@ -1049,6 +1057,7 @@ esp_err_t esp_bt_controller_deinit(void)
|
|||||||
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||||
|
|
||||||
|
ble_stack_deinitEnv();
|
||||||
r_ble_controller_deinit();
|
r_ble_controller_deinit();
|
||||||
esp_ble_unregister_bb_funcs();
|
esp_ble_unregister_bb_funcs();
|
||||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
@ -1102,6 +1111,12 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
|||||||
r_ble_ll_scan_start_time_init_compensation(500);
|
r_ble_ll_scan_start_time_init_compensation(500);
|
||||||
r_priv_sdk_config_insert_proc_time_set(500);
|
r_priv_sdk_config_insert_proc_time_set(500);
|
||||||
#endif // CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
#endif // CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||||
|
|
||||||
|
if (ble_stack_enable() != 0) {
|
||||||
|
ret = ESP_FAIL;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if (r_ble_controller_enable(mode) != 0) {
|
if (r_ble_controller_enable(mode) != 0) {
|
||||||
ret = ESP_FAIL;
|
ret = ESP_FAIL;
|
||||||
goto error;
|
goto error;
|
||||||
@ -1110,6 +1125,7 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
|||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
ble_stack_disable();
|
||||||
#if CONFIG_SW_COEXIST_ENABLE
|
#if CONFIG_SW_COEXIST_ENABLE
|
||||||
coex_disable();
|
coex_disable();
|
||||||
#endif
|
#endif
|
||||||
@ -1133,6 +1149,7 @@ esp_err_t esp_bt_controller_disable(void)
|
|||||||
if (r_ble_controller_disable() != 0) {
|
if (r_ble_controller_disable() != 0) {
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
ble_stack_disable();
|
||||||
#if CONFIG_SW_COEXIST_ENABLE
|
#if CONFIG_SW_COEXIST_ENABLE
|
||||||
coex_disable();
|
coex_disable();
|
||||||
#endif
|
#endif
|
||||||
|
@ -306,110 +306,116 @@ config BT_LE_CONTROLLER_TASK_STACK_SIZE
|
|||||||
help
|
help
|
||||||
This configures stack size of NimBLE controller task
|
This configures stack size of NimBLE controller task
|
||||||
|
|
||||||
menuconfig BT_LE_CONTROLLER_LOG_ENABLED
|
menu "Controller debug features"
|
||||||
bool "Controller log enable"
|
menuconfig BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default n
|
bool "Controller log enable"
|
||||||
help
|
default n
|
||||||
Enable controller log
|
help
|
||||||
|
Enable controller log
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
config BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||||
bool "enable controller log module"
|
bool "enable controller log module"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default y
|
default y
|
||||||
help
|
help
|
||||||
Enable controller log module
|
Enable controller log module
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_HCI_ENABLED
|
config BT_LE_CONTROLLER_LOG_HCI_ENABLED
|
||||||
bool "enable HCI log module"
|
bool "enable HCI log module"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default y
|
default y
|
||||||
help
|
help
|
||||||
Enable hci log module
|
Enable hci log module
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
config BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||||
bool "Controller log dump mode only"
|
bool "Controller log dump mode only"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default y
|
default y
|
||||||
help
|
help
|
||||||
Only operate in dump mode
|
Only operate in dump mode
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
config BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||||
bool "Output ble controller logs to SPI bus (Experimental)"
|
bool "Output ble controller logs to SPI bus (Experimental)"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||||
select BT_BLE_LOG_SPI_OUT_ENABLED
|
select BT_BLE_LOG_SPI_OUT_ENABLED
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
Output ble controller logs to SPI bus
|
Output ble controller logs to SPI bus
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
config BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||||
bool "Store ble controller logs to flash(Experimental)"
|
bool "Store ble controller logs to flash(Experimental)"
|
||||||
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
Store ble controller logs to flash memory.
|
Store ble controller logs to flash memory.
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_PARTITION_SIZE
|
config BT_LE_CONTROLLER_LOG_PARTITION_SIZE
|
||||||
int "size of ble controller log partition(Multiples of 4K)"
|
int "size of ble controller log partition(Multiples of 4K)"
|
||||||
depends on BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
depends on BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||||
default 65536
|
default 65536
|
||||||
help
|
help
|
||||||
The size of ble controller log partition shall be a multiples of 4K.
|
The size of ble controller log partition shall be a multiples of 4K.
|
||||||
The name of log partition shall be "bt_ctrl_log".
|
The name of log partition shall be "bt_ctrl_log".
|
||||||
The partition type shall be ESP_PARTITION_TYPE_DATA.
|
The partition type shall be ESP_PARTITION_TYPE_DATA.
|
||||||
The partition sub_type shall be ESP_PARTITION_SUBTYPE_ANY.
|
The partition sub_type shall be ESP_PARTITION_SUBTYPE_ANY.
|
||||||
|
|
||||||
config BT_LE_LOG_CTRL_BUF1_SIZE
|
config BT_LE_LOG_CTRL_BUF1_SIZE
|
||||||
int "size of the first BLE controller LOG buffer"
|
int "size of the first BLE controller LOG buffer"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default 4096
|
default 4096
|
||||||
help
|
help
|
||||||
Configure the size of the first BLE controller LOG buffer.
|
Configure the size of the first BLE controller LOG buffer.
|
||||||
|
|
||||||
config BT_LE_LOG_CTRL_BUF2_SIZE
|
config BT_LE_LOG_CTRL_BUF2_SIZE
|
||||||
int "size of the second BLE controller LOG buffer"
|
int "size of the second BLE controller LOG buffer"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default 1024
|
default 1024
|
||||||
help
|
help
|
||||||
Configure the size of the second BLE controller LOG buffer.
|
Configure the size of the second BLE controller LOG buffer.
|
||||||
|
|
||||||
config BT_LE_LOG_HCI_BUF_SIZE
|
config BT_LE_LOG_HCI_BUF_SIZE
|
||||||
int "size of the BLE HCI LOG buffer"
|
int "size of the BLE HCI LOG buffer"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default 4096
|
default 4096
|
||||||
help
|
help
|
||||||
Configure the size of the BLE HCI LOG buffer.
|
Configure the size of the BLE HCI LOG buffer.
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||||
bool "Enable wrap panic handler"
|
bool "Enable wrap panic handler"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
Wrap esp_panic_handler to get controller logs when PC pointer exception crashes.
|
Wrap esp_panic_handler to get controller logs when PC pointer exception crashes.
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
config BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
||||||
bool "Enable esp_task_wdt_isr_user_handler implementation"
|
bool "Enable esp_task_wdt_isr_user_handler implementation"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
Implement esp_task_wdt_isr_user_handler to get controller logs when task wdt issue is triggered.
|
Implement esp_task_wdt_isr_user_handler to get controller logs when task wdt issue is triggered.
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL
|
config BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL
|
||||||
int "The output level of controller log"
|
int "The output level of controller log"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
range 0 5
|
range 0 5
|
||||||
default 1
|
default 1
|
||||||
help
|
help
|
||||||
The output level of controller log.
|
The output level of controller log.
|
||||||
|
|
||||||
config BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH
|
config BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH
|
||||||
hex "The switch of module log output"
|
hex "The switch of module log output"
|
||||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
range 0 0xFFFFFFFF
|
range 0 0xFFFFFFFF
|
||||||
default 0xFFFFFFFF
|
default 0xFFFFFFFF
|
||||||
help
|
help
|
||||||
The switch of module log output, this is an unsigned 32-bit hexadecimal value.
|
The switch of module log output, this is an unsigned 32-bit hexadecimal value.
|
||||||
|
|
||||||
|
config BT_LE_ERROR_SIM_ENABLED
|
||||||
|
bool "Enable controller features for internal testing"
|
||||||
|
default n
|
||||||
|
endmenu
|
||||||
|
|
||||||
config BT_LE_LL_RESOLV_LIST_SIZE
|
config BT_LE_LL_RESOLV_LIST_SIZE
|
||||||
int "BLE LL Resolving list size"
|
int "BLE LL Resolving list size"
|
||||||
|
106
components/bt/controller/esp32h2/ble.c
Normal file
106
components/bt/controller/esp32h2/ble.c
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
#include "esp_bt_cfg.h"
|
||||||
|
|
||||||
|
/* External functions or variables
|
||||||
|
************************************************************************
|
||||||
|
*/
|
||||||
|
int base_stack_initEnv(void);
|
||||||
|
void base_stack_deinitEnv(void);
|
||||||
|
int base_stack_enable(void);
|
||||||
|
void base_stack_disable(void);
|
||||||
|
|
||||||
|
int conn_stack_initEnv(void);
|
||||||
|
void conn_stack_deinitEnv(void);
|
||||||
|
int conn_stack_enable(void);
|
||||||
|
void conn_stack_disable(void);
|
||||||
|
|
||||||
|
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
int conn_errorSim_initEnv(void);
|
||||||
|
void conn_errorSim_deinitEnv(void);
|
||||||
|
int conn_errorSim_enable(void);
|
||||||
|
void conn_errorSim_disable(void);
|
||||||
|
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
|
||||||
|
/* Local functions definition
|
||||||
|
***************************************************************************
|
||||||
|
*/
|
||||||
|
int ble_stack_initEnv(void)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = base_stack_initEnv();
|
||||||
|
if (rc) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
rc = conn_stack_initEnv();
|
||||||
|
if (rc) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
rc = conn_errorSim_initEnv();
|
||||||
|
if (rc) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ble_stack_deinitEnv(void)
|
||||||
|
{
|
||||||
|
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
conn_errorSim_deinitEnv();
|
||||||
|
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
conn_stack_deinitEnv();
|
||||||
|
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
|
||||||
|
base_stack_deinitEnv();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ble_stack_enable(void)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = base_stack_enable();
|
||||||
|
if (rc) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
rc = conn_stack_enable();
|
||||||
|
if (rc) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
rc = conn_errorSim_enable();
|
||||||
|
if (rc) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ble_stack_disable(void)
|
||||||
|
{
|
||||||
|
#if DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
#if CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
conn_errorSim_disable();
|
||||||
|
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
|
||||||
|
conn_stack_disable();
|
||||||
|
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS
|
||||||
|
|
||||||
|
base_stack_disable();
|
||||||
|
}
|
12
components/bt/controller/esp32h2/ble_priv.h
Normal file
12
components/bt/controller/esp32h2/ble_priv.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
int ble_stack_initEnv(void);
|
||||||
|
|
||||||
|
void ble_stack_deinitEnv(void);
|
||||||
|
|
||||||
|
int ble_stack_enable(void);
|
||||||
|
|
||||||
|
void ble_stack_disable(void);
|
@ -34,6 +34,7 @@
|
|||||||
#include "os/endian.h"
|
#include "os/endian.h"
|
||||||
|
|
||||||
#include "esp_bt.h"
|
#include "esp_bt.h"
|
||||||
|
#include "ble_priv.h"
|
||||||
#include "esp_intr_alloc.h"
|
#include "esp_intr_alloc.h"
|
||||||
#include "esp_sleep.h"
|
#include "esp_sleep.h"
|
||||||
#include "esp_pm.h"
|
#include "esp_pm.h"
|
||||||
@ -939,13 +940,19 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
|||||||
goto modem_deint;
|
goto modem_deint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||||
|
|
||||||
ret = r_ble_controller_init(cfg);
|
ret = r_ble_controller_init(cfg);
|
||||||
if (ret != ESP_OK) {
|
if (ret != ESP_OK) {
|
||||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "r_ble_controller_init failed %d", ret);
|
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "r_ble_controller_init failed %d", ret);
|
||||||
goto modem_deint;
|
goto modem_deint;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
ret = ble_stack_initEnv();
|
||||||
|
if (ret != ESP_OK) {
|
||||||
|
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_stack_initEnv failed %d", ret);
|
||||||
|
goto free_controller;
|
||||||
|
}
|
||||||
|
|
||||||
ble_controller_scan_duplicate_config();
|
ble_controller_scan_duplicate_config();
|
||||||
|
|
||||||
@ -988,6 +995,7 @@ free_controller:
|
|||||||
hci_transport_deinit();
|
hci_transport_deinit();
|
||||||
controller_sleep_deinit();
|
controller_sleep_deinit();
|
||||||
os_msys_deinit();
|
os_msys_deinit();
|
||||||
|
ble_stack_deinitEnv();
|
||||||
r_ble_controller_deinit();
|
r_ble_controller_deinit();
|
||||||
modem_deint:
|
modem_deint:
|
||||||
esp_ble_unregister_bb_funcs();
|
esp_ble_unregister_bb_funcs();
|
||||||
@ -1023,6 +1031,7 @@ esp_err_t esp_bt_controller_deinit(void)
|
|||||||
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||||
|
|
||||||
|
ble_stack_deinitEnv();
|
||||||
r_ble_controller_deinit();
|
r_ble_controller_deinit();
|
||||||
esp_ble_unregister_bb_funcs();
|
esp_ble_unregister_bb_funcs();
|
||||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||||
@ -1076,6 +1085,12 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
|||||||
r_ble_ll_scan_start_time_init_compensation(500);
|
r_ble_ll_scan_start_time_init_compensation(500);
|
||||||
r_priv_sdk_config_insert_proc_time_set(500);
|
r_priv_sdk_config_insert_proc_time_set(500);
|
||||||
#endif // CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
#endif // CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY
|
||||||
|
|
||||||
|
if (ble_stack_enable() != 0) {
|
||||||
|
ret = ESP_FAIL;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if (r_ble_controller_enable(mode) != 0) {
|
if (r_ble_controller_enable(mode) != 0) {
|
||||||
ret = ESP_FAIL;
|
ret = ESP_FAIL;
|
||||||
goto error;
|
goto error;
|
||||||
@ -1084,6 +1099,7 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
|||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
ble_stack_disable();
|
||||||
#if CONFIG_SW_COEXIST_ENABLE
|
#if CONFIG_SW_COEXIST_ENABLE
|
||||||
coex_disable();
|
coex_disable();
|
||||||
#endif
|
#endif
|
||||||
@ -1107,6 +1123,7 @@ esp_err_t esp_bt_controller_disable(void)
|
|||||||
if (r_ble_controller_disable() != 0) {
|
if (r_ble_controller_disable() != 0) {
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
ble_stack_disable();
|
||||||
#if CONFIG_SW_COEXIST_ENABLE
|
#if CONFIG_SW_COEXIST_ENABLE
|
||||||
coex_disable();
|
coex_disable();
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user