Skip to content

Commit

Permalink
Updated to Percepio Tracealyzer Recorder v4.4.0 (FreeRTOS#330)
Browse files Browse the repository at this point in the history
* Updated to Tracealyzer Recorder v4.4.0
Added support for FreeRTOS v10.4.1

* Fixed version numbers in USB stream port
  • Loading branch information
eriktamlin authored Oct 29, 2020
1 parent 832a797 commit 015536f
Show file tree
Hide file tree
Showing 29 changed files with 373 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.2.0
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* aws_secure_socket.tzext.h
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.2.0
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* aws_secure_socket.tzext.h
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.3.11
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcExtensions.h
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.3.11
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcHardwarePort.h
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.3.11
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* Terms of Use
Expand Down Expand Up @@ -73,6 +73,7 @@ extern "C" {
#define TRC_FREERTOS_VERSION_10_3_0 9
#define TRC_FREERTOS_VERSION_10_3_1 TRC_FREERTOS_VERSION_10_3_0
#define TRC_FREERTOS_VERSION_10_4_0 10
#define TRC_FREERTOS_VERSION_10_4_1 TRC_FREERTOS_VERSION_10_4_0

/* Legacy FreeRTOS version codes for backwards compatibility with old trace configurations */
#define TRC_FREERTOS_VERSION_7_3 TRC_FREERTOS_VERSION_7_3_X
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.3.11
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcPortDefines.h
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.3.11
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcRecorder.h
Expand Down
5 changes: 3 additions & 2 deletions FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/config/trcConfig.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.3.11
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcConfig.h
Expand Down Expand Up @@ -121,7 +121,8 @@ extern "C" {
* TRC_FREERTOS_VERSION_10_2_1 If using FreeRTOS v10.2.1
* TRC_FREERTOS_VERSION_10_3_0 If using FreeRTOS v10.3.0
* TRC_FREERTOS_VERSION_10_3_1 If using FreeRTOS v10.3.1
* TRC_FREERTOS_VERSION_10_4_0 If using FreeRTOS v10.4.0 or later
* TRC_FREERTOS_VERSION_10_4_0 If using FreeRTOS v10.4.0
* TRC_FREERTOS_VERSION_10_4_1 If using FreeRTOS v10.4.1 or later
*****************************************************************************/
#define TRC_CFG_FREERTOS_VERSION FREERTOS_VERSION_NOT_SET

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.3.11
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcSnapshotConfig.h
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.3.11
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcStreamingConfig.h
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.3.11
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcStreamingPort.c
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.3.11
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcStreamingPort.c
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.3.11
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcStreamingPort.h
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.3.11
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcStreamingPort.c
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.3.11
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcStreamingPort.h
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.3.11
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcStreamingPort.c
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.3.11
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcStreamingPort.h
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.3.11
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcStreamingPort.c
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
Tracealyzer Stream Port for STM32 USB CDC (Virtual COM Port)
------------------------------------------------------------

This directory contains a "stream port" for the Tracealyzer recorder library,
allowing for streaming the trace data over a USB connection. The stream port is defined by a set of macros in
trcStreamingPort.h, found in the "include" directory, that relies on functions in trcStreamingPort.c.

This particular stream port targets STM32 devices using USB CDC (virtual COM port).
It was been tested with STM32F767 and STM32L475.

--- Prerequisites ---

- An STM32 device with a USB connector for application use.

- Tracealyzer 4 with a license for FreeRTOS, SafeRTOS or Micrium µC/OS-III.

- STM32CubeIDE or the stand-alone STM32CubeMX configuration tool.

--- Instructions ---

1. Follow the general instructions (Section 1) at https://percepio.com/gettingstarted-freertos/
and verify that Snapshot mode works. The basic integration of the recorder library is the same.

2. Open the Device Configuration Tool (STM32CubeMX), e.g. by double-clicking on the .ioc file in your STM32CubeIDE project.

2.1. Under "Middleware", enable "USB_DEVICE" and...
- In "USB_DEVICE Mode and Configuration", set the "Class for FS IP" to "Communication Device Class (Virtual Com Port)".
- Under Configuration -> Parameter Settings, set the TX and RX buffer sizes to a small value (e.g. 1).
The default TX and RX buffers are not used by the trace recorder library, so this avoids wasting RAM.

2.2. Under "Connectivity", open "USB_OTG_FS" and...
- In "USB_OTG_FS Mode and Configuration", make sure "Mode" is set to "Device_Only"
- Under "Configuration", open "NVIC Settings" and make sure "USB OTG FS global interrupt" is enabled.

3. Open trcConfig.h and set TRC_CFG_RECORDER_MODE to TRC_RECORDER_MODE_STREAMING.

4. Copy trcStreamingPort.c and include/trcStreamingPort.h into your project.

5. Make sure you have "vTraceEnable(TRC_INIT);" in main.c (not TRC_START or so).
This should be placed after the HW setup but before making any RTOS calls.

6. Plug in a USB cable to the connector labeled "USB OTG" or similar (i.e. for application use).

7. Build the project and start it. Check that your computer finds a new USB device (there should be a notification).

8. Check the number of the new COM port, that should have appeared. This is NOT "STLink Virtual COM port".

9. Start Tracealyzer and open Recording Settings and select Target Connection: SerialPort.
You can also access these settings via File -> Settings -> PSF Streaming Settings.

10. Enter the number of the COM port in the "Device" field. The settings (data
bits, data rate etc.) are irrelevant for USB serial connections and not used.

11. While the target is running, select Record Streaming Trace in Tracealyzer.
You should now see a live display of the trace, while it is being received.
Make sure there are no warnings about "Dropped Events" (in that case, see Troubleshooting, below).

Note that you can still debug and use breakpoints while streaming the trace.

--- Further reading ---

- http://percepio.com/2017/02/03/usb-trace-streaming-st-nucleo-f767zi-board
- http://percepio.com/2016/10/05/rtos-tracing
- https://percepio.com/2018/10/11/tuning-your-custom-trace-streaming/

--- Troubleshooting ---

A. If you get an error about "multiple definition of SysTick_Handler", open
FreeRTOSConfig.h (found in Core/Inc) and add this line in the bottom,
after the definition of xPortSysTickHandler.

#undef xPortSysTickHandler

B. If you get "Missed Events" in the Live Stream window, it is typically because
your application produces more trace data than can be transferred, so the trace
buffer overflows.
You may try the following to start with:
- Increase TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT and/or TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE in trcStreamingConfig.h
- Decrease TRC_CFG_CTRL_TASK_DELAY in trcConfig.h
- Increase TRC_CFG_CTRL_TASK_PRIORITY in trcConfig.h

Also see the "tuning" guide at https://percepio.com/2018/10/11/tuning-your-custom-trace-streaming/

Also note that this USB stream port has a diagnostics option that might come handy.
Enable USB_PERF_DIAGNOSTICS in trcStreamingPort.h. This will save additional "user events"
each time a buffer page is transmitted, showing the number of bytes sent and the
remaining capacity in the trace buffer (if this goes down to zero, data is lost).

#define USB_PERF_DIAGNOSTICS 1

If you need assistence, feel free to contact [email protected].

Percepio AB
https://percepio.com
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcStreamingPort.h
*
* The interface definitions for trace streaming ("stream ports").
* This "stream port" sets up the recorder to use USB CDC as streaming channel.
* The example is for STM32 using STM32Cube.
*
* Terms of Use
* This file is part of the trace recorder library (RECORDER), which is the
* intellectual property of Percepio AB (PERCEPIO) and provided under a
* license as follows.
* The RECORDER may be used free of charge for the purpose of recording data
* intended for analysis in PERCEPIO products. It may not be used or modified
* for other purposes without explicit permission from PERCEPIO.
* You may distribute the RECORDER in its original source code form, assuming
* this text (terms of use, disclaimer, copyright notice) is unchanged. You are
* allowed to distribute the RECORDER with minor modifications intended for
* configuration or porting of the RECORDER, e.g., to allow using it on a
* specific processor, processor family or with a specific communication
* interface. Any such modifications should be documented directly below
* this comment block.
*
* Disclaimer
* The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty
* as to its use or performance. PERCEPIO does not and cannot warrant the
* performance or results you may obtain by using the RECORDER or documentation.
* PERCEPIO make no warranties, express or implied, as to noninfringement of
* third party rights, merchantability, or fitness for any particular purpose.
* In no event will PERCEPIO, its technology partners, or distributors be liable
* to you for any consequential, incidental or special damages, including any
* lost profits or lost savings, even if a representative of PERCEPIO has been
* advised of the possibility of such damages, or for any claim by any third
* party. Some jurisdictions do not allow the exclusion or limitation of
* incidental, consequential or special damages, or the exclusion of implied
* warranties or limitations on how long an implied warranty may last, so the
* above limitations may not apply to you.
*
* Tabs are used for indent in this file (1 tab = 4 spaces)
*
* Copyright Percepio AB, 2018.
* www.percepio.com
******************************************************************************/

#ifndef TRC_STREAMING_PORT_H
#define TRC_STREAMING_PORT_H

#include "usb_device.h"
#include "usbd_CDC_if.h"

#ifdef __cplusplus
extern "C" {
#endif

/* The time to wait if the USB interface is busy. */
#define TRC_CFG_DELAY_ON_BUSY 3

/* For FreeRTOS. Modify for other RTOSes. */
#define TRC_OS_DELAY(x) vTaskDelay(x)

void trcCDCInit(void);

int32_t trcCDCReceive(void *data, uint32_t size, int32_t* NumBytes);

int32_t trcCDCTransmit(void* data, uint32_t size, int32_t * noOfBytesSent );

#define TRC_STREAM_PORT_INIT() \
trcCDCInit();\
TRC_STREAM_PORT_MALLOC();

#define TRC_STREAM_PORT_READ_DATA(_ptrData, _size, _ptrBytesRead) trcCDCReceive(_ptrData, _size, _ptrBytesRead)

#define TRC_STREAM_PORT_WRITE_DATA(_ptrData, _size, _ptrBytesSent) trcCDCTransmit(_ptrData, _size, _ptrBytesSent)


#ifdef __cplusplus
}
#endif

#endif /* TRC_STREAMING_PORT_H */
Loading

0 comments on commit 015536f

Please sign in to comment.