mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-02 18:10:57 +02:00
Merge branch 'feat/ble_log_v2_esp_target_support_v5.3' into 'release/v5.3'
Feat/ble log v2 esp target support (v5.3) See merge request espressif/esp-idf!41919
This commit is contained in:
@@ -33,12 +33,32 @@ if BLE_LOG_ENABLED
|
||||
try to use the LBM with spin lock protection. So the more LBMs with atomic
|
||||
lock protection are created, the more ISRs can nest.
|
||||
|
||||
config BLE_LOG_IS_ESP_CONTROLLER
|
||||
bool "Current BLE Controller is ESP BLE Controller"
|
||||
depends on BT_CONTROLLER_ENABLED
|
||||
depends on SOC_ESP_NIMBLE_CONTROLLER
|
||||
default y
|
||||
select BT_LE_CONTROLLER_LOG_ENABLED
|
||||
select BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
|
||||
select BLE_LOG_LL_ENABLED
|
||||
help
|
||||
Current BLE Controller is ESP BLE Controller
|
||||
|
||||
config BLE_LOG_IS_ESP_LEGACY_CONTROLLER
|
||||
bool "Current BLE Controller is ESP BLE Legacy Controller"
|
||||
depends on BT_CONTROLLER_ENABLED
|
||||
depends on !SOC_ESP_NIMBLE_CONTROLLER
|
||||
depends on BT_CTRL_RUN_IN_FLASH_ONLY
|
||||
default y
|
||||
select BT_CTRL_LE_LOG_EN
|
||||
select BLE_LOG_LL_ENABLED
|
||||
help
|
||||
Current BLE Controller is ESP BLE Legacy Controller
|
||||
|
||||
config BLE_LOG_LL_ENABLED
|
||||
bool "Enable BLE Log for Link Layer"
|
||||
depends on BT_CONTROLLER_ENABLED
|
||||
default y
|
||||
select BT_LE_CONTROLLER_LOG_ENABLED
|
||||
select BT_LE_CONTROLLER_LOG_MODE_BLE_LOG
|
||||
default n
|
||||
help
|
||||
Enable BLE Log for Link Layer
|
||||
|
||||
@@ -96,11 +116,13 @@ if BLE_LOG_ENABLED
|
||||
|
||||
config BLE_LOG_PRPH_SPI_MASTER_DMA
|
||||
bool "Utilize SPI master DMA driver as transport"
|
||||
depends on SOC_GPSPI_SUPPORTED
|
||||
help
|
||||
Utilize SPI master DMA driver as transport
|
||||
|
||||
config BLE_LOG_PRPH_UART_DMA
|
||||
bool "Utilize UART DMA driver as transport"
|
||||
depends on SOC_UHCI_SUPPORTED
|
||||
help
|
||||
Utilize UART DMA driver as transport
|
||||
endchoice
|
||||
|
@@ -17,7 +17,6 @@
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/portmacro.h"
|
||||
|
||||
/* ------------------------- */
|
||||
/* Log Frame Defines */
|
||||
|
@@ -17,11 +17,11 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "esp_bit_defs.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
|
||||
#ifndef UNIT_TEST
|
||||
#include "freertos/portmacro.h"
|
||||
#include "esp_heap_caps.h"
|
||||
#include "esp_rom_serial_output.h"
|
||||
#include "esp_rom_uart.h"
|
||||
#endif /* !UNIT_TEST */
|
||||
|
||||
/* MACRO */
|
||||
@@ -47,18 +47,9 @@
|
||||
#define BLE_LOG_MEMSET(ptr, value, len) memset(ptr, value, len)
|
||||
|
||||
/* Critical section wrapper */
|
||||
#ifndef CONFIG_BLE_LOG_LL_ENABLED
|
||||
extern portMUX_TYPE ble_log_spin_lock;
|
||||
#define BLE_LOG_ENTER_CRITICAL() portENTER_CRITICAL_SAFE(&ble_log_spin_lock);
|
||||
#define BLE_LOG_EXIT_CRITICAL() portEXIT_CRITICAL_SAFE(&ble_log_spin_lock);
|
||||
#else /* CONFIG_BLE_LOG_LL_ENABLED */
|
||||
/* Note
|
||||
* It's mandatory to use the same spin lock with Link Layer in multi-core system */
|
||||
extern uint32_t npl_freertos_hw_enter_critical(void);
|
||||
extern void npl_freertos_hw_exit_critical(uint32_t ctx);
|
||||
#define BLE_LOG_ENTER_CRITICAL() npl_freertos_hw_enter_critical()
|
||||
#define BLE_LOG_EXIT_CRITICAL() npl_freertos_hw_exit_critical(0)
|
||||
#endif /* !CONFIG_BLE_LOG_LL_ENABLED */
|
||||
|
||||
#define BLE_LOG_ACQUIRE_SPIN_LOCK(spin_lock) portENTER_CRITICAL_SAFE(spin_lock)
|
||||
#define BLE_LOG_RELEASE_SPIN_LOCK(spin_lock) portEXIT_CRITICAL_SAFE(spin_lock)
|
||||
|
@@ -23,7 +23,7 @@
|
||||
|
||||
/* MACRO */
|
||||
#define BLE_LOG_UART_MAX_TRANSFER_SIZE (10240)
|
||||
#define BLE_LOG_UART_RX_BUF_SIZE (32)
|
||||
#define BLE_LOG_UART_RX_BUF_SIZE (256)
|
||||
#define BLE_LOG_UART_DMA_BURST_SIZE (32)
|
||||
#if BLE_LOG_PRPH_UART_DMA_REDIR
|
||||
#define BLE_LOG_UART_REDIR_BUF_SIZE (512)
|
||||
@@ -95,8 +95,6 @@ bool ble_log_prph_init(size_t trans_cnt)
|
||||
.data_bits = UART_DATA_8_BITS,
|
||||
.parity = UART_PARITY_DISABLE,
|
||||
.stop_bits = UART_STOP_BITS_1,
|
||||
.flow_ctrl = UART_HW_FLOWCTRL_CTS_RTS,
|
||||
.rx_flow_ctrl_thresh = 122,
|
||||
};
|
||||
if ((uart_param_config(CONFIG_BLE_LOG_PRPH_UART_DMA_PORT, &uart_config) != ESP_OK) ||
|
||||
(uart_set_pin(CONFIG_BLE_LOG_PRPH_UART_DMA_PORT,
|
||||
|
@@ -48,9 +48,13 @@
|
||||
#include "esp_rom_sys.h"
|
||||
#include "hli_api.h"
|
||||
|
||||
#if CONFIG_BLE_LOG_ENABLED
|
||||
#include "ble_log.h"
|
||||
#else /* !CONFIG_BLE_LOG_ENABLED */
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
#include "ble_log/ble_log_spi_out.h"
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
#endif /* CONFIG_BLE_LOG_ENABLED */
|
||||
|
||||
#if CONFIG_BT_ENABLED
|
||||
|
||||
@@ -1702,6 +1706,13 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
coex_init();
|
||||
#endif
|
||||
|
||||
#if CONFIG_BLE_LOG_ENABLED
|
||||
if (!ble_log_init()) {
|
||||
ESP_LOGE(BTDM_LOG_TAG, "BLE Log v2 init failed");
|
||||
err = ESP_ERR_NO_MEM;
|
||||
goto error;
|
||||
}
|
||||
#else /* !CONFIG_BLE_LOG_ENABLED */
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
if (ble_log_spi_out_init() != 0) {
|
||||
ESP_LOGE(BTDM_LOG_TAG, "BLE Log SPI output init failed");
|
||||
@@ -1709,6 +1720,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
goto error;
|
||||
}
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
#endif /* CONFIG_BLE_LOG_ENABLED */
|
||||
|
||||
btdm_cfg_mask = btdm_config_mask_load();
|
||||
|
||||
@@ -1737,9 +1749,13 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
|
||||
error:
|
||||
|
||||
#if CONFIG_BLE_LOG_ENABLED
|
||||
ble_log_deinit();
|
||||
#else /* !CONFIG_BLE_LOG_ENABLED */
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
ble_log_spi_out_deinit();
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
#endif /* CONFIG_BLE_LOG_ENABLED */
|
||||
|
||||
bt_controller_deinit_internal();
|
||||
|
||||
@@ -1752,9 +1768,13 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_LOG_ENABLED
|
||||
ble_log_deinit();
|
||||
#else /* !CONFIG_BLE_LOG_ENABLED */
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
ble_log_spi_out_deinit();
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
#endif /* CONFIG_BLE_LOG_ENABLED */
|
||||
|
||||
btdm_controller_deinit();
|
||||
|
||||
|
@@ -288,6 +288,14 @@ menu "Controller debug features"
|
||||
help
|
||||
Enable controller log
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
|
||||
bool "Utilize BLE Log v2 for controller log"
|
||||
depends on BLE_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
Utilize BLE Log v2 for controller log
|
||||
|
||||
if !BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
|
||||
config BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||
bool "enable controller log module"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
@@ -356,6 +364,7 @@ menu "Controller debug features"
|
||||
default 4096
|
||||
help
|
||||
Configure the size of the BLE HCI LOG buffer.
|
||||
endif
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||
bool "Enable wrap panic handler"
|
||||
|
@@ -66,9 +66,13 @@
|
||||
#include "hal/efuse_ll.h"
|
||||
#include "soc/rtc.h"
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
|
||||
#include "ble_log.h"
|
||||
#else /* !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
#include "ble_log/ble_log_spi_out.h"
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
#endif /* CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
|
||||
|
||||
/* Macro definition
|
||||
************************************************************************
|
||||
@@ -207,12 +211,14 @@ static int esp_ecc_gen_key_pair(uint8_t *pub, uint8_t *priv);
|
||||
static int esp_ecc_gen_dh_key(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_key_y,
|
||||
const uint8_t *our_priv_key, uint8_t *out_dhkey);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
#if !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
|
||||
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag);
|
||||
#endif // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
#endif /* !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
/* Local variable definition
|
||||
***************************************************************************
|
||||
@@ -224,9 +230,43 @@ void *g_ble_lll_rfmgmt_env_p;
|
||||
static DRAM_ATTR esp_bt_controller_status_t ble_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
const static uint32_t log_bufs_size[] = {CONFIG_BT_LE_LOG_CTRL_BUF1_SIZE, CONFIG_BT_LE_LOG_HCI_BUF_SIZE, CONFIG_BT_LE_LOG_CTRL_BUF2_SIZE};
|
||||
static bool log_is_inited = false;
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
|
||||
/* TODO: Remove event handler dependency in lib */
|
||||
static void void_handler(void) {}
|
||||
|
||||
/* TODO: Declare public interfaces in a public header */
|
||||
void esp_bt_controller_log_deinit(void)
|
||||
{
|
||||
log_is_inited = false;
|
||||
ble_log_deinit_simple();
|
||||
ble_log_deinit();
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_log_init(void)
|
||||
{
|
||||
if (log_is_inited) {
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if (!ble_log_init()) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (ble_log_init_simple(ble_log_write_hex_ll, void_handler) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
log_is_inited = true;
|
||||
return ESP_OK;
|
||||
|
||||
exit:
|
||||
esp_bt_controller_log_deinit();
|
||||
return ESP_FAIL;
|
||||
}
|
||||
#else /* !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
|
||||
const static uint32_t log_bufs_size[] = {CONFIG_BT_LE_LOG_CTRL_BUF1_SIZE, CONFIG_BT_LE_LOG_HCI_BUF_SIZE, CONFIG_BT_LE_LOG_CTRL_BUF2_SIZE};
|
||||
esp_err_t esp_bt_controller_log_init(void)
|
||||
{
|
||||
if (log_is_inited) {
|
||||
@@ -289,6 +329,7 @@ void esp_bt_controller_log_deinit(void)
|
||||
|
||||
log_is_inited = false;
|
||||
}
|
||||
#endif /* CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
#include "esp_partition.h"
|
||||
@@ -413,6 +454,12 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
|
||||
void esp_ble_controller_log_dump_all(bool output)
|
||||
{
|
||||
ble_log_dump_to_console();
|
||||
}
|
||||
#else /* !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
|
||||
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag)
|
||||
{
|
||||
@@ -455,6 +502,7 @@ void esp_ble_controller_log_dump_all(bool output)
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
#endif
|
||||
}
|
||||
#endif /* CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
|
||||
void esp_task_wdt_isr_user_handler(void)
|
||||
|
@@ -567,11 +567,15 @@ menu "Controller debug log Options (Experimental)"
|
||||
bool "Enable BLE debug log"
|
||||
default n
|
||||
|
||||
config BT_CTRL_LE_HCI_LOG_EN
|
||||
config BT_CTRL_LE_LOG_MODE_BLE_LOG_V2
|
||||
bool "Utilize BLE Log v2 for controller log"
|
||||
depends on BT_CTRL_LE_LOG_EN
|
||||
bool "Enable BLE HCI log"
|
||||
default n
|
||||
depends on BLE_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
Utilize BLE Log v2 for controller log
|
||||
|
||||
if !BT_CTRL_LE_LOG_MODE_BLE_LOG_V2
|
||||
config BT_CTRL_LE_LOG_DUMP_ONLY
|
||||
depends on BT_CTRL_LE_LOG_EN
|
||||
bool "Enable BLE log dump only"
|
||||
@@ -601,6 +605,12 @@ menu "Controller debug log Options (Experimental)"
|
||||
default n
|
||||
help
|
||||
Output ble controller logs to SPI bus
|
||||
endif
|
||||
|
||||
config BT_CTRL_LE_HCI_LOG_EN
|
||||
depends on BT_CTRL_LE_LOG_EN
|
||||
bool "Enable BLE HCI log"
|
||||
default n
|
||||
|
||||
config BT_CTRL_LE_LOG_MODE_EN
|
||||
depends on BT_CTRL_LE_LOG_EN
|
||||
|
@@ -49,9 +49,13 @@
|
||||
#else //CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/rom_layout.h"
|
||||
#endif
|
||||
#if CONFIG_BLE_LOG_ENABLED
|
||||
#include "ble_log.h"
|
||||
#else /* !CONFIG_BLE_LOG_ENABLED */
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
#include "ble_log/ble_log_spi_out.h"
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
#endif /* CONFIG_BLE_LOG_ENABLED */
|
||||
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||
#include "esp_partition.h"
|
||||
#include "hal/wdt_hal.h"
|
||||
@@ -502,10 +506,14 @@ enum log_out_mode {
|
||||
LOG_ASYNC_OUT,
|
||||
LOG_STORAGE_TO_FLASH,
|
||||
LOG_SPI_OUT,
|
||||
LOG_BLE_LOG_V2,
|
||||
};
|
||||
|
||||
const static uint32_t log_bufs_size[] = {CONFIG_BT_CTRL_LE_LOG_BUF1_SIZE, CONFIG_BT_CTRL_LE_LOG_HCI_BUF_SIZE, CONFIG_BT_CTRL_LE_LOG_BUF2_SIZE};
|
||||
bool log_is_inited = false;
|
||||
#if CONFIG_BT_CTRL_LE_LOG_MODE_BLE_LOG_V2
|
||||
uint8_t log_output_mode = LOG_BLE_LOG_V2;
|
||||
#else /* !CONFIG_BT_CTRL_LE_LOG_MODE_BLE_LOG_V2 */
|
||||
#if CONFIG_BT_CTRL_LE_LOG_DUMP_ONLY
|
||||
uint8_t log_output_mode = LOG_DUMP_MEMORY;
|
||||
#else
|
||||
@@ -517,6 +525,7 @@ uint8_t log_output_mode = LOG_SPI_OUT;
|
||||
uint8_t log_output_mode = LOG_ASYNC_OUT;
|
||||
#endif // CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||
#endif // CONFIG_BT_CTRL_LE_LOG_DUMP_ONLY
|
||||
#endif /* CONFIG_BT_CTRL_LE_LOG_MODE_BLE_LOG_V2 */
|
||||
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||
static const esp_partition_t *log_partition;
|
||||
static uint32_t write_index = 0;
|
||||
@@ -526,6 +535,17 @@ static bool stop_write = false;
|
||||
static bool is_filled = false;
|
||||
#endif // CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||
|
||||
#if CONFIG_BT_CTRL_LE_LOG_MODE_BLE_LOG_V2
|
||||
static IRAM_ATTR void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, bool end)
|
||||
{
|
||||
ble_log_write_hex_ll(len, addr, 0, NULL, 0);
|
||||
}
|
||||
|
||||
void esp_ble_controller_log_dump_all(bool output)
|
||||
{
|
||||
ble_log_dump_to_console();
|
||||
}
|
||||
#else /* !CONFIG_BT_CTRL_LE_LOG_MODE_BLE_LOG_V2 */
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, bool end)
|
||||
{
|
||||
if (log_output_mode == LOG_STORAGE_TO_FLASH) {
|
||||
@@ -570,6 +590,7 @@ void esp_ble_controller_log_dump_all(bool output)
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BT_CTRL_LE_LOG_MODE_BLE_LOG_V2 */
|
||||
|
||||
void esp_bt_log_output_mode_set(uint8_t output_mode)
|
||||
{
|
||||
@@ -581,6 +602,31 @@ uint8_t esp_bt_log_output_mode_get(void)
|
||||
return log_output_mode;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_CTRL_LE_LOG_MODE_BLE_LOG_V2
|
||||
esp_err_t esp_bt_controller_log_init(uint8_t log_output_mode)
|
||||
{
|
||||
if (log_is_inited) {
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t ret = ESP_OK;
|
||||
uint8_t buffers = 0;
|
||||
|
||||
#if CONFIG_BT_CTRL_LE_LOG_EN
|
||||
buffers |= ESP_BLE_LOG_BUF_CONTROLLER;
|
||||
#endif // CONFIG_BT_CTRL_LE_LOG_EN
|
||||
#if CONFIG_BT_CTRL_LE_HCI_LOG_EN
|
||||
buffers |= ESP_BLE_LOG_BUF_HCI;
|
||||
#endif // CONFIG_BT_CTRL_LE_HCI_LOG_EN
|
||||
|
||||
ret = r_ble_log_init_async(esp_bt_controller_log_interface, true, buffers, (uint32_t *)log_bufs_size);
|
||||
if (ret == ESP_OK) {
|
||||
log_is_inited = true;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#else /* !CONFIG_BT_CTRL_LE_LOG_MODE_BLE_LOG_V2 */
|
||||
esp_err_t esp_bt_controller_log_init(uint8_t log_output_mode)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
@@ -630,8 +676,9 @@ esp_err_t esp_bt_controller_log_init(uint8_t log_output_mode)
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* CONFIG_BT_CTRL_LE_LOG_MODE_BLE_LOG_V2*/
|
||||
|
||||
void esp_bt_ontroller_log_deinit(void)
|
||||
void esp_bt_controller_log_deinit(void)
|
||||
{
|
||||
r_ble_log_deinit_async();
|
||||
log_is_inited = false;
|
||||
@@ -712,7 +759,7 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
esp_panic_handler_feed_wdts();
|
||||
r_ble_log_async_output_dump_all(true);
|
||||
esp_bt_ontroller_log_deinit();
|
||||
esp_bt_controller_log_deinit();
|
||||
stop_write = true;
|
||||
|
||||
buffer = (const uint8_t *)mapped_ptr;
|
||||
@@ -1805,6 +1852,13 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
coex_init();
|
||||
#endif
|
||||
|
||||
#if CONFIG_BLE_LOG_ENABLED
|
||||
if (!ble_log_init()) {
|
||||
ESP_LOGE(BT_LOG_TAG, "BLE Log v2 init failed");
|
||||
err = ESP_ERR_NO_MEM;
|
||||
goto error;
|
||||
}
|
||||
#else /* !CONFIG_BLE_LOG_ENABLED */
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
if (ble_log_spi_out_init() != 0) {
|
||||
ESP_LOGE(BT_LOG_TAG, "BLE Log SPI output init failed");
|
||||
@@ -1812,6 +1866,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
goto error;
|
||||
}
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
#endif /* CONFIG_BLE_LOG_ENABLED */
|
||||
|
||||
periph_module_enable(PERIPH_BT_MODULE);
|
||||
periph_module_reset(PERIPH_BT_MODULE);
|
||||
@@ -1845,9 +1900,13 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
|
||||
error:
|
||||
|
||||
#if CONFIG_BLE_LOG_ENABLED
|
||||
ble_log_deinit();
|
||||
#else /* !CONFIG_BLE_LOG_ENABLED */
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
ble_log_spi_out_deinit();
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
#endif /* CONFIG_BLE_LOG_ENABLED */
|
||||
|
||||
bt_controller_deinit_internal();
|
||||
|
||||
@@ -1860,9 +1919,13 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_LOG_ENABLED
|
||||
ble_log_deinit();
|
||||
#else /* !CONFIG_BLE_LOG_ENABLED */
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
ble_log_spi_out_deinit();
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
#endif /* CONFIG_BLE_LOG_ENABLED */
|
||||
|
||||
#if (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED)
|
||||
scan_stack_enableAdvFlowCtrlVsCmd(false);
|
||||
@@ -1950,7 +2013,7 @@ static void bt_controller_deinit_internal(void)
|
||||
esp_phy_modem_deinit();
|
||||
|
||||
#if CONFIG_BT_CTRL_LE_LOG_EN
|
||||
esp_bt_ontroller_log_deinit();
|
||||
esp_bt_controller_log_deinit();
|
||||
#endif // CONFIG_BT_CTRL_LE_LOG_EN
|
||||
|
||||
if (osi_funcs_p != NULL) {
|
||||
|
@@ -338,6 +338,14 @@ menu "Controller debug features"
|
||||
help
|
||||
Enable controller log
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
|
||||
bool "Utilize BLE Log v2 for controller log"
|
||||
depends on BLE_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
Utilize BLE Log v2 for controller log
|
||||
|
||||
if !BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
|
||||
config BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||
bool "enable controller log module"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
@@ -416,6 +424,7 @@ menu "Controller debug features"
|
||||
default 4096
|
||||
help
|
||||
Configure the size of the BLE HCI LOG buffer.
|
||||
endif
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||
bool "Enable wrap panic handler"
|
||||
|
@@ -63,6 +63,9 @@
|
||||
#include "soc/rtc.h"
|
||||
#include "modem/modem_syscon_struct.h"
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
|
||||
#include "ble_log.h"
|
||||
#else /* !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
#include "ble_log/ble_log_spi_out.h"
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
@@ -70,6 +73,7 @@
|
||||
#if CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
|
||||
#include "ble_log/ble_log_uhci_out.h"
|
||||
#endif // CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
|
||||
#endif /* CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
|
||||
|
||||
/* Macro definition
|
||||
************************************************************************
|
||||
@@ -211,12 +215,14 @@ static int esp_ecc_gen_key_pair(uint8_t *pub, uint8_t *priv);
|
||||
static int esp_ecc_gen_dh_key(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_key_y,
|
||||
const uint8_t *our_priv_key, uint8_t *out_dhkey);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
#if !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
|
||||
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED && !CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag);
|
||||
#endif // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED && !CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
#endif /* !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
/* Local variable definition
|
||||
***************************************************************************
|
||||
@@ -225,9 +231,47 @@ static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void);
|
||||
static DRAM_ATTR esp_bt_controller_status_t ble_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
const static uint32_t log_bufs_size[] = {CONFIG_BT_LE_LOG_CTRL_BUF1_SIZE, CONFIG_BT_LE_LOG_HCI_BUF_SIZE, CONFIG_BT_LE_LOG_CTRL_BUF2_SIZE};
|
||||
static bool log_is_inited = false;
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
|
||||
/* TODO: Remove event handler dependency in lib */
|
||||
static void void_handler(void) {}
|
||||
|
||||
/* TODO: Declare public interfaces in a public header */
|
||||
void esp_bt_controller_log_deinit(void)
|
||||
{
|
||||
log_is_inited = false;
|
||||
r_ble_log_deinit_simple();
|
||||
ble_log_deinit();
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_log_init(void)
|
||||
{
|
||||
if (log_is_inited) {
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if (!ble_log_init()) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (r_ble_log_init_simple(ble_log_write_hex_ll, void_handler) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (r_ble_log_ctrl_level_and_mod(CONFIG_BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL,
|
||||
CONFIG_BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH) != ESP_OK) {
|
||||
goto exit;
|
||||
}
|
||||
log_is_inited = true;
|
||||
return ESP_OK;
|
||||
|
||||
exit:
|
||||
esp_bt_controller_log_deinit();
|
||||
return ESP_FAIL;
|
||||
}
|
||||
#else /* !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
|
||||
const static uint32_t log_bufs_size[] = {CONFIG_BT_LE_LOG_CTRL_BUF1_SIZE, CONFIG_BT_LE_LOG_HCI_BUF_SIZE, CONFIG_BT_LE_LOG_CTRL_BUF2_SIZE};
|
||||
esp_err_t esp_bt_controller_log_init(void)
|
||||
{
|
||||
if (log_is_inited) {
|
||||
@@ -321,6 +365,7 @@ void esp_bt_controller_log_deinit(void)
|
||||
|
||||
log_is_inited = false;
|
||||
}
|
||||
#endif /* CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
#include "esp_partition.h"
|
||||
@@ -1518,6 +1563,12 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po
|
||||
}
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
|
||||
void esp_ble_controller_log_dump_all(bool output)
|
||||
{
|
||||
ble_log_dump_to_console();
|
||||
}
|
||||
#else /* !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
|
||||
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED && !CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag)
|
||||
{
|
||||
@@ -1564,6 +1615,7 @@ void esp_ble_controller_log_dump_all(bool output)
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
#endif
|
||||
}
|
||||
#endif /* CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
|
||||
#if (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
|
@@ -332,6 +332,14 @@ menu "Controller debug features"
|
||||
help
|
||||
Enable controller log
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
|
||||
bool "Utilize BLE Log v2 for controller log"
|
||||
depends on BLE_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
Utilize BLE Log v2 for controller log
|
||||
|
||||
if !BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
|
||||
config BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||
bool "enable controller log module"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
@@ -410,6 +418,7 @@ menu "Controller debug features"
|
||||
default 4096
|
||||
help
|
||||
Configure the size of the BLE HCI LOG buffer.
|
||||
endif
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
|
||||
bool "Enable wrap panic handler"
|
||||
|
@@ -55,6 +55,9 @@
|
||||
#include "esp_sleep.h"
|
||||
#include "soc/rtc.h"
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
|
||||
#include "ble_log.h"
|
||||
#else /* !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
|
||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
#include "ble_log/ble_log_spi_out.h"
|
||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
@@ -62,6 +65,7 @@
|
||||
#if CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
|
||||
#include "ble_log/ble_log_uhci_out.h"
|
||||
#endif // CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
|
||||
#endif /* CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
|
||||
|
||||
/* Macro definition
|
||||
************************************************************************
|
||||
@@ -194,12 +198,14 @@ static int esp_ecc_gen_key_pair(uint8_t *pub, uint8_t *priv);
|
||||
static int esp_ecc_gen_dh_key(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_key_y,
|
||||
const uint8_t *our_priv_key, uint8_t *out_dhkey);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
#if !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
|
||||
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED && !CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag);
|
||||
#endif // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED && !CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
#endif /* !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
/* Local variable definition
|
||||
***************************************************************************
|
||||
@@ -208,9 +214,47 @@ static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void);
|
||||
static DRAM_ATTR esp_bt_controller_status_t ble_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
const static uint32_t log_bufs_size[] = {CONFIG_BT_LE_LOG_CTRL_BUF1_SIZE, CONFIG_BT_LE_LOG_HCI_BUF_SIZE, CONFIG_BT_LE_LOG_CTRL_BUF2_SIZE};
|
||||
static bool log_is_inited = false;
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
|
||||
/* TODO: Remove event handler dependency in lib */
|
||||
static void void_handler(void) {}
|
||||
|
||||
/* TODO: Declare public interfaces in a public header */
|
||||
void esp_bt_controller_log_deinit(void)
|
||||
{
|
||||
log_is_inited = false;
|
||||
r_ble_log_deinit_simple();
|
||||
ble_log_deinit();
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_log_init(void)
|
||||
{
|
||||
if (log_is_inited) {
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if (!ble_log_init()) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (r_ble_log_init_simple(ble_log_write_hex_ll, void_handler) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (r_ble_log_ctrl_level_and_mod(CONFIG_BT_LE_CONTROLLER_LOG_OUTPUT_LEVEL,
|
||||
CONFIG_BT_LE_CONTROLLER_LOG_MOD_OUTPUT_SWITCH) != ESP_OK) {
|
||||
goto exit;
|
||||
}
|
||||
log_is_inited = true;
|
||||
return ESP_OK;
|
||||
|
||||
exit:
|
||||
esp_bt_controller_log_deinit();
|
||||
return ESP_FAIL;
|
||||
}
|
||||
#else /* !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
|
||||
const static uint32_t log_bufs_size[] = {CONFIG_BT_LE_LOG_CTRL_BUF1_SIZE, CONFIG_BT_LE_LOG_HCI_BUF_SIZE, CONFIG_BT_LE_LOG_CTRL_BUF2_SIZE};
|
||||
esp_err_t esp_bt_controller_log_init(void)
|
||||
{
|
||||
if (log_is_inited) {
|
||||
@@ -304,6 +348,7 @@ void esp_bt_controller_log_deinit(void)
|
||||
|
||||
log_is_inited = false;
|
||||
}
|
||||
#endif /* CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
|
||||
#include "esp_partition.h"
|
||||
@@ -1442,6 +1487,12 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po
|
||||
}
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2
|
||||
void esp_ble_controller_log_dump_all(bool output)
|
||||
{
|
||||
ble_log_dump_to_console();
|
||||
}
|
||||
#else /* !CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
|
||||
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED && !CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
|
||||
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag)
|
||||
{
|
||||
@@ -1488,6 +1539,7 @@ void esp_ble_controller_log_dump_all(bool output)
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
#endif
|
||||
}
|
||||
#endif /* CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2 */
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
|
||||
#if (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
|
Reference in New Issue
Block a user