change(app_trace): breaking changes related to destination selection

- Destination selection is unified for SystemView and app_trace
- Destination param is removed from app_trace APIs
- Destinaiton and related configuration now can be override from users
  with a callback from system_init_fn
This commit is contained in:
Erhan Kurubas
2025-08-28 11:33:35 +03:00
committed by BOT
parent 68764bf80f
commit 2ef718fc29
47 changed files with 1318 additions and 936 deletions

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@@ -17,16 +17,34 @@
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_app_trace.h"
#include "soc/uart_pins.h"
#include "esp_log.h"
static const char *TAG = "example";
#if !CONFIG_APPTRACE_DEST_JTAG
/* Override default config to use console pins as a uart channel */
esp_apptrace_config_t esp_apptrace_get_user_params(void)
{
esp_apptrace_config_t config = APPTRACE_UART_CONFIG_DEFAULT();
config.dest_cfg.uart.uart_num = 0;
config.dest_cfg.uart.tx_pin_num = U0TXD_GPIO_NUM;
config.dest_cfg.uart.rx_pin_num = U0RXD_GPIO_NUM;
return config;
}
#endif
void app_main(void)
{
ESP_LOGI(TAG, "Waiting for OpenOCD connection");
if (esp_apptrace_get_destination() == ESP_APPTRACE_DEST_JTAG) {
ESP_LOGI(TAG, "Waiting for OpenOCD connection");
while (!esp_apptrace_host_is_connected(ESP_APPTRACE_DEST_JTAG)) {
vTaskDelay(1);
while (!esp_apptrace_host_is_connected()) {
vTaskDelay(1);
}
} else { // UART
// Before sending data, wait for the UART host to be ready
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
ESP_LOGI(TAG, "Sending example data to the host...");
@@ -34,11 +52,11 @@ void app_main(void)
for (unsigned int cnt = 1; cnt < 51; ++cnt) {
char buf[32] = {0};
snprintf(buf, sizeof(buf), "Apptrace test data[%d]:%d\n", cnt, cnt * cnt);
esp_err_t res = esp_apptrace_write(ESP_APPTRACE_DEST_JTAG, buf, strlen(buf), ESP_APPTRACE_TMO_INFINITE);
esp_err_t res = esp_apptrace_write(buf, strlen(buf), ESP_APPTRACE_TMO_INFINITE);
if (res != ESP_OK) {
ESP_LOGE(TAG, "Failed to write data to host [0x%x] (%s)", res, esp_err_to_name(res));
}
esp_apptrace_flush(ESP_APPTRACE_DEST_JTAG, 1000);
esp_apptrace_flush(1000);
vTaskDelay(50 / portTICK_PERIOD_MS);
}