mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-02 18:10:57 +02:00
feat(ble): supported ble log v2 for ESP32-C3/ESP32-S3
This commit is contained in:
@@ -567,41 +567,50 @@ menu "Controller debug log Options (Experimental)"
|
||||
bool "Enable BLE debug log"
|
||||
default n
|
||||
|
||||
config BT_CTRL_LE_LOG_MODE_BLE_LOG_V2
|
||||
bool "Utilize BLE Log v2 for controller log"
|
||||
depends on BT_CTRL_LE_LOG_EN
|
||||
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"
|
||||
default n
|
||||
|
||||
config BT_CTRL_LE_LOG_STORAGE_EN
|
||||
depends on BT_CTRL_LE_LOG_EN
|
||||
bool "Enable BLE log storage to flash"
|
||||
default n
|
||||
|
||||
config BT_CTRL_LE_LOG_PARTITION_SIZE
|
||||
int "The size of ble controller log partition(Multiples of 4K)"
|
||||
depends on BT_CTRL_LE_LOG_STORAGE_EN
|
||||
default 65536
|
||||
help
|
||||
The size of ble controller log partition shall be a multiples of 4K.
|
||||
The name of log partition shall be "bt_ctrl_log".
|
||||
The partition type shall be ESP_PARTITION_TYPE_DATA.
|
||||
The partition sub_type shall be ESP_PARTITION_SUBTYPE_ANY.
|
||||
|
||||
config BT_CTRL_LE_LOG_SPI_OUT_EN
|
||||
bool "Output ble controller logs to SPI bus"
|
||||
depends on BT_CTRL_LE_LOG_EN
|
||||
depends on !BT_CTRL_LE_LOG_DUMP_ONLY
|
||||
select BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
select BT_BLE_LOG_SPI_OUT_LL_ENABLED
|
||||
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_DUMP_ONLY
|
||||
depends on BT_CTRL_LE_LOG_EN
|
||||
bool "Enable BLE log dump only"
|
||||
default n
|
||||
|
||||
config BT_CTRL_LE_LOG_STORAGE_EN
|
||||
depends on BT_CTRL_LE_LOG_EN
|
||||
bool "Enable BLE log storage to flash"
|
||||
default n
|
||||
|
||||
config BT_CTRL_LE_LOG_PARTITION_SIZE
|
||||
int "The size of ble controller log partition(Multiples of 4K)"
|
||||
depends on BT_CTRL_LE_LOG_STORAGE_EN
|
||||
default 65536
|
||||
help
|
||||
The size of ble controller log partition shall be a multiples of 4K.
|
||||
The name of log partition shall be "bt_ctrl_log".
|
||||
The partition type shall be ESP_PARTITION_TYPE_DATA.
|
||||
The partition sub_type shall be ESP_PARTITION_SUBTYPE_ANY.
|
||||
|
||||
config BT_CTRL_LE_LOG_SPI_OUT_EN
|
||||
bool "Output ble controller logs to SPI bus"
|
||||
depends on BT_CTRL_LE_LOG_EN
|
||||
depends on !BT_CTRL_LE_LOG_DUMP_ONLY
|
||||
select BT_BLE_LOG_SPI_OUT_ENABLED
|
||||
select BT_BLE_LOG_SPI_OUT_LL_ENABLED
|
||||
default n
|
||||
help
|
||||
Output ble controller logs to SPI bus
|
||||
|
||||
config BT_CTRL_LE_LOG_MODE_EN
|
||||
depends on BT_CTRL_LE_LOG_EN
|
||||
int "Enable log for specified BLE mode"
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user