Apptrace Library | Can't Dump Trace Buffer to Host
Posted: Thu Mar 19, 2026 12:22 pm
For a couple of days I try to get the Apptrace Library to work with my ESP32-S3. However, I still can't read out the trace buffer in post-mortem mode. I want to use the SystemView port for this.
The documentation says, that without the connection of a host, the apptrace module will operate in post-mortem mode. As soon as a host is connected, it will switch into streaming mode.
Here is my sdkconfig:
What I've tried until now:
First of all, I wanted to test if my JTAG connection actually works. I used the streaming mode for this. I ran the newest version of openocd (07-07-2025) with the right target configuration:
After that, I connected over telnet to the openocd server:
From there, I used the following command to start the trace module in streaming mode:
My firmware called the following function cyclically to flush FreeRTOS event data to the host:
This setup actually worked and I got trace data which I could open with SEGGER SystemView. The actual freeRTOS data was alright. However, the tracing slowed down my application significantly and the program often froze. This was due to the reason that in streaming mode the apptrace module will stop writing event data to the trace buffer as soon as it detects that the connected host didn't entirely read the prior data.
For my use case, I just want to flush data to the host when things go wrong or errors occur. This is why I wanted to try if the post-mortem mode works better for me.
I used the following command from openOCD to dump the current trace buffer to the host (for core 0):
With this call, I got the following error thrown:
For this setup, I deleted the "esp_sysview_flush(0)" because I thought that the dump automatically retrieves the trace buffer without needing to manually flush.
Update: flush is not necessary, event data is forwarded to the hardware buffer automatically if enough data got buffered. However, manually flushed small amounts of data (for example one printf) are not recognized by the host on dump.
What could go wrong? Does "esp apptrace dump" only work for actual apptrace events and no sysview events? An alternative like "esp sysview dump" doesn't exist yet.
Update: Dump is only supported for apptrace and not sysview at the moment. Is there an alternative approach to read out sysview data in a post-mortem way?
Feel free to ask for any additional information. Thanks in advance for your help!
The documentation says, that without the connection of a host, the apptrace module will operate in post-mortem mode. As soon as a host is connected, it will switch into streaming mode.
Here is my sdkconfig:
Code: Select all
CONFIG_APPTRACE_ENABLE=y
CONFIG_APPTRACE_DEST_JTAG=y
CONFIG_APPTRACE_TRAX_ENABLE=y
CONFIG_APPTRACE_LOCK_ENABLE=y
CONFIG_APPTRACE_ONPANIC_HOST_FLUSH_TMO=0
CONFIG_APPTRACE_POSTMORTEM_FLUSH_THRESH=0
CONFIG_APPTRACE_SV_ENABLE=y
CONFIG_APPTRACE_SV_TS_SOURCE_ESP_TIMER=y
CONFIG_APPTRACE_SV_MAX_TASKS=16
CONFIG_APPTRACE_SV_BUF_WAIT_TMO=0
CONFIG_APPTRACE_SV_EVT_OVERFLOW_ENABLE=y
CONFIG_APPTRACE_SV_EVT_ISR_ENTER_ENABLE=y
CONFIG_APPTRACE_SV_EVT_ISR_EXIT_ENABLE=y
CONFIG_APPTRACE_SV_EVT_ISR_TO_SCHED_ENABLE=y
CONFIG_APPTRACE_SV_EVT_TASK_START_EXEC_ENABLE=y
CONFIG_APPTRACE_SV_EVT_TASK_STOP_EXEC_ENABLE=y
CONFIG_APPTRACE_SV_EVT_TASK_START_READY_ENABLE=y
CONFIG_APPTRACE_SV_EVT_TASK_STOP_READY_ENABLE=y
CONFIG_APPTRACE_SV_EVT_IDLE_ENABLE=y
First of all, I wanted to test if my JTAG connection actually works. I used the streaming mode for this. I ran the newest version of openocd (07-07-2025) with the right target configuration:
Code: Select all
openocd -f .\esp32s3-builtin.cfg -c "adapter speed 20000"
Code: Select all
telnet localhost 4444
Code: Select all
esp sysview start file://core0.bin file://core1.bin 0 -1 -1
Code: Select all
esp_sysview_flush(0);
For my use case, I just want to flush data to the host when things go wrong or errors occur. This is why I wanted to try if the post-mortem mode works better for me.
I used the following command from openOCD to dump the current trace buffer to the host (for core 0):
Code: Select all
esp apptrace dump file://core0.bin 0
Code: Select all
Info : Total trace memory: 16384 bytes
Info : Open file core.bin
App trace params: from 2 cores, size -1 bytes, stop_tmo -1 s, poll period 0 ms, wait_rst 0, skip 0 bytes
Warn : [esp32s3.cpu0] apptrace connection is lost. Re-connect.
Warn : [esp32s3.cpu1] apptrace connection is lost. Re-connect.
Error: Data timeout!
Error: Failed to poll target for trace data (-4)!
Tracing is STOPPED. Size is 0 of -1 @ nan (nan) KiB/s
Data: blocks incomplete 0, lost bytes: 0
Block read time [1000000000.000000..0.000000] ms
Block proc time [1000000000.000000..0.000000] ms
Update: flush is not necessary, event data is forwarded to the hardware buffer automatically if enough data got buffered. However, manually flushed small amounts of data (for example one printf) are not recognized by the host on dump.
What could go wrong? Does "esp apptrace dump" only work for actual apptrace events and no sysview events? An alternative like "esp sysview dump" doesn't exist yet.
Update: Dump is only supported for apptrace and not sysview at the moment. Is there an alternative approach to read out sysview data in a post-mortem way?
Feel free to ask for any additional information. Thanks in advance for your help!