Skip to content

Commit ae8a7c8

Browse files
author
Zhou Xiao
committed
feat(ble): support ble log uart dma out for ESP32-C6
1 parent 534b43e commit ae8a7c8

File tree

2 files changed

+52
-12
lines changed

2 files changed

+52
-12
lines changed

components/bt/controller/esp32c6/Kconfig.in

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,16 @@ menu "Controller debug features"
361361
help
362362
Output ble controller logs to SPI bus
363363

364+
config BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
365+
bool "Output ble controller logs via UART DMA (Experimental)"
366+
depends on BT_LE_CONTROLLER_LOG_ENABLED
367+
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
368+
depends on !BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
369+
select BT_BLE_LOG_UHCI_OUT_ENABLED
370+
default y
371+
help
372+
Output ble controller logs via UART DMA
373+
364374
config BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
365375
bool "Store ble controller logs to flash(Experimental)"
366376
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY

components/bt/controller/esp32c6/bt.c

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@
6464
#include "ble_log/ble_log_spi_out.h"
6565
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
6666

67+
#if CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
68+
#include "ble_log/ble_log_uhci_out.h"
69+
#endif // CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
70+
6771
/* Macro definition
6872
************************************************************************
6973
*/
@@ -205,9 +209,9 @@ static int esp_ecc_gen_key_pair(uint8_t *pub, uint8_t *priv);
205209
static int esp_ecc_gen_dh_key(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_key_y,
206210
const uint8_t *our_priv_key, uint8_t *out_dhkey);
207211
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
208-
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
212+
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED && !CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
209213
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);
210-
#endif // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
214+
#endif // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED && !CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
211215
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
212216
static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void);
213217
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
@@ -234,11 +238,21 @@ esp_err_t esp_bt_controller_log_init(void)
234238
}
235239
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
236240

241+
#if CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
242+
if (ble_log_uhci_out_init() != 0) {
243+
goto uhci_out_init_failed;
244+
}
245+
#endif // CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
246+
237247
#if CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
238248
if (r_ble_log_init_simple(ble_log_spi_out_ll_write, ble_log_spi_out_ll_log_ev_proc) != 0) {
239249
goto log_init_failed;
240250
}
241-
#else // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
251+
#elif CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
252+
if (r_ble_log_init_simple(ble_log_uhci_out_ll_write, ble_log_uhci_out_ll_log_ev_proc) != 0) {
253+
goto log_init_failed;
254+
}
255+
#else
242256
uint8_t buffers = 0;
243257
#if CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED
244258
buffers |= ESP_BLE_LOG_BUF_CONTROLLER;
@@ -252,12 +266,12 @@ esp_err_t esp_bt_controller_log_init(void)
252266
task_create = false;
253267
#elif CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
254268
esp_bt_ctrl_log_partition_get_and_erase_first_block();
255-
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
269+
#endif
256270

257271
if (r_ble_log_init_async(esp_bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size) != 0) {
258272
goto log_init_failed;
259273
}
260-
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
274+
#endif
261275

262276
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) {
263277
goto ctrl_level_init_failed;
@@ -268,14 +282,20 @@ esp_err_t esp_bt_controller_log_init(void)
268282
ctrl_level_init_failed:
269283
#if CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
270284
r_ble_log_deinit_simple();
271-
#else // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
285+
#elif CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
286+
r_ble_log_deinit_simple();
287+
#else
272288
r_ble_log_deinit_async();
273-
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
289+
#endif
274290
log_init_failed:
275291
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
276292
ble_log_spi_out_deinit();
277293
spi_out_init_failed:
278294
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
295+
#if CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
296+
ble_log_uhci_out_deinit();
297+
uhci_out_init_failed:
298+
#endif // CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
279299
return ESP_FAIL;
280300
}
281301

@@ -285,11 +305,17 @@ void esp_bt_controller_log_deinit(void)
285305
ble_log_spi_out_deinit();
286306
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
287307

308+
#if CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
309+
ble_log_uhci_out_deinit();
310+
#endif // CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
311+
288312
#if CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
289313
r_ble_log_deinit_simple();
290-
#else // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
314+
#elif CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
315+
r_ble_log_deinit_simple();
316+
#else
291317
r_ble_log_deinit_async();
292-
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
318+
#endif
293319

294320
log_is_inited = false;
295321
}
@@ -1483,7 +1509,7 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po
14831509
}
14841510

14851511
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
1486-
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
1512+
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED && !CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
14871513
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)
14881514
{
14891515
bool end = (flag & BIT(BLE_LOG_INTERFACE_FLAG_END));
@@ -1505,17 +1531,21 @@ static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, u
15051531
portEXIT_CRITICAL_SAFE(&spinlock);
15061532
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
15071533
}
1508-
#endif // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
1534+
#endif // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED && !CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
15091535

15101536
void esp_ble_controller_log_dump_all(bool output)
15111537
{
15121538
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
15131539
ble_log_spi_out_dump_all();
15141540
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
15151541

1542+
#if CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
1543+
ble_log_uhci_out_dump_all();
1544+
#endif // CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
1545+
15161546
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
15171547
esp_bt_read_ctrl_log_from_flash(output);
1518-
#elif !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
1548+
#elif !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED && !CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
15191549
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
15201550
portENTER_CRITICAL_SAFE(&spinlock);
15211551
esp_panic_handler_feed_wdts();

0 commit comments

Comments
 (0)