mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
Move 6 trace-related examples (app_trace_basic, app_trace_to_plot, esp_trace, gcov, sysview_tracing, sysview_tracing_heap_log) from examples/system/ into a dedicated examples/system/tracing/ subdirectory for better organization. Update all path references across documentation (en + zh_CN), build-test-rules, CI configs and component READMEs. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KZAGzon27T12sGbDPPbZ8G
77 lines
2.4 KiB
C
77 lines
2.4 KiB
C
/*
|
|
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
|
|
*
|
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
|
*/
|
|
#include <stdio.h>
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
#include "driver/gpio.h"
|
|
#include "esp_gcov.h"
|
|
#include "sdkconfig.h"
|
|
#include "esp_log.h"
|
|
|
|
/* Can use project configuration menu (idf.py menuconfig) to choose the GPIO
|
|
to blink, or you can edit the following line and set a number here.
|
|
*/
|
|
#define BLINK_GPIO CONFIG_BLINK_GPIO
|
|
|
|
static const char *TAG = "example";
|
|
|
|
void blink_dummy_func(void);
|
|
void some_dummy_func(void);
|
|
|
|
#if !CONFIG_APPTRACE_DEST_JTAG
|
|
#include "soc/uart_pins.h"
|
|
#include "esp_app_trace.h"
|
|
/* Override default uart 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
|
|
|
|
static void blink_task(void *pvParameter)
|
|
{
|
|
ESP_LOGI(TAG, "Ready for OpenOCD connection");
|
|
|
|
// The first two iterations GCOV data are dumped using call to esp_gcov_dump() and OOCD's "esp32 gcov dump" command.
|
|
// After that they can be dumped using OOCD's "esp32 gcov" command only.
|
|
int dump_gcov_after = -2;
|
|
/* Configure the IOMUX register for pad BLINK_GPIO (some pads are
|
|
muxed to GPIO on reset already, but some default to other
|
|
functions and need to be switched to GPIO. Consult the
|
|
Technical Reference for a list of pads and their default
|
|
functions.)
|
|
*/
|
|
gpio_reset_pin(BLINK_GPIO);
|
|
/* Set the GPIO as a push/pull output */
|
|
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
|
|
|
|
while(1) {
|
|
/* Blink off (output low) */
|
|
gpio_set_level(BLINK_GPIO, 0);
|
|
vTaskDelay(500 / portTICK_PERIOD_MS);
|
|
/* Blink on (output high) */
|
|
gpio_set_level(BLINK_GPIO, 1);
|
|
vTaskDelay(500 / portTICK_PERIOD_MS);
|
|
blink_dummy_func();
|
|
some_dummy_func();
|
|
if (dump_gcov_after++ < 0) {
|
|
// Dump gcov data
|
|
printf("Ready to dump GCOV data...\n");
|
|
esp_gcov_dump();
|
|
printf("GCOV data have been dumped.\n");
|
|
}
|
|
}
|
|
}
|
|
|
|
void app_main(void)
|
|
{
|
|
xTaskCreate(&blink_task, "blink_task", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
|
|
}
|