• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

include/11-Mar-2024-4921

Readme-Streamport.txtD11-Mar-20244.4 KiB9462

trcStreamingPort.cD11-Mar-20242.8 KiB13182

Readme-Streamport.txt

1Tracealyzer Stream Port for STM32 USB CDC (Virtual COM Port)
2Percepio AB
3https://percepio.com
4------------------------------------------------------------
5
6This directory contains a "stream port" for the Tracealyzer recorder library,
7allowing for streaming the trace data over a USB connection. The stream port is defined by a set of macros in
8trcStreamingPort.h, found in the "include" directory, that relies on functions in trcStreamingPort.c.
9
10This particular stream port targets STM32 devices using USB CDC (virtual COM port).
11It was been tested with STM32F767 and STM32L475.
12
13--- Prerequisites ---
14
15- An STM32 device with a USB connector for application use.
16
17- Tracealyzer 4 with a license for FreeRTOS, SafeRTOS or Micrium µC/OS-III.
18
19- STM32CubeIDE or the stand-alone STM32CubeMX configuration tool.
20
21--- Instructions ---
22
231. Follow the general instructions (Section 1) at https://percepio.com/gettingstarted-freertos/
24and verify that Snapshot mode works. The basic integration of the recorder library is the same.
25
262. Open the Device Configuration Tool (STM32CubeMX), e.g. by double-clicking on the .ioc file in your STM32CubeIDE project.
27
282.1. Under "Middleware", enable "USB_DEVICE" and...
29- In "USB_DEVICE Mode and Configuration", set the "Class for FS IP" to "Communication Device Class (Virtual Com Port)".
30- Under Configuration -> Parameter Settings, set the TX and RX buffer sizes to a small value (e.g. 1).
31The default TX and RX buffers are not used by the trace recorder library, so this avoids wasting RAM.
32
332.2. Under "Connectivity", open "USB_OTG_FS" and...
34- In "USB_OTG_FS Mode and Configuration", make sure "Mode" is set to "Device_Only"
35- Under "Configuration", open "NVIC Settings" and make sure "USB OTG FS global interrupt" is enabled.
36
373. Open trcConfig.h and set TRC_CFG_RECORDER_MODE to TRC_RECORDER_MODE_STREAMING.
38
394. Copy trcStreamingPort.c and include/trcStreamingPort.h into your project.
40
415. Make sure you have "vTraceEnable(TRC_INIT);" in main.c (not TRC_START or so).
42This should be placed after the HW setup but before making any RTOS calls.
43
446. Plug in a USB cable to the connector labeled "USB OTG" or similar (i.e. for application use).
45
467. Build the project and start it. Check that your computer finds a new USB device (there should be a notification).
47
488. Check the number of the new COM port, that should have appeared. This is NOT "STLink Virtual COM port".
49
509. Start Tracealyzer and open Recording Settings and select Target Connection: SerialPort.
51You can also access these settings via File -> Settings -> PSF Streaming Settings.
52
5310. Enter the number of the COM port in the "Device" field. The settings (data
54bits, data rate etc.) are irrelevant for USB serial connections and not used.
55
5611. While the target is running, select Record Streaming Trace in Tracealyzer.
57You should now see a live display of the trace, while it is being received.
58Make sure there are no warnings about "Dropped Events" (in that case, see Troubleshooting, below).
59
60Note that you can still debug and use breakpoints while streaming the trace.
61
62--- Further reading ---
63
64- http://percepio.com/2017/02/03/usb-trace-streaming-st-nucleo-f767zi-board
65- http://percepio.com/2016/10/05/rtos-tracing
66- https://percepio.com/2018/10/11/tuning-your-custom-trace-streaming/
67
68--- Troubleshooting ---
69
70A. If you get an error about "multiple definition of SysTick_Handler", open
71FreeRTOSConfig.h (found in Core/Inc) and add this line in the bottom,
72after the definition of xPortSysTickHandler.
73
74#undef xPortSysTickHandler
75
76B. If you get "Missed Events" in the Live Stream window, it is typically because
77your application produces more trace data than can be transferred, so the trace
78buffer overflows.
79You may try the following to start with:
80- Increase TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT and/or TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE in trcStreamingConfig.h
81- Decrease TRC_CFG_CTRL_TASK_DELAY in trcConfig.h
82- Increase TRC_CFG_CTRL_TASK_PRIORITY in trcConfig.h
83
84Also see the "tuning" guide at https://percepio.com/2018/10/11/tuning-your-custom-trace-streaming/
85
86Also note that this USB stream port has a diagnostics option that might come handy.
87Enable USB_PERF_DIAGNOSTICS in trcStreamingPort.h. This will save additional "user events"
88each time a buffer page is transmitted, showing the number of bytes sent and the
89remaining capacity in the trace buffer (if this goes down to zero, data is lost).
90
91#define USB_PERF_DIAGNOSTICS 1
92
93If you need assistence, feel free to contact support@percepio.com.
94