From 015536f35d10b3790ecab1ccf4000b81dec9dd3e Mon Sep 17 00:00:00 2001 From: Erik Tamlin <64702921+eriktamlin@users.noreply.github.com> Date: Thu, 29 Oct 2020 03:43:59 +0100 Subject: [PATCH] Updated to Percepio Tracealyzer Recorder v4.4.0 (#330) * Updated to Tracealyzer Recorder v4.4.0 Added support for FreeRTOS v10.4.1 * Fixed version numbers in USB stream port --- .../Include/aws_secure_sockets.tzext.h | 2 +- .../Include/aws_wifi.tzext.h | 2 +- .../Include/trcExtensions.h | 2 +- .../Include/trcHardwarePort.h | 2 +- .../Include/trcKernelPort.h | 3 +- .../Include/trcPortDefines.h | 2 +- .../FreeRTOS-Plus-Trace/Include/trcRecorder.h | 2 +- .../FreeRTOS-Plus-Trace/config/trcConfig.h | 5 +- .../config/trcSnapshotConfig.h | 2 +- .../config/trcStreamingConfig.h | 2 +- .../AFR_WIFI_LOCAL/include/trcStreamingPort.h | 2 +- .../AFR_WIFI_LOCAL/trcStreamingPort.c | 2 +- .../ARM_ITM/include/trcStreamingPort.h | 2 +- .../streamports/ARM_ITM/trcStreamingPort.c | 2 +- .../File/include/trcStreamingPort.h | 2 +- .../streamports/File/trcStreamingPort.c | 2 +- .../Jlink_RTT/include/trcStreamingPort.h | 2 +- .../streamports/Jlink_RTT/trcStreamingPort.c | 2 +- .../STM32_USB_CDC/Readme-Streamport.txt | 94 ++++++++++ .../STM32_USB_CDC/include/trcStreamingPort.h | 82 +++++++++ .../STM32_USB_CDC/trcStreamingPort.c | 164 ++++++++++++++++++ .../TCPIP/include/trcStreamingPort.h | 2 +- .../streamports/TCPIP/trcStreamingPort.c | 2 +- .../TCPIP_Win32/include/trcStreamingPort.h | 2 +- .../TCPIP_Win32/trcStreamingPort.c | 2 +- .../tracealyzer_readme.txt | 5 + .../FreeRTOS-Plus-Trace/trcKernelPort.c | 2 +- .../FreeRTOS-Plus-Trace/trcSnapshotRecorder.c | 2 +- .../trcStreamingRecorder.c | 2 +- 29 files changed, 373 insertions(+), 26 deletions(-) create mode 100644 FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/STM32_USB_CDC/Readme-Streamport.txt create mode 100644 FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/STM32_USB_CDC/include/trcStreamingPort.h create mode 100644 FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/STM32_USB_CDC/trcStreamingPort.c diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/aws_secure_sockets.tzext.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/aws_secure_sockets.tzext.h index f2ebf74c044..045203adedd 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/aws_secure_sockets.tzext.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/aws_secure_sockets.tzext.h @@ -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 diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/aws_wifi.tzext.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/aws_wifi.tzext.h index 238eacaff87..65d0cd54fef 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/aws_wifi.tzext.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/aws_wifi.tzext.h @@ -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 diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcExtensions.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcExtensions.h index dfcdfcea724..df5f0d8f204 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcExtensions.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcExtensions.h @@ -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 diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcHardwarePort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcHardwarePort.h index e452999eef3..e95170da716 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcHardwarePort.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcHardwarePort.h @@ -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 diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelPort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelPort.h index d877e81c6c4..b44b3597165 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelPort.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelPort.h @@ -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 @@ -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 diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcPortDefines.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcPortDefines.h index 99a2fbf50fe..71447638263 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcPortDefines.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcPortDefines.h @@ -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 diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcRecorder.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcRecorder.h index 3d4f3d635db..3dfbdba76fd 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcRecorder.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcRecorder.h @@ -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 diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/config/trcConfig.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/config/trcConfig.h index fa113949d7f..9ccf57449f9 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/config/trcConfig.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/config/trcConfig.h @@ -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 @@ -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 diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/config/trcSnapshotConfig.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/config/trcSnapshotConfig.h index 601dfda68c4..f585bcba87b 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/config/trcSnapshotConfig.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/config/trcSnapshotConfig.h @@ -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 diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/config/trcStreamingConfig.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/config/trcStreamingConfig.h index 9ad2ce577d1..641244995ae 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/config/trcStreamingConfig.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/config/trcStreamingConfig.h @@ -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 diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/AFR_WIFI_LOCAL/include/trcStreamingPort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/AFR_WIFI_LOCAL/include/trcStreamingPort.h index 4d4322d926d..545f06c7aba 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/AFR_WIFI_LOCAL/include/trcStreamingPort.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/AFR_WIFI_LOCAL/include/trcStreamingPort.h @@ -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 diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/AFR_WIFI_LOCAL/trcStreamingPort.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/AFR_WIFI_LOCAL/trcStreamingPort.c index 1edee04c313..36bfd834094 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/AFR_WIFI_LOCAL/trcStreamingPort.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/AFR_WIFI_LOCAL/trcStreamingPort.c @@ -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 diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/ARM_ITM/include/trcStreamingPort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/ARM_ITM/include/trcStreamingPort.h index c14c4e1f9e2..95fa38836f4 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/ARM_ITM/include/trcStreamingPort.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/ARM_ITM/include/trcStreamingPort.h @@ -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 diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/ARM_ITM/trcStreamingPort.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/ARM_ITM/trcStreamingPort.c index 4b51d7f0e5b..e014eba3d5a 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/ARM_ITM/trcStreamingPort.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/ARM_ITM/trcStreamingPort.c @@ -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 diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/File/include/trcStreamingPort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/File/include/trcStreamingPort.h index 0deb9ad1ccd..6977552c877 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/File/include/trcStreamingPort.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/File/include/trcStreamingPort.h @@ -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 diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/File/trcStreamingPort.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/File/trcStreamingPort.c index 03a5a9a6ff5..ccb95ff1666 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/File/trcStreamingPort.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/File/trcStreamingPort.c @@ -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 diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/include/trcStreamingPort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/include/trcStreamingPort.h index 6ad22d5076c..ca879ca6447 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/include/trcStreamingPort.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/include/trcStreamingPort.h @@ -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 diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/trcStreamingPort.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/trcStreamingPort.c index d4d7ec11801..759987b677d 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/trcStreamingPort.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/Jlink_RTT/trcStreamingPort.c @@ -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 diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/STM32_USB_CDC/Readme-Streamport.txt b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/STM32_USB_CDC/Readme-Streamport.txt new file mode 100644 index 00000000000..7a59e3a2eef --- /dev/null +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/STM32_USB_CDC/Readme-Streamport.txt @@ -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 support@percepio.com. + +Percepio AB +https://percepio.com \ No newline at end of file diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/STM32_USB_CDC/include/trcStreamingPort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/STM32_USB_CDC/include/trcStreamingPort.h new file mode 100644 index 00000000000..52827f43151 --- /dev/null +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/STM32_USB_CDC/include/trcStreamingPort.h @@ -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 */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/STM32_USB_CDC/trcStreamingPort.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/STM32_USB_CDC/trcStreamingPort.c new file mode 100644 index 00000000000..a2ad625e876 --- /dev/null +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/streamports/STM32_USB_CDC/trcStreamingPort.c @@ -0,0 +1,164 @@ +/******************************************************************************* + * Trace Recorder Library for Tracealyzer v4.4.0 + * Percepio AB, www.percepio.com + * + * trcStreamingPort.c + * + * Supporting functions 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 + ******************************************************************************/ + +#include "trcRecorder.h" + +#if (TRC_USE_TRACEALYZER_RECORDER == 1) +#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) + +#include "stdint.h" + +typedef struct{ + uint32_t idx; + uint8_t data[64]; +}recBuf; + +recBuf commandBuffer; + +static int8_t CDC_Receive_FS_modified (uint8_t* pbuf, uint32_t *Len); + +extern USBD_CDC_ItfTypeDef USBD_Interface_fops_FS; + +static int8_t (* CDC_Receive_FS)(uint8_t *Buf, uint32_t *Len); + +static int8_t CDC_Receive_FS_modified (uint8_t* Buf, uint32_t *Len) +{ + for( uint32_t i=0;i<* Len;i++) + { + commandBuffer.data[commandBuffer.idx]=Buf[i]; + commandBuffer.idx++; + } + + CDC_Receive_FS(Buf, Len); + + return (USBD_OK); +} + + +void trcCDCInit(void) +{ + + /* Store the original "Receive" function, from the static initialization */ + CDC_Receive_FS = USBD_Interface_fops_FS.Receive; + + /* Update the function pointer with our modified variant */ + USBD_Interface_fops_FS.Receive = CDC_Receive_FS_modified; + + MX_USB_DEVICE_Init(); +} + +/* The READ function, used in trcStreamingPort.h */ +int32_t trcCDCReceive(void *data, uint32_t size, int32_t* NumBytes) +{ + uint32_t i,diff; + + if(commandBuffer.idx>0) + { + if (size >= commandBuffer.idx) // more than what is stored, number of bytes will be .idx + { + memcpy(data,commandBuffer.data, commandBuffer.idx); + *NumBytes=commandBuffer.idx; + commandBuffer.idx=0; // Make the buffer ready for a new command + } + else //If some data in the buffer is not read + { + diff = commandBuffer.idx-size; + memcpy(data,commandBuffer.data, size); + for(i=0;i v4.4.0 +- Updates to the USB CDC streamport + +------------------------------------------------------------------------------- + Changes, v4.3.10 -> v4.3.11 - Adapted for new Task Notify changes diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernelPort.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernelPort.c index 374e9a6d5f9..f34a8485838 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernelPort.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernelPort.c @@ -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 * * trcKernelPort.c diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcSnapshotRecorder.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcSnapshotRecorder.c index a2513b08a48..ef49f2de768 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcSnapshotRecorder.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcSnapshotRecorder.c @@ -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 * * trcSnapshotRecorder.c diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcStreamingRecorder.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcStreamingRecorder.c index 0ca034b84b4..5526530a2d2 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcStreamingRecorder.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcStreamingRecorder.c @@ -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 * * trcStreamingRecorder.c