Updates FreeRTOS-Plus-Trace to a submodule pointer (#1082)

This PR updates FreeRTOS-Plus-Trace to a submodule pointer and
updates the relevant project files.  Percepio recommends to use
streaming to ring buffer on a 64-bit system instead of snapshot
and therefore, POSIX demo is updated to use streaming to ring
buffer.
pull/1101/head
Anubhav Rawal 1 year ago committed by GitHub
parent d3575643b8
commit ddb6e58d0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -311,6 +311,7 @@ FREERTOS_IGNORED_PATTERNS = [
r'FreeRTOS/Demo/CORTEX_A5_SAMA5D2x_Xplained_IAR/AtmelFiles/drivers/misc/.*', r'FreeRTOS/Demo/CORTEX_A5_SAMA5D2x_Xplained_IAR/AtmelFiles/drivers/misc/.*',
r'FreeRTOS/Demo/CORTEX_ATSAM3X_Atmel_Studio/src/.*', r'FreeRTOS/Demo/CORTEX_ATSAM3X_Atmel_Studio/src/.*',
r'FreeRTOS-Plus/Demo/FreeRTOS_Plus_CLI_with_Trace_Windows_Simulator/Trace_Recorder_Configuration/.*', r'FreeRTOS-Plus/Demo/FreeRTOS_Plus_CLI_with_Trace_Windows_Simulator/Trace_Recorder_Configuration/.*',
r'FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Posix/Trace_Recorder_Configuration/.*',
r'FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_IPv6_Demo/common/WinPCap/.*', r'FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_IPv6_Demo/common/WinPCap/.*',
r'FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_IPv6_Demo/common/WinPCap/pcap/.*', r'FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_IPv6_Demo/common/WinPCap/pcap/.*',
r'FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_IPv6_Demo/IPv6_Multi_WinSim_demo/FreeRTOS_Plus_TCP_IPv6_Multi.props', r'FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_IPv6_Demo/IPv6_Multi_WinSim_demo/FreeRTOS_Plus_TCP_IPv6_Multi.props',

@ -24,16 +24,18 @@ jobs:
stepName: Checkout Repository stepName: Checkout Repository
name: ${{ env.stepName }} name: ${{ env.stepName }}
uses: actions/checkout@v3 uses: actions/checkout@v3
- env: - env:
stepName: Fetch Kernel Submodule stepName: Fetch Required Submodule
name: ${{ env.stepName }} name: ${{ env.stepName }}
shell: bash shell: bash
run: | run: |
# ${{ env.stepName }} # ${{ env.stepName }}
echo -e "::group::${{ env.stepName }}" echo -e "::group::${{ env.stepName }}"
set +e set +e
git submodule update --checkout --init --depth 1 FreeRTOS/Source git submodule update --checkout --init --depth 1 \
FreeRTOS/Source \
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace
exitStatus=$? exitStatus=$?
set -e set -e
echo -e "::endgroup::" echo -e "::endgroup::"
@ -153,13 +155,15 @@ jobs:
uses: actions/checkout@v3 uses: actions/checkout@v3
- env: - env:
stepName: Fetch Kernel Submodule stepName: Fetch Required Submodule
name: ${{ env.stepName }} name: ${{ env.stepName }}
shell: bash shell: bash
run: | run: |
# ${{ env.stepName }} # ${{ env.stepName }}
echo -e "::group::${{ env.stepName }}" echo -e "::group::${{ env.stepName }}"
git submodule update --checkout --init --depth 1 FreeRTOS/Source git submodule update --checkout --init --depth 1 \
FreeRTOS/Source \
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace
echo -e "::endgroup::" echo -e "::endgroup::"
echo -e "${{ env.bashPass }} ${{env.stepName}} ${{ env.bashEnd }}" echo -e "${{ env.bashPass }} ${{env.stepName}} ${{ env.bashEnd }}"
@ -238,14 +242,16 @@ jobs:
uses: actions/checkout@v3 uses: actions/checkout@v3
- env: - env:
stepName: Fetch Kernel Submodule stepName: Fetch Required Submodule
name: ${{ env.stepName }} name: ${{ env.stepName }}
shell: bash shell: bash
run: | run: |
# ${{ env.stepName }} # ${{ env.stepName }}
echo -e "::group::${{ env.stepName }}" echo -e "::group::${{ env.stepName }}"
set +e set +e
git submodule update --checkout --init --depth 1 FreeRTOS/Source git submodule update --checkout --init --depth 1 \
FreeRTOS/Source \
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace
set -e set -e
exitStatus=$? exitStatus=$?
set -e set -e

@ -1036,7 +1036,8 @@ jobs:
echo -e "::group::${{ env.stepName }}" echo -e "::group::${{ env.stepName }}"
git submodule update --checkout --init --depth 1 \ git submodule update --checkout --init --depth 1 \
FreeRTOS/Source \ FreeRTOS/Source \
FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP \
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace
echo "::endgroup::" echo "::endgroup::"
echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }} " echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }} "
@ -1301,6 +1302,7 @@ jobs:
FreeRTOS-Plus/Source/Application-Protocols/coreMQTT-Agent \ FreeRTOS-Plus/Source/Application-Protocols/coreMQTT-Agent \
FreeRTOS-Plus/Source/Application-Protocols/coreSNTP \ FreeRTOS-Plus/Source/Application-Protocols/coreSNTP \
FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP \ FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP \
FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace \
FreeRTOS-Plus/Source/Utilities/backoff_algorithm \ FreeRTOS-Plus/Source/Utilities/backoff_algorithm \
FreeRTOS-Plus/Source/coreJSON \ FreeRTOS-Plus/Source/coreJSON \
FreeRTOS-Plus/Source/corePKCS11 \ FreeRTOS-Plus/Source/corePKCS11 \

3
.gitmodules vendored

@ -82,3 +82,6 @@
[submodule "FreeRTOS-Plus/Source/FreeRTOS-Cellular-Modules/sara-r4"] [submodule "FreeRTOS-Plus/Source/FreeRTOS-Cellular-Modules/sara-r4"]
path = FreeRTOS-Plus/Source/FreeRTOS-Cellular-Modules/sara-r4 path = FreeRTOS-Plus/Source/FreeRTOS-Cellular-Modules/sara-r4
url = https://github.com/FreeRTOS/Lab-FreeRTOS-Cellular-Interface-Reference-ublox-SARA-R4.git url = https://github.com/FreeRTOS/Lab-FreeRTOS-Cellular-Interface-Reference-ublox-SARA-R4.git
[submodule "FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace"]
path = FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace
url = https://github.com/percepio/TraceRecorderSource.git

@ -88,7 +88,7 @@
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\Source\FreeRTOS-Plus-CLI;.\Trace_Recorder_Configuration;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\..\Source\FreeRTOS-Plus-Trace\include;..\..\Source\FreeRTOS-Plus-CLI;.\Trace_Recorder_Configuration;..\..\Source\FreeRTOS-Plus-Trace\kernelports\FreeRTOS;..\..\Source\FreeRTOS-Plus-Trace\kernelports\FreeRTOS\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
@ -103,7 +103,7 @@
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_WINSOCKAPI_;WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_WINSOCKAPI_;WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\Source\FreeRTOS-Plus-CLI;.\Trace_Recorder_Configuration;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\..\Source\FreeRTOS-Plus-Trace\include;..\..\Source\FreeRTOS-Plus-CLI;.\Trace_Recorder_Configuration;..\..\Source\FreeRTOS-Plus-Trace\kernelports\FreeRTOS\include;..\..\Source\FreeRTOS-Plus-Trace\kernelports\FreeRTOS\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
@ -118,7 +118,7 @@
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\Source\FreeRTOS-Plus-CLI;.\Trace_Recorder_Configuration;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\..\Source\FreeRTOS-Plus-Trace\kernelports\FreeRTOS\include;..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\Source\FreeRTOS-Plus-CLI;.\Trace_Recorder_Configuration;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
@ -155,7 +155,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\Source\FreeRTOS-Plus-CLI\FreeRTOS_CLI.c" /> <ClCompile Include="..\..\Source\FreeRTOS-Plus-CLI\FreeRTOS_CLI.c" />
<ClCompile Include="..\..\Source\FreeRTOS-Plus-Trace\trcKernelPort.c" /> <ClCompile Include="..\..\Source\FreeRTOS-Plus-Trace\kernelPorts\FreeRTOS\trcKernelPort.c" />
<ClCompile Include="..\..\Source\FreeRTOS-Plus-Trace\trcSnapshotRecorder.c" /> <ClCompile Include="..\..\Source\FreeRTOS-Plus-Trace\trcSnapshotRecorder.c" />
<ClCompile Include="..\..\Source\FreeRTOS-Plus-Trace\trcStreamingRecorder.c" /> <ClCompile Include="..\..\Source\FreeRTOS-Plus-Trace\trcStreamingRecorder.c" />
<ClCompile Include="CLI-commands.c" /> <ClCompile Include="CLI-commands.c" />

@ -36,7 +36,7 @@
<ClCompile Include="UDPCommandServer.c"> <ClCompile Include="UDPCommandServer.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\Source\FreeRTOS-Plus-Trace\trcKernelPort.c"> <ClCompile Include="..\..\Source\FreeRTOS-Plus-Trace\kernelPorts\FreeRTOS\trcKernelPort.c">
<Filter>FreeRTOS+Trace</Filter> <Filter>FreeRTOS+Trace</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\Source\FreeRTOS-Plus-Trace\trcSnapshotRecorder.c"> <ClCompile Include="..\..\Source\FreeRTOS-Plus-Trace\trcSnapshotRecorder.c">

@ -22,10 +22,10 @@ INCLUDE_DIRS += -I${FREERTOS_DIR}/Demo/Common/include
INCLUDE_DIRS += -I${FREERTOS_PLUS_TCP_DIR}/portable/NetworkInterface/linux/ INCLUDE_DIRS += -I${FREERTOS_PLUS_TCP_DIR}/portable/NetworkInterface/linux/
INCLUDE_DIRS += -I${FREERTOS_PLUS_TCP_DIR}/include/ INCLUDE_DIRS += -I${FREERTOS_PLUS_TCP_DIR}/include/
INCLUDE_DIRS += -I${FREERTOS_PLUS_TCP_DIR}/portable/Compiler/GCC/ INCLUDE_DIRS += -I${FREERTOS_PLUS_TCP_DIR}/portable/Compiler/GCC/
INCLUDE_DIRS += -I${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/Include INCLUDE_DIRS += -I${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/include
INCLUDE_DIRS += -I${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/config INCLUDE_DIRS += -I${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/kernelports/FreeRTOS/include
INCLUDE_DIRS += -I${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/streamports/File/include INCLUDE_DIRS += -I${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/streamports/RingBuffer/include
INCLUDE_DIRS += -I${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/streamports/File/config
# FreeRTOS Kernel source files # FreeRTOS Kernel source files
SOURCE_FILES := SOURCE_FILES :=
@ -81,7 +81,8 @@ ifeq ($(COVERAGE_TEST),1)
else else
CPPFLAGS += -DprojCOVERAGE_TEST=0 CPPFLAGS += -DprojCOVERAGE_TEST=0
# Trace library. # Trace library.
SOURCE_FILES += ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/trcKernelPort.c SOURCE_FILES += ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/kernelports/FreeRTOS/trcKernelPort.c
SOURCE_FILES += ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/streamports/RingBuffer/trcStreamPort.c
SOURCE_FILES += $(wildcard ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/*.c ) SOURCE_FILES += $(wildcard ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/*.c )
endif endif

@ -1,6 +1,6 @@
/* /*
* Trace Recorder for Tracealyzer v4.6.0 * Trace Recorder for Tracealyzer v4.8.1
* Copyright 2021 Percepio AB * Copyright 2023 Percepio AB
* www.percepio.com * www.percepio.com
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
@ -30,7 +30,7 @@
* TRC_RECORDER_MODE_SNAPSHOT * TRC_RECORDER_MODE_SNAPSHOT
* TRC_RECORDER_MODE_STREAMING * TRC_RECORDER_MODE_STREAMING
*/ */
#define TRC_CFG_RECORDER_MODE TRC_RECORDER_MODE_SNAPSHOT #define TRC_CFG_RECORDER_MODE TRC_RECORDER_MODE_STREAMING
/** /**
* @def TRC_CFG_FREERTOS_VERSION * @def TRC_CFG_FREERTOS_VERSION
@ -54,9 +54,13 @@
* TRC_FREERTOS_VERSION_10_3_0 If using FreeRTOS v10.3.0 * 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_3_1 If using FreeRTOS v10.3.1
* TRC_FREERTOS_VERSION_10_4_0 If using FreeRTOS v10.4.0 * 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 * TRC_FREERTOS_VERSION_10_4_1 If using FreeRTOS v10.4.1
* TRC_FREERTOS_VERSION_10_4_2 If using FreeRTOS v10.4.2
* TRC_FREERTOS_VERSION_10_4_3 If using FreeRTOS v10.4.3
* TRC_FREERTOS_VERSION_10_5_0 If using FreeRTOS v10.5.0
* TRC_FREERTOS_VERSION_10_5_1 If using FreeRTOS v10.5.1 or later
*/ */
#define TRC_CFG_FREERTOS_VERSION TRC_FREERTOS_VERSION_10_4_1 #define TRC_CFG_FREERTOS_VERSION TRC_FREERTOS_VERSION_10_5_1
/** /**
* @def TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS * @def TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS

@ -1,69 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* Kernel port configuration parameters for snapshot mode.
*/
#ifndef TRC_KERNEL_PORT_SNAPSHOT_CONFIG_H
#define TRC_KERNEL_PORT_SNAPSHOT_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @def TRC_CFG_NTASK, TRC_CFG_NISR, TRC_CFG_NQUEUE, TRC_CFG_NSEMAPHORE...
* @brief A group of macros which should be defined as integer values, zero or larger.
*
* These define the capacity of the Object Property Table, i.e., the maximum
* number of objects active at any given point, within each object class (e.g.,
* task, queue, semaphore, ...).
*
* If tasks or other objects are deleted in your system, this
* setting does not limit the total amount of objects created, only the number
* of objects that have been successfully created but not yet deleted.
*
* Using too small values will cause vTraceError to be called, which stores an
* error message in the trace that is shown when opening the trace file. The
* error message can also be retrieved using xTraceGetLastError.
*
* It can be wise to start with large values for these constants,
* unless you are very confident on these numbers. Then do a recording and
* check the actual usage by selecting View menu -> Trace Details ->
* Resource Usage -> Object Table.
*/
#define TRC_CFG_NTASK 150
#define TRC_CFG_NISR 90
#define TRC_CFG_NQUEUE 90
#define TRC_CFG_NSEMAPHORE 90
#define TRC_CFG_NMUTEX 90
#define TRC_CFG_NTIMER 250
#define TRC_CFG_NEVENTGROUP 90
#define TRC_CFG_NSTREAMBUFFER 50
#define TRC_CFG_NMESSAGEBUFFER 50
/**
* @def TRC_CFG_NAME_LEN_TASK, TRC_CFG_NAME_LEN_QUEUE, ...
* @brief Macros that specify the maximum lengths (number of characters) for names of
* kernel objects, such as tasks and queues. If longer names are used, they will
* be truncated when stored in the recorder.
*/
#define TRC_CFG_NAME_LEN_TASK 15
#define TRC_CFG_NAME_LEN_ISR 15
#define TRC_CFG_NAME_LEN_QUEUE 15
#define TRC_CFG_NAME_LEN_SEMAPHORE 15
#define TRC_CFG_NAME_LEN_MUTEX 15
#define TRC_CFG_NAME_LEN_TIMER 15
#define TRC_CFG_NAME_LEN_EVENTGROUP 15
#define TRC_CFG_NAME_LEN_STREAMBUFFER 15
#define TRC_CFG_NAME_LEN_MESSAGEBUFFER 15
#ifdef __cplusplus
}
#endif
#endif /* TRC_KERNEL_PORT_SNAPSHOT_CONFIG_H */

@ -1,6 +1,6 @@
/* /*
* Trace Recorder for Tracealyzer v4.6.0 * Trace Recorder for Tracealyzer v4.8.1
* Copyright 2021 Percepio AB * Copyright 2023 Percepio AB
* www.percepio.com * www.percepio.com
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0

@ -1,245 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* Configuration parameters for trace recorder library in snapshot mode.
* Read more at http://percepio.com/2016/10/05/rtos-tracing/
*/
#ifndef TRC_SNAPSHOT_CONFIG_H
#define TRC_SNAPSHOT_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @def TRC_CFG_SNAPSHOT_MODE
* @brief Macro which should be defined as one of:
* - TRC_SNAPSHOT_MODE_RING_BUFFER
* - TRC_SNAPSHOT_MODE_STOP_WHEN_FULL
* Default is TRC_SNAPSHOT_MODE_RING_BUFFER.
*
* With TRC_CFG_SNAPSHOT_MODE set to TRC_SNAPSHOT_MODE_RING_BUFFER, the
* events are stored in a ring buffer, i.e., where the oldest events are
* overwritten when the buffer becomes full. This allows you to get the last
* events leading up to an interesting state, e.g., an error, without having
* to store the whole run since startup.
*
* When TRC_CFG_SNAPSHOT_MODE is TRC_SNAPSHOT_MODE_STOP_WHEN_FULL, the
* recording is stopped when the buffer becomes full. This is useful for
* recording events following a specific state, e.g., the startup sequence.
*/
#define TRC_CFG_SNAPSHOT_MODE TRC_SNAPSHOT_MODE_RING_BUFFER
/**
* @def TRC_CFG_EVENT_BUFFER_SIZE
* @brief Macro which should be defined as an integer value.
*
* This defines the capacity of the event buffer, i.e., the number of records
* it may store. Most events use one record (4 byte), although some events
* require multiple 4-byte records. You should adjust this to the amount of RAM
* available in the target system.
*
* Default value is 1000, which means that 4000 bytes is allocated for the
* event buffer.
*/
#define TRC_CFG_EVENT_BUFFER_SIZE 50000
/**
* @def TRC_CFG_INCLUDE_FLOAT_SUPPORT
* @brief Macro which should be defined as either zero (0) or one (1).
*
* If this is zero (0), the support for logging floating point values in
* vTracePrintF is stripped out, in case floating point values are not used or
* supported by the platform used.
*
* Floating point values are only used in vTracePrintF and its subroutines, to
* allow for storing float (%f) or double (%lf) arguments.
*
* vTracePrintF can be used with integer and string arguments in either case.
*
* Default value is 0.
*/
#define TRC_CFG_INCLUDE_FLOAT_SUPPORT 0
/**
* @def TRC_CFG_SYMBOL_TABLE_SIZE
* @brief Macro which should be defined as an integer value.
*
* This defines the capacity of the symbol table, in bytes. This symbol table
* stores User Events labels and names of deleted tasks, queues, or other kernel
* objects. If you don't use User Events or delete any kernel
* objects you set this to a very low value. The minimum recommended value is 4.
* A size of zero (0) is not allowed since a zero-sized array may result in a
* 32-bit pointer, i.e., using 4 bytes rather than 0.
*
* Default value is 800.
*/
#define TRC_CFG_SYMBOL_TABLE_SIZE 8000
#if ( TRC_CFG_SYMBOL_TABLE_SIZE == 0 )
#error "TRC_CFG_SYMBOL_TABLE_SIZE may not be zero!"
#endif
/******************************************************************************
*** ADVANCED SETTINGS ********************************************************
******************************************************************************
* The remaining settings are not necessary to modify but allows for optimizing
* the recorder setup for your specific needs, e.g., to exclude events that you
* are not interested in, in order to get longer traces.
*****************************************************************************/
/**
* @def TRC_CFG_HEAP_SIZE_BELOW_16M
* @brief An integer constant that can be used to reduce the buffer usage of memory
* allocation events (malloc/free). This value should be 1 if the heap size is
* below 16 MB (2^24 byte), and you can live with reported addresses showing the
* lower 24 bits only. If 0, you get the full 32-bit addresses.
*
* Default value is 0.
*/
#define TRC_CFG_HEAP_SIZE_BELOW_16M 0
/**
* @def TRC_CFG_USE_IMPLICIT_IFE_RULES
* @brief Macro which should be defined as either zero (0) or one (1).
* Default is 1.
*
* Tracealyzer groups the events into "instances" based on Instance Finish
* Events (IFEs), produced either by default rules or calls to the recorder
* functions xTraceTaskInstanceFinishedNow and xTraceTaskInstanceFinishedNext.
*
* If TRC_CFG_USE_IMPLICIT_IFE_RULES is one (1), the default IFE rules is
* used, resulting in a "typical" grouping of events into instances.
* If these rules don't give appropriate instances in your case, you can
* override the default rules using xTraceTaskInstanceFinishedNow/Next for one
* or several tasks. The default IFE rules are then disabled for those tasks.
*
* If TRC_CFG_USE_IMPLICIT_IFE_RULES is zero (0), the implicit IFE rules are
* disabled globally. You must then call xTraceTaskInstanceFinishedNow or
* xTraceTaskInstanceFinishedNext to manually group the events into instances,
* otherwise the tasks will appear a single long instance.
*
* The default IFE rules count the following events as "instance finished":
* - Task delay, delay until
* - Task suspend
* - Blocking on "input" operations, i.e., when the task is waiting for the
* next a message/signal/event. But only if this event is blocking.
*/
#define TRC_CFG_USE_IMPLICIT_IFE_RULES 1
/**
* @def TRC_CFG_USE_16BIT_OBJECT_HANDLES
* @brief Macro which should be defined as either zero (0) or one (1).
*
* If set to 0 (zero), the recorder uses 8-bit handles to identify kernel
* objects such as tasks and queues. This limits the supported number of
* concurrently active objects to 255 of each type (tasks, queues, mutexes,
* etc.) Note: 255, not 256, since handle 0 is reserved.
*
* If set to 1 (one), the recorder uses 16-bit handles to identify kernel
* objects such as tasks and queues. This limits the supported number of
* concurrent objects to 65535 of each type (object class). However, since the
* object property table is limited to 64 KB, the practical limit is about
* 3000 objects in total.
*
* Default is 0 (8-bit handles)
*
* NOTE: An object with handle above 255 will use an extra 4-byte record in
* the event buffer whenever the object is referenced. Moreover, some internal
* tables in the recorder gets slightly larger when using 16-bit handles.
*/
#define TRC_CFG_USE_16BIT_OBJECT_HANDLES 1
/**
* @def TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER
* @brief Macro which should be defined as an integer value.
*
* Set TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER to 1 to enable the
* separate user event buffer (UB).
* In this mode, user events are stored separately from other events,
* e.g., RTOS events. Thereby you can get a much longer history of
* user events as they don't need to share the buffer space with more
* frequent events.
*
* The UB is typically used with the snapshot ring-buffer mode, so the
* recording can continue when the main buffer gets full. And since the
* main buffer then overwrites the earliest events, Tracealyzer displays
* "Unknown Actor" instead of task scheduling for periods with UB data only.
*
* In UB mode, user events are structured as UB channels, which contains
* a channel name and a default format string. Register a UB channel using
* xTraceRegisterUBChannel.
*
* Events and data arguments are written using vTraceUBEvent and
* vTraceUBData. They are designed to provide efficient logging of
* repeating events, using the same format string within each channel.
*
* Examples:
* TraceStringHandle_t chn1;
* TraceStringHandle_t fmt1;
* xTraceStringRegister("Channel 1", &chn1);
* xTraceStringRegister("Event!", &fmt1);
* traceUBChannel UBCh1 = xTraceRegisterUBChannel(chn1, fmt1);
*
* TraceStringHandle_t chn2;
* TraceStringHandle_t fmt2;
* xTraceStringRegister("Channel 2", &chn2);
* xTraceStringRegister("X: %d, Y: %d", &fmt2);
* traceUBChannel UBCh2 = xTraceRegisterUBChannel(chn2, fmt2);
*
* // Result in "[Channel 1] Event!"
* vTraceUBEvent(UBCh1);
*
* // Result in "[Channel 2] X: 23, Y: 19"
* vTraceUBData(UBCh2, 23, 19);
*
* You can also use the other user event functions, like xTracePrintF.
* as they are then rerouted to the UB instead of the main event buffer.
* vTracePrintF then looks up the correct UB channel based on the
* provided channel name and format string, or creates a new UB channel
* if no match is found. The format string should therefore not contain
* "random" messages but mainly format specifiers. Random strings should
* be stored using %s and with the string as an argument.
*
* // Creates a new UB channel ("Channel 2", "%Z: %d")
* xTracePrintF(chn2, "%Z: %d", value1);
*
* // Finds the existing UB channel
* xTracePrintF(chn2, "%Z: %d", value2);
*/
#define TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER 1
/**
* @def TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE
* @brief Macro which should be defined as an integer value.
*
* This defines the capacity of the user event buffer (UB), in number of slots.
* A single user event can use multiple slots, depending on the arguments.
*
* Only applicable if TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER is 1.
*/
#define TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE 200
/**
* @def TRC_CFG_UB_CHANNELS
* @brief Macro which should be defined as an integer value.
*
* This defines the number of User Event Buffer Channels (UB channels).
* These are used to structure the events when using the separate user
* event buffer, and contains both a User Event Channel (the name) and
* a default format string for the channel.
*
* Only applicable if TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER is 1.
*/
#define TRC_CFG_UB_CHANNELS 32
#ifdef __cplusplus
}
#endif
#endif /*TRC_SNAPSHOT_CONFIG_H*/

@ -1,6 +1,6 @@
/* /*
* Trace Recorder for Tracealyzer v4.6.0 * Trace Recorder for Tracealyzer v4.8.1
* Copyright 2021 Percepio AB * Copyright 2023 Percepio AB
* www.percepio.com * www.percepio.com
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
@ -30,7 +30,7 @@
* *
* @brief Defines the size of the ring buffer use for storing trace events. * @brief Defines the size of the ring buffer use for storing trace events.
*/ */
#define TRC_CFG_STREAM_PORT_BUFFER_SIZE 10000 #define TRC_CFG_STREAM_PORT_BUFFER_SIZE 10240
/** /**
* @def TRC_CFG_STREAM_PORT_BUFFER_MODE * @def TRC_CFG_STREAM_PORT_BUFFER_MODE

@ -1,6 +1,6 @@
/* /*
* Trace Recorder for Tracealyzer v4.6.0 * Trace Recorder for Tracealyzer v4.8.1
* Copyright 2021 Percepio AB * Copyright 2023 Percepio AB
* www.percepio.com * www.percepio.com
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
@ -42,7 +42,7 @@
* which will affect the trace display. In that case, there will be warnings * which will affect the trace display. In that case, there will be warnings
* (as User Events) from TzCtrl task, that monitors this. * (as User Events) from TzCtrl task, that monitors this.
*/ */
#define TRC_CFG_ENTRY_SYMBOL_MAX_LENGTH 32 #define TRC_CFG_ENTRY_SYMBOL_MAX_LENGTH 28
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -305,8 +305,9 @@ static void prvSaveTraceFile( void )
if( pxOutputFile != NULL ) if( pxOutputFile != NULL )
{ {
{ {
extern TraceRingBuffer_t * RecorderDataPtr;
xTraceDisable(); xTraceDisable();
fwrite( RecorderDataPtr, sizeof( RecorderDataType ), 1, pxOutputFile ); fwrite( RecorderDataPtr, sizeof( TraceRingBuffer_t ), 1, pxOutputFile );
fclose( pxOutputFile ); fclose( pxOutputFile );
printf( "\r\nTrace output saved to Trace.dump\r\n" ); printf( "\r\nTrace output saved to Trace.dump\r\n" );
xTraceEnable( TRC_START ); xTraceEnable( TRC_START );

@ -0,0 +1 @@
Subproject commit 3aa03556bdb47641d6ff0c95416d16e42a8cdc02

@ -1,144 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* An example of a Tracealyzer extension for tracing API calls, in this case
* for tracing selected functions in Amazon FreeRTOS/aws_secure_sockets.
* See trcExtensions.h for information on how to use this.
*
* To create your own extension, first make sure to read the documentation
* in trcExtensions.h. Then, to create an extension header file like this
* one, you need to provide:
*
* - Extension Definitions - name and event codes of the extensions.
*
* - Trace Wrappers - calls the original function and traces the event.
*
* - Function Redefinitions - changes the function calls to the trace wrappers.
*
* See the below comments for details about these definitions. Note that you
* also need a matching .xml file for Tracealyzer to understand the data.
* See trcExtensions.h for further information.
*/
#ifndef _AWS_SECURE_SOCKETS_TZEXT_H
#define _AWS_SECURE_SOCKETS_TZEXT_H
/***** Extension Definitions *****/
/******************************************************************************
* <EXTENSIONPREFIX>_NAME
* The name of the extension as a string constant. This name is used by the
* Tracealyzer host application to find the right XML file for interpreting
* the events. Assuming the extension name is "aws_secure_sockets", Tracealyzer
* will look for an XML file named "aws_secure_sockets-<VERSION>.xml", first in
* the folder of the current trace file, next in the Tracealyzer 4/cfg folder.
* For the VERSION part, see the TRC_EXT_<ExtName>_VERSION macros below.
*
* Note: The extension name displayed in Tracealyzer is defined in the XML file
* in the EventGroup element (e.g. <EventGroup name="SOCKETS">)
*
*****************************************************************************/
#define TRC_EXT_SOCKETS_NAME "aws_secure_sockets"
/******************************************************************************
* <EXTENSIONPREFIX>_VERSION_MAJOR
* <EXTENSIONPREFIX>_VERSION_MINOR
* <EXTENSIONPREFIX>_VERSION_PATCH
*
* The version code of the extension (MAJOR.MINOR.PATCH)
*
* If you increment the version code when modifying an extension, you can still
* show old traces recorded using an earlier version of the extension.
*
* Assuming the extension name is "aws_secure_sockets", and the below version
* codes are 1 (MAJOR), 2 (MINOR), 3 (PATCH), Tracealyzer will assume the
* corresponding XML file is named "aws_secure_sockets-v1.2.3.xml". So if then
* view a trace recorded with extension version 1.2.2, those traces will look
* for "aws_secure_sockets-v1.2.2.xml" instead.
*
* Note that major and minor are stored as 8 bit values, while patch is stored
* using 16 bits. They are treated as unsigned integers, so the maximum values
* are 256, 256 and 65535.
*****************************************************************************/
#define TRC_EXT_SOCKETS_VERSION_MAJOR 1
#define TRC_EXT_SOCKETS_VERSION_MINOR 0
#define TRC_EXT_SOCKETS_VERSION_PATCH 0
/******************************************************************************
* <EXTENSIONPREFIX>_<EVENTCODE>
* The event codes used in the trace wrapper functions. Important that these
* are relative to <PREFIX>_FIRST.
*****************************************************************************/
#define EVENTCODE_SOCKETS_Connect ( TRC_EXT_BASECODE + 0 )
#define EVENTCODE_SOCKETS_Send ( TRC_EXT_BASECODE + 1 )
#define EVENTCODE_SOCKETS_Recv ( TRC_EXT_BASECODE + 2 )
/******************************************************************************
* <EXTENSIONPREFIX>_COUNT
* The number of event codes used by this extension. Should be at least 1.
* Tracealyzer allows for events codes up to 4095.
*****************************************************************************/
#define TRC_EXT_SOCKETS_COUNT 2
/***** Trace Wrappers *****/
#include <aws_secure_sockets.h> /* Including the original header file, so that custom data types are understood. */
static inline int32_t SOCKETS_Connect__trace( Socket_t xSocket,
SocketsSockaddr_t * pxAddress,
Socklen_t xAddressLength )
{
int32_t ret = SOCKETS_Connect( xSocket, pxAddress, xAddressLength );
/* Note: The host-side xml file assumes that ret == 0 means OK, otherwise timeout/error. */
prvTraceStoreEvent3( EVENTCODE_SOCKETS_Connect, ( uint32_t ) xSocket, ( uint32_t ) pxAddress->ulAddress, ( uint32_t ) ret );
return ret;
}
static inline int32_t SOCKETS_Send__trace( Socket_t xSocket,
const void * pvBuffer,
size_t xDataLength,
uint32_t ulFlags )
{
int32_t ret = SOCKETS_Send( xSocket, pvBuffer, xDataLength, ulFlags );
/* Note: The host-side xml file assumes that ret == 0 means OK, otherwise timeout/error. */
prvTraceStoreEvent2( EVENTCODE_SOCKETS_Send, ( uint32_t ) xSocket, ( uint32_t ) ret );
return ret;
}
static inline int32_t SOCKETS_Recv__trace( Socket_t xSocket,
void * pvBuffer,
size_t xBufferLength,
uint32_t ulFlags )
{
int32_t ret = SOCKETS_Recv( xSocket, pvBuffer, xBufferLength, ulFlags );
/* Note: The host-side xml file assumes that ret == 0 means OK, otherwise timeout/error. */
prvTraceStoreEvent2( EVENTCODE_SOCKETS_Recv, ( uint32_t ) xSocket, ( uint32_t ) ret );
return ret;
}
/***** Function Redefinitions *****/
#define SOCKETS_Connect SOCKETS_Connect__trace
#define SOCKETS_Send SOCKETS_Send__trace
#define SOCKETS_Recv SOCKETS_Recv__trace
#endif /* _AWS_SECURE_SOCKETS_TZEXT_H */

@ -1,135 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* An example of a Tracealyzer extension for tracing API calls, in this case
* for tracing selected functions in Amazon FreeRTOS/aws_wifi.
* See trcExtensions.h for information on how to use this.
*
* To create your own extension, first make sure to read the documentation
* in trcExtensions.h. Then, to create an extension header file like this
* one, you need to provide:
*
* - Extension Definitions - name and event codes of the extensions.
*
* - Trace Wrappers - calls the original function and traces the event.
*
* - Function Redefinitions - changes the function calls to the trace wrappers.
*
* See the below comments for details about these definitions. Note that you
* also need a matching .xml file for Tracealyzer to understand the data.
* See trcExtensions.h for further information.
*/
#ifndef _AWS_WIFI_TZEXT_H
#define _AWS_WIFI_TZEXT_H
/***** Extension Definitions (must use the same prefix!) *****/
/******************************************************************************
* <EXTENSIONPREFIX>_NAME
* The name of the extension as a string constant. This name is used by the
* Tracealyzer host application to find the right XML file for interpreting
* the events. Assuming the extension name is "aws_secure_sockets", Tracealyzer
* will look for an XML file named "aws_secure_sockets-<VERSION>.xml", first in
* the folder of the current trace file, next in the Tracealyzer 4/cfg folder.
* For the VERSION part, see the TRC_EXT_<ExtName>_VERSION macros below.
*
* Note: The extension name displayed in Tracealyzer is defined in the XML file
* in the EventGroup element (e.g. <EventGroup name="SOCKETS">)
*
*****************************************************************************/
#define TRC_EXT_WIFI_NAME "aws_wifi"
/******************************************************************************
* <EXTENSIONPREFIX>_VERSION_MAJOR
* <EXTENSIONPREFIX>_VERSION_MINOR
* <EXTENSIONPREFIX>_VERSION_PATCH
*
* The version code of the extension (MAJOR.MINOR.PATCH)
*
* If you increment the version code when modifying an extension, you can still
* show old traces recorded using an earlier version of the extension.
*
* Assuming the extension name is "aws_secure_sockets", and the below version
* codes are 1 (MAJOR), 2 (MINOR), 3 (PATCH), Tracealyzer will assume the
* corresponding XML file is named "aws_secure_sockets-v1.2.3.xml". So if then
* view a trace recorded with extension version 1.2.2, those traces will look
* for "aws_secure_sockets-v1.2.2.xml" instead.
*
* Note that major and minor are stored as 8 bit values, while patch is stored
* using 16 bits. They are treated as unsigned integers, so the maximum values
* are 256, 256 and 65535.
*****************************************************************************/
#define TRC_EXT_WIFI_VERSION_MAJOR 1
#define TRC_EXT_WIFI_VERSION_MINOR 0
#define TRC_EXT_WIFI_VERSION_PATCH 0
/******************************************************************************
* <EXTENSIONPREFIX>_<EVENTCODE>
* The event codes used in the trace wrapper functions. Important that these
* are relative to <PREFIX>_FIRST.
*****************************************************************************/
#define EVENTCODE_WIFI_On ( TRC_EXT_BASECODE + 0 )
#define EVENTCODE_WIFI_Off ( TRC_EXT_BASECODE + 1 )
#define EVENTCODE_WIFI_ConnectAP ( TRC_EXT_BASECODE + 2 )
/******************************************************************************
* <EXTENSIONPREFIX>_COUNT
* The number of event codes used by this extension. Should be at least 1.
* Tracealyzer allows for events codes up to 4095.
*****************************************************************************/
#define TRC_EXT_WIFI_COUNT 3
/***** Trace Wrappers *****/
#include <aws_wifi.h> /* Including the original header file, so that custom data types are understood. */
static inline WIFIReturnCode_t WIFI_On__trace( void )
{
WIFIReturnCode_t ret = WIFI_On();
/* Note: The host-side xml file assumes that ret == 0 means OK, otherwise timeout/error. */
prvTraceStoreEvent1( EVENTCODE_WIFI_On, ( uint32_t ) ret );
return ret;
}
static inline WIFIReturnCode_t WIFI_Off__trace( void )
{
WIFIReturnCode_t ret = WIFI_Off();
/* Note: The host-side xml file assumes that ret == 0 means OK, otherwise timeout/error. */
prvTraceStoreEvent1( EVENTCODE_WIFI_Off, ( uint32_t ) ret );
return ret;
}
static inline WIFIReturnCode_t WIFI_ConnectAP__trace( const WIFINetworkParams_t * const pxNetworkParams )
{
WIFIReturnCode_t ret = WIFI_ConnectAP( pxNetworkParams );
/* Note: The host-side xml file assumes that ret == 0 means OK, otherwise timeout/error. */
prvTraceStoreStringEvent( 2, EVENTCODE_WIFI_ConnectAP, pxNetworkParams->pcSSID, pxNetworkParams->xSecurity, ret );
return ret;
}
/***** Function Redefinitions *****/
#define WIFI_On WIFI_On__trace
#define WIFI_Off WIFI_Off__trace
#define WIFI_ConnectAP WIFI_ConnectAP__trace
#endif /* _AWS_SECURE_SOCKETS2_TZEXT_H */

@ -1,145 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
*
* @brief Public trace assert APIs.
*/
#ifndef TRC_ASSERT_H
#define TRC_ASSERT_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <trcTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup trace_assert_apis Trace Asserts APIs
* @ingroup trace_recorder_apis
* @{
*/
#ifndef TRC_CFG_USE_TRACE_ASSERT
#error "TRC_CFG_USE_TRACE_ASSERT is not defined. Please define it in trcConfig.h"
#endif
#if ( ( TRC_CFG_USE_TRACE_ASSERT ) == 1 )
/* Standard assert */
#define TRC_ASSERT( __condition ) if( !( __condition ) ) { prvTraceAssertCreate( __FILE__, __LINE__ ); return TRC_FAIL; }
#define TRC_ASSERT_ALWAYS_EVALUATE TRC_ASSERT
/* Standard assert with custom on fail actions */
#define TRC_ASSERT_CUSTOM_ON_FAIL( __condition, __custom_on_fail ) if( !( __condition ) ) { prvTraceAssertCreate( __FILE__, __LINE__ ); __custom_on_fail; }
#define TRC_ASSERT_CUSTOM_ON_FAIL_ALWAYS_EVALUATE TRC_ASSERT_CUSTOM_ON_FAIL
#if ( defined( TRC_CFG_TEST_MODE ) && ( TRC_CFG_TEST_MODE ) == 1 )
/* Asserts that two types have an equal size. Condition passed to function to avoid compilers warning about unreachable code due to constant value. */
#define TRC_ASSERT_EQUAL_SIZE( x, y ) if( !prvTraceAssertCheckCondition( ( TraceBaseType_t ) ( sizeof( x ) == sizeof( y ) ) ) ) { prvTraceAssertCreate( __FILE__, __LINE__ ); return TRC_FAIL; }
/**
* @brief Inlined condition check to get around some compiler warnings for unused variables.
*
* @param[in] condition The condition
*/
inline TraceBaseType_t prvTraceAssertCheckCondition( TraceBaseType_t condition )
{
return condition;
}
#else /* if ( defined( TRC_CFG_TEST_MODE ) && ( TRC_CFG_TEST_MODE ) == 1 ) */
#define TRC_ASSERT_EQUAL_SIZE( x, y )
#endif /* if ( defined( TRC_CFG_TEST_MODE ) && ( TRC_CFG_TEST_MODE ) == 1 ) */
#define TRC_ASSERT_BUFFER_SIZE ( sizeof( TraceEntryHandle_t ) )
typedef struct TraceAssertBuffer
{
uint8_t buffer[ TRC_ASSERT_BUFFER_SIZE ];
} TraceAssertBuffer_t;
/**
* @internal Initializes assert system
*
* @param[in] pxBuffer The assert data buffer
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceAssertInitialize( TraceAssertBuffer_t * pxBuffer );
/**
* @internal Creates an assert
*
* @param[in] szFilePath File name
* @param[in] uxLineNumber Line number
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
void prvTraceAssertCreate( const char * szFilePath,
TraceUnsignedBaseType_t uxLineNumber );
/**
* @brief Retrieves the assert and line number
*
* @param[out] pxFileNameStringHandle File name string handle
* @param[out] puxLineNumber Line number
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceAssertGet( TraceStringHandle_t * pxFileNameStringHandle,
TraceUnsignedBaseType_t * puxLineNumber );
#else /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */
#define TRC_ASSERT( __condition )
#define TRC_ASSERT_ALWAYS_EVALUATE( __condition ) ( void ) ( __condition )
#define TRC_ASSERT_CUSTOM_ON_FAIL( __condition, __custom_on_fail )
#define TRC_ASSERT_CUSTOM_ON_FAIL_ALWAYS_EVALUATE( __condition, __custom_on_fail ) ( __condition )
#define TRC_ASSERT_EQUAL_SIZE( x, y )
typedef struct TraceAssertBuffer
{
uint32_t buffer[ 1 ];
} TraceAssertBuffer_t;
#define xTraceAssertInitialize( pxBuffer ) ( ( void ) pxBuffer, TRC_SUCCESS )
#define xTraceAssertGet( pxFileNameStringHandle, puxLineNumber ) ( ( void ) pxFileNameStringHandle, ( void ) puxLineNumber, TRC_FAIL )
#endif /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
#endif /* TRC_ASSERT_H */

@ -1,164 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
*
* @brief Public trace counter APIs.
*/
#ifndef TRC_COUNTER_H
#define TRC_COUNTER_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <trcTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup trace_counter_apis Trace Counter APIs
* @ingroup trace_recorder_apis
* @{
*/
/**
* @brief Sets trace counter callback.
*
* @param[in] xCallback Callback
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceCounterSetCallback( TraceCounterCallback_t xCallback );
/**
* @brief Creates trace counter.
*
* @param[in] szName Name.
* @param[in] xInitialValue Initial value.
* @param[in] xLowerLimit Lower limit.
* @param[in] xUpperLimit Upper limit.
* @param[out] pxCounterHandle Uninitialized trace counter handle.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceCounterCreate( const char * szName,
TraceBaseType_t xInitialValue,
TraceBaseType_t xLowerLimit,
TraceBaseType_t xUpperLimit,
TraceCounterHandle_t * pxCounterHandle );
/**
* @brief Adds value to trace counter.
*
* @param[in] xCounterHandle Initialized trace counter handle.
* @param[in] xValue Value.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceCounterAdd( TraceCounterHandle_t xCounterHandle,
TraceBaseType_t xValue );
/**
* @brief Sets trace counter value.
*
* @param[in] xCounterHandle Initialized trace counter handle.
* @param[in] xValue Value.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceCounterSet( TraceCounterHandle_t xCounterHandle,
TraceBaseType_t xValue );
/**
* @brief Gets trace counter value.
*
* @param[in] xCounterHandle Initialized trace counter handle.
* @param[out] pxValue Value.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceCounterGet( TraceCounterHandle_t xCounterHandle,
TraceBaseType_t * pxValue );
/**
* @brief Increases trace counter value.
*
* @param[in] xCounterHandle Initialized trace counter handle.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceCounterIncrease( TraceCounterHandle_t xCounterHandle );
/**
* @brief Decreases trace counter value.
*
* @param[in] xCounterHandle Initialized trace counter handle.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceCounterDecrease( TraceCounterHandle_t xCounterHandle );
/**
* @brief Gets trace counter upper limit.
*
* @param[in] xCounterHandle Initialized trace counter handle.
* @param[out] pxValue Value.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceCounterGetUpperLimit( TraceCounterHandle_t xCounterHandle,
TraceBaseType_t * pxValue );
/**
* @brief Gets trace counter lower limit.
*
* @param[in] xCounterHandle Initialized trace counter handle.
* @param[out] pxValue Value
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceCounterGetLowerLimit( TraceCounterHandle_t xCounterHandle,
TraceBaseType_t * pxValue );
/**
* @brief Gets trace counter name.
*
* @param[in] xCounterHandle Initialized trace counter handle.
* @param[out] pszName Name.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceCounterGetName( TraceCounterHandle_t xCounterHandle,
const char ** pszName );
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
#endif /* TRC_COUNTER_H */

@ -1,182 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* Some common defines for the trace recorder.
*/
#ifndef TRC_DEFINES_H
#define TRC_DEFINES_H
#define TRC_SUCCESS ( 0 )
#define TRC_FAIL ( 1 )
#define TRC_FREE_RUNNING_32BIT_INCR 1
#define TRC_FREE_RUNNING_32BIT_DECR 2
#define TRC_OS_TIMER_INCR 3
#define TRC_OS_TIMER_DECR 4
#define TRC_CUSTOM_TIMER_INCR 5
#define TRC_CUSTOM_TIMER_DECR 6
#define TRC_STATE_IN_STARTUP 0
#define TRC_STATE_IN_TASKSWITCH 1
#define TRC_STATE_IN_APPLICATION 2
/* Start options for vTraceEnable. */
#define TRC_START_FROM_HOST 0
#define TRC_START 1
#define TRC_START_AWAIT_HOST 2
#define TRC_ACKNOWLEDGED ( 0xABC99123 )
/* Command codes for TzCtrl task */
#define CMD_SET_ACTIVE 1 /* Start (param1 = 1) or Stop (param1 = 0) */
/* The final command code, used to validate commands. */
#define CMD_LAST_COMMAND 1
#define TRC_RECORDER_MODE_SNAPSHOT 0
#define TRC_RECORDER_MODE_STREAMING 1
#define TRC_SNAPSHOT_MODE_RING_BUFFER ( 0x01 )
#define TRC_SNAPSHOT_MODE_STOP_WHEN_FULL ( 0x02 )
#define TRC_RECORDER_BUFFER_ALLOCATION_STATIC ( 0x00 )
#define TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC ( 0x01 )
#define TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM ( 0x02 )
#define TRC_OPTION_BIT_SHIFT_IRQ_ORDER 0
#define TRC_OPTION_BIT_SHIFT_BASE_SIZE 8
/******************************************************************************/
/*** ERROR AND WARNING CODES (check using xTraceErrorGetLast) *****************/
/******************************************************************************/
#define TRC_ERROR_NONE 0x00
#define TRC_ERROR_ASSERT 0x01
#define TRC_ERROR_EVENT_CODE_TOO_LARGE 0x02
#define TRC_ERROR_ISR_NESTING_OVERFLOW 0x03
#define TRC_ERROR_DWT_NOT_SUPPORTED 0x04
#define TRC_ERROR_DWT_CYCCNT_NOT_SUPPORTED 0x05
#define TRC_ERROR_TZCTRLTASK_NOT_CREATED 0x06
#define TRC_ERROR_STREAM_PORT_WRITE 0x07
#define TRC_WARNING_ENTRY_TABLE_SLOTS 0x08
#define TRC_WARNING_ENTRY_SYMBOL_MAX_LENGTH 0x09
#define TRC_WARNING_EVENT_SIZE_TRUNCATED 0x0A
#define TRC_WARNING_STREAM_PORT_READ 0x0B
#define TRC_WARNING_STREAM_PORT_WRITE 0x0C
#define TRC_WARNING_STREAM_PORT_INITIAL_BLOCKING 0x0D
#define TRC_WARNING_STACKMON_NO_SLOTS 0x0E
/* Entry Option definitions */
#define TRC_ENTRY_OPTION_EXCLUDED 0x00000001
#define TRC_ENTRY_OPTION_HEAP 0x80000000
#define TRC_ENTRY_OPTION_EXTENSION 0x40000000
#define TRC_ENTRY_OPTION_STATE_MACHINE 0x20000000
#define TRC_ENTRY_OPTION_STATE_MACHINE_STATE 0x10000000
#define TRC_ENTRY_OPTION_INTERVAL 0x08000000
#define TRC_ENTRY_OPTION_COUNTER 0x04000000
#define TRC_RECORDER_COMPONENT_CORE 0x00000001
#define TRC_RECORDER_COMPONENT_ASSERT 0x00000002
#define TRC_RECORDER_COMPONENT_BLOB 0x00000004
#define TRC_RECORDER_COMPONENT_DIAGNOSTICS 0x00000008
#define TRC_RECORDER_COMPONENT_ENTRY 0x00000010
#define TRC_RECORDER_COMPONENT_ERROR 0x00000020
#define TRC_RECORDER_COMPONENT_EVENT 0x00000040
#define TRC_RECORDER_COMPONENT_EVENT_BUFFER 0x00000080
#define TRC_RECORDER_COMPONENT_EXTENSION 0x00000100
#define TRC_RECORDER_COMPONENT_HEAP 0x00000200
#define TRC_RECORDER_COMPONENT_INTERNAL_EVENT_BUFFER 0x00000400
#define TRC_RECORDER_COMPONENT_INTERVAL 0x00000800
#define TRC_RECORDER_COMPONENT_ISR 0x00001000
#define TRC_RECORDER_COMPONENT_MULTI_CORE_EVENT_BUFFER 0x00002000
#define TRC_RECORDER_COMPONENT_OBJECT 0x00004000
#define TRC_RECORDER_COMPONENT_PRINT 0x00008000
#define TRC_RECORDER_COMPONENT_STACK_MONITOR 0x00010000
#define TRC_RECORDER_COMPONENT_STATE_MACHINE 0x00020000
#define TRC_RECORDER_COMPONENT_STATIC_BUFFER 0x00040000
#define TRC_RECORDER_COMPONENT_STRING 0x00080000
#define TRC_RECORDER_COMPONENT_TASK 0x00100000
#define TRC_RECORDER_COMPONENT_TIMESTAMP 0x00200000
#define TRC_RECORDER_COMPONENT_COUNTER 0x00400000
/* Filter Groups */
#define FilterGroup0 ( uint16_t ) 0x0001
#define FilterGroup1 ( uint16_t ) 0x0002
#define FilterGroup2 ( uint16_t ) 0x0004
#define FilterGroup3 ( uint16_t ) 0x0008
#define FilterGroup4 ( uint16_t ) 0x0010
#define FilterGroup5 ( uint16_t ) 0x0020
#define FilterGroup6 ( uint16_t ) 0x0040
#define FilterGroup7 ( uint16_t ) 0x0080
#define FilterGroup8 ( uint16_t ) 0x0100
#define FilterGroup9 ( uint16_t ) 0x0200
#define FilterGroup10 ( uint16_t ) 0x0400
#define FilterGroup11 ( uint16_t ) 0x0800
#define FilterGroup12 ( uint16_t ) 0x1000
#define FilterGroup13 ( uint16_t ) 0x2000
#define FilterGroup14 ( uint16_t ) 0x4000
#define FilterGroup15 ( uint16_t ) 0x8000
/******************************************************************************
* Supported ports
*
* TRC_HARDWARE_PORT_HWIndependent
* A hardware independent fallback option for event timestamping. Provides low
* resolution timestamps based on the OS tick.
* This may be used on the Win32 port, but may also be used on embedded hardware
* platforms. All time durations will be truncated to the OS tick frequency,
* typically 1 KHz. This means that a task or ISR that executes in less than
* 1 ms get an execution time of zero.
*
* TRC_HARDWARE_PORT_APPLICATION_DEFINED
* Allows for defining the port macros in other source code files.
*
* TRC_HARDWARE_PORT_Win32
* "Accurate" timestamping based on the Windows performance counter for Win32
* builds. Note that this gives the host machine time, not the kernel time.
*
* Hardware specific ports
* To get accurate timestamping, a hardware timer is necessary. Below are the
* available ports. Some of these are "unofficial", meaning that
* they have not yet been verified by Percepio but have been contributed by
* external developers. They should work, otherwise let us know by emailing
* support@percepio.com. Some work on any OS platform, while other are specific
* to a certain operating system.
*****************************************************************************/
/****** Port Name ************************************* Code ** Official ** OS Platform *********/
#define TRC_HARDWARE_PORT_APPLICATION_DEFINED 98 /* - - */
#define TRC_HARDWARE_PORT_NOT_SET 99 /* - - */
#define TRC_HARDWARE_PORT_HWIndependent 0 /* Yes Any */
#define TRC_HARDWARE_PORT_Win32 1 /* Yes FreeRTOS on Win32 */
#define TRC_HARDWARE_PORT_Atmel_AT91SAM7 2 /* No Any */
#define TRC_HARDWARE_PORT_Atmel_UC3A0 3 /* No Any */
#define TRC_HARDWARE_PORT_ARM_Cortex_M 4 /* Yes Any */
#define TRC_HARDWARE_PORT_Renesas_RX600 6 /* Yes Any */
#define TRC_HARDWARE_PORT_MICROCHIP_PIC24_PIC32 7 /* Yes Any */
#define TRC_HARDWARE_PORT_TEXAS_INSTRUMENTS_TMS570_RM48 8 /* Yes Any */
#define TRC_HARDWARE_PORT_TEXAS_INSTRUMENTS_MSP430 9 /* No Any */
#define TRC_HARDWARE_PORT_XILINX_PPC405 11 /* No FreeRTOS */
#define TRC_HARDWARE_PORT_XILINX_PPC440 12 /* No FreeRTOS */
#define TRC_HARDWARE_PORT_XILINX_MICROBLAZE 13 /* No Any */
#define TRC_HARDWARE_PORT_XILINX_ZyncUltraScaleR5 14 /* No FreeRTOS */
#define TRC_HARDWARE_PORT_NXP_LPC210X 15 /* No Any */
#define TRC_HARDWARE_PORT_ARM_CORTEX_A9 16 /* Yes Any */
#define TRC_HARDWARE_PORT_POWERPC_Z4 17 /* No FreeRTOS */
#define TRC_HARDWARE_PORT_Altera_NiosII 18 /* Yes Any (Tested with FreeRTOS) */
#define TRC_HARDWARE_PORT_ZEPHYR 19 /* Yes Zephyr */
#define TRC_HARDWARE_PORT_XTensa_LX6 20 /* Yes ESP-IDF FreeRTOS */
#define TRC_HARDWARE_PORT_XTensa_LX7 21 /* Yes ESP-IDF FreeRTOS */
#define TRC_HARDWARE_PORT_Win64 22 /* Yes FreeRTOS on Win64 */
#define TRC_HARDWARE_PORT_XMOS_XCOREAI 23 /* Yes FreeRTOS SMP */
#define TRC_HARDWARE_PORT_RISCV_RV32I 24 /* Yes FreeRTOS */
#define TRC_HARDWARE_PORT_CYCLONE_V_HPS 25 /* Yes FreeRTOS */
#endif /* TRC_PORTDEFINES_H */

@ -1,150 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
*
* @brief Public trace diagnostic APIs.
*/
#ifndef TRC_DIAGNOSTICS_H
#define TRC_DIAGNOSTICS_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <trcTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
#define TRC_DIAGNOSTICS_COUNT 5
typedef enum TraceDiagnosticsType
{
TRC_DIAGNOSTICS_ENTRY_SYMBOL_LONGEST_LENGTH = 0x00,
TRC_DIAGNOSTICS_ENTRY_SLOTS_NO_ROOM = 0x01,
TRC_DIAGNOSTICS_BLOB_MAX_BYTES_TRUNCATED = 0x02,
TRC_DIAGNOSTICS_STACK_MONITOR_NO_SLOTS = 0x03,
TRC_DIAGNOSTICS_ASSERTS_TRIGGERED = 0x04,
} TraceDiagnosticsType_t;
typedef struct TraceDiagnosticsBuffer
{
uint8_t buffer[ sizeof( TraceBaseType_t ) * ( TRC_DIAGNOSTICS_COUNT ) ];
} TraceDiagnosticsBuffer_t;
/**
* @internal Initialize diagnostics
*
* @param[in] pxBuffer Diagnostics buffer
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceDiagnosticsInitialize( TraceDiagnosticsBuffer_t * pxBuffer );
/**
* @brief Retrieve diagnostics value
*
* @param[in] xType Diagnostics type
* @param[out] pxValue Pointer to value
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceDiagnosticsGet( TraceDiagnosticsType_t xType,
TraceBaseType_t * pxValue );
/**
* @brief Set diagnostics value
*
* @param[in] xType Diagnostics type
* @param[in] xValue Value
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceDiagnosticsSet( TraceDiagnosticsType_t xType,
TraceBaseType_t xValue );
/**
* @brief Add to diagnostics value
*
* @param[in] xType Diagnostics type
* @param[in] xValue Value
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceDiagnosticsAdd( TraceDiagnosticsType_t xType,
TraceBaseType_t xValue );
/**
* @brief Increase diagnostics value
*
* @param[in] xType Diagnostics type
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceDiagnosticsIncrease( TraceDiagnosticsType_t xType );
/**
* @brief Decrease diagnostics value
*
* @param[in] xType Diagnostics type
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceDiagnosticsDecrease( TraceDiagnosticsType_t xType );
/**
* @brief Set a new diagnostics value if higher than previous value
*
* @param[in] xType Dagnostics type
* @param[in] xValue Value
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceDiagnosticsSetIfHigher( TraceDiagnosticsType_t xType,
TraceBaseType_t xValue );
/**
* @brief Set a new diagnostics value if lower than previous value
*
* @param[in] xType Dagnostics type
* @param[in] xValue Value
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceDiagnosticsSetIfLower( TraceDiagnosticsType_t xType,
TraceBaseType_t xValue );
/**
* @brief Check the diagnostics status
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceDiagnosticsCheckStatus( void );
#ifdef __cplusplus
}
#endif
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
#endif /* TRC_DIAGNOSTICS_H */

@ -1,271 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
*
* @brief Public trace entry table APIs.
*/
#ifndef TRC_ENTRY_TABLE_H
#define TRC_ENTRY_TABLE_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <trcTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup trace_entry_table_apis Trace Entry Table APIs
* @ingroup trace_recorder_apis
* @{
*/
#define TRC_ENTRY_CREATE_WITH_ADDRESS( _pvAddress, _pxEntryHandle ) ( xTraceEntryCreate( _pxEntryHandle ) == TRC_SUCCESS ? ( ( ( TraceEntry_t * ) *( _pxEntryHandle ) )->pvAddress = ( _pvAddress ), TRC_SUCCESS ) : TRC_FAIL )
#define TRC_ENTRY_SET_STATE( xEntryHandle, uiStateIndex, uxState ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( ( ( TraceEntry_t * ) ( xEntryHandle ) )->xStates[ uiStateIndex ] = ( uxState ), TRC_SUCCESS )
#define TRC_ENTRY_SET_OPTIONS( xEntryHandle, uiMask ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( ( ( TraceEntry_t * ) ( xEntryHandle ) )->uiOptions |= ( uiMask ), TRC_SUCCESS )
#define TRC_ENTRY_CLEAR_OPTIONS( xEntryHandle, uiMask ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( ( ( TraceEntry_t * ) ( xEntryHandle ) )->uiOptions &= ~( uiMask ), TRC_SUCCESS )
#define TRC_ENTRY_GET_ADDRESS( xEntryHandle, ppvAddress ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( *( ppvAddress ) = ( ( TraceEntry_t * ) ( xEntryHandle ) )->pvAddress, TRC_SUCCESS )
#define TRC_ENTRY_GET_SYMBOL( xEntryHandle, pszSymbol ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( *( pszSymbol ) = ( ( TraceEntry_t * ) ( xEntryHandle ) )->szSymbol, TRC_SUCCESS )
#define TRC_ENTRY_GET_STATE( xEntryHandle, uiStateIndex, puxState ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( *( puxState ) = ( ( TraceEntry_t * ) ( xEntryHandle ) )->xStates[ uiStateIndex ], TRC_SUCCESS )
#define TRC_ENTRY_GET_OPTIONS( xEntryHandle, puiOptions ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( *( puiOptions ) = ( ( TraceEntry_t * ) ( xEntryHandle ) )->uiOptions, TRC_SUCCESS )
#define TRC_ENTRY_TABLE_SLOTS ( TRC_CFG_ENTRY_SLOTS )
#define TRC_ENTRY_TABLE_STATE_COUNT ( 3 )
#define TRC_ENTRY_TABLE_SYMBOL_LENGTH ( TRC_CFG_ENTRY_SYMBOL_MAX_LENGTH )
#define TRC_ENTRY_TABLE_SLOT_SYMBOL_SIZE ( ( ( ( sizeof( char ) * TRC_ENTRY_TABLE_SYMBOL_LENGTH ) + ( sizeof( uint32_t ) - 1 ) ) / sizeof( uint32_t ) ) * sizeof( uint32_t ) )
/** Trace Entry Structure */
typedef struct TraceEntry
{
void * pvAddress; /**< */
TraceUnsignedBaseType_t xStates[ TRC_ENTRY_TABLE_STATE_COUNT ]; /**< */
uint32_t uiOptions; /**< */
char szSymbol[ TRC_ENTRY_TABLE_SLOT_SYMBOL_SIZE ]; /**< */
} TraceEntry_t;
#define TRC_ENTRY_TABLE_SIZE ( sizeof( uint32_t ) + sizeof( uint32_t ) + sizeof( uint32_t ) + ( sizeof( TraceEntry_t ) * ( TRC_ENTRY_TABLE_SLOTS ) ) )
/** Trace Entry Table Buffer Structure */
typedef struct TraceEntryTableBuffer
{
uint8_t buffer[ ( TRC_ENTRY_TABLE_SIZE ) ]; /**< */
} TraceEntryTableBuffer_t;
/**
* @internal Initialize trace entry table.
*
* This routine initializes the trace entry table which maps objects to
* symbolic identifiers, state information, and options.
*
* @param[in] pxBuffer Pointer to uninitialized trace entry table buffer.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEntryTableInitialize( TraceEntryTableBuffer_t * pxBuffer );
/**
* @brief Creates trace entry.
*
* @param[out] pxEntryHandle Pointer to uninitialized trace entry handle.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEntryCreate( TraceEntryHandle_t * pxEntryHandle );
/**
* @brief Deletes trace entry.
*
* @param[in] xEntryHandle Pointer to initialized trace entry handle.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEntryDelete( TraceEntryHandle_t xEntryHandle );
/**
* @brief Finds trace entry mapped to object address.
*
* @param[in] pvAddress Address of object.
* @param[out] pxEntryHandle Pointer to uninitialized trace entry handle.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEntryFind( void * pvAddress,
TraceEntryHandle_t * pxEntryHandle );
/**
* @brief Gets the number of entries in the trace entry table.
*
* @param[out] puiCount Count.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEntryGetCount( uint32_t * puiCount );
/**
* @brief Gets trace table entry at index.
*
* @param[in] index Entry index.
* @param[out] pxEntryHandle Pointer to uninitialized trace entry handle.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEntryGetAtIndex( uint32_t index,
TraceEntryHandle_t * pxEntryHandle );
/**
* @brief Sets symbol for entry.
*
* @param[in] xEntryHandle Pointer to initialized trace entry handle.
* @param[out] szSymbol Pointer to symbol string, set by function
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEntrySetSymbol( TraceEntryHandle_t xEntryHandle,
const char * szSymbol );
#if ( ( TRC_CFG_USE_TRACE_ASSERT ) == 1 )
/**
* @brief Creates trace entry mapped to memory address.
*
* @param[in] pvAddress Address.
* @param[out] pxEntryHandle Pointer to uninitialized trace entry handle.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEntryCreateWithAddress( void * pvAddress,
TraceEntryHandle_t * pxEntryHandle );
/**
* @brief Sets trace entry state.
*
* @param[in] xEntryHandle Pointer to initialized trace entry handle.
* @param[in] uiStateIndex Index of state (< TRC_ENTRY_TABLE_STATE_COUNT).
* @param[in] uxState State.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEntrySetState( TraceEntryHandle_t xEntryHandle,
uint32_t uiStateIndex,
TraceUnsignedBaseType_t uxState );
/**
* @brief Sets trace entry option(s).
*
* @param[in] xEntryHandle Pointer to initialized trace entry handle.
* @param[in] uiMask Option(s) set mask.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEntrySetOptions( TraceEntryHandle_t xEntryHandle,
uint32_t uiMask );
/**
* @brief Clears trace entry option(s).
*
* @param[in] xEntryHandle Pointer to initialized trace entry handle.
* @param[in] uiMask Options(s) clear mask.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEntryClearOptions( TraceEntryHandle_t xEntryHandle,
uint32_t uiMask );
/**
* @brief Gets linked address for trace entry.
*
* @param[in] xEntryHandle Pointer to initialized trace entry handle.
* @param[out] ppvAddress Address.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEntryGetAddress( TraceEntryHandle_t xEntryHandle,
void ** ppvAddress );
/**
* @brief Gets symbol for trace entry.
*
* @param[in] xEntryHandle Pointer to initialized trace entry handle.
* @param[out] pszSymbol Symbol.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEntryGetSymbol( TraceEntryHandle_t xEntryHandle,
const char ** pszSymbol );
/**
* @brief Gets state for trace entry.
*
* @param[in] xEntryHandle Pointer to initialized trace entry handle.
* @param[in] uiStateIndex State index (< TRC_ENTRY_TABLE_STATE_COUNT).
* @param[out] puxState State.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEntryGetState( TraceEntryHandle_t xEntryHandle,
uint32_t uiStateIndex,
TraceUnsignedBaseType_t * puxState );
/**
* @brief Gets options for trace entry.
*
* @param[in] xEntryHandle Pointer to initialized trace entry handle.
* @param[out] puiOptions Options.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEntryGetOptions( TraceEntryHandle_t xEntryHandle,
uint32_t * puiOptions );
#else /* if ( ( TRC_CFG_USE_TRACE_ASSERT ) == 1 ) */
#define xTraceEntryCreateWithAddress TRC_ENTRY_CREATE_WITH_ADDRESS
#define xTraceEntrySetState TRC_ENTRY_SET_STATE
#define xTraceEntrySetOptions TRC_ENTRY_SET_OPTIONS
#define xTraceEntryClearOptions TRC_ENTRY_CLEAR_OPTIONS
#define xTraceEntryGetAddress TRC_ENTRY_GET_ADDRESS
#define xTraceEntryGetSymbol TRC_ENTRY_GET_SYMBOL
#define xTraceEntryGetState TRC_ENTRY_GET_STATE
#define xTraceEntryGetOptions TRC_ENTRY_GET_OPTIONS
#endif /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
#endif /* TRC_ENTRY_TABLE_H */

@ -1,99 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
*
* @brief Public trace error APIs.
*/
#ifndef TRC_ERROR_H
#define TRC_ERROR_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <trcTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup trace_assert_apis Trace Asserts APIs
* @ingroup trace_recorder_apis
* @{
*/
#define TRC_ERROR_BUFFER_SIZE ( sizeof( uint32_t ) + sizeof( uint32_t ) + sizeof( TraceStringHandle_t ) )
typedef struct TraceErrorBuffer
{
uint32_t buffer[ ( TRC_ERROR_BUFFER_SIZE ) / sizeof( uint32_t ) ];
} TraceErrorBuffer_t;
/**
* @internal Initializes the error system
*
* @param[in] pxBuffer Pointer to buffer
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceErrorInitialize( TraceErrorBuffer_t * pxBuffer );
/**
* @brief Register a warning
*
* @param[in] uiErrorCode Label
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceWarning( uint32_t uiErrorCode );
/**
* @brief Register an error
*
* @param[in] uiErrorCode Error code
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceError( uint32_t uiErrorCode );
/**
* @brief Retrieve the string for the last error
*
* @param[out] pszError Error string pointer
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceErrorGetLast( const char ** pszError );
/**
* @brief Clears any errors
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceErrorClear( void );
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
#endif /* TRC_ERROR_H*/

@ -1,635 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
*
* @brief Public trace event APIs.
*/
#ifndef TRC_EVENT_H
#define TRC_EVENT_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <trcTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup trace_event_apis Trace Event APIs
* @ingroup trace_recorder_apis
* @{
*/
/**
* @internal Macro helper for setting trace event parameter count.
*/
#define TRC_EVENT_SET_PARAM_COUNT( id, n ) ( ( ( uint16_t ) ( id ) ) | ( ( ( ( uint16_t ) ( n ) ) & 0xF ) << 12 ) )
/**
* @internal Macro helper for getting trace event parameter count.
*/
#define TRC_EVENT_GET_PARAM_COUNT( id ) ( ( ( id ) >> 12 ) & 0xF )
#if ( TRC_CFG_CORE_COUNT > 1 )
#define TRC_EVENT_SET_EVENT_COUNT( c ) ( ( ( TRC_CFG_GET_CURRENT_CORE() & 0xF ) << 12 ) | ( ( uint16_t ) ( c ) & 0xFFF ) )
#else
#define TRC_EVENT_SET_EVENT_COUNT( c ) ( uint16_t ) ( c )
#endif
/**
* @internal Macro helpder for setting base event data.
*/
#define SET_BASE_EVENT_DATA( pxEvent, eventId, paramCount, eventCount ) \
( \
( pxEvent )->EventID = TRC_EVENT_SET_PARAM_COUNT( eventId, paramCount ), \
( pxEvent )->EventCount = TRC_EVENT_SET_EVENT_COUNT( eventCount ), \
xTraceTimestampGet( &( pxEvent )->TS ) \
)
/**
* @internal Macro helper for resetting trace event data.
*/
#define RESET_EVENT_DATA( p ) \
( \
( p )->pvBlob = 0, \
( p )->size = 0, \
( p )->offset = 0 \
)
/**
* @internal Macro optimization for getting trace event size.
*/
#define TRC_EVENT_GET_SIZE( pvAddress, puiSize ) ( *( uint32_t * ) ( puiSize ) = sizeof( TraceBaseEvent_t ) + ( TRC_EVENT_GET_PARAM_COUNT( ( ( TraceBaseEvent_t * ) ( pvAddress ) )->EventID ) ) * sizeof( uint32_t ), TRC_SUCCESS )
/**
* @internal Macro optimization for getting trace event data pointer with an offset.
*/
#define TRC_EVENT_GET_RAW_DATA( xEventHandle, uiOffset, uiSize, ppvData ) ( ( void ) ( uiSize ), *( void ** ) ( ppvData ) = ( void * ) &( ( uint8_t * ) ( ( TraceEventData_t * ) ( xEventHandle ) )->pvBlob )[ uiOffset ], TRC_SUCCESS )
/**
* @internal Macro optimization for getting trace event payload pointer with an offset.
*/
#define TRC_EVENT_GET_PAYLOAD( xEventHandle, uiOffset, uiSize, ppvData ) ( ( void ) ( uiSize ), *( void ** ) ( ppvData ) = ( void * ) &( ( uint8_t * ) ( ( TraceEventData_t * ) ( xEventHandle ) )->pvBlob )[ sizeof( TraceBaseEvent_t ) + ( uiOffset ) ], TRC_SUCCESS )
/**
* @internal Macro optimization for getting trace event remaining payload size.
*/
#define TRC_EVENT_PAYLOAD_REMAINING( xEventHandle, puiValue ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( *( uint32_t * ) ( puiValue ) = ( ( TraceEventData_t * ) ( xEventHandle ) )->size - ( ( TraceEventData_t * ) ( xEventHandle ) )->offset, TRC_SUCCESS )
/**
* @internal Macro optimization for getting trace event used payload size.
*/
#define TRC_EVENT_PAYLOAD_USED( xEventHandle, puiValue ) ( *( uint32_t * ) ( puiValue ) = ( ( TraceEventData_t * ) ( xEventHandle ) )->offset - sizeof( TraceBaseEvent_t ), TRC_SUCCESS )
/**
* @internal Macro optimization getting trace event payload size.
*/
#define TRC_EVENT_PAYLOAD_SIZE( xEventHandle, puiValue ) ( *( uint32_t * ) ( puiValue ) = ( ( TraceEventData_t * ) ( xEventHandle ) )->size - sizeof( TraceBaseEvent_t ), TRC_SUCCESS )
/**
* @internal Macro optimization for adding a pointer address to trace event.
*/
#define TRC_EVENT_ADD_POINTER( xEventHandle, value ) \
TRC_COMMA_EXPR_TO_STATEMENT_EXPR_3( \
( ( void ** ) ( ( TraceEventData_t * ) ( xEventHandle ) )->pvBlob )[ ( ( TraceEventData_t * ) ( xEventHandle ) )->offset / sizeof( void * ) ] = ( value ), \
( ( TraceEventData_t * ) ( xEventHandle ) )->offset += sizeof( void * ), \
TRC_SUCCESS \
)
/**
* @internal Macro optimization for adding a unsigned base type to trace event.
*/
#define TRC_EVENT_ADD_UNSIGNED_BASE_TYPE( xEventHandle, value ) \
TRC_COMMA_EXPR_TO_STATEMENT_EXPR_3( \
( ( TraceUnsignedBaseType_t * ) ( ( TraceEventData_t * ) ( xEventHandle ) )->pvBlob )[ ( ( TraceEventData_t * ) ( xEventHandle ) )->offset / sizeof( TraceUnsignedBaseType_t ) ] = ( value ), \
( ( TraceEventData_t * ) ( xEventHandle ) )->offset += sizeof( TraceUnsignedBaseType_t ), \
TRC_SUCCESS \
)
/**
* @internal Macro optimization for adding a 32-bit value to trace event.
*/
#define TRC_EVENT_ADD_32( xEventHandle, value ) \
TRC_COMMA_EXPR_TO_STATEMENT_EXPR_3( \
( ( uint32_t * ) ( ( TraceEventData_t * ) ( xEventHandle ) )->pvBlob )[ ( ( TraceEventData_t * ) ( xEventHandle ) )->offset / sizeof( uint32_t ) ] = ( value ), \
( ( TraceEventData_t * ) ( xEventHandle ) )->offset += sizeof( uint32_t ), \
TRC_SUCCESS \
)
/**
* @internal Macro optimization for adding a 16-bit value to trace event.
*/
#define TRC_EVENT_ADD_16( xEventHandle, value ) \
TRC_COMMA_EXPR_TO_STATEMENT_EXPR_3( \
( ( uint16_t * ) ( ( TraceEventData_t * ) ( xEventHandle ) )->pvBlob )[ ( ( TraceEventData_t * ) ( xEventHandle ) )->offset / sizeof( uint16_t ) ] = ( value ), \
( ( TraceEventData_t * ) ( xEventHandle ) )->offset += sizeof( uint16_t ), \
TRC_SUCCESS \
)
/**
* @internal Macro optimization for adding a 8-bit value to trace event.
*/
#define TRC_EVENT_ADD_8( xEventHandle, value ) \
TRC_COMMA_EXPR_TO_STATEMENT_EXPR_3( \
( ( uint8_t * ) ( ( TraceEventData_t * ) ( xEventHandle ) )->pvBlob )[ ( ( TraceEventData_t * ) ( xEventHandle ) )->offset / sizeof( uint8_t ) ] = ( value ), \
( ( TraceEventData_t * ) ( xEventHandle ) )->offset += sizeof( uint8_t ), \
TRC_SUCCESS \
)
/**
* @internal Macro optimization for beginning an offline trace event.
*/
#define TRC_EVENT_BEGIN_OFFLINE( uiEventCode, uiPayloadSize, pxEventHandle ) \
( \
( xTraceEventBeginRawOffline( sizeof( TraceBaseEvent_t ) + ( uiPayloadSize ), pxEventHandle ) ) == TRC_SUCCESS ? \
( \
pxTraceEventDataTable->coreEventData[ TRC_CFG_GET_CURRENT_CORE() ].eventCounter++, \
SET_BASE_EVENT_DATA( ( TraceBaseEvent_t * ) ( ( ( TraceEventData_t * ) *( pxEventHandle ) )->pvBlob ), \
uiEventCode, \
( ( ( TraceEventData_t * ) *( pxEventHandle ) )->size - sizeof( TraceBaseEvent_t ) ) / sizeof( uint32_t ), \
pxTraceEventDataTable->coreEventData[ TRC_CFG_GET_CURRENT_CORE() ].eventCounter ), \
( ( TraceEventData_t * ) *( pxEventHandle ) )->offset += sizeof( TraceBaseEvent_t ), \
TRC_SUCCESS \
) : TRC_FAIL \
)
/**
* @internal Macro optimization for ending an offline trace event.
*/
#define TRC_EVENT_END_OFFLINE( xEventHandle ) \
TRC_COMMA_EXPR_TO_STATEMENT_EXPR_4( \
xTraceStreamPortCommit( ( ( TraceEventData_t * ) ( xEventHandle ) )->pvBlob, \
( ( TraceEventData_t * ) ( xEventHandle ) )->size, &DUMMY_iTraceBytesCommitted ), \
RESET_EVENT_DATA( ( TraceEventData_t * ) ( xEventHandle ) ), \
TRC_SUCCESS \
)
/**
* @internal Trace Base Event Structure
*/
typedef struct
{
uint16_t EventID; /**< */
uint16_t EventCount; /**< */
uint32_t TS; /**< */
} TraceBaseEvent_t;
/**
* @internal Trace Event Data Structure
*/
typedef struct TraceEventData
{
void * pvBlob; /**< */
uint32_t size; /**< */
uint32_t offset; /**< */
} TraceEventData_t;
/**
* @internal Trace Core Event Data Structure
*/
typedef struct TraceCoreEventData
{
TraceEventData_t eventData[ ( TRC_CFG_MAX_ISR_NESTING ) + 1 ]; /**< */
uint32_t eventCounter; /**< */
} TraceCoreEventData_t;
/**
* @internal Trace Event Data Table Structure.
*/
typedef struct TraceEventDataTable
{
TraceCoreEventData_t coreEventData[ TRC_CFG_CORE_COUNT ]; /**< Holds data about current event for each core/isr depth */
} TraceEventDataTable_t;
#define TRC_EVENT_DATA_BUFFER_SIZE ( sizeof( TraceEventDataTable_t ) )
/**
* @internal Trace Event Data Buffer Structure.
*/
typedef struct TraceEventDataBuffer
{
uint8_t buffer[ TRC_EVENT_DATA_BUFFER_SIZE ]; /**< */
} TraceEventDataBuffer_t;
extern TraceEventDataTable_t * pxTraceEventDataTable;
/**
* @internal Initialize event trace system.
*
* @param[in] pxBuffer Pointer to memory that will be used by the event
* trace system.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEventInitialize( TraceEventDataBuffer_t * pxBuffer );
/**
* @brief Gets trace event size.
*
* @param[in] pvAddress Pointer to initialized trace event.
* @param[out] puiSize Size.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEventGetSize( void * pvAddress,
uint32_t * puiSize );
/**
* @internal Begins a raw trace event offline.
*
* This routine begins a trace event with specified size. Must call xTraceEventEnd()
* to finalize event creation. Does not care about RecorderEnabled.
*
* @param[in] uiSize Size.
* @param[in] pxEventHandle Pointer to initialized trace event.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEventBeginRawOffline( uint32_t uiSize,
TraceEventHandle_t * pxEventHandle );
/**
* @internal Begins a blocking trace event offline.
*
* This routine begins a trace event with specified size. Must call xTraceEventEnd()
* to finalize event creation. Does not care about RecorderEnabled.
*
* @param[in] uiSize Size.
* @param[in] pxEventHandle Pointer to initialized trace event.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEventBeginRawOfflineBlocking( uint32_t uiSize,
TraceEventHandle_t * pxEventHandle );
/**
* @internal Begins a trace event offline.
*
* This routine begins a trace event with specified size. Must call xTraceEventEnd()
* to finalize event creation. Does not care about RecorderEnabled.
*
* @param[in] uiSize Size.
* @param[in] pxEventHandle Pointer to initialized trace event.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceEventBeginOffline TRC_EVENT_BEGIN_OFFLINE
/**
* @brief Begins a trace event.
*
* This routine begins a trace event with specified size. Must call xTraceEventEnd()
* to finalize event creation. Does not care about RecorderEnabled.
*
* @param[in] uiSize Size.
* @param[in] pxEventHandle Pointer to initialized trace event.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceEventBegin( uiEventCode, uiTotalPayloadSize, pxEventHandle ) \
( xTraceIsRecorderEnabled() ? xTraceEventBeginOffline( uiEventCode, uiTotalPayloadSize, pxEventHandle ) : TRC_FAIL )
/**
* @internal Ends a trace event offline.
*
* This routine ends the event that was begun by calling on xTraceEventBegin().
* Does not care about uiRecorderEnabled.
*
* @param[in] xEventHandle Pointer to initialized trace event.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEventEndOffline( TraceEventHandle_t xEventHandle );
/**
* @internal Ends a blocking event offline.
*
* Ends the event that was begun by calling on xTraceEventBegin()
*
* @param[in] xEventHandle Pointer to initialized trace event.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEventEndOfflineBlocking( TraceEventHandle_t xEventHandle );
/**
* @brief Ends a trace event.
*
* This routine ends the event that was begun by calling on xTraceEventBegin().
* Does not care about uiRecorderEnabled.
*
* @param[in] xEventHandle Pointer to initialized trace event.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceEventEnd( xEventHandle ) \
( xTraceIsRecorderEnabled() == 0 ? TRC_FAIL : xTraceEventEndOffline( xEventHandle ) )
/**
* @brief Adds data to event payload.
*
* @param[in] xEventHandle Pointer to initialized trace event.
* @param[in] pvData Pointer to data.
* @param[in] uiSize Size.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEventAddData( TraceEventHandle_t xEventHandle,
void * pvData,
uint32_t uiSize );
#if ( ( TRC_CFG_USE_TRACE_ASSERT ) == 1 )
/**
* @brief Gets trace event data pointer with an offset.
*
* This routine gets a trace event data pointer with an offset. It also verfies
* that the size so it won't go outside its buffer.
*
* @param[in] xEventHandle Pointer to initialized trace event.
* @param[in] uiOffset Offset.
* @param[in] uiSize Size.
* @param[out] ppvData Data.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEventGetRawData( TraceEventHandle_t xEventHandle,
uint32_t uiOffset,
uint32_t uiSize,
void ** ppvData );
/**
* @brief Gets trace event payload pointer with an offset.
*
* This routine gets a trace event payload pointer with an offset. It also verifies
* that the size so it won't go outside its payload buffer.
*
* @param[in] xEventHandle Pointer to initialized trace event.
* @param[in] uiOffset Offset.
* @param[in] uiSize Size.
* @param[out] ppvData Data.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEventGetPayload( TraceEventHandle_t xEventHandle,
uint32_t uiOffset,
uint32_t uiSize,
void ** ppvData );
/**
* @brief Gets the amount of remaining trace event payload.
*
* @param[in] xEventHandle Pointer to initialized trace event.
* @param[out] puiValue Value.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEventPayloadRemaining( TraceEventHandle_t xEventHandle,
uint32_t * puiValue );
/**
* @brief Gets the amount of used trace event payload.
*
* @param[in] xEventHandle Pointer to initialized trace event.
* @param[out] puiValue Value
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEventPayloadUsed( TraceEventHandle_t xEventHandle,
uint32_t * puiValue );
/**
* @brief Gets trace event payload size.
*
* @param[in] xEventHandle Pointer to initialized trace event.
* @param[out] puiValue Value
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEventPayloadSize( TraceEventHandle_t xEventHandle,
uint32_t * puiValue );
/**
* @brief Adds an unsigned base type value as trace event payload
*
* @param[in] xEventHandle Pointer to initialized trace event.
* @param[in] uxValue Value.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEventAddUnsignedBaseType( TraceEventHandle_t xEventHandle,
TraceUnsignedBaseType_t uxValue );
/**
* @brief Adds a pointer address as trace event payload
*
* @param[in] xEventHandle Pointer to initialized trace event.
* @param[in] pvAddress Address.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEventAddPointer( TraceEventHandle_t xEventHandle,
void * pvAddress );
/**
* @brief Adds an uint32_t as trace event payload
*
* @param[in] xEventHandle Pointer to initialized trace event.
* @param[in] value Value.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEventAdd32( TraceEventHandle_t xEventHandle,
uint32_t value );
/**
* @brief Adds an uint16_t as trace event payload
*
* @param[in] xEventHandle Pointer to initialized trace event.
* @param[in] value Value.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEventAdd16( TraceEventHandle_t xEventHandle,
uint16_t value );
/**
* @brief Adds an uint8_t as trace event payload.
*
* @param[in] xEventHandle Pointer to initialized trace event.
* @param[in] value Value.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEventAdd8( TraceEventHandle_t xEventHandle,
uint8_t value );
#else /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */
/**
* @brief Gets trace event size.
*
* @param[in] pvAddress Pointer to initialized trace event.
* @param[out] puiSize Size.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceEventGetSize( pvAddress, puiSize ) ( *( uint32_t * ) ( puiSize ) = sizeof( TraceBaseEvent_t ) + ( TRC_EVENT_GET_PARAM_COUNT( ( ( TraceBaseEvent_t * ) ( pvAddress ) )->EventID ) ) * sizeof( uint32_t ), TRC_SUCCESS )
/**
* @brief Gets trace event data pointer with an offset.
*
* This routine gets a trace event data pointer with an offset. It also verfies
* that the size so it won't go outside its buffer.
*
* @param[in] xEventHandle Pointer to initialized trace event.
* @param[in] uiOffset Offset.
* @param[in] uiSize Size.
* @param[out] ppvData Data.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceEventGetRawData TRC_EVENT_GET_RAW_DATA
/**
* @brief Gets trace event payload pointer with an offset.
*
* This routine gets a trace event payload pointer with an offset. It also verifies
* that the size so it won't go outside its payload buffer.
*
* @param[in] xEventHandle Pointer to initialized trace event.
* @param[in] uiOffset Offset.
* @param[in] uiSize Size.
* @param[out] ppvData Data.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceEventGetPayload TRC_EVENT_GET_PAYLOAD
/**
* @brief Gets the amount of remaining trace event payload.
*
* @param[in] xEventHandle Pointer to initialized trace event.
* @param[out] puiValue Value.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceEventPayloadRemaining TRC_EVENT_PAYLOAD_REMAINING
/**
* @brief Gets the amount of used trace event payload.
*
* @param[in] xEventHandle Pointer to initialized trace event.
* @param[out] puiValue Value
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceEventPayloadUsed TRC_EVENT_PAYLOAD_USED
/**
* @brief Gets trace event payload size.
*
* @param[in] xEventHandle Pointer to initialized trace event.
* @param[out] puiValue Value
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceEventPayloadSize TRC_EVENT_PAYLOAD_SIZE
/* Adds a pointer as event payload with no errors checks */
#define xTraceEventAddPointer TRC_EVENT_ADD_POINTER
/**
* @brief Adds an unsigned base type value as trace event payload
*
* @param[in] xEventHandle Pointer to initialized trace event.
* @param[in] uxValue Value.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceEventAddUnsignedBaseType TRC_EVENT_ADD_UNSIGNED_BASE_TYPE
/**
* @brief Adds an uint32_t as trace event payload
*
* @param[in] xEventHandle Pointer to initialized trace event.
* @param[in] value Value.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceEventAdd32 TRC_EVENT_ADD_32
/**
* @brief Adds an uint16_t as trace event payload
*
* @param[in] xEventHandle Pointer to initialized trace event.
* @param[in] value Value.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceEventAdd16 TRC_EVENT_ADD_16
/**
* @brief Adds an uint8_t as trace event payload.
*
* @param[in] xEventHandle Pointer to initialized trace event.
* @param[in] value Value.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceEventAdd8 TRC_EVENT_ADD_8
#endif /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
#endif /* TRC_EVENT_H */

@ -1,138 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
*
* @brief Public trace event buffer APIs.
*/
#ifndef TRC_EVENT_BUFFER_H
#define TRC_EVENT_BUFFER_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <trcTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup trace_event_buffer_apis Trace Event Buffer APIs
* @ingroup trace_recorder_apis
* @{
*/
/**
* @def TRC_EVENT_BUFFER_OPTION_SKIP
* @brief Buffer should skip new events when full
*/
#define TRC_EVENT_BUFFER_OPTION_SKIP ( 0U )
/**
* @def TRC_EVENT_BUFFER_OPTION_OVERWRITE
* @brief Buffer should overwrite old events when full
*/
#define TRC_EVENT_BUFFER_OPTION_OVERWRITE ( 1U )
/**
* @brief Trace Event Buffer Structure
*/
typedef struct TraceEventBuffer
{
uint32_t uiHead; /**< Head index of buffer */
uint32_t uiTail; /**< Tail index of buffer */
uint32_t uiSize; /**< Buffer size */
uint32_t uiOptions; /**< Options (skip/overwrite when full) */
uint32_t uiDroppedEvents; /**< Nr of dropped events */
uint32_t uiFree; /**< Nr of free bytes */
uint32_t uiTimerWraparounds; /**< Nr of timer wraparounds */
uint8_t * puiBuffer; /**< Trace Event Buffer: may be NULL */
} TraceEventBuffer_t;
/**
* @internal Initialize trace event buffer.
*
* This routine initializes a trace event buffer and assigns it a
* memory area based on the supplied buffer.
*
* Trace event buffer options specifies the buffer behavior regarding
* old data, the alternatives are TRC_EVENT_BUFFER_OPTION_SKIP and
* TRC_EVENT_BUFFER_OPTION_OVERWRITE (mutual exclusive).
*
* @param[out] pxTraceEventBuffer Pointer to uninitialized trace event buffer.
* @param[in] uiOptions Trace event buffer options.
* @param[in] puiBuffer Pointer to buffer that will be used by the trace event buffer.
* @param[in] uiSize Size of buffer
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEventBufferInitialize( TraceEventBuffer_t * pxTraceEventBuffer,
uint32_t uiOptions,
uint8_t * puiBuffer,
uint32_t uiSize );
/**
* @brief Pushes data into trace event buffer.
*
* This routine attempts to push data into the trace event buffer.
*
* @param[in] pxTraceEventBuffer Pointer to initialized trace event buffer.
* @param[in] pxData Pointer to data that should be pushed into trace event buffer.
* @param[in] uiSize Size of data.
* @param[out] piBytesWritten Bytes written.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEventBufferPush( TraceEventBuffer_t * pxTraceEventBuffer,
void * pxData,
uint32_t uiSize,
int32_t * piBytesWritten );
/**
* @brief Transfer trace event buffer data through streamport.
*
* This routine will attempt to transfer all existing data in the trace event
* buffer through the streamport. New data pushed to the trace event buffer
* during the execution of this routine will not be transferred to
*
* @param[in] pxTraceEventBuffer Pointer to initialized trace event buffer.
* @param[out] piBytesWritten Bytes written.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEventBufferTransfer( TraceEventBuffer_t * pxTraceEventBuffer,
int32_t * piBytesWritten );
/**
* @brief Clears all data from event buffer.
*
* @param[in] pxTraceEventBuffer Pointer to initialized trace event buffer.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceEventBufferClear( TraceEventBuffer_t * pxTraceEventBuffer );
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
#endif /* TRC_EVENT_BUFFER_H */

@ -1,102 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
*
* @brief Public trace extension APIs.
*/
#ifndef TRC_EXTENSION_H
#define TRC_EXTENSION_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <trcTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup trace_extension_apis Trace Extension APIs
* @ingroup trace_recorder_apis
* @{
*/
/**
* @brief Creates trace extension.
*
* @param[in] szName Name.
* @param[in] uiMajor Major version.
* @param[in] uiMinor Minor version.
* @param[in] uiPatch Patch version.
* @param[in] uiEventCount Event count.
* @param[out] pxExtensionHandle Pointer to uninitialized extension handle.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceExtensionCreate( const char * szName,
uint8_t uiMajor,
uint8_t uiMinor,
uint16_t uiPatch,
uint32_t uiEventCount,
TraceExtensionHandle_t * pxExtensionHandle );
/**
* @brief Gets extension base event id.
*
* @param[in] xExtensionHandle Pointer to initialized extension handle.
* @param[out] puiBaseEventId Base event id.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceExtensionGetBaseEventId( TraceExtensionHandle_t xExtensionHandle,
uint32_t * puiBaseEventId );
/**
* @brief Gets extension event id.
*
* @param[in] xExtensionHandle Pointer to initialized extension handle.
* @param[in] uiLocalEventId Local event id.
* @param[out] puiGlobalEventId Global event id.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceExtensionGetEventId( TraceExtensionHandle_t xExtensionHandle,
uint32_t uiLocalEventId,
uint32_t * puiGlobalEventId );
/**
* @brief Gets extension configuration name.
*
* @param[in] xExtensionHandle Pointer to initialized extension handle.
* @param[out] pszName Name.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceExtensionGetConfigName( TraceExtensionHandle_t xExtensionHandle,
const char ** pszName );
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
#endif /* TRC_EXTENSION_H */

@ -1,724 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The hardware abstraction layer for the trace recorder.
*/
#ifndef TRC_HARDWARE_PORT_H
#define TRC_HARDWARE_PORT_H
#include <trcDefines.h>
#if ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_NOT_SET )
#error "TRC_CFG_HARDWARE_PORT not selected - see trcConfig.h"
#endif
/*******************************************************************************
* TRC_IRQ_PRIORITY_ORDER
*
* Macro which should be defined as an integer of 0 or 1.
*
* This should be 0 if lower IRQ priority values implies higher priority
* levels, such as on ARM Cortex M. If the opposite scheme is used, i.e.,
* if higher IRQ priority values means higher priority, this should be 1.
*
* This setting is not critical. It is used only to sort and colorize the
* interrupts in priority order, in case you record interrupts using
* the vTraceStoreISRBegin and vTraceStoreISREnd routines.
*
******************************************************************************
*
* HWTC Macros
*
* These macros provides a hardware isolation layer representing the
* hardware timer/counter used for the event timestamping.
*
* TRC_HWTC_COUNT: How to read the current value of the timer/counter.
*
* TRC_HWTC_TYPE: Tells the type of timer/counter used for TRC_HWTC_COUNT:
*
* - TRC_FREE_RUNNING_32BIT_INCR:
* Free-running 32-bit timer/counter, counting upwards from 0.
*
* - TRC_FREE_RUNNING_32BIT_DECR
* Free-running 32-bit timer/counter, counting downwards from 0xFFFFFFFF.
*
* - TRC_OS_TIMER_INCR
* Periodic timer that drives the OS tick interrupt, counting upwards
* from 0 until (TRC_HWTC_PERIOD-1).
*
* - TRC_OS_TIMER_DECR
* Periodic timer that drives the OS tick interrupt, counting downwards
* from TRC_HWTC_PERIOD-1 until 0.
*
* - TRC_CUSTOM_TIMER_INCR
* A custom timer or counter independent of the OS tick, counting
* downwards from TRC_HWTC_PERIOD-1 until 0. (Currently only supported
* in streaming mode).
*
* - TRC_CUSTOM_TIMER_DECR
* A custom timer independent of the OS tick, counting downwards
* from TRC_HWTC_PERIOD-1 until 0. (Currently only supported
* in streaming mode).
*
* TRC_HWTC_PERIOD: The number of HWTC_COUNT ticks until the timer wraps
* around. If using TRC_FREE_RUNNING_32BIT_INCR/DECR, this should be 0.
*
* TRC_HWTC_FREQ_HZ: The clock rate of the TRC_HWTC_COUNT counter in Hz. If using
* TRC_OS_TIMER_INCR/DECR, this is should be TRC_HWTC_PERIOD * TRC_TICK_RATE_HZ.
* If using a free-running timer, this is often TRACE_CPU_CLOCK_HZ (if running at
* the core clock rate). If using TRC_CUSTOM_TIMER_INCR/DECR, this should match
* the clock rate of your custom timer (i.e., TRC_HWTC_COUNT). If the default value
* of TRC_HWTC_FREQ_HZ is incorrect for your setup, you can override it by calling
* vTraceSetFrequency before calling vTraceEnable.
*
* TRC_HWTC_DIVISOR (used in snapshot mode only):
* In snapshot mode, the timestamp resolution is TRC_HWTC_FREQ_HZ/TRC_HWTC_DIVISOR.
* If the timer frequency is very high (hundreds of MHz), we recommend increasing
* the TRC_HWTC_DIVISOR prescaler, to reduce the bandwidth needed to store
* timestamps. This since extra "XTS" events are inserted if the time since the
* previous event exceeds a certain limit (255 or 65535 depending on event type).
* It is advised to keep the time between most events below 65535 native ticks
* (after division by TRC_HWTC_DIVISOR) to avoid frequent XTS events.
******************************************************************************/
#if ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_NOT_SET )
#error "TRC_CFG_HARDWARE_PORT not selected - see trcConfig.h"
#endif
#if ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Win32 )
/* This can be used as a template for any free-running 32-bit counter */
void vTraceTimerReset( void );
uint32_t uiTraceTimerGetFrequency( void );
uint32_t uiTraceTimerGetValue( void );
#define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
#define TRC_HWTC_COUNT ( ( TraceUnsignedBaseType_t ) uiTraceTimerGetValue() )
#define TRC_HWTC_PERIOD 0
#define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ ( ( TraceUnsignedBaseType_t ) uiTraceTimerGetFrequency() )
#define TRC_IRQ_PRIORITY_ORDER 1
#define TRC_PORT_SPECIFIC_INIT() vTraceTimerReset()
#elif ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Win64 )
/* This can be used as a template for any free-running 32-bit counter */
void vTraceTimerReset( void );
uint32_t uiTraceTimerGetFrequency( void );
uint32_t uiTraceTimerGetValue( void );
#define TRC_BASE_TYPE int64_t
#define TRC_UNSIGNED_BASE_TYPE uint64_t
#define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
#define TRC_HWTC_COUNT ( ( TraceUnsignedBaseType_t ) uiTraceTimerGetValue() )
#define TRC_HWTC_PERIOD 0
#define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ ( ( TraceUnsignedBaseType_t ) uiTraceTimerGetFrequency() )
#define TRC_IRQ_PRIORITY_ORDER 1
#define TRC_PORT_SPECIFIC_INIT() vTraceTimerReset()
#elif ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_HWIndependent )
/* Timestamping by OS tick only (typically 1 ms resolution) */
#define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
#define TRC_HWTC_COUNT 0
#define TRC_HWTC_PERIOD 1
#define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ TRC_TICK_RATE_HZ
/* Set the meaning of IRQ priorities in ISR tracing - see above */
#define TRC_IRQ_PRIORITY_ORDER NOT_SET
#elif ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_ARM_Cortex_M )
#ifndef __CORTEX_M
#error "Can't find the CMSIS API. Please include your processor's header file in trcConfig.h"
#endif
#define TRACE_ALLOC_CRITICAL_SECTION() uint32_t __irq_status;
#define TRACE_ENTER_CRITICAL_SECTION() { __irq_status = __get_PRIMASK(); __set_PRIMASK( 1 ); } /* PRIMASK disables ALL interrupts - allows for tracing in any ISR */
#define TRACE_EXIT_CRITICAL_SECTION() { __set_PRIMASK( __irq_status ); }
/**************************************************************************
* For Cortex-M3, M4 and M7, the DWT cycle counter is used for timestamping.
* For Cortex-M0 and M0+, the SysTick timer is used since DWT is not
* available. Systick timestamping can also be forced on Cortex-M3, M4 and
* M7 by defining the preprocessor directive TRC_CFG_ARM_CM_USE_SYSTICK,
* either directly below or in trcConfig.h.
*
* #define TRC_CFG_ARM_CM_USE_SYSTICK
**************************************************************************/
#if ( ( __CORTEX_M >= 0x03 ) && ( !defined TRC_CFG_ARM_CM_USE_SYSTICK ) )
void xTraceHardwarePortInitCortexM( void );
#define TRC_REG_DEMCR ( *( volatile uint32_t * ) 0xE000EDFC )
#define TRC_REG_DWT_CTRL ( *( volatile uint32_t * ) 0xE0001000 )
#define TRC_REG_DWT_CYCCNT ( *( volatile uint32_t * ) 0xE0001004 )
#define TRC_REG_DWT_EXCCNT ( *( volatile uint32_t * ) 0xE000100C )
#define TRC_REG_ITM_LOCKACCESS ( *( volatile uint32_t * ) 0xE0001FB0 )
#define TRC_ITM_LOCKACCESS_UNLOCK ( 0xC5ACCE55 )
/* Bit mask for TRCENA bit in DEMCR - Global enable for DWT and ITM */
#define TRC_DEMCR_TRCENA ( 1 << 24 )
/* Bit mask for NOPRFCNT bit in DWT_CTRL. If 1, DWT_EXCCNT is not supported */
#define TRC_DWT_CTRL_NOPRFCNT ( 1 << 24 )
/* Bit mask for NOCYCCNT bit in DWT_CTRL. If 1, DWT_CYCCNT is not supported */
#define TRC_DWT_CTRL_NOCYCCNT ( 1 << 25 )
/* Bit mask for EXCEVTENA_ bit in DWT_CTRL. Set to 1 to enable DWT_EXCCNT */
#define TRC_DWT_CTRL_EXCEVTENA ( 1 << 18 )
/* Bit mask for EXCEVTENA_ bit in DWT_CTRL. Set to 1 to enable DWT_CYCCNT */
#define TRC_DWT_CTRL_CYCCNTENA ( 1 )
#define TRC_PORT_SPECIFIC_INIT() xTraceHardwarePortInitCortexM()
#define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
#define TRC_HWTC_COUNT TRC_REG_DWT_CYCCNT
#define TRC_HWTC_PERIOD 0
#define TRC_HWTC_DIVISOR 4
#define TRC_HWTC_FREQ_HZ TRACE_CPU_CLOCK_HZ
#define TRC_IRQ_PRIORITY_ORDER 0
#else /* if ( ( __CORTEX_M >= 0x03 ) && ( !defined TRC_CFG_ARM_CM_USE_SYSTICK ) ) */
#define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
#define TRC_HWTC_COUNT ( *( ( volatile uint32_t * ) 0xE000E018 ) )
#define TRC_HWTC_PERIOD ( ( *( ( volatile uint32_t * ) 0xE000E014 ) ) + 1 )
#define TRC_HWTC_DIVISOR 4
#define TRC_HWTC_FREQ_HZ TRACE_CPU_CLOCK_HZ
#define TRC_IRQ_PRIORITY_ORDER 0
#endif /* if ( ( __CORTEX_M >= 0x03 ) && ( !defined TRC_CFG_ARM_CM_USE_SYSTICK ) ) */
#elif ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Renesas_RX600 )
#define TRACE_ALLOC_CRITICAL_SECTION() TraceBaseType_t __x_irq_status;
#define TRACE_ENTER_CRITICAL_SECTION() { __x_irq_status = TRC_KERNEL_PORT_SET_INTERRUPT_MASK(); }
#define TRACE_EXIT_CRITICAL_SECTION() { TRC_KERNEL_PORT_CLEAR_INTERRUPT_MASK( __x_irq_status ); }
#include <iodefine.h>
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
#define TRC_HWTC_COUNT ( CMT0.CMCNT )
#elif ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT )
/* Decreasing counters better for Tickless Idle? */
#define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
#define TRC_HWTC_COUNT ( CMT0.CMCOR - CMT0.CMCNT )
#endif /* if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING ) */
#define TRC_HWTC_PERIOD ( CMT0.CMCOR + 1 )
#define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ ( TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD )
#define TRC_IRQ_PRIORITY_ORDER 1
#elif ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_MICROCHIP_PIC24_PIC32 )
#define TRACE_ALLOC_CRITICAL_SECTION() TraceBaseType_t __x_irq_status;
#define TRACE_ENTER_CRITICAL_SECTION() { __x_irq_status = TRC_KERNEL_PORT_SET_INTERRUPT_MASK(); }
#define TRACE_EXIT_CRITICAL_SECTION() { TRC_KERNEL_PORT_CLEAR_INTERRUPT_MASK( __x_irq_status ); }
#define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
#define TRC_HWTC_COUNT ( TMR1 )
#define TRC_HWTC_PERIOD ( PR1 + 1 )
#define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ ( TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD )
#define TRC_IRQ_PRIORITY_ORDER 1
#elif ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_TEXAS_INSTRUMENTS_TMS570_RM48 )
#define TRC_RTIFRC0 *( ( uint32_t * ) 0xFFFFFC10 )
#define TRC_RTICOMP0 *( ( uint32_t * ) 0xFFFFFC50 )
#define TRC_RTIUDCP0 *( ( uint32_t * ) 0xFFFFFC54 )
#define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
#define TRC_HWTC_COUNT ( TRC_RTIFRC0 - ( TRC_RTICOMP0 - TRC_RTIUDCP0 ) )
#define TRC_HWTC_PERIOD ( TRC_RTIUDCP0 )
#define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ ( TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD )
#define TRC_IRQ_PRIORITY_ORDER 0
#elif ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Atmel_AT91SAM7 )
/* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */
#define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
#define TRC_HWTC_COUNT ( ( uint32_t ) ( AT91C_BASE_PITC->PITC_PIIR & 0xFFFFF ) )
#define TRC_HWTC_PERIOD ( ( uint32_t ) ( AT91C_BASE_PITC->PITC_PIMR + 1 ) )
#define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ ( TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD )
#define TRC_IRQ_PRIORITY_ORDER 1
#elif ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Atmel_UC3A0 )
/* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO*/
/* For Atmel AVR32 (AT32UC3A) */
#define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
#define TRC_HWTC_COUNT ( ( uint32_t ) sysreg_read( AVR32_COUNT ) )
#define TRC_HWTC_PERIOD ( ( uint32_t ) ( sysreg_read( AVR32_COMPARE ) + 1 ) )
#define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ ( TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD )
#define TRC_IRQ_PRIORITY_ORDER 1
#elif ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_NXP_LPC210X )
/* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */
/* Tested with LPC2106, but should work with most LPC21XX chips. */
#define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
#define TRC_HWTC_COUNT *( ( uint32_t * ) 0xE0004008 )
#define TRC_HWTC_PERIOD *( ( uint32_t * ) 0xE0004018 )
#define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ ( TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD )
#define TRC_IRQ_PRIORITY_ORDER 0
#elif ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_TEXAS_INSTRUMENTS_MSP430 )
/* UNOFFICIAL PORT - NOT YET VERIFIED */
#define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
#define TRC_HWTC_COUNT ( TA0R )
#define TRC_HWTC_PERIOD ( ( ( uint16_t ) TACCR0 ) + 1 )
#define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ ( TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD )
#define TRC_IRQ_PRIORITY_ORDER 1
#elif ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XILINX_PPC405 )
/* UNOFFICIAL PORT - NOT YET VERIFIED */
#define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
#define TRC_HWTC_COUNT mfspr( 0x3db )
#define TRC_HWTC_PERIOD ( TRACE_CPU_CLOCK_HZ / TRC_TICK_RATE_HZ )
#define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ ( TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD )
#define TRC_IRQ_PRIORITY_ORDER 0
#elif ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XILINX_PPC440 )
/* UNOFFICIAL PORT */
/* This should work with most PowerPC chips */
#define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
#define TRC_HWTC_COUNT mfspr( 0x016 )
#define TRC_HWTC_PERIOD ( TRACE_CPU_CLOCK_HZ / TRC_TICK_RATE_HZ )
#define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ ( TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD )
#define TRC_IRQ_PRIORITY_ORDER 0
#elif ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XILINX_MICROBLAZE )
/* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */
/* This should work with most Microblaze configurations.
* It uses the AXI Timer 0 - the tick interrupt source.
* If an AXI Timer 0 peripheral is available on your hardware platform, no modifications are required.
*/
#include <xtmrctr_l.h>
#define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
#define TRC_HWTC_COUNT XTmrCtr_GetTimerCounterReg( XPAR_TMRCTR_0_BASEADDR, 0 )
#define TRC_HWTC_PERIOD ( XTmrCtr_GetLoadReg( XPAR_TMRCTR_0_BASEADDR, 0 ) + 1 )
#define TRC_HWTC_DIVISOR 16
#define TRC_HWTC_FREQ_HZ ( TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD )
#define TRC_IRQ_PRIORITY_ORDER 0
#elif ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XILINX_ZyncUltraScaleR5 )
extern int cortex_a9_r5_enter_critical( void );
extern void cortex_a9_r5_exit_critical( int irq_already_masked_at_enter );
#define TRACE_ALLOC_CRITICAL_SECTION() uint32_t __irq_mask_status;
#define TRACE_ENTER_CRITICAL_SECTION() { __irq_mask_status = cortex_a9_r5_enter_critical(); }
#define TRACE_EXIT_CRITICAL_SECTION() { cortex_a9_r5_exit_critical( __irq_mask_status ); }
#include <xttcps_hw.h>
#define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
#define TRC_HWTC_COUNT ( *( volatile uint32_t * ) ( configTIMER_BASEADDR + XTTCPS_COUNT_VALUE_OFFSET ) )
#define TRC_HWTC_PERIOD ( *( volatile uint32_t * ) ( configTIMER_BASEADDR + XTTCPS_INTERVAL_VAL_OFFSET ) )
#define TRC_HWTC_DIVISOR 16
#define TRC_HWTC_FREQ_HZ ( TRC_HWTC_PERIOD * TRC_TICK_RATE_HZ )
#define TRC_IRQ_PRIORITY_ORDER 0
#ifdef __GNUC__
/* For Arm Cortex-A and Cortex-R in general. */
static inline uint32_t prvGetCPSR( void )
{
unsigned long ret;
/* GCC-style assembly for getting the CPSR/APSR register, where the system execution mode is found. */
asm volatile ( " mrs %0, cpsr" : "=r" ( ret ) : /* no inputs */ );
return ret;
}
#else
#error "Only GCC Supported!"
#endif /* ifdef __GNUC__ */
#elif ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Altera_NiosII )
/* OFFICIAL PORT */
#include <system.h>
#include <altera_avalon_timer_regs.h>
#include <sys/alt_irq.h>
#define TRACE_ALLOC_CRITICAL_SECTION() alt_irq_context __irq_status;
#define TRACE_ENTER_CRITICAL_SECTION() { __irq_status = alt_irq_disable_all(); }
#define TRACE_EXIT_CRITICAL_SECTION() { alt_irq_enable_all( __irq_status ); }
#define NOT_SET 1
/* The base address for the system timer set.
* The name user for the system timer can be found in the BSP editor.
* If the name of the timer is sys_tmr SYSTEM_TIMER_BASE should be set to SYS_TMR_BASE.
*/
#define SYSTEM_TIMER_BASE NOT_SET
#if ( SYSTEM_TIMER == NOT_SET )
#error "Set SYSTEM_TIMER_BASE to the timer base used for system ticks."
#endif
static inline uint32_t altera_nios2_GetTimerSnapReg( void )
{
/* A processor can read the current counter value by first writing to either snapl or snaph to request a coherent snapshot of the counter,
* and then reading snapl and snaph for the full 32-bit value.
*/
IOWR_ALTERA_AVALON_TIMER_SNAPL( SYSTEM_TIMER_BASE, 0 );
return ( IORD_ALTERA_AVALON_TIMER_SNAPH( SYSTEM_TIMER_BASE ) << 16 ) | IORD_ALTERA_AVALON_TIMER_SNAPL( SYSTEM_TIMER_BASE );
}
#define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
#define TRC_HWTC_COUNT altera_nios2_GetTimerSnapReg()
#define TRC_HWTC_PERIOD ( configCPU_CLOCK_HZ / configTICK_RATE_HZ )
#define TRC_HWTC_DIVISOR 16
#define TRC_HWTC_FREQ_HZ ( TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD )
#define TRC_IRQ_PRIORITY_ORDER 0
#elif ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_ARM_CORTEX_A9 )
/**************************************************************************
* This hardware port only supports FreeRTOS and the GCC compiler at the
* moment, due to the implementation of critical sections (trcKernelPort.h).
*
* Assuming FreeRTOS is used:
*
* For critical sections, this uses vTaskEnterCritical is when called from
* task context and ulPortSetInterruptMask when called from ISR context.
* Thus, it does not disable all ISRs. This means that the trace recorder
* can only be called from ISRs with priority less or equal to
* configMAX_API_CALL_INTERRUPT_PRIORITY (like FreeRTOS fromISR functions).
*
* This hardware port has been tested on it a Xilinx Zync 7000 (Cortex-A9),
* but should work with all Cortex-A and R processors assuming that
* TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS is set accordingly.
**************************************************************************/
extern int cortex_a9_r5_enter_critical( void );
extern void cortex_a9_r5_exit_critical( int irq_already_masked_at_enter );
#define TRACE_ALLOC_CRITICAL_SECTION() uint32_t __irq_mask_status;
#define TRACE_ENTER_CRITICAL_SECTION() { __irq_mask_status = cortex_a9_r5_enter_critical(); }
#define TRACE_EXIT_CRITICAL_SECTION() { cortex_a9_r5_exit_critical( __irq_mask_status ); }
/* INPUT YOUR PERIPHERAL BASE ADDRESS HERE (0xF8F00000 for Xilinx Zynq 7000)*/
#define TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS 0
#if ( TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS == 0 )
#error "Please specify TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS."
#endif
#define TRC_CA9_MPCORE_PRIVATE_MEMORY_OFFSET 0x0600
#define TRC_CA9_MPCORE_PRIVCTR_PERIOD_REG ( *( volatile uint32_t * ) ( TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS + TRC_CA9_MPCORE_PRIVATE_MEMORY_OFFSET + 0x00 ) )
#define TRC_CA9_MPCORE_PRIVCTR_COUNTER_REG ( *( volatile uint32_t * ) ( TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS + TRC_CA9_MPCORE_PRIVATE_MEMORY_OFFSET + 0x04 ) )
#define TRC_CA9_MPCORE_PRIVCTR_CONTROL_REG ( *( volatile uint32_t * ) ( TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS + TRC_CA9_MPCORE_PRIVATE_MEMORY_OFFSET + 0x08 ) )
#define TRC_CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_MASK 0x0000FF00
#define TRC_CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_SHIFT 8
#define TRC_CA9_MPCORE_PRIVCTR_PRESCALER ( ( ( TRC_CA9_MPCORE_PRIVCTR_CONTROL_REG & TRC_CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_MASK ) >> TRC_CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_SHIFT ) + 1 )
#define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
#define TRC_HWTC_COUNT TRC_CA9_MPCORE_PRIVCTR_COUNTER_REG
#define TRC_HWTC_PERIOD ( TRC_CA9_MPCORE_PRIVCTR_PERIOD_REG + 1 )
/****************************************************************************************
* NOTE: The private timer ticks with a very high frequency (half the core-clock usually),
* depending on the prescaler used. If a low prescaler is used, the number of HW ticks between
* the trace events gets large, and thereby inefficient to store (sometimes extra events are
* needed). To improve efficiency, you may use the TRC_HWTC_DIVISOR as an additional prescaler.
*****************************************************************************************/
#define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ ( TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD )
#define TRC_IRQ_PRIORITY_ORDER 0
#ifdef __GNUC__
/* For Arm Cortex-A and Cortex-R in general. */
static inline uint32_t prvGetCPSR( void )
{
unsigned long ret;
/* GCC-style assembly for getting the CPSR/APSR register, where the system execution mode is found. */
asm volatile ( " mrs %0, cpsr" : "=r" ( ret ) : /* no inputs */ );
return ret;
}
#else
#error "Only GCC Supported!"
#endif /* ifdef __GNUC__ */
#elif ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_CYCLONE_V_HPS )
#include "alt_clock_manager.h"
extern int cortex_a9_r5_enter_critical( void );
extern void cortex_a9_r5_exit_critical( int irq_already_masked_at_enter );
#define TRACE_ALLOC_CRITICAL_SECTION() uint32_t __irq_mask_status;
#define TRACE_ENTER_CRITICAL_SECTION() { __irq_mask_status = cortex_a9_r5_enter_critical(); }
#define TRACE_EXIT_CRITICAL_SECTION() { cortex_a9_r5_exit_critical( __irq_mask_status ); }
#define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
#define TRC_HWTC_COUNT *( ( uint32_t * ) 0xFFFEC200 )
#define TRC_HWTC_PERIOD 0
#define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ \
( ( { \
uint32_t __freq; \
alt_clk_freq_get( ALT_CLK_MPU_PERIPH, &__freq ); \
__freq; \
} ) )
#define TRC_IRQ_PRIORITY_ORDER 0
#ifdef __GNUC__
/* For Arm Cortex-A and Cortex-R in general. */
static inline uint32_t prvGetCPSR( void )
{
unsigned long ret;
/* GCC-style assembly for getting the CPSR/APSR register, where the system execution mode is found. */
__asm__ __volatile__ ( " mrs %0, cpsr" : "=r" ( ret ) : /* no inputs */ );
return ret;
}
#else
#error "Only GCC Supported!"
#endif /* ifdef __GNUC__ */
#elif ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_ZEPHYR )
#define TRACE_ALLOC_CRITICAL_SECTION() int key;
#define TRACE_ENTER_CRITICAL_SECTION() { key = irq_lock(); }
#define TRACE_EXIT_CRITICAL_SECTION() { irq_unlock( key ); }
#define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
#define TRC_HWTC_COUNT k_cycle_get_32()
#define TRC_HWTC_PERIOD ( CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC / CONFIG_SYS_CLOCK_TICKS_PER_SEC )
#define TRC_HWTC_DIVISOR 4
#define TRC_HWTC_FREQ_HZ CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC
#define TRC_IRQ_PRIORITY_ORDER 0 /* Lower IRQ priority values are more significant */
#define TRC_PORT_SPECIFIC_INIT()
#elif ( ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XTensa_LX6 ) || ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XTensa_LX7 ) )
/**
* @note When running with SMP FreeRTOS we cannot use the CCOUNT register for timestamping,
* instead we use the external 40MHz timer for synchronized timestamping between the cores.
*/
#if CONFIG_FREERTOS_UNICORE == 1
#define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
#define TRC_HWTC_COUNT \
( { unsigned int __ccount; \
__asm__ __volatile__ ( "rsr.ccount %0" : "=a" ( __ccount ) ); \
__ccount; } )
#ifdef CONFIG_IDF_TARGET_ESP32
#define TRC_HWTC_FREQ_HZ ( CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ * 1000000 )
#elif defined( CONFIG_IDF_TARGET_ESP32S2 )
#define TRC_HWTC_FREQ_HZ ( CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ * 1000000 )
#else
#error "Invalid IDF target, check your sdkconfig."
#endif
#define TRC_HWTC_PERIOD 0
#define TRC_HWTC_DIVISOR 4
#define TRC_IRQ_PRIORITY_ORDER 0
#else /* if CONFIG_FREERTOS_UNICORE == 1 */
/**
* @brief Fetch core agnostic timestamp using the external 40MHz timer. This is used by tracerecorder
* when running with both cores.
*
* @return Ticks since the timer started
*/
uint32_t prvGetSMPTimestamp();
#define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
#define TRC_HWTC_COUNT prvGetSMPTimestamp()
#define TRC_HWTC_FREQ_HZ 40000000
#define TRC_HWTC_PERIOD 0
#define TRC_HWTC_DIVISOR 4
#define TRC_IRQ_PRIORITY_ORDER 0
#endif /* if CONFIG_FREERTOS_UNICORE == 1 */
#if !defined( TRC_HWTC_FREQ_HZ )
#error "The XTensa LX6/LX7 trace hardware clock frequency is not defined."
#endif
#elif ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_RISCV_RV32I )
#define TRACE_ALLOC_CRITICAL_SECTION() unsigned int __irq_status;
#define TRACE_ENTER_CRITICAL_SECTION() \
__asm__ __volatile__ ( "csrr %0, mstatus \n\t"\
"csrci mstatus, 8 \n\t"\
"andi %0, %0, 8 \n\t"\
: "=r" ( __irq_status ) )
#define TRACE_EXIT_CRITICAL_SECTION() \
__asm__ __volatile__ ( "csrr a1, mstatus \n\t"\
"or %0, %0, a1 \n\t"\
"csrs mstatus, %0 \n\t"\
: \
: "r" ( __irq_status ) \
: "a1" )
#define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
#define TRC_HWTC_COUNT \
( { unsigned int __count; \
__asm__ __volatile__ ( "rdcycle %0" : "=r" ( __count ) ); \
__count; } )
#define TRC_HWTC_PERIOD 0
#define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ 16000000
#define TRC_IRQ_PRIORITY_ORDER 0
#elif ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XMOS_XCOREAI )
#define TRC_PORT_SPECIFIC_INIT()
#define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
#define TRC_HWTC_COUNT xscope_gettime()
#define TRC_HWTC_PERIOD ( configCPU_CLOCK_HZ / configTICK_RATE_HZ )
#define TRC_HWTC_DIVISOR 4
#define TRC_HWTC_FREQ_HZ 100000000
#define TRC_IRQ_PRIORITY_ORDER 0
#elif ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_POWERPC_Z4 )
/* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */
#define TRACE_ALLOC_CRITICAL_SECTION() TraceBaseType_t __x_irq_status;
#define TRACE_ENTER_CRITICAL_SECTION() { __x_irq_status = TRC_KERNEL_PORT_SET_INTERRUPT_MASK(); }
#define TRACE_EXIT_CRITICAL_SECTION() { TRC_KERNEL_PORT_CLEAR_INTERRUPT_MASK( __x_irq_status ); }
#define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
/*#define HWTC_COUNT_DIRECTION DIRECTION_DECREMENTING */
#define TRC_HWTC_COUNT PIT.TIMER[ configTICK_PIT_CHANNEL ].CVAL.R /* must be the PIT channel used for the systick */
#define TRC_HWTC_PERIOD ( ( configPIT_CLOCK_HZ / configTICK_RATE_HZ ) - 1U ) /* TODO FIXME or maybe not -1? what's the right "period" value? */
#define TRC_HWTC_FREQ_HZ configPIT_CLOCK_HZ
#define TRC_HWTC_DIVISOR 1
#define TRC_IRQ_PRIORITY_ORDER 1 /* higher IRQ priority values are more significant */
#elif ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_APPLICATION_DEFINED )
#if !( defined( TRC_HWTC_TYPE ) && defined( TRC_HWTC_COUNT ) && defined( TRC_HWTC_PERIOD ) && defined( TRC_HWTC_FREQ_HZ ) && defined( TRC_IRQ_PRIORITY_ORDER ) )
#error "The hardware port is not completely defined!"
#endif
#elif ( TRC_CFG_HARDWARE_PORT != TRC_HARDWARE_PORT_NOT_SET )
#error "TRC_CFG_HARDWARE_PORT had unsupported value!"
#define TRC_CFG_HARDWARE_PORT TRC_HARDWARE_PORT_NOT_SET
#endif /* if ( TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Win32 ) */
#ifndef TRC_HWTC_DIVISOR
#define TRC_HWTC_DIVISOR 1
#endif
#ifndef TRC_PORT_SPECIFIC_INIT
#define TRC_PORT_SPECIFIC_INIT()
#endif
/* If Win32 port */
#ifdef WIN32
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0600
/* Standard includes. */
#include <stdio.h>
#include <windows.h>
#include <direct.h>
/***************************************************************************
* The Win32 port by default saves the trace to file and then kills the
* program when the recorder is stopped, to facilitate quick, simple tests
* of the recorder.
***************************************************************************/
#define WIN32_PORT_SAVE_WHEN_STOPPED 1
#define WIN32_PORT_EXIT_WHEN_STOPPED 1
#endif /* ifdef WIN32 */
#if ( TRC_CFG_HARDWARE_PORT != TRC_HARDWARE_PORT_NOT_SET )
#ifndef TRC_HWTC_TYPE
#error "TRC_HWTC_TYPE is not set!"
#endif
#ifndef TRC_HWTC_COUNT
#error "TRC_HWTC_COUNT is not set!"
#endif
#ifndef TRC_HWTC_PERIOD
#error "TRC_HWTC_PERIOD is not set!"
#endif
#ifndef TRC_HWTC_DIVISOR
#error "TRC_HWTC_DIVISOR is not set!"
#endif
#ifndef TRC_IRQ_PRIORITY_ORDER
#error "TRC_IRQ_PRIORITY_ORDER is not set!"
#elif ( TRC_IRQ_PRIORITY_ORDER != 0 ) && ( TRC_IRQ_PRIORITY_ORDER != 1 )
#error "TRC_IRQ_PRIORITY_ORDER has bad value!"
#endif
#if ( TRC_HWTC_DIVISOR < 1 )
#error "TRC_HWTC_DIVISOR must be a non-zero positive value!"
#endif
#ifndef TRC_HWTC_FREQ_HZ
#error "TRC_HWTC_FREQ_HZ not defined!"
#endif
#endif /* if ( TRC_CFG_HARDWARE_PORT != TRC_HARDWARE_PORT_NOT_SET ) */
#ifndef TRACE_ALLOC_CRITICAL_SECTION
#define TRACE_ALLOC_CRITICAL_SECTION() TRC_KERNEL_PORT_ALLOC_CRITICAL_SECTION()
#endif
#ifndef TRACE_ENTER_CRITICAL_SECTION
#define TRACE_ENTER_CRITICAL_SECTION() TRC_KERNEL_PORT_ENTER_CRITICAL_SECTION()
#endif
#ifndef TRACE_EXIT_CRITICAL_SECTION
#define TRACE_EXIT_CRITICAL_SECTION() TRC_KERNEL_PORT_EXIT_CRITICAL_SECTION()
#endif
#endif /*TRC_SNAPSHOT_HARDWARE_PORT_H*/

@ -1,146 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
*
* @brief Public trace heap APIs.
*/
#ifndef TRC_HEAP_H
#define TRC_HEAP_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#ifndef TRC_USE_HEAPS
#define TRC_USE_HEAPS 1
#endif
#if ( TRC_USE_HEAPS == 1 )
#include <trcTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup trace_heap_apis Trace Heap APIs
* @ingroup trace_recorder_apis
* @{
*/
/**
* @brief Creates trace heap.
*
* @param[in] szName Name.
* @param[in] uxCurrent Current level.
* @param[in] uxHighWaterMark High water mark
* @param[in] uxMax Maximum level.
* @param[out] pxHeapHandle Pointer to uninitialized trace heap handle.
* @return traceResult
*/
traceResult xTraceHeapCreate( const char * szName,
TraceUnsignedBaseType_t uxCurrent,
TraceUnsignedBaseType_t uxHighWaterMark,
TraceUnsignedBaseType_t uxMax,
TraceHeapHandle_t * pxHeapHandle );
/**
* @brief Signals trace heap alloc.
*
* @param[in] xHeapHandle Pointer to initialized trace heap handle.
* @param[in] pvAddress Address.
* @param[in] uxSize Size.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceHeapAlloc( TraceHeapHandle_t xHeapHandle,
void * pvAddress,
TraceUnsignedBaseType_t uxSize );
/**
* @brief Signals trace heap free.
*
* @param[in] xHeapHandle Pointer to initialized trace heap handle.
* @param[in] pvAddress Address.
* @param[in] uxSize Size.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceHeapFree( TraceHeapHandle_t xHeapHandle,
void * pvAddress,
TraceUnsignedBaseType_t uxSize );
/**
* @brief Gets trace heap current allocation size.
*
* @param[in] xHeapHandle Pointer to initialized trace heap handle.
* @param[out] puxCurrent Current.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceHeapGetCurrent( TraceHeapHandle_t xHeapHandle,
TraceUnsignedBaseType_t * puxCurrent );
/**
* @brief Gets trace heap high water mark.
*
* @param[in] xHeapHandle Pointer to initialized trace heap handle.
* @param[out] puxHighWaterMark High water mark.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceHeapGetHighWaterMark( TraceHeapHandle_t xHeapHandle,
TraceUnsignedBaseType_t * puxHighWaterMark );
/**
* @brief Gets trace heap max size.
*
* @param[in] xHeapHandle Pointer to initialized trace heap handle.
* @param[out] puxMax Max.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceHeapGetMax( TraceHeapHandle_t xHeapHandle,
TraceUnsignedBaseType_t * puxMax );
/** @} */
#ifdef __cplusplus
}
#endif
#else /* if ( TRC_USE_HEAPS == 1 ) */
#define xTraceHeapCreate( szName, uxCurrent, uxHighWaterMark, uxMax, pxHeapHandle ) ( ( void ) szName, ( void ) uxCurrent, ( void ) uxHighWaterMark, ( void ) uxMax, pxHeapHandle != 0 ? TRC_SUCCESS : TRC_FAIL )
#define xTraceHeapAlloc( xHeapHandle, pvAddress, uxSize ) ( ( void ) xHeapHandle, ( void ) pvAddress, ( void ) uxSize, TRC_SUCCESS )
#define xTraceHeapFree( xHeapHandle, pvAddress, uxSize ) ( ( void ) xHeapHandle, ( void ) pvAddress, ( void ) uxSize, TRC_SUCCESS )
#define xTraceHeapGetCurrent( xHeapHandle, puxCurrent ) ( ( void ) xHeapHandle, puxCurrent != 0 ? *puxCurrent = 0 : 0, puxCurrent != 0 ? TRC_SUCCESS : TRC_FAIL )
#define xTraceHeapGetHighWaterMark( xHeapHandle, puxHighWaterMark ) ( ( void ) xHeapHandle, puxHighWaterMark != 0 ? *puxHighWaterMark = 0 : 0, puxHighWaterMark != 0 ? TRC_SUCCESS : TRC_FAIL )
#define xTraceHeapGetMax( xHeapHandle, puxMax ) ( ( void ) xHeapHandle, puxMax != 0 ? *puxMax = 0 : 0, puxMax != 0 ? TRC_SUCCESS : TRC_FAIL )
#endif /* (TRC_USE_HEAPS == 1) */
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
#endif /* TRC_HEAP_H */

@ -1,229 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
*
* @brief Public trace ISR APIs.
*/
#ifndef TRC_ISR_H
#define TRC_ISR_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <trcTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup trace_isr_apis Trace ISR APIs
* @ingroup trace_recorder_apis
* @{
*/
/**
* @internal Trace ISR Core Info Structure
*/
typedef struct TraceISRCoreInfo
{
TraceISRHandle_t handleStack[ TRC_CFG_MAX_ISR_NESTING ]; /**< */
int32_t stackIndex; /**< */
int32_t isPendingContextSwitch; /**< */
} TraceISRCoreInfo_t;
/**
* @internal Trace ISR Info Structure
*/
typedef struct TraceISRInfo
{
TraceISRCoreInfo_t coreInfos[ TRC_CFG_CORE_COUNT ]; /* ISR handles */
} TraceISRInfo_t;
/* We expose this to enable faster access */
extern TraceISRInfo_t * pxTraceISRInfo;
#define TRACE_ISR_INFO_BUFFER_SIZE ( sizeof( TraceISRInfo_t ) )
/**
* @internal Trace ISR Info Buffer
*/
typedef struct TraceISRInfoBuffer
{
uint8_t buffer[ ( TRACE_ISR_INFO_BUFFER_SIZE ) ]; /**< */
} TraceISRInfoBuffer_t;
/**
* @internal Initialize ISR trace system.
*
* @param[in] pxBuffer Pointer to memory that will be used by the ISR
* trace system.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceISRInitialize( TraceISRInfoBuffer_t * pxBuffer );
/**
* @brief Registers trace ISR.
*
* This routine stores a name and priority level for an Interrupt Service Routine,
* to allow for better visualization. Returns a TraceISRHandle_t used by
* xTraceISRBegin/xTraceISREnd.
*
* Example:
* #define PRIO_OF_ISR_TIMER1 3 // the hardware priority of the interrupt
* TraceISRHandle_t xISRTimer1Handle = 0; // The ID set by the recorder
* ...
* xTraceISRRegister("ISRTimer1", PRIO_OF_ISR_TIMER1, &xISRTimer1Handle);
* ...
* void ISR_handler()
* {
* xTraceISRBegin(xISRTimer1Handle);
* ...
* xTraceISREnd(0);
* }
*
* @param[in] szName Name.
* @param[in] uiPriority Priority.
* @param[out] pxISRHandle Pointer to uninitialized ISR trace handle.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceISRRegister( const char * szName,
uint32_t uiPriority,
TraceISRHandle_t * pxISRHandle );
/**
* @brief Registers the beginning of an Interrupt Service Routine.
*
* This routine register the beginning of an ISR using a TraceISRHandle_t.
* See xTraceISRRegister for and example of using ISR tracing.
*
* @param[in] xISRHandle Pointer to initialized ISR trace handle.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceISRBegin( TraceISRHandle_t xISRHandle );
/**
* @brief Registers the end of an Interrupt Service Routine.
*
* This routine register the end of an ISR using a TraceISRHandle_t.
* See xTraceISRRegister for and example of using ISR tracing.
*
* The parameter uxIsTaskSwitchRequired indicates if the interrupt has requested
* a task-switch (= 1), e.g., by signaling a semaphore. Otherwise (= 0) the
* interrupt is assumed to return to the previous context.
*
* @param[in] xIsTaskSwitchRequired Task switch required.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceISREnd( TraceBaseType_t xIsTaskSwitchRequired );
#if ( ( TRC_CFG_USE_TRACE_ASSERT ) == 1 )
/**
* @brief Gets current trace ISR nesting level.
*
* This routine gets the current trace ISR nesting level for the
* CPU on which it is called.
*
* @param[out] puiValue Value.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceISRGetCurrentNesting( int32_t * puiValue );
/**
* @brief
*
* @return int32_t
*/
int32_t xTraceISRGetCurrentNestingReturned( void );
/**
* @brief Gets current ISR trace handle.
*
* @param[out] pxISRHandle ISR Handle.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceISRGetCurrent( TraceISRHandle_t * pxISRHandle );
#else /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */
/**
* @brief Gets current trace ISR nesting level.
*
* This routine gets the current trace ISR nesting level for the
* CPU on which it is called.
*
* @param[out] puiValue Value.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceISRGetCurrentNesting( puiValue ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( *( puiValue ) = pxTraceISRInfo->coreInfos[ TRC_CFG_GET_CURRENT_CORE() ].stackIndex, TRC_SUCCESS )
/**
* @brief
*
* @return int32_t
*/
#define xTraceISRGetCurrentNestingReturned() ( pxTraceISRInfo->coreInfos[ TRC_CFG_GET_CURRENT_CORE() ].stackIndex )
/**
* @brief Gets current trace ISR nesting level.
*
* This routine gets the current trace ISR nesting level for the
* CPU on which it is called.
*
* @param[out] puiValue Value.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceISRGetCurrent( pxISRHandle ) ( xTraceISRGetCurrentNestingReturned() >= 0 ? ( *( pxISRHandle ) = pxTraceISRInfo->coreInfos[ TRC_CFG_GET_CURRENT_CORE() ].handleStack[ xTraceISRGetCurrentNestingReturned() ], TRC_SUCCESS ) : TRC_FAIL )
#endif /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */
/** @internal Deprecated - Provides backwards-compability with older recorders for now, will be removed in the future */
TraceISRHandle_t xTraceSetISRProperties( const char * szName,
uint32_t uiPriority );
/** @internal Deprecated - Provides backwards-compability with older recorders for now, will be removed in the future */
#define xTraceGetCurrentISRNesting( puiValue ) xTraceISRGetCurrentNesting( puiValue )
/** @internal Deprecated - Provides backwards-compability with older recorders for now, will be removed in the future */
#define vTraceStoreISRBegin( xISRHandle ) xTraceISRBegin( xISRHandle )
/** @internal Deprecated - Provides backwards-compability with older recorders for now, will be removed in the future */
#define vTraceStoreISREnd( xIsTaskSwitchRequired ) xTraceISREnd( xIsTaskSwitchRequired )
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
#endif /* TRC_ISR_H */

@ -1,110 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
*
* @brief Public internal event buffer APIs.
*/
#ifndef TRC_INTERNAL_BUFFER_H
#define TRC_INTERNAL_BUFFER_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#ifndef TRC_USE_INTERNAL_BUFFER
#define TRC_USE_INTERNAL_BUFFER 1
#endif
#if ( TRC_USE_INTERNAL_BUFFER == 1 )
#include <trcTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup trace_internal_event_buffer_apis Trace Internal Event Buffer APIs
* @ingroup trace_recorder_apis
* @{
*/
/**
* @internal Initializes the internal trace event buffer used by certain stream ports.
*
* @param[in] puiBuffer Pointer to previously allocated memory buffer
* @param[in] uiSize Size of buffer
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceInternalEventBufferInitialize( uint8_t * puiBuffer,
uint32_t uiSize );
/**
* @brief Pushes data to the internal trace event buffer.
*
* @param[in] pvData Pointer to data
* @param[in] uiSize Size of data
* @param[out] piBytesWritten Bytes written.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceInternalEventBufferPush( void * pvData,
uint32_t uiSize,
int32_t * piBytesWritten );
/**
* @brief Transfers all internal trace event buffer data using the function
* xTraceStreamPortWriteData(...) as defined in trcStreamPort.h.
*
* This function is intended to be called by the periodic TzCtrl task with a
* suitable delay (e.g. 10-100 ms).
*
* In case of errors from the streaming interface, it registers a warning
* (TRC_WARNING_STREAM_PORT_WRITE) provided by xTraceErrorGetLast().
*
* @param[out] piBytesWritten Bytes written.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceInternalEventBufferTransfer( int32_t * piBytesWritten );
/**
* @brief Clears all trace events in the internal trace event buffer.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceInternalEventBufferClear( void );
/** @} */
#ifdef __cplusplus
}
#endif
#else /* (TRC_USE_INTERNAL_BUFFER == 1)*/
#define xTraceInternalEventBufferInitialize( puiBuffer, uiSize ) ( ( void ) uiSize, puiBuffer != 0 ? TRC_SUCCESS : TRC_FAIL )
#define xTraceInternalEventBufferPush( pvData, uiSize, piBytesWritten ) ( ( void ) uiSize, ( void ) piBytesWritten, pvData != 0 ? TRC_SUCCESS : TRC_FAIL )
#define xTraceInternalEventBufferTransfer( piBytesWritten ) ( ( void ) piBytesWritten, TRC_SUCCESS )
#define xTraceInternalEventBufferClear() ( void ) ( TRC_SUCCESS )
#endif /* (TRC_USE_INTERNAL_BUFFER == 1)*/
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
#endif /* TRC_INTERNAL_BUFFER_H */

@ -1,88 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
*
* @brief Public trace interval APIs.
*/
#ifndef TRC_INTERVAL_H
#define TRC_INTERVAL_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <trcTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup trace_interval_apis Trace Interval APIs
* @ingroup trace_recorder_apis
* @{
*/
/**
* @brief Creates trace interval.
*
* @param[in] szName Name.
* @param[out] pxIntervalHandle Pointer to uninitialized trace interval.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceIntervalCreate( const char * szName,
TraceIntervalHandle_t * pxIntervalHandle );
/**
* @brief Starts trace interval.
*
* @param[in] xIntervalHandle Pointer to initialized trace interval.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceIntervalStart( TraceIntervalHandle_t xIntervalHandle );
/**
* @brief Stops trace interval.
*
* @param[in] xIntervalHandle Pointer to initialized trace interval.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceIntervalStop( TraceIntervalHandle_t xIntervalHandle );
/**
* @brief Gets trace interval state.
*
* @param[in] xIntervalHandle Pointer to initialized trace interval.
* @param[out] puxState State.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceIntervalGetState( TraceIntervalHandle_t xIntervalHandle,
uint32_t * puxState );
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
#endif /* TRC_INTERVAL_H */

@ -1,149 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
*
* @internal Public trace multicore event buffer APIs.
*/
#ifndef TRC_MULTI_CORE_EVENT_BUFFER_H
#define TRC_MULTI_CORE_EVENT_BUFFER_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <trcTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup trace_multi_core_event_buffer_apis Trace Multi-Core Event Buffer APIs
* @ingroup trace_recorder_apis
* @{
*/
/**
* @brief Trace Multi-Core Event Buffer Structure
*/
typedef struct TraceMultiCoreEventBuffer
{
TraceEventBuffer_t * xEventBuffer[ TRC_CFG_CORE_COUNT ]; /**< */
} TraceMultiCoreEventBuffer_t;
/**
* @internal Initialize multi-core event buffer.
*
* This routine initializes a multi-core trace event buffer and assigns it
* a memory area based on the supplied buffer.
*
* Trace event buffer options specifies the buffer behavior regarding
* old data, the alternatives are TRC_EVENT_BUFFER_OPTION_SKIP and
* TRC_EVENT_BUFFER_OPTION_OVERWRITE (mutual exclusive).
*
* @param[out] pxTraceMultiCoreEventBuffer Pointer to uninitialized multi-core trace event buffer.
* @param[in] uiOptions Trace event buffer options.
* @param[in] puiBuffer Pointer to buffer that will be used by the multi-core trace event buffer.
* @param[in] uiSize Size of buffer.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceMultiCoreEventBufferInitialize( TraceMultiCoreEventBuffer_t * pxTraceMultiCoreEventBuffer,
uint32_t uiOptions,
uint8_t * puiBuffer,
uint32_t uiSize );
#if ( ( TRC_CFG_USE_TRACE_ASSERT ) == 1 )
/**
* @brief Pushes data into multi-core trace event buffer.
*
* This routine attempts to push data into the multi-core trace event buffer. Selection
* of which core the data is pushed for is managed automatically through the
* TRC_CFG_GET_CURRENT_CORE macro which is defined on an RTOS basis.
*
* @param[in] pxTraceMultiCoreEventBuffer Pointer to initialized multi-core event buffer.
* @param[in] pvData Pointer to data should be pushed into multi-core event buffer.
* @param[in] uiSize Size of data that should be pushed into multi-core trace event buffer.
* @param[out] piBytesWritten Pointer to variable which the routine will write the number
* of bytes that was pushed into the multi-core trace event buffer.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceMultiCoreEventBufferPush( TraceMultiCoreEventBuffer_t * pxTraceMultiCoreEventBuffer,
void * pvData,
uint32_t uiSize,
int32_t * piBytesWritten );
#else
/**
* @brief Pushes data into multi-core trace event buffer.
*
* This routine attempts to push data into the multi-core trace event buffer. Selection
* of which core the data is pushed for is managed automatically through the
* TRC_CFG_GET_CURRENT_CORE macro which is defined on an RTOS basis.
*
* @param[in] pxTraceMultiCoreEventBuffer Pointer to initialized multi-core event buffer.
* @param[in] pvData Pointer to data should be pushed into multi-core event buffer.
* @param[in] uiSize Size of data that should be pushed into multi-core trace event buffer.
* @param[out] piBytesWritten Pointer to variable which the routine will write the number
* of bytes that was pushed into the multi-core trace event buffer.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceMultiCoreEventBufferPush( pxTraceMultiCoreEventBuffer, pvData, uiSize, piBytesWritten ) xTraceEventBufferPush( ( pxTraceMultiCoreEventBuffer )->xEventBuffer[ TRC_CFG_GET_CURRENT_CORE() ], pvData, uiSize, piBytesWritten )
#endif /* if ( ( TRC_CFG_USE_TRACE_ASSERT ) == 1 ) */
/**
* @brief Transfer multi-core trace event buffer data through streamport.
*
* This routine will attempt to transfer all existing data in the multi-core trace event
* buffer through the streamport. New data pushed to the trace event buffer
* during the execution of this routine will not be transferred to
*
* @param[in] pxTraceMultiCoreEventBuffer Pointer to initialized multi-core event buffer.
* @param[out] piBytesWritten Pointer to variable which the routine will write the number
* of bytes that was pushed into the multi-core trace event buffer.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceMultiCoreEventBufferTransfer( TraceMultiCoreEventBuffer_t * pxTraceMultiCoreEventBuffer,
int32_t * piBytesWritten );
/**
* @brief Clears all data from event buffer.
*
* @param[in] pxTraceMultiCoreEventBuffer Pointer to initialized multi-core trace event buffer.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceMultiCoreEventBufferClear( TraceMultiCoreEventBuffer_t * pxTraceMultiCoreEventBuffer );
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
#endif /* TRC_MULTI_CORE_EVENT_BUFFER_H */

@ -1,224 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
*
* @brief Public trace object APIs.
*/
#ifndef TRC_OBJECT_H
#define TRC_OBJECT_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <trcTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup trace_object_apis Trace Object APIs
* @ingroup trace_recorder_apis
* @{
*/
/**
* @brief Registers trace object.
*
* @param[in] uiEventCode Event code.
* @param[in] pvObject Object.
* @param[in] szName Name.
* @param[in] uxStateCount State count.
* @param[in] uxStates States.
* @param[in] uxOptions Options.
* @param[out] pxObjectHandle Pointer to uninitialized trace object.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceObjectRegisterInternal( uint32_t uiEventCode,
void * pvObject,
const char * szName,
TraceUnsignedBaseType_t uxStateCount,
TraceUnsignedBaseType_t uxStates[],
TraceUnsignedBaseType_t uxOptions,
TraceObjectHandle_t * pxObjectHandle );
/**
* @brief Registers trace object.
*
* @param[in] uiEventCode Event code.
* @param[in] pvObject Object.
* @param[in] szName Name.
* @param[in] uxState State.
* @param[out] pxObjectHandle Pointer to uninitialized trace object.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceObjectRegister( uint32_t uiEventCode,
void * pvObject,
const char * szName,
TraceUnsignedBaseType_t uxState,
TraceObjectHandle_t * pxObjectHandle );
/**
* @brief Unregisters trace object.
*
* @param[in] xObjectHandle Pointer to initialized trace object.
* @param[in] uiEventCode Event code.
* @param[in] uxState State.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceObjectUnregister( TraceObjectHandle_t xObjectHandle,
uint32_t uiEventCode,
TraceUnsignedBaseType_t uxState );
/**
* @brief Sets trace object name.
*
* @param[in] xObjectHandle Pointer to initialized trace object.
* @param[in] szName Name.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceObjectSetName( TraceObjectHandle_t xObjectHandle,
const char * szName );
/**
* @brief Sets trace object state.
*
* @param[in] xObjectHandle Pointer to initialized trace object.
* @param[in] uxState State.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceObjectSetState( xObjectHandle, uxState ) xTraceObjectSetSpecificState( xObjectHandle, 0, uxState )
/**
* @brief Sets trace object specific state state.
*
* @param[in] xObjectHandle Pointer to initialized trace object.
* @param[in] uiIndex State Index.
* @param[in] uxState State.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceObjectSetSpecificState( xObjectHandle, uiIndex, uxState ) xTraceEntrySetState( ( TraceEntryHandle_t ) ( xObjectHandle ), uiIndex, uxState )
/**
* @brief Sets trace object options.
*
* @param[in] xObjectHandle Pointer to initialized trace object.
* @param[in] uiOptions Options.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceObjectSetOptions( xObjectHandle, uiOptions ) xTraceEntrySetOptions( ( TraceEntryHandle_t ) ( xObjectHandle ), uiOptions )
/**
* @brief Registers trace object without trace object handle.
*
* @param[in] uiEventCode Event code.
* @param[in] pvObject Object.
* @param[in] szName Name.
* @param[in] uxState State.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceObjectRegisterWithoutHandle( uint32_t uiEventCode,
void * pvObject,
const char * szName,
TraceUnsignedBaseType_t uxState );
/**
* @brief Unregisters trace object without trace object handle.
*
* @param[in] uiEventCode Event code.
* @param[in] pvObject Object.
* @param[in] uxState State.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceObjectUnregisterWithoutHandle( uint32_t uiEventCode,
void * pvObject,
TraceUnsignedBaseType_t uxState );
/**
* @brief Set trace object name without trace object handle.
*
* @param[in] pvObject Object.
* @param[in] szName Name.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceObjectSetNameWithoutHandle( void * pvObject,
const char * szName );
/**
* @brief Set trace object state without trace object handle.
*
* @param[in] pvObject Object.
* @param[in] uxState State.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceObjectSetStateWithoutHandle( pvObject, uxState ) xTraceObjectSetSpecificStateWithoutHandle( pvObject, 0, uxState )
/**
* @brief Sets trace object specific state without trace object
* handle.
*
* @param[in] pvObject Object.
* @param[in] uiIndex State index.
* @param[in] uxState State.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceObjectSetSpecificStateWithoutHandle( void * pvObject,
uint32_t uiIndex,
TraceUnsignedBaseType_t uxState );
/**
* @brief Sets trace object options without trace object handle.
*
* @param[in] pvObject Object.
* @param[in] uiOptions Options.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceObjectSetOptionsWithoutHandle( void * pvObject,
uint32_t uiOptions );
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
#endif /* TRC_OBJECT_H */

@ -1,213 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
*
* @brief Public trace print APIs.
*/
#ifndef TRC_PRINT_H
#define TRC_PRINT_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <stdarg.h>
#include <trcTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup trace_print_apis Trace Print APIs
* @ingroup trace_recorder_apis
* @{
*/
#if ( TRC_CFG_SCHEDULING_ONLY == 0 ) && ( TRC_CFG_INCLUDE_USER_EVENTS == 1 )
/** @internal */
#define TRC_PRINT_BUFFER_SIZE ( sizeof( TraceStringHandle_t ) + sizeof( TraceStringHandle_t ) )
/**
* @internal Trace Print Buffer Structure
*/
typedef struct TracePrintBuffer
{
uint32_t buffer[ ( TRC_PRINT_BUFFER_SIZE ) / sizeof( uint32_t ) ];
} TracePrintBuffer_t;
/**
* @internal Initialize print trace system.
*
* @param[in] pxBuffer Pointer to memory that will be used by the print
* trace system.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTracePrintInitialize( TracePrintBuffer_t * pxBuffer );
/**
* @brief Generate "User Events" with unformatted text.
*
* User Events can be used for very efficient application logging, and are shown
* as yellow labels in the main trace view.
*
* You may group User Events into User Event Channels. The yellow User Event
* labels shows the logged string, preceded by the channel name within
* brackets. For example:
*
* "[MyChannel] Hello World!"
*
* The User Event Channels are shown in the View Filter, which makes it easy to
* select what User Events you wish to display. User Event Channels are created
* using xTraceStringRegister().
*
* Example:
*
* TraceStringHandle_t xChannel = xTraceStringRegister("MyChannel");
* ...
* xTracePrint(xChannel, "Hello World!");
*
* @param[in] xChannel Channel.
* @param[in] szString String.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTracePrint( TraceStringHandle_t xChannel,
const char * szString );
/**
* @brief Wrapper for vTracePrintF for printing to default channel.
*
* Wrapper for vTracePrintF, using the default channel. Can be used as a drop-in
* replacement for printf and similar functions, e.g. in a debug logging macro.
*
* Example:
* // Old: #define LogString debug_console_printf
*
* // New, log to Tracealyzer instead:
* #define LogString xTraceConsoleChannelPrintF
* ...
* LogString("My value is: %d", myValue);
*
* @param[in] szFormat Format
* @param[in] ...
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceConsoleChannelPrintF( const char * szFormat,
... );
/**
* @brief Generates "User Events" with formatted text and data.
*
* Generates "User Events", with formatted text and data, similar to a "printf".
* It is very fast since the actual formatting is done on the host side when the
* trace is displayed.
*
* User Events can be used for very efficient application logging, and are shown
* as yellow labels in the main trace view.
* An advantage of User Events is that data can be plotted in the "User Event
* Signal Plot" view, visualizing any data you log as User Events, discrete
* states or control system signals (e.g. system inputs or outputs).
*
* You may group User Events into User Event Channels. The yellow User Event
* labels show the logged string, preceded by the channel name within brackets.
*
* Example:
*
* "[MyChannel] Hello World!"
*
* The User Event Channels are shown in the View Filter, which makes it easy to
* select what User Events you wish to display. User Event Channels are created
* using xTraceStringRegister().
*
* Example:
*
* TraceStringHandle_t adc_uechannel = xTraceStringRegister("ADC User Events");
* ...
* xTracePrintF(adc_uechannel,
* "ADC channel %d: %d volts",
* ch, adc_reading);
*
* All data arguments are assumed to be 32 bit wide. The following formats are
* supported:
* %d - signed integer. The following width and padding format is supported: "%05d" -> "-0042" and "%5d" -> " -42"
* %u - unsigned integer. The following width and padding format is supported: "%05u" -> "00042" and "%5u" -> " 42"
* %X - hexadecimal (uppercase). The following width and padding format is supported: "%04X" -> "002A" and "%4X" -> " 2A"
* %x - hexadecimal (lowercase). The following width and padding format is supported: "%04x" -> "002a" and "%4x" -> " 2a"
* %s - string (currently, this must be an earlier stored symbol name)
*
* Up to 15 data arguments are allowed, with a total size of maximum 60 byte
* including 8 byte for the base event fields and the format string. So with
* one data argument, the maximum string length is 48 chars. If this is exceeded
* the string is truncated (4 bytes at a time).
*
* @param[in] xChannel Channel.
* @param[in] szFormat Format.
* @param[in] ...
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTracePrintF( TraceStringHandle_t xChannel,
const char * szFormat,
... );
/**
* @brief Generates "User Events" with formatted text and data.
*
* @param[in] xChannel Channel.
* @param[in] szFormat Format.
* @param[in] xVL Variable list arguments.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceVPrintF( TraceStringHandle_t xChannel,
const char * szFormat,
va_list xVL );
#else /* (TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1) */
typedef struct TracePrintBuffer
{
uint32_t buffer[ 1 ];
} TracePrintBuffer_t;
#define xTracePrintInitialize( p ) ( ( void ) p, p != 0 ? TRC_SUCCESS : TRC_FAIL )
#define xTracePrint( c, s ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_3( ( void ) c, ( void ) s, TRC_SUCCESS )
#define xTracePrintF( c, s, ... ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_3( ( void ) c, ( void ) s, TRC_SUCCESS )
#define xTraceConsoleChannelPrintF( s, ... ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( ( void ) s, TRC_SUCCESS )
#define xTraceVPrintF( c, s, v ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_4( ( void ) c, ( void ) s, ( void ) v, TRC_SUCCESS )
#endif /* (TRC_CFG_SCHEDULING_ONLY == 0) && (TRC_CFG_INCLUDE_USER_EVENTS == 1) */
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
#endif /* TRC_PRINT_H */

@ -1,137 +0,0 @@
/*
* Percepio Trace Recorder SDK for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
*
* @brief Public trace stack monitor APIs.
*/
#ifndef TRC_STACK_MONITOR_H
#define TRC_STACK_MONITOR_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <stdint.h>
#include <trcRecorder.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup trace_stack_monitor_apis Trace Stack Monitor APIs
* @ingroup trace_recorder_apis
* @{
*/
#if ( ( ( TRC_CFG_ENABLE_STACK_MONITOR ) == 1 ) && ( ( TRC_CFG_SCHEDULING_ONLY ) == 0 ) )
#define TRACE_STACK_MONITOR_BUFFER_SIZE ( ( sizeof( void * ) + sizeof( TraceUnsignedBaseType_t ) ) * ( TRC_CFG_STACK_MONITOR_MAX_TASKS ) + sizeof( uint32_t ) )
/**
* @internal Trace Stack Monitor Buffer Structure
*/
typedef struct TraceStackMonitorBuffer
{
uint32_t buffer[ ( TRACE_STACK_MONITOR_BUFFER_SIZE ) / sizeof( uint32_t ) ];
} TraceStackMonitorBuffer_t;
/**
* @internal Initialize trace stack monitor system.
*
* @param[in] pxBuffer Pointer to memory that will be used by the trace
* stack monitor system.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStackMonitorInitialize( TraceStackMonitorBuffer_t * pxBuffer );
/**
* @brief Adds task/thread to trace stack monitor.
*
* @param[in] pvTask Task/Thread.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStackMonitorAdd( void * pvTask );
/**
* @brief Removes task/thread from trace stack monitor.
*
* @param[in] pvTask Task/Thread.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStackMonitorRemove( void * pvTask );
/**
* @brief Gets trace stack monitor tread/task at index.
*
* @param[in] uiIndex Index.
* @param[in] ppvTask Task/Thread.
* @param[out] puxLowWaterMark Low water mark.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStackMonitorGetAtIndex( uint32_t uiIndex,
void ** ppvTask,
TraceUnsignedBaseType_t * puxLowWaterMark );
/**
* @brief Performs trace stack monitor reporting.
*
* This routine performs a trace stack monitor check and report
* for TRC_CFG_STACK_MONITOR_MAX_REPORTS number of registered
* tasks/threads.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStackMonitorReport( void );
#else /* (((TRC_CFG_ENABLE_STACK_MONITOR) == 1) && ((TRC_CFG_SCHEDULING_ONLY) == 0)) */
typedef struct TraceStackMonitorBuffer
{
uint32_t buffer[ 1 ];
} TraceStackMonitorBuffer_t;
#define xTraceStackMonitorInitialize( pxBuffer ) ( ( void ) pxBuffer, TRC_SUCCESS )
#define xTraceStackMonitorDiagnosticsGet( xType, puiValue ) ( ( void ) xType, puiValue != 0 ? *puiValue = 0 : 0, puiValue != 0 ? TRC_SUCCESS : TRC_FAIL )
#define xTraceStackMonitorDiagnosticsSet( xType, uiValue ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_3( ( void ) xType, ( void ) uiValue, TRC_SUCCESS )
#define xTraceStackMonitorAdd( pvTask ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( ( void ) pvTask, TRC_SUCCESS )
#define xTraceStackMonitorRemove( pvTask ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( ( void ) pvTask, TRC_SUCCESS )
#define xTraceStackMonitorGetAtIndex( uiIndex, ppvTask, puxLowWaterMark ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_4( ( void ) uiIndex, ( void ) ppvTask, ( void ) puxLowWaterMark, TRC_SUCCESS )
#define xTraceStackMonitorReport() TRC_COMMA_EXPR_TO_STATEMENT_EXPR_1( TRC_SUCCESS )
#endif /* (((TRC_CFG_ENABLE_STACK_MONITOR) == 1) && ((TRC_CFG_SCHEDULING_ONLY) == 0)) */
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
#endif /* TRC_STACK_MONITOR_H */

@ -1,82 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
*
* @brief Public trace state machine APIs.
*/
#ifndef TRC_STATE_MACHINE_H
#define TRC_STATE_MACHINE_H
#include <trcTypes.h>
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup trace_state_machine_apis Trace State Machine APIs
* @ingroup trace_recorder_apis
* @{
*/
/**
* @brief Creates trace state machine.
*
* @param[in] szName Name.
* @param[out] pxStateMachineHandle Pointer to uninitialized trace state machine.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStateMachineCreate( const char * szName,
TraceStateMachineHandle_t * pxStateMachineHandle );
/**
* @brief Creates trace state machine state.
*
* @param[in] xStateMachineHandle Pointer to initialized trace state machine.
* @param[in] szName Name.
* @param[out] pxStateHandle Pointer to uninitialized trace state machine state.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStateMachineStateCreate( TraceStateMachineHandle_t xStateMachineHandle,
const char * szName,
TraceStateMachineStateHandle_t * pxStateHandle );
/**
* @brief Sets trace state machine state.
*
* @param[in] xStateMachineHandle Pointer to initialized trace state machine.
* @param[in] xStateHandle Pointer to initialized trace state machine state.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStateMachineSetState( TraceStateMachineHandle_t xStateMachineHandle,
TraceStateMachineStateHandle_t xStateHandle );
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
#endif /* TRC_STATE_MACHINE_H */

@ -1,112 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
*
* @brief Public trace static buffer APIs.
*/
#ifndef TRC_STATIC_BUFFER_H
#define TRC_STATIC_BUFFER_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <trcTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup trace_static_buffer_apis Trace Static Buffer APIs
* @ingroup trace_recorder_apis
* @{
*/
/* A buffer type that is maximum size */
typedef uint8_t TraceStaticBuffer_t[ TRC_MAX_BLOB_SIZE ];
/**
* @internal Trace Core Static Buffer Core Structure
*/
typedef struct TraceCoreStaticBufferCore
{
TraceStaticBuffer_t dummyEvents[ ( TRC_CFG_MAX_ISR_NESTING ) + 1 ]; /**< */
} TraceCoreStaticBuffer_t;
/**
* @internal Trace Static Buffer Table Structure
*/
typedef struct TraceStaticBufferTable
{
TraceCoreStaticBuffer_t coreDummyEvents[ TRC_CFG_CORE_COUNT ]; /**< Temporary buffers used for event or blob creation. */
} TraceStaticBufferTable_t;
#define TRC_STATIC_BUFFER_BUFFER_SIZE ( sizeof( TraceStaticBufferTable_t ) )
/**
* @internal Trace Static Buffer Buffer Structure
*/
typedef struct TraceStaticBufferBuffer
{
uint8_t buffer[ TRC_STATIC_BUFFER_BUFFER_SIZE ]; /**< */
} TraceStaticBufferBuffer_t;
extern TraceStaticBufferTable_t * pxTraceStaticBufferTable;
/**
* @internal Initialize trace static buffer.
*
* @param[in] pxBuffer Pointer to memory that will be used by the
* trace static buffer.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStaticBufferInitialize( TraceStaticBufferBuffer_t * pxBuffer );
#if ( ( TRC_CFG_USE_TRACE_ASSERT ) == 1 )
/**
* @brief Gets trace static buffer.
*
* @param[out] ppvBuffer Buffer.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStaticBufferGet( void ** ppvBuffer );
#else /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */
/**
* @brief Gets trace static buffer.
*
* @param[out] ppvBuffer Buffer.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceStaticBufferGet( ppvBuffer ) ( *ppvBuffer = ( void * ) &pxTraceStaticBufferTable->coreDummyEvents[ TRC_CFG_GET_CURRENT_CORE() ].dummyEvents[ xTraceISRGetCurrentNestingReturned() + 1 ], TRC_SUCCESS )
#endif /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
#endif /* TRC_STATIC_BUFFER_H */

@ -1,77 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
*
* @brief Public trace string APIs.
*/
#ifndef TRC_STRING_H
#define TRC_STRING_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <trcTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup trace_string_apis Trace String APIs
* @ingroup trace_recorder_apis
* @{
*/
/**
* @brief Registers a trace string.
*
* This routine registers a strings in the recorder, e.g. for names of user
* event channels.
*
* Example:
* TraceStringHandle_t myEventHandle;
* xTraceStringRegister("MyUserEvent", &myEventHandle);
* ...
* xTracePrintF(myEventHandle, "My value is: %d", myValue);
*
* @param[in] szString String.
* @param[out] pString Pointer to uninitialized trace string.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStringRegister( const char * szString,
TraceStringHandle_t * pString );
/**
* @brief Registers a trace string.
*
* @deprecated Remains for backward compability with pre v4.6 versions
* of the recorder.
*
* @param[in] name Name.
*
* @return TraceStringHandle_t
*/
TraceStringHandle_t xTraceRegisterString( const char * name );
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
#endif /* TRC_STRING_H */

@ -1,248 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
*
* @brief Public trace task APIs.
*/
#ifndef TRC_TASK_H
#define TRC_TASK_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <trcTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup trace_task_apis Trace Task APIs
* @ingroup trace_recorder_apis
* @{
*/
#ifndef TRC_CFG_ENABLE_STACK_MONITOR
#define TRC_CFG_ENABLE_STACK_MONITOR 0
#endif
/**
* @internal Trace Task Info Structure
*/
typedef struct TraceTaskInfo
{
void * coreTasks[ TRC_CFG_CORE_COUNT ];
} TraceTaskInfo_t;
extern TraceTaskInfo_t * pxTraceTaskInfo;
#define TRACE_TASK_INFO_BUFFER_SIZE ( sizeof( TraceTaskInfo_t ) )
/**
* @internal Trace Task Info Buffer Structure
*/
typedef struct TraceTaskInfoBuffer
{
uint8_t buffer[ TRACE_TASK_INFO_BUFFER_SIZE ];
} TraceTaskInfoBuffer_t;
/**
* @internal Initialize trace task system.
*
* @param[in] pxBuffer Pointer to memory that will be used by the
* trace task system.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceTaskInitialize( TraceTaskInfoBuffer_t * pxBuffer );
/**
* @brief Register trace task in the trace.
*
* @param[in] pvTask Task.
* @param[in] szName Name.
* @param[in] uxPriority Priority.
* @param[out] pxTaskHandle Pointer to uninitialized trace task.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceTaskRegister( pvTask, szName, uxPriority, pxTaskHandle ) ( ( ( ( pvTask ) != 0 ) && ( xTraceObjectRegister( PSF_EVENT_TASK_CREATE, pvTask, szName, uxPriority, ( TraceObjectHandle_t * ) ( pxTaskHandle ) ) == TRC_SUCCESS ) ) ? ( xTraceStackMonitorAdd( pvTask ), TRC_SUCCESS ) : TRC_FAIL )
/**
* @brief Unregister trace task from trace.
*
* @param[in] xTaskHandle Pointer to initialized trace task.
* @param[in] uxPriority Priority.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceTaskUnregister( TraceTaskHandle_t xTaskHandle,
TraceUnsignedBaseType_t uxPriority );
/**
* @brief Sets trace task name.
*
* @param[in] pvTask Task.
* @param[in] szName Name.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceTaskSetName xTraceObjectSetName
/**
* @brief Sets trace task priority.
*
* @param[in] xTaskHandle Pointer to initialized trace task.
* @param[in] uxPriority Priority.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceTaskSetPriority( TraceTaskHandle_t xTaskHandle,
TraceUnsignedBaseType_t uxPriority );
/**
* @brief Registers trace task without trace task handle.
*
* @param[in] pvTask Task.
* @param[in] szName Name.
* @param[in] uxPriority Priority.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceTaskRegisterWithoutHandle( pvTask, szName, uxPriority ) ( ( ( ( pvTask ) != 0 ) && ( xTraceObjectRegisterWithoutHandle( PSF_EVENT_TASK_CREATE, pvTask, szName, uxPriority ) == TRC_SUCCESS ) ) ? ( xTraceStackMonitorAdd( pvTask ), TRC_SUCCESS ) : TRC_FAIL )
/**
* @brief Unregisters trace task without trace task handle.
*
* @param[in] pvTask Task.
* @param[in] uxPriority Priority.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceTaskUnregisterWithoutHandle( pvTask, uxPriority ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( xTraceStackMonitorRemove( pvTask ), xTraceObjectUnregisterWithoutHandle( PSF_EVENT_TASK_DELETE, pvTask, uxPriority ) )
/**
* @brief Sets trace task name without trace task handle.
*
* @param[in] pvTask Task.
* @param[in] szName Name.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceTaskSetNameWithoutHandle xTraceObjectSetNameWithoutHandle
/**
* @brief Sets trace task priority without trace task handle.
*
* @param[in] pvTask Task.
* @param[in] uxPriority Priority.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceTaskSetPriorityWithoutHandle( void * pvTask,
TraceUnsignedBaseType_t uxPriority );
/**
* @brief Registers trace task switch event.
*
* @param[in] pvTask Task.
* @param[in] uxPriority Priority.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceTaskSwitch( void * pvTask,
TraceUnsignedBaseType_t uxPriority );
#if ( TRC_CFG_INCLUDE_READY_EVENTS == 1 )
/**
* @brief Registers trace task ready event.
*
* @param[in] pvTask Task.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceTaskReady( void * pvTask );
#else
#define xTraceTaskReady( p ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( ( void ) p, TRC_SUCCESS )
#endif
/**
* @brief Sets current trace task.
*
* @param[in] pvTask Task.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceTaskSetCurrent( pvTask ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( pxTraceTaskInfo->coreTasks[ TRC_CFG_GET_CURRENT_CORE() ] = ( pvTask ), TRC_SUCCESS )
/**
* @brief Gets current trace task.
*
* @param[out] ppvTask Task.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceTaskGetCurrent( ppvTask ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( *( ppvTask ) = pxTraceTaskInfo->coreTasks[ TRC_CFG_GET_CURRENT_CORE() ], TRC_SUCCESS )
/**
* @brief Registers trace task instance finished event.
*
* This routine creates a trace event that ends the current task instance at
* this very instant. This makes the viewer split the current fragment at
* this point and begin a new actor instance, even if no task-switch has
* occurred
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceTaskInstanceFinishedNow( void );
/**
* @brief Marks the current trace task instance as finished on the next
* kernel call.
*
* If that kernel call is blocking, the instance ends after the blocking event
* and the corresponding return event is then the start of the next instance.
* If the kernel call is not blocking, the viewer instead splits the current
* fragment right before the kernel call, which makes this call the first event
* of the next instance.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceTaskInstanceFinishedNext( void );
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
#endif /* TRC_TASK_H */

@ -1,253 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
*
* @brief Public trace timestamp APIs.
*/
#ifndef TRC_TIMESTAMP_H
#define TRC_TIMESTAMP_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <trcTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup trace_timestamp_apis Trace Timestamp APIs
* @ingroup trace_recorder_apis
* @{
*/
/**
* @brief Trace Timestamp Structure
*/
typedef struct TraceTimestamp
{
uint32_t type; /**< Timer type (direction) */
TraceUnsignedBaseType_t frequency; /**< Timer Frequency */
uint32_t period; /**< Timer Period */
uint32_t wraparounds; /**< Nr of timer wraparounds */
uint32_t osTickHz; /**< RTOS tick frequency */
uint32_t latestTimestamp; /**< Latest timestamp */
uint32_t osTickCount; /**< RTOS tick count */
} TraceTimestamp_t;
extern TraceTimestamp_t * pxTraceTimestamp;
#define TRC_TIMESTAMP_RECORD_SIZE ( sizeof( TraceTimestamp_t ) )
/**
* @internal Trace Timestamp Buffer Structure
*/
typedef struct TraceTimestampBuffer
{
uint32_t buffer[ ( TRC_TIMESTAMP_RECORD_SIZE ) / sizeof( uint32_t ) ];
} TraceTimestampBuffer_t;
/**
* @internal Initialize trace timestamp system.
*
* @param[in] pxBuffer Pointer to memory that will be used by the
* trace timestamp system.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceTimestampInitialize( TraceTimestampBuffer_t * pxBuffer );
#if ( ( TRC_CFG_USE_TRACE_ASSERT ) == 1 )
/**
* @brief Gets current trace timestamp.
*
* @param[out] puiTimestamp Timestamp.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceTimestampGet( uint32_t * puiTimestamp );
/**
* @brief Gets trace timestamp wraparounds.
*
* @param[out] puiTimerWraparounds Timer wraparounds.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceTimestampGetWraparounds( uint32_t * puiTimerWraparounds );
/**
* @brief Sets trace timestamp frequency.
*
* @param[in] uxFrequency Frequency.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceTimestampSetFrequency( TraceUnsignedBaseType_t uxFrequency );
/**
* @brief Gets trace timestamp frequency.
*
* @param[out] puxFrequency Frequency.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceTimestampGetFrequency( TraceUnsignedBaseType_t * puxFrequency );
/**
* @brief Sets trace timestamp period.
*
* @param[in] uiPeriod Period.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceTimestampSetPeriod( uint32_t uiPeriod );
/**
* @brief Gets trace timestamp period.
*
* @param[out] puiPeriod Period.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceTimestampGetPeriod( uint32_t * puiPeriod );
/**
* @brief Sets trace timestamp OS tick count.
*
* @param[in] uiOsTickCount OS tick count.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceTimestampSetOsTickCount( uint32_t uiOsTickCount );
/**
* @brief Gets trace timestamp OS tick count.
*
* @param[in] puiOsTickCount
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceTimestampGetOsTickCount( uint32_t * puiOsTickCount );
#else /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */
/**
* @brief Gets current trace timestamp.
*
* @param[out] puiTimestamp Timestamp.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#if ( ( TRC_HWTC_TYPE == TRC_FREE_RUNNING_32BIT_INCR ) || ( TRC_HWTC_TYPE == TRC_CUSTOM_TIMER_INCR ) )
#define xTraceTimestampGet( puiTimestamp ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_4( *( puiTimestamp ) = TRC_HWTC_COUNT, ( *( puiTimestamp ) < pxTraceTimestamp->latestTimestamp ) ? pxTraceTimestamp->wraparounds++ : 0, pxTraceTimestamp->latestTimestamp = *( puiTimestamp ), TRC_SUCCESS )
#elif ( ( TRC_HWTC_TYPE == TRC_FREE_RUNNING_32BIT_DECR ) || ( TRC_HWTC_TYPE == TRC_CUSTOM_TIMER_DECR ) )
#define xTraceTimestampGet( puiTimestamp ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_4( *( puiTimestamp ) = TRC_HWTC_COUNT, ( *( puiTimestamp ) > pxTraceTimestamp->latestTimestamp ) ? pxTraceTimestamp->wraparounds++ : 0, pxTraceTimestamp->latestTimestamp = *( puiTimestamp ), TRC_SUCCESS )
#elif ( ( TRC_HWTC_TYPE == TRC_OS_TIMER_INCR ) || ( TRC_HWTC_TYPE == TRC_OS_TIMER_DECR ) )
#define xTraceTimestampGet( puiTimestamp ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_4( *( puiTimestamp ) = ( ( TRC_HWTC_COUNT ) & 0x00FFFFFFU ) + ( ( pxTraceTimestamp->osTickCount & 0x000000FFU ) << 24 ), pxTraceTimestamp->wraparounds = pxTraceTimestamp->osTickCount, pxTraceTimestamp->latestTimestamp = *( puiTimestamp ), TRC_SUCCESS )
#endif
/**
* @brief Gets trace timestamp wraparounds.
*
* @param[out] puiTimerWraparounds Timer wraparounds.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceTimestampGetWraparounds( puiTimerWraparounds ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( *( puiTimerWraparounds ) = pxTraceTimestamp->wraparounds, TRC_SUCCESS )
/**
* @brief Sets trace timestamp frequency.
*
* @param[in] uxFrequency Frequency.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceTimestampSetFrequency( uxFrequency ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( pxTraceTimestamp->frequency = uxFrequency, TRC_SUCCESS )
/**
* @brief Sets trace timestamp period.
*
* @param[in] uiPeriod Period.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceTimestampSetPeriod( uiPeriod ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( pxTraceTimestamp->period = uiPeriod, TRC_SUCCESS )
/**
* @brief Sets trace timestamp OS tick count.
*
* @param[in] uiOsTickCount OS tick count.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceTimestampSetOsTickCount( uiOsTickCount ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( pxTraceTimestamp->osTickCount = uiOsTickCount, TRC_SUCCESS )
/**
* @brief Gets trace timestamp frequency.
*
* @param[out] puxFrequency Frequency.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceTimestampGetFrequency( puxFrequency ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( *( puxFrequency ) = pxTraceTimestamp->frequency, TRC_SUCCESS )
/**
* @brief Gets trace timestamp period.
*
* @param[out] puiPeriod Period.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceTimestampGetPeriod( puiPeriod ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( *( puiPeriod ) = pxTraceTimestamp->period, TRC_SUCCESS )
/**
* @brief Gets trace timestamp OS tick count.
*
* @param[in] puiOsTickCount
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
#define xTraceTimestampGetOsTickCount( puiOsTickCount ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( *( puiOsTickCount ) = pxTraceTimestamp->osTickCount, TRC_SUCCESS )
#endif /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */
#endif /* TRC_TIMESTAMP_H */

@ -1,69 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The common types.
*/
#ifndef TRC_TYPES_H
#define TRC_TYPES_H
#include <stdint.h>
#include <trcConfig.h>
#include <trcHardwarePort.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef TRC_BASE_TYPE
#define TRC_BASE_TYPE int32_t
#endif
#ifndef TRC_UNSIGNED_BASE_TYPE
#define TRC_UNSIGNED_BASE_TYPE uint32_t
#endif
typedef TRC_UNSIGNED_BASE_TYPE TraceUnsignedBaseType_t;
typedef TRC_BASE_TYPE TraceBaseType_t;
typedef TraceUnsignedBaseType_t traceResult;
typedef TraceUnsignedBaseType_t TraceEventHandle_t;
typedef TraceUnsignedBaseType_t TraceISRHandle_t;
typedef TraceUnsignedBaseType_t TraceEntryHandle_t;
typedef TraceUnsignedBaseType_t TraceTaskHandle_t;
typedef TraceUnsignedBaseType_t TraceObjectHandle_t;
typedef TraceUnsignedBaseType_t TraceExtensionHandle_t;
typedef TraceUnsignedBaseType_t TraceHeapHandle_t;
typedef TraceUnsignedBaseType_t TraceIntervalHandle_t;
typedef TraceUnsignedBaseType_t TraceStateMachineHandle_t;
typedef TraceUnsignedBaseType_t TraceStateMachineStateHandle_t;
typedef TraceUnsignedBaseType_t TraceStringHandle_t;
typedef TraceUnsignedBaseType_t TraceCounterHandle_t;
typedef void (* TraceCounterCallback_t)( TraceCounterHandle_t xCounterHandle );
/* DEPRECATED. Backwards compatibility */
typedef TraceStringHandle_t traceString;
#ifdef __cplusplus
}
#endif
#endif /* TRC_TYPES_H */

@ -1,51 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The interface for trace utility functions.
*/
#ifndef TRC_UTILITY_H
#define TRC_UTILITY_H
#ifndef TRC_MEMCPY
#define TRC_MEMCPY( dst, src, size ) \
{ \
uint32_t __i; \
for( __i = 0; __i < size; __i++ ) { \
( ( uint8_t * ) ( dst ) )[ __i ] = ( ( uint8_t * ) ( src ) )[ __i ]; \
} \
}
#endif
#define TRC_STRCAT( dst, dst_size, pDstLength, src ) \
{ \
TraceUnsignedBaseType_t uxTRC_STRCAT_INDEX = 0; \
while( *( pDstLength ) < ( dst_size ) ) \
{ \
dst[ *( pDstLength ) ] = src[ uxTRC_STRCAT_INDEX ]; \
if( dst[ *( pDstLength ) ] == 0 ) \
break; \
( *( pDstLength ) ) ++; \
uxTRC_STRCAT_INDEX++; \
} \
}
#if ( defined( TRC_CFG_USE_GCC_STATEMENT_EXPR ) && TRC_CFG_USE_GCC_STATEMENT_EXPR == 1 ) || __GNUC__
#define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_1( e1 ) ( { e1; } )
#define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( e1, e2 ) ( { e1; e2; } )
#define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_3( e1, e2, e3 ) ( { e1; e2; e3; } )
#define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_4( e1, e2, e3, e4 ) ( { e1; e2; e3; e4; } )
#define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_5( e1, e2, e3, e4, e5 ) ( { e1; e2; e3; e4; e5; } )
#else
#define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_1( e1 ) ( e1 )
#define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( e1, e2 ) ( e1, e2 )
#define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_3( e1, e2, e3 ) ( e1, e2, e3 )
#define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_4( e1, e2, e3, e4 ) ( e1, e2, e3, e4 )
#define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_5( e1, e2, e3, e4, e5 ) ( e1, e2, e3, e4, e5 )
#endif /* if ( defined( TRC_CFG_USE_GCC_STATEMENT_EXPR ) && TRC_CFG_USE_GCC_STATEMENT_EXPR == 1 ) || __GNUC__ */
#endif /* TRC_UTILITY_H */

@ -1,201 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

@ -1,10 +0,0 @@
SPDXVersion: SPDX-2.2
DataLicense: CC0-1.0
Creator: Organization: Percepio AB ()
PackageName: TraceRecorderSource
PackageOriginator: Percepio AB
PackageDownloadLocation: git+https://github.com/percepio/TraceRecorderSource.git
PackageLicenseDeclared: Apache-2.0
PackageCopyrightText: <text>Copyright 2021 Percepio AB</text>
PackageSummary: <text>Trace Recorder</text>
PackageDescription: <text>A generic software Trace Recorder that can generate trace events and transmit or store them.</text>

@ -1,5 +0,0 @@
Trace Recorder source code for use with Percepio's Tracealyzer.
Read more at https://percepio.com/tracealyzer/ and https://percepio.com/gettingstarted.
Repository at https://github.com/percepio/TraceRecorderSource

@ -1,5 +0,0 @@
[InternetShortcut]
URL=http://www.freertos.org/trace
IDList=
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2

@ -1,320 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* Main configuration parameters for the trace recorder library.
* More settings can be found in trcStreamingConfig.h and trcSnapshotConfig.h.
*/
#ifndef TRC_CONFIG_H
#define TRC_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
/******************************************************************************
* Include of processor header file
*
* Here you may need to include the header file for your processor. This is
* required at least for the ARM Cortex-M port, that uses the ARM CMSIS API.
* Try that in case of build problems. Otherwise, remove the #error line below.
*****************************************************************************/
#error "Trace Recorder: Please include your processor's header file here and remove this line."
/**
* @def TRC_CFG_HARDWARE_PORT
* @brief Specify what hardware port to use (i.e., the "timestamping driver").
*
* All ARM Cortex-M MCUs are supported by "TRC_HARDWARE_PORT_ARM_Cortex_M".
* This port uses the DWT cycle counter for Cortex-M3/M4/M7 devices, which is
* available on most such devices. In case your device don't have DWT support,
* you will get an error message opening the trace. In that case, you may
* force the recorder to use SysTick timestamping instead, using this define:
*
* #define TRC_CFG_ARM_CM_USE_SYSTICK
*
* For ARM Cortex-M0/M0+ devices, SysTick mode is used automatically.
*
* See trcHardwarePort.h for available ports and information on how to
* define your own port, if not already present.
*/
#define TRC_CFG_HARDWARE_PORT TRC_HARDWARE_PORT_NOT_SET
/**
* @def TRC_CFG_SCHEDULING_ONLY
* @brief Macro which should be defined as an integer value.
*
* If this setting is enabled (= 1), only scheduling events are recorded.
* If disabled (= 0), all events are recorded (unless filtered in other ways).
*
* Default value is 0 (= include additional events).
*/
#define TRC_CFG_SCHEDULING_ONLY 0
/**
* @def TRC_CFG_INCLUDE_MEMMANG_EVENTS
* @brief Macro which should be defined as either zero (0) or one (1).
*
* This controls if malloc and free calls should be traced. Set this to zero (0)
* to exclude malloc/free calls, or one (1) to include such events in the trace.
*
* Default value is 1.
*/
#define TRC_CFG_INCLUDE_MEMMANG_EVENTS 1
/**
* @def TRC_CFG_INCLUDE_USER_EVENTS
* @brief Macro which should be defined as either zero (0) or one (1).
*
* If this is zero (0), all code related to User Events is excluded in order
* to reduce code size. Any attempts of storing User Events are then silently
* ignored.
*
* User Events are application-generated events, like "printf" but for the
* trace log, generated using vTracePrint and vTracePrintF.
* The formatting is done on host-side, by Tracealyzer. User Events are
* therefore much faster than a console printf and can often be used
* in timing critical code without problems.
*
* Note: In streaming mode, User Events are used to provide error messages
* and warnings from the recorder (in case of incorrect configuration) for
* display in Tracealyzer. Disabling user events will also disable these
* warnings. You can however still catch them by calling xTraceErrorGetLast
* or by putting breakpoints in xTraceError and xTraceWarning.
*
* Default value is 1.
*/
#define TRC_CFG_INCLUDE_USER_EVENTS 1
/**
* @def TRC_CFG_INCLUDE_ISR_TRACING
* @brief Macro which should be defined as either zero (0) or one (1).
*
* If this is zero (0), the code for recording Interrupt Service Routines is
* excluded, in order to reduce code size. This means that any calls to
* vTraceStoreISRBegin/vTraceStoreISREnd will be ignored.
* This does not completely disable ISR tracing, in cases where an ISR is
* calling a traced kernel service. These events will still be recorded and
* show up in anonymous ISR instances in Tracealyzer, with names such as
* "ISR sending to <queue name>".
* To disable such tracing, please refer to vTraceSetFilterGroup and
* vTraceSetFilterMask.
*
* Default value is 1.
*
* Note: tracing ISRs requires that you insert calls to vTraceStoreISRBegin
* and vTraceStoreISREnd in your interrupt handlers.
*/
#define TRC_CFG_INCLUDE_ISR_TRACING 1
/**
* @def TRC_CFG_INCLUDE_READY_EVENTS
* @brief Macro which should be defined as either zero (0) or one (1).
*
* If one (1), events are recorded when tasks enter scheduling state "ready".
* This allows Tracealyzer to show the initial pending time before tasks enter
* the execution state, and present accurate response times.
* If zero (0), "ready events" are not created, which allows for recording
* longer traces in the same amount of RAM.
*
* Default value is 1.
*/
#define TRC_CFG_INCLUDE_READY_EVENTS 1
/**
* @def TRC_CFG_INCLUDE_OSTICK_EVENTS
* @brief Macro which should be defined as either zero (0) or one (1).
*
* If this is one (1), events will be generated whenever the OS clock is
* increased. If zero (0), OS tick events are not generated, which allows for
* recording longer traces in the same amount of RAM.
*
* Default value is 1.
*/
#define TRC_CFG_INCLUDE_OSTICK_EVENTS 1
/**
* @def TRC_CFG_ENABLE_STACK_MONITOR
* @brief If enabled (1), the recorder periodically reports the unused stack space of
* all active tasks.
* The stack monitoring runs in the Tracealyzer Control task, TzCtrl. This task
* is always created by the recorder when in streaming mode.
* In snapshot mode, the TzCtrl task is only used for stack monitoring and is
* not created unless this is enabled.
*/
#define TRC_CFG_ENABLE_STACK_MONITOR 1
/**
* @def TRC_CFG_STACK_MONITOR_MAX_TASKS
* @brief Macro which should be defined as a non-zero integer value.
*
* This controls how many tasks that can be monitored by the stack monitor.
* If this is too small, some tasks will be excluded and a warning is shown.
*
* Default value is 10.
*/
#define TRC_CFG_STACK_MONITOR_MAX_TASKS 10
/**
* @def TRC_CFG_STACK_MONITOR_MAX_REPORTS
* @brief Macro which should be defined as a non-zero integer value.
*
* This defines how many tasks that will be subject to stack usage analysis for
* each execution of the Tracealyzer Control task (TzCtrl). Note that the stack
* monitoring cycles between the tasks, so this does not affect WHICH tasks that
* are monitored, but HOW OFTEN each task stack is analyzed.
*
* This setting can be combined with TRC_CFG_CTRL_TASK_DELAY to tune the
* frequency of the stack monitoring. This is motivated since the stack analysis
* can take some time to execute.
* However, note that the stack analysis runs in a separate task (TzCtrl) that
* can be executed on low priority. This way, you can avoid that the stack
* analysis disturbs any time-sensitive tasks.
*
* Default value is 1.
*/
#define TRC_CFG_STACK_MONITOR_MAX_REPORTS 1
/**
* @def TRC_CFG_CTRL_TASK_PRIORITY
* @brief The scheduling priority of the Tracealyzer Control (TzCtrl) task.
*
* In streaming mode, TzCtrl is used to receive start/stop commands from
* Tracealyzer and in some cases also to transmit the trace data (for stream
* ports that uses the internal buffer, like TCP/IP). For such stream ports,
* make sure the TzCtrl priority is high enough to ensure reliable periodic
* execution and transfer of the data, but low enough to avoid disturbing any
* time-sensitive functions.
*
* In Snapshot mode, TzCtrl is only used for the stack usage monitoring and is
* not created if stack monitoring is disabled. TRC_CFG_CTRL_TASK_PRIORITY should
* be low, to avoid disturbing any time-sensitive tasks.
*/
#define TRC_CFG_CTRL_TASK_PRIORITY 1
/**
* @def TRC_CFG_CTRL_TASK_DELAY
* @brief The delay between loops of the TzCtrl task (see TRC_CFG_CTRL_TASK_PRIORITY),
* which affects the frequency of the stack monitoring.
*
* In streaming mode, this also affects the trace data transfer if you are using
* a stream port leveraging the internal buffer (like TCP/IP). A shorter delay
* increases the CPU load of TzCtrl somewhat, but may improve the performance of
* of the trace streaming, especially if the trace buffer is small.
*/
#define TRC_CFG_CTRL_TASK_DELAY 2
/**
* @def TRC_CFG_CTRL_TASK_STACK_SIZE
* @brief The stack size of the Tracealyzer Control (TzCtrl) task.
* See TRC_CFG_CTRL_TASK_PRIORITY for further information about TzCtrl.
*/
#define TRC_CFG_CTRL_TASK_STACK_SIZE 1024
/**
* @def TRC_CFG_RECORDER_BUFFER_ALLOCATION
* @brief Specifies how the recorder buffer is allocated (also in case of streaming, in
* port using the recorder's internal temporary buffer)
*
* Values:
* TRC_RECORDER_BUFFER_ALLOCATION_STATIC - Static allocation (internal)
* TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC - Malloc in vTraceEnable
* TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM - Use vTraceSetRecorderDataBuffer
*
* Static and dynamic mode does the allocation for you, either in compile time
* (static) or in runtime (malloc).
* The custom mode allows you to control how and where the allocation is made,
* for details see TRC_ALLOC_CUSTOM_BUFFER and vTraceSetRecorderDataBuffer().
*/
#define TRC_CFG_RECORDER_BUFFER_ALLOCATION TRC_RECORDER_BUFFER_ALLOCATION_STATIC
/**
* @def TRC_CFG_MAX_ISR_NESTING
* @brief Defines how many levels of interrupt nesting the recorder can handle, in
* case multiple ISRs are traced and ISR nesting is possible. If this
* is exceeded, the particular ISR will not be traced and the recorder then
* logs an error message. This setting is used to allocate an internal stack
* for keeping track of the previous execution context (4 byte per entry).
*
* This value must be a non-zero positive constant, at least 1.
*
* Default value: 8
*/
#define TRC_CFG_MAX_ISR_NESTING 8
/**
* @def TRC_CFG_ISR_TAILCHAINING_THRESHOLD
* @brief Macro which should be defined as an integer value.
*
* If tracing multiple ISRs, this setting allows for accurate display of the
* context-switching also in cases when the ISRs execute in direct sequence.
*
* vTraceStoreISREnd normally assumes that the ISR returns to the previous
* context, i.e., a task or a preempted ISR. But if another traced ISR
* executes in direct sequence, Tracealyzer may incorrectly display a minimal
* fragment of the previous context in between the ISRs.
*
* By using TRC_CFG_ISR_TAILCHAINING_THRESHOLD you can avoid this. This is
* however a threshold value that must be measured for your specific setup.
* See http://percepio.com/2014/03/21/isr_tailchaining_threshold/
*
* The default setting is 0, meaning "disabled" and that you may get an
* extra fragments of the previous context in between tail-chained ISRs.
*
* Note: This setting has separate definitions in trcSnapshotConfig.h and
* trcStreamingConfig.h, since it is affected by the recorder mode.
*/
#define TRC_CFG_ISR_TAILCHAINING_THRESHOLD 0
/**
* @def TRC_CFG_RECORDER_DATA_INIT
* @brief Macro which states wether the recorder data should have an initial value.
*
* In very specific cases where traced objects are created before main(),
* the recorder will need to be started even before that. In these cases,
* the recorder data would be initialized by vTraceEnable(TRC_INIT) but could
* then later be overwritten by the initialization value.
* If this is an issue for you, set TRC_CFG_RECORDER_DATA_INIT to 0.
* The following code can then be used before any traced objects are created:
*
* extern uint32_t RecorderEnabled;
* RecorderEnabled = 0;
* xTraceInitialize();
*
* After the clocks are properly initialized, use vTraceEnable(...) to start
* the tracing.
*
* Default value is 1.
*/
#define TRC_CFG_RECORDER_DATA_INIT 1
/**
* @def TRC_CFG_RECORDER_DATA_ATTRIBUTE
* @brief When setting TRC_CFG_RECORDER_DATA_INIT to 0, you might also need to make
* sure certain recorder data is placed in a specific RAM section to avoid being
* zeroed out after initialization. Define TRC_CFG_RECORDER_DATA_ATTRIBUTE as
* that attribute.
*
* Example:
* #define TRC_CFG_RECORDER_DATA_ATTRIBUTE __attribute__((section(".bss.trace_recorder_data")))
*
* Default value is empty.
*/
#define TRC_CFG_RECORDER_DATA_ATTRIBUTE
/**
* @def TRC_CFG_USE_TRACE_ASSERT
* @brief Enable or disable debug asserts. Information regarding any assert that is
* triggered will be in trcAssert.c.
*/
#define TRC_CFG_USE_TRACE_ASSERT 0
#ifdef __cplusplus
}
#endif
#endif /* _TRC_CONFIG_H */

@ -1,116 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* Configuration parameters for the kernel port.
* More settings can be found in trcKernelPortStreamingConfig.h and
* trcKernelPortSnapshotConfig.h.
*/
#ifndef TRC_KERNEL_PORT_CONFIG_H
#define TRC_KERNEL_PORT_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @def TRC_CFG_RECORDER_MODE
* @brief Specify what recording mode to use. Snapshot means that the data is saved in
* an internal RAM buffer, for later upload. Streaming means that the data is
* transferred continuously to the host PC.
*
* For more information, see http://percepio.com/2016/10/05/rtos-tracing/
* and the Tracealyzer User Manual.
*
* Values:
* TRC_RECORDER_MODE_SNAPSHOT
* TRC_RECORDER_MODE_STREAMING
*/
#define TRC_CFG_RECORDER_MODE TRC_RECORDER_MODE_STREAMING
/**
* @def TRC_CFG_FREERTOS_VERSION
* @brief Specify what version of FreeRTOS that is used (don't change unless using the
* trace recorder library with an older version of FreeRTOS).
*
* TRC_FREERTOS_VERSION_7_3_X If using FreeRTOS v7.3.X
* TRC_FREERTOS_VERSION_7_4_X If using FreeRTOS v7.4.X
* TRC_FREERTOS_VERSION_7_5_X If using FreeRTOS v7.5.X
* TRC_FREERTOS_VERSION_7_6_X If using FreeRTOS v7.6.X
* TRC_FREERTOS_VERSION_8_X_X If using FreeRTOS v8.X.X
* TRC_FREERTOS_VERSION_9_0_0 If using FreeRTOS v9.0.0
* TRC_FREERTOS_VERSION_9_0_1 If using FreeRTOS v9.0.1
* TRC_FREERTOS_VERSION_9_0_2 If using FreeRTOS v9.0.2
* TRC_FREERTOS_VERSION_10_0_0 If using FreeRTOS v10.0.0
* TRC_FREERTOS_VERSION_10_0_1 If using FreeRTOS v10.0.1
* TRC_FREERTOS_VERSION_10_1_0 If using FreeRTOS v10.1.0
* TRC_FREERTOS_VERSION_10_1_1 If using FreeRTOS v10.1.1
* TRC_FREERTOS_VERSION_10_2_0 If using FreeRTOS v10.2.0
* 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
* TRC_FREERTOS_VERSION_10_4_1 If using FreeRTOS v10.4.1 or later
*/
#define TRC_CFG_FREERTOS_VERSION TRC_FREERTOS_VERSION_10_4_1
/**
* @def TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS
* @brief Macro which should be defined as either zero (0) or one (1).
*
* If this is zero (0), the trace will exclude any "event group" events.
*
* Default value is 0 (excluded) since dependent on event_groups.c
*/
#define TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS 1
/**
* @def TRC_CFG_INCLUDE_TIMER_EVENTS
* @brief Macro which should be defined as either zero (0) or one (1).
*
* If this is zero (0), the trace will exclude any Timer events.
*
* Default value is 0 since dependent on timers.c
*/
#define TRC_CFG_INCLUDE_TIMER_EVENTS 1
/**
* @def TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS
* @brief Macro which should be defined as either zero (0) or one (1).
*
* If this is zero (0), the trace will exclude any "pending function call"
* events, such as xTimerPendFunctionCall().
*
* Default value is 0 since dependent on timers.c
*/
#define TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS 1
/**
* @def TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS
* @brief Macro which should be defined as either zero (0) or one (1).
*
* If this is zero (0), the trace will exclude any stream buffer or message
* buffer events.
*
* Default value is 0 since dependent on stream_buffer.c (new in FreeRTOS v10)
*/
#define TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS 1
/**
* @def TRC_CFG_ACKNOWLEDGE_QUEUE_SET_SEND
* @brief When using FreeRTOS v10.3.0 or v10.3.1, please make sure that the trace
* point in prvNotifyQueueSetContainer() in queue.c is renamed from
* traceQUEUE_SEND to traceQUEUE_SET_SEND in order to tell them apart from
* other traceQUEUE_SEND trace points. Then set this to TRC_ACKNOWLEDGED.
*/
#define TRC_CFG_ACKNOWLEDGE_QUEUE_SET_SEND 0 /* TRC_ACKNOWLEDGED */
#ifdef __cplusplus
}
#endif
#endif /* TRC_KERNEL_PORT_CONFIG_H */

@ -1,69 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* Kernel port configuration parameters for snapshot mode.
*/
#ifndef TRC_KERNEL_PORT_SNAPSHOT_CONFIG_H
#define TRC_KERNEL_PORT_SNAPSHOT_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @def TRC_CFG_NTASK, TRC_CFG_NISR, TRC_CFG_NQUEUE, TRC_CFG_NSEMAPHORE...
* @brief A group of macros which should be defined as integer values, zero or larger.
*
* These define the capacity of the Object Property Table, i.e., the maximum
* number of objects active at any given point, within each object class (e.g.,
* task, queue, semaphore, ...).
*
* If tasks or other objects are deleted in your system, this
* setting does not limit the total amount of objects created, only the number
* of objects that have been successfully created but not yet deleted.
*
* Using too small values will cause vTraceError to be called, which stores an
* error message in the trace that is shown when opening the trace file. The
* error message can also be retrieved using xTraceGetLastError.
*
* It can be wise to start with large values for these constants,
* unless you are very confident on these numbers. Then do a recording and
* check the actual usage by selecting View menu -> Trace Details ->
* Resource Usage -> Object Table.
*/
#define TRC_CFG_NTASK 15
#define TRC_CFG_NISR 5
#define TRC_CFG_NQUEUE 10
#define TRC_CFG_NSEMAPHORE 10
#define TRC_CFG_NMUTEX 10
#define TRC_CFG_NTIMER 5
#define TRC_CFG_NEVENTGROUP 5
#define TRC_CFG_NSTREAMBUFFER 5
#define TRC_CFG_NMESSAGEBUFFER 5
/**
* @def TRC_CFG_NAME_LEN_TASK, TRC_CFG_NAME_LEN_QUEUE, ...
* @brief Macros that specify the maximum lengths (number of characters) for names of
* kernel objects, such as tasks and queues. If longer names are used, they will
* be truncated when stored in the recorder.
*/
#define TRC_CFG_NAME_LEN_TASK 15
#define TRC_CFG_NAME_LEN_ISR 15
#define TRC_CFG_NAME_LEN_QUEUE 15
#define TRC_CFG_NAME_LEN_SEMAPHORE 15
#define TRC_CFG_NAME_LEN_MUTEX 15
#define TRC_CFG_NAME_LEN_TIMER 15
#define TRC_CFG_NAME_LEN_EVENTGROUP 15
#define TRC_CFG_NAME_LEN_STREAMBUFFER 15
#define TRC_CFG_NAME_LEN_MESSAGEBUFFER 15
#ifdef __cplusplus
}
#endif
#endif /* TRC_KERNEL_PORT_SNAPSHOT_CONFIG_H */

@ -1,245 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* Configuration parameters for trace recorder library in snapshot mode.
* Read more at http://percepio.com/2016/10/05/rtos-tracing/
*/
#ifndef TRC_SNAPSHOT_CONFIG_H
#define TRC_SNAPSHOT_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @def TRC_CFG_SNAPSHOT_MODE
* @brief Macro which should be defined as one of:
* - TRC_SNAPSHOT_MODE_RING_BUFFER
* - TRC_SNAPSHOT_MODE_STOP_WHEN_FULL
* Default is TRC_SNAPSHOT_MODE_RING_BUFFER.
*
* With TRC_CFG_SNAPSHOT_MODE set to TRC_SNAPSHOT_MODE_RING_BUFFER, the
* events are stored in a ring buffer, i.e., where the oldest events are
* overwritten when the buffer becomes full. This allows you to get the last
* events leading up to an interesting state, e.g., an error, without having
* to store the whole run since startup.
*
* When TRC_CFG_SNAPSHOT_MODE is TRC_SNAPSHOT_MODE_STOP_WHEN_FULL, the
* recording is stopped when the buffer becomes full. This is useful for
* recording events following a specific state, e.g., the startup sequence.
*/
#define TRC_CFG_SNAPSHOT_MODE TRC_SNAPSHOT_MODE_RING_BUFFER
/**
* @def TRC_CFG_EVENT_BUFFER_SIZE
* @brief Macro which should be defined as an integer value.
*
* This defines the capacity of the event buffer, i.e., the number of records
* it may store. Most events use one record (4 byte), although some events
* require multiple 4-byte records. You should adjust this to the amount of RAM
* available in the target system.
*
* Default value is 1000, which means that 4000 bytes is allocated for the
* event buffer.
*/
#define TRC_CFG_EVENT_BUFFER_SIZE 1000
/**
* @def TRC_CFG_INCLUDE_FLOAT_SUPPORT
* @brief Macro which should be defined as either zero (0) or one (1).
*
* If this is zero (0), the support for logging floating point values in
* vTracePrintF is stripped out, in case floating point values are not used or
* supported by the platform used.
*
* Floating point values are only used in vTracePrintF and its subroutines, to
* allow for storing float (%f) or double (%lf) arguments.
*
* vTracePrintF can be used with integer and string arguments in either case.
*
* Default value is 0.
*/
#define TRC_CFG_INCLUDE_FLOAT_SUPPORT 0
/**
* @def TRC_CFG_SYMBOL_TABLE_SIZE
* @brief Macro which should be defined as an integer value.
*
* This defines the capacity of the symbol table, in bytes. This symbol table
* stores User Events labels and names of deleted tasks, queues, or other kernel
* objects. If you don't use User Events or delete any kernel
* objects you set this to a very low value. The minimum recommended value is 4.
* A size of zero (0) is not allowed since a zero-sized array may result in a
* 32-bit pointer, i.e., using 4 bytes rather than 0.
*
* Default value is 800.
*/
#define TRC_CFG_SYMBOL_TABLE_SIZE 800
#if ( TRC_CFG_SYMBOL_TABLE_SIZE == 0 )
#error "TRC_CFG_SYMBOL_TABLE_SIZE may not be zero!"
#endif
/******************************************************************************
*** ADVANCED SETTINGS ********************************************************
******************************************************************************
* The remaining settings are not necessary to modify but allows for optimizing
* the recorder setup for your specific needs, e.g., to exclude events that you
* are not interested in, in order to get longer traces.
*****************************************************************************/
/**
* @def TRC_CFG_HEAP_SIZE_BELOW_16M
* @brief An integer constant that can be used to reduce the buffer usage of memory
* allocation events (malloc/free). This value should be 1 if the heap size is
* below 16 MB (2^24 byte), and you can live with reported addresses showing the
* lower 24 bits only. If 0, you get the full 32-bit addresses.
*
* Default value is 0.
*/
#define TRC_CFG_HEAP_SIZE_BELOW_16M 0
/**
* @def TRC_CFG_USE_IMPLICIT_IFE_RULES
* @brief Macro which should be defined as either zero (0) or one (1).
* Default is 1.
*
* Tracealyzer groups the events into "instances" based on Instance Finish
* Events (IFEs), produced either by default rules or calls to the recorder
* functions xTraceTaskInstanceFinishedNow and xTraceTaskInstanceFinishedNext.
*
* If TRC_CFG_USE_IMPLICIT_IFE_RULES is one (1), the default IFE rules is
* used, resulting in a "typical" grouping of events into instances.
* If these rules don't give appropriate instances in your case, you can
* override the default rules using xTraceTaskInstanceFinishedNow/Next for one
* or several tasks. The default IFE rules are then disabled for those tasks.
*
* If TRC_CFG_USE_IMPLICIT_IFE_RULES is zero (0), the implicit IFE rules are
* disabled globally. You must then call xTraceTaskInstanceFinishedNow or
* xTraceTaskInstanceFinishedNext to manually group the events into instances,
* otherwise the tasks will appear a single long instance.
*
* The default IFE rules count the following events as "instance finished":
* - Task delay, delay until
* - Task suspend
* - Blocking on "input" operations, i.e., when the task is waiting for the
* next a message/signal/event. But only if this event is blocking.
*/
#define TRC_CFG_USE_IMPLICIT_IFE_RULES 1
/**
* @def TRC_CFG_USE_16BIT_OBJECT_HANDLES
* @brief Macro which should be defined as either zero (0) or one (1).
*
* If set to 0 (zero), the recorder uses 8-bit handles to identify kernel
* objects such as tasks and queues. This limits the supported number of
* concurrently active objects to 255 of each type (tasks, queues, mutexes,
* etc.) Note: 255, not 256, since handle 0 is reserved.
*
* If set to 1 (one), the recorder uses 16-bit handles to identify kernel
* objects such as tasks and queues. This limits the supported number of
* concurrent objects to 65535 of each type (object class). However, since the
* object property table is limited to 64 KB, the practical limit is about
* 3000 objects in total.
*
* Default is 0 (8-bit handles)
*
* NOTE: An object with handle above 255 will use an extra 4-byte record in
* the event buffer whenever the object is referenced. Moreover, some internal
* tables in the recorder gets slightly larger when using 16-bit handles.
*/
#define TRC_CFG_USE_16BIT_OBJECT_HANDLES 0
/**
* @def TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER
* @brief Macro which should be defined as an integer value.
*
* Set TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER to 1 to enable the
* separate user event buffer (UB).
* In this mode, user events are stored separately from other events,
* e.g., RTOS events. Thereby you can get a much longer history of
* user events as they don't need to share the buffer space with more
* frequent events.
*
* The UB is typically used with the snapshot ring-buffer mode, so the
* recording can continue when the main buffer gets full. And since the
* main buffer then overwrites the earliest events, Tracealyzer displays
* "Unknown Actor" instead of task scheduling for periods with UB data only.
*
* In UB mode, user events are structured as UB channels, which contains
* a channel name and a default format string. Register a UB channel using
* xTraceRegisterUBChannel.
*
* Events and data arguments are written using vTraceUBEvent and
* vTraceUBData. They are designed to provide efficient logging of
* repeating events, using the same format string within each channel.
*
* Examples:
* TraceStringHandle_t chn1;
* TraceStringHandle_t fmt1;
* xTraceStringRegister("Channel 1", &chn1);
* xTraceStringRegister("Event!", &fmt1);
* traceUBChannel UBCh1 = xTraceRegisterUBChannel(chn1, fmt1);
*
* TraceStringHandle_t chn2;
* TraceStringHandle_t fmt2;
* xTraceStringRegister("Channel 2", &chn2);
* xTraceStringRegister("X: %d, Y: %d", &fmt2);
* traceUBChannel UBCh2 = xTraceRegisterUBChannel(chn2, fmt2);
*
* // Result in "[Channel 1] Event!"
* vTraceUBEvent(UBCh1);
*
* // Result in "[Channel 2] X: 23, Y: 19"
* vTraceUBData(UBCh2, 23, 19);
*
* You can also use the other user event functions, like xTracePrintF.
* as they are then rerouted to the UB instead of the main event buffer.
* vTracePrintF then looks up the correct UB channel based on the
* provided channel name and format string, or creates a new UB channel
* if no match is found. The format string should therefore not contain
* "random" messages but mainly format specifiers. Random strings should
* be stored using %s and with the string as an argument.
*
* // Creates a new UB channel ("Channel 2", "%Z: %d")
* xTracePrintF(chn2, "%Z: %d", value1);
*
* // Finds the existing UB channel
* xTracePrintF(chn2, "%Z: %d", value2);
*/
#define TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER 0
/**
* @def TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE
* @brief Macro which should be defined as an integer value.
*
* This defines the capacity of the user event buffer (UB), in number of slots.
* A single user event can use multiple slots, depending on the arguments.
*
* Only applicable if TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER is 1.
*/
#define TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE 200
/**
* @def TRC_CFG_UB_CHANNELS
* @brief Macro which should be defined as an integer value.
*
* This defines the number of User Event Buffer Channels (UB channels).
* These are used to structure the events when using the separate user
* event buffer, and contains both a User Event Channel (the name) and
* a default format string for the channel.
*
* Only applicable if TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER is 1.
*/
#define TRC_CFG_UB_CHANNELS 32
#ifdef __cplusplus
}
#endif
#endif /*TRC_SNAPSHOT_CONFIG_H*/

@ -1,55 +0,0 @@
/*
* Percepio Trace Recorder Initialization v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* This file should only be included in a project if there is a need to
* initialize the Trace Recorder before main() has been called.
* An example of this scenario is if you have a global object instance that has
* a constructor that creates an object that should be traced.
* This file will make it easier to initiate the recorder correctly.
*
* Usage:
* Add a call to TraceRecorderInit::Initialize() wherever a traced object is
* created before the Trace Recorder is normally initialized. This will ensure
* the Trace Recorder is initialized only once.
*
* Set TRC_CFG_RECORDER_DATA_PTR_INIT to 0 in trcSnapshotConfig.h to ensure
* RecorderInitialized isn't initialized to 0 after the recorder has been
* already initialized.
*
* Finally, call vTraceEnable(TRC_START) after hardware is initialized to
* start gathering trace events.
*/
#include <TraceRecorderInit.h>
#include <trcRecorder.h>
extern "C" uint32_t RecorderInitialized;
/* Public */
bool TraceRecorderInit::Initialize()
{
/* Lazy initialization, and constructor is only run once ensuring that we only initialize the recorder once */
static TraceRecorderInit instance;
return instance.IsInitialized();
}
/* Private */
TraceRecorderInit::TraceRecorderInit()
{
RecorderInitialized = 0;
xTraceInitialize();
}
TraceRecorderInit::~TraceRecorderInit()
{
}
bool TraceRecorderInit::IsInitialized()
{
return RecorderInitialized != 0;
}

@ -1,38 +0,0 @@
/*
* Percepio Trace Recorder Initialization v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* This file should only be included in a project if there is a need to
* initialize the Trace Recorder before main() has been called.
* An example of this scenario is if you have a global object instance that has
* a constructor that creates an object that should be traced.
* This file will make it easier to initiate the recorder correctly.
*
* Usage:
* Add a call to TraceRecorderInit::Initialize() wherever a traced object is
* created before the Trace Recorder is normally initialized. This will ensure
* the Trace Recorder is initialized only once.
*
* Set TRC_CFG_RECORDER_DATA_PTR_INIT to 0 in trcSnapshotConfig.h to ensure
* RecorderInitialized isn't initialized to 0 after the recorder has been
* already initialized.
*
* Finally, call vTraceEnable(TRC_START) after hardware is initialized to
* start gathering trace events.
*/
#pragma once
class TraceRecorderInit
{
public:
static bool Initialize();
private:
TraceRecorderInit();
~TraceRecorderInit();
bool IsInitialized();
};

@ -1,30 +0,0 @@
Percepio Trace Recorder Initialization v4.6.0
Copyright 2021 Percepio AB
www.percepio.com
This folder contains files that should only be included in a project
if there is a need to initialize the Trace Recorder before main()
has been called.
An example of this scenario is if you have a global object instance that has
a constructor that creates an object that should be traced.
TraceRecorderInit will make it easier to initiate the recorder correctly.
Usage:
Add a call to TraceRecorderInit::Initialize() wherever a traced object
is created before the Trace Recorder is normally initialized, or simply
as early as absloutely possible. This will ensure the Trace Recorder is
initialized only once.
Set TRC_CFG_RECORDER_DATA_INIT to 0 in trcConfig.h to ensure
recorder data isn't initialized cleared after the recorder has been
already initialized.
It is possible that you also need to make sure certain recorder data isn't
cleared when RAM sections are initialized. Create a RAM section that isn't
cleared, then set the appropriate attribute in TRC_CFG_RECORDER_DATA_ATTRIBUTE.
This attribute will then be set for all necessary recorder data that should
not be cleared.
After the hardware and clocks are properly initialized, use
vTraceEnable(TRC_START) to start the tracing.

@ -1,21 +0,0 @@
Tracealyzer Stream Port for Amazon FreeRTOS TCP/WIFI
Percepio AB
www.percepio.com
----------------------------------------------------
This directory contains a "stream port" for the Tracealyzer recorder library,
i.e., the specific code needed to use a particular interface for streaming a
Tracealyzer RTOS trace. The stream port is defined by a set of macros in
trcStreamPort.h, found in the "include" directory.
This particular stream port is for streaming via a TCP socket in Amazon
FreeRTOS (AFR) directly to a host computer on the local network, typically
using Wifi. Read more in trcStreamPort.h.
To use this stream port, make sure that include/trcStreamPort.h is found
by the compiler (i.e., add this folder to your project's include paths) and
add all included source files to your build. Make sure no other versions of
trcStreamPort.h are included by mistake!
See also http://percepio.com/2016/10/05/rtos-tracing
and https://percepio.com/2018/10/11/tuning-your-custom-trace-streaming/

@ -1,131 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* This stream port provides trace streaming using the Amazon FreeRTOS sockets
* layer and is intended for streaming over Wifi directly to a computer on the
* local Wifi network.
*
* Note that this does NOT use the TLS encryption available in Amazon
* FreeRTOS, due to performance and memory usage concerns. However, it does not
* use any AWS services either, and is intended for your local network only.
*
* This should be started using vTraceEnable(TRC_START) and this call should be
* made AFTER the kernel has started and the Wifi interface is ready.
*
* In the Tracealyzer setting -> "PSF Streaming Settings" make sure that the
* "Target Connection" setting is "TCP (Target Initiated)".
*
* To use this, make sure to start the trace recording in Tracealyzer before
* you start your target system. This ensures that Tracealyzer is ready when
* the target system connects.
*
* And don't forget to enter the IP address of the Tracealyzer host computer
* in trcStreamPort.h.
*
* NOTES:
*
* 1: The tracing will increase the stack usage of you application, so you
* may want to increase configMINIMAL_STACK_SIZE in your FreeRTOSConfig.h.
*
* 2: To reduce the amount of trace data, we recommend disabling the tracing
* of OS Ticks and memory allocation events.
* See TRC_CFG_INCLUDE_OSTICK_EVENTS in trcConfig.h.
*
* 3: The transmission of trace data is done in the TzCtrl task. To avoid that
* the trace streaming is blocked during the (long) MQTT connection phase,
* make sure the scheduling priority of TzCtrl is higher than the MQTT task.
* Otherwise, if you prefer to run the TzCtrl task at lower priority to avoid
* interfering with your application, wait with the vTraceEnable call until
* after the MQTT connection is established.
* See TRC_CFG_CTRL_TASK_PRIORITY in trcStreamingConfig.h.
*
* 4: The Wifi transmission of trace data often uses FreeRTOS functions, that
* are traced and thus produce additional trace data. This may cause a fast
* increase in trace data rate, that may saturate the trace buffer and cause
* data loss (i.e. incomplete traces).
* To eliminate this effect and reduce the amount of trace data produced, we
* recommend excluding all FreeRTOS objects that are used by Wifi stack.
* This is done using vTraceSetFilterGroup and vTraceSetFilterMask:
*
* // Just before wifi initialization:
*
* // All objects created after this point are assigned to group 15.
* vTraceSetFilterGroup(FilterGroup15);
*
* // Only trace objects assigned to group 0 (the default group).
* vTraceSetFilterMask(FilterGroup0);
*
* // The wifi stack initialization... (creates semaphores etc.)
* if ( eWifi_Connected == prvWifiConnect() )
* {
* yMainState = eMain_StartApplication;
*
* // When connected, restore the FilterGroup setting to Group 0, so
* // that later created objects are included, like the TzCtrl task
* // created in vTraceEnable. Excluding tasks is not recommended!
* vTraceSetFilterGroup(FilterGroup0);
*
* // Then call vTraceEnable to start the tracing.
* vTraceEnable(TRC_START);
* }
*
* 5: If you still get "red sections" in Tracealyzer (lost data), you need
* to adjust the other settings in trcStreamingConfig.h.
*
* - TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT
* Increase this, as long as you have memory to spare.
*
* - TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE
* Increase this, as long as you have memory to spare.
* But don't exceed the maximum payload size of the Wifi chip, which
* is often limited to 1000-1500 bytes. Some chips crash if you try to
* send to large chunks...
*
* - TRC_CFG_CTRL_TASK_DELAY
* Decrease this to flush the trace buffer more frequently.
*
* See also http://percepio.com/2016/10/05/rtos-tracing
* and https://percepio.com/2018/10/11/tuning-your-custom-trace-streaming/
*/
#ifndef TRC_STREAM_PORT_H
#define TRC_STREAM_PORT_H
#ifdef __cplusplus
extern "C" {
#endif
#define HOST_IPADDRESS_0 192
#define HOST_IPADDRESS_1 168
#define HOST_IPADDRESS_2 10
#define HOST_IPADDRESS_3 116
#define HOST_PORT 12000
void prvInitSocket( void );
int32_t prvReadFromSocket( void * ptrData,
uint32_t size,
int32_t * ptrBytesRead );
int32_t prvWriteToSocket( void * ptrData,
uint32_t size,
int32_t * ptrBytesWritten );
#define TRC_STREAM_PORT_INIT() \
TRC_STREAM_PORT_MALLOC(); \
prvInitSocket();
#define TRC_STREAM_PORT_USE_INTERNAL_BUFFER 1
#define TRC_STREAM_PORT_WRITE_DATA( _ptrData, _size, _ptrBytesWritten ) prvWriteToSocket( _ptrData, _size, _ptrBytesWritten )
#define TRC_STREAM_PORT_READ_DATA( _ptrData, _size, _ptrBytesRead ) prvReadFromSocket( _ptrData, _size, _ptrBytesRead )
#ifdef __cplusplus
}
#endif
#endif /* TRC_STREAM_PORT_H */

@ -1,163 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* This stream port provides trace streaming using the Amazon FreeRTOS sockets
* layer and is intended for streaming over Wifi directly to a computer on the
* local Wifi network.
*
* Note that this does NOT use the TLS encryption available in Amazon
* FreeRTOS, due to performance and memory usage concerns. However, it does not
* use any AWS services either, and is intended for your local network only.
*
* This should be started using vTraceEnable(TRC_START) and this call should be
* made AFTER the kernel has started and the Wifi interface is ready.
*
* In the Tracealyzer setting -> "PSF Streaming Settings" make sure that the
* "Target Connection" setting is "TCP (Target Initiated)".
*
* To use this, make sure to start the trace recording in Tracealyzer before
* you start your target system. This ensures that Tracealyzer is ready when
* the target system connects.
*
* And don't forget to enter the IP address of the Tracealyzer host computer
* in trcStreamPort.h.
*
* NOTES:
*
* 1: The tracing will increase the stack usage of you application, so you
* may want to increase configMINIMAL_STACK_SIZE in your FreeRTOSConfig.h.
*
* 2: To reduce the amount of trace data, we recommend disabling the tracing
* of OS Ticks and memory allocation events.
* See TRC_CFG_INCLUDE_OSTICK_EVENTS in trcConfig.h.
*
* 3: The transmission of trace data is done in the TzCtrl task. To avoid that
* the trace streaming is blocked during the (long) MQTT connection phase,
* make sure the scheduling priority of TzCtrl is higher than the MQTT task.
* Otherwise, if you prefer to run the TzCtrl task at lower priority to avoid
* interfering with your application, wait with the vTraceEnable call until
* after the MQTT connection is established.
* See TRC_CFG_CTRL_TASK_PRIORITY in trcStreamingConfig.h.
*
* 4: The Wifi transmission of trace data often uses FreeRTOS functions, that
* are traced and thus produce additional trace data. This may cause a fast
* increase in trace data rate, that may saturate the trace buffer and cause
* data loss (i.e. incomplete traces).
* To eliminate this effect and reduce the amount of trace data produced, we
* recommend excluding all FreeRTOS objects that are used by Wifi stack.
* This is done using vTraceSetFilterGroup and vTraceSetFilterMask:
*
* // Just before wifi initialization:
*
* // All objects created after this point are assigned to group 15.
* vTraceSetFilterGroup(FilterGroup15);
*
* // Only trace objects assigned to group 0 (the default group).
* vTraceSetFilterMask(FilterGroup0);
*
* // The wifi stack initialization... (creates semaphores etc.)
* if ( eWifi_Connected == prvWifiConnect() )
* {
* yMainState = eMain_StartApplication;
*
* // When connected, restore the FilterGroup setting to Group 0, so
* // that later created objects are included, like the TzCtrl task
* // created in vTraceEnable. Excluding tasks is not recommended!
* vTraceSetFilterGroup(FilterGroup0);
*
* // Then call vTraceEnable to start the tracing.
* vTraceEnable(TRC_START);
* }
*
* 5: If you still get "red sections" in Tracealyzer (lost data), you need
* to adjust the other settings in trcStreamingConfig.h.
*
* - TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT
* Increase this, as long as you have memory to spare.
*
* - TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE
* Increase this, as long as you have memory to spare.
* But don't exceed the maximum payload size of the Wifi chip, which
* is often limited to 1000-1500 bytes. Some chips crash if you try to
* send to large chunks...
*
* - TRC_CFG_CTRL_TASK_DELAY
* Decrease this to flush the trace buffer more frequently.
*
* See also http://percepio.com/2016/10/05/rtos-tracing
* and https://percepio.com/2018/10/11/tuning-your-custom-trace-streaming/
*/
#include <trcRecorder.h>
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <aws_secure_sockets.h>
SocketsSockaddr_t addr = { sizeof( SocketsSockaddr_t ), SOCKETS_AF_INET, 0, 0 };
#define IPv4( a, b, c, d ) ( uint32_t ) ( ( d << 24 ) + ( c << 16 ) + ( b << 8 ) + a )
Socket_t sock = 0;
void prvInitSocket( void )
{
int32_t status;
SOCKETS_Init();
sock = SOCKETS_Socket( SOCKETS_AF_INET, SOCKETS_SOCK_STREAM, SOCKETS_IPPROTO_TCP );
configPRINTF( ( "Connecting to %d.%d.%d.%d, port %d\r\n", HOST_IPADDRESS_0, HOST_IPADDRESS_1, HOST_IPADDRESS_2, HOST_IPADDRESS_3, HOST_PORT ) );
addr.ulAddress = IPv4( HOST_IPADDRESS_0, HOST_IPADDRESS_1, HOST_IPADDRESS_2, HOST_IPADDRESS_3 );
addr.usPort = SOCKETS_htons( HOST_PORT );
status = SOCKETS_Connect( sock, &addr, sizeof( SocketsSockaddr_t ) );
if( status != SOCKETS_ERROR_NONE )
{
/*prvTraceError(PSF_ERROR_STREAM_PORT_FAIL); */
configPRINTF( ( "Failed to connect, status: %d\r\n", status ) );
}
else
{
configPRINTF( ( "Connected.\r\n" ) );
}
}
int32_t prvWriteToSocket( void * ptrData,
uint32_t size,
int32_t * ptrBytesWritten )
{
uint32_t bytesWritten = SOCKETS_Send( sock, ptrData, size, 0 );
if( ptrBytesWritten != 0 )
{
*ptrBytesWritten = ( int32_t ) bytesWritten;
}
if( bytesWritten != size )
{
return -1;
}
return 0;
}
int32_t prvReadFromSocket( void * ptrData,
uint32_t size,
int32_t * ptrBytesRead )
{
/* Not yet implemented, since not necessary. */
return 0;
}
#endif /* if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING ) */
#endif /* if ( TRC_USE_TRACEALYZER_RECORDER == 1 ) */

@ -1,55 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
*/
FUNC void tzSetEnable(int enable)
{
if (enable == 1)
{
printf("Starting Tracealyzer recorder\n");
// Forward the ITM data to file
exec("ITMLOG 1 > .\\tracealyzer.psf");
// Send start command to Tracealyzer (not required if using vTraceEnable(TRC_START))
exec("E CHAR tz_host_command_data = 1, 1, 0, 0, 0, 0, 0xFD, 0xFF");
exec("tz_host_command_bytes_to_read = 8");
}
else if (enable == 0)
{
printf("Stopping Tracealyzer recorder...\n");
// Send stop command to Tracealyzer, to stop writing ITM data.
exec("E CHAR tz_host_command_data = 1, 0, 0, 0, 0, 0, 0xFE, 0xFF");
exec("tz_host_command_bytes_to_read = 8");
_sleep_(2000); // Wait a while to let all data be written the host file.
// Stop forwarding the ITM data to file and close the file.
exec("ITMLOG 1 OFF");
printf("Tracealyzer recorder stopped.\n");
}
else printf("Usage: tzSetEnable(0 or 1), where 0 is disable (stops recorder) and 1 enable (starts recording)");
}
// The Tracealyzer ITM stream port for Keil µVision can be used in two ways.
//
// 1. Start tracing directly from startup.
// Make sure tzSetEnable(1) is called below and vTraceEnable(TRC_START) in your target startup.
//
// 2. Start the trace manually, using the "Start Recording" button in Keil µVision.
// In this case, comment out the below call to tzSetEnable and make sure you call vTraceEnable(TRC_INIT) in your target startup (not TRC_START).
tzSetEnable(1);
DEFINE BUTTON "Start Recording", "tzSetEnable(1)";
DEFINE BUTTON "Stop Recording", "tzSetEnable(0)";

@ -1,34 +0,0 @@
Tracealyzer Stream Port for ARM Cortex-M ITM
Percepio AB
www.percepio.com
--------------------------------------------
This directory contains a "stream port" for the Tracealyzer recorder library,
i.e., the specific code needed to use a particular interface for streaming a
Tracealyzer RTOS trace. The stream port is defined by a set of macros in
trcStreamPort.h, found in the "include" directory.
This particular stream port targets ARM's ITM interface, which together with
a fast debug probe such as a Keil ULINKpro or ULINKplus provides excellent
performance. This stream port does not use any RAM buffer for the trace, but
writes the data directly to the ITM registers. This is very fast.
To setup Keil uVision for ITM tracing with a Keil ULINKpro (or ULINKplus),
see Percepio Application Note PA-021, https://percepio.com/2018/05/04/keil-itm-support/
To setup IAR Embedded Workbench for ITM tracing with an IAR I-Jet,
see Percepio Application Note PA-023, https://percepio.com/iar
To setup Lauterbach TRACE32 for ITM tracing with a uTrace,
see Percepio Application Note PA-033, https://percepio.com/apn/PA033-TRACE32%20ITM%20Streaming.pdf
Learn more:
- Tracealyzer User Manual (Help -> User Manual)
- https://percepio.com/gettingstarted
- Percepio Application Note PA-021 (Keil), https://percepio.com/2018/05/04/keil-itm-support/
- Percepio Application Note PA-023 (IAR), https://percepio.com/iar
- Percepio Application Note PA-033 (Lauterbach), https://percepio.com/apn/PA033-TRACE32%20ITM%20Streaming.pdf
- About ITM trace, https://percepio.com/2016/06/09/arm-itm/
- About the recorder and custom streaming, http://percepio.com/2016/10/05/rtos-tracing
For questions, please contact support@percepio.com

@ -1,35 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The configuration for trace streaming ("stream ports").
*/
#ifndef TRC_STREAM_PORT_CONFIG_H
#define TRC_STREAM_PORT_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
/*******************************************************************************
* TRC_CFG_STREAM_PORT_ITM_PORT
*
* Valid values: 0 - 31
*
* What ITM port to use for the ITM software events. Make sure the IDE is
* configured for the same channel.
*
* Default: 1 (0 is typically terminal output and 31 is used by Keil)
*
******************************************************************************/
#define TRC_CFG_STREAM_PORT_ITM_PORT 1
#ifdef __cplusplus
}
#endif
#endif /* TRC_STREAM_PORT_CONFIG_H */

@ -1,117 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The interface definitions for trace streaming ("stream ports").
* This "stream port" sets up the recorder to use ARM ITM as streaming channel.
*
* To setup Keil uVision for ITM tracing with a Keil ULINKpro (or ULINKplus),
* see Percepio Application Note PA-021, available at
* https://percepio.com/2018/05/04/keil-itm-support/
*
* To setup IAR Embedded Workbench for ITM tracing with an IAR I-Jet,
* see Percepio Application Note PA-023, https://percepio.com/iar
*
* NOTE: This stream port may block the application in case the ITM port
* is not ready for more data (the TPIU FIFO has become full). This is
* necessary to avoid data loss, as the TPIU FIFO is often quite small.
*
* --- Direct vs. Indirect ITM streaming ---
* Direct streaming: By default, this stream port writes directly to the ITM
* register mode without any RAM buffer. This assumes you have a fast debug
* probe, like aKeil ULINKpro or IAR I-Jet, to avoid excessive blocking.
* In case the ITM blocking appears to disturb your application, make sure your
* debugger is configured for maximum performance, as described in the above
* Application Nodes.
*
* Indirect streaming: If direct streaming gives too much overhead, you may
* instead try indirect ITM streaming. This is done by enabling the internal
* RAM buffer, like below. This reconfigures the recorder to store the events
* in the internal RAM buffer instead of writing them directly to the ITM port.
*
* Set TRC_STREAM_PORT_USE_INTERNAL_BUFFER to 1 to use the indirect mode.
*
* This increases RAM usage but eliminates peaks in the trace data rate.
* Moreover, the ITM writes are then performed in a separate task (TzCtrl).
* You find relevant settings (buffer size etc.) in trcStreamingConfig.h.
*
* See also https://percepio.com/2018/10/11/tuning-your-custom-trace-streaming
*
* --- One-way vs. Two-way Communication ---
* The ITM port only provides one-way communication, from target to host.
* This is sufficient if you start the tracing from the target application,
* using vTraceEnable(TRC_START). Just make sure to start the Tracealyzer
* recording before you start the target system.
*
* In case you prefer to interactively start and stop the tracing from the host
* computer, you need two-way communication to send commands to the recorder.
* This is possible by writing such "start" and "stop" commands to a special
* buffer, monitored by the recorder library, using the debugger IDE.
* See trcStreamingPort.c and also the example macro for Keil uVision
* (Keil-uVision-Tracealyzer-ITM-Exporter.ini).
*/
#ifndef TRC_STREAM_PORT_H
#define TRC_STREAM_PORT_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <stdint.h>
#include <trcTypes.h>
#include <trcStreamPortConfig.h>
#ifdef __cplusplus
extern "C" {
#endif
#if ( !defined( TRC_CFG_STREAM_PORT_ITM_PORT ) || ( TRC_CFG_STREAM_PORT_ITM_PORT ) < 0 ) || ( ( TRC_CFG_STREAM_PORT_ITM_PORT ) > 31 )
#error "Invalid ITM port defined in trcStreamPortConfig.h."
#endif
/* Important for the ITM port - no RAM buffer, direct writes. In most other ports this can be skipped (default is 1) */
#define TRC_USE_INTERNAL_BUFFER 0
typedef struct TraceStreamPortBuffer
{
uint8_t buffer[ sizeof( TraceUnsignedBaseType_t ) ];
} TraceStreamPortBuffer_t;
traceResult prvTraceItmWrite( void * ptrData,
uint32_t size,
int32_t * ptrBytesWritten );
traceResult prvTraceItmRead( void * ptrData,
uint32_t uiSize,
int32_t * piBytesRead );
traceResult xTraceStreamPortInitialize( TraceStreamPortBuffer_t * pxBuffer );
#define xTraceStreamPortAllocate( uiSize, ppvData ) ( ( void ) uiSize, xTraceStaticBufferGet( ppvData ) )
#define xTraceStreamPortCommit( pvData, uiSize, piBytesCommitted ) prvTraceItmWrite( pvData, uiSize, piBytesCommitted )
#define xTraceStreamPortWriteData( pvData, uiSize, piBytesWritten ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_4( ( void ) pvData, ( void ) uiSize, ( void ) piBytesWritten, TRC_SUCCESS )
#define xTraceStreamPortReadData( pvData, uiSize, piBytesRead ) prvTraceItmRead( pvData, uiSize, piBytesRead )
#define xTraceStreamPortOnEnable( uiStartOption ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( ( void ) ( uiStartOption ), TRC_SUCCESS )
#define xTraceStreamPortOnDisable() TRC_COMMA_EXPR_TO_STATEMENT_EXPR_1( TRC_SUCCESS )
#define xTraceStreamPortOnTraceBegin() TRC_COMMA_EXPR_TO_STATEMENT_EXPR_1( TRC_SUCCESS )
#define xTraceStreamPortOnTraceEnd() TRC_COMMA_EXPR_TO_STATEMENT_EXPR_1( TRC_SUCCESS )
#ifdef __cplusplus
}
#endif
#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/
#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/
#endif /* TRC_STREAM_PORT_H */

@ -1,165 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* Supporting functions for trace streaming, used by the "stream ports"
* for reading and writing data to the interface.
* Existing ports can easily be modified to fit another setup, e.g., a
* different TCP/IP stack, or to define your own stream port.
*
* This stream port is for ITM streaming on Arm Cortex-M devices.
*
* To setup Keil uVision for ITM tracing with a Keil ULINKpro (or ULINKplus),
* see Percepio Application Note PA-021, available at
* https://percepio.com/2018/05/04/keil-itm-support/
*
* To setup IAR Embedded Workbench for ITM tracing with an IAR I-Jet,
* see Percepio Application Note PA-023, https://percepio.com/iar
*
* NOTE: This stream port may block the application in case the ITM port
* is not ready for more data (the TPIU FIFO has become full). This is
* necessary to avoid data loss, as the TPIU FIFO is often quite small.
*
* --- Direct vs. Indirect ITM streaming ---
* Direct streaming: By default, this stream port writes directly to the ITM
* register mode without any RAM buffer. This assumes you have a fast debug
* probe, like aKeil ULINKpro or IAR I-Jet, to avoid excessive blocking.
* In case the ITM blocking appears to disturb your application, make sure your
* debugger is configured for maximum performance, as described in the above
* Application Nodes.
*
* Indirect streaming: If direct streaming gives too much overhead, you may
* instead try indirect ITM streaming. This is done by enabling the internal
* RAM buffer, like below. This reconfigures the recorder to store the events
* in the internal RAM buffer instead of writing them directly to the ITM port.
*
* Set TRC_STREAM_PORT_USE_INTERNAL_BUFFER to 1 to use the indirect mode.
*
* This increases RAM usage but eliminates peaks in the trace data rate.
* Moreover, the ITM writes are then performed in a separate task (TzCtrl).
* You find relevant settings (buffer size etc.) in trcStreamingConfig.h.
*
* See also https://percepio.com/2018/10/11/tuning-your-custom-trace-streaming
*
* --- One-way vs. Two-way Communication ---
* The ITM port only provides one-way communication, from target to host.
* This is sufficient if you start the tracing from the target application,
* using vTraceEnable(TRC_START). Just make sure to start the Tracealyzer
* recording before you start the target system.
*
* In case you prefer to interactively start and stop the tracing from the host
* computer, you need two-way communication to send commands to the recorder.
* This is possible by writing such "start" and "stop" commands to a special
* buffer, monitored by the recorder library, using the debugger IDE.
* See trcStreamingPort.c and also the example macro for Keil uVision
* (Keil-uVision-Tracealyzer-ITM-Exporter.ini).
*/
#include <trcRecorder.h>
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
typedef struct TraceStreamPortFile
{
uint8_t buffer[ sizeof( TraceUnsignedBaseType_t ) ];
} TraceStreamPortFile_t;
static TraceStreamPortFile_t * pxStreamPortFile;
/* This will be set by the debugger when there is data to be read */
volatile int32_t tz_host_command_bytes_to_read = 0;
/* This will be filled with data from the debugger */
volatile char tz_host_command_data[ 32 ];
/* These variables are used for reading commands from the host, using read_from_host().
* This is not required if using vTraceEnable(TRC_START).
* A debugger IDE may write to these functions using a macro.
* An example for Keil is included (Keil-uVision-Tracealyzer-ITM-Exporter.ini). */
#define itm_write_32( __data ) \
{ \
if( ( CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk ) && /* Trace enabled? */ \
( ITM->TCR & ITM_TCR_ITMENA_Msk ) && /* ITM enabled? */ \
( ITM->TER & ( 1UL << ( TRC_CFG_STREAM_PORT_ITM_PORT ) ) ) ) /* ITM port enabled? */ \
{ \
while( ITM->PORT[ TRC_CFG_STREAM_PORT_ITM_PORT ].u32 == 0 ) { /* Do nothing */ } /* Block until room in ITM FIFO - This stream port is always in "blocking mode", since intended for high-speed ITM! */ \
ITM->PORT[ TRC_CFG_STREAM_PORT_ITM_PORT ].u32 = __data; /* Write the data */ \
} \
}
/* This is assumed to execute from within the recorder, with interrupts disabled */
traceResult prvTraceItmWrite( void * ptrData,
uint32_t size,
int32_t * ptrBytesWritten )
{
uint32_t * ptr32 = ( uint32_t * ) ptrData;
TRC_ASSERT( size % 4 == 0 );
TRC_ASSERT( ptrBytesWritten != 0 );
*ptrBytesWritten = 0;
while( *ptrBytesWritten < ( int32_t ) size )
{
itm_write_32( *ptr32 );
ptr32++;
*ptrBytesWritten += 4;
}
return TRC_SUCCESS;
}
/* This reads "command" data from a RAM buffer, written by a host macro in the debugger */
traceResult prvTraceItmRead( void * ptrData,
uint32_t uiSize,
int32_t * piBytesRead )
{
int32_t i;
uint8_t * bytesBuffer = ( uint8_t * ) ptrData;
TRC_ASSERT( piBytesRead != 0 );
/* Check if the debugger has updated tz_host_command_bytes_to_read */
if( tz_host_command_bytes_to_read > 0 )
{
if( tz_host_command_bytes_to_read != ( int32_t ) uiSize )
{
/* Sanity check. */
return TRC_FAIL;
}
*piBytesRead = ( int32_t ) tz_host_command_bytes_to_read;
/* Read the bytes */
for( i = 0; i < tz_host_command_bytes_to_read; i++ )
{
bytesBuffer[ i ] = tz_host_command_data[ i ];
}
/* Reset */
tz_host_command_bytes_to_read = 0;
}
return TRC_SUCCESS;
}
traceResult xTraceStreamPortInitialize( TraceStreamPortBuffer_t * pxBuffer )
{
TRC_ASSERT_EQUAL_SIZE( TraceStreamPortBuffer_t, TraceStreamPortFile_t );
TRC_ASSERT( pxBuffer != 0 );
pxStreamPortFile = ( TraceStreamPortFile_t * ) pxBuffer;
return TRC_SUCCESS;
}
#endif /* if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING ) */
#endif /* if ( TRC_USE_TRACEALYZER_RECORDER == 1 ) */

@ -1,18 +0,0 @@
Tracealyzer Stream Port for Files
Percepio AB
www.percepio.com
-------------------------------------------------
This directory contains a "stream port" for the Tracealyzer recorder library,
i.e., the specific code needed to use a particular interface for streaming a
Tracealyzer RTOS trace. The stream port is defined by a set of macros in
trcStreamPort.h, found in the "include" directory.
This particular stream port is for streaming to a file via stdio.h (fwrite).
To use this stream port, make sure that include/trcStreamPort.h is found
by the compiler (i.e., add this folder to your project's include paths) and
add all included source files to your build. Make sure no other versions of
trcStreamPort.h are included by mistake!
See also http://percepio.com/2016/10/05/rtos-tracing.

@ -1,39 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The configuration for trace streaming ("stream ports").
*/
#ifndef TRC_STREAM_PORT_CONFIG_H
#define TRC_STREAM_PORT_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
/* Default file name */
#ifndef TRC_CFG_STREAM_PORT_TRACE_FILE
#define TRC_CFG_STREAM_PORT_TRACE_FILE "trace.psf"
#endif
/* This define will determine whether to use the internal buffer or not.
* If file writing creates additional trace events (i.e. it uses semaphores or mutexes),
* then the internal buffer must be enabled to avoid infinite recursion. */
#define TRC_CFG_STREAM_PORT_USE_INTERNAL_BUFFER 0
/*******************************************************************************
* Configuration Macro: TRC_CFG_STREAM_PORT_BUFFER_SIZE
*
* Specifies the size of the internal buffer, if one is used.
******************************************************************************/
#define TRC_CFG_STREAM_PORT_BUFFER_SIZE 10000
#ifdef __cplusplus
}
#endif
#endif /* TRC_STREAM_PORT_CONFIG_H */

@ -1,84 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The interface definitions for trace streaming ("stream ports").
* This "stream port" sets up the recorder to stream the trace to file.
*/
#ifndef TRC_STREAM_PORT_H
#define TRC_STREAM_PORT_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <stdint.h>
#include <trcTypes.h>
#include <trcStreamPortConfig.h>
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
#define TRC_USE_INTERNAL_BUFFER ( TRC_CFG_STREAM_PORT_USE_INTERNAL_BUFFER )
/* Default file name */
#ifndef TRC_CFG_STREAM_PORT_TRACE_FILE
#define TRC_CFG_STREAM_PORT_TRACE_FILE "trace.psf"
#endif
typedef struct TraceStreamPortFile
{
FILE * pxFile;
#if ( TRC_USE_INTERNAL_BUFFER )
uint8_t buffer[ TRC_STREAM_PORT_BUFFER_SIZE ];
#endif
} TraceStreamPortFile_t;
extern TraceStreamPortFile_t * pxStreamPortFile;
#define TRC_STREAM_PORT_BUFFER_SIZE ( sizeof( TraceStreamPortFile_t ) )
typedef struct TraceStreamPortBuffer
{
uint8_t buffer[ TRC_STREAM_PORT_BUFFER_SIZE ];
} TraceStreamPortBuffer_t;
traceResult xTraceStreamPortInitialize( TraceStreamPortBuffer_t * pxBuffer );
#define xTraceStreamPortAllocate( uiSize, ppvData ) ( ( void ) ( uiSize ), xTraceStaticBufferGet( ppvData ) )
#if ( TRC_USE_INTERNAL_BUFFER == 1 )
/* Push to internal buffer. It will call on xTraceStreamPortWriteData() periodically. */
#define xTraceStreamPortCommit( pvData, uiSize, piBytesCommitted ) xTraceInternalEventBufferPush( pvData, uiSize, piBytesCommitted )
#else
/* Write directly to file */
#define xTraceStreamPortCommit( pvData, uiSize, piBytesCommitted ) xTraceStreamPortWriteData( pvData, uiSize, piBytesCommitted )
#endif
#define xTraceStreamPortWriteData( pvData, uiSize, piBytesWritten ) ( *( piBytesWritten ) = fwrite( pvData, 1, uiSize, pxStreamPortFile->pxFile ), TRC_SUCCESS )
#define xTraceStreamPortReadData( pvData, uiSize, piBytesRead ) ( ( void ) ( pvData ), ( void ) ( uiSize ), ( void ) ( piBytesRead ), TRC_SUCCESS )
#define xTraceStreamPortOnEnable( uiStartOption ) ( ( void ) ( uiStartOption ), TRC_SUCCESS )
#define xTraceStreamPortOnDisable() ( TRC_SUCCESS )
traceResult xTraceStreamPortOnTraceBegin( void );
traceResult xTraceStreamPortOnTraceEnd( void );
#ifdef __cplusplus
}
#endif
#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/
#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/
#endif /* TRC_STREAM_PORT_H */

@ -1,83 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* Supporting functions for trace streaming, used by the "stream ports"
* for reading and writing data to the interface.
* Existing ports can easily be modified to fit another setup, e.g., a
* different TCP/IP stack, or to define your own stream port.
*/
#include <trcRecorder.h>
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
TraceStreamPortFile_t * pxStreamPortFile;
traceResult xTraceStreamPortInitialize( TraceStreamPortBuffer_t * pxBuffer )
{
TRC_ASSERT_EQUAL_SIZE( TraceStreamPortBuffer_t, TraceStreamPortFile_t );
TRC_ASSERT( pxBuffer != 0 );
pxStreamPortFile = ( TraceStreamPortFile_t * ) pxBuffer;
pxStreamPortFile->pxFile = 0;
#if ( TRC_USE_INTERNAL_BUFFER == 1 )
return xTraceInternalEventBufferInitialize( pxStreamPortFile->buffer, sizeof( pxStreamPortFile->buffer ) );
#else
return TRC_SUCCESS;
#endif
}
traceResult xTraceStreamPortOnTraceBegin( void )
{
if( pxStreamPortFile == 0 )
{
return TRC_FAIL;
}
if( pxStreamPortFile->pxFile == 0 )
{
errno_t err = fopen_s( &pxStreamPortFile->pxFile, TRC_CFG_STREAM_PORT_TRACE_FILE, "wb" );
if( err != 0 )
{
printf( "Could not open trace file, error code %d.\n", err );
return TRC_FAIL;
}
else
{
printf( "Trace file created.\n" );
}
}
return TRC_SUCCESS;
}
traceResult xTraceStreamPortOnTraceEnd( void )
{
if( pxStreamPortFile == 0 )
{
return TRC_FAIL;
}
if( pxStreamPortFile->pxFile != 0 )
{
fclose( pxStreamPortFile->pxFile );
pxStreamPortFile->pxFile = 0;
printf( "Trace file closed.\n" );
}
return TRC_SUCCESS;
}
#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/
#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/

@ -1,21 +0,0 @@
Tracealyzer Stream Port for SEGGER J-Link
Percepio AB
www.percepio.com
-----------------------------------------
This directory contains a "stream port" for the Tracealyzer recorder library,
i.e., the specific code needed to use a particular interface for streaming a
Tracealyzer RTOS trace. The stream port is defined by a set of macros in
trcStreamPort.h, found in the "include" directory.
This particular stream port targets SEGGER J-Link debug probes, using the RTT
interface provided by SEGGER.
To use this stream port, make sure that include/trcStreamPort.h is found
by the compiler (i.e., add this folder to your project's include paths) and
add all included source files to your build. Make sure no other versions of
trcStreamPort.h are included by mistake!
Note that this stream port also contains SEGGER's RTT driver.
See also http://percepio.com/2016/10/05/rtos-tracing.

@ -1,123 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The configuration for trace streaming ("stream ports").
*/
#ifndef TRC_STREAM_PORT_CONFIG_H
#define TRC_STREAM_PORT_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
/* This define will determine whether to use the internal buffer or not.
* If file writing creates additional trace events (i.e. it uses semaphores or mutexes),
* then the internal buffer must be enabled to avoid infinite recursion. */
#define TRC_CFG_STREAM_PORT_USE_INTERNAL_BUFFER 0
/**
* @def TRC_CFG_INTERNAL_BUFFER_SIZE
*
* @brief Configures the size of the internal buffer if used.
* is enabled.
*/
#define TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_SIZE 5000
/**
* @def TRC_CFG_STREAM_PORT_RTT_UP_BUFFER_SIZE
*
* @brief Defines the size of the "up" RTT buffer (target -> host) to use for writing
* the trace data, for RTT buffer 1 or higher.
*
* This setting is ignored for RTT buffer 0, which can't be reconfigured
* in runtime and therefore hard-coded to use the defines in SEGGER_RTT_Conf.h.
*
* Default buffer size for Tracealyzer is 5000 bytes.
*
* If you have a stand-alone J-Link probe, the can be decreased to around 1 KB.
* But integrated J-Link OB interfaces are slower and needs about 5-10 KB,
* depending on the amount of data produced.
*/
#define TRC_CFG_STREAM_PORT_RTT_UP_BUFFER_SIZE 5000
/**
* @def TRC_CFG_STREAM_PORT_RTT_DOWN_BUFFER_SIZE
*
* @brief Defines the size of the "down" RTT buffer (host -> target) to use for reading
* commands from Tracealyzer, for RTT buffer 1 or higher.
*
* Default buffer size for Tracealyzer is 32 bytes.
*
* This setting is ignored for RTT buffer 0, which can't be reconfigured
* in runtime and therefore hard-coded to use the defines in SEGGER_RTT_Conf.h.
*/
#define TRC_CFG_STREAM_PORT_RTT_DOWN_BUFFER_SIZE 32
/**
* @def TRC_CFG_STREAM_PORT_RTT_UP_BUFFER_INDEX
*
* @brief Defines the RTT buffer to use for writing the trace data. Make sure that
* the PC application has the same setting (File->Settings).
*
* Default: 1
*
* We don't recommend using RTT buffer 0, since mainly intended for terminals.
* If you prefer to use buffer 0, it must be configured in SEGGER_RTT_Conf.h.
*/
#define TRC_CFG_STREAM_PORT_RTT_UP_BUFFER_INDEX 1
/**
* @def TRC_CFG_STREAM_PORT_RTT_DOWN_BUFFER_INDEX
*
* @brief Defines the RTT buffer to use for reading the trace data. Make sure that
* the PC application has the same setting (File->Settings).
*
* Default: 1
*
* We don't recommend using RTT buffer 0, since mainly intended for terminals.
* If you prefer to use buffer 0, it must be configured in SEGGER_RTT_Conf.h.
*/
#define TRC_CFG_STREAM_PORT_RTT_DOWN_BUFFER_INDEX 1
/**
* @def TRC_CFG_STREAM_PORT_RTT_MODE
*
* @brief This stream port for J-Link streaming relies on SEGGER RTT, that contains an
* internal RAM buffer read by the J-Link probes during execution.
*
* Possible values:
* - SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
* - SEGGER_RTT_MODE_NO_BLOCK_SKIP (default)
*
* Using SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL ensure that you get a
* complete and valid trace. This may however cause blocking if your streaming
* interface isn't fast enough, which may disturb the real-time behavior.
*
* We therefore recommend SEGGER_RTT_MODE_NO_BLOCK_SKIP. In this mode,
* Tracealyzer will report lost events if the transfer is not
* fast enough. In that case, try increasing the size of the "up buffer".
*/
#define TRC_CFG_STREAM_PORT_RTT_MODE SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
/**
* @def TRC_CFG_STREAM_PORT_RTT_NO_LOCK_WRITE
*
* @brief Sets if RTT should write without locking or not when writing
* RTT data. This should normally be disabled with an exception being
* Zephyr, where the SEGGER RTT locks aren't necessary and causes
* problems if enabled.
*
* Default: 0
*/
#define TRC_CFG_STREAM_PORT_RTT_NO_LOCK_WRITE 0
#ifdef __cplusplus
}
#endif
#endif /* TRC_STREAM_PORT_CONFIG_H */

@ -1,275 +0,0 @@
/*********************************************************************
* SEGGER MICROCONTROLLER GmbH & Co. KG *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 2014 - 2016 SEGGER Microcontroller GmbH & Co. KG *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* SEGGER RTT * Real Time Transfer for embedded targets *
* *
**********************************************************************
* *
* All rights reserved. *
* *
* * This software may in its unmodified form be freely redistributed *
* in source, linkable, or executable form. *
* * The source code may be modified, provided the source code *
* retains the above copyright notice, this list of conditions and *
* the following disclaimer. *
* * Modified versions of this software in source, executable, or *
* linkable form may not be distributed without prior consent of *
* SEGGER. *
* * This software may only be used for communication with SEGGER *
* J-Link debug probes. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
**********************************************************************
* *
* RTT version: 6.00e *
* *
**********************************************************************
* ---------------------------END-OF-HEADER------------------------------
* File : SEGGER_RTT.h
* Purpose : Implementation of SEGGER real-time transfer which allows
* real-time communication on targets which support debugger
* memory accesses while the CPU is running.
* Revision: $Rev: 4079 $
* ----------------------------------------------------------------------
*/
#ifndef SEGGER_RTT_H
#define SEGGER_RTT_H
#include "SEGGER_RTT_Conf.h"
/*********************************************************************
*
* Defines, fixed
*
**********************************************************************
*/
/*********************************************************************
*
* Types
*
**********************************************************************
*/
/* */
/* Description for a circular buffer (also called "ring buffer") */
/* which is used as up-buffer (T->H) */
/* */
typedef struct
{
const char * sName; /* Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4" */
char * pBuffer; /* Pointer to start of buffer */
unsigned SizeOfBuffer; /* Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty. */
unsigned WrOff; /* Position of next item to be written by either target. */
volatile unsigned RdOff; /* Position of next item to be read by host. Must be volatile since it may be modified by host. */
unsigned Flags; /* Contains configuration flags */
} SEGGER_RTT_BUFFER_UP;
/* */
/* Description for a circular buffer (also called "ring buffer") */
/* which is used as down-buffer (H->T) */
/* */
typedef struct
{
const char * sName; /* Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4" */
char * pBuffer; /* Pointer to start of buffer */
unsigned SizeOfBuffer; /* Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty. */
volatile unsigned WrOff; /* Position of next item to be written by host. Must be volatile since it may be modified by host. */
unsigned RdOff; /* Position of next item to be read by target (down-buffer). */
unsigned Flags; /* Contains configuration flags */
} SEGGER_RTT_BUFFER_DOWN;
/* */
/* RTT control block which describes the number of buffers available */
/* as well as the configuration for each buffer */
/* */
/* */
typedef struct
{
char acID[ 16 ]; /* Initialized to "SEGGER RTT" */
int MaxNumUpBuffers; /* Initialized to SEGGER_RTT_MAX_NUM_UP_BUFFERS (type. 2) */
int MaxNumDownBuffers; /* Initialized to SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (type. 2) */
SEGGER_RTT_BUFFER_UP aUp[ SEGGER_RTT_MAX_NUM_UP_BUFFERS ]; /* Up buffers, transferring information up from target via debug probe to host */
SEGGER_RTT_BUFFER_DOWN aDown[ SEGGER_RTT_MAX_NUM_DOWN_BUFFERS ]; /* Down buffers, transferring information down from host via debug probe to target */
} SEGGER_RTT_CB;
/*********************************************************************
*
* Global data
*
**********************************************************************
*/
extern SEGGER_RTT_CB _SEGGER_RTT;
/*********************************************************************
*
* RTT API functions
*
**********************************************************************
*/
#ifdef __cplusplus
extern "C" {
#endif
int SEGGER_RTT_AllocDownBuffer( const char * sName,
void * pBuffer,
unsigned BufferSize,
unsigned Flags );
int SEGGER_RTT_AllocUpBuffer( const char * sName,
void * pBuffer,
unsigned BufferSize,
unsigned Flags );
int SEGGER_RTT_ConfigUpBuffer( unsigned BufferIndex,
const char * sName,
void * pBuffer,
unsigned BufferSize,
unsigned Flags );
int SEGGER_RTT_ConfigDownBuffer( unsigned BufferIndex,
const char * sName,
void * pBuffer,
unsigned BufferSize,
unsigned Flags );
int SEGGER_RTT_GetKey( void );
unsigned SEGGER_RTT_HasData( unsigned BufferIndex );
int SEGGER_RTT_HasKey( void );
void SEGGER_RTT_Init( void );
unsigned SEGGER_RTT_Read( unsigned BufferIndex,
void * pBuffer,
unsigned BufferSize );
unsigned SEGGER_RTT_ReadNoLock( unsigned BufferIndex,
void * pData,
unsigned BufferSize );
int SEGGER_RTT_SetNameDownBuffer( unsigned BufferIndex,
const char * sName );
int SEGGER_RTT_SetNameUpBuffer( unsigned BufferIndex,
const char * sName );
int SEGGER_RTT_SetFlagsDownBuffer( unsigned BufferIndex,
unsigned Flags );
int SEGGER_RTT_SetFlagsUpBuffer( unsigned BufferIndex,
unsigned Flags );
int SEGGER_RTT_WaitKey( void );
unsigned SEGGER_RTT_Write( unsigned BufferIndex,
const void * pBuffer,
unsigned NumBytes );
unsigned SEGGER_RTT_WriteNoLock( unsigned BufferIndex,
const void * pBuffer,
unsigned NumBytes );
unsigned SEGGER_RTT_WriteSkipNoLock( unsigned BufferIndex,
const void * pBuffer,
unsigned NumBytes );
unsigned SEGGER_RTT_WriteString( unsigned BufferIndex,
const char * s );
void SEGGER_RTT_WriteWithOverwriteNoLock( unsigned BufferIndex,
const void * pBuffer,
unsigned NumBytes );
/* */
/* Function macro for performance optimization */
/* */
#define SEGGER_RTT_HASDATA( n ) ( _SEGGER_RTT.aDown[ n ].WrOff - _SEGGER_RTT.aDown[ n ].RdOff )
/*********************************************************************
*
* RTT "Terminal" API functions
*
**********************************************************************
*/
int SEGGER_RTT_SetTerminal( char TerminalId );
int SEGGER_RTT_TerminalOut( char TerminalId,
const char * s );
/*********************************************************************
*
* RTT printf functions (require SEGGER_RTT_printf.c)
*
**********************************************************************
*/
int SEGGER_RTT_printf( unsigned BufferIndex,
const char * sFormat,
... );
#ifdef __cplusplus
}
#endif
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
/* */
/* Operating modes. Define behavior if buffer is full (not enough space for entire message) */
/* */
#define SEGGER_RTT_MODE_NO_BLOCK_SKIP ( 0U ) /* Skip. Do not block, output nothing. (Default) */
#define SEGGER_RTT_MODE_NO_BLOCK_TRIM ( 1U ) /* Trim: Do not block, output as much as fits. */
#define SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL ( 2U ) /* Block: Wait until there is space in the buffer. */
#define SEGGER_RTT_MODE_MASK ( 3U )
/* */
/* Control sequences, based on ANSI. */
/* Can be used to control color, and clear the screen */
/* */
#define RTT_CTRL_RESET "" /* Reset to default colors */
#define RTT_CTRL_CLEAR "" /* Clear screen, reposition cursor to top left */
#define RTT_CTRL_TEXT_BLACK ""
#define RTT_CTRL_TEXT_RED ""
#define RTT_CTRL_TEXT_GREEN ""
#define RTT_CTRL_TEXT_YELLOW ""
#define RTT_CTRL_TEXT_BLUE ""
#define RTT_CTRL_TEXT_MAGENTA ""
#define RTT_CTRL_TEXT_CYAN ""
#define RTT_CTRL_TEXT_WHITE ""
#define RTT_CTRL_TEXT_BRIGHT_BLACK ""
#define RTT_CTRL_TEXT_BRIGHT_RED ""
#define RTT_CTRL_TEXT_BRIGHT_GREEN ""
#define RTT_CTRL_TEXT_BRIGHT_YELLOW ""
#define RTT_CTRL_TEXT_BRIGHT_BLUE ""
#define RTT_CTRL_TEXT_BRIGHT_MAGENTA ""
#define RTT_CTRL_TEXT_BRIGHT_CYAN ""
#define RTT_CTRL_TEXT_BRIGHT_WHITE ""
#define RTT_CTRL_BG_BLACK ""
#define RTT_CTRL_BG_RED ""
#define RTT_CTRL_BG_GREEN ""
#define RTT_CTRL_BG_YELLOW ""
#define RTT_CTRL_BG_BLUE ""
#define RTT_CTRL_BG_MAGENTA ""
#define RTT_CTRL_BG_CYAN ""
#define RTT_CTRL_BG_WHITE ""
#define RTT_CTRL_BG_BRIGHT_BLACK ""
#define RTT_CTRL_BG_BRIGHT_RED ""
#define RTT_CTRL_BG_BRIGHT_GREEN ""
#define RTT_CTRL_BG_BRIGHT_YELLOW ""
#define RTT_CTRL_BG_BRIGHT_BLUE ""
#define RTT_CTRL_BG_BRIGHT_MAGENTA ""
#define RTT_CTRL_BG_BRIGHT_CYAN ""
#define RTT_CTRL_BG_BRIGHT_WHITE ""
#endif /* ifndef SEGGER_RTT_H */
/*************************** End of file ****************************/

@ -1,279 +0,0 @@
/*********************************************************************
* SEGGER MICROCONTROLLER GmbH & Co. KG *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 2014 - 2016 SEGGER Microcontroller GmbH & Co. KG *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* SEGGER RTT * Real Time Transfer for embedded targets *
* *
**********************************************************************
* *
* All rights reserved. *
* *
* * This software may in its unmodified form be freely redistributed *
* in source, linkable, or executable form. *
* * The source code may be modified, provided the source code *
* retains the above copyright notice, this list of conditions and *
* the following disclaimer. *
* * Modified versions of this software in source, executable, or *
* linkable form may not be distributed without prior consent of *
* SEGGER. *
* * This software may only be used for communication with SEGGER *
* J-Link debug probes. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
**********************************************************************
* *
* RTT version: 6.00e *
* *
**********************************************************************
* ----------------------------------------------------------------------
* File : SEGGER_RTT_Conf.h
* Purpose : Implementation of SEGGER real-time transfer (RTT) which
* allows real-time communication on targets which support
* debugger memory accesses while the CPU is running.
* Revision: $Rev: 3892 $
* ---------------------------END-OF-HEADER------------------------------
*/
#ifndef SEGGER_RTT_CONF_H
#define SEGGER_RTT_CONF_H
#ifdef __IAR_SYSTEMS_ICC__
#include <intrinsics.h>
#endif
/*********************************************************************
*
* Defines, configurable
*
**********************************************************************
*/
#define SEGGER_RTT_MAX_NUM_UP_BUFFERS ( 3 ) /* Max. number of up-buffers (T->H) available on this target (Default: 3) */
#define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS ( 3 ) /* Max. number of down-buffers (H->T) available on this target (Default: 3) */
#define BUFFER_SIZE_UP ( 64 ) /* Size of the buffer for terminal output of target, up to host (Default: 1k) */
#define BUFFER_SIZE_DOWN ( 16 ) /* Size of the buffer for terminal input to target from host (Usually keyboard input) (Default: 16) */
#define SEGGER_RTT_PRINTF_BUFFER_SIZE ( 64u ) /* Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64) */
#define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP /* Mode for pre-initialized terminal channel (buffer 0) */
/* This can be used to place the RTT control block in the right memory range, if no found automatically. */
/* This example is for NXP LPC54018, needs to be adapted for each MCU family. */
/*#define SEGGER_RTT_SECTION ".data.$RAM2" */
/* */
/* Target is not allowed to perform other RTT operations while string still has not been stored completely. */
/* Otherwise we would probably end up with a mixed string in the buffer. */
/* If using RTT from within interrupts, multiple tasks or multi processors, define the SEGGER_RTT_LOCK() and SEGGER_RTT_UNLOCK() function here. */
/* */
/* SEGGER_RTT_MAX_INTERRUPT_PRIORITY can be used in the sample lock routines on Cortex-M3/4. */
/* Make sure to mask all interrupts which can send RTT data, i.e. generate SystemView events, or cause task switches. */
/* When high-priority interrupts must not be masked while sending RTT data, SEGGER_RTT_MAX_INTERRUPT_PRIORITY needs to be adjusted accordingly. */
/* (Higher priority = lower priority number) */
/* Default value for embOS: 128u */
/* Default configuration in FreeRTOS: configMAX_SYSCALL_INTERRUPT_PRIORITY: ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) */
/* In case of doubt mask all interrupts: 1 << (8 - BASEPRI_PRIO_BITS) i.e. 1 << 5 when 3 bits are implemented in NVIC */
/* or define SEGGER_RTT_LOCK() to completely disable interrupts. */
/* */
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY ( 0x20 ) /* Interrupt priority to lock on SEGGER_RTT_LOCK on Cortex-M3/4 (Default: 0x20) */
/*********************************************************************
*
* RTT lock configuration for SEGGER Embedded Studio,
* Rowley CrossStudio and GCC
*/
#if ( defined __SES_ARM ) || ( defined __CROSSWORKS_ARM ) || ( defined __GNUC__ )
#ifdef __ARM_ARCH_6M__
#define SEGGER_RTT_LOCK() \
{ \
unsigned int LockState; \
__asm volatile ( "mrs %0, primask \n\t" \
"mov r1, $1 \n\t" \
"msr primask, r1 \n\t" \
: "=r" ( LockState ) \
: \
: "r1" \
);
#define SEGGER_RTT_UNLOCK() \
__asm volatile ( "msr primask, %0 \n\t" \
: \
: "r" ( LockState ) \
: \
); \
}
#elif ( defined( __ARM_ARCH_7M__ ) || defined( __ARM_ARCH_7EM__ ) )
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY ( 0x20 )
#endif
#define SEGGER_RTT_LOCK() \
{ \
unsigned int LockState; \
__asm volatile ( "mrs %0, basepri \n\t" \
"mov r1, %1 \n\t" \
"msr basepri, r1 \n\t" \
: "=r" ( LockState ) \
: "i" ( SEGGER_RTT_MAX_INTERRUPT_PRIORITY ) \
: "r1" \
);
#define SEGGER_RTT_UNLOCK() \
__asm volatile ( "msr basepri, %0 \n\t" \
: \
: "r" ( LockState ) \
: \
); \
}
#elif defined( __ARM_ARCH_7A__ )
#define SEGGER_RTT_LOCK() \
{ \
unsigned int LockState; \
__asm volatile ( "mrs r1, CPSR \n\t" \
"mov %0, r1 \n\t" \
"orr r1, r1, #0xC0 \n\t" \
"msr CPSR_c, r1 \n\t" \
: "=r" ( LockState ) \
: \
: "r1" \
);
#define SEGGER_RTT_UNLOCK() \
__asm volatile ( "mov r0, %0 \n\t" \
"mrs r1, CPSR \n\t" \
"bic r1, r1, #0xC0 \n\t" \
"and r0, r0, #0xC0 \n\t" \
"orr r1, r1, r0 \n\t" \
"msr CPSR_c, r1 \n\t" \
: \
: "r" ( LockState ) \
: "r0", "r1" \
); \
}
#else /* ifdef __ARM_ARCH_6M__ */
#define SEGGER_RTT_LOCK()
#define SEGGER_RTT_UNLOCK()
#endif /* ifdef __ARM_ARCH_6M__ */
#endif /* if ( defined __SES_ARM ) || ( defined __CROSSWORKS_ARM ) || ( defined __GNUC__ ) */
/*********************************************************************
*
* RTT lock configuration for IAR EWARM
*/
#ifdef __ICCARM__
#if ( defined( __ARM6M__ ) && ( __CORE__ == __ARM6M__ ) )
#define SEGGER_RTT_LOCK() \
{ \
unsigned int LockState; \
LockState = __get_PRIMASK(); \
__set_PRIMASK( 1 );
#define SEGGER_RTT_UNLOCK() \
__set_PRIMASK( LockState ); \
}
#elif ( ( defined( __ARM7EM__ ) && ( __CORE__ == __ARM7EM__ ) ) || ( defined( __ARM7M__ ) && ( __CORE__ == __ARM7M__ ) ) )
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY ( 0x20 )
#endif
#define SEGGER_RTT_LOCK() \
{ \
unsigned int LockState; \
LockState = __get_BASEPRI(); \
__set_BASEPRI( SEGGER_RTT_MAX_INTERRUPT_PRIORITY );
#define SEGGER_RTT_UNLOCK() \
__set_BASEPRI( LockState ); \
}
#endif /* if ( defined( __ARM6M__ ) && ( __CORE__ == __ARM6M__ ) ) */
#endif /* ifdef __ICCARM__ */
/*********************************************************************
*
* RTT lock configuration for IAR RX
*/
#ifdef __ICCRX__
#define SEGGER_RTT_LOCK() \
{ \
unsigned long LockState; \
LockState = __get_interrupt_state(); \
__disable_interrupt();
#define SEGGER_RTT_UNLOCK() \
__set_interrupt_state( LockState ); \
}
#endif
/*********************************************************************
*
* RTT lock configuration for KEIL ARM
*/
#ifdef __CC_ARM
#if ( defined __TARGET_ARCH_6S_M )
#define SEGGER_RTT_LOCK() \
{ \
unsigned int LockState; \
register unsigned char PRIMASK __asm( "primask" ); \
LockState = PRIMASK; \
PRIMASK = 1u; \
__schedule_barrier();
#define SEGGER_RTT_UNLOCK() \
PRIMASK = LockState; \
__schedule_barrier(); \
}
#elif ( defined( __TARGET_ARCH_7_M ) || defined( __TARGET_ARCH_7E_M ) )
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY ( 0x20 )
#endif
#define SEGGER_RTT_LOCK() \
{ \
unsigned int LockState; \
register unsigned char BASEPRI __asm( "basepri" ); \
LockState = BASEPRI; \
BASEPRI = SEGGER_RTT_MAX_INTERRUPT_PRIORITY; \
__schedule_barrier();
#define SEGGER_RTT_UNLOCK() \
BASEPRI = LockState; \
__schedule_barrier(); \
}
#endif /* if ( defined __TARGET_ARCH_6S_M ) */
#endif /* ifdef __CC_ARM */
/*********************************************************************
*
* RTT lock configuration fallback
*/
#ifndef SEGGER_RTT_LOCK
#define SEGGER_RTT_LOCK() /* Lock RTT (nestable) (i.e. disable interrupts) */
#endif
#ifndef SEGGER_RTT_UNLOCK
#define SEGGER_RTT_UNLOCK() /* Unlock RTT (nestable) (i.e. enable previous interrupt lock state) */
#endif
#endif /* ifndef SEGGER_RTT_CONF_H */
/*************************** End of file ****************************/

@ -1,143 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The interface definitions for trace streaming ("stream ports").
* This "stream port" sets up the recorder to use SEGGER RTT as streaming channel.
*
* Note that this stream port is more complex than the typical case, since
* the J-Link interface uses a separate RAM buffer in SEGGER_RTT.c, instead
* of the default buffer included in the recorder core. The other stream ports
* offer more typical examples of how to define a custom streaming interface.
*/
#ifndef TRC_STREAM_PORT_H
#define TRC_STREAM_PORT_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#ifdef __cplusplus
extern "C" {
#endif
#include <trcTypes.h>
#include <trcStreamPortConfig.h>
#include <SEGGER_RTT_Conf.h>
#include <SEGGER_RTT.h>
#define TRC_USE_INTERNAL_BUFFER ( TRC_CFG_STREAM_PORT_USE_INTERNAL_BUFFER )
/* Aligned */
#define TRC_STREAM_PORT_INTERNAL_BUFFER_SIZE ( ( ( ( TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_SIZE ) + sizeof( TraceUnsignedBaseType_t ) - 1 ) / sizeof( TraceUnsignedBaseType_t ) ) * sizeof( TraceUnsignedBaseType_t ) )
/* Aligned */
#define TRC_STREAM_PORT_RTT_UP_BUFFER_SIZE ( ( ( ( TRC_CFG_STREAM_PORT_RTT_UP_BUFFER_SIZE ) + sizeof( TraceUnsignedBaseType_t ) - 1 ) / sizeof( TraceUnsignedBaseType_t ) ) * sizeof( TraceUnsignedBaseType_t ) )
/* Aligned */
#define TRC_STREAM_PORT_RTT_DOWN_BUFFER_SIZE ( ( ( ( TRC_CFG_STREAM_PORT_RTT_DOWN_BUFFER_SIZE ) + sizeof( TraceUnsignedBaseType_t ) - 1 ) / sizeof( TraceUnsignedBaseType_t ) ) * sizeof( TraceUnsignedBaseType_t ) )
/**
* @brief A structure representing the trace stream port buffer.
*/
typedef struct TraceStreamPortBuffer
{
#if ( TRC_USE_INTERNAL_BUFFER == 1 )
uint8_t bufferInternal[ TRC_STREAM_PORT_INTERNAL_BUFFER_SIZE ];
#endif
uint8_t bufferUp[ TRC_STREAM_PORT_RTT_UP_BUFFER_SIZE ];
uint8_t bufferDown[ TRC_STREAM_PORT_RTT_DOWN_BUFFER_SIZE ];
} TraceStreamPortBuffer_t;
/**
* @internal Stream port initialize callback.
*
* This function is called by the recorder as part of its initialization phase.
*
* @param[in] pxBuffer Buffer
*
* @retval TRC_FAIL Initialization failed
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStreamPortInitialize( TraceStreamPortBuffer_t * pxBuffer );
/**
* @brief Allocates data from the stream port.
*
* @param[in] uiSize Allocation size
* @param[out] ppvData Allocation data pointer
*
* @retval TRC_FAIL Allocate failed
* @retval TRC_SUCCESS Success
*/
#define xTraceStreamPortAllocate( uiSize, ppvData ) ( ( void ) ( uiSize ), xTraceStaticBufferGet( ppvData ) )
/**
* @brief Commits data to the stream port, depending on the implementation/configuration of the
* stream port this data might be directly written to the stream port interface, buffered, or
* something else.
*
* @param[in] pvData Data to commit
* @param[in] uiSize Data to commit size
* @param[out] piBytesCommitted Bytes committed
*
* @retval TRC_FAIL Commit failed
* @retval TRC_SUCCESS Success
*/
#if ( TRC_USE_INTERNAL_BUFFER == 1 )
#define xTraceStreamPortCommit xTraceInternalEventBufferPush
#else
#define xTraceStreamPortCommit xTraceStreamPortWriteData
#endif
/**
* @brief Writes data through the stream port interface.
*
* @param[in] pvData Data to write
* @param[in] uiSize Data to write size
* @param[out] piBytesWritten Bytes written
*
* @retval TRC_FAIL Write failed
* @retval TRC_SUCCESS Success
*/
#if ( defined( TRC_CFG_STREAM_PORT_RTT_NO_LOCK_WRITE ) && TRC_CFG_STREAM_PORT_RTT_NO_LOCK_WRITE == 1 )
#define xTraceStreamPortWriteData( pvData, uiSize, piBytesWritten ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( *( piBytesWritten ) = ( int32_t ) SEGGER_RTT_WriteNoLock( ( TRC_CFG_STREAM_PORT_RTT_UP_BUFFER_INDEX ), ( const char * ) pvData, uiSize ), TRC_SUCCESS )
#else
#define xTraceStreamPortWriteData( pvData, uiSize, piBytesWritten ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( *( piBytesWritten ) = ( int32_t ) SEGGER_RTT_Write( ( TRC_CFG_STREAM_PORT_RTT_UP_BUFFER_INDEX ), ( const char * ) pvData, uiSize ), TRC_SUCCESS )
#endif
/**
* @brief Reads data through the stream port interface.
*
* @param[in] pvData Destination data buffer
* @param[in] uiSize Destination data buffer size
* @param[out] piBytesRead Bytes read
*
* @retval TRC_FAIL Read failed
* @retval TRC_SUCCESS Success
*/
#define xTraceStreamPortReadData( pvData, uiSize, piBytesRead ) ( ( SEGGER_RTT_HASDATA( TRC_CFG_STREAM_PORT_RTT_DOWN_BUFFER_INDEX ) ) ? ( *( piBytesRead ) = ( int32_t ) SEGGER_RTT_Read( ( TRC_CFG_STREAM_PORT_RTT_DOWN_BUFFER_INDEX ), ( char * ) ( pvData ), uiSize ), TRC_SUCCESS ) : TRC_SUCCESS )
traceResult xTraceStreamPortOnEnable( uint32_t uiStartOption );
#define xTraceStreamPortOnDisable() ( void ) ( TRC_SUCCESS )
#define xTraceStreamPortOnTraceBegin() ( void ) ( TRC_SUCCESS )
#define xTraceStreamPortOnTraceEnd() ( void ) ( TRC_SUCCESS )
#ifdef __cplusplus
}
#endif
#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/
#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/
#endif /* TRC_STREAM_PORT_H */

@ -1,65 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* Supporting functions for trace streaming, used by the "stream ports"
* for reading and writing data to the interface.
*
* Note that this stream port is more complex than the typical case, since
* the J-Link interface uses a separate RAM buffer in SEGGER_RTT.c, instead
* of the default buffer included in the recorder core. The other stream ports
* offer more typical examples of how to define a custom streaming interface.
*/
#include <trcRecorder.h>
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
typedef struct TraceStreamPortRTT
{
#if ( TRC_USE_INTERNAL_BUFFER == 1 )
uint8_t bufferInternal[ TRC_STREAM_PORT_INTERNAL_BUFFER_SIZE ];
#endif
uint8_t bufferUp[ TRC_STREAM_PORT_RTT_UP_BUFFER_SIZE ];
uint8_t bufferDown[ TRC_STREAM_PORT_RTT_DOWN_BUFFER_SIZE ];
} TraceStreamPortRTT_t;
static TraceStreamPortRTT_t * pxStreamPortRTT;
traceResult xTraceStreamPortInitialize( TraceStreamPortBuffer_t * pxBuffer )
{
TRC_ASSERT_EQUAL_SIZE( TraceStreamPortBuffer_t, TraceStreamPortRTT_t );
if( pxBuffer == 0 )
{
return TRC_FAIL;
}
pxStreamPortRTT = ( TraceStreamPortRTT_t * ) pxBuffer;
#if ( TRC_USE_INTERNAL_BUFFER == 1 )
return xTraceInternalEventBufferInitialize( pxStreamPortRTT->bufferInternal, sizeof( pxStreamPortRTT->bufferInternal ) );
#else
return TRC_SUCCESS;
#endif
}
traceResult xTraceStreamPortOnEnable( uint32_t uiStartOption )
{
( void ) uiStartOption;
/* Configure the RTT buffers */
SEGGER_RTT_ConfigUpBuffer( TRC_CFG_STREAM_PORT_RTT_UP_BUFFER_INDEX, "TzData", pxStreamPortRTT->bufferUp, sizeof( pxStreamPortRTT->bufferUp ), TRC_CFG_STREAM_PORT_RTT_MODE );
SEGGER_RTT_ConfigDownBuffer( TRC_CFG_STREAM_PORT_RTT_DOWN_BUFFER_INDEX, "TzCtrl", pxStreamPortRTT->bufferDown, sizeof( pxStreamPortRTT->bufferDown ), TRC_CFG_STREAM_PORT_RTT_MODE );
return TRC_SUCCESS;
}
#endif /* if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING ) */
#endif /* if ( TRC_USE_TRACEALYZER_RECORDER == 1 ) */

@ -1,19 +0,0 @@
Tracealyzer Stream Port for Ring Buffer
-------------------------------------------------
This directory contains a "stream port" for the Tracealyzer recorder library,
i.e., the specific code needed to use a particular interface for streaming a
Tracealyzer RTOS trace. The stream port is defined by a set of macros in
trcStreamPort.h, found in the "include" directory.
This particular stream port is for streaming to a ring buffer.
To use this stream port, make sure that include/trcStreamPort.h is found
by the compiler (i.e., add this folder to your project's include paths) and
add all included source files to your build. Make sure no other versions of
trcStreamPort.h are included by mistake!
See also http://percepio.com/2016/10/05/rtos-tracing.
Percepio AB
www.percepio.com

@ -1,203 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The interface definitions for trace streaming ("stream ports").
* This "stream port" sets up the recorder to stream to a Ring Buffer.
*/
#ifndef TRC_STREAM_PORT_H
#define TRC_STREAM_PORT_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <trcTypes.h>
#include <trcStreamPortConfig.h>
#include <trcRecorder.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @def TRC_EXTERNAL_BUFFERS
*
* @brief This Stream Port houses the EntryTable and Timestamp buffers
*/
#define TRC_EXTERNAL_BUFFERS 1
/**
* @def TRC_SEND_NAME_ONLY_ON_DELETE
*
* @brief This Stream Port requires additional information to be sent when objects are deleted
*/
#define TRC_SEND_NAME_ONLY_ON_DELETE 1
/**
* @def TRC_USE_INTERNAL_BUFFER
*
* @brief This Stream Port uses the Multi Core Buffer directly.
*/
#define TRC_USE_INTERNAL_BUFFER 0
#define TRC_STREAM_PORT_BUFFER_SIZE ( ( ( ( TRC_CFG_STREAM_PORT_BUFFER_SIZE ) + sizeof( uint32_t ) - 1 ) / sizeof( uint32_t ) ) * sizeof( uint32_t ) )
/**
* @brief
*/
typedef struct TraceMultiCoreBuffer
{
uint32_t uiSize;
uint8_t uiBuffer[ TRC_STREAM_PORT_BUFFER_SIZE ];
} TraceMultiCoreBuffer_t;
/**
* @brief
*/
typedef struct TraceRingBuffer
{
volatile uint8_t START_MARKERS[ 12 ];
TraceHeaderBuffer_t xHeaderBuffer;
TraceTimestampBuffer_t xTimestampInfo;
TraceEntryTableBuffer_t xEntryTableBuffer;
TraceMultiCoreBuffer_t xEventBuffer;
volatile uint8_t END_MARKERS[ 12 ];
} TraceRingBuffer_t;
/**
* @brief
*/
typedef struct TraceStreamPortData
{
TraceMultiCoreEventBuffer_t xMultiCoreEventBuffer;
TraceRingBuffer_t xRingBuffer;
} TraceStreamPortData_t;
extern TraceStreamPortData_t * pxStreamPortData;
/**
* @def TRC_STREAM_PORT_BUFFER_SIZE
* @brief The buffer size, aligned to base type.
*/
#define TRC_STREAM_PORT_DATA_BUFFER_SIZE ( sizeof( TraceStreamPortData_t ) )
/**
* @brief A structure representing the trace stream port buffer.
*/
typedef struct TraceStreamPortBuffer
{
uint8_t buffer[ ( TRC_STREAM_PORT_DATA_BUFFER_SIZE ) ];
} TraceStreamPortBuffer_t;
/**
* @internal Stream port initialize callback.
*
* This function is called by the recorder as part of its initialization phase.
*
* @param[in] pxBuffer Buffer
*
* @retval TRC_FAIL Initialization failed
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStreamPortInitialize( TraceStreamPortBuffer_t * pxBuffer );
/**
* @brief Allocates data from the stream port.
*
* @param[in] uiSize Allocation size
* @param[out] ppvData Allocation data pointer
*
* @retval TRC_FAIL Allocate failed
* @retval TRC_SUCCESS Success
*/
#define xTraceStreamPortAllocate( uiSize, ppvData ) ( ( void ) uiSize, xTraceStaticBufferGet( ppvData ) )
/**
* @brief Commits data to the stream port, depending on the implementation/configuration of the
* stream port this data might be directly written to the stream port interface, buffered, or
* something else.
*
* @param[in] pvData Data to commit
* @param[in] uiSize Data to commit size
* @param[out] piBytesCommitted Bytes commited
*
* @retval TRC_FAIL Commit failed
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStreamPortCommit( void * pvData,
uint32_t uiSize,
int32_t * piBytesCommitted );
/**
* @brief Writes data through the stream port interface.
*
* @param[in] pvData Data to write
* @param[in] uiSize Data to write size
* @param[out] piBytesWritten Bytes written
*
* @retval TRC_FAIL Write failed
* @retval TRC_SUCCESS Success
*/
#define xTraceStreamPortWriteData( pvData, uiSize, piBytesWritten ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_4( ( void ) pvData, ( void ) uiSize, ( void ) piBytesWritten, TRC_SUCCESS )
/**
* @brief Reads data through the stream port interface.
*
* @param[in] pvData Destination data buffer
* @param[in] uiSize Destination data buffer size
* @param[out] piBytesRead Bytes read
*
* @retval TRC_FAIL Read failed
* @retval TRC_SUCCESS Success
*/
#define xTraceStreamPortReadData( pvData, uiSize, piBytesRead ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_4( ( void ) pvData, ( void ) uiSize, ( void ) piBytesRead, TRC_SUCCESS )
/**
* @brief Callback for when recorder is enabled
*
* @param[in] uiStartOption Start option used when enabling trace recorder
*
* @retval TRC_FAIL Read failed
* @retval TRC_SUCCESS Success
*/
#define xTraceStreamPortOnEnable( uiStartOption ) TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2( ( void ) ( uiStartOption ), TRC_SUCCESS )
/**
* @brief Callback for when recorder is disabled
*
* @retval TRC_FAIL Read failed
* @retval TRC_SUCCESS Success
*/
#define xTraceStreamPortOnDisable() TRC_COMMA_EXPR_TO_STATEMENT_EXPR_1( TRC_SUCCESS )
/**
* @brief Callback for when tracing begins
*
* @retval TRC_FAIL Read failed
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStreamPortOnTraceBegin();
/**
* @brief Callback for when tracing ends
*
* @retval TRC_FAIL Read failed
* @retval TRC_SUCCESS Success
*/
#define xTraceStreamPortOnTraceEnd() TRC_COMMA_EXPR_TO_STATEMENT_EXPR_1( TRC_SUCCESS )
#ifdef __cplusplus
}
#endif
#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/
#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/
#endif /* TRC_STREAM_PORT_H */

@ -1,134 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* Supporting functions for trace streaming, used by the "stream ports"
* for reading and writing data to the interface.
* This "stream port" sets up the recorder to stream to a Ring Buffer.
*/
#include <trcRecorder.h>
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
/* Backwards compatibility with plugins */
typedef TraceRingBuffer_t RecorderData;
RecorderData * RecorderDataPtr = 0;
TraceStreamPortData_t * pxStreamPortData;
traceResult xTraceStreamPortInitialize( TraceStreamPortBuffer_t * pxBuffer )
{
TraceRingBuffer_t * pxRingBuffer;
TRC_ASSERT_EQUAL_SIZE( TraceStreamPortBuffer_t, TraceStreamPortData_t );
if( pxBuffer == 0 )
{
return TRC_FAIL;
}
pxStreamPortData = ( TraceStreamPortData_t * ) pxBuffer;
RecorderDataPtr = pxRingBuffer = &pxStreamPortData->xRingBuffer;
pxRingBuffer->xEventBuffer.uiSize = sizeof( pxRingBuffer->xEventBuffer.uiBuffer );
#if ( TRC_CFG_STREAM_PORT_RINGBUFFER_MODE == TRC_STREAM_PORT_RINGBUFFER_MODE_OVERWRITE_WHEN_FULL )
if( xTraceMultiCoreEventBufferInitialize( &pxStreamPortData->xMultiCoreEventBuffer, TRC_EVENT_BUFFER_OPTION_OVERWRITE, pxRingBuffer->xEventBuffer.uiBuffer, sizeof( pxRingBuffer->xEventBuffer.uiBuffer ) ) == TRC_FAIL )
{
return TRC_FAIL;
}
#else
if( xTraceMultiCoreEventBufferInitialize( &pxStreamPortData->xMultiCoreEventBuffer, TRC_EVENT_BUFFER_OPTION_SKIP, pxRingBuffer->xEventBuffer.uiBuffer, sizeof( pxRingBuffer->xEventBuffer.uiBuffer ) ) == TRC_FAIL )
{
return TRC_FAIL;
}
#endif
if( xTraceHeaderInitialize( &pxRingBuffer->xHeaderBuffer ) == TRC_FAIL )
{
return TRC_FAIL;
}
if( xTraceEntryTableInitialize( &pxRingBuffer->xEntryTableBuffer ) == TRC_FAIL )
{
return TRC_FAIL;
}
if( xTraceTimestampInitialize( &pxRingBuffer->xTimestampInfo ) == TRC_FAIL )
{
return TRC_FAIL;
}
pxRingBuffer->END_MARKERS[ 0 ] = 0x0A;
pxRingBuffer->END_MARKERS[ 1 ] = 0x0B;
pxRingBuffer->END_MARKERS[ 2 ] = 0x0C;
pxRingBuffer->END_MARKERS[ 3 ] = 0x0D;
pxRingBuffer->END_MARKERS[ 4 ] = 0x71;
pxRingBuffer->END_MARKERS[ 5 ] = 0x72;
pxRingBuffer->END_MARKERS[ 6 ] = 0x73;
pxRingBuffer->END_MARKERS[ 7 ] = 0x74;
pxRingBuffer->END_MARKERS[ 8 ] = 0xF1;
pxRingBuffer->END_MARKERS[ 9 ] = 0xF2;
pxRingBuffer->END_MARKERS[ 10 ] = 0xF3;
pxRingBuffer->END_MARKERS[ 11 ] = 0xF4;
pxRingBuffer->START_MARKERS[ 0 ] = 0x05;
pxRingBuffer->START_MARKERS[ 1 ] = 0x06;
pxRingBuffer->START_MARKERS[ 2 ] = 0x07;
pxRingBuffer->START_MARKERS[ 3 ] = 0x08;
pxRingBuffer->START_MARKERS[ 4 ] = 0x75;
pxRingBuffer->START_MARKERS[ 5 ] = 0x76;
pxRingBuffer->START_MARKERS[ 6 ] = 0x77;
pxRingBuffer->START_MARKERS[ 7 ] = 0x78;
pxRingBuffer->START_MARKERS[ 8 ] = 0xF5;
pxRingBuffer->START_MARKERS[ 9 ] = 0xF6;
pxRingBuffer->START_MARKERS[ 10 ] = 0xF7;
pxRingBuffer->START_MARKERS[ 11 ] = 0xF8;
return TRC_SUCCESS;
}
traceResult xTraceStreamPortCommit( void * pvData,
uint32_t uiSize,
int32_t * piBytesCommitted )
{
if( pvData == 0 )
{
return TRC_FAIL;
}
xTraceMultiCoreEventBufferPush( &pxStreamPortData->xMultiCoreEventBuffer, pvData, uiSize, piBytesCommitted );
#if ( TRC_CFG_STREAM_PORT_RINGBUFFER_MODE == TRC_STREAM_PORT_RINGBUFFER_MODE_STOP_WHEN_FULL )
/* If no bytes was written it means that the buffer is full and we should stop
* tracing.
*/
if( ( uiSize > 0 ) && ( *piBytesCommitted == 0 ) )
{
xTraceDisable();
return TRC_FAIL;
}
#endif
return TRC_SUCCESS;
}
traceResult xTraceStreamPortOnTraceBegin()
{
return xTraceMultiCoreEventBufferClear( &pxStreamPortData->xMultiCoreEventBuffer );
}
#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/
#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/

@ -1,93 +0,0 @@
Tracealyzer Stream Port for STM32 USB CDC (Virtual COM Port)
Percepio AB
https://percepio.com
------------------------------------------------------------
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
trcStreamPort.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/trcStreamPort.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 trcStreamPort.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 assistance, feel free to contact support@percepio.com.

@ -1,39 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The configuration for trace streaming ("stream ports").
*/
#ifndef TRC_STREAM_PORT_CONFIG_H
#define TRC_STREAM_PORT_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
/* The time to wait if the USB interface is busy. */
#define TRC_CFG_STREAM_PORT_DELAY_ON_BUSY 3
/*******************************************************************************
* Configuration Macro: TRC_CFG_STREAM_PORT_USB_BUFFER_SIZE
*
* Specifies the size of the usb buffer.
******************************************************************************/
#define TRC_CFG_STREAM_PORT_USB_BUFFER_SIZE 64
/*******************************************************************************
* Configuration Macro: TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_SIZE
*
* Specifies the size of the internal buffer.
******************************************************************************/
#define TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_SIZE 10000
#ifdef __cplusplus
}
#endif
#endif /* TRC_STREAM_PORT_CONFIG_H */

@ -1,114 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* 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.
*/
#ifndef TRC_STREAM_PORT_H
#define TRC_STREAM_PORT_H
#include <trcTypes.h>
#include <trcStreamPortConfig.h>
#ifdef __cplusplus
extern "C" {
#endif
#define TRC_USE_INTERNAL_BUFFER 1
#define TRC_STREAM_PORT_USB_BUFFER_SIZE ( ( ( ( TRC_CFG_STREAM_PORT_USB_BUFFER_SIZE ) + sizeof( TraceUnsignedBaseType_t ) - 1 ) / sizeof( TraceUnsignedBaseType_t ) ) * sizeof( TraceUnsignedBaseType_t ) )
#define TRC_STREAM_PORT_INTERNAL_BUFFER_SIZE ( ( ( ( TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_SIZE ) + sizeof( TraceUnsignedBaseType_t ) - 1 ) / sizeof( TraceUnsignedBaseType_t ) ) * sizeof( TraceUnsignedBaseType_t ) )
typedef struct TraceStreamPortBuffer
{
uint8_t buffer[ ( TRC_STREAM_PORT_USB_BUFFER_SIZE ) + ( TRC_STREAM_PORT_INTERNAL_BUFFER_SIZE ) + sizeof( TraceUnsignedBaseType_t ) ];
} TraceStreamPortBuffer_t;
traceResult prvTraceCDCReceive( void * data,
uint32_t uiSize,
int32_t * piBytesReceived );
traceResult prvTraceCDCTransmit( void * pvData,
uint32_t uiSize,
int32_t * piBytesSent );
/**
* @internal Stream port initialize callback.
*
* This function is called by the recorder as part of its initialization phase.
*
* @param[in] pxBuffer Buffer
*
* @retval TRC_FAIL Initialization failed
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStreamPortInitialize( TraceStreamPortBuffer_t * pxBuffer );
/**
* @brief Allocates data from the stream port.
*
* @param[in] uiSize Allocation size
* @param[out] ppvData Allocation data pointer
*
* @retval TRC_FAIL Allocate failed
* @retval TRC_SUCCESS Success
*/
#define xTraceStreamPortAllocate( uiSize, ppvData ) ( ( void ) uiSize, xTraceStaticBufferGet( ppvData ) )
/**
* @brief Commits data to the stream port, depending on the implementation/configuration of the
* stream port this data might be directly written to the stream port interface, buffered, or
* something else.
*
* @param[in] pvData Data to commit
* @param[in] uiSize Data to commit size
* @param[out] piBytesCommitted Bytes committed
*
* @retval TRC_FAIL Commit failed
* @retval TRC_SUCCESS Success
*/
#define xTraceStreamPortCommit xTraceInternalEventBufferPush
/**
* @brief Writes data through the stream port interface.
*
* @param[in] pvData Data to write
* @param[in] uiSize Data to write size
* @param[out] piBytesWritten Bytes written
*
* @retval TRC_FAIL Write failed
* @retval TRC_SUCCESS Success
*/
#define xTraceStreamPortWriteData prvTraceCDCTransmit
/**
* @brief Reads data through the stream port interface.
*
* @param[in] pvData Destination data buffer
* @param[in] uiSize Destination data buffer size
* @param[out] piBytesRead Bytes read
*
* @retval TRC_FAIL Read failed
* @retval TRC_SUCCESS Success
*/
#define xTraceStreamPortReadData prvTraceCDCReceive
#define xTraceStreamPortOnEnable( uiStartOption ) ( ( void ) ( uiStartOption ), TRC_SUCCESS )
#define xTraceStreamPortOnDisable() ( TRC_SUCCESS )
#define xTraceStreamPortOnTraceBegin() ( TRC_SUCCESS )
#define xTraceStreamPortOnTraceEnd() ( TRC_SUCCESS )
#ifdef __cplusplus
}
#endif
#endif /* TRC_STREAM_PORT_H */

@ -1,158 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* 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.
*/
#include <trcRecorder.h>
#include <usb_device.h>
#include <usbd_CDC_if.h>
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
static void prvCDCInit( void );
static int8_t CDC_Receive_FS_modified( uint8_t * pbuf,
uint32_t * puiLength );
extern USBD_CDC_ItfTypeDef USBD_Interface_fops_FS;
static int8_t (* CDC_Receive_FS)( uint8_t * Buf,
uint32_t * Len );
typedef struct TraceStreamPortUSBCommandBuffer
{
TraceUnsignedBaseType_t idx;
uint8_t bufferUSB[ TRC_STREAM_PORT_USB_BUFFER_SIZE ];
uint8_t bufferInternal[ TRC_STREAM_PORT_INTERNAL_BUFFER_SIZE ];
} TraceStreamPortUSBBuffers_t;
TraceStreamPortUSBBuffers_t * pxUSBBuffers;
static int8_t CDC_Receive_FS_modified( uint8_t * pBuffer,
uint32_t * puiLength )
{
for( uint32_t i = 0; i < *puiLength; i++ )
{
pxUSBBuffers->bufferUSB[ pxUSBBuffers->idx ] = pBuffer[ i ];
pxUSBBuffers->idx++;
}
CDC_Receive_FS( pBuffer, puiLength );
return( USBD_OK );
}
static void prvCDCInit( 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;
pxUSBBuffers->idx = 0;
MX_USB_DEVICE_Init();
}
/* The READ function, used in trcStreamPort.h */
traceResult prvTraceCDCReceive( void * data,
uint32_t uiSize,
int32_t * piBytesReceived )
{
uint32_t i, uiDiff;
if( pxUSBBuffers->idx > 0 )
{
if( ( TraceUnsignedBaseType_t ) uiSize >= pxUSBBuffers->idx ) /* More than what is stored, number of bytes will be .idx */
{
TRC_MEMCPY( data, pxUSBBuffers->bufferUSB, pxUSBBuffers->idx );
*piBytesReceived = ( int32_t ) pxUSBBuffers->idx;
pxUSBBuffers->idx = 0; /* Make the buffer ready for a new command */
}
else /* If some data in the buffer is not read */
{
uiDiff = pxUSBBuffers->idx - uiSize;
TRC_MEMCPY( data, pxUSBBuffers->bufferUSB, uiSize );
for( i = 0; i < uiDiff; i++ )
{
pxUSBBuffers->bufferUSB[ i ] = pxUSBBuffers->bufferUSB[ i + uiSize ];
}
*piBytesReceived = uiSize;
pxUSBBuffers->idx = uiDiff;
}
}
else
{
*piBytesReceived = 0;
}
return TRC_SUCCESS;
}
/* The WRITE function, used in trcStreamPort.h */
traceResult prvTraceCDCTransmit( void * pvData,
uint32_t uiSize,
int32_t * piBytesSent )
{
static int fail_counter = 0;
int32_t result;
*piBytesSent = 0;
result = CDC_Transmit_FS( pvData, uiSize );
if( result == USBD_OK )
{
fail_counter = 0;
*piBytesSent = uiSize;
return TRC_SUCCESS;
}
else
{
fail_counter++;
/* We keep trying to send more pvData. If busy, we delay for a while. This function will be called again afterwards. */
xTraceKernelPortDelay( TRC_CFG_STREAM_PORT_DELAY_ON_BUSY );
if( fail_counter >= 100 )
{
/* If many unsuccessful attempts in a row, something is very wrong. Returning -1 will stop the recorder. */
return TRC_FAIL;
}
}
return TRC_SUCCESS;
}
traceResult xTraceStreamPortInitialize( TraceStreamPortBuffer_t * pxBuffer )
{
TRC_ASSERT_EQUAL_SIZE( TraceStreamPortBuffer_t, TraceStreamPortUSBBuffers_t );
if( pxBuffer == 0 )
{
return TRC_FAIL;
}
pxUSBBuffers = ( TraceStreamPortUSBBuffers_t * ) pxBuffer;
prvCDCInit();
return xTraceInternalEventBufferInitialize( pxUSBBuffers->bufferInternal, sizeof( pxUSBBuffers->bufferInternal ) );
}
#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/
#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/

@ -1,49 +0,0 @@
Tracealyzer Stream Port for TCP/IP (lwIP example)
Percepio AB
www.percepio.com
-------------------------------------------------
This directory contains a "stream port" for the Tracealyzer recorder library,
i.e., the specific code needed to use a particular interface for streaming a
Tracealyzer RTOS trace. The stream port is defined by a set of macros in
trcStreamPort.h, found in the "include" directory.
This particular stream port targets TCP/IP. This example assumes lwIP but is
easy to modify for other TCP/IP stacks.
Instructions:
1. Integrate the trace recorder and configure it for streaming, as described
in the Tracealyzer User Manual. For FreeRTOS this is found at:
https://percepio.com/docs/FreeRTOS/manual/index.html#Creating_and_Loading_Traces___Introduction
2. Make sure all .c and .h files from this stream port folder is included in
your build, and that no other variant of trcStreamPort.h is included.
3. In lwipopts.h, make sure you have this line:
#define LWIP_SOCKET 1
4. Make sure that vTraceEnable(TRC_INIT) is called during the startup, before
any RTOS calls are made.
5. In Tracealyzer, open File -> Settings -> PSF Streaming Settings and
select Target Connection: TCP. Enter the IP address of the target system
and the port number (by default 12000).
6. Start your target system, wait a few seconds to ensure that the lwIP is operational,
then select Start Recording in Tracealyzer.
Troubleshooting:
- If the tracing suddenly stops, check the "errno" value in trcSocketSend (trcStreamingPort.c).
You can see the error code definitions in lwip/errno.h. If errno is ENOMEM, may you need to
increase MEM_SIZE in lwipopts.h.
- Since lwIP performs a lot of semaphore and mutex operations, we recommend filtering out
such events from the trace, at least those caused by the transmission of trace data in the
TzCtrl task. This can be done using vTraceSetFilterGroup() and vTraceSetFilterMask().
Note that lwIP is not included in the stream port, but assumed to exist in the project already.
See also http://percepio.com/2016/10/05/rtos-tracing.

@ -1,41 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The configuration for trace streaming ("stream ports").
*/
#ifndef TRC_STREAM_PORT_CONFIG_H
#define TRC_STREAM_PORT_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
/* This define will determine whether to use the internal buffer or not.
* If file writing creates additional trace events (i.e. it uses semaphores or mutexes),
* then the internal buffer must be enabled to avoid infinite recursion. */
#define TRC_CFG_STREAM_PORT_USE_INTERNAL_BUFFER 0
/*******************************************************************************
* Configuration Macro: TRC_CFG_STREAM_PORT_TCPIP_PORT
*
* Specifies the TCP/IP port.
******************************************************************************/
#define TRC_CFG_STREAM_PORT_TCPIP_PORT 8888
/*******************************************************************************
* Configuration Macro: TRC_CFG_STREAM_PORT_BUFFER_SIZE
*
* Specifies the size of the internal buffer, if one is used.
******************************************************************************/
#define TRC_CFG_STREAM_PORT_BUFFER_SIZE 10000
#ifdef __cplusplus
}
#endif
#endif /* TRC_STREAM_PORT_CONFIG_H */

@ -1,78 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The interface definitions for trace streaming ("stream ports").
* This "stream port" sets up the recorder to use TCP/IP as streaming channel.
* The example is for lwIP.
*/
#ifndef TRC_STREAM_PORT_H
#define TRC_STREAM_PORT_H
#include <stdint.h>
#include <trcTypes.h>
#include <trcStreamPortConfig.h>
#ifdef __cplusplus
extern "C" {
#endif
#define TRC_USE_INTERNAL_BUFFER ( TRC_CFG_STREAM_PORT_USE_INTERNAL_BUFFER )
/**
* @def TRC_STREAM_PORT_BUFFER_SIZE
*
* @brief The buffer size, aligned to base type.
*/
#define TRC_STREAM_PORT_BUFFER_SIZE ( ( ( ( TRC_CFG_STREAM_PORT_BUFFER_SIZE ) + sizeof( TraceUnsignedBaseType_t ) - 1 ) / sizeof( TraceUnsignedBaseType_t ) ) * sizeof( TraceUnsignedBaseType_t ) )
typedef struct TraceStreamPortBuffer
{
#if ( TRC_USE_INTERNAL_BUFFER )
uint8_t buffer[ ( TRC_STREAM_PORT_BUFFER_SIZE ) ];
#else
TraceUnsignedBaseType_t buffer[ 1 ];
#endif
} TraceStreamPortBuffer_t;
int32_t prvTraceTcpWrite( void * pvData,
uint32_t uiSize,
int32_t * piBytesWritten );
int32_t prvTraceTcpRead( void * pvData,
uint32_t uiSize,
int32_t * piBytesRead );
traceResult xTraceStreamPortInitialize( TraceStreamPortBuffer_t * pxBuffer );
#define xTraceStreamPortAllocate( uiSize, ppvData ) ( ( void ) ( uiSize ), xTraceStaticBufferGet( ppvData ) )
#if ( TRC_USE_INTERNAL_BUFFER == 1 )
/* Push to internal buffer. It will call on xTraceStreamPortWriteData() periodically. */
#define xTraceStreamPortCommit xTraceInternalEventBufferPush
#else
/* Write directly */
#define xTraceStreamPortCommit xTraceStreamPortWriteData
#endif
#define xTraceStreamPortWriteData( pvData, uiSize, piBytesWritten ) ( prvTraceTcpWrite( pvData, uiSize, piBytesWritten ) == 0 ? TRC_SUCCESS : TRC_FAIL )
#define xTraceStreamPortReadData( pvData, uiSize, piBytesRead ) ( prvTraceTcpRead( pvData, uiSize, piBytesRead ) == 0 ? TRC_SUCCESS : TRC_FAIL )
#define xTraceStreamPortOnEnable( uiStartOption ) ( ( void ) ( uiStartOption ), TRC_SUCCESS )
#define xTraceStreamPortOnDisable() ( TRC_SUCCESS )
#define xTraceStreamPortOnTraceBegin() ( TRC_SUCCESS )
traceResult xTraceStreamPortOnTraceEnd( void );
#ifdef __cplusplus
}
#endif
#endif /* TRC_STREAM_PORT_H */

@ -1,235 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* Supporting functions for trace streaming, used by the "stream ports"
* for reading and writing data to the interface.
* Existing ports can easily be modified to fit another setup, e.g., a
* different TCP/IP stack, or to define your own stream port.
*/
#include <trcRecorder.h>
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
/* TCP/IP includes - for lwIP in this case */
#include <lwip/tcpip.h>
#include <lwip/sockets.h>
#include <lwip/errno.h>
int sock = -1, new_sd = -1;
int flags = 0;
int remoteSize;
struct sockaddr_in address, remote;
typedef struct TraceStreamPortTCPIP
{
#if ( TRC_USE_INTERNAL_BUFFER )
uint8_t buffer[ ( TRC_STREAM_PORT_BUFFER_SIZE ) ];
#else
TraceUnsignedBaseType_t buffer[ 1 ];
#endif
} TraceStreamPortTCPIP_t;
static TraceStreamPortTCPIP_t * pxStreamPortFile;
static int32_t prvSocketSend( void * pvData,
uint32_t uiSize,
int32_t * piBytesWritten );
static int32_t prvSocketReceive( void * pvData,
uint32_t uiSize,
int32_t * bytesRead );
static int32_t prvSocketInitializeListener();
static int32_t prvSocketAccept();
static void prvCloseAllSockets();
static int32_t prvSocketSend( void * pvData,
uint32_t uiSize,
int32_t * piBytesWritten )
{
if( new_sd < 0 )
{
return -1;
}
if( piBytesWritten == 0 )
{
return -1;
}
*piBytesWritten = send( new_sd, pvData, uiSize, 0 );
if( *piBytesWritten < 0 )
{
/* EWOULDBLOCK may be expected when buffers are full */
if( ( errno != 0 ) && ( errno != EWOULDBLOCK ) )
{
closesocket( new_sd );
new_sd = -1;
return -1;
}
else
{
*piBytesWritten = 0;
}
}
return 0;
}
static int32_t prvSocketReceive( void * pvData,
uint32_t uiSize,
int32_t * bytesRead )
{
if( new_sd < 0 )
{
return -1;
}
*bytesRead = recv( new_sd, pvData, uiSize, 0 );
/* EWOULDBLOCK may be expected when there is no pvData to receive */
if( ( errno != 0 ) && ( errno != EWOULDBLOCK ) )
{
closesocket( new_sd );
new_sd = -1;
return -1;
}
return 0;
}
static int32_t prvSocketInitializeListener()
{
if( sock >= 0 )
{
return 0;
}
sock = lwip_socket( AF_INET, SOCK_STREAM, 0 );
if( sock < 0 )
{
return -1;
}
address.sin_family = AF_INET;
address.sin_port = htons( TRC_CFG_STREAM_PORT_TCPIP_PORT );
address.sin_addr.s_addr = INADDR_ANY;
if( bind( sock, ( struct sockaddr * ) &address, sizeof( address ) ) < 0 )
{
closesocket( sock );
sock = -1;
return -1;
}
if( lwip_listen( sock, 5 ) < 0 )
{
closesocket( sock );
sock = -1;
return -1;
}
return 0;
}
static int32_t prvSocketAccept()
{
if( sock < 0 )
{
return -1;
}
if( new_sd >= 0 )
{
return 0;
}
remoteSize = sizeof( remote );
new_sd = accept( sock, ( struct sockaddr * ) &remote, ( socklen_t * ) &remoteSize );
if( new_sd < 0 )
{
closesocket( new_sd );
new_sd = -1;
closesocket( sock );
sock = -1;
return -1;
}
flags = fcntl( new_sd, F_GETFL, 0 );
fcntl( new_sd, F_SETFL, flags | O_NONBLOCK );
return 0;
}
static void prvCloseAllSockets()
{
if( new_sd > 0 )
{
closesocket( new_sd );
}
if( sock > 0 )
{
closesocket( sock );
}
}
/************** MODIFY THE ABOVE PART TO USE YOUR TPC/IP STACK ****************/
int32_t prvTraceTcpWrite( void * pvData,
uint32_t uiSize,
int32_t * piBytesWritten )
{
prvSocketInitializeListener();
prvSocketAccept();
return prvSocketSend( pvData, uiSize, piBytesWritten );
}
int32_t prvTraceTcpRead( void * pvData,
uint32_t uiSize,
int32_t * piBytesRead )
{
prvSocketInitializeListener();
prvSocketAccept();
return prvSocketReceive( pvData, uiSize, piBytesRead );
}
traceResult xTraceStreamPortInitialize( TraceStreamPortBuffer_t * pxBuffer )
{
TRC_ASSERT_EQUAL_SIZE( TraceStreamPortBuffer_t, TraceStreamPortTCPIP_t );
if( pxBuffer == 0 )
{
return TRC_FAIL;
}
pxStreamPortFile = ( TraceStreamPortTCPIP_t * ) pxBuffer;
#if ( TRC_USE_INTERNAL_BUFFER == 1 )
return xTraceInternalEventBufferInitialize( pxStreamPortFile->buffer, sizeof( pxStreamPortFile->buffer ) );
#else
return TRC_SUCCESS;
#endif
}
traceResult xTraceStreamPortOnTraceEnd( void )
{
prvCloseAllSockets();
return TRC_SUCCESS;
}
#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/
#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/

@ -1,37 +0,0 @@
Tracealyzer Stream Port for TCP/IP (Win32 example)
Percepio AB
www.percepio.com
-------------------------------------------------
This directory contains a "stream port" for the Tracealyzer recorder library,
i.e., the I/O code needed for streaming a Tracealyzer RTOS trace over specific
interface. The stream port is defined by a set of macros in trcStreamPort.h,
found in the "include" directory.
This particular stream port is for streaming over TCP/IP on Windows, intended
for the FreeRTOS Windows port (WIN32-MSVC). To try it:
1. Open the WIN32-MSVC demo project found in the FreeRTOS demo folder. You
need will Visual Studio, but there are free versions (Express or Community).
2. Make sure the project includes a recent version or the recorder library
(v3.1.x).
3. Make sure the recorder library is configured for streaming mode (see
trcConfig.h).
4. Make sure the project's include paths contains trcStreamPort.h found in
this include folder (and not any other stream port), and the related code
in this folder.
5. Build and start the Win32 demo application. It should begin waiting for
a connection.
6. In Tracealyzer, open File -> Settings... -> Streaming Trace Settings.
Specify target connection: TCP, host: 127.0.0.1 (i.e. localhost) and port 8888.
7. In Tracealyzer, now open File -> Connect to Target System... and there
click "Start Recording". Now you should see a live CPU load graph and some
counters. Let it record for a few seconds, then click "Stop Recording" and then "View Trace".
See also http://percepio.com/2016/10/05/rtos-tracing.

@ -1,41 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The configuration for trace streaming ("stream ports").
*/
#ifndef TRC_STREAM_PORT_CONFIG_H
#define TRC_STREAM_PORT_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
/* This define will determine whether to use the internal buffer or not.
* If file writing creates additional trace events (i.e. it uses semaphores or mutexes),
* then the internal buffer must be enabled to avoid infinite recursion. */
#define TRC_CFG_STREAM_PORT_USE_INTERNAL_BUFFER 0
/*******************************************************************************
* Configuration Macro: TRC_CFG_STREAM_PORT_TCPIP_PORT
*
* Specifies the TCP/IP port.
******************************************************************************/
#define TRC_CFG_STREAM_PORT_TCPIP_PORT 8888
/*******************************************************************************
* Configuration Macro: TRC_CFG_STREAM_PORT_BUFFER_SIZE
*
* Specifies the size of the internal buffer, if one is used.
******************************************************************************/
#define TRC_CFG_STREAM_PORT_BUFFER_SIZE 10000
#ifdef __cplusplus
}
#endif
#endif /* TRC_STREAM_PORT_CONFIG_H */

@ -1,85 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The interface definitions for trace streaming ("stream ports").
* This "stream port" sets up the recorder to use TCP/IP as streaming channel.
* The example is for Windows sockets (Winsock), for use with Windows ports.
*/
#ifndef TRC_STREAM_PORT_H
#define TRC_STREAM_PORT_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#include <stdint.h>
#include <trcTypes.h>
#include <trcStreamPortConfig.h>
#ifdef __cplusplus
extern "C" {
#endif
#define TRC_USE_INTERNAL_BUFFER ( TRC_CFG_STREAM_PORT_USE_INTERNAL_BUFFER )
/**
* @def TRC_STREAM_PORT_BUFFER_SIZE
*
* @brief The buffer size, aligned to base type.
*/
#define TRC_STREAM_PORT_BUFFER_SIZE ( ( ( ( TRC_CFG_STREAM_PORT_BUFFER_SIZE ) + sizeof( TraceUnsignedBaseType_t ) - 1 ) / sizeof( TraceUnsignedBaseType_t ) ) * sizeof( TraceUnsignedBaseType_t ) )
typedef struct TraceStreamPortBuffer
{
#if ( TRC_USE_INTERNAL_BUFFER )
uint8_t buffer[ ( TRC_STREAM_PORT_BUFFER_SIZE ) ];
#else
TraceUnsignedBaseType_t buffer[ 1 ];
#endif
} TraceStreamPortBuffer_t;
int32_t prvTraceWriteToSocket( void * data,
uint32_t size,
int32_t * ptrBytesWritten );
int32_t prvTraceReadFromSocket( void * data,
uint32_t bufsize,
int32_t * ptrBytesRead );
traceResult xTraceStreamPortInitialize( TraceStreamPortBuffer_t * pxBuffer );
#define xTraceStreamPortAllocate( uiSize, ppvData ) ( ( void ) ( uiSize ), xTraceStaticBufferGet( ppvData ) )
#if ( TRC_USE_INTERNAL_BUFFER == 1 )
/* Push to internal buffer. It will call on xTraceStreamPortWriteData() periodically. */
#define xTraceStreamPortCommit xTraceInternalEventBufferPush
#else
/* Write directly */
#define xTraceStreamPortCommit xTraceStreamPortWriteData
#endif
#define xTraceStreamPortWriteData( pvData, uiSize, piBytesWritten ) ( prvTraceWriteToSocket( pvData, uiSize, piBytesWritten ) == 0 ? TRC_SUCCESS : TRC_FAIL )
#define xTraceStreamPortReadData( pvData, uiSize, piBytesRead ) ( prvTraceReadFromSocket( pvData, uiSize, piBytesRead ) == 0 ? TRC_SUCCESS : TRC_FAIL )
#define xTraceStreamPortOnEnable( uiStartOption ) ( ( void ) ( uiStartOption ), TRC_SUCCESS )
#define xTraceStreamPortOnDisable() ( TRC_SUCCESS )
#define xTraceStreamPortOnTraceBegin() ( TRC_SUCCESS )
traceResult xTraceStreamPortOnTraceEnd( void );
#ifdef __cplusplus
}
#endif
#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/
#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/
#endif /* TRC_STREAM_PORT_H */

@ -1,259 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* Supporting functions for trace streaming, used by the "stream ports"
* for reading and writing data to the interface.
* Existing ports can easily be modified to fit another setup, e.g., a
* different TCP/IP stack, or to define your own stream port.
*/
#include <stdio.h>
#include <winsock2.h>
#include <trcRecorder.h>
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#pragma comment(lib,"ws2_32.lib") /*Winsock Library */
typedef struct TraceStreamPortTCPIP
{
#if ( TRC_USE_INTERNAL_BUFFER )
uint8_t buffer[ ( TRC_STREAM_PORT_BUFFER_SIZE ) ];
#else
TraceUnsignedBaseType_t buffer[ 1 ];
#endif
} TraceStreamPortTCPIP_t;
static TraceStreamPortTCPIP_t * pxStreamPortFile;
static SOCKET server_socket = ( UINT_PTR ) 0, trace_socket = ( UINT_PTR ) 0;
struct sockaddr_in server, client;
static int prvInitServerSocketIfNeeded( void );
static int prvInitWinsockIfNeeded( void );
static int prvInitTraceSocketIfNeeded( void );
static void prvCloseAllSockets( void );
static int prvInitWinsockIfNeeded( void )
{
WSADATA wsa;
if( server_socket )
{
return 0;
}
if( WSAStartup( MAKEWORD( 2, 2 ), &wsa ) != 0 )
{
return -1;
}
return 0;
}
static int prvInitServerSocketIfNeeded( void )
{
if( prvInitWinsockIfNeeded() < 0 )
{
return -1;
}
if( server_socket )
{
return 0;
}
if( ( server_socket = socket( AF_INET, SOCK_STREAM, 0 ) ) == INVALID_SOCKET )
{
return -1;
}
server.sin_family = AF_INET;
server.sin_addr.s_addr = INADDR_ANY;
server.sin_port = htons( TRC_CFG_STREAM_PORT_TCPIP_PORT );
if( bind( server_socket, ( struct sockaddr * ) &server, sizeof( server ) ) == SOCKET_ERROR )
{
closesocket( server_socket );
WSACleanup();
server_socket = ( UINT_PTR ) 0;
return -1;
}
if( listen( server_socket, 3 ) < 0 )
{
closesocket( server_socket );
WSACleanup();
server_socket = ( UINT_PTR ) 0;
return -1;
}
return 0;
}
static int prvInitTraceSocketIfNeeded( void )
{
int c;
if( !server_socket )
{
return -1;
}
if( trace_socket )
{
return 0;
}
c = sizeof( struct sockaddr_in );
trace_socket = accept( server_socket, ( struct sockaddr * ) &client, &c );
if( trace_socket == INVALID_SOCKET )
{
trace_socket = ( UINT_PTR ) 0;
closesocket( server_socket );
WSACleanup();
server_socket = ( UINT_PTR ) 0;
return -1;
}
return 0;
}
int32_t prvTraceWriteToSocket( void * data,
uint32_t size,
int32_t * ptrBytesWritten )
{
int ret;
if( prvInitServerSocketIfNeeded() < 0 )
{
return -1;
}
if( prvInitTraceSocketIfNeeded() < 0 )
{
return -1;
}
if( !trace_socket )
{
if( ptrBytesWritten != 0 )
{
*ptrBytesWritten = 0;
}
return -1;
}
ret = send( trace_socket, data, size, 0 );
if( ret <= 0 )
{
if( ptrBytesWritten != 0 )
{
*ptrBytesWritten = 0;
}
closesocket( trace_socket );
trace_socket = ( UINT_PTR ) 0;
return ret;
}
if( ptrBytesWritten != 0 )
{
*ptrBytesWritten = ret;
}
return 0;
}
int32_t prvTraceReadFromSocket( void * data,
uint32_t bufsize,
int32_t * ptrBytesRead )
{
unsigned long bytesAvailable = 0;
if( prvInitServerSocketIfNeeded() < 0 )
{
return -1;
}
if( prvInitTraceSocketIfNeeded() < 0 )
{
return -1;
}
if( ioctlsocket( trace_socket, FIONREAD, &bytesAvailable ) != NO_ERROR )
{
closesocket( trace_socket );
trace_socket = ( UINT_PTR ) 0;
return -1;
}
if( bytesAvailable > 0 )
{
*ptrBytesRead = recv( trace_socket, data, bufsize, 0 );
if( *ptrBytesRead == SOCKET_ERROR )
{
closesocket( trace_socket );
trace_socket = ( UINT_PTR ) 0;
return -1;
}
}
return 0;
}
static void prvCloseAllSockets( void )
{
if( trace_socket != 0 )
{
closesocket( trace_socket );
trace_socket = 0;
}
if( server_socket != 0 )
{
closesocket( server_socket );
server_socket = 0;
}
}
traceResult xTraceStreamPortInitialize( TraceStreamPortBuffer_t * pxBuffer )
{
TRC_ASSERT_EQUAL_SIZE( TraceStreamPortBuffer_t, TraceStreamPortTCPIP_t );
if( pxBuffer == 0 )
{
return TRC_FAIL;
}
pxStreamPortFile = ( TraceStreamPortTCPIP_t * ) pxBuffer;
#if ( TRC_USE_INTERNAL_BUFFER == 1 )
return xTraceInternalEventBufferInitialize( pxStreamPortFile->buffer, sizeof( pxStreamPortFile->buffer ) );
#else
return TRC_SUCCESS;
#endif
}
traceResult xTraceStreamPortOnTraceEnd( void )
{
prvCloseAllSockets();
return TRC_SUCCESS;
}
#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/
#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/

@ -1,35 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The configuration for trace streaming ("stream ports").
*/
#ifndef TRC_STREAM_PORT_CONFIG_H
#define TRC_STREAM_PORT_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
/* This define will determine whether to use the internal buffer or not.
* If file writing creates additional trace events (i.e. it uses semaphores or mutexes),
* then the internal buffer must be enabled to avoid infinite recursion. */
#define TRC_CFG_STREAM_PORT_USE_INTERNAL_BUFFER 1
/**
* @def TRC_CFG_INTERNAL_BUFFER_SIZE
*
* @brief Configures the size of the internal buffer if used.
* is enabled.
*/
#define TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_SIZE 35000
#ifdef __cplusplus
}
#endif
#endif /* TRC_STREAM_PORT_CONFIG_H */

@ -1,137 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The interface definitions for trace streaming ("stream ports").
* This "stream port" sets up the recorder to use XMOS xScope as a streaming channel.
*/
#ifndef TRC_STREAMING_PORT_H
#define TRC_STREAMING_PORT_H
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#ifdef __cplusplus
extern "C" {
#endif
#include <trcTypes.h>
#include <trcStreamPortConfig.h>
#define TRC_USE_INTERNAL_BUFFER ( TRC_CFG_STREAM_PORT_USE_INTERNAL_BUFFER )
/* Aligned */
#define TRC_STREAM_PORT_INTERNAL_BUFFER_SIZE ( ( ( ( TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_SIZE ) + sizeof( TraceUnsignedBaseType_t ) - 1 ) / sizeof( TraceUnsignedBaseType_t ) ) * sizeof( TraceUnsignedBaseType_t ) )
/**
* @brief A structure representing the trace stream port buffer.
*/
typedef struct TraceStreamPortBuffer
{
#if ( TRC_USE_INTERNAL_BUFFER == 1 )
uint8_t uiBufferInternal[ TRC_STREAM_PORT_INTERNAL_BUFFER_SIZE ];
#endif
uint8_t uiBuffer[ 4 ];
} TraceStreamPortBuffer_t;
/**
* @internal Stream port initialize callback.
*
* This function is called by the recorder as part of its initialization phase.
*
* @param[in] pxBuffer Buffer
* @retval TRC_FAIL Initialization failed
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStreamPortInitialize( TraceStreamPortBuffer_t * pxBuffer );
/**
* @brief Stream port begin callback.
*
* This function is called by the recorder as part of its begin phase.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStreamPortOnBegin( void );
/**
* @brief Stream port end callback.
*
* This function is called by the recorder as part of its end phase.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStreamPortOnEnd( void );
/**
* @brief Allocates data from the stream port.
*
* @param[in] uiSize Allocation size
* @param[out] ppvData Allocation data pointer
*
* @retval TRC_FAIL Allocate failed
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStreamPortAllocate( uint32_t uiSize,
void ** ppvData );
/**
* @brief Commits data to the stream port, depending on the implementation/configuration of the
* stream port this data might be directly written to the stream port interface, buffered, or
* something else.
*
* @param[in] pvData Data to commit
* @param[in] uiSize Data to commit size
* @param[out] piBytesCommitted Bytes commited
*
* @retval TRC_FAIL Commit failed
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStreamPortCommit( void * pvData,
uint32_t uiSize,
int32_t * piBytesCommitted );
/**
* @brief Writes data through the stream port interface.
*
* @param[in] pvData Data to write
* @param[in] uiSize Data to write size
* @param[out] piBytesWritten Bytes written
*
* @retval TRC_FAIL Write failed
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStreamPortWriteData( void * pvData,
uint32_t uiSize,
int32_t * piBytesWritten );
/**
* @brief Reads data through the stream port interface.
*
* @param[in] pvData Destination data buffer
* @param[in] uiSize Destination data buffer size
* @param[out] piBytesRead Bytes read
*
* @retval TRC_FAIL Read failed
* @retval TRC_SUCCESS Success
*/
traceResult xTraceStreamPortReadData( void * pvData,
uint32_t uiSize,
int32_t * piBytesRead );
#ifdef __cplusplus
}
#endif
#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/
#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/
#endif /* TRC_STREAMING_PORT_H */

@ -1,110 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* Supporting functions for trace streaming, used by the "stream ports"
* for reading and writing data to the interface.
*/
#include <trcRecorder.h>
#include <xscope.h>
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
typedef struct TraceStreamPortXS
{
#if ( TRC_USE_INTERNAL_BUFFER == 1 )
uint8_t uiBufferInternal[ TRC_STREAM_PORT_INTERNAL_BUFFER_SIZE ];
#endif
uint8_t uiBuffer[ 4 ];
} TraceStreamPortXS_t;
static TraceStreamPortXS_t * pxStreamPortXS;
traceResult xTraceStreamPortInitialize( TraceStreamPortBuffer_t * pxBuffer )
{
TRC_ASSERT_EQUAL_SIZE( TraceStreamPortBuffer_t, TraceStreamPortXS_t );
if( pxBuffer == 0 )
{
return TRC_FAIL;
}
pxStreamPortXS = ( TraceStreamPortXS_t * ) pxBuffer;
#if ( TRC_USE_INTERNAL_BUFFER == 1 )
return xTraceInternalEventBufferInitialize( pxStreamPortXS->uiBufferInternal, sizeof( pxStreamPortXS->uiBufferInternal ) );
#else
return TRC_SUCCESS;
#endif
}
traceResult xTraceStreamPortOnBegin( void )
{
return TRC_SUCCESS;
}
traceResult xTraceStreamPortOnEnd( void )
{
return TRC_SUCCESS;
}
traceResult xTraceStreamPortAllocate( uint32_t uiSize,
void ** ppvData )
{
( void ) uiSize;
return xTraceStaticBufferGet( ppvData );
}
traceResult xTraceStreamPortCommit( void * pvData,
uint32_t uiSize,
int32_t * piBytesCommitted )
{
if( pvData == 0 )
{
return TRC_FAIL;
}
#if ( TRC_USE_INTERNAL_BUFFER == 1 )
/* Push to internal buffer. It will call on xTraceStreamPortWriteData() periodically. */
return xTraceInternalEventBufferPush( pvData, uiSize, piBytesCommitted );
#else
/* Write directly to file */
return xTraceStreamPortWriteData( pvData, uiSize, piBytesCommitted );
#endif
}
traceResult xTraceStreamPortWriteData( void * pvData,
uint32_t uiSize,
int32_t * piBytesWritten )
{
/* xscope_bytes is supposed to be thread safe, so we do not bother with any
* critical sections here. */
xscope_bytes( 0, uiSize, ( unsigned char * ) pvData );
if( piBytesWritten != 0 )
{
/* Since xScope always write all bytes (not all might be received) we flag this as
* a full write */
*piBytesWritten = ( int32_t ) uiSize;
}
return TRC_SUCCESS;
}
traceResult xTraceStreamPortReadData( void * pvData,
uint32_t uiSize,
int32_t * piBytesRead )
{
return TRC_SUCCESS;
}
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */

@ -1,131 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The implementation for errors.
*/
#include <trcRecorder.h>
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#if ( ( TRC_CFG_USE_TRACE_ASSERT ) == 1 )
#if ( defined( TRC_CFG_TEST_MODE ) && ( TRC_CFG_TEST_MODE ) == 1 )
extern inline TraceBaseType_t prvTraceAssertCheckCondition( TraceBaseType_t condition );
#endif
#define TRC_ASSERT_STATE_INDEX_LINE_NUMBER 0
typedef struct TraceAssertInfo
{
TraceEntryHandle_t xEntry;
} TraceAssertInfo_t;
static TraceAssertInfo_t * pxAssertInfo;
traceResult xTraceAssertInitialize( TraceAssertBuffer_t * pxBuffer )
{
TRC_ASSERT_EQUAL_SIZE( TraceAssertBuffer_t, TraceAssertInfo_t );
TRC_ASSERT( pxBuffer != 0 );
pxAssertInfo = ( TraceAssertInfo_t * ) pxBuffer;
pxAssertInfo->xEntry = 0;
xTraceSetComponentInitialized( TRC_RECORDER_COMPONENT_ASSERT );
return TRC_SUCCESS;
}
void prvTraceAssertCreate( const char * szFilePath,
TraceUnsignedBaseType_t uxLineNumber )
{
TraceBaseType_t i, xLength;
TraceUnsignedBaseType_t uxEntryLineNumber = 0xFFFFFFFF;
static TraceUnsignedBaseType_t uxRecursionGuard = 0;
if( uxRecursionGuard == 0 )
{
/* Recursion can only get here once */
uxRecursionGuard = 1;
if( !xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_ASSERT ) )
{
return;
}
if( pxAssertInfo->xEntry == 0 )
{
if( xTraceEntryCreate( &pxAssertInfo->xEntry ) == TRC_FAIL )
{
return;
}
}
xTraceEntryGetState( pxAssertInfo->xEntry, TRC_ASSERT_STATE_INDEX_LINE_NUMBER, &uxEntryLineNumber );
/* We only save the first ASSERT information */
if( uxEntryLineNumber == 0 )
{
/* Find length */
for( i = 0; ( szFilePath[ i ] != 0 ) && ( i < 128 ); i++ )
{
}
xLength = i;
/* Find last slash or backslash */
for( i = xLength - 1; ( i >= 0 ) && ( ( szFilePath[ i ] != '\\' ) && ( szFilePath[ i ] != '/' ) ); i-- )
{
}
/* We treat the entry as an object and set it's name and state */
xTraceObjectSetName( ( TraceObjectHandle_t ) pxAssertInfo->xEntry, &szFilePath[ i + 1 ] );
xTraceObjectSetState( ( TraceObjectHandle_t ) pxAssertInfo->xEntry, uxLineNumber );
xTraceError( TRC_ERROR_ASSERT );
}
}
xTraceDiagnosticsIncrease( TRC_DIAGNOSTICS_ASSERTS_TRIGGERED );
}
traceResult xTraceAssertGet( TraceStringHandle_t * pxFileNameStringHandle,
TraceUnsignedBaseType_t * puxLineNumber )
{
TRC_ASSERT( pxFileNameStringHandle != 0 );
TRC_ASSERT( puxLineNumber != 0 );
if( !xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_ASSERT ) )
{
return TRC_FAIL;
}
*puxLineNumber = 0;
xTraceEntryGetState( pxAssertInfo->xEntry, TRC_ASSERT_STATE_INDEX_LINE_NUMBER, puxLineNumber );
if( *puxLineNumber == 0 )
{
return TRC_FAIL;
}
/* The string handle can be set to the entry handle */
*pxFileNameStringHandle = ( TraceStringHandle_t ) pxAssertInfo->xEntry;
return TRC_SUCCESS;
}
#endif /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */

@ -1,164 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The implementation of intervals.
*/
#include <trcRecorder.h>
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#define TRC_COUNTER_VALUE_INDEX 0
#define TRC_COUNTER_LOWER_LIMIT_INDEX 1
#define TRC_COUNTER_UPPER_LIMIT_INDEX 2
static TraceCounterCallback_t xCallbackFunction;
traceResult xTraceCounterSetCallback( TraceCounterCallback_t xCallback )
{
TRC_ASSERT( xCallback != 0 );
xCallbackFunction = xCallback;
/* We only set this component as initialized when the callback has been set */
xTraceSetComponentInitialized( TRC_RECORDER_COMPONENT_COUNTER );
return TRC_SUCCESS;
}
traceResult xTraceCounterCreate( const char * szName,
TraceBaseType_t xInitialValue,
TraceBaseType_t xLowerLimit,
TraceBaseType_t xUpperLimit,
TraceCounterHandle_t * pxCounterHandle )
{
TraceObjectHandle_t xObjectHandle;
TraceUnsignedBaseType_t uxStates[ 3 ];
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_COUNTER ) );
/* This should never fail */
TRC_ASSERT( pxCounterHandle != 0 );
TRC_ASSERT( xInitialValue >= xLowerLimit && xInitialValue <= xUpperLimit );
uxStates[ TRC_COUNTER_VALUE_INDEX ] = xInitialValue;
uxStates[ TRC_COUNTER_LOWER_LIMIT_INDEX ] = xLowerLimit;
uxStates[ TRC_COUNTER_UPPER_LIMIT_INDEX ] = xUpperLimit;
/* We need to check this */
if( xTraceObjectRegisterInternal( PSF_EVENT_COUNTER_CREATE, 0, szName, 3, uxStates, TRC_ENTRY_OPTION_COUNTER, &xObjectHandle ) == TRC_FAIL )
{
return TRC_FAIL;
}
*pxCounterHandle = ( TraceIntervalHandle_t ) xObjectHandle;
return TRC_SUCCESS;
}
traceResult xTraceCounterIncrease( TraceCounterHandle_t xCounterHandle )
{
return xTraceCounterAdd( xCounterHandle, 1 );
}
traceResult xTraceCounterDecrease( TraceCounterHandle_t xCounterHandle )
{
return xTraceCounterAdd( xCounterHandle, -1 );
}
traceResult xTraceCounterAdd( TraceCounterHandle_t xCounterHandle,
TraceBaseType_t xValue )
{
TraceBaseType_t xCurrent;
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_COUNTER ) );
/* This should never fail */
TRC_ASSERT_ALWAYS_EVALUATE( xTraceCounterGet( xCounterHandle, &xCurrent ) == TRC_SUCCESS );
/* This should never fail */
TRC_ASSERT_ALWAYS_EVALUATE( xTraceCounterSet( xCounterHandle, xCurrent + xValue ) == TRC_SUCCESS );
return TRC_SUCCESS;
}
traceResult xTraceCounterSet( TraceCounterHandle_t xCounterHandle,
TraceBaseType_t xValue )
{
TraceEventHandle_t xEventHandle = 0;
TraceBaseType_t xLowerLimit;
TraceBaseType_t xUpperLimit;
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_COUNTER ) );
/* This should never fail */
TRC_ASSERT_ALWAYS_EVALUATE( xTraceEntrySetState( ( TraceEntryHandle_t ) xCounterHandle, TRC_COUNTER_VALUE_INDEX, ( TraceUnsignedBaseType_t ) xValue ) == TRC_SUCCESS );
/* We need to check this */
if( xTraceEventBegin( PSF_EVENT_COUNTER_CHANGE, sizeof( void * ) + sizeof( uint32_t ), &xEventHandle ) == TRC_SUCCESS )
{
xTraceEventAddPointer( xEventHandle, ( void * ) xCounterHandle );
xTraceEventAdd32( xEventHandle, ( TraceUnsignedBaseType_t ) xValue );
xTraceEventEnd( xEventHandle );
}
/* This should never fail */
TRC_ASSERT_ALWAYS_EVALUATE( xTraceCounterGetLowerLimit( xCounterHandle, &xLowerLimit ) == TRC_SUCCESS );
if( xValue < xLowerLimit )
{
xCallbackFunction( xCounterHandle );
}
/* This should never fail */
TRC_ASSERT_ALWAYS_EVALUATE( xTraceCounterGetUpperLimit( xCounterHandle, &xUpperLimit ) == TRC_SUCCESS );
if( xValue > xUpperLimit )
{
xCallbackFunction( xCounterHandle );
}
return TRC_SUCCESS;
}
traceResult xTraceCounterGet( TraceCounterHandle_t xCounterHandle,
TraceBaseType_t * pxValue )
{
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_COUNTER ) );
return xTraceEntryGetState( ( TraceEntryHandle_t ) xCounterHandle, TRC_COUNTER_VALUE_INDEX, ( TraceUnsignedBaseType_t * ) pxValue );
}
traceResult xTraceCounterGetUpperLimit( TraceCounterHandle_t xCounterHandle,
TraceBaseType_t * pxValue )
{
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_COUNTER ) );
return xTraceEntryGetState( ( TraceEntryHandle_t ) xCounterHandle, TRC_COUNTER_UPPER_LIMIT_INDEX, ( TraceUnsignedBaseType_t * ) pxValue );
}
traceResult xTraceCounterGetLowerLimit( TraceCounterHandle_t xCounterHandle,
TraceBaseType_t * pxValue )
{
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_COUNTER ) );
return xTraceEntryGetState( ( TraceEntryHandle_t ) xCounterHandle, TRC_COUNTER_LOWER_LIMIT_INDEX, ( TraceUnsignedBaseType_t * ) pxValue );
}
traceResult xTraceCounterGetName( TraceCounterHandle_t xCounterHandle,
const char ** pszName )
{
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_COUNTER ) );
return xTraceEntryGetSymbol( ( TraceEntryHandle_t ) xCounterHandle, pszName );
}
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */

@ -1,171 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The implementation of the diagnostics.
*/
#include <trcRecorder.h>
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
typedef struct TraceDiagnostics
{
TraceBaseType_t metrics[ TRC_DIAGNOSTICS_COUNT ];
} TraceDiagnostics_t;
static TraceDiagnostics_t * pxDiagnostics;
traceResult xTraceDiagnosticsInitialize( TraceDiagnosticsBuffer_t * pxBuffer )
{
uint32_t i;
TRC_ASSERT_EQUAL_SIZE( TraceDiagnosticsBuffer_t, TraceDiagnostics_t );
/* This should never fail */
TRC_ASSERT( pxBuffer != 0 );
pxDiagnostics = ( TraceDiagnostics_t * ) pxBuffer;
for( i = 0; i < TRC_DIAGNOSTICS_COUNT; i++ )
{
pxDiagnostics->metrics[ i ] = 0;
}
xTraceSetComponentInitialized( TRC_RECORDER_COMPONENT_DIAGNOSTICS );
return TRC_SUCCESS;
}
traceResult xTraceDiagnosticsGet( TraceDiagnosticsType_t xType,
TraceBaseType_t * pxValue )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_DIAGNOSTICS ) );
/* This should never fail */
TRC_ASSERT( ( TraceUnsignedBaseType_t ) xType < TRC_DIAGNOSTICS_COUNT );
/* This should never fail */
TRC_ASSERT( pxValue != 0 );
*pxValue = pxDiagnostics->metrics[ ( TraceUnsignedBaseType_t ) xType ];
return TRC_SUCCESS;
}
traceResult xTraceDiagnosticsSet( TraceDiagnosticsType_t xType,
TraceBaseType_t xValue )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_DIAGNOSTICS ) );
/* This should never fail */
TRC_ASSERT( ( TraceUnsignedBaseType_t ) xType < TRC_DIAGNOSTICS_COUNT );
pxDiagnostics->metrics[ ( TraceUnsignedBaseType_t ) xType ] = xValue;
return TRC_SUCCESS;
}
traceResult xTraceDiagnosticsAdd( TraceDiagnosticsType_t xType,
TraceBaseType_t xValue )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_DIAGNOSTICS ) );
/* This should never fail */
TRC_ASSERT( ( TraceUnsignedBaseType_t ) xType < TRC_DIAGNOSTICS_COUNT );
pxDiagnostics->metrics[ ( TraceUnsignedBaseType_t ) xType ] += xValue;
return TRC_SUCCESS;
}
traceResult xTraceDiagnosticsIncrease( TraceDiagnosticsType_t xType )
{
return xTraceDiagnosticsAdd( xType, 1 );
}
traceResult xTraceDiagnosticsDecrease( TraceDiagnosticsType_t xType )
{
return xTraceDiagnosticsAdd( xType, -1 );
}
traceResult xTraceDiagnosticsSetIfHigher( TraceDiagnosticsType_t xType,
TraceBaseType_t xValue )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_DIAGNOSTICS ) );
/* This should never fail */
TRC_ASSERT( ( TraceUnsignedBaseType_t ) xType < TRC_DIAGNOSTICS_COUNT );
if( xValue > pxDiagnostics->metrics[ xType ] )
{
pxDiagnostics->metrics[ ( TraceUnsignedBaseType_t ) xType ] = xValue;
}
return TRC_SUCCESS;
}
traceResult xTraceDiagnosticsSetIfLower( TraceDiagnosticsType_t xType,
TraceBaseType_t xValue )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_DIAGNOSTICS ) );
/* This should never fail */
TRC_ASSERT( ( TraceUnsignedBaseType_t ) xType < TRC_DIAGNOSTICS_COUNT );
if( xValue < pxDiagnostics->metrics[ ( TraceUnsignedBaseType_t ) xType ] )
{
pxDiagnostics->metrics[ ( TraceUnsignedBaseType_t ) xType ] = xValue;
}
return TRC_SUCCESS;
}
traceResult xTraceDiagnosticsCheckStatus( void )
{
/* It is probably good if we always check this */
if( !xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_DIAGNOSTICS ) )
{
return TRC_FAIL;
}
if( pxDiagnostics->metrics[ TRC_DIAGNOSTICS_ENTRY_SLOTS_NO_ROOM ] > 0 )
{
xTraceWarning( TRC_WARNING_ENTRY_TABLE_SLOTS );
pxDiagnostics->metrics[ TRC_DIAGNOSTICS_ENTRY_SLOTS_NO_ROOM ] = 0;
}
if( pxDiagnostics->metrics[ TRC_DIAGNOSTICS_ENTRY_SYMBOL_LONGEST_LENGTH ] > ( TRC_CFG_ENTRY_SYMBOL_MAX_LENGTH ) )
{
xTraceWarning( TRC_WARNING_ENTRY_SYMBOL_MAX_LENGTH );
pxDiagnostics->metrics[ TRC_DIAGNOSTICS_ENTRY_SYMBOL_LONGEST_LENGTH ] = 0;
}
if( pxDiagnostics->metrics[ TRC_DIAGNOSTICS_BLOB_MAX_BYTES_TRUNCATED ] > 0 )
{
xTraceWarning( TRC_WARNING_EVENT_SIZE_TRUNCATED );
pxDiagnostics->metrics[ TRC_DIAGNOSTICS_BLOB_MAX_BYTES_TRUNCATED ] = 0;
}
if( pxDiagnostics->metrics[ TRC_DIAGNOSTICS_STACK_MONITOR_NO_SLOTS ] > 0 )
{
xTraceWarning( TRC_WARNING_STACKMON_NO_SLOTS );
pxDiagnostics->metrics[ TRC_DIAGNOSTICS_STACK_MONITOR_NO_SLOTS ] = 0;
}
return TRC_SUCCESS;
}
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */

@ -1,445 +0,0 @@
/*
* Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The implementation of the entry table.
*/
#include <trcRecorder.h>
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#define VALIDATE_ENTRY_HANDLE( xEntryHandle ) ( ( ( ( TraceUnsignedBaseType_t ) ( xEntryHandle ) >= ( TraceUnsignedBaseType_t ) pxEntryTable ) && ( ( TraceUnsignedBaseType_t ) ( xEntryHandle ) < ( ( TraceUnsignedBaseType_t ) pxEntryTable + sizeof( TraceEntryTable_t ) ) ) ) )
#define GIVE_ENTRY_INDEX( xIndex ) xIndexTable.axFreeIndexes[ xIndexTable.uiFreeIndexCount ] = ( xIndex ); xIndexTable.uiFreeIndexCount++
#define GET_FREE_INDEX_COUNT() xIndexTable.uiFreeIndexCount
#define CALCULATE_ENTRY_INDEX( xEntryHandle ) ( TraceEntryIndex_t ) ( ( ( TraceUnsignedBaseType_t ) ( ( TraceUnsignedBaseType_t ) ( xEntryHandle ) - ( TraceUnsignedBaseType_t ) pxEntryTable ) / sizeof( TraceEntry_t ) ) )
#if ( TRC_ENTRY_TABLE_SLOTS > 256 )
typedef uint16_t TraceEntryIndex_t;
#else
typedef uint8_t TraceEntryIndex_t;
#endif /* (TRC_CFG_ENTRY_TABLE_SLOTS > 256) */
typedef struct EntryIndexTable
{
TraceEntryIndex_t axFreeIndexes[ TRC_ENTRY_TABLE_SLOTS ];
uint32_t uiFreeIndexCount;
} TraceEntryIndexTable_t;
typedef struct TraceEntryTable
{
uint32_t uiSlots;
uint32_t uiEntrySymbolLength;
uint32_t uiEntryStateCount;
TraceEntry_t axEntries[ TRC_ENTRY_TABLE_SLOTS ];
} TraceEntryTable_t;
/* Private function definitions */
traceResult prvEntryIndexInitialize( TraceEntryIndexTable_t * pxIndexTable );
traceResult prvEntryIndexTake( TraceEntryIndex_t * pxIndex );
/* Variables */
static TraceEntryTable_t * pxEntryTable;
static TraceEntryIndexTable_t xIndexTable;
traceResult xTraceEntryTableInitialize( TraceEntryTableBuffer_t * pxBuffer )
{
uint32_t i, j;
TRC_ASSERT_EQUAL_SIZE( TraceEntryTableBuffer_t, TraceEntryTable_t );
/* This should never fail */
TRC_ASSERT( pxBuffer != 0 );
/* This should never fail */
TRC_ASSERT( ( TRC_ENTRY_TABLE_SLOTS ) != 0 );
pxEntryTable = ( TraceEntryTable_t * ) pxBuffer;
pxEntryTable->uiSlots = TRC_ENTRY_TABLE_SLOTS;
pxEntryTable->uiEntrySymbolLength = TRC_ENTRY_TABLE_SLOT_SYMBOL_SIZE;
pxEntryTable->uiEntryStateCount = TRC_ENTRY_TABLE_STATE_COUNT;
for( i = 0; i < TRC_ENTRY_TABLE_SLOTS; i++ )
{
pxEntryTable->axEntries[ i ].pvAddress = 0;
for( j = 0; j < TRC_ENTRY_TABLE_STATE_COUNT; j++ )
{
pxEntryTable->axEntries[ i ].xStates[ j ] = 0;
}
pxEntryTable->axEntries[ i ].szSymbol[ 0 ] = 0;
}
prvEntryIndexInitialize( &xIndexTable );
xTraceSetComponentInitialized( TRC_RECORDER_COMPONENT_ENTRY );
return TRC_SUCCESS;
}
traceResult xTraceEntryCreate( TraceEntryHandle_t * pxEntryHandle )
{
uint32_t i;
TraceEntryIndex_t xIndex;
TraceEntry_t * pxEntry;
TRACE_ALLOC_CRITICAL_SECTION();
/* We always check this */
if( !xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_ENTRY ) )
{
return TRC_FAIL;
}
/* This should never fail */
TRC_ASSERT( pxEntryHandle != 0 );
TRACE_ENTER_CRITICAL_SECTION();
if( prvEntryIndexTake( &xIndex ) != TRC_SUCCESS )
{
xTraceDiagnosticsIncrease( TRC_DIAGNOSTICS_ENTRY_SLOTS_NO_ROOM );
TRACE_EXIT_CRITICAL_SECTION();
return TRC_FAIL;
}
pxEntry = &pxEntryTable->axEntries[ xIndex ];
pxEntry->pvAddress = ( void * ) pxEntry; /* We set a temporary address */
for( i = 0; i < TRC_ENTRY_TABLE_STATE_COUNT; i++ )
{
pxEntry->xStates[ i ] = 0;
}
pxEntry->uiOptions = 0;
pxEntry->szSymbol[ 0 ] = 0;
*pxEntryHandle = ( TraceEntryHandle_t ) pxEntry;
TRACE_EXIT_CRITICAL_SECTION();
return TRC_SUCCESS;
}
traceResult xTraceEntryDelete( TraceEntryHandle_t xEntryHandle )
{
TraceEntryIndex_t xIndex;
TRACE_ALLOC_CRITICAL_SECTION();
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_ENTRY ) );
/* This should never fail */
TRC_ASSERT( VALIDATE_ENTRY_HANDLE( xEntryHandle ) );
/* Calculate the index based on the entry address */
/* Does not need to be locked. */
/* This should never fail */
xIndex = CALCULATE_ENTRY_INDEX( xEntryHandle );
TRC_ASSERT( xIndex < TRC_ENTRY_TABLE_SLOTS );
TRACE_ENTER_CRITICAL_SECTION();
if( ( ( TraceEntry_t * ) xEntryHandle )->pvAddress == 0 )
{
/* Someone else has deleted this already? */
TRACE_EXIT_CRITICAL_SECTION();
return TRC_FAIL;
}
/* A valid address, so we assume it is OK. */
/* For good measure, we clear the address field */
( ( TraceEntry_t * ) xEntryHandle )->pvAddress = 0;
/* Give back the index */
GIVE_ENTRY_INDEX( xIndex );
TRACE_EXIT_CRITICAL_SECTION();
return TRC_SUCCESS;
}
traceResult xTraceEntryFind( void * pvAddress,
TraceEntryHandle_t * pxEntryHandle )
{
uint32_t i;
TraceEntry_t * pxEntry;
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_ENTRY ) );
/* This should never fail */
TRC_ASSERT( pxEntryHandle != 0 );
/* This should never fail */
TRC_ASSERT( pvAddress != 0 );
for( i = 0; i < TRC_ENTRY_TABLE_SLOTS; i++ )
{
pxEntry = ( TraceEntry_t * ) ( ( ( uint32_t ) pxEntryTable->axEntries ) + ( i * sizeof( TraceEntry_t ) ) );
if( pxEntry->pvAddress == pvAddress )
{
*pxEntryHandle = ( TraceEntryHandle_t ) pxEntry;
return TRC_SUCCESS;
}
}
return TRC_FAIL;
}
traceResult xTraceEntrySetSymbol( TraceEntryHandle_t xEntryHandle,
const char * szSymbol )
{
uint32_t i;
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_ENTRY ) );
if( szSymbol == 0 )
{
szSymbol = "";
}
/* Does not need to be locked. */
/* This should never fail */
TRC_ASSERT( VALIDATE_ENTRY_HANDLE( xEntryHandle ) );
for( i = 0; i < ( TRC_ENTRY_TABLE_SYMBOL_LENGTH ); i++ )
{
( ( TraceEntry_t * ) xEntryHandle )->szSymbol[ i ] = szSymbol[ i ]; /* We do this first to ensure we also get the 0 termination, if there is one */
if( szSymbol[ i ] == 0 )
{
break;
}
}
/* Check the length of "name", if longer than TRC_ENTRY_TABLE_SYMBOL_LENGTH */
while( ( szSymbol[ i ] != 0 ) && i < 128 )
{
i++;
}
/* Remember the longest symbol name */
xTraceDiagnosticsSetIfHigher( TRC_DIAGNOSTICS_ENTRY_SYMBOL_LONGEST_LENGTH, i );
return TRC_SUCCESS;
}
traceResult xTraceEntryGetCount( uint32_t * puiCount )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_ENTRY ) );
/* This should never fail */
TRC_ASSERT( puiCount != 0 );
*puiCount = TRC_ENTRY_TABLE_SLOTS - GET_FREE_INDEX_COUNT();
return TRC_SUCCESS;
}
traceResult xTraceEntryGetAtIndex( uint32_t index,
TraceEntryHandle_t * pxEntryHandle )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_ENTRY ) );
/* This should never fail */
TRC_ASSERT( index < TRC_ENTRY_TABLE_SLOTS );
/* This should never fail */
TRC_ASSERT( pxEntryHandle != 0 );
*pxEntryHandle = ( TraceEntryHandle_t ) ( ( uint32_t ) ( pxEntryTable->axEntries ) + ( index * sizeof( TraceEntry_t ) ) );
return TRC_SUCCESS;
}
#if ( ( TRC_CFG_USE_TRACE_ASSERT ) == 1 )
traceResult xTraceEntryCreateWithAddress( void * pvAddress,
TraceEntryHandle_t * pxEntryHandle )
{
/* This should never fail */
TRC_ASSERT( pvAddress != 0 );
return TRC_ENTRY_CREATE_WITH_ADDRESS( pvAddress, pxEntryHandle );
}
traceResult xTraceEntrySetState( TraceEntryHandle_t xEntryHandle,
uint32_t uiStateIndex,
TraceUnsignedBaseType_t uxState )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_ENTRY ) );
/* This should never fail */
TRC_ASSERT( uiStateIndex < ( TRC_ENTRY_TABLE_STATE_COUNT ) );
/* This should never fail */
TRC_ASSERT( VALIDATE_ENTRY_HANDLE( xEntryHandle ) );
return TRC_ENTRY_SET_STATE( xEntryHandle, uiStateIndex, uxState );
}
traceResult xTraceEntrySetOptions( TraceEntryHandle_t xEntryHandle,
uint32_t uiMask )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_ENTRY ) );
/* Does not need to be locked. */
/* This should never fail */
TRC_ASSERT( VALIDATE_ENTRY_HANDLE( xEntryHandle ) );
return TRC_ENTRY_SET_OPTIONS( xEntryHandle, uiMask );
}
traceResult xTraceEntryClearOptions( TraceEntryHandle_t xEntryHandle,
uint32_t uiMask )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_ENTRY ) );
/* Does not need to be locked. */
/* This should never fail */
TRC_ASSERT( VALIDATE_ENTRY_HANDLE( xEntryHandle ) );
return TRC_ENTRY_CLEAR_OPTIONS( xEntryHandle, uiMask );
}
traceResult xTraceEntryGetAddress( TraceEntryHandle_t xEntryHandle,
void ** ppvAddress )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_ENTRY ) );
/* This should never fail */
TRC_ASSERT( ppvAddress != 0 );
/* Does not need to be locked. */
/* This should never fail */
TRC_ASSERT( VALIDATE_ENTRY_HANDLE( xEntryHandle ) );
return TRC_ENTRY_GET_ADDRESS( xEntryHandle, ppvAddress );
}
traceResult xTraceEntryGetSymbol( TraceEntryHandle_t xEntryHandle,
const char ** pszSymbol )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_ENTRY ) );
/* This should never fail */
TRC_ASSERT( pszSymbol != 0 );
/* Does not need to be locked. */
/* This should never fail */
TRC_ASSERT( VALIDATE_ENTRY_HANDLE( xEntryHandle ) );
return TRC_ENTRY_GET_SYMBOL( xEntryHandle, pszSymbol );
}
traceResult xTraceEntryGetState( TraceEntryHandle_t xEntryHandle,
uint32_t uiStateIndex,
TraceUnsignedBaseType_t * puxState )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_ENTRY ) );
/* This should never fail */
TRC_ASSERT( puxState != 0 );
/* This should never fail */
TRC_ASSERT( uiStateIndex < TRC_ENTRY_TABLE_STATE_COUNT );
/* Does not need to be locked. */
/* This should never fail */
TRC_ASSERT( VALIDATE_ENTRY_HANDLE( xEntryHandle ) );
return TRC_ENTRY_GET_STATE( xEntryHandle, uiStateIndex, puxState );
}
traceResult xTraceEntryGetOptions( TraceEntryHandle_t xEntryHandle,
uint32_t * puiOptions )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_ENTRY ) );
/* This should never fail */
TRC_ASSERT( puiOptions != 0 );
/* Does not need to be locked. */
/* This should never fail */
TRC_ASSERT( VALIDATE_ENTRY_HANDLE( xEntryHandle ) );
return TRC_ENTRY_GET_OPTIONS( xEntryHandle, puiOptions );
}
#endif /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */
/* PRIVATE FUNCTIONS */
traceResult prvEntryIndexInitialize( TraceEntryIndexTable_t * pxIndexTable )
{
uint32_t i;
for( i = 0; i < TRC_ENTRY_TABLE_SLOTS; i++ )
{
pxIndexTable->axFreeIndexes[ i ] = ( TraceEntryIndex_t ) i;
}
xIndexTable.uiFreeIndexCount = TRC_ENTRY_TABLE_SLOTS;
return TRC_SUCCESS;
}
traceResult prvEntryIndexTake( TraceEntryIndex_t * pxIndex )
{
/* Critical Section must be active! */
TraceEntryIndex_t xIndex;
if( xIndexTable.uiFreeIndexCount == 0 )
{
return TRC_FAIL;
}
/* Always take the first item */
xIndex = xIndexTable.axFreeIndexes[ 0 ];
xIndexTable.uiFreeIndexCount--;
/* Move the last item to the first slot, to avoid holes */
xIndexTable.axFreeIndexes[ 0 ] = xIndexTable.axFreeIndexes[ xIndexTable.uiFreeIndexCount ];
#if ( TRC_ENTRY_TABLE_SLOTS > 256 )
xIndexTable.axFreeIndexes[ xIndexTable.uiFreeIndexCount ] = UINT16_MAX;
#else
xIndexTable.axFreeIndexes[ xIndexTable.uiFreeIndexCount ] = UINT8_MAX;
#endif
*pxIndex = xIndex;
return TRC_SUCCESS;
}
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */

@ -1,354 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The implementation for errors.
*/
#include <trcRecorder.h>
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
/* We skip the slot for TRC_ERROR_NONE so error code 1 is the first bit */
#define GET_ERROR_WARNING_FLAG( errorCode ) ( pxErrorInfo->uiErrorAndWarningFlags & ( 1 << ( ( errorCode ) - 1 ) ) )
#define SET_ERROR_WARNING_FLAG( errorCode ) ( pxErrorInfo->uiErrorAndWarningFlags |= ( 1 << ( ( errorCode ) - 1 ) ) )
traceResult prvTraceErrorPrint( uint32_t uiErrorCode );
traceResult prvTraceErrorGetDescription( uint32_t uiErrorCode,
const char ** pszDesc );
typedef struct TraceErrorInfo
{
uint32_t uiErrorAndWarningFlags;
uint32_t uiErrorCode;
TraceStringHandle_t xWarningChannel;
} TraceErrorInfo_t;
static TraceErrorInfo_t * pxErrorInfo;
traceResult xTraceErrorInitialize( TraceErrorBuffer_t * pxBuffer )
{
TRC_ASSERT_EQUAL_SIZE( TraceErrorBuffer_t, TraceErrorInfo_t );
/* This should never fail */
TRC_ASSERT( pxBuffer != 0 );
pxErrorInfo = ( TraceErrorInfo_t * ) pxBuffer;
pxErrorInfo->uiErrorAndWarningFlags = 0;
pxErrorInfo->uiErrorCode = 0;
pxErrorInfo->xWarningChannel = 0;
xTraceSetComponentInitialized( TRC_RECORDER_COMPONENT_ERROR );
return TRC_SUCCESS;
}
/* Called on warnings, when the recording can continue. */
traceResult xTraceWarning( uint32_t uiErrorCode )
{
/* Probably good to verify this */
if( !xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_ERROR ) )
{
/* If not initialized */
return TRC_FAIL;
}
if( GET_ERROR_WARNING_FLAG( uiErrorCode ) == 0 )
{
/* Will never reach this point more than once per warning type, since we verify if uiErrorAndWarningFlags[uiErrorCode] has already been set */
SET_ERROR_WARNING_FLAG( uiErrorCode );
prvTraceErrorPrint( uiErrorCode );
}
return TRC_SUCCESS;
}
/* Called on critical errors in the recorder. Stops the recorder! */
traceResult xTraceError( uint32_t uiErrorCode )
{
/* Probably good to verify this */
if( !xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_ERROR ) )
{
return TRC_FAIL;
}
if( pxErrorInfo->uiErrorCode == TRC_ERROR_NONE )
{
/* Will never reach this point more than once, since we verify if uiErrorCode has already been set */
SET_ERROR_WARNING_FLAG( uiErrorCode );
pxErrorInfo->uiErrorCode = uiErrorCode;
if( prvTraceErrorPrint( uiErrorCode ) == TRC_FAIL )
{
xTraceDisable();
return TRC_FAIL;
}
xTracePrint( pxErrorInfo->xWarningChannel, "Recorder stopped in xTraceError(...)!" );
xTraceDisable();
}
return TRC_SUCCESS;
}
/*******************************************************************************
* xTraceErrorGetLast
*
* Returns the last error or warning, as a string, or NULL if none.
*****************************************************************************/
traceResult xTraceErrorGetLast( const char ** pszError )
{
/* Probably good to verify this */
if( !xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_ERROR ) )
{
return TRC_FAIL;
}
/* This should never fail */
TRC_ASSERT( pszError != 0 );
return prvTraceErrorGetDescription( pxErrorInfo->uiErrorCode, pszError );
}
/*******************************************************************************
* xTraceErrorClear
*
* Clears any errors.
*****************************************************************************/
traceResult xTraceErrorClear( void )
{
/* Probably good to verify this */
if( !xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_ERROR ) )
{
/* If not initialized */
return TRC_FAIL;
}
pxErrorInfo->uiErrorCode = TRC_ERROR_NONE;
return TRC_SUCCESS;
}
/* Returns the error or warning, as a string, or NULL if none. */
traceResult prvTraceErrorPrint( uint32_t uiErrorCode )
{
const char * szDesc;
/* Note: the error messages are short, in order to fit in a User Event.
* Instead, the users can read more in the below comments.*/
if( pxErrorInfo->xWarningChannel == 0 )
{
/* The #WFR channel means "Warnings from Recorder" and
* is used to store warnings and errors from the recorder.
* The abbreviation #WFR is used instead of the longer full name,
* to avoid truncation by small slots in the symbol table.
* This is translated in Tracealyzer and shown as the full name,
* "Warnings from Recorder".
*/
if( xTraceStringRegister( "#WFR", &pxErrorInfo->xWarningChannel ) == TRC_FAIL )
{
return TRC_FAIL;
}
}
prvTraceErrorGetDescription( uiErrorCode, &szDesc );
switch( uiErrorCode )
{
case TRC_WARNING_ENTRY_TABLE_SLOTS:
case TRC_WARNING_ENTRY_SYMBOL_MAX_LENGTH:
case TRC_WARNING_EVENT_SIZE_TRUNCATED:
case TRC_WARNING_STREAM_PORT_READ:
case TRC_WARNING_STREAM_PORT_WRITE:
case TRC_WARNING_STREAM_PORT_INITIAL_BLOCKING:
case TRC_WARNING_STACKMON_NO_SLOTS:
case TRC_ERROR_STREAM_PORT_WRITE:
case TRC_ERROR_EVENT_CODE_TOO_LARGE:
case TRC_ERROR_ISR_NESTING_OVERFLOW:
case TRC_ERROR_DWT_NOT_SUPPORTED:
case TRC_ERROR_DWT_CYCCNT_NOT_SUPPORTED:
case TRC_ERROR_TZCTRLTASK_NOT_CREATED:
xTracePrint( pxErrorInfo->xWarningChannel, szDesc );
break;
case TRC_ERROR_ASSERT:
/* A TRC_ASSERT has triggered */
{
TraceUnsignedBaseType_t uxLineNumber;
TraceStringHandle_t xFileName;
if( xTraceAssertGet( &xFileName, &uxLineNumber ) == TRC_FAIL )
{
return TRC_FAIL;
}
xTracePrintF( pxErrorInfo->xWarningChannel, szDesc, xFileName, ( uint32_t ) uxLineNumber );
return TRC_SUCCESS;
}
default:
/* No error, or an unknown error occurred */
xTracePrintF( pxErrorInfo->xWarningChannel, "Unknown error code: 0x%08X", uiErrorCode );
return TRC_FAIL;
}
return TRC_SUCCESS;
}
/* Returns the error or warning, as a string, or NULL if none. */
traceResult prvTraceErrorGetDescription( uint32_t uiErrorCode,
const char ** pszDesc )
{
/* Note: the error messages are short, in order to fit in a User Event.
* Instead, the users can read more in the below comments.*/
switch( uiErrorCode )
{
case TRC_ERROR_NONE:
return TRC_FAIL;
case TRC_WARNING_ENTRY_TABLE_SLOTS:
/* There was not enough symbol table slots for storing symbol names.
* The number of missing slots is counted by NoRoomForSymbol. Inspect this
* variable and increase TRC_CFG_ENTRY_TABLE_SLOTS by at least that value. */
*pszDesc = "Exceeded TRC_CFG_ENTRY_TABLE_SLOTS";
break;
case TRC_WARNING_ENTRY_SYMBOL_MAX_LENGTH:
/* A symbol name exceeded TRC_CFG_ENTRY_SYMBOL_MAX_LENGTH in length.
* Make sure the symbol names are at most TRC_CFG_SYMBOL_MAX_LENGTH,
* or inspect uiLongestSymbolName in trcEntryTable and increase
* TRC_CFG_ENTRY_SYMBOL_MAX_LENGTH to at least this value. */
*pszDesc = "Exceeded TRC_CFG_ENTRY_SYMBOL_MAX_LENGTH";
break;
case TRC_WARNING_EVENT_SIZE_TRUNCATED:
/* Some arguments was longer than the maximum payload size
* and has been truncated by "uiMaxBytesTruncated" bytes.
*
* This usually happens for the following functions:
* - xTracePrint
* - xTracePrintF
* - xTraceStringRegister
*
* A trace event may store a maximum of 56 bytes payload, including
* data arguments and string characters. */
*pszDesc = "Event size exceeded";
break;
case TRC_WARNING_STREAM_PORT_READ:
/* TRC_STREAM_PORT_READ_DATA is expected to return 0 when completed successfully.
* This means there is an error in the communication with host/Tracealyzer. */
*pszDesc = "TRC_STREAM_PORT_READ_DATA returned error";
break;
case TRC_WARNING_STREAM_PORT_WRITE:
/* TRC_STREAM_PORT_WRITE_DATA is expected to return 0 when completed successfully.
* This means there is an error in the communication with host/Tracealyzer. */
*pszDesc = "TRC_STREAM_PORT_WRITE_DATA returned error";
break;
case TRC_WARNING_STREAM_PORT_INITIAL_BLOCKING:
/* Blocking occurred during xTraceEnable. This happens if the trace buffer is
* smaller than the initial transmission (trace header, object table, and symbol table). */
*pszDesc = "Blocking in xTraceEnable";
break;
case TRC_WARNING_STACKMON_NO_SLOTS:
/* Some tasks did not fit in the stack monitor. Increase the slot count. */
*pszDesc = "No slots left in Stack Monitor";
break;
case TRC_ERROR_STREAM_PORT_WRITE:
/* TRC_STREAM_PORT_WRITE_DATA is expected to return 0 when completed successfully.
* This means there is an error in the communication with host/Tracealyzer. */
*pszDesc = "TRC_STREAM_PORT_WRITE_DATA returned error";
break;
case TRC_ERROR_EVENT_CODE_TOO_LARGE:
/* The highest allowed event code is 4095, anything higher is an unexpected error.
* Please contact support@percepio.com for assistance.*/
*pszDesc = "Invalid event code";
break;
case TRC_ERROR_ISR_NESTING_OVERFLOW:
/* Nesting of ISR trace calls exceeded the limit (TRC_CFG_MAX_ISR_NESTING).
* If this is unlikely, make sure that you call vTraceStoreISRExit in the end
* of all ISR handlers. Or increase TRC_CFG_MAX_ISR_NESTING. */
*pszDesc = "Exceeded ISR nesting";
break;
case TRC_ERROR_DWT_NOT_SUPPORTED:
/* On ARM Cortex-M only - failed to initialize DWT Cycle Counter since not supported by this chip.
* DWT timestamping is selected automatically for ART Cortex-M3, M4 and higher, based on the __CORTEX_M
* macro normally set by ARM's CMSIS library, since typically available. You can however select
* SysTick timestamping instead by defining adding "#define TRC_CFG_ARM_CM_USE_SYSTICK".*/
*pszDesc = "DWT not supported";
break;
case TRC_ERROR_DWT_CYCCNT_NOT_SUPPORTED:
/* On ARM Cortex-M only - failed to initialize DWT Cycle Counter since not supported by this chip.
* DWT timestamping is selected automatically for ART Cortex-M3, M4 and higher, based on the __CORTEX_M
* macro normally set by ARM's CMSIS library, since typically available. You can however select
* SysTick timestamping instead by defining adding "#define TRC_CFG_ARM_CM_USE_SYSTICK".*/
*pszDesc = "DWT_CYCCNT not supported";
break;
case TRC_ERROR_TZCTRLTASK_NOT_CREATED:
/* xTraceEnable failed creating the trace control task (TzCtrl) - incorrect parameters (priority?)
* or insufficient heap size? */
*pszDesc = "Could not create TzCtrl";
break;
case TRC_ERROR_ASSERT:
/* A TRC_ASSERT has triggered */
*pszDesc = "ASSERT: %s (%d)";
break;
default:
/* An unknown error occurred */
*pszDesc = "Unknown error code: 0x%08X";
break;
}
return TRC_SUCCESS;
}
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */

@ -1,432 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The implementation for events.
*/
#include <trcRecorder.h>
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
#define VERIFY_EVENT_SIZE( i ) \
if( ( i ) > ( TRC_MAX_BLOB_SIZE ) ) \
{ \
xTraceDiagnosticsSetIfHigher( TRC_DIAGNOSTICS_BLOB_MAX_BYTES_TRUNCATED, ( TraceUnsignedBaseType_t ) ( ( i ) - ( TRC_MAX_BLOB_SIZE ) ) ); \
( i ) = TRC_MAX_BLOB_SIZE; \
}
TraceEventDataTable_t * pxTraceEventDataTable;
int32_t DUMMY_iTraceBytesCommitted;
TRACE_ALLOC_CRITICAL_SECTION();
traceResult xTraceEventInitialize( TraceEventDataBuffer_t * pxBuffer )
{
TraceCoreEventData_t * pxCoreEventData;
uint32_t i, j;
TRC_ASSERT_EQUAL_SIZE( TraceEventDataBuffer_t, TraceEventDataTable_t );
/* This should never fail */
TRC_ASSERT( pxBuffer != 0 );
pxTraceEventDataTable = ( TraceEventDataTable_t * ) pxBuffer;
for( i = 0; i < TRC_CFG_CORE_COUNT; i++ )
{
pxCoreEventData = &pxTraceEventDataTable->coreEventData[ i ];
pxCoreEventData->eventCounter = 0;
for( j = 0; j < ( TRC_CFG_MAX_ISR_NESTING ) +1; j++ )
{
RESET_EVENT_DATA( &pxCoreEventData->eventData[ j ] );
}
}
xTraceSetComponentInitialized( TRC_RECORDER_COMPONENT_EVENT );
return TRC_SUCCESS;
}
traceResult xTraceEventBeginRawOffline( uint32_t uiSize,
TraceEventHandle_t * pxEventHandle )
{
TraceEventData_t * pxEventData;
int32_t ISR_nesting;
/* We need to check this */
if( !xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_EVENT ) )
{
return TRC_FAIL;
}
/* This should never fail */
TRC_ASSERT( pxEventHandle != 0 );
TRACE_ENTER_CRITICAL_SECTION();
xTraceISRGetCurrentNesting( &ISR_nesting );
/* We add 1 since xTraceISRGetCurrentNesting(...) returns -1 if no ISR is active */
pxEventData = &pxTraceEventDataTable->coreEventData[ TRC_CFG_GET_CURRENT_CORE() ].eventData[ ISR_nesting + 1 ];
/* This should never fail */
TRC_ASSERT_CUSTOM_ON_FAIL( pxEventData->pvBlob == 0, TRACE_EXIT_CRITICAL_SECTION();
return TRC_FAIL;
);
VERIFY_EVENT_SIZE( uiSize );
pxEventData->size = ( ( uiSize + ( sizeof( uint32_t ) - 1 ) ) / sizeof( uint32_t ) ) * sizeof( uint32_t ); /* 4-byte align */
pxEventData->offset = 0;
/* This can fail and we should handle it */
if( xTraceStreamPortAllocate( pxEventData->size, &pxEventData->pvBlob ) == TRC_FAIL )
{
TRACE_EXIT_CRITICAL_SECTION();
return TRC_FAIL;
}
*pxEventHandle = ( TraceEventHandle_t ) pxEventData;
return TRC_SUCCESS;
}
traceResult xTraceEventBeginRawOfflineBlocking( uint32_t uiSize,
TraceEventHandle_t * pxEventHandle )
{
TraceEventData_t * pxEventData;
int32_t ISR_nesting;
uint32_t uiAttempts = 0;
/* We need to check this */
if( !xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_EVENT ) )
{
return TRC_FAIL;
}
/* This should never fail */
TRC_ASSERT( pxEventHandle != 0 );
TRACE_ENTER_CRITICAL_SECTION();
xTraceGetCurrentISRNesting( &ISR_nesting );
/* We add 1 since xTraceISRGetCurrentNesting(...) returns -1 if no ISR is active */
pxEventData = &pxTraceEventDataTable->coreEventData[ TRC_CFG_GET_CURRENT_CORE() ].eventData[ ISR_nesting + 1 ];
/* This should never fail */
TRC_ASSERT_CUSTOM_ON_FAIL( pxEventData->pvBlob == 0, TRACE_EXIT_CRITICAL_SECTION();
return TRC_FAIL;
);
VERIFY_EVENT_SIZE( uiSize );
pxEventData->size = ( ( uiSize + ( sizeof( uint32_t ) - 1 ) ) / sizeof( uint32_t ) ) * sizeof( uint32_t ); /* 4-byte align */
pxEventData->offset = 0;
/* This can fail and we should handle it */
while( xTraceStreamPortAllocate( pxEventData->size, &pxEventData->pvBlob ) != TRC_SUCCESS )
{
uiAttempts++;
}
*pxEventHandle = ( TraceEventHandle_t ) pxEventData;
return TRC_SUCCESS;
}
traceResult xTraceEventEndOffline( TraceEventHandle_t xEventHandle )
{
int32_t iBytesCommitted;
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_EVENT ) );
/* This should never fail */
TRC_ASSERT( xEventHandle != 0 );
/* This should never fail */
TRC_ASSERT( ( ( TraceEventData_t * ) xEventHandle )->pvBlob != 0 );
xTraceStreamPortCommit( ( ( TraceEventData_t * ) xEventHandle )->pvBlob, ( ( TraceEventData_t * ) xEventHandle )->size, &iBytesCommitted );
RESET_EVENT_DATA( ( TraceEventData_t * ) xEventHandle );
TRACE_EXIT_CRITICAL_SECTION();
return TRC_SUCCESS;
}
traceResult xTraceEventEndOfflineBlocking( TraceEventHandle_t xEventHandle )
{
TraceEventData_t * pxEventData = ( TraceEventData_t * ) xEventHandle;
int32_t iBytesCommitted;
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_EVENT ) );
/* This should never fail */
TRC_ASSERT( pxEventData != 0 );
while( pxEventData->size > 0 )
{
iBytesCommitted = 0;
xTraceStreamPortCommit( pxEventData->pvBlob, pxEventData->size, &iBytesCommitted );
pxEventData->size -= iBytesCommitted;
pxEventData->pvBlob = ( ( uint8_t * ) pxEventData->pvBlob ) + iBytesCommitted;
}
RESET_EVENT_DATA( pxEventData );
TRACE_EXIT_CRITICAL_SECTION();
return TRC_SUCCESS;
}
traceResult xTraceEventAddData( TraceEventHandle_t xEventHandle,
void * pvData,
uint32_t uiSize )
{
uint32_t i;
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_EVENT ) );
/* This should never fail */
TRC_ASSERT( xEventHandle != 0 );
/* This should never fail */
TRC_ASSERT( pvData != 0 );
/* This should never fail */
TRC_ASSERT( ( ( TraceEventData_t * ) xEventHandle )->offset + uiSize <= ( ( TraceEventData_t * ) xEventHandle )->size );
for( i = 0; i < uiSize; i++ )
{
TRC_EVENT_ADD_8( xEventHandle, ( ( uint8_t * ) pvData )[ i ] );
}
return TRC_SUCCESS;
}
#if ( ( TRC_CFG_USE_TRACE_ASSERT ) == 1 )
traceResult xTraceEventGetSize( void * pvAddress,
uint32_t * puiSize )
{
/* This should never fail */
TRC_ASSERT( pvAddress != 0 );
/* This should never fail */
TRC_ASSERT( puiSize != 0 );
/* This should never fail */
TRC_ASSERT( ( sizeof( TraceBaseEvent_t ) + ( TRC_EVENT_GET_PARAM_COUNT( ( ( TraceBaseEvent_t * ) pvAddress )->EventID ) ) * sizeof( uint32_t ) ) <= TRC_MAX_BLOB_SIZE );
return TRC_EVENT_GET_SIZE( pvAddress, puiSize );
}
traceResult xTraceEventGetRawData( TraceEventHandle_t xEventHandle,
uint32_t uiOffset,
uint32_t uiSize,
void ** ppvData )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_EVENT ) );
/* This should never fail */
TRC_ASSERT( xEventHandle != 0 );
/* This should never fail */
TRC_ASSERT( ppvData != 0 );
/* This should never fail */
TRC_ASSERT( uiOffset + uiSize <= ( ( TraceEventData_t * ) xEventHandle )->size );
return TRC_EVENT_GET_RAW_DATA( xEventHandle, uiOffset, uiSize, ppvData );
}
traceResult xTraceEventGetPayload( TraceEventHandle_t xEventHandle,
uint32_t uiOffset,
uint32_t uiSize,
void ** ppvData )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_EVENT ) );
/* This should never fail */
TRC_ASSERT( xEventHandle != 0 );
/* This should never fail */
TRC_ASSERT( ppvData != 0 );
/* This should never fail */
TRC_ASSERT( uiOffset + uiSize <= ( ( TraceEventData_t * ) xEventHandle )->size );
return TRC_EVENT_GET_PAYLOAD( xEventHandle, uiOffset, uiSize, ppvData );
}
traceResult xTraceEventPayloadRemaining( TraceEventHandle_t xEventHandle,
uint32_t * puiValue )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_EVENT ) );
/* This should never fail */
TRC_ASSERT( xEventHandle != 0 );
/* This should never fail */
TRC_ASSERT( puiValue != 0 );
/* This should never fail */
TRC_ASSERT( ( ( TraceEventData_t * ) xEventHandle )->pvBlob != 0 );
return TRC_EVENT_PAYLOAD_REMAINING( xEventHandle, puiValue );
}
traceResult xTraceEventPayloadUsed( TraceEventHandle_t xEventHandle,
uint32_t * puiValue )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_EVENT ) );
/* This should never fail */
TRC_ASSERT( xEventHandle != 0 );
/* This should never fail */
TRC_ASSERT( puiValue != 0 );
/* This should never fail */
TRC_ASSERT( ( ( TraceEventData_t * ) xEventHandle )->pvBlob != 0 );
return TRC_EVENT_PAYLOAD_USED( xEventHandle, puiValue );
}
traceResult xTraceEventPayloadSize( TraceEventHandle_t xEventHandle,
uint32_t * puiValue )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_EVENT ) );
/* This should never fail */
TRC_ASSERT( xEventHandle != 0 );
/* This should never fail */
TRC_ASSERT( puiValue != 0 );
/* This should never fail */
TRC_ASSERT( ( ( TraceEventData_t * ) xEventHandle )->pvBlob != 0 );
return TRC_EVENT_PAYLOAD_SIZE( xEventHandle, puiValue );
}
traceResult xTraceEventAddPointer( TraceEventHandle_t xEventHandle,
void * pvAddress )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_EVENT ) );
/* This should never fail */
TRC_ASSERT( xEventHandle != 0 );
/* This should never fail */
TRC_ASSERT( ( ( TraceEventData_t * ) xEventHandle )->offset + sizeof( void * ) <= ( ( TraceEventData_t * ) xEventHandle )->size );
/* Make sure we are writing at void* aligned offset */
/* This should never fail */
TRC_ASSERT( ( ( ( TraceEventData_t * ) xEventHandle )->offset & ( sizeof( void * ) - 1 ) ) == 0 );
return TRC_EVENT_ADD_POINTER( xEventHandle, pvAddress );
}
traceResult xTraceEventAddUnsignedBaseType( TraceEventHandle_t xEventHandle,
TraceUnsignedBaseType_t uxValue )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_EVENT ) );
/* This should never fail */
TRC_ASSERT( xEventHandle != 0 );
/* This should never fail */
TRC_ASSERT( ( ( TraceEventData_t * ) xEventHandle )->offset + sizeof( TraceUnsignedBaseType_t ) <= ( ( TraceEventData_t * ) xEventHandle )->size );
/* Make sure we are writing at TraceUnsignedBaseType_t aligned offset */
/* This should never fail */
TRC_ASSERT( ( ( ( TraceEventData_t * ) xEventHandle )->offset & ( sizeof( TraceUnsignedBaseType_t ) - 1 ) ) == 0 );
return TRC_EVENT_ADD_UNSIGNED_BASE_TYPE( xEventHandle, uxValue );
}
traceResult xTraceEventAdd32( TraceEventHandle_t xEventHandle,
uint32_t value )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_EVENT ) );
/* This should never fail */
TRC_ASSERT( xEventHandle != 0 );
/* This should never fail */
TRC_ASSERT( ( ( TraceEventData_t * ) xEventHandle )->offset + sizeof( uint32_t ) <= ( ( TraceEventData_t * ) xEventHandle )->size );
/* Make sure we are writing at 32-bit aligned offset */
/* This should never fail */
TRC_ASSERT( ( ( ( TraceEventData_t * ) xEventHandle )->offset & 3 ) == 0 );
return TRC_EVENT_ADD_32( xEventHandle, value );
}
traceResult xTraceEventAdd16( TraceEventHandle_t xEventHandle,
uint16_t value )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_EVENT ) );
/* This should never fail */
TRC_ASSERT( xEventHandle != 0 );
/* This should never fail */
TRC_ASSERT( ( ( TraceEventData_t * ) xEventHandle )->offset + sizeof( uint16_t ) <= ( ( TraceEventData_t * ) xEventHandle )->size );
/* Make sure we are writing at 16-bit aligned offset */
/* This should never fail */
TRC_ASSERT( ( ( ( TraceEventData_t * ) xEventHandle )->offset & 1 ) == 0 );
return TRC_EVENT_ADD_16( xEventHandle, value );
}
traceResult xTraceEventAdd8( TraceEventHandle_t xEventHandle,
uint8_t value )
{
/* This should never fail */
TRC_ASSERT( xTraceIsComponentInitialized( TRC_RECORDER_COMPONENT_EVENT ) );
/* This should never fail */
TRC_ASSERT( xEventHandle != 0 );
/* This should never fail */
TRC_ASSERT( ( ( TraceEventData_t * ) xEventHandle )->offset + sizeof( uint8_t ) <= ( ( TraceEventData_t * ) xEventHandle )->size );
return TRC_EVENT_ADD_8( xEventHandle, value );
}
#endif /* ((TRC_CFG_USE_TRACE_ASSERT) == 1) */
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */

@ -1,260 +0,0 @@
/*
* Percepio Trace Recorder for Tracealyzer v4.6.0
* Copyright 2021 Percepio AB
* www.percepio.com
*
* SPDX-License-Identifier: Apache-2.0
*
* The implementation for the event buffer.
*/
#include <trcRecorder.h>
#if ( TRC_USE_TRACEALYZER_RECORDER == 1 )
#if ( TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING )
traceResult xTraceEventBufferInitialize( TraceEventBuffer_t * pxTraceEventBuffer,
uint32_t uiOptions,
uint8_t * puiBuffer,
uint32_t uiSize )
{
/* This should never fail */
TRC_ASSERT( pxTraceEventBuffer != 0 );
/* This should never fail */
TRC_ASSERT( puiBuffer != 0 );
pxTraceEventBuffer->uiOptions = uiOptions;
pxTraceEventBuffer->uiHead = 0;
pxTraceEventBuffer->uiTail = 0;
pxTraceEventBuffer->uiSize = uiSize;
pxTraceEventBuffer->uiFree = uiSize;
pxTraceEventBuffer->puiBuffer = puiBuffer;
pxTraceEventBuffer->uiTimerWraparounds = 0;
xTraceSetComponentInitialized( TRC_RECORDER_COMPONENT_EVENT_BUFFER );
return TRC_SUCCESS;
}
/**
* @brief Pops the oldest event from the Event Buffer.
*
* @param[in] pxTraceEventBuffer Pointer to initialized trace event buffer.
*
* @retval TRC_FAIL Failure
* @retval TRC_SUCCESS Success
*/
static traceResult prvTraceEventBufferPop( TraceEventBuffer_t * pxTraceEventBuffer )
{
uint32_t uiFreeSize = 0;
/* Get size of event we are freeing */
/* This should never fail */
TRC_ASSERT_ALWAYS_EVALUATE( xTraceEventGetSize( ( ( void * ) &( pxTraceEventBuffer->puiBuffer[ pxTraceEventBuffer->uiTail ] ) ), &uiFreeSize ) == TRC_SUCCESS );
pxTraceEventBuffer->uiFree += uiFreeSize;
/* Update tail to point to the new last event */
pxTraceEventBuffer->uiTail = ( pxTraceEventBuffer->uiTail + uiFreeSize ) % pxTraceEventBuffer->uiSize;
return TRC_SUCCESS;
}
traceResult xTraceEventBufferPush( TraceEventBuffer_t * pxTraceEventBuffer,
void * pxData,
uint32_t uiDataSize,
int32_t * piBytesWritten )
{
uint32_t uiBufferSize;
/* This should never fail */
TRC_ASSERT( pxTraceEventBuffer != 0 );
/* This should never fail */
TRC_ASSERT( pxData != 0 );
uiBufferSize = pxTraceEventBuffer->uiSize;
/* Check if the data size is larger than the buffer */
/* This should never fail */
TRC_ASSERT( uiDataSize <= uiBufferSize );
/* Check byte alignment */
/* This should never fail */
TRC_ASSERT( ( uiDataSize % 4 ) == 0 );
/* Ensure bytes written start at 0 */
/* This should never fail */
TRC_ASSERT( piBytesWritten != 0 );
*piBytesWritten = 0;
/* This should never fail */
TRC_ASSERT_ALWAYS_EVALUATE( xTraceTimestampGetWraparounds( &pxTraceEventBuffer->uiTimerWraparounds ) == TRC_SUCCESS );
/* In ring buffer mode we cannot provide lock free access since the producer modified
* the head and tail variables in the same call. This option is only safe when used
* with an internal buffer (streaming snapshot) which no consumer accesses.
*/
switch( pxTraceEventBuffer->uiOptions )
{
case TRC_EVENT_BUFFER_OPTION_OVERWRITE:
{
uint32_t uiHead = pxTraceEventBuffer->uiHead;
/* If there isn't enough space in the buffer pop events until there is */
while( pxTraceEventBuffer->uiFree < uiDataSize )
{
prvTraceEventBufferPop( pxTraceEventBuffer );
}
/* Copy data */
if( ( uiBufferSize - uiHead ) > uiDataSize )
{
TRC_MEMCPY( &pxTraceEventBuffer->puiBuffer[ uiHead ], pxData, uiDataSize );
}
else
{
TRC_MEMCPY( &pxTraceEventBuffer->puiBuffer[ uiHead ], pxData, uiBufferSize - uiHead );
TRC_MEMCPY( pxTraceEventBuffer->puiBuffer,
( void * ) ( &( ( uint8_t * ) pxData )[ ( uiBufferSize - uiHead ) ] ),
uiDataSize - ( uiBufferSize - uiHead ) );
}
pxTraceEventBuffer->uiFree -= uiDataSize;
pxTraceEventBuffer->uiHead = ( uiHead + uiDataSize ) % uiBufferSize;
*piBytesWritten = uiDataSize;
break;
}
case TRC_EVENT_BUFFER_OPTION_SKIP:
{
/* Since a consumer could potentially update tail (free) during the procedure
* we have to save it here to avoid problems with the push algorithm.
*/
uint32_t uiHead = pxTraceEventBuffer->uiHead;
uint32_t uiTail = pxTraceEventBuffer->uiTail;
if( uiHead >= uiTail )
{
uint32_t uiFreeSpace = ( uiBufferSize - uiHead - sizeof( uint32_t ) ) + uiTail;
if( uiFreeSpace < uiDataSize )
{
*piBytesWritten = 0;
return TRC_SUCCESS;
}
/* Copy data */
if( ( uiBufferSize - uiHead ) > uiDataSize )
{
TRC_MEMCPY( &pxTraceEventBuffer->puiBuffer[ pxTraceEventBuffer->uiHead ], pxData, uiDataSize );
}
else
{
TRC_MEMCPY( &pxTraceEventBuffer->puiBuffer[ uiHead ], pxData, uiBufferSize - uiHead );
TRC_MEMCPY( pxTraceEventBuffer->puiBuffer,
( void * ) ( &( ( uint8_t * ) pxData )[ ( uiBufferSize - uiHead ) ] ),
uiDataSize - ( uiBufferSize - uiHead ) );
}
pxTraceEventBuffer->uiHead = ( uiHead + uiDataSize ) % uiBufferSize;
}
else
{
uint32_t uiFreeSpace = uiTail - uiHead - sizeof( uint32_t );
if( uiFreeSpace < uiDataSize )
{
*piBytesWritten = 0;
return TRC_SUCCESS;
}
/* Copy data */
TRC_MEMCPY( &pxTraceEventBuffer->puiBuffer[ pxTraceEventBuffer->uiHead ], pxData, uiDataSize );
pxTraceEventBuffer->uiHead = ( uiHead + uiDataSize );
}
*piBytesWritten = uiDataSize;
break;
}
default:
return TRC_FAIL;
}
return TRC_SUCCESS;
}
traceResult xTraceEventBufferTransfer( TraceEventBuffer_t * pxTraceEventBuffer,
int32_t * piBytesWritten )
{
int32_t iBytesWritten = 0;
int32_t iSumBytesWritten = 0;
uint32_t uiHead;
uint32_t uiTail;
/* This should never fail */
TRC_ASSERT( pxTraceEventBuffer != 0 );
/* This should never fail */
TRC_ASSERT( piBytesWritten != 0 );
uiHead = pxTraceEventBuffer->uiHead;
uiTail = pxTraceEventBuffer->uiTail;
/* Check if core event buffer is empty */
if( uiHead == uiTail )
{
return TRC_SUCCESS;
}
/* Check if we can do a direct write or if we have to handle wrapping */
if( uiHead > uiTail )
{
xTraceStreamPortWriteData( &pxTraceEventBuffer->puiBuffer[ uiTail ], ( uiHead - uiTail ), &iBytesWritten );
pxTraceEventBuffer->uiTail = uiHead;
}
else
{
xTraceStreamPortWriteData( &pxTraceEventBuffer->puiBuffer[ uiTail ], ( pxTraceEventBuffer->uiSize - uiTail ), &iBytesWritten );
iSumBytesWritten += iBytesWritten;
xTraceStreamPortWriteData( pxTraceEventBuffer->puiBuffer, uiHead, &iBytesWritten );
pxTraceEventBuffer->uiTail = uiHead;
}
iSumBytesWritten += iBytesWritten;
*piBytesWritten = iSumBytesWritten;
return TRC_SUCCESS;
}
traceResult xTraceEventBufferClear( TraceEventBuffer_t * pxTraceEventBuffer )
{
/* This should never fail */
TRC_ASSERT( pxTraceEventBuffer != 0 );
pxTraceEventBuffer->uiHead = 0;
pxTraceEventBuffer->uiTail = 0;
pxTraceEventBuffer->uiFree = pxTraceEventBuffer->uiSize;
return TRC_SUCCESS;
}
#endif /* (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) */
#endif /* (TRC_USE_TRACEALYZER_RECORDER == 1) */

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save