mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-03 02:20:57 +02:00
feat(ble): supported ble log v2 for ESP32-C3/ESP32-S3
This commit is contained in:
@@ -567,11 +567,14 @@ menu "Controller debug log Options (Experimental)"
|
|||||||
bool "Enable BLE debug log"
|
bool "Enable BLE debug log"
|
||||||
default n
|
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
|
depends on BT_CTRL_LE_LOG_EN
|
||||||
bool "Enable BLE HCI log"
|
default y
|
||||||
default n
|
help
|
||||||
|
Utilize BLE Log v2 for controller log
|
||||||
|
|
||||||
|
if !BT_CTRL_LE_LOG_MODE_BLE_LOG_V2
|
||||||
config BT_CTRL_LE_LOG_DUMP_ONLY
|
config BT_CTRL_LE_LOG_DUMP_ONLY
|
||||||
depends on BT_CTRL_LE_LOG_EN
|
depends on BT_CTRL_LE_LOG_EN
|
||||||
bool "Enable BLE log dump only"
|
bool "Enable BLE log dump only"
|
||||||
@@ -601,6 +604,12 @@ menu "Controller debug log Options (Experimental)"
|
|||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
Output ble controller logs to SPI bus
|
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
|
config BT_CTRL_LE_LOG_MODE_EN
|
||||||
depends on BT_CTRL_LE_LOG_EN
|
depends on BT_CTRL_LE_LOG_EN
|
||||||
|
@@ -49,9 +49,13 @@
|
|||||||
#else //CONFIG_IDF_TARGET_ESP32S3
|
#else //CONFIG_IDF_TARGET_ESP32S3
|
||||||
#include "esp32s3/rom/rom_layout.h"
|
#include "esp32s3/rom/rom_layout.h"
|
||||||
#endif
|
#endif
|
||||||
|
#if CONFIG_BLE_LOG_ENABLED
|
||||||
|
#include "ble_log.h"
|
||||||
|
#else /* !CONFIG_BLE_LOG_ENABLED */
|
||||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||||
#include "ble_log/ble_log_spi_out.h"
|
#include "ble_log/ble_log_spi_out.h"
|
||||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||||
|
#endif /* CONFIG_BLE_LOG_ENABLED */
|
||||||
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||||
#include "esp_partition.h"
|
#include "esp_partition.h"
|
||||||
#include "hal/wdt_hal.h"
|
#include "hal/wdt_hal.h"
|
||||||
@@ -502,10 +506,14 @@ enum log_out_mode {
|
|||||||
LOG_ASYNC_OUT,
|
LOG_ASYNC_OUT,
|
||||||
LOG_STORAGE_TO_FLASH,
|
LOG_STORAGE_TO_FLASH,
|
||||||
LOG_SPI_OUT,
|
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};
|
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;
|
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
|
#if CONFIG_BT_CTRL_LE_LOG_DUMP_ONLY
|
||||||
uint8_t log_output_mode = LOG_DUMP_MEMORY;
|
uint8_t log_output_mode = LOG_DUMP_MEMORY;
|
||||||
#else
|
#else
|
||||||
@@ -517,6 +525,7 @@ uint8_t log_output_mode = LOG_SPI_OUT;
|
|||||||
uint8_t log_output_mode = LOG_ASYNC_OUT;
|
uint8_t log_output_mode = LOG_ASYNC_OUT;
|
||||||
#endif // CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
#endif // CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||||
#endif // CONFIG_BT_CTRL_LE_LOG_DUMP_ONLY
|
#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
|
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
||||||
static const esp_partition_t *log_partition;
|
static const esp_partition_t *log_partition;
|
||||||
static uint32_t write_index = 0;
|
static uint32_t write_index = 0;
|
||||||
@@ -526,6 +535,17 @@ static bool stop_write = false;
|
|||||||
static bool is_filled = false;
|
static bool is_filled = false;
|
||||||
#endif // CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
|
#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)
|
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, bool end)
|
||||||
{
|
{
|
||||||
if (log_output_mode == LOG_STORAGE_TO_FLASH) {
|
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);
|
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)
|
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;
|
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 esp_bt_controller_log_init(uint8_t log_output_mode)
|
||||||
{
|
{
|
||||||
esp_err_t ret = ESP_OK;
|
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;
|
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();
|
r_ble_log_deinit_async();
|
||||||
log_is_inited = false;
|
log_is_inited = false;
|
||||||
@@ -712,7 +759,7 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
|
|||||||
portENTER_CRITICAL_SAFE(&spinlock);
|
portENTER_CRITICAL_SAFE(&spinlock);
|
||||||
esp_panic_handler_feed_wdts();
|
esp_panic_handler_feed_wdts();
|
||||||
r_ble_log_async_output_dump_all(true);
|
r_ble_log_async_output_dump_all(true);
|
||||||
esp_bt_ontroller_log_deinit();
|
esp_bt_controller_log_deinit();
|
||||||
stop_write = true;
|
stop_write = true;
|
||||||
|
|
||||||
buffer = (const uint8_t *)mapped_ptr;
|
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();
|
coex_init();
|
||||||
#endif
|
#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 CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||||
if (ble_log_spi_out_init() != 0) {
|
if (ble_log_spi_out_init() != 0) {
|
||||||
ESP_LOGE(BT_LOG_TAG, "BLE Log SPI output init failed");
|
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;
|
goto error;
|
||||||
}
|
}
|
||||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||||
|
#endif /* CONFIG_BLE_LOG_ENABLED */
|
||||||
|
|
||||||
periph_module_enable(PERIPH_BT_MODULE);
|
periph_module_enable(PERIPH_BT_MODULE);
|
||||||
periph_module_reset(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:
|
error:
|
||||||
|
|
||||||
|
#if CONFIG_BLE_LOG_ENABLED
|
||||||
|
ble_log_deinit();
|
||||||
|
#else /* !CONFIG_BLE_LOG_ENABLED */
|
||||||
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||||
ble_log_spi_out_deinit();
|
ble_log_spi_out_deinit();
|
||||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||||
|
#endif /* CONFIG_BLE_LOG_ENABLED */
|
||||||
|
|
||||||
bt_controller_deinit_internal();
|
bt_controller_deinit_internal();
|
||||||
|
|
||||||
@@ -1860,9 +1919,13 @@ esp_err_t esp_bt_controller_deinit(void)
|
|||||||
return ESP_ERR_INVALID_STATE;
|
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
|
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||||
ble_log_spi_out_deinit();
|
ble_log_spi_out_deinit();
|
||||||
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
|
||||||
|
#endif /* CONFIG_BLE_LOG_ENABLED */
|
||||||
|
|
||||||
#if (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED)
|
#if (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED)
|
||||||
scan_stack_enableAdvFlowCtrlVsCmd(false);
|
scan_stack_enableAdvFlowCtrlVsCmd(false);
|
||||||
@@ -1950,7 +2013,7 @@ static void bt_controller_deinit_internal(void)
|
|||||||
esp_phy_modem_deinit();
|
esp_phy_modem_deinit();
|
||||||
|
|
||||||
#if CONFIG_BT_CTRL_LE_LOG_EN
|
#if CONFIG_BT_CTRL_LE_LOG_EN
|
||||||
esp_bt_ontroller_log_deinit();
|
esp_bt_controller_log_deinit();
|
||||||
#endif // CONFIG_BT_CTRL_LE_LOG_EN
|
#endif // CONFIG_BT_CTRL_LE_LOG_EN
|
||||||
|
|
||||||
if (osi_funcs_p != NULL) {
|
if (osi_funcs_p != NULL) {
|
||||||
|
Reference in New Issue
Block a user