Skip to content

Commit d45778f

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

File tree

2 files changed

+52
-12
lines changed

2 files changed

+52
-12
lines changed

components/bt/controller/esp32h2/Kconfig.in

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

358+
config BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
359+
bool "Output ble controller logs via UART DMA (Experimental)"
360+
depends on BT_LE_CONTROLLER_LOG_ENABLED
361+
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
362+
depends on !BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
363+
select BT_BLE_LOG_UHCI_OUT_ENABLED
364+
default y
365+
help
366+
Output ble controller logs via UART DMA
367+
358368
config BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
359369
bool "Store ble controller logs to flash(Experimental)"
360370
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY

components/bt/controller/esp32h2/bt.c

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
#include "ble_log/ble_log_spi_out.h"
6060
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
6161

62+
#if CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
63+
#include "ble_log/ble_log_uhci_out.h"
64+
#endif // CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
65+
6266
/* Macro definition
6367
************************************************************************
6468
*/
@@ -191,9 +195,9 @@ static int esp_ecc_gen_key_pair(uint8_t *pub, uint8_t *priv);
191195
static int esp_ecc_gen_dh_key(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_key_y,
192196
const uint8_t *our_priv_key, uint8_t *out_dhkey);
193197
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
194-
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
198+
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED && !CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
195199
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);
196-
#endif // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
200+
#endif // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED && !CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
197201
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
198202
static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void);
199203
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
@@ -220,11 +224,21 @@ esp_err_t esp_bt_controller_log_init(void)
220224
}
221225
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
222226

227+
#if CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
228+
if (ble_log_uhci_out_init() != 0) {
229+
goto uhci_out_init_failed;
230+
}
231+
#endif // CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
232+
223233
#if CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
224234
if (r_ble_log_init_simple(ble_log_spi_out_ll_write, ble_log_spi_out_ll_log_ev_proc) != 0) {
225235
goto log_init_failed;
226236
}
227-
#else // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
237+
#elif CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
238+
if (r_ble_log_init_simple(ble_log_uhci_out_ll_write, ble_log_uhci_out_ll_log_ev_proc) != 0) {
239+
goto log_init_failed;
240+
}
241+
#else
228242
uint8_t buffers = 0;
229243
#if CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED
230244
buffers |= ESP_BLE_LOG_BUF_CONTROLLER;
@@ -238,12 +252,12 @@ esp_err_t esp_bt_controller_log_init(void)
238252
task_create = false;
239253
#elif CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
240254
esp_bt_ctrl_log_partition_get_and_erase_first_block();
241-
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
255+
#endif
242256

243257
if (r_ble_log_init_async(esp_bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size) != 0) {
244258
goto log_init_failed;
245259
}
246-
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
260+
#endif
247261

248262
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) {
249263
goto ctrl_level_init_failed;
@@ -254,14 +268,20 @@ esp_err_t esp_bt_controller_log_init(void)
254268
ctrl_level_init_failed:
255269
#if CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
256270
r_ble_log_deinit_simple();
257-
#else // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
271+
#elif CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
272+
r_ble_log_deinit_simple();
273+
#else
258274
r_ble_log_deinit_async();
259-
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
275+
#endif
260276
log_init_failed:
261277
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
262278
ble_log_spi_out_deinit();
263279
spi_out_init_failed:
264280
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
281+
#if CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
282+
ble_log_uhci_out_deinit();
283+
uhci_out_init_failed:
284+
#endif // CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
265285
return ESP_FAIL;
266286
}
267287

@@ -271,11 +291,17 @@ void esp_bt_controller_log_deinit(void)
271291
ble_log_spi_out_deinit();
272292
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
273293

294+
#if CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
295+
ble_log_uhci_out_deinit();
296+
#endif // CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
297+
274298
#if CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
275299
r_ble_log_deinit_simple();
276-
#else // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
300+
#elif CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
301+
r_ble_log_deinit_simple();
302+
#else
277303
r_ble_log_deinit_async();
278-
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
304+
#endif
279305

280306
log_is_inited = false;
281307
}
@@ -1406,7 +1432,7 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po
14061432
}
14071433

14081434
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
1409-
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
1435+
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED && !CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
14101436
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)
14111437
{
14121438
bool end = (flag & BIT(BLE_LOG_INTERFACE_FLAG_END));
@@ -1428,17 +1454,21 @@ static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, u
14281454
portEXIT_CRITICAL_SAFE(&spinlock);
14291455
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
14301456
}
1431-
#endif // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
1457+
#endif // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED && !CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
14321458

14331459
void esp_ble_controller_log_dump_all(bool output)
14341460
{
14351461
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
14361462
ble_log_spi_out_dump_all();
14371463
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
14381464

1465+
#if CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
1466+
ble_log_uhci_out_dump_all();
1467+
#endif // CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED
1468+
14391469
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
14401470
esp_bt_read_ctrl_log_from_flash(output);
1441-
#elif !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
1471+
#elif !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED && !CONFIG_BT_LE_CONTROLLER_LOG_UHCI_OUT_ENABLED
14421472
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
14431473
portENTER_CRITICAL_SAFE(&spinlock);
14441474
esp_panic_handler_feed_wdts();

0 commit comments

Comments
 (0)