Percepio Trace Recorder v4.6.0 (#789)

* * Percepio Trace Recorder v4.6.0

* Add space between inclusion of header and comment

* Fix broken posix build - part 1

* Add percepio timer implementation

* Remove delted trace recorder header file

* Fix Networking demo  build

* Fix CLI demo

* Fix visual studio version number

* Fix core header check

* Fix more core checks

* Fix last of core checks

Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com>
Co-authored-by: Alfred Gedeon <alfred2g@hotmail.com>
This commit is contained in:
Erik Tamlin 2022-11-03 21:58:38 +01:00 committed by GitHub
parent aa316fc1b4
commit c568ba8c44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
143 changed files with 23823 additions and 16781 deletions

View file

@ -268,9 +268,12 @@ FREERTOS_IGNORED_PATTERNS = [
r'.*/trcConfig\.h.*', r'.*/trcConfig\.h.*',
r'.*/trcConfig\.c.*', r'.*/trcConfig\.c.*',
r'.*/trcSnapshotConfig\.h.*', r'.*/trcSnapshotConfig\.h.*',
r'.*/trcKernelPortConfig\.h.*',
r'.*/MicroZed_hw_platform.*', r'.*/MicroZed_hw_platform.*',
r'.*/ThirdParty/.*', r'.*/ThirdParty/.*',
r'FreeRTOS\-Plus/Demo/Common/WinPCap/.*' r'FreeRTOS\-Plus/Demo/Common/WinPCap/.*',
r'FreeRTOS\-Plus/Source/FreeRTOS-Plus-Trace/.*',
r'FreeRTOS-Plus/Demo/FreeRTOS_Plus_CLI_with_Trace_Windows_Simulator/Trace_Recorder_Configuration/.*'
] ]
FREERTOS_IGNORED_FILES = [ FREERTOS_IGNORED_FILES = [

View file

@ -1,6 +1,6 @@
/* /*
* FreeRTOS V202112.00 * FreeRTOS V202112.00
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@ -20,7 +20,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* https://www.FreeRTOS.org * https://www.FreeRTOS.org
* https://aws.amazon.com/freertos * https://github.com/FreeRTOS
* *
*/ */
@ -335,7 +335,9 @@ BaseType_t lParameterStringLength;
/* Start or restart the trace. */ /* Start or restart the trace. */
vTraceStop(); vTraceStop();
vTraceClear(); vTraceClear();
uiTraceStart();
vTraceEnable( TRC_START );
traceSTART();
sprintf( pcWriteBuffer, "Trace recording (re)started.\r\n" ); sprintf( pcWriteBuffer, "Trace recording (re)started.\r\n" );
} }

View file

@ -19,4 +19,7 @@ Global
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F78FDCED-CBDF-4B81-B6E3-78A0A2989E82}
EndGlobalSection
EndGlobal EndGlobal

View file

@ -52,8 +52,6 @@
extern "C" { extern "C" {
#endif #endif
#include "trcPortDefines.h"
/****************************************************************************** /******************************************************************************
* Include of processor header file * Include of processor header file
* *
@ -99,32 +97,6 @@ extern "C" {
******************************************************************************/ ******************************************************************************/
#define TRC_CFG_RECORDER_MODE TRC_RECORDER_MODE_SNAPSHOT #define TRC_CFG_RECORDER_MODE TRC_RECORDER_MODE_SNAPSHOT
/******************************************************************************
* TRC_CFG_FREERTOS_VERSION
*
* 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 or later
*****************************************************************************/
#define TRC_CFG_FREERTOS_VERSION TRC_FREERTOS_VERSION_10_4_0
/******************************************************************************* /*******************************************************************************
* TRC_CFG_SCHEDULING_ONLY * TRC_CFG_SCHEDULING_ONLY
* *
@ -224,17 +196,6 @@ extern "C" {
*****************************************************************************/ *****************************************************************************/
#define TRC_CFG_INCLUDE_OSTICK_EVENTS 1 #define TRC_CFG_INCLUDE_OSTICK_EVENTS 1
/*****************************************************************************
* TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS
*
* 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 0
/***************************************************************************** /*****************************************************************************
* TRC_CFG_INCLUDE_TIMER_EVENTS * TRC_CFG_INCLUDE_TIMER_EVENTS
* *
@ -258,18 +219,6 @@ extern "C" {
*****************************************************************************/ *****************************************************************************/
#define TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS 1 #define TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS 1
/*******************************************************************************
* Configuration Macro: TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS
*
* 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 0
/****************************************************************************** /******************************************************************************
* TRC_CFG_ENABLE_STACK_MONITOR * TRC_CFG_ENABLE_STACK_MONITOR
* *
@ -387,15 +336,19 @@ extern "C" {
*****************************************************************************/ *****************************************************************************/
#define TRC_CFG_MAX_ISR_NESTING 8 #define TRC_CFG_MAX_ISR_NESTING 8
/****************************************************************************** /**
* TRC_CFG_ACKNOWLEDGE_QUEUE_SET_SEND * @def TRC_CFG_RECORDER_DATA_ATTRIBUTE
* * @brief When setting TRC_CFG_RECORDER_DATA_INIT to 0, you might also need to make
* When using FreeRTOS v10.3.0 or v10.3.1, please make sure that the trace * sure certain recorder data is placed in a specific RAM section to avoid being
* point in prvNotifyQueueSetContainer() in queue.c is renamed from * zeroed out after initialization. Define TRC_CFG_RECORDER_DATA_ATTRIBUTE as
* traceQUEUE_SEND to traceQUEUE_SET_SEND in order to tell them apart from * that attribute.
* other traceQUEUE_SEND trace points. Then set this to TRC_ACKNOWLEDGED. *
*****************************************************************************/ * Example:
#define TRC_CFG_ACKNOWLEDGE_QUEUE_SET_SEND TRC_ACKNOWLEDGED /* 0 or TRC_ACKNOWLEDGED */ * #define TRC_CFG_RECORDER_DATA_ATTRIBUTE __attribute__((section(".bss.trace_recorder_data")))
*
* Default value is empty.
*/
#define TRC_CFG_RECORDER_DATA_ATTRIBUTE
/* Specific configuration, depending on Streaming/Snapshot mode */ /* Specific configuration, depending on Streaming/Snapshot mode */
#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT) #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT)

View file

@ -0,0 +1,116 @@
/*
* 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_SNAPSHOT
/**
* @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 0
/**
* @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 0
/**
* @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 */

View file

@ -0,0 +1,69 @@
/*
* 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 */

View file

@ -84,39 +84,6 @@
******************************************************************************/ ******************************************************************************/
#define TRC_CFG_EVENT_BUFFER_SIZE 15000 #define TRC_CFG_EVENT_BUFFER_SIZE 15000
/*******************************************************************************
* TRC_CFG_NTASK, TRC_CFG_NISR, TRC_CFG_NQUEUE, TRC_CFG_NSEMAPHORE...
*
* 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
/****************************************************************************** /******************************************************************************
* TRC_CFG_INCLUDE_FLOAT_SUPPORT * TRC_CFG_INCLUDE_FLOAT_SUPPORT
* *

View file

@ -130,10 +130,12 @@
</Bscmake> </Bscmake>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\..\FreeRTOS\Source\event_groups.c" />
<ClCompile Include="..\..\..\FreeRTOS\Source\list.c" /> <ClCompile Include="..\..\..\FreeRTOS\Source\list.c" />
<ClCompile Include="..\..\..\FreeRTOS\Source\portable\MemMang\heap_3.c" /> <ClCompile Include="..\..\..\FreeRTOS\Source\portable\MemMang\heap_3.c" />
<ClCompile Include="..\..\..\FreeRTOS\Source\portable\MSVC-MingW\port.c" /> <ClCompile Include="..\..\..\FreeRTOS\Source\portable\MSVC-MingW\port.c" />
<ClCompile Include="..\..\..\FreeRTOS\Source\queue.c" /> <ClCompile Include="..\..\..\FreeRTOS\Source\queue.c" />
<ClCompile Include="..\..\..\FreeRTOS\Source\stream_buffer.c" />
<ClCompile Include="..\..\..\FreeRTOS\Source\tasks.c" /> <ClCompile Include="..\..\..\FreeRTOS\Source\tasks.c" />
<ClCompile Include="..\..\..\FreeRTOS\Source\timers.c" /> <ClCompile Include="..\..\..\FreeRTOS\Source\timers.c" />
<ClCompile Include="..\..\Source\FreeRTOS-Plus-CLI\FreeRTOS_CLI.c" /> <ClCompile Include="..\..\Source\FreeRTOS-Plus-CLI\FreeRTOS_CLI.c" />

View file

@ -80,6 +80,12 @@
<ClCompile Include="..\..\Source\FreeRTOS-Plus-Trace\trcStreamingRecorder.c"> <ClCompile Include="..\..\Source\FreeRTOS-Plus-Trace\trcStreamingRecorder.c">
<Filter>FreeRTOS+\FreeRTOS+Trace</Filter> <Filter>FreeRTOS+\FreeRTOS+Trace</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\FreeRTOS\Source\event_groups.c">
<Filter>FreeRTOS\Source</Filter>
</ClCompile>
<ClCompile Include="..\..\..\FreeRTOS\Source\stream_buffer.c">
<Filter>FreeRTOS\Source</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="FreeRTOSConfig.h"> <ClInclude Include="FreeRTOSConfig.h">

View file

@ -1,6 +1,6 @@
/* /*
* FreeRTOS V202112.00 * FreeRTOS V202112.00
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@ -20,7 +20,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* https://www.FreeRTOS.org * https://www.FreeRTOS.org
* https://aws.amazon.com/freertos * https://github.com/FreeRTOS
* *
*/ */
@ -242,4 +242,19 @@ const unsigned long ulLongSleep = 1000UL;
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
static uint32_t ulEntryTime = 0;
void vTraceTimerReset( void )
{
ulEntryTime = xTaskGetTickCount();
}
uint32_t uiTraceTimerGetFrequency( void )
{
return configTICK_RATE_HZ;
}
uint32_t uiTraceTimerGetValue( void )
{
return ( xTaskGetTickCount() - ulEntryTime );
}

View file

@ -18,6 +18,7 @@ INCLUDE_DIRS += -I${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/Include
INCLUDE_DIRS += -I${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/linux/ INCLUDE_DIRS += -I${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/linux/
INCLUDE_DIRS += -I${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-TCP/include/ INCLUDE_DIRS += -I${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-TCP/include/
INCLUDE_DIRS += -I${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-TCP/portable/Compiler/GCC/ INCLUDE_DIRS += -I${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-TCP/portable/Compiler/GCC/
INCLUDE_DIRS += -I${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/config
SOURCE_FILES := $(wildcard *.c) SOURCE_FILES := $(wildcard *.c)
SOURCE_FILES += $(wildcard ${FREERTOS_DIR}/Source/*.c) SOURCE_FILES += $(wildcard ${FREERTOS_DIR}/Source/*.c)
@ -70,11 +71,10 @@ SOURCE_FILES += ${FREERTOS_DIR}/Demo/Common/Minimal/TimerDemo.c
# Trace library. # Trace library.
SOURCE_FILES += ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/trcKernelPort.c SOURCE_FILES += ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/trcKernelPort.c
SOURCE_FILES += ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/trcSnapshotRecorder.c SOURCE_FILES += ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/trcSnapshotRecorder.c
SOURCE_FILES += ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/trcStreamingRecorder.c
SOURCE_FILES += ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/streamports/File/trcStreamingPort.c
CFLAGS := -ggdb3 -O0
CPPFLAGS := -DprojCOVERAGE_TEST=0 -D_DEFAULT_SOURCE -D_WINDOWS_ -DTRACE_ON_ENTER=0
CFLAGS := -ggdb3 -O0 -DprojCOVERAGE_TEST=0 -D_WINDOWS_
LDFLAGS := -ggdb3 -O0 -pthread -lpcap LDFLAGS := -ggdb3 -O0 -pthread -lpcap
OBJ_FILES = $(SOURCE_FILES:%.c=$(BUILD_DIR)/%.o) OBJ_FILES = $(SOURCE_FILES:%.c=$(BUILD_DIR)/%.o)
@ -85,23 +85,16 @@ ${BIN} : $(BUILD_DIR)/$(BIN)
${BUILD_DIR}/${BIN} : ${OBJ_FILES} ${BUILD_DIR}/${BIN} : ${OBJ_FILES}
-mkdir -p ${@D} -mkdir -p ${@D}
$(CC) $^ $(CFLAGS) $(INCLUDE_DIRS) ${LDFLAGS} -o $@ $(CC) $^ ${LDFLAGS} -o $@
-include ${DEP_FILE} -include ${DEP_FILE}
${BUILD_DIR}/%.o : %.c ${BUILD_DIR}/%.o : %.c Makefile
-mkdir -p $(@D) -mkdir -p $(@D)
$(CC) $(CFLAGS) ${INCLUDE_DIRS} -MMD -c $< -o $@ $(CC) $(CFLAGS) ${CPPFLAGS} ${INCLUDE_DIRS} -MMD -c $< -o $@
.PHONY: clean .PHONY: clean
clean: clean:
-rm -rf $(BUILD_DIR) -rm -rf $(BUILD_DIR)

View file

@ -51,6 +51,8 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <stdarg.h> #include <stdarg.h>
#include <time.h>
#include <errno.h>
/* FreeRTOS kernel includes. */ /* FreeRTOS kernel includes. */
#include "FreeRTOS.h" #include "FreeRTOS.h"
@ -59,6 +61,8 @@
/* Local includes. */ /* Local includes. */
#include "console.h" #include "console.h"
#include <trcRecorder.h>
#define ECHO_CLIENT_DEMO 0 #define ECHO_CLIENT_DEMO 0
#define mainSELECTED_APPLICATION ECHO_CLIENT_DEMO #define mainSELECTED_APPLICATION ECHO_CLIENT_DEMO
@ -103,6 +107,10 @@ StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
/* Notes if the trace is running or not. */ /* Notes if the trace is running or not. */
static BaseType_t xTraceRunning = pdTRUE; static BaseType_t xTraceRunning = pdTRUE;
static clockid_t cid = CLOCK_THREAD_CPUTIME_ID;
static uint32_t frequency;
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
int main( void ) int main( void )
@ -118,7 +126,7 @@ int main( void )
configASSERT() is called. */ configASSERT() is called. */
printf( "\r\nTrace started.\r\nThe trace will be dumped to disk if a call to configASSERT() fails.\r\n" ); printf( "\r\nTrace started.\r\nThe trace will be dumped to disk if a call to configASSERT() fails.\r\n" );
printf( "\r\nThe trace will be dumped to disk if Enter is hit.\r\n" ); printf( "\r\nThe trace will be dumped to disk if Enter is hit.\r\n" );
uiTraceStart(); traceSTART();
} }
#endif #endif
@ -284,6 +292,7 @@ static void prvSaveTraceFile( void )
#if ( projCOVERAGE_TEST != 1 ) #if ( projCOVERAGE_TEST != 1 )
{ {
FILE * pxOutputFile; FILE * pxOutputFile;
extern RecorderDataType * RecorderDataPtr;
vTraceStop(); vTraceStop();
@ -355,3 +364,57 @@ the stack and so not exists after this function exits. */
configMINIMAL_STACK_SIZE is specified in words, not bytes. */ configMINIMAL_STACK_SIZE is specified in words, not bytes. */
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
} }
void vTraceTimerReset( void )
{
int xRet;
struct timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 0;
xRet = clock_settime( cid, &ts );
if( xRet != 0 )
{
printf( "Could not reset time: %s\n", strerror( errno ) );
}
}
uint32_t uiTraceTimerGetFrequency( void )
{
struct timespec res;
int xRet;
res.tv_nsec = 0;
res.tv_sec = 0;
xRet = clock_getres( cid, &res );
if( xRet == 0 )
{
// calculate frequency from timer definition
frequency = (uint64_t) 1000000000 / res.tv_nsec;
}
else
{
printf( "Could not get clock frequency: %s\n", strerror( errno ) );
}
return frequency;
}
uint32_t uiTraceTimerGetValue( void )
{
int xRet;
struct timespec tp;
uint32_t result = 0;
xRet = clock_gettime( cid, &tp );
if( xRet == 0 )
{
result = tp.tv_nsec / frequency;
result += (tp.tv_sec * 1000000000) / frequency;
}
else
{
printf( "Could not get time: %s\n", strerror( errno ) );
}
return result;
}

View file

@ -52,8 +52,6 @@
extern "C" { extern "C" {
#endif #endif
#include "trcPortDefines.h"
/****************************************************************************** /******************************************************************************
* Include of processor header file * Include of processor header file
* *
@ -98,31 +96,6 @@ extern "C" {
* 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_SNAPSHOT
/******************************************************************************
* TRC_CFG_FREERTOS_VERSION
*
* 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 or later
*****************************************************************************/
#define TRC_CFG_FREERTOS_VERSION TRC_FREERTOS_VERSION_10_4_0
/******************************************************************************* /*******************************************************************************
* TRC_CFG_SCHEDULING_ONLY * TRC_CFG_SCHEDULING_ONLY
@ -295,6 +268,14 @@ extern "C" {
*****************************************************************************/ *****************************************************************************/
#define TRC_CFG_MAX_ISR_NESTING 8 #define TRC_CFG_MAX_ISR_NESTING 8
#define TRC_CFG_CTRL_TASK_STACK_SIZE ( 1024 )
#define TRC_CFG_CTRL_TASK_PRIORITY 1
#define TRC_CFG_CTRL_TASK_DELAY 2
#define TRC_CFG_RECORDER_DATA_ATTRIBUTE
/* Specific configuration, depending on Streaming/Snapshot mode */ /* Specific configuration, depending on Streaming/Snapshot mode */
#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT) #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT)
#include "trcSnapshotConfig.h" #include "trcSnapshotConfig.h"

View file

@ -0,0 +1,116 @@
/*
* 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_SNAPSHOT
/**
* @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 */

View file

@ -84,39 +84,6 @@
******************************************************************************/ ******************************************************************************/
#define TRC_CFG_EVENT_BUFFER_SIZE 32000 #define TRC_CFG_EVENT_BUFFER_SIZE 32000
/*******************************************************************************
* TRC_CFG_NTASK, TRC_CFG_NISR, TRC_CFG_NQUEUE, TRC_CFG_NSEMAPHORE...
*
* 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 100
#define TRC_CFG_NMESSAGEBUFFER 100
/****************************************************************************** /******************************************************************************
* TRC_CFG_INCLUDE_FLOAT_SUPPORT * TRC_CFG_INCLUDE_FLOAT_SUPPORT
* *

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

View file

@ -1,8 +1,9 @@
/******************************************************************************* /*
* Trace Recorder Library for Tracealyzer v4.4.0 * Trace Recorder for Tracealyzer v4.6.0
* Percepio AB, www.percepio.com * Copyright 2021 Percepio AB
* www.percepio.com
* *
* aws_secure_socket.tzext.h * SPDX-License-Identifier: Apache-2.0
* *
* An example of a Tracealyzer extension for tracing API calls, in this case * An example of a Tracealyzer extension for tracing API calls, in this case
* for tracing selected functions in Amazon FreeRTOS/aws_secure_sockets. * for tracing selected functions in Amazon FreeRTOS/aws_secure_sockets.
@ -21,42 +22,7 @@
* See the below comments for details about these definitions. Note that you * See the below comments for details about these definitions. Note that you
* also need a matching .xml file for Tracealyzer to understand the data. * also need a matching .xml file for Tracealyzer to understand the data.
* See trcExtensions.h for further information. * See trcExtensions.h for further information.
* */
* Terms of Use
* This file is part of the trace recorder library (RECORDER), which is the
* intellectual property of Percepio AB (PERCEPIO) and provided under a
* license as follows.
* The RECORDER may be used free of charge for the purpose of recording data
* intended for analysis in PERCEPIO products. It may not be used or modified
* for other purposes without explicit permission from PERCEPIO.
* You may distribute the RECORDER in its original source code form, assuming
* this text (terms of use, disclaimer, copyright notice) is unchanged. You are
* allowed to distribute the RECORDER with minor modifications intended for
* configuration or porting of the RECORDER, e.g., to allow using it on a
* specific processor, processor family or with a specific communication
* interface. Any such modifications should be documented directly below
* this comment block.
*
* Disclaimer
* The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty
* as to its use or performance. PERCEPIO does not and cannot warrant the
* performance or results you may obtain by using the RECORDER or documentation.
* PERCEPIO make no warranties, express or implied, as to noninfringement of
* third party rights, merchantability, or fitness for any particular purpose.
* In no event will PERCEPIO, its technology partners, or distributors be liable
* to you for any consequential, incidental or special damages, including any
* lost profits or lost savings, even if a representative of PERCEPIO has been
* advised of the possibility of such damages, or for any claim by any third
* party. Some jurisdictions do not allow the exclusion or limitation of
* incidental, consequential or special damages, or the exclusion of implied
* warranties or limitations on how long an implied warranty may last, so the
* above limitations may not apply to you.
*
* Tabs are used for indent in this file (1 tab = 4 spaces)
*
* Copyright Percepio AB, 2018.
* www.percepio.com
******************************************************************************/
#ifndef _AWS_SECURE_SOCKETS_TZEXT_H #ifndef _AWS_SECURE_SOCKETS_TZEXT_H
#define _AWS_SECURE_SOCKETS_TZEXT_H #define _AWS_SECURE_SOCKETS_TZEXT_H
@ -126,7 +92,7 @@
/***** Trace Wrappers *****/ /***** Trace Wrappers *****/
#include "aws_secure_sockets.h" /* Including the original header file, so that custom data types are understood. */ #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 ) static inline int32_t SOCKETS_Connect__trace( Socket_t xSocket, SocketsSockaddr_t * pxAddress, Socklen_t xAddressLength )
{ {

View file

@ -1,8 +1,9 @@
/******************************************************************************* /*
* Trace Recorder Library for Tracealyzer v4.4.0 * Trace Recorder for Tracealyzer v4.6.0
* Percepio AB, www.percepio.com * Copyright 2021 Percepio AB
* www.percepio.com
* *
* aws_secure_socket.tzext.h * SPDX-License-Identifier: Apache-2.0
* *
* An example of a Tracealyzer extension for tracing API calls, in this case * An example of a Tracealyzer extension for tracing API calls, in this case
* for tracing selected functions in Amazon FreeRTOS/aws_wifi. * for tracing selected functions in Amazon FreeRTOS/aws_wifi.
@ -21,42 +22,7 @@
* See the below comments for details about these definitions. Note that you * See the below comments for details about these definitions. Note that you
* also need a matching .xml file for Tracealyzer to understand the data. * also need a matching .xml file for Tracealyzer to understand the data.
* See trcExtensions.h for further information. * See trcExtensions.h for further information.
* */
* Terms of Use
* This file is part of the trace recorder library (RECORDER), which is the
* intellectual property of Percepio AB (PERCEPIO) and provided under a
* license as follows.
* The RECORDER may be used free of charge for the purpose of recording data
* intended for analysis in PERCEPIO products. It may not be used or modified
* for other purposes without explicit permission from PERCEPIO.
* You may distribute the RECORDER in its original source code form, assuming
* this text (terms of use, disclaimer, copyright notice) is unchanged. You are
* allowed to distribute the RECORDER with minor modifications intended for
* configuration or porting of the RECORDER, e.g., to allow using it on a
* specific processor, processor family or with a specific communication
* interface. Any such modifications should be documented directly below
* this comment block.
*
* Disclaimer
* The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty
* as to its use or performance. PERCEPIO does not and cannot warrant the
* performance or results you may obtain by using the RECORDER or documentation.
* PERCEPIO make no warranties, express or implied, as to noninfringement of
* third party rights, merchantability, or fitness for any particular purpose.
* In no event will PERCEPIO, its technology partners, or distributors be liable
* to you for any consequential, incidental or special damages, including any
* lost profits or lost savings, even if a representative of PERCEPIO has been
* advised of the possibility of such damages, or for any claim by any third
* party. Some jurisdictions do not allow the exclusion or limitation of
* incidental, consequential or special damages, or the exclusion of implied
* warranties or limitations on how long an implied warranty may last, so the
* above limitations may not apply to you.
*
* Tabs are used for indent in this file (1 tab = 4 spaces)
*
* Copyright Percepio AB, 2018.
* www.percepio.com
******************************************************************************/
#ifndef _AWS_WIFI_TZEXT_H #ifndef _AWS_WIFI_TZEXT_H
#define _AWS_WIFI_TZEXT_H #define _AWS_WIFI_TZEXT_H
@ -125,7 +91,7 @@
/***** Trace Wrappers *****/ /***** Trace Wrappers *****/
#include "aws_wifi.h" /* Including the original header file, so that custom data types are understood. */ #include <aws_wifi.h> /* Including the original header file, so that custom data types are understood. */
static inline WIFIReturnCode_t WIFI_On__trace( void ) static inline WIFIReturnCode_t WIFI_On__trace( void )
{ {

View file

@ -0,0 +1,143 @@
/*
* 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
#define TRC_ASSERT_EQUAL_SIZE(x, y)
#endif
#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 */

View file

@ -0,0 +1,154 @@
/*
* 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 */

View file

@ -1,49 +1,18 @@
/******************************************************************************* /*
* Trace Recorder Library for Tracealyzer v4.4.0 * Trace Recorder for Tracealyzer v4.6.0
* Percepio AB, www.percepio.com * Copyright 2021 Percepio AB
* www.percepio.com
* *
* trcPortDefines.h * SPDX-License-Identifier: Apache-2.0
* *
* Some common defines for the trace recorder. * Some common defines for the trace recorder.
* */
* Terms of Use
* This file is part of the trace recorder library (RECORDER), which is the
* intellectual property of Percepio AB (PERCEPIO) and provided under a
* license as follows.
* The RECORDER may be used free of charge for the purpose of recording data
* intended for analysis in PERCEPIO products. It may not be used or modified
* for other purposes without explicit permission from PERCEPIO.
* You may distribute the RECORDER in its original source code form, assuming
* this text (terms of use, disclaimer, copyright notice) is unchanged. You are
* allowed to distribute the RECORDER with minor modifications intended for
* configuration or porting of the RECORDER, e.g., to allow using it on a
* specific processor, processor family or with a specific communication
* interface. Any such modifications should be documented directly below
* this comment block.
*
* Disclaimer
* The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty
* as to its use or performance. PERCEPIO does not and cannot warrant the
* performance or results you may obtain by using the RECORDER or documentation.
* PERCEPIO make no warranties, express or implied, as to noninfringement of
* third party rights, merchantability, or fitness for any particular purpose.
* In no event will PERCEPIO, its technology partners, or distributors be liable
* to you for any consequential, incidental or special damages, including any
* lost profits or lost savings, even if a representative of PERCEPIO has been
* advised of the possibility of such damages, or for any claim by any third
* party. Some jurisdictions do not allow the exclusion or limitation of
* incidental, consequential or special damages, or the exclusion of implied
* warranties or limitations on how long an implied warranty may last, so the
* above limitations may not apply to you.
*
* Tabs are used for indent in this file (1 tab = 4 spaces)
*
* Copyright Percepio AB, 2018.
* www.percepio.com
******************************************************************************/
#ifndef TRC_PORTDEFINES_H #ifndef TRC_DEFINES_H
#define TRC_PORTDEFINES_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_INCR 1
#define TRC_FREE_RUNNING_32BIT_DECR 2 #define TRC_FREE_RUNNING_32BIT_DECR 2
@ -52,10 +21,16 @@
#define TRC_CUSTOM_TIMER_INCR 5 #define TRC_CUSTOM_TIMER_INCR 5
#define TRC_CUSTOM_TIMER_DECR 6 #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. */ /* Start options for vTraceEnable. */
#define TRC_INIT 0 #define TRC_START_FROM_HOST 0
#define TRC_START 1 #define TRC_START 1
#define TRC_START_AWAIT_HOST 2 #define TRC_START_AWAIT_HOST 2
#define TRC_ACKNOWLEDGED (0xABC99123)
/* Command codes for TzCtrl task */ /* Command codes for TzCtrl task */
#define CMD_SET_ACTIVE 1 /* Start (param1 = 1) or Stop (param1 = 0) */ #define CMD_SET_ACTIVE 1 /* Start (param1 = 1) or Stop (param1 = 0) */
@ -66,10 +41,71 @@
#define TRC_RECORDER_MODE_SNAPSHOT 0 #define TRC_RECORDER_MODE_SNAPSHOT 0
#define TRC_RECORDER_MODE_STREAMING 1 #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_STATIC (0x00)
#define TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC (0x01) #define TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC (0x01)
#define TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM (0x02) #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 */ /* Filter Groups */
#define FilterGroup0 (uint16_t)0x0001 #define FilterGroup0 (uint16_t)0x0001
#define FilterGroup1 (uint16_t)0x0002 #define FilterGroup1 (uint16_t)0x0002
@ -135,4 +171,12 @@
#define TRC_HARDWARE_PORT_ARM_CORTEX_A9 16 /* Yes Any */ #define TRC_HARDWARE_PORT_ARM_CORTEX_A9 16 /* Yes Any */
#define TRC_HARDWARE_PORT_POWERPC_Z4 17 /* No FreeRTOS */ #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_Altera_NiosII 18 /* Yes Any (Tested with FreeRTOS) */
#endif /*TRC_PORTDEFINES_H*/ #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 */

View file

@ -0,0 +1,145 @@
/*
* 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 */

View file

@ -0,0 +1,258 @@
/*
* 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
#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 */

View file

@ -0,0 +1,99 @@
/*
* 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*/

View file

@ -0,0 +1,615 @@
/*
* 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 */

View file

@ -0,0 +1,132 @@
/*
* 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 (mutal 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 transfered 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 */

View file

@ -0,0 +1,93 @@
/*
* 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 */

View file

@ -1,422 +0,0 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcExtensions.h
*
* The extension interface of the recorder library, allowing for tracing
* function calls to any API without modifications. All that is needed is a
* single #include line in the .c files calling the API.
*
* This can be used to provide more detailed traces, including calls to e.g.
* middleware, drivers or important APIs in your application code. This can be
* applied selectively to specified functions and may include selected
* parameters as well as the return value.
*
* Unlike the "User Event" concept, an extension is intended for systematic use
* and can benefit from all powerful features in Tracealyzer via host-side XML
* files that configure how Tracealyzer should interpret each event.
*
* Extensions are self-contained and easy to integrate, which makes them
* convenient for distribution. Software vendors can thus develop such
* extensions and provide trace support for their users.
*
* An extension consists of two files:
*
* - An extension header file (e.g. "api.tzext.h") - this defines how to
* trace the API function calls.
*
* - An XML file for the Tracealyzer application (e.g. "api-v1.0.0.xml").
* This needs to match the tracing setup in your extension header file.
*
*
* USAGE
*
* This description assumes you already have the extension files for the APIs you
* like to trace. To include them, follow these steps:
*
* 1. Update trcExtensions.h with respect to:
*
* 1.1. TRC_CFG_EXTENSION_COUNT: The number of extensions to enable (max 4).
*
* 1.2. The name(s) of the extension header file(s) to include.
*
* 1.3. The Extension Prefix, i.e., the first part of the definition names
* used in each header file.
*
* 2. Add #include "trcExtensions.h" in all .c files calling the API:
*
* #include ...
* #include "api.h" // The API you like to trace
* #include ...
* #include "trcExtensions.h"
*
* We recommend to put this as the LAST #include statement.
*
* HOWEVER, don't include "trcExtensions.h" in the .c files containing the
* functions you intend to trace. The compiler will then complain about
* multiple definitions of the trace wrapper function.
*
* 3. Copy the extension XML file to the "Tracealyzer 4/cfg" folder.
* On Windows this is typically
*
* C:\Program Files\Percepio\Tracealyzer 4\cfg
*
*
* HOW IT WORKS
*
* By including "trcExtensions.h" in your .c files, the preprocessor will
* redefine all calls of the functions specified in the extension header file.
* Calls to those functions will now instead call the "trace wrapper functions"
* defined in the extension header. The trace wrapper functions then call the
* original function as well as the trace recorder library.
*
* call foo(a) ----> foo__trace(a) -----> foo(a)
* -----> trace recorder library
*
* Note that the trace wrapper function should have the same declaration as the
* original function (apart from the name) and also returns any return value
* back to the original caller. So functionally this is completely transparent.
*
* This works also for calls via function pointers, as the assignments of the
* function pointers will be affected, so the function pointers will point to
* the trace wrapper function.
*
* It even works when calling binary libraries, since only the calling code
* is modified, not the API itself.
*
* Extensions include a version code (Major.Minor.Patch), which is registered
* in the trace and also part of the XML file name. This way, Tracealyzer
* automatically finds the matching XML file, even if you open a old trace
* recorded using a earlier version of the extension (e.g. if the API has
* changed).
*
* LIMITATIONS
*
* The main limitation of this automatic approach is that it only allows for
* tracing call between different .c files. Moreover, you can't trace multiple
* APIs with calls between them. This since the calling file must include
* trcExtensions.h, while the called file must NOT include this.
*
* It is however possible to get around this limitation. You need to add
* #undef lines for each affected function to locally disable the redefinition,
* and modify each function call to instead call the trace wrapper function.
*
* #include "trcExtensions.h"
* #undef foo
* ...
* void foo(int a)
* {
* ...
* }
* ...
* foo__trace(a); // in another function - call foo and trace it
*
* These changes can remain in your code if you like, as the trace wrappers
* works even if the recorder is disabled.
*
* MAKING YOUR OWN EXTENSIONS
*
* Examples are found in the extensions directory. We recommend that you start
* by looking at aws_secure_sockets files (.h and .xml) that provides a basic
* example. The aws_wifi files provides a more advanced example.
* The header files include detailed documentation about how to design them,
*
* The XML files should have the same name as specified in the NAME property
* in the header file, followed by the version, i.e.
*
* <NAME>-v<VERSION_MAJOR>.<<VERSION_MINOR>.<VERSION_PATCH>.xml
*
* Documentation for the XML file format is not yet available, but is under
* development.
*
*
* Terms of Use
* This file is part of the trace recorder library (RECORDER), which is the
* intellectual property of Percepio AB (PERCEPIO) and provided under a
* license as follows.
* The RECORDER may be used free of charge for the purpose of recording data
* intended for analysis in PERCEPIO products. It may not be used or modified
* for other purposes without explicit permission from PERCEPIO.
* You may distribute the RECORDER in its original source code form, assuming
* this text (terms of use, disclaimer, copyright notice) is unchanged. You are
* allowed to distribute the RECORDER with minor modifications intended for
* configuration or porting of the RECORDER, e.g., to allow using it on a
* specific processor, processor family or with a specific communication
* interface. Any such modifications should be documented directly below
* this comment block.
*
* Disclaimer
* The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty
* as to its use or performance. PERCEPIO does not and cannot warrant the
* performance or results you may obtain by using the RECORDER or documentation.
* PERCEPIO make no warranties, express or implied, as to noninfringement of
* third party rights, merchantability, or fitness for any particular purpose.
* In no event will PERCEPIO, its technology partners, or distributors be liable
* to you for any consequential, incidental or special damages, including any
* lost profits or lost savings, even if a representative of PERCEPIO has been
* advised of the possibility of such damages, or for any claim by any third
* party. Some jurisdictions do not allow the exclusion or limitation of
* incidental, consequential or special damages, or the exclusion of implied
* warranties or limitations on how long an implied warranty may last, so the
* above limitations may not apply to you.
*
* Tabs are used for indent in this file (1 tab = 4 spaces)
*
* Copyright Percepio AB, 2018.
* www.percepio.com
******************************************************************************/
#ifndef TRCEXTENSIONS_H_
#define TRCEXTENSIONS_H_
#include "trcRecorder.h"
/******************************************************************************
* TRC_CFG_EXTENSION_COUNT
*
* Defines the number of extensions included in the trace. Maximum 4 extensions
* can be included.
*
* Default value is 0 (extension support disabled).
*
*****************************************************************************/
#define TRC_CFG_EXTENSION_COUNT 0
/******************************************************************************
* TRC_CFG_EXT_MAX_NAME_LEN
*
* Defines the maximum length of extension name(s), i.e. the <EXTENSION>_NAME
* macro(s) in trcExtensions.h.
*
* This value should will by rounded up to the nearest multiple of 4, and must
* not be zero. To disable extension support, see TRC_CFG_EXTENSION_COUNT.
*
* It is important that this setting is large enough so extension names are
* not truncated, otherwise the host-side Tracealyzer application won't be able
* to find the corresponding XML file.
*
* You may adjust this to reduce memory usage, or increase it to allow for
* longer extension names.
*
* Default value is 20.
*****************************************************************************/
#define TRC_CFG_EXT_MAX_NAME_LEN 20
/******************************************************************************
* TRC_EXTENSION_EVENTCODE_BASE
*
* The first event code used for the Extension system. This will be the first
* event code of the first extension, and other event codes are relative to
* this. This can be modified but this is normally not required.
*****************************************************************************/
#define TRC_EXTENSION_EVENTCODE_BASE 256
/*** Included Extensions ******************************************************
*
* Below you specify what extensions to include. For each
* extension you must define:
*
* - HEADER: The header file that defines the trace extension.
*
* - EXTENSION_PREFIX: The first part of the HEADER definition names.
*
*****************************************************************************/
#define TRC_EXT1_HEADER "aws_secure_sockets.tzext.h"
#define TRC_EXT1_PREFIX TRC_EXT_SOCKETS
#define TRC_EXT2_HEADER "aws_wifi.tzext.h"
#define TRC_EXT2_PREFIX TRC_EXT_WIFI
#define TRC_EXT3_HEADER "Here you specify the header file for Extensions 3."
#define TRC_EXT3_PREFIX NOT_DEFINED
#define TRC_EXT4_HEADER "Here you specify the header file for Extensions 4."
#define TRC_EXT4_PREFIX NOT_DEFINED
/*** Don't modify below ******************************************************/
#define ROUNDUP4(n) (4*((n+3)/4))
typedef struct{
uint16_t firstEventCode;
uint16_t lastEventCode;
uint16_t patchVersion;
uint8_t minorVersion;
uint8_t majorVersion;
char name[ROUNDUP4(TRC_CFG_EXT_MAX_NAME_LEN)];
} PSFExtensionEntryType;
typedef struct{
uint16_t extensionEntryCount;
uint16_t baseEventCode;
#if (TRC_CFG_EXTENSION_COUNT > 0)
uint8_t extensionEntryNameMaxLength;
uint8_t extensionEntrySize;
PSFExtensionEntryType extension[TRC_CFG_EXTENSION_COUNT];
#endif
} PSFExtensionInfoType;
extern PSFExtensionInfoType PSFExtensionInfo;
#define CAT(a, ...) PRIMITIVE_CAT(a, __VA_ARGS__)
#define PRIMITIVE_CAT(a, ...) a ## __VA_ARGS__
#define TRC_EXT_BASECODE (PSFExtensionInfo.extension[TRC_EXT_NUMBER-1].firstEventCode)
#if (TRC_CFG_EXTENSION_COUNT >= 1)
#ifdef TRC_EXT1_HEADER
#define TRC_EXT_NUMBER 1
#include TRC_EXT1_HEADER
#undef TRC_EXT_NUMBER
#endif
#endif
#if (TRC_CFG_EXTENSION_COUNT >= 2)
#ifdef TRC_EXT2_HEADER
#define TRC_EXT_NUMBER 2
#include TRC_EXT2_HEADER
#undef TRC_EXT_NUMBER
#endif
#endif
#if (TRC_CFG_EXTENSION_COUNT >= 3)
#ifdef TRC_EXT3_HEADER
#define TRC_EXT_NUMBER 3
#include TRC_EXT3_HEADER
#undef TRC_EXT_NUMBER
#endif
#endif
#if (TRC_CFG_EXTENSION_COUNT == 4)
#ifdef TRC_EXT3_HEADER
#define TRC_EXT_NUMBER 4
#include TRC_EXT4_HEADER
#undef TRC_EXT_NUMBER
#endif
#endif
#define TRC_EXT1_COUNT CAT(TRC_EXT1_PREFIX, _COUNT)
#define TRC_EXT2_COUNT CAT(TRC_EXT2_PREFIX, _COUNT)
#define TRC_EXT3_COUNT CAT(TRC_EXT3_PREFIX, _COUNT)
#define TRC_EXT4_COUNT CAT(TRC_EXT4_PREFIX, _COUNT)
#define TRC_EXT1_NAME CAT(TRC_EXT1_PREFIX, _NAME)
#define TRC_EXT2_NAME CAT(TRC_EXT2_PREFIX, _NAME)
#define TRC_EXT3_NAME CAT(TRC_EXT3_PREFIX, _NAME)
#define TRC_EXT4_NAME CAT(TRC_EXT4_PREFIX, _NAME)
#define TRC_EXT1_VERSION_MAJOR CAT(TRC_EXT1_PREFIX, _VERSION_MAJOR)
#define TRC_EXT2_VERSION_MAJOR CAT(TRC_EXT2_PREFIX, _VERSION_MAJOR)
#define TRC_EXT3_VERSION_MAJOR CAT(TRC_EXT3_PREFIX, _VERSION_MAJOR)
#define TRC_EXT4_VERSION_MAJOR CAT(TRC_EXT4_PREFIX, _VERSION_MAJOR)
#define TRC_EXT1_VERSION_MINOR CAT(TRC_EXT1_PREFIX, _VERSION_MINOR)
#define TRC_EXT2_VERSION_MINOR CAT(TRC_EXT2_PREFIX, _VERSION_MINOR)
#define TRC_EXT3_VERSION_MINOR CAT(TRC_EXT3_PREFIX, _VERSION_MINOR)
#define TRC_EXT4_VERSION_MINOR CAT(TRC_EXT4_PREFIX, _VERSION_MINOR)
#define TRC_EXT1_VERSION_PATCH CAT(TRC_EXT1_PREFIX, _VERSION_PATCH)
#define TRC_EXT2_VERSION_PATCH CAT(TRC_EXT2_PREFIX, _VERSION_PATCH)
#define TRC_EXT3_VERSION_PATCH CAT(TRC_EXT3_PREFIX, _VERSION_PATCH)
#define TRC_EXT4_VERSION_PATCH CAT(TRC_EXT4_PREFIX, _VERSION_PATCH)
#if ((TRC_CFG_EXTENSION_COUNT > 4) || (TRC_CFG_EXTENSION_COUNT < 0))
#error "TRC_CFG_EXTENSION_COUNT must be in range [0..4]"
#endif
#if (TRC_CFG_EXTENSION_COUNT == 0)
#define TRC_EXTENSIONS_DATA
#endif
#if (TRC_CFG_EXTENSION_COUNT == 1)
#define TRC_EXTENSIONS_DATA \
{ \
{ TRC_EXTENSION_EVENTCODE_BASE, \
TRC_EXTENSION_EVENTCODE_BASE + TRC_EXT1_COUNT-1, \
TRC_EXT1_VERSION_PATCH, \
TRC_EXT1_VERSION_MINOR, \
TRC_EXT1_VERSION_MAJOR, \
TRC_EXT1_NAME } \
}
#endif
#if (TRC_CFG_EXTENSION_COUNT == 2)
#define TRC_EXTENSIONS_DATA \
{ \
{ TRC_EXTENSION_EVENTCODE_BASE, \
TRC_EXTENSION_EVENTCODE_BASE + TRC_EXT1_COUNT-1, \
TRC_EXT1_VERSION_PATCH, \
TRC_EXT1_VERSION_MINOR, \
TRC_EXT1_VERSION_MAJOR, \
TRC_EXT1_NAME } \
,{ TRC_EXTENSION_EVENTCODE_BASE + TRC_EXT1_COUNT, \
TRC_EXTENSION_EVENTCODE_BASE + TRC_EXT1_COUNT + TRC_EXT2_COUNT-1, \
TRC_EXT2_VERSION_PATCH, \
TRC_EXT2_VERSION_MINOR, \
TRC_EXT2_VERSION_MAJOR, \
TRC_EXT2_NAME } \
}
#endif
#if (TRC_CFG_EXTENSION_COUNT == 3)
#define TRC_EXTENSIONS_DATA \
{ \
{ TRC_EXTENSION_EVENTCODE_BASE, \
TRC_EXTENSION_EVENTCODE_BASE + TRC_EXT1_COUNT-1, \
TRC_EXT1_VERSION_PATCH, \
TRC_EXT1_VERSION_MINOR, \
TRC_EXT1_VERSION_MAJOR, \
TRC_EXT1_NAME } \
,{ TRC_EXTENSION_EVENTCODE_BASE + TRC_EXT1_COUNT, \
TRC_EXTENSION_EVENTCODE_BASE + TRC_EXT1_COUNT + TRC_EXT2_COUNT-1, \
TRC_EXT2_VERSION_PATCH, \
TRC_EXT2_VERSION_MINOR, \
TRC_EXT2_VERSION_MAJOR, \
TRC_EXT2_NAME } \
,{ TRC_EXTENSION_EVENTCODE_BASE + TRC_EXT1_COUNT + TRC_EXT2_COUNT, \
TRC_EXTENSION_EVENTCODE_BASE + TRC_EXT1_COUNT + TRC_EXT2_COUNT + TRC_EXT3_COUNT - 1, \
TRC_EXT3_VERSION_PATCH, \
TRC_EXT3_VERSION_MINOR, \
TRC_EXT3_VERSION_MAJOR, \
TRC_EXT3_NAME } \
}
#endif
#if (TRC_CFG_EXTENSION_COUNT == 4)
#define TRC_EXTENSIONS_DATA \
{ \
{ TRC_EXTENSION_EVENTCODE_BASE, \
TRC_EXTENSION_EVENTCODE_BASE + TRC_EXT1_COUNT-1, \
TRC_EXT1_VERSION_PATCH, \
TRC_EXT1_VERSION_MINOR, \
TRC_EXT1_VERSION_MAJOR, \
TRC_EXT1_NAME } \
,{ TRC_EXTENSION_EVENTCODE_BASE + TRC_EXT1_COUNT, \
TRC_EXTENSION_EVENTCODE_BASE + TRC_EXT1_COUNT + TRC_EXT2_COUNT-1, \
TRC_EXT2_VERSION_PATCH, \
TRC_EXT2_VERSION_MINOR, \
TRC_EXT2_VERSION_MAJOR, \
TRC_EXT2_NAME } \
,{ TRC_EXTENSION_EVENTCODE_BASE + TRC_EXT1_COUNT + TRC_EXT2_COUNT, \
TRC_EXTENSION_EVENTCODE_BASE + TRC_EXT1_COUNT + TRC_EXT2_COUNT + TRC_EXT3_COUNT - 1, \
TRC_EXT3_VERSION_PATCH, \
TRC_EXT3_VERSION_MINOR, \
TRC_EXT3_VERSION_MAJOR, \
TRC_EXT3_NAME } \
,{ TRC_EXTENSION_EVENTCODE_BASE + TRC_EXT1_COUNT + TRC_EXT2_COUNT + TRC_EXT3_COUNT, \
TRC_EXTENSION_EVENTCODE_BASE + TRC_EXT1_COUNT + TRC_EXT2_COUNT + TRC_EXT3_COUNT + TRC_EXT4_COUNT- 1, \
TRC_EXT4_VERSION_PATCH, \
TRC_EXT4_VERSION_MINOR, \
TRC_EXT4_VERSION_MAJOR, \
TRC_EXT4_NAME } \
}
#endif
#if (TRC_CFG_EXTENSION_COUNT > 0)
#define TRC_EXTENSION_INFO {TRC_CFG_EXTENSION_COUNT, TRC_EXTENSION_EVENTCODE_BASE, ROUNDUP4(TRC_CFG_EXT_MAX_NAME_LEN), sizeof(PSFExtensionEntryType), TRC_EXTENSIONS_DATA}
#else
#define TRC_EXTENSION_INFO {TRC_CFG_EXTENSION_COUNT, TRC_EXTENSION_EVENTCODE_BASE}
#endif
#endif /* TRCEXTENSIONS_H_ */

View file

@ -1,51 +1,17 @@
/******************************************************************************* /*
* Trace Recorder Library for Tracealyzer v4.4.0 * Trace Recorder for Tracealyzer v4.6.0
* Percepio AB, www.percepio.com * Copyright 2021 Percepio AB
* www.percepio.com
* *
* trcHardwarePort.h * SPDX-License-Identifier: Apache-2.0
* *
* The hardware abstraction layer for the trace recorder. * The hardware abstraction layer for the trace recorder.
* */
* Terms of Use
* This file is part of the trace recorder library (RECORDER), which is the
* intellectual property of Percepio AB (PERCEPIO) and provided under a
* license as follows.
* The RECORDER may be used free of charge for the purpose of recording data
* intended for analysis in PERCEPIO products. It may not be used or modified
* for other purposes without explicit permission from PERCEPIO.
* You may distribute the RECORDER in its original source code form, assuming
* this text (terms of use, disclaimer, copyright notice) is unchanged. You are
* allowed to distribute the RECORDER with minor modifications intended for
* configuration or porting of the RECORDER, e.g., to allow using it on a
* specific processor, processor family or with a specific communication
* interface. Any such modifications should be documented directly below
* this comment block.
*
* Disclaimer
* The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty
* as to its use or performance. PERCEPIO does not and cannot warrant the
* performance or results you may obtain by using the RECORDER or documentation.
* PERCEPIO make no warranties, express or implied, as to noninfringement of
* third party rights, merchantability, or fitness for any particular purpose.
* In no event will PERCEPIO, its technology partners, or distributors be liable
* to you for any consequential, incidental or special damages, including any
* lost profits or lost savings, even if a representative of PERCEPIO has been
* advised of the possibility of such damages, or for any claim by any third
* party. Some jurisdictions do not allow the exclusion or limitation of
* incidental, consequential or special damages, or the exclusion of implied
* warranties or limitations on how long an implied warranty may last, so the
* above limitations may not apply to you.
*
* Tabs are used for indent in this file (1 tab = 4 spaces)
*
* Copyright Percepio AB, 2018.
* www.percepio.com
******************************************************************************/
#ifndef TRC_HARDWARE_PORT_H #ifndef TRC_HARDWARE_PORT_H
#define TRC_HARDWARE_PORT_H #define TRC_HARDWARE_PORT_H
#include "trcPortDefines.h" #include <trcDefines.h>
#if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_NOT_SET) #if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_NOT_SET)
@ -104,7 +70,7 @@
* around. If using TRC_FREE_RUNNING_32BIT_INCR/DECR, this should be 0. * 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_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 * TRACE_TICK_RATE_HZ. * 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 * 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 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 * the clock rate of your custom timer (i.e., TRC_HWTC_COUNT). If the default value
@ -126,16 +92,40 @@
#endif #endif
#if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Win32) #if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Win32)
/* This can be used as a template for any free-running 32-bit counter */ /* This can be used as a template for any free-running 32-bit counter */
#define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR void vTraceTimerReset(void);
#define TRC_HWTC_COUNT (ulGetRunTimeCounterValue()) uint32_t uiTraceTimerGetFrequency(void);
#define TRC_HWTC_PERIOD 0 uint32_t uiTraceTimerGetValue(void);
#define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ 100000
#define TRC_IRQ_PRIORITY_ORDER 1 #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_PORT_SPECIFIC_INIT() #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) #elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_HWIndependent)
/* Timestamping by OS tick only (typically 1 ms resolution) */ /* Timestamping by OS tick only (typically 1 ms resolution) */
@ -143,7 +133,7 @@
#define TRC_HWTC_COUNT 0 #define TRC_HWTC_COUNT 0
#define TRC_HWTC_PERIOD 1 #define TRC_HWTC_PERIOD 1
#define TRC_HWTC_DIVISOR 1 #define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ TRACE_TICK_RATE_HZ #define TRC_HWTC_FREQ_HZ TRC_TICK_RATE_HZ
/* Set the meaning of IRQ priorities in ISR tracing - see above */ /* Set the meaning of IRQ priorities in ISR tracing - see above */
#define TRC_IRQ_PRIORITY_ORDER NOT_SET #define TRC_IRQ_PRIORITY_ORDER NOT_SET
@ -154,6 +144,10 @@
#error "Can't find the CMSIS API. Please include your processor's header file in trcConfig.h" #error "Can't find the CMSIS API. Please include your processor's header file in trcConfig.h"
#endif #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-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 * For Cortex-M0 and M0+, the SysTick timer is used since DWT is not
@ -166,7 +160,7 @@
#if ((__CORTEX_M >= 0x03) && (! defined TRC_CFG_ARM_CM_USE_SYSTICK)) #if ((__CORTEX_M >= 0x03) && (! defined TRC_CFG_ARM_CM_USE_SYSTICK))
void prvTraceInitCortexM(void); void xTraceHardwarePortInitCortexM(void);
#define TRC_REG_DEMCR (*(volatile uint32_t*)0xE000EDFC) #define TRC_REG_DEMCR (*(volatile uint32_t*)0xE000EDFC)
#define TRC_REG_DWT_CTRL (*(volatile uint32_t*)0xE0001000) #define TRC_REG_DWT_CTRL (*(volatile uint32_t*)0xE0001000)
@ -191,7 +185,7 @@
/* Bit mask for EXCEVTENA_ bit in DWT_CTRL. Set to 1 to enable DWT_CYCCNT */ /* Bit mask for EXCEVTENA_ bit in DWT_CTRL. Set to 1 to enable DWT_CYCCNT */
#define TRC_DWT_CTRL_CYCCNTENA (1) #define TRC_DWT_CTRL_CYCCNTENA (1)
#define TRC_PORT_SPECIFIC_INIT() prvTraceInitCortexM() #define TRC_PORT_SPECIFIC_INIT() xTraceHardwarePortInitCortexM()
#define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR #define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
#define TRC_HWTC_COUNT TRC_REG_DWT_CYCCNT #define TRC_HWTC_COUNT TRC_REG_DWT_CYCCNT
@ -212,8 +206,11 @@
#endif #endif
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Renesas_RX600) #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" #include <iodefine.h>
#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
@ -230,16 +227,20 @@
#define TRC_HWTC_PERIOD (CMT0.CMCOR + 1) #define TRC_HWTC_PERIOD (CMT0.CMCOR + 1)
#define TRC_HWTC_DIVISOR 1 #define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
#define TRC_IRQ_PRIORITY_ORDER 1 #define TRC_IRQ_PRIORITY_ORDER 1
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_MICROCHIP_PIC24_PIC32) #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_TYPE TRC_OS_TIMER_INCR
#define TRC_HWTC_COUNT (TMR1) #define TRC_HWTC_COUNT (TMR1)
#define TRC_HWTC_PERIOD (PR1 + 1) #define TRC_HWTC_PERIOD (PR1 + 1)
#define TRC_HWTC_DIVISOR 1 #define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
#define TRC_IRQ_PRIORITY_ORDER 1 #define TRC_IRQ_PRIORITY_ORDER 1
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_TEXAS_INSTRUMENTS_TMS570_RM48) #elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_TEXAS_INSTRUMENTS_TMS570_RM48)
@ -252,7 +253,7 @@
#define TRC_HWTC_COUNT (TRC_RTIFRC0 - (TRC_RTICOMP0 - TRC_RTIUDCP0)) #define TRC_HWTC_COUNT (TRC_RTIFRC0 - (TRC_RTICOMP0 - TRC_RTIUDCP0))
#define TRC_HWTC_PERIOD (TRC_RTIUDCP0) #define TRC_HWTC_PERIOD (TRC_RTIUDCP0)
#define TRC_HWTC_DIVISOR 1 #define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
#define TRC_IRQ_PRIORITY_ORDER 0 #define TRC_IRQ_PRIORITY_ORDER 0
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Atmel_AT91SAM7) #elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Atmel_AT91SAM7)
@ -263,7 +264,7 @@
#define TRC_HWTC_COUNT ((uint32_t)(AT91C_BASE_PITC->PITC_PIIR & 0xFFFFF)) #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_PERIOD ((uint32_t)(AT91C_BASE_PITC->PITC_PIMR + 1))
#define TRC_HWTC_DIVISOR 1 #define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
#define TRC_IRQ_PRIORITY_ORDER 1 #define TRC_IRQ_PRIORITY_ORDER 1
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Atmel_UC3A0) #elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Atmel_UC3A0)
@ -276,7 +277,7 @@
#define TRC_HWTC_COUNT ((uint32_t)sysreg_read(AVR32_COUNT)) #define TRC_HWTC_COUNT ((uint32_t)sysreg_read(AVR32_COUNT))
#define TRC_HWTC_PERIOD ((uint32_t)(sysreg_read(AVR32_COMPARE) + 1)) #define TRC_HWTC_PERIOD ((uint32_t)(sysreg_read(AVR32_COMPARE) + 1))
#define TRC_HWTC_DIVISOR 1 #define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
#define TRC_IRQ_PRIORITY_ORDER 1 #define TRC_IRQ_PRIORITY_ORDER 1
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_NXP_LPC210X) #elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_NXP_LPC210X)
@ -289,7 +290,7 @@
#define TRC_HWTC_COUNT *((uint32_t *)0xE0004008 ) #define TRC_HWTC_COUNT *((uint32_t *)0xE0004008 )
#define TRC_HWTC_PERIOD *((uint32_t *)0xE0004018 ) #define TRC_HWTC_PERIOD *((uint32_t *)0xE0004018 )
#define TRC_HWTC_DIVISOR 1 #define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
#define TRC_IRQ_PRIORITY_ORDER 0 #define TRC_IRQ_PRIORITY_ORDER 0
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_TEXAS_INSTRUMENTS_MSP430) #elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_TEXAS_INSTRUMENTS_MSP430)
@ -300,7 +301,7 @@
#define TRC_HWTC_COUNT (TA0R) #define TRC_HWTC_COUNT (TA0R)
#define TRC_HWTC_PERIOD (((uint16_t)TACCR0)+1) #define TRC_HWTC_PERIOD (((uint16_t)TACCR0)+1)
#define TRC_HWTC_DIVISOR 1 #define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
#define TRC_IRQ_PRIORITY_ORDER 1 #define TRC_IRQ_PRIORITY_ORDER 1
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XILINX_PPC405) #elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XILINX_PPC405)
@ -309,9 +310,9 @@
#define TRC_HWTC_TYPE TRC_OS_TIMER_DECR #define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
#define TRC_HWTC_COUNT mfspr(0x3db) #define TRC_HWTC_COUNT mfspr(0x3db)
#define TRC_HWTC_PERIOD (TRACE_CPU_CLOCK_HZ / TRACE_TICK_RATE_HZ) #define TRC_HWTC_PERIOD (TRACE_CPU_CLOCK_HZ / TRC_TICK_RATE_HZ)
#define TRC_HWTC_DIVISOR 1 #define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
#define TRC_IRQ_PRIORITY_ORDER 0 #define TRC_IRQ_PRIORITY_ORDER 0
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XILINX_PPC440) #elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XILINX_PPC440)
@ -322,9 +323,9 @@
#define TRC_HWTC_TYPE TRC_OS_TIMER_DECR #define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
#define TRC_HWTC_COUNT mfspr(0x016) #define TRC_HWTC_COUNT mfspr(0x016)
#define TRC_HWTC_PERIOD (TRACE_CPU_CLOCK_HZ / TRACE_TICK_RATE_HZ) #define TRC_HWTC_PERIOD (TRACE_CPU_CLOCK_HZ / TRC_TICK_RATE_HZ)
#define TRC_HWTC_DIVISOR 1 #define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
#define TRC_IRQ_PRIORITY_ORDER 0 #define TRC_IRQ_PRIORITY_ORDER 0
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XILINX_MICROBLAZE) #elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XILINX_MICROBLAZE)
@ -335,24 +336,33 @@
* It uses the AXI Timer 0 - the tick interrupt source. * 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. * If an AXI Timer 0 peripheral is available on your hardware platform, no modifications are required.
*/ */
#include "xtmrctr_l.h" #include <xtmrctr_l.h>
#define TRC_HWTC_TYPE TRC_OS_TIMER_DECR #define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
#define TRC_HWTC_COUNT XTmrCtr_GetTimerCounterReg( XPAR_TMRCTR_0_BASEADDR, 0 ) #define TRC_HWTC_COUNT XTmrCtr_GetTimerCounterReg( XPAR_TMRCTR_0_BASEADDR, 0 )
#define TRC_HWTC_PERIOD (XTmrCtr_mGetLoadReg( XPAR_TMRCTR_0_BASEADDR, 0) + 1) #define TRC_HWTC_PERIOD (XTmrCtr_GetLoadReg( XPAR_TMRCTR_0_BASEADDR, 0) + 1)
#define TRC_HWTC_DIVISOR 16 #define TRC_HWTC_DIVISOR 16
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
#define TRC_IRQ_PRIORITY_ORDER 0 #define TRC_IRQ_PRIORITY_ORDER 0
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XILINX_ZyncUltraScaleR5) #elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XILINX_ZyncUltraScaleR5)
#include "xttcps_hw.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); }
#include <xttcps_hw.h>
#define TRC_HWTC_TYPE TRC_OS_TIMER_INCR #define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
#define TRC_HWTC_COUNT (*(volatile uint32_t *)(configTIMER_BASEADDR + XTTCPS_COUNT_VALUE_OFFSET)) #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_PERIOD (*(volatile uint32_t *)(configTIMER_BASEADDR + XTTCPS_INTERVAL_VAL_OFFSET))
#define TRC_HWTC_DIVISOR 16 #define TRC_HWTC_DIVISOR 16
#define TRC_HWTC_FREQ_HZ (TRC_HWTC_PERIOD * TRACE_TICK_RATE_HZ) #define TRC_HWTC_FREQ_HZ (TRC_HWTC_PERIOD * TRC_TICK_RATE_HZ)
#define TRC_IRQ_PRIORITY_ORDER 0 #define TRC_IRQ_PRIORITY_ORDER 0
#ifdef __GNUC__ #ifdef __GNUC__
@ -374,6 +384,11 @@
#include <system.h> #include <system.h>
#include <altera_avalon_timer_regs.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 #define NOT_SET 1
@ -400,7 +415,7 @@
#define TRC_HWTC_COUNT altera_nios2_GetTimerSnapReg() #define TRC_HWTC_COUNT altera_nios2_GetTimerSnapReg()
#define TRC_HWTC_PERIOD (configCPU_CLOCK_HZ / configTICK_RATE_HZ ) #define TRC_HWTC_PERIOD (configCPU_CLOCK_HZ / configTICK_RATE_HZ )
#define TRC_HWTC_DIVISOR 16 #define TRC_HWTC_DIVISOR 16
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
#define TRC_IRQ_PRIORITY_ORDER 0 #define TRC_IRQ_PRIORITY_ORDER 0
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_ARM_CORTEX_A9) #elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_ARM_CORTEX_A9)
@ -422,6 +437,15 @@
* TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS is set accordingly. * 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)*/ /* INPUT YOUR PERIPHERAL BASE ADDRESS HERE (0xF8F00000 for Xilinx Zynq 7000)*/
#define TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS 0 #define TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS 0
@ -450,7 +474,7 @@
*****************************************************************************************/ *****************************************************************************************/
#define TRC_HWTC_DIVISOR 1 #define TRC_HWTC_DIVISOR 1
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD) #define TRC_HWTC_FREQ_HZ (TRC_TICK_RATE_HZ * TRC_HWTC_PERIOD)
#define TRC_IRQ_PRIORITY_ORDER 0 #define TRC_IRQ_PRIORITY_ORDER 0
#ifdef __GNUC__ #ifdef __GNUC__
@ -466,11 +490,133 @@
#error "Only GCC Supported!" #error "Only GCC Supported!"
#endif #endif
#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
#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
/**
* @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 !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) #elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_POWERPC_Z4)
/* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */ /* 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 TRC_HWTC_TYPE TRC_OS_TIMER_DECR
//#define HWTC_COUNT_DIRECTION DIRECTION_DECREMENTING //#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_COUNT PIT.TIMER[configTICK_PIT_CHANNEL].CVAL.R // must be the PIT channel used for the systick
@ -555,4 +701,14 @@
#endif #endif
#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*/ #endif /*TRC_SNAPSHOT_HARDWARE_PORT_H*/

View file

@ -0,0 +1,135 @@
/*
* 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
#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 */

View file

@ -0,0 +1,226 @@
/*
* 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 */

View file

@ -0,0 +1,107 @@
/*
* 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 */

View file

@ -0,0 +1,86 @@
/*
* 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 */

View file

@ -0,0 +1,143 @@
/*
* 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 assignts 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 (mutal exclusive).
*
* @param[out] pxTraceMultiCoreEventBuffer Pointer to unitialized 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
/**
* @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 transfered 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 */

View file

@ -0,0 +1,202 @@
/*
* 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 */

View file

@ -0,0 +1,207 @@
/*
* 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 */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,135 @@
/*
* 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 */

View file

@ -0,0 +1,78 @@
/*
* 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 */

View file

@ -0,0 +1,112 @@
/*
* 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 */

View file

@ -0,0 +1,76 @@
/*
* 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 */

View file

@ -0,0 +1,243 @@
/*
* 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 */

View file

@ -0,0 +1,253 @@
/*
* 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 */

View file

@ -0,0 +1,69 @@
/*
* 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 */

View file

@ -0,0 +1,51 @@
/*
* 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
#endif /* TRC_UTILITY_H */

View file

@ -0,0 +1,201 @@
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.

View file

@ -0,0 +1,10 @@
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>

View file

@ -0,0 +1,5 @@
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

View file

@ -1,49 +1,13 @@
/******************************************************************************* /*
* Trace Recorder Library for Tracealyzer v4.4.0 * Trace Recorder for Tracealyzer v4.6.0
* Percepio AB, www.percepio.com * Copyright 2021 Percepio AB
* www.percepio.com
* *
* trcConfig.h * SPDX-License-Identifier: Apache-2.0
* *
* Main configuration parameters for the trace recorder library. * Main configuration parameters for the trace recorder library.
* More settings can be found in trcStreamingConfig.h and trcSnapshotConfig.h. * More settings can be found in trcStreamingConfig.h and trcSnapshotConfig.h.
* */
* Read more at http://percepio.com/2016/10/05/rtos-tracing/
*
* Terms of Use
* This file is part of the trace recorder library (RECORDER), which is the
* intellectual property of Percepio AB (PERCEPIO) and provided under a
* license as follows.
* The RECORDER may be used free of charge for the purpose of recording data
* intended for analysis in PERCEPIO products. It may not be used or modified
* for other purposes without explicit permission from PERCEPIO.
* You may distribute the RECORDER in its original source code form, assuming
* this text (terms of use, disclaimer, copyright notice) is unchanged. You are
* allowed to distribute the RECORDER with minor modifications intended for
* configuration or porting of the RECORDER, e.g., to allow using it on a
* specific processor, processor family or with a specific communication
* interface. Any such modifications should be documented directly below
* this comment block.
*
* Disclaimer
* The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty
* as to its use or performance. PERCEPIO does not and cannot warrant the
* performance or results you may obtain by using the RECORDER or documentation.
* PERCEPIO make no warranties, express or implied, as to noninfringement of
* third party rights, merchantability, or fitness for any particular purpose.
* In no event will PERCEPIO, its technology partners, or distributors be liable
* to you for any consequential, incidental or special damages, including any
* lost profits or lost savings, even if a representative of PERCEPIO has been
* advised of the possibility of such damages, or for any claim by any third
* party. Some jurisdictions do not allow the exclusion or limitation of
* incidental, consequential or special damages, or the exclusion of implied
* warranties or limitations on how long an implied warranty may last, so the
* above limitations may not apply to you.
*
* Tabs are used for indent in this file (1 tab = 4 spaces)
*
* Copyright Percepio AB, 2018.
* www.percepio.com
******************************************************************************/
#ifndef TRC_CONFIG_H #ifndef TRC_CONFIG_H
#define TRC_CONFIG_H #define TRC_CONFIG_H
@ -52,8 +16,6 @@
extern "C" { extern "C" {
#endif #endif
#include "trcPortDefines.h"
/****************************************************************************** /******************************************************************************
* Include of processor header file * Include of processor header file
* *
@ -63,10 +25,9 @@ extern "C" {
*****************************************************************************/ *****************************************************************************/
#error "Trace Recorder: Please include your processor's header file here and remove this line." #error "Trace Recorder: Please include your processor's header file here and remove this line."
/******************************************************************************* /**
* Configuration Macro: TRC_CFG_HARDWARE_PORT * @def TRC_CFG_HARDWARE_PORT
* * @brief Specify what hardware port to use (i.e., the "timestamping driver").
* 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". * 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 * This port uses the DWT cycle counter for Cortex-M3/M4/M7 devices, which is
@ -80,80 +41,34 @@ extern "C" {
* *
* See trcHardwarePort.h for available ports and information on how to * See trcHardwarePort.h for available ports and information on how to
* define your own port, if not already present. * define your own port, if not already present.
******************************************************************************/ */
#define TRC_CFG_HARDWARE_PORT TRC_HARDWARE_PORT_NOT_SET #define TRC_CFG_HARDWARE_PORT TRC_HARDWARE_PORT_NOT_SET
/******************************************************************************* /**
* Configuration Macro: TRC_CFG_RECORDER_MODE * @def TRC_CFG_SCHEDULING_ONLY
* * @brief Macro which should be defined as an integer value.
* 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_SNAPSHOT
/******************************************************************************
* TRC_CFG_FREERTOS_VERSION
*
* 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 FREERTOS_VERSION_NOT_SET
/*******************************************************************************
* TRC_CFG_SCHEDULING_ONLY
*
* Macro which should be defined as an integer value.
* *
* If this setting is enabled (= 1), only scheduling events are recorded. * If this setting is enabled (= 1), only scheduling events are recorded.
* If disabled (= 0), all events are recorded (unless filtered in other ways). * If disabled (= 0), all events are recorded (unless filtered in other ways).
* *
* Default value is 0 (= include additional events). * Default value is 0 (= include additional events).
******************************************************************************/ */
#define TRC_CFG_SCHEDULING_ONLY 0 #define TRC_CFG_SCHEDULING_ONLY 0
/****************************************************************************** /**
* TRC_CFG_INCLUDE_MEMMANG_EVENTS * @def TRC_CFG_INCLUDE_MEMMANG_EVENTS
* * @brief Macro which should be defined as either zero (0) or one (1).
* 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) * 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. * to exclude malloc/free calls, or one (1) to include such events in the trace.
* *
* Default value is 1. * Default value is 1.
*****************************************************************************/ */
#define TRC_CFG_INCLUDE_MEMMANG_EVENTS 1 #define TRC_CFG_INCLUDE_MEMMANG_EVENTS 1
/****************************************************************************** /**
* TRC_CFG_INCLUDE_USER_EVENTS * @def TRC_CFG_INCLUDE_USER_EVENTS
* * @brief Macro which should be defined as either zero (0) or one (1).
* 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 * 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 * to reduce code size. Any attempts of storing User Events are then silently
@ -168,17 +83,16 @@ extern "C" {
* Note: In streaming mode, User Events are used to provide error messages * Note: In streaming mode, User Events are used to provide error messages
* and warnings from the recorder (in case of incorrect configuration) for * and warnings from the recorder (in case of incorrect configuration) for
* display in Tracealyzer. Disabling user events will also disable these * display in Tracealyzer. Disabling user events will also disable these
* warnings. You can however still catch them by calling xTraceGetLastError * warnings. You can however still catch them by calling xTraceErrorGetLast
* or by putting breakpoints in prvTraceError and prvTraceWarning. * or by putting breakpoints in xTraceError and xTraceWarning.
* *
* Default value is 1. * Default value is 1.
*****************************************************************************/ */
#define TRC_CFG_INCLUDE_USER_EVENTS 1 #define TRC_CFG_INCLUDE_USER_EVENTS 1
/***************************************************************************** /**
* TRC_CFG_INCLUDE_ISR_TRACING * @def TRC_CFG_INCLUDE_ISR_TRACING
* * @brief Macro which should be defined as either zero (0) or one (1).
* 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 * 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 * excluded, in order to reduce code size. This means that any calls to
@ -194,13 +108,12 @@ extern "C" {
* *
* Note: tracing ISRs requires that you insert calls to vTraceStoreISRBegin * Note: tracing ISRs requires that you insert calls to vTraceStoreISRBegin
* and vTraceStoreISREnd in your interrupt handlers. * and vTraceStoreISREnd in your interrupt handlers.
*****************************************************************************/ */
#define TRC_CFG_INCLUDE_ISR_TRACING 1 #define TRC_CFG_INCLUDE_ISR_TRACING 1
/***************************************************************************** /**
* TRC_CFG_INCLUDE_READY_EVENTS * @def TRC_CFG_INCLUDE_READY_EVENTS
* * @brief Macro which should be defined as either zero (0) or one (1).
* Macro which should be defined as either zero (0) or one (1).
* *
* If one (1), events are recorded when tasks enter scheduling state "ready". * If one (1), events are recorded when tasks enter scheduling state "ready".
* This allows Tracealyzer to show the initial pending time before tasks enter * This allows Tracealyzer to show the initial pending time before tasks enter
@ -209,96 +122,46 @@ extern "C" {
* longer traces in the same amount of RAM. * longer traces in the same amount of RAM.
* *
* Default value is 1. * Default value is 1.
*****************************************************************************/ */
#define TRC_CFG_INCLUDE_READY_EVENTS 1 #define TRC_CFG_INCLUDE_READY_EVENTS 1
/***************************************************************************** /**
* TRC_CFG_INCLUDE_OSTICK_EVENTS * @def TRC_CFG_INCLUDE_OSTICK_EVENTS
* * @brief Macro which should be defined as either zero (0) or one (1).
* 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 * 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 * increased. If zero (0), OS tick events are not generated, which allows for
* recording longer traces in the same amount of RAM. * recording longer traces in the same amount of RAM.
* *
* Default value is 1. * Default value is 1.
*****************************************************************************/ */
#define TRC_CFG_INCLUDE_OSTICK_EVENTS 1 #define TRC_CFG_INCLUDE_OSTICK_EVENTS 1
/***************************************************************************** /**
* TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS * @def TRC_CFG_ENABLE_STACK_MONITOR
* * @brief If enabled (1), the recorder periodically reports the unused stack space of
* 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 0
/*****************************************************************************
* TRC_CFG_INCLUDE_TIMER_EVENTS
*
* 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 0
/*****************************************************************************
* TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS
*
* 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 0
/*******************************************************************************
* Configuration Macro: TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS
*
* 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 0
/******************************************************************************
* TRC_CFG_ENABLE_STACK_MONITOR
*
* If enabled (1), the recorder periodically reports the unused stack space of
* all active tasks. * all active tasks.
* The stack monitoring runs in the Tracealyzer Control task, TzCtrl. This task * The stack monitoring runs in the Tracealyzer Control task, TzCtrl. This task
* is always created by the recorder when in streaming mode. * is always created by the recorder when in streaming mode.
* In snapshot mode, the TzCtrl task is only used for stack monitoring and is * In snapshot mode, the TzCtrl task is only used for stack monitoring and is
* not created unless this is enabled. * not created unless this is enabled.
*****************************************************************************/ */
#define TRC_CFG_ENABLE_STACK_MONITOR 1 #define TRC_CFG_ENABLE_STACK_MONITOR 1
/****************************************************************************** /**
* TRC_CFG_STACK_MONITOR_MAX_TASKS * @def TRC_CFG_STACK_MONITOR_MAX_TASKS
* * @brief Macro which should be defined as a non-zero integer value.
* Macro which should be defined as a non-zero integer value.
* *
* This controls how many tasks that can be monitored by the stack monitor. * 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. * If this is too small, some tasks will be excluded and a warning is shown.
* *
* Default value is 10. * Default value is 10.
*****************************************************************************/ */
#define TRC_CFG_STACK_MONITOR_MAX_TASKS 10 #define TRC_CFG_STACK_MONITOR_MAX_TASKS 10
/****************************************************************************** /**
* TRC_CFG_STACK_MONITOR_MAX_REPORTS * @def TRC_CFG_STACK_MONITOR_MAX_REPORTS
* * @brief Macro which should be defined as a non-zero integer value.
* 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 * 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 * each execution of the Tracealyzer Control task (TzCtrl). Note that the stack
@ -313,13 +176,12 @@ extern "C" {
* analysis disturbs any time-sensitive tasks. * analysis disturbs any time-sensitive tasks.
* *
* Default value is 1. * Default value is 1.
*****************************************************************************/ */
#define TRC_CFG_STACK_MONITOR_MAX_REPORTS 1 #define TRC_CFG_STACK_MONITOR_MAX_REPORTS 1
/******************************************************************************* /**
* Configuration Macro: TRC_CFG_CTRL_TASK_PRIORITY * @def TRC_CFG_CTRL_TASK_PRIORITY
* * @brief The scheduling priority of the Tracealyzer Control (TzCtrl) task.
* The scheduling priority of the Tracealyzer Control (TzCtrl) task.
* *
* In streaming mode, TzCtrl is used to receive start/stop commands from * 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 * Tracealyzer and in some cases also to transmit the trace data (for stream
@ -331,34 +193,31 @@ extern "C" {
* In Snapshot mode, TzCtrl is only used for the stack usage monitoring and is * 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 * not created if stack monitoring is disabled. TRC_CFG_CTRL_TASK_PRIORITY should
* be low, to avoid disturbing any time-sensitive tasks. * be low, to avoid disturbing any time-sensitive tasks.
******************************************************************************/ */
#define TRC_CFG_CTRL_TASK_PRIORITY 1 #define TRC_CFG_CTRL_TASK_PRIORITY 1
/******************************************************************************* /**
* Configuration Macro: TRC_CFG_CTRL_TASK_DELAY * @def TRC_CFG_CTRL_TASK_DELAY
* * @brief The delay between loops of the TzCtrl task (see TRC_CFG_CTRL_TASK_PRIORITY),
* The delay between loops of the TzCtrl task (see TRC_CFG_CTRL_TASK_PRIORITY),
* which affects the frequency of the stack monitoring. * which affects the frequency of the stack monitoring.
* *
* In streaming mode, this also affects the trace data transfer if you are using * 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 * 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 * increases the CPU load of TzCtrl somewhat, but may improve the performance of
* of the trace streaming, especially if the trace buffer is small. * of the trace streaming, especially if the trace buffer is small.
******************************************************************************/ */
#define TRC_CFG_CTRL_TASK_DELAY 10 #define TRC_CFG_CTRL_TASK_DELAY 2
/******************************************************************************* /**
* Configuration Macro: TRC_CFG_CTRL_TASK_STACK_SIZE * @def TRC_CFG_CTRL_TASK_STACK_SIZE
* * @brief The stack size of the Tracealyzer Control (TzCtrl) task.
* The stack size of the Tracealyzer Control (TzCtrl) task.
* See TRC_CFG_CTRL_TASK_PRIORITY for further information about TzCtrl. * See TRC_CFG_CTRL_TASK_PRIORITY for further information about TzCtrl.
******************************************************************************/ */
#define TRC_CFG_CTRL_TASK_STACK_SIZE (configMINIMAL_STACK_SIZE * 2) #define TRC_CFG_CTRL_TASK_STACK_SIZE 1024
/******************************************************************************* /**
* Configuration Macro: TRC_CFG_RECORDER_BUFFER_ALLOCATION * @def TRC_CFG_RECORDER_BUFFER_ALLOCATION
* * @brief Specifies how the recorder buffer is allocated (also in case of streaming, in
* Specifies how the recorder buffer is allocated (also in case of streaming, in
* port using the recorder's internal temporary buffer) * port using the recorder's internal temporary buffer)
* *
* Values: * Values:
@ -370,13 +229,12 @@ extern "C" {
* (static) or in runtime (malloc). * (static) or in runtime (malloc).
* The custom mode allows you to control how and where the allocation is made, * The custom mode allows you to control how and where the allocation is made,
* for details see TRC_ALLOC_CUSTOM_BUFFER and vTraceSetRecorderDataBuffer(). * for details see TRC_ALLOC_CUSTOM_BUFFER and vTraceSetRecorderDataBuffer().
******************************************************************************/ */
#define TRC_CFG_RECORDER_BUFFER_ALLOCATION TRC_RECORDER_BUFFER_ALLOCATION_STATIC #define TRC_CFG_RECORDER_BUFFER_ALLOCATION TRC_RECORDER_BUFFER_ALLOCATION_STATIC
/****************************************************************************** /**
* TRC_CFG_MAX_ISR_NESTING * @def TRC_CFG_MAX_ISR_NESTING
* * @brief Defines how many levels of interrupt nesting the recorder can handle, in
* Defines how many levels of interrupt nesting the recorder can handle, in
* case multiple ISRs are traced and ISR nesting is possible. If this * 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 * 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 * logs an error message. This setting is used to allocate an internal stack
@ -385,25 +243,75 @@ extern "C" {
* This value must be a non-zero positive constant, at least 1. * This value must be a non-zero positive constant, at least 1.
* *
* Default value: 8 * Default value: 8
*****************************************************************************/ */
#define TRC_CFG_MAX_ISR_NESTING 8 #define TRC_CFG_MAX_ISR_NESTING 8
/****************************************************************************** /**
* TRC_CFG_ACKNOWLEDGE_QUEUE_SET_SEND * @def TRC_CFG_ISR_TAILCHAINING_THRESHOLD
* @brief Macro which should be defined as an integer value.
* *
* When using FreeRTOS v10.3.0 or v10.3.1, please make sure that the trace * If tracing multiple ISRs, this setting allows for accurate display of the
* point in prvNotifyQueueSetContainer() in queue.c is renamed from * context-switching also in cases when the ISRs execute in direct sequence.
* traceQUEUE_SEND to traceQUEUE_SET_SEND in order to tell them apart from *
* other traceQUEUE_SEND trace points. Then set this to TRC_ACKNOWLEDGED. * vTraceStoreISREnd normally assumes that the ISR returns to the previous
*****************************************************************************/ * context, i.e., a task or a preempted ISR. But if another traced ISR
#define TRC_CFG_ACKNOWLEDGE_QUEUE_SET_SEND 0 /* TRC_ACKNOWLEDGED */ * 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
/* Specific configuration, depending on Streaming/Snapshot mode */ /**
#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT) * @def TRC_CFG_RECORDER_DATA_INIT
#include "trcSnapshotConfig.h" * @brief Macro which states wether the recorder data should have an initial value.
#elif (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) *
#include "trcStreamingConfig.h" * In very specific cases where traced objects are created before main(),
#endif * 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 #ifdef __cplusplus
} }

View file

@ -0,0 +1,116 @@
/*
* 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 */

View file

@ -0,0 +1,69 @@
/*
* 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 */

View file

@ -0,0 +1,24 @@
/*
* 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 streaming mode.
*/
#ifndef TRC_KERNEL_PORT_STREAMING_CONFIG_H
#define TRC_KERNEL_PORT_STREAMING_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
/* Nothing yet */
#ifdef __cplusplus
}
#endif
#endif /* TRC_KERNEL_PORT_STREAMING_CONFIG_H */

View file

@ -1,58 +1,24 @@
/******************************************************************************* /*
* Trace Recorder Library for Tracealyzer v4.4.0 * Trace Recorder for Tracealyzer v4.6.0
* Percepio AB, www.percepio.com * Copyright 2021 Percepio AB
* www.percepio.com
* *
* trcSnapshotConfig.h * SPDX-License-Identifier: Apache-2.0
* *
* Configuration parameters for trace recorder library in snapshot mode. * Configuration parameters for trace recorder library in snapshot mode.
* Read more at http://percepio.com/2016/10/05/rtos-tracing/ * Read more at http://percepio.com/2016/10/05/rtos-tracing/
* */
* Terms of Use
* This file is part of the trace recorder library (RECORDER), which is the
* intellectual property of Percepio AB (PERCEPIO) and provided under a
* license as follows.
* The RECORDER may be used free of charge for the purpose of recording data
* intended for analysis in PERCEPIO products. It may not be used or modified
* for other purposes without explicit permission from PERCEPIO.
* You may distribute the RECORDER in its original source code form, assuming
* this text (terms of use, disclaimer, copyright notice) is unchanged. You are
* allowed to distribute the RECORDER with minor modifications intended for
* configuration or porting of the RECORDER, e.g., to allow using it on a
* specific processor, processor family or with a specific communication
* interface. Any such modifications should be documented directly below
* this comment block.
*
* Disclaimer
* The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty
* as to its use or performance. PERCEPIO does not and cannot warrant the
* performance or results you may obtain by using the RECORDER or documentation.
* PERCEPIO make no warranties, express or implied, as to noninfringement of
* third party rights, merchantability, or fitness for any particular purpose.
* In no event will PERCEPIO, its technology partners, or distributors be liable
* to you for any consequential, incidental or special damages, including any
* lost profits or lost savings, even if a representative of PERCEPIO has been
* advised of the possibility of such damages, or for any claim by any third
* party. Some jurisdictions do not allow the exclusion or limitation of
* incidental, consequential or special damages, or the exclusion of implied
* warranties or limitations on how long an implied warranty may last, so the
* above limitations may not apply to you.
*
* Tabs are used for indent in this file (1 tab = 4 spaces)
*
* Copyright Percepio AB, 2018.
* www.percepio.com
******************************************************************************/
#ifndef TRC_SNAPSHOT_CONFIG_H #ifndef TRC_SNAPSHOT_CONFIG_H
#define TRC_SNAPSHOT_CONFIG_H #define TRC_SNAPSHOT_CONFIG_H
#define TRC_SNAPSHOT_MODE_RING_BUFFER (0x01) #ifdef __cplusplus
#define TRC_SNAPSHOT_MODE_STOP_WHEN_FULL (0x02) extern "C" {
#endif
/****************************************************************************** /**
* TRC_CFG_SNAPSHOT_MODE * @def TRC_CFG_SNAPSHOT_MODE
* * @brief Macro which should be defined as one of:
* Macro which should be defined as one of:
* - TRC_SNAPSHOT_MODE_RING_BUFFER * - TRC_SNAPSHOT_MODE_RING_BUFFER
* - TRC_SNAPSHOT_MODE_STOP_WHEN_FULL * - TRC_SNAPSHOT_MODE_STOP_WHEN_FULL
* Default is TRC_SNAPSHOT_MODE_RING_BUFFER. * Default is TRC_SNAPSHOT_MODE_RING_BUFFER.
@ -66,13 +32,12 @@
* When TRC_CFG_SNAPSHOT_MODE is TRC_SNAPSHOT_MODE_STOP_WHEN_FULL, the * 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 is stopped when the buffer becomes full. This is useful for
* recording events following a specific state, e.g., the startup sequence. * recording events following a specific state, e.g., the startup sequence.
*****************************************************************************/ */
#define TRC_CFG_SNAPSHOT_MODE TRC_SNAPSHOT_MODE_RING_BUFFER #define TRC_CFG_SNAPSHOT_MODE TRC_SNAPSHOT_MODE_RING_BUFFER
/******************************************************************************* /**
* TRC_CFG_EVENT_BUFFER_SIZE * @def TRC_CFG_EVENT_BUFFER_SIZE
* * @brief Macro which should be defined as an integer value.
* Macro which should be defined as an integer value.
* *
* This defines the capacity of the event buffer, i.e., the number of records * 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 * it may store. Most events use one record (4 byte), although some events
@ -81,45 +46,12 @@
* *
* Default value is 1000, which means that 4000 bytes is allocated for the * Default value is 1000, which means that 4000 bytes is allocated for the
* event buffer. * event buffer.
******************************************************************************/ */
#define TRC_CFG_EVENT_BUFFER_SIZE 1000 #define TRC_CFG_EVENT_BUFFER_SIZE 1000
/******************************************************************************* /**
* TRC_CFG_NTASK, TRC_CFG_NISR, TRC_CFG_NQUEUE, TRC_CFG_NSEMAPHORE... * @def TRC_CFG_INCLUDE_FLOAT_SUPPORT
* * @brief Macro which should be defined as either zero (0) or one (1).
* 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
/******************************************************************************
* TRC_CFG_INCLUDE_FLOAT_SUPPORT
*
* 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 * 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 * vTracePrintF is stripped out, in case floating point values are not used or
@ -131,13 +63,12 @@
* vTracePrintF can be used with integer and string arguments in either case. * vTracePrintF can be used with integer and string arguments in either case.
* *
* Default value is 0. * Default value is 0.
*****************************************************************************/ */
#define TRC_CFG_INCLUDE_FLOAT_SUPPORT 0 #define TRC_CFG_INCLUDE_FLOAT_SUPPORT 0
/******************************************************************************* /**
* TRC_CFG_SYMBOL_TABLE_SIZE * @def TRC_CFG_SYMBOL_TABLE_SIZE
* * @brief Macro which should be defined as an integer value.
* Macro which should be defined as an integer value.
* *
* This defines the capacity of the symbol table, in bytes. This symbol table * 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 * stores User Events labels and names of deleted tasks, queues, or other kernel
@ -147,30 +78,13 @@
* 32-bit pointer, i.e., using 4 bytes rather than 0. * 32-bit pointer, i.e., using 4 bytes rather than 0.
* *
* Default value is 800. * Default value is 800.
******************************************************************************/ */
#define TRC_CFG_SYMBOL_TABLE_SIZE 800 #define TRC_CFG_SYMBOL_TABLE_SIZE 800
#if (TRC_CFG_SYMBOL_TABLE_SIZE == 0) #if (TRC_CFG_SYMBOL_TABLE_SIZE == 0)
#error "TRC_CFG_SYMBOL_TABLE_SIZE may not be zero!" #error "TRC_CFG_SYMBOL_TABLE_SIZE may not be zero!"
#endif #endif
/******************************************************************************
* TRC_CFG_NAME_LEN_TASK, TRC_CFG_NAME_LEN_QUEUE, ...
*
* 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
/****************************************************************************** /******************************************************************************
*** ADVANCED SETTINGS ******************************************************** *** ADVANCED SETTINGS ********************************************************
****************************************************************************** ******************************************************************************
@ -179,37 +93,35 @@
* are not interested in, in order to get longer traces. * are not interested in, in order to get longer traces.
*****************************************************************************/ *****************************************************************************/
/****************************************************************************** /**
* TRC_CFG_HEAP_SIZE_BELOW_16M * @def TRC_CFG_HEAP_SIZE_BELOW_16M
* * @brief An integer constant that can be used to reduce the buffer usage of memory
* 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
* 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
* 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.
* lower 24 bits only. If 0, you get the full 32-bit addresses. *
* * Default value is 0.
* Default value is 0. */
******************************************************************************/
#define TRC_CFG_HEAP_SIZE_BELOW_16M 0 #define TRC_CFG_HEAP_SIZE_BELOW_16M 0
/****************************************************************************** /**
* TRC_CFG_USE_IMPLICIT_IFE_RULES * @def TRC_CFG_USE_IMPLICIT_IFE_RULES
* * @brief Macro which should be defined as either zero (0) or one (1).
* Macro which should be defined as either zero (0) or one (1).
* Default is 1. * Default is 1.
* *
* Tracealyzer groups the events into "instances" based on Instance Finish * Tracealyzer groups the events into "instances" based on Instance Finish
* Events (IFEs), produced either by default rules or calls to the recorder * Events (IFEs), produced either by default rules or calls to the recorder
* functions vTraceInstanceFinishedNow and vTraceInstanceFinishedNext. * functions xTraceTaskInstanceFinishedNow and xTraceTaskInstanceFinishedNext.
* *
* If TRC_CFG_USE_IMPLICIT_IFE_RULES is one (1), the default IFE rules is * 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. * used, resulting in a "typical" grouping of events into instances.
* If these rules don't give appropriate instances in your case, you can * If these rules don't give appropriate instances in your case, you can
* override the default rules using vTraceInstanceFinishedNow/Next for one * override the default rules using xTraceTaskInstanceFinishedNow/Next for one
* or several tasks. The default IFE rules are then disabled for those tasks. * 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 * If TRC_CFG_USE_IMPLICIT_IFE_RULES is zero (0), the implicit IFE rules are
* disabled globally. You must then call vTraceInstanceFinishedNow or * disabled globally. You must then call xTraceTaskInstanceFinishedNow or
* vTraceInstanceFinishedNext to manually group the events into instances, * xTraceTaskInstanceFinishedNext to manually group the events into instances,
* otherwise the tasks will appear a single long instance. * otherwise the tasks will appear a single long instance.
* *
* The default IFE rules count the following events as "instance finished": * The default IFE rules count the following events as "instance finished":
@ -217,16 +129,12 @@
* - Task suspend * - Task suspend
* - Blocking on "input" operations, i.e., when the task is waiting for the * - 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. * next a message/signal/event. But only if this event is blocking.
* */
* For details, see trcSnapshotKernelPort.h and look for references to the
* macro trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED.
*****************************************************************************/
#define TRC_CFG_USE_IMPLICIT_IFE_RULES 1 #define TRC_CFG_USE_IMPLICIT_IFE_RULES 1
/****************************************************************************** /**
* TRC_CFG_USE_16BIT_OBJECT_HANDLES * @def TRC_CFG_USE_16BIT_OBJECT_HANDLES
* * @brief Macro which should be defined as either zero (0) or one (1).
* 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 * 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 * objects such as tasks and queues. This limits the supported number of
@ -244,31 +152,12 @@
* NOTE: An object with handle above 255 will use an extra 4-byte record in * 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 * the event buffer whenever the object is referenced. Moreover, some internal
* tables in the recorder gets slightly larger when using 16-bit handles. * tables in the recorder gets slightly larger when using 16-bit handles.
*****************************************************************************/ */
#define TRC_CFG_USE_16BIT_OBJECT_HANDLES 0 #define TRC_CFG_USE_16BIT_OBJECT_HANDLES 0
/****************************************************************************** /**
* TRC_CFG_USE_TRACE_ASSERT * @def TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER
* * @brief Macro which should be defined as an integer value.
* Macro which should be defined as either zero (0) or one (1).
* Default is 1.
*
* If this is one (1), the TRACE_ASSERT macro (used at various locations in the
* trace recorder) will verify that a relevant condition is true.
* If the condition is false, prvTraceError() will be called, which stops the
* recording and stores an error message that is displayed when opening the
* trace in Tracealyzer.
*
* This is used on several places in the recorder code for sanity checks on
* parameters. Can be switched off to reduce the footprint of the tracing, but
* we recommend to have it enabled initially.
*****************************************************************************/
#define TRC_CFG_USE_TRACE_ASSERT 1
/*******************************************************************************
* TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER
*
* Macro which should be defined as an integer value.
* *
* Set TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER to 1 to enable the * Set TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER to 1 to enable the
* separate user event buffer (UB). * separate user event buffer (UB).
@ -291,14 +180,17 @@
* repeating events, using the same format string within each channel. * repeating events, using the same format string within each channel.
* *
* Examples: * Examples:
* * TraceStringHandle_t chn1;
* traceString chn1 = xTraceRegisterString("Channel 1"); * TraceStringHandle_t fmt1;
* traceString fmt1 = xTraceRegisterString("Event!"); * xTraceStringRegister("Channel 1", &chn1);
* xTraceStringRegister("Event!", &fmt1);
* traceUBChannel UBCh1 = xTraceRegisterUBChannel(chn1, fmt1); * traceUBChannel UBCh1 = xTraceRegisterUBChannel(chn1, fmt1);
* *
* traceString chn2 = xTraceRegisterString("Channel 2"); * TraceStringHandle_t chn2;
* traceString fmt2 = xTraceRegisterString("X: %d, Y: %d"); * TraceStringHandle_t fmt2;
* traceUBChannel UBCh2 = xTraceRegisterUBChannel(chn2, fmt2); * xTraceStringRegister("Channel 2", &chn2);
* xTraceStringRegister("X: %d, Y: %d", &fmt2);
* traceUBChannel UBCh2 = xTraceRegisterUBChannel(chn2, fmt2);
* *
* // Result in "[Channel 1] Event!" * // Result in "[Channel 1] Event!"
* vTraceUBEvent(UBCh1); * vTraceUBEvent(UBCh1);
@ -306,7 +198,7 @@
* // Result in "[Channel 2] X: 23, Y: 19" * // Result in "[Channel 2] X: 23, Y: 19"
* vTraceUBData(UBCh2, 23, 19); * vTraceUBData(UBCh2, 23, 19);
* *
* You can also use the other user event functions, like vTracePrintF. * 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. * 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 * vTracePrintF then looks up the correct UB channel based on the
* provided channel name and format string, or creates a new UB channel * provided channel name and format string, or creates a new UB channel
@ -315,30 +207,27 @@
* be stored using %s and with the string as an argument. * be stored using %s and with the string as an argument.
* *
* // Creates a new UB channel ("Channel 2", "%Z: %d") * // Creates a new UB channel ("Channel 2", "%Z: %d")
* vTracePrintF(chn2, "%Z: %d", value1); * xTracePrintF(chn2, "%Z: %d", value1);
* *
* // Finds the existing UB channel * // Finds the existing UB channel
* vTracePrintF(chn2, "%Z: %d", value2); * xTracePrintF(chn2, "%Z: %d", value2);
*/
******************************************************************************/
#define TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER 0 #define TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER 0
/******************************************************************************* /**
* TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE * @def TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE
* * @brief Macro which should be defined as an integer value.
* Macro which should be defined as an integer value.
* *
* This defines the capacity of the user event buffer (UB), in number of slots. * 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. * A single user event can use multiple slots, depending on the arguments.
* *
* Only applicable if TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER is 1. * Only applicable if TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER is 1.
******************************************************************************/ */
#define TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE 200 #define TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE 200
/******************************************************************************* /**
* TRC_CFG_UB_CHANNELS * @def TRC_CFG_UB_CHANNELS
* * @brief Macro which should be defined as an integer value.
* Macro which should be defined as an integer value.
* *
* This defines the number of User Event Buffer Channels (UB channels). * This defines the number of User Event Buffer Channels (UB channels).
* These are used to structure the events when using the separate user * These are used to structure the events when using the separate user
@ -346,32 +235,11 @@
* a default format string for the channel. * a default format string for the channel.
* *
* Only applicable if TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER is 1. * Only applicable if TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER is 1.
******************************************************************************/ */
#define TRC_CFG_UB_CHANNELS 32 #define TRC_CFG_UB_CHANNELS 32
/******************************************************************************* #ifdef __cplusplus
* TRC_CFG_ISR_TAILCHAINING_THRESHOLD }
* #endif
* 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
#endif /*TRC_SNAPSHOT_CONFIG_H*/ #endif /*TRC_SNAPSHOT_CONFIG_H*/

View file

@ -1,47 +1,13 @@
/******************************************************************************* /*
* Trace Recorder Library for Tracealyzer v4.4.0 * Trace Recorder for Tracealyzer v4.6.0
* Percepio AB, www.percepio.com * Copyright 2021 Percepio AB
* www.percepio.com
* *
* trcStreamingConfig.h * SPDX-License-Identifier: Apache-2.0
* *
* Configuration parameters for the trace recorder library in streaming mode. * Configuration parameters for the trace recorder library in streaming mode.
* Read more at http://percepio.com/2016/10/05/rtos-tracing/ * Read more at http://percepio.com/2016/10/05/rtos-tracing/
* */
* Terms of Use
* This file is part of the trace recorder library (RECORDER), which is the
* intellectual property of Percepio AB (PERCEPIO) and provided under a
* license as follows.
* The RECORDER may be used free of charge for the purpose of recording data
* intended for analysis in PERCEPIO products. It may not be used or modified
* for other purposes without explicit permission from PERCEPIO.
* You may distribute the RECORDER in its original source code form, assuming
* this text (terms of use, disclaimer, copyright notice) is unchanged. You are
* allowed to distribute the RECORDER with minor modifications intended for
* configuration or porting of the RECORDER, e.g., to allow using it on a
* specific processor, processor family or with a specific communication
* interface. Any such modifications should be documented directly below
* this comment block.
*
* Disclaimer
* The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty
* as to its use or performance. PERCEPIO does not and cannot warrant the
* performance or results you may obtain by using the RECORDER or documentation.
* PERCEPIO make no warranties, express or implied, as to noninfringement of
* third party rights, merchantability, or fitness for any particular purpose.
* In no event will PERCEPIO, its technology partners, or distributors be liable
* to you for any consequential, incidental or special damages, including any
* lost profits or lost savings, even if a representative of PERCEPIO has been
* advised of the possibility of such damages, or for any claim by any third
* party. Some jurisdictions do not allow the exclusion or limitation of
* incidental, consequential or special damages, or the exclusion of implied
* warranties or limitations on how long an implied warranty may last, so the
* above limitations may not apply to you.
*
* Tabs are used for indent in this file (1 tab = 4 spaces)
*
* Copyright Percepio AB, 2018.
* www.percepio.com
******************************************************************************/
#ifndef TRC_STREAMING_CONFIG_H #ifndef TRC_STREAMING_CONFIG_H
#define TRC_STREAMING_CONFIG_H #define TRC_STREAMING_CONFIG_H
@ -50,92 +16,33 @@
extern "C" { extern "C" {
#endif #endif
/******************************************************************************* /**
* Configuration Macro: TRC_CFG_SYMBOL_TABLE_SLOTS * @def TRC_CFG_ENTRY_SLOTS
* * @brief The maximum number of objects and symbols that can be stored. This includes:
* The maximum number of symbols names that can be stored. This includes:
* - Task names * - Task names
* - Named ISRs (vTraceSetISRProperties) * - Named ISRs (vTraceSetISRProperties)
* - Named kernel objects (vTraceStoreKernelObjectName) * - Named kernel objects (vTraceStoreKernelObjectName)
* - User event channels (xTraceRegisterString) * - User event channels (xTraceStringRegister)
* *
* If this value is too small, not all symbol names will be stored and the * If this value is too small, not all symbol names will be stored and the
* trace display will be affected. In that case, there will be warnings * trace display will be affected. 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_SYMBOL_TABLE_SLOTS 40 #define TRC_CFG_ENTRY_SLOTS 50
/******************************************************************************* /**
* Configuration Macro: TRC_CFG_SYMBOL_MAX_LENGTH * @def TRC_CFG_ENTRY_SYMBOL_MAX_LENGTH
* * @brief The maximum length of symbol names, including:
* The maximum length of symbol names, including:
* - Task names * - Task names
* - Named ISRs (vTraceSetISRProperties) * - Named ISRs (vTraceSetISRProperties)
* - Named kernel objects (vTraceStoreKernelObjectName) * - Named kernel objects (vTraceStoreKernelObjectName)
* - User event channel names (xTraceRegisterString) * - User event channel names (xTraceStringRegister)
* *
* If longer symbol names are used, they will be truncated by the recorder, * If longer symbol names are used, they will be truncated by the recorder,
* 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_SYMBOL_MAX_LENGTH 25 #define TRC_CFG_ENTRY_SYMBOL_MAX_LENGTH 32
/*******************************************************************************
* Configuration Macro: TRC_CFG_OBJECT_DATA_SLOTS
*
* The maximum number of object data entries (used for task priorities) that can
* be stored at the same time. Must be sufficient for all tasks, otherwise there
* will be warnings (as User Events) from TzCtrl task, that monitors this.
******************************************************************************/
#define TRC_CFG_OBJECT_DATA_SLOTS 40
/*******************************************************************************
* Configuration Macro: TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT
*
* Specifies the number of pages used by the paged event buffer.
* This may need to be increased if there are a lot of missed events.
*
* Note: not used by the J-Link RTT stream port (see trcStreamingPort.h instead)
******************************************************************************/
#define TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT 10
/*******************************************************************************
* Configuration Macro: TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE
*
* Specifies the size of each page in the paged event buffer. This can be tuned
* to match any internal low-level buffers used by the streaming interface, like
* the Ethernet MTU (Maximum Transmission Unit). However, since the currently
* active page can't be transfered, having more but smaller pages is more
* efficient with respect memory usage, than having a few large pages.
*
* Note: not used by the J-Link RTT stream port (see trcStreamingPort.h instead)
******************************************************************************/
#define TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE 500
/*******************************************************************************
* TRC_CFG_ISR_TAILCHAINING_THRESHOLD
*
* 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
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -0,0 +1,55 @@
/*
* 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;
}

View file

@ -0,0 +1,38 @@
/*
* 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();
};

View file

@ -0,0 +1,30 @@
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.

View file

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

View file

@ -1,8 +1,9 @@
/******************************************************************************* /*
* Trace Recorder Library for Tracealyzer v4.4.0 * Trace Recorder for Tracealyzer v4.6.0
* Percepio AB, www.percepio.com * Copyright 2021 Percepio AB
* www.percepio.com
* *
* trcStreamingPort.c * SPDX-License-Identifier: Apache-2.0
* *
* This stream port provides trace streaming using the Amazon FreeRTOS sockets * 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 * layer and is intended for streaming over Wifi directly to a computer on the
@ -23,7 +24,7 @@
* the target system connects. * the target system connects.
* *
* And don't forget to enter the IP address of the Tracealyzer host computer * And don't forget to enter the IP address of the Tracealyzer host computer
* in trcStreamingPort.h. * in trcStreamPort.h.
* *
* NOTES: * NOTES:
* *
@ -89,45 +90,10 @@
* *
* See also http://percepio.com/2016/10/05/rtos-tracing * See also http://percepio.com/2016/10/05/rtos-tracing
* and https://percepio.com/2018/10/11/tuning-your-custom-trace-streaming/ * and https://percepio.com/2018/10/11/tuning-your-custom-trace-streaming/
* */
* Terms of Use
* This file is part of the trace recorder library (RECORDER), which is the
* intellectual property of Percepio AB (PERCEPIO) and provided under a
* license as follows.
* The RECORDER may be used free of charge for the purpose of recording data
* intended for analysis in PERCEPIO products. It may not be used or modified
* for other purposes without explicit permission from PERCEPIO.
* You may distribute the RECORDER in its original source code form, assuming
* this text (terms of use, disclaimer, copyright notice) is unchanged. You are
* allowed to distribute the RECORDER with minor modifications intended for
* configuration or porting of the RECORDER, e.g., to allow using it on a
* specific processor, processor family or with a specific communication
* interface. Any such modifications should be documented directly below
* this comment block.
*
* Disclaimer
* The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty
* as to its use or performance. PERCEPIO does not and cannot warrant the
* performance or results you may obtain by using the RECORDER or documentation.
* PERCEPIO make no warranties, express or implied, as to noninfringement of
* third party rights, merchantability, or fitness for any particular purpose.
* In no event will PERCEPIO, its technology partners, or distributors be liable
* to you for any consequential, incidental or special damages, including any
* lost profits or lost savings, even if a representative of PERCEPIO has been
* advised of the possibility of such damages, or for any claim by any third
* party. Some jurisdictions do not allow the exclusion or limitation of
* incidental, consequential or special damages, or the exclusion of implied
* warranties or limitations on how long an implied warranty may last, so the
* above limitations may not apply to you.
*
* Tabs are used for indent in this file (1 tab = 4 spaces)
*
* Copyright Percepio AB, 2018.
* www.percepio.com
******************************************************************************/
#ifndef TRC_STREAMING_PORT_H #ifndef TRC_STREAM_PORT_H
#define TRC_STREAMING_PORT_H #define TRC_STREAM_PORT_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -158,4 +124,4 @@ int32_t prvWriteToSocket(void* ptrData, uint32_t size, int32_t* ptrBytesWritten)
} }
#endif #endif
#endif /* TRC_STREAMING_PORT_H */ #endif /* TRC_STREAM_PORT_H */

View file

@ -1,8 +1,9 @@
/******************************************************************************* /*
* Trace Recorder Library for Tracealyzer v4.4.0 * Trace Recorder for Tracealyzer v4.6.0
* Percepio AB, www.percepio.com * Copyright 2021 Percepio AB
* www.percepio.com
* *
* trcStreamingPort.c * SPDX-License-Identifier: Apache-2.0
* *
* This stream port provides trace streaming using the Amazon FreeRTOS sockets * 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 * layer and is intended for streaming over Wifi directly to a computer on the
@ -23,7 +24,7 @@
* the target system connects. * the target system connects.
* *
* And don't forget to enter the IP address of the Tracealyzer host computer * And don't forget to enter the IP address of the Tracealyzer host computer
* in trcStreamingPort.h. * in trcStreamPort.h.
* *
* NOTES: * NOTES:
* *
@ -89,55 +90,20 @@
* *
* See also http://percepio.com/2016/10/05/rtos-tracing * See also http://percepio.com/2016/10/05/rtos-tracing
* and https://percepio.com/2018/10/11/tuning-your-custom-trace-streaming/ * and https://percepio.com/2018/10/11/tuning-your-custom-trace-streaming/
* */
* Terms of Use
* This file is part of the trace recorder library (RECORDER), which is the #include <trcRecorder.h>
* intellectual property of Percepio AB (PERCEPIO) and provided under a
* license as follows.
* The RECORDER may be used free of charge for the purpose of recording data
* intended for analysis in PERCEPIO products. It may not be used or modified
* for other purposes without explicit permission from PERCEPIO.
* You may distribute the RECORDER in its original source code form, assuming
* this text (terms of use, disclaimer, copyright notice) is unchanged. You are
* allowed to distribute the RECORDER with minor modifications intended for
* configuration or porting of the RECORDER, e.g., to allow using it on a
* specific processor, processor family or with a specific communication
* interface. Any such modifications should be documented directly below
* this comment block.
*
* Disclaimer
* The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty
* as to its use or performance. PERCEPIO does not and cannot warrant the
* performance or results you may obtain by using the RECORDER or documentation.
* PERCEPIO make no warranties, express or implied, as to noninfringement of
* third party rights, merchantability, or fitness for any particular purpose.
* In no event will PERCEPIO, its technology partners, or distributors be liable
* to you for any consequential, incidental or special damages, including any
* lost profits or lost savings, even if a representative of PERCEPIO has been
* advised of the possibility of such damages, or for any claim by any third
* party. Some jurisdictions do not allow the exclusion or limitation of
* incidental, consequential or special damages, or the exclusion of implied
* warranties or limitations on how long an implied warranty may last, so the
* above limitations may not apply to you.
*
* Tabs are used for indent in this file (1 tab = 4 spaces)
*
* Copyright Percepio AB, 2018.
* www.percepio.com
******************************************************************************/
#include "trcRecorder.h"
#if (TRC_USE_TRACEALYZER_RECORDER == 1) #if (TRC_USE_TRACEALYZER_RECORDER == 1)
#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
#include "aws_secure_sockets.h" #include <aws_secure_sockets.h>
#include "trcExtensions.h"
SocketsSockaddr_t addr = {sizeof(SocketsSockaddr_t), SOCKETS_AF_INET, 0, 0}; 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) #define IPv4(a,b,c,d) (uint32_t)((d << 24) + (c << 16) + (b << 8) + a)
Socket_t sock = NULL; Socket_t sock = 0;
void prvInitSocket(void) void prvInitSocket(void)
{ {
@ -170,7 +136,7 @@ int32_t prvWriteToSocket(void* ptrData, uint32_t size, int32_t* ptrBytesWritten)
{ {
uint32_t bytesWritten = SOCKETS_Send(sock, ptrData, size, 0); uint32_t bytesWritten = SOCKETS_Send(sock, ptrData, size, 0);
if (ptrBytesWritten != NULL) if (ptrBytesWritten != 0)
*ptrBytesWritten = (int32_t)bytesWritten; *ptrBytesWritten = (int32_t)bytesWritten;
if (bytesWritten != size) if (bytesWritten != size)

View file

@ -1,8 +1,11 @@
/************************************************************ /*
* Percepio Tracealyzer - ITM Trace Exporter for Keil uVision * Trace Recorder for Tracealyzer v4.6.0
* Copyright (c) 2018, Percepio AB. * Copyright 2021 Percepio AB
* https://percepio.com * www.percepio.com
************************************************************/ *
* SPDX-License-Identifier: Apache-2.0
*
*/
FUNC void tzSetEnable(int enable) FUNC void tzSetEnable(int enable)
{ {

View file

@ -1,11 +1,12 @@
Tracealyzer Stream Port for ARM Cortex-M ITM Tracealyzer Stream Port for ARM Cortex-M ITM
Percepio AB
www.percepio.com
-------------------------------------------- --------------------------------------------
2018-05-04
This directory contains a "stream port" for the Tracealyzer recorder library, 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 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 Tracealyzer RTOS trace. The stream port is defined by a set of macros in
trcStreamingPort.h, found in the "include" directory. trcStreamPort.h, found in the "include" directory.
This particular stream port targets ARM's ITM interface, which together with 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 a fast debug probe such as a Keil ULINKpro or ULINKplus provides excellent
@ -18,15 +19,16 @@ see Percepio Application Note PA-021, https://percepio.com/2018/05/04/keil-itm-s
To setup IAR Embedded Workbench for ITM tracing with an IAR I-Jet, To setup IAR Embedded Workbench for ITM tracing with an IAR I-Jet,
see Percepio Application Note PA-023, https://percepio.com/iar see Percepio Application Note PA-023, https://percepio.com/iar
Learning more: 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) - Tracealyzer User Manual (Help -> User Manual)
- https://percepio.com/gettingstarted - https://percepio.com/gettingstarted
- Percepio Application Note PA-021 (Keil), https://percepio.com/2018/05/04/keil-itm-support/ - 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-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 ITM trace, https://percepio.com/2016/06/09/arm-itm/
- About the recorder and custom streaming, http://percepio.com/2016/10/05/rtos-tracing - About the recorder and custom streaming, http://percepio.com/2016/10/05/rtos-tracing
For questions, please contact support@percepio.com For questions, please contact support@percepio.com
Percepio AB
www.percepio.com

View file

@ -0,0 +1,35 @@
/*
* 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 */

View file

@ -0,0 +1,113 @@
/*
* 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 */

View file

@ -1,137 +0,0 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcStreamingPort.h
*
* The interface definitions for trace streaming ("stream ports").
* This "stream port" sets up the recorder to use 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).
*
*
* Terms of Use
* This file is part of the trace recorder library (RECORDER), which is the
* intellectual property of Percepio AB (PERCEPIO) and provided under a
* license as follows.
* The RECORDER may be used free of charge for the purpose of recording data
* intended for analysis in PERCEPIO products. It may not be used or modified
* for other purposes without explicit permission from PERCEPIO.
* You may distribute the RECORDER in its original source code form, assuming
* this text (terms of use, disclaimer, copyright notice) is unchanged. You are
* allowed to distribute the RECORDER with minor modifications intended for
* configuration or porting of the RECORDER, e.g., to allow using it on a
* specific processor, processor family or with a specific communication
* interface. Any such modifications should be documented directly below
* this comment block.
*
* Disclaimer
* The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty
* as to its use or performance. PERCEPIO does not and cannot warrant the
* performance or results you may obtain by using the RECORDER or documentation.
* PERCEPIO make no warranties, express or implied, as to noninfringement of
* third party rights, merchantability, or fitness for any particular purpose.
* In no event will PERCEPIO, its technology partners, or distributors be liable
* to you for any consequential, incidental or special damages, including any
* lost profits or lost savings, even if a representative of PERCEPIO has been
* advised of the possibility of such damages, or for any claim by any third
* party. Some jurisdictions do not allow the exclusion or limitation of
* incidental, consequential or special damages, or the exclusion of implied
* warranties or limitations on how long an implied warranty may last, so the
* above limitations may not apply to you.
*
* Tabs are used for indent in this file (1 tab = 4 spaces)
*
* Copyright Percepio AB, 2018.
* www.percepio.com
******************************************************************************/
#ifndef TRC_STREAMING_PORT_H
#define TRC_STREAMING_PORT_H
#ifdef __cplusplus
extern "C" {
#endif
int32_t itm_write(void* ptrData, uint32_t size, int32_t* ptrBytesWritten);
int32_t read_from_host(void* ptrData, uint32_t size, int32_t* ptrBytesRead);
/*******************************************************************************
* TRC_CFG_ITM_PORT
*
* Possible 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_ITM_PORT 1
#if (TRC_CFG_ITM_PORT < 0) || (TRC_CFG_ITM_PORT > 31)
#error "Bad ITM port selected."
#endif
// Not used for ITM - no RAM buffer...
#define TRC_STREAM_PORT_ALLOCATE_FIELDS()
// Not used for ITM - assume the IDE configures the ITM setup
#define TRC_STREAM_PORT_INIT()
/* Important for the ITM port - no RAM buffer, direct writes. In most other ports this can be skipped (default is 1) */
#define TRC_STREAM_PORT_USE_INTERNAL_BUFFER 0
#define TRC_STREAM_PORT_WRITE_DATA(_ptrData, _size, _ptrBytesWritten) itm_write(_ptrData, _size, _ptrBytesWritten)
#define TRC_STREAM_PORT_READ_DATA(_ptrData, _size, _ptrBytesRead) read_from_host(_ptrData, _size, _ptrBytesRead)
#ifdef __cplusplus
}
#endif
#endif /* TRC_STREAMING_PORT_H */

View file

@ -1,8 +1,9 @@
/******************************************************************************* /*
* Trace Recorder Library for Tracealyzer v4.4.0 * Trace Recorder for Tracealyzer v4.6.0
* Percepio AB, www.percepio.com * Copyright 2021 Percepio AB
* www.percepio.com
* *
* trcStreamingPort.c * SPDX-License-Identifier: Apache-2.0
* *
* Supporting functions for trace streaming, used by the "stream ports" * Supporting functions for trace streaming, used by the "stream ports"
* for reading and writing data to the interface. * for reading and writing data to the interface.
@ -55,115 +56,106 @@
* buffer, monitored by the recorder library, using the debugger IDE. * buffer, monitored by the recorder library, using the debugger IDE.
* See trcStreamingPort.c and also the example macro for Keil uVision * See trcStreamingPort.c and also the example macro for Keil uVision
* (Keil-uVision-Tracealyzer-ITM-Exporter.ini). * (Keil-uVision-Tracealyzer-ITM-Exporter.ini).
* */
* Terms of Use
* This file is part of the trace recorder library (RECORDER), which is the
* intellectual property of Percepio AB (PERCEPIO) and provided under a
* license as follows.
* The RECORDER may be used free of charge for the purpose of recording data
* intended for analysis in PERCEPIO products. It may not be used or modified
* for other purposes without explicit permission from PERCEPIO.
* You may distribute the RECORDER in its original source code form, assuming
* this text (terms of use, disclaimer, copyright notice) is unchanged. You are
* allowed to distribute the RECORDER with minor modifications intended for
* configuration or porting of the RECORDER, e.g., to allow using it on a
* specific processor, processor family or with a specific communication
* interface. Any such modifications should be documented directly below
* this comment block.
*
* Disclaimer
* The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty
* as to its use or performance. PERCEPIO does not and cannot warrant the
* performance or results you may obtain by using the RECORDER or documentation.
* PERCEPIO make no warranties, express or implied, as to noninfringement of
* third party rights, merchantability, or fitness for any particular purpose.
* In no event will PERCEPIO, its technology partners, or distributors be liable
* to you for any consequential, incidental or special damages, including any
* lost profits or lost savings, even if a representative of PERCEPIO has been
* advised of the possibility of such damages, or for any claim by any third
* party. Some jurisdictions do not allow the exclusion or limitation of
* incidental, consequential or special damages, or the exclusion of implied
* warranties or limitations on how long an implied warranty may last, so the
* above limitations may not apply to you.
*
* Tabs are used for indent in this file (1 tab = 4 spaces)
*
* Copyright Percepio AB, 2018.
* www.percepio.com
******************************************************************************/
#include "trcRecorder.h" #include <trcRecorder.h>
#if (TRC_USE_TRACEALYZER_RECORDER == 1) #if (TRC_USE_TRACEALYZER_RECORDER == 1)
#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
static void itm_write_32(uint32_t data); 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(). /* These variables are used for reading commands from the host, using read_from_host().
* This is not required if using vTraceEnable(TRC_START). * This is not required if using vTraceEnable(TRC_START).
* A debugger IDE may write to these functions using a macro. * A debugger IDE may write to these functions using a macro.
* An example for Keil is included (Keil-uVision-Tracealyzer-ITM-Exporter.ini). */ * An example for Keil is included (Keil-uVision-Tracealyzer-ITM-Exporter.ini). */
volatile int32_t tz_host_command_bytes_to_read = 0; #define itm_write_32(__data) \
volatile char tz_host_command_data[32]; {\
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 */ /* This reads "command" data from a RAM buffer, written by a host macro in the debugger */
int32_t read_from_host(void* ptrData, uint32_t size, int32_t* ptrBytesRead) traceResult prvTraceItmRead(void* ptrData, uint32_t uiSize, int32_t* piBytesRead)
{ {
if ( tz_host_command_bytes_to_read > 0) 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)
{ {
int i; if (tz_host_command_bytes_to_read != (int32_t)uiSize)
uint8_t * bytesBuffer = (uint8_t*) ptrData;
if (ptrBytesRead != NULL)
*ptrBytesRead = (int32_t)tz_host_command_bytes_to_read;
if (tz_host_command_bytes_to_read != size)
{ {
return -1; /* Sanity check. */
return TRC_FAIL;
} }
for (i=0; i < tz_host_command_bytes_to_read; i++) *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]; bytesBuffer[i] = tz_host_command_data[i];
} }
/* Reset */
tz_host_command_bytes_to_read = 0; tz_host_command_bytes_to_read = 0;
} }
return 0; return TRC_SUCCESS;
} }
static void itm_write_32(uint32_t data) traceResult xTraceStreamPortInitialize(TraceStreamPortBuffer_t* pxBuffer)
{ {
if ((CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk) && // Trace enabled TRC_ASSERT_EQUAL_SIZE(TraceStreamPortBuffer_t, TraceStreamPortFile_t);
(ITM->TCR & ITM_TCR_ITMENA_Msk) && // ITM enabled
(ITM->TER & (1UL << TRC_CFG_ITM_PORT))) // ITM port enabled
{
while (ITM->PORT[TRC_CFG_ITM_PORT].u32 == 0); // Block until room in ITM FIFO - This stream port is always in "blocking mode", since intended for high-speed ITM!
ITM->PORT[TRC_CFG_ITM_PORT].u32 = data; // Write the data
}
}
/* This is assumed to execute from within the recorder, with interrupts disabled */ TRC_ASSERT(pxBuffer != 0);
int32_t itm_write(void* ptrData, uint32_t size, int32_t* ptrBytesWritten)
{
uint32_t bytesWritten = 0;
uint32_t* ptr32 = (uint32_t*)ptrData;
if (size % 4 != 0) return -2; pxStreamPortFile = (TraceStreamPortFile_t*)pxBuffer;
while(bytesWritten < size) return TRC_SUCCESS;
{
itm_write_32(*ptr32);
ptr32++;
bytesWritten += 4;
}
*ptrBytesWritten = bytesWritten;
return 0;
} }
#endif #endif
#endif #endif

View file

@ -1,19 +1,18 @@
Tracealyzer Stream Port for Files Tracealyzer Stream Port for Files
Percepio AB
www.percepio.com
------------------------------------------------- -------------------------------------------------
This directory contains a "stream port" for the Tracealyzer recorder library, 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 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 Tracealyzer RTOS trace. The stream port is defined by a set of macros in
trcStreamingPort.h, found in the "include" directory. trcStreamPort.h, found in the "include" directory.
This particular stream port is for streaming to a file via stdio.h (fwrite). This particular stream port is for streaming to a file via stdio.h (fwrite).
To use this stream port, make sure that include/trcStreamingPort.h is found 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 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 add all included source files to your build. Make sure no other versions of
trcStreamingPort.h are included by mistake! trcStreamPort.h are included by mistake!
See also http://percepio.com/2016/10/05/rtos-tracing. See also http://percepio.com/2016/10/05/rtos-tracing.
Percepio AB
www.percepio.com

View file

@ -0,0 +1,39 @@
/*
* 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 */

View file

@ -0,0 +1,84 @@
/*
* 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 */

View file

@ -1,87 +0,0 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcStreamingPort.h
*
* The interface definitions for trace streaming ("stream ports").
* This "stream port" sets up the recorder to stream the trace to file.
*
* Terms of Use
* This file is part of the trace recorder library (RECORDER), which is the
* intellectual property of Percepio AB (PERCEPIO) and provided under a
* license as follows.
* The RECORDER may be used free of charge for the purpose of recording data
* intended for analysis in PERCEPIO products. It may not be used or modified
* for other purposes without explicit permission from PERCEPIO.
* You may distribute the RECORDER in its original source code form, assuming
* this text (terms of use, disclaimer, copyright notice) is unchanged. You are
* allowed to distribute the RECORDER with minor modifications intended for
* configuration or porting of the RECORDER, e.g., to allow using it on a
* specific processor, processor family or with a specific communication
* interface. Any such modifications should be documented directly below
* this comment block.
*
* Disclaimer
* The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty
* as to its use or performance. PERCEPIO does not and cannot warrant the
* performance or results you may obtain by using the RECORDER or documentation.
* PERCEPIO make no warranties, express or implied, as to noninfringement of
* third party rights, merchantability, or fitness for any particular purpose.
* In no event will PERCEPIO, its technology partners, or distributors be liable
* to you for any consequential, incidental or special damages, including any
* lost profits or lost savings, even if a representative of PERCEPIO has been
* advised of the possibility of such damages, or for any claim by any third
* party. Some jurisdictions do not allow the exclusion or limitation of
* incidental, consequential or special damages, or the exclusion of implied
* warranties or limitations on how long an implied warranty may last, so the
* above limitations may not apply to you.
*
* Tabs are used for indent in this file (1 tab = 4 spaces)
*
* Copyright Percepio AB, 2018.
* www.percepio.com
******************************************************************************/
#ifndef TRC_STREAMING_PORT_H
#define TRC_STREAMING_PORT_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
int32_t writeToFile(void* data, uint32_t size, int32_t *ptrBytesWritten);
void closeFile(void);
void openFile(char* fileName);
/* This define will determine whether to use the internal PagedEventBuffer or not.
If file writing creates additional trace events (i.e. it uses semaphores or mutexes),
then the paged event buffer must be enabled to avoid infinite recursion. */
#define TRC_STREAM_PORT_USE_INTERNAL_BUFFER 1
#define TRC_STREAM_PORT_READ_DATA(_ptrData, _size, _ptrBytesRead) 0 /* Does not read commands from Tz (yet) */
#define TRC_STREAM_PORT_WRITE_DATA(_ptrData, _size, _ptrBytesSent) writeToFile(_ptrData, _size, _ptrBytesSent)
#if (TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC)
#define TRC_STREAM_PORT_MALLOC() \
_TzTraceData = TRC_PORT_MALLOC((TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT) * (TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE));
extern char* _TzTraceData;
#else
#define TRC_STREAM_PORT_MALLOC() /* Custom or static allocation. Not used. */
#endif
#define TRC_STREAM_PORT_INIT() \
TRC_STREAM_PORT_MALLOC(); \
openFile("trace.psf")
#define TRC_STREAM_PORT_ON_TRACE_END() closeFile()
#ifdef __cplusplus
}
#endif
#endif /* TRC_STREAMING_PORT_H */

View file

@ -0,0 +1,82 @@
/*
* 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)*/

View file

@ -1,103 +0,0 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcStreamingPort.c
*
* 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.
*
* Terms of Use
* This file is part of the trace recorder library (RECORDER), which is the
* intellectual property of Percepio AB (PERCEPIO) and provided under a
* license as follows.
* The RECORDER may be used free of charge for the purpose of recording data
* intended for analysis in PERCEPIO products. It may not be used or modified
* for other purposes without explicit permission from PERCEPIO.
* You may distribute the RECORDER in its original source code form, assuming
* this text (terms of use, disclaimer, copyright notice) is unchanged. You are
* allowed to distribute the RECORDER with minor modifications intended for
* configuration or porting of the RECORDER, e.g., to allow using it on a
* specific processor, processor family or with a specific communication
* interface. Any such modifications should be documented directly below
* this comment block.
*
* Disclaimer
* The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty
* as to its use or performance. PERCEPIO does not and cannot warrant the
* performance or results you may obtain by using the RECORDER or documentation.
* PERCEPIO make no warranties, express or implied, as to noninfringement of
* third party rights, merchantability, or fitness for any particular purpose.
* In no event will PERCEPIO, its technology partners, or distributors be liable
* to you for any consequential, incidental or special damages, including any
* lost profits or lost savings, even if a representative of PERCEPIO has been
* advised of the possibility of such damages, or for any claim by any third
* party. Some jurisdictions do not allow the exclusion or limitation of
* incidental, consequential or special damages, or the exclusion of implied
* warranties or limitations on how long an implied warranty may last, so the
* above limitations may not apply to you.
*
* Tabs are used for indent in this file (1 tab = 4 spaces)
*
* Copyright Percepio AB, 2018.
* www.percepio.com
******************************************************************************/
#include "trcRecorder.h"
#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
#if (TRC_USE_TRACEALYZER_RECORDER == 1)
FILE* traceFile = NULL;
void openFile(char* fileName)
{
if (traceFile == NULL)
{
errno_t err = fopen_s(&traceFile, fileName, "wb");
if (err != 0)
{
printf("Could not open trace file, error code %d.\n", err);
exit(-1);
}
else {
printf("Trace file created.\n");
}
}
}
int32_t writeToFile(void* data, uint32_t size, int32_t *ptrBytesWritten)
{
int32_t written = 0;
if (traceFile != NULL)
{
written = fwrite(data, 1, size, traceFile);
}
else
{
written = 0;
}
if (ptrBytesWritten != 0)
*ptrBytesWritten = written;
if ((int32_t)size == written)
return 0;
else
return -1;
}
void closeFile(void)
{
if (traceFile != NULL)
{
fclose(traceFile);
traceFile = NULL;
printf("Trace file closed.\n");
}
}
#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/
#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/

View file

@ -1,22 +1,21 @@
Tracealyzer Stream Port for SEGGER J-Link Tracealyzer Stream Port for SEGGER J-Link
Percepio AB
www.percepio.com
----------------------------------------- -----------------------------------------
This directory contains a "stream port" for the Tracealyzer recorder library, 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 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 Tracealyzer RTOS trace. The stream port is defined by a set of macros in
trcStreamingPort.h, found in the "include" directory. trcStreamPort.h, found in the "include" directory.
This particular stream port targets SEGGER J-Link debug probes, using the RTT This particular stream port targets SEGGER J-Link debug probes, using the RTT
interface provided by SEGGER. interface provided by SEGGER.
To use this stream port, make sure that include/trcStreamingPort.h is found 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 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 add all included source files to your build. Make sure no other versions of
trcStreamingPort.h are included by mistake! trcStreamPort.h are included by mistake!
Note that this stream port also contains SEGGER's RTT driver. Note that this stream port also contains SEGGER's RTT driver.
See also http://percepio.com/2016/10/05/rtos-tracing. See also http://percepio.com/2016/10/05/rtos-tracing.
Percepio AB
www.percepio.com

View file

@ -0,0 +1,123 @@
/*
* 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 */

View file

@ -0,0 +1,143 @@
/*
* 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 */

View file

@ -1,196 +0,0 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcStreamingPort.h
*
* The interface definitions for trace streaming ("stream ports").
* This "stream port" sets up the recorder to use 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.
*
* Terms of Use
* This file is part of the trace recorder library (RECORDER), which is the
* intellectual property of Percepio AB (PERCEPIO) and provided under a
* license as follows.
* The RECORDER may be used free of charge for the purpose of recording data
* intended for analysis in PERCEPIO products. It may not be used or modified
* for other purposes without explicit permission from PERCEPIO.
* You may distribute the RECORDER in its original source code form, assuming
* this text (terms of use, disclaimer, copyright notice) is unchanged. You are
* allowed to distribute the RECORDER with minor modifications intended for
* configuration or porting of the RECORDER, e.g., to allow using it on a
* specific processor, processor family or with a specific communication
* interface. Any such modifications should be documented directly below
* this comment block.
*
* Disclaimer
* The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty
* as to its use or performance. PERCEPIO does not and cannot warrant the
* performance or results you may obtain by using the RECORDER or documentation.
* PERCEPIO make no warranties, express or implied, as to noninfringement of
* third party rights, merchantability, or fitness for any particular purpose.
* In no event will PERCEPIO, its technology partners, or distributors be liable
* to you for any consequential, incidental or special damages, including any
* lost profits or lost savings, even if a representative of PERCEPIO has been
* advised of the possibility of such damages, or for any claim by any third
* party. Some jurisdictions do not allow the exclusion or limitation of
* incidental, consequential or special damages, or the exclusion of implied
* warranties or limitations on how long an implied warranty may last, so the
* above limitations may not apply to you.
*
* Tabs are used for indent in this file (1 tab = 4 spaces)
*
* Copyright Percepio AB, 2018.
* www.percepio.com
******************************************************************************/
#ifndef TRC_STREAMING_PORT_H
#define TRC_STREAMING_PORT_H
#ifdef __cplusplus
extern "C" {
#endif
/*******************************************************************************
* Configuration Macro: TRC_CFG_RTT_BUFFER_SIZE_UP
*
* 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_RTT_BUFFER_SIZE_UP 5000
/*******************************************************************************
* Configuration Macro: TRC_CFG_RTT_BUFFER_SIZE_DOWN
*
* 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_RTT_BUFFER_SIZE_DOWN 32
/*******************************************************************************
* Configuration Macro: TRC_CFG_RTT_UP_BUFFER_INDEX
*
* 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_RTT_UP_BUFFER_INDEX 1
/*******************************************************************************
* Configuration Macro: TRC_CFG_RTT_DOWN_BUFFER_INDEX
*
* 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_RTT_DOWN_BUFFER_INDEX 1
/*******************************************************************************
* TRC_CFG_RTT_MODE
* 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_RTT_MODE SEGGER_RTT_MODE_NO_BLOCK_SKIP
#include "SEGGER_RTT_Conf.h"
#include "SEGGER_RTT.h"
#if (TRC_CFG_RTT_UP_BUFFER_INDEX >= SEGGER_RTT_MAX_NUM_UP_BUFFERS)
#error "TRC_CFG_RTT_UP_BUFFER_INDEX must be smaller than SEGGER_RTT_MAX_NUM_UP_BUFFERS"
#endif
#if (TRC_CFG_RTT_DOWN_BUFFER_INDEX >= SEGGER_RTT_MAX_NUM_DOWN_BUFFERS)
#error "TRC_CFG_RTT_DOWN_BUFFER_INDEX must be smaller than SEGGER_RTT_MAX_NUM_DOWN_BUFFERS"
#endif
/* If index is defined as 0, the internal RTT buffers will be used instead of this. */
#if TRC_CFG_RTT_UP_BUFFER_INDEX == 0
#define TRC_RTT_ALLOC_UP() static char* _TzTraceData = NULL; /* Not actually used. Ignore allocation method. */
#define TRC_STREAM_PORT_MALLOC() /* Static allocation. Not used. */
#else
#if TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_STATIC
#define TRC_RTT_ALLOC_UP() char _TzTraceData[TRC_CFG_RTT_BUFFER_SIZE_UP]; /* Static allocation */
#define TRC_STREAM_PORT_MALLOC() /* Static allocation. Not used. */
#endif
#if TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC
#define TRC_RTT_ALLOC_UP() char* _TzTraceData = NULL; /* Dynamic allocation */
#define TRC_STREAM_PORT_MALLOC() _TzTraceData = TRC_PORT_MALLOC(TRC_CFG_RTT_BUFFER_SIZE_UP);
#endif
#if TRC_CFG_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM
#define TRC_RTT_ALLOC_UP() char* _TzTraceData = NULL; /* Custom allocation, user needs to call vTraceSetRecorderDataBuffer before vTraceEnable, to assign this */
#define TRC_STREAM_PORT_MALLOC() /* Not used in custom mode */
#endif
#endif
/* Down-buffer. If index is defined as 0, the internal RTT buffers will be used instead of this. */ \
#if TRC_CFG_RTT_DOWN_BUFFER_INDEX == 0
#define TRC_RTT_ALLOC_DOWN() static char* _TzCtrlData = NULL; /* Not actually used. Ignore allocation method. */
#else
#define TRC_RTT_ALLOC_DOWN() static char _TzCtrlData[TRC_CFG_RTT_BUFFER_SIZE_DOWN]; /* Always static allocation, since usually small. */
#endif
#define TRC_STREAM_PORT_ALLOCATE_FIELDS() \
TRC_RTT_ALLOC_UP() /* Macro that will result in proper UP buffer allocation */ \
TRC_RTT_ALLOC_DOWN() /* Macro that will result in proper DOWN buffer allocation */
int32_t readFromRTT(void* ptrData, uint32_t size, int32_t* ptrBytesRead);
int32_t writeToRTT(void* ptrData, uint32_t size, int32_t* ptrBytesWritten);
#define TRC_STREAM_PORT_INIT() \
TRC_STREAM_PORT_MALLOC(); /*Dynamic allocation or empty if static */ \
SEGGER_RTT_ConfigUpBuffer(TRC_CFG_RTT_UP_BUFFER_INDEX, "TzData", _TzTraceData, TRC_CFG_RTT_BUFFER_SIZE_UP, TRC_CFG_RTT_MODE ); \
SEGGER_RTT_ConfigDownBuffer(TRC_CFG_RTT_DOWN_BUFFER_INDEX, "TzCtrl", _TzCtrlData, TRC_CFG_RTT_BUFFER_SIZE_DOWN, TRC_CFG_RTT_MODE);
/* Important for the J-Link port, in most other ports this can be skipped (default is 1) */
#define TRC_STREAM_PORT_USE_INTERNAL_BUFFER 0
#define TRC_STREAM_PORT_WRITE_DATA(_ptrData, _size, _ptrBytesWritten) writeToRTT(_ptrData, _size, _ptrBytesWritten)
#define TRC_STREAM_PORT_READ_DATA(_ptrData, _size, _ptrBytesRead) readFromRTT(_ptrData, _size, _ptrBytesRead)
#ifdef __cplusplus
}
#endif
#endif /* TRC_STREAMING_PORT_H */

View file

@ -0,0 +1,64 @@
/*
* 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
#endif

View file

@ -1,83 +0,0 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcStreamingPort.c
*
* 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.
*
* Terms of Use
* This file is part of the trace recorder library (RECORDER), which is the
* intellectual property of Percepio AB (PERCEPIO) and provided under a
* license as follows.
* The RECORDER may be used free of charge for the purpose of recording data
* intended for analysis in PERCEPIO products. It may not be used or modified
* for other purposes without explicit permission from PERCEPIO.
* You may distribute the RECORDER in its original source code form, assuming
* this text (terms of use, disclaimer, copyright notice) is unchanged. You are
* allowed to distribute the RECORDER with minor modifications intended for
* configuration or porting of the RECORDER, e.g., to allow using it on a
* specific processor, processor family or with a specific communication
* interface. Any such modifications should be documented directly below
* this comment block.
*
* Disclaimer
* The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty
* as to its use or performance. PERCEPIO does not and cannot warrant the
* performance or results you may obtain by using the RECORDER or documentation.
* PERCEPIO make no warranties, express or implied, as to noninfringement of
* third party rights, merchantability, or fitness for any particular purpose.
* In no event will PERCEPIO, its technology partners, or distributors be liable
* to you for any consequential, incidental or special damages, including any
* lost profits or lost savings, even if a representative of PERCEPIO has been
* advised of the possibility of such damages, or for any claim by any third
* party. Some jurisdictions do not allow the exclusion or limitation of
* incidental, consequential or special damages, or the exclusion of implied
* warranties or limitations on how long an implied warranty may last, so the
* above limitations may not apply to you.
*
* Tabs are used for indent in this file (1 tab = 4 spaces)
*
* Copyright Percepio AB, 2018.
* www.percepio.com
******************************************************************************/
#include "trcRecorder.h"
#if (TRC_USE_TRACEALYZER_RECORDER == 1)
#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
int32_t readFromRTT(void* ptrData, uint32_t size, int32_t* ptrBytesRead)
{
uint32_t bytesRead = 0;
if (SEGGER_RTT_HASDATA(TRC_CFG_RTT_DOWN_BUFFER_INDEX))
{
bytesRead = SEGGER_RTT_Read((TRC_CFG_RTT_DOWN_BUFFER_INDEX), (char*)ptrData, size);
if (ptrBytesRead != NULL)
*ptrBytesRead = (int32_t)bytesRead;
}
return 0;
}
int32_t writeToRTT(void* ptrData, uint32_t size, int32_t* ptrBytesWritten)
{
uint32_t bytesWritten = SEGGER_RTT_Write((TRC_CFG_RTT_UP_BUFFER_INDEX), (const char*)ptrData, size);
if (ptrBytesWritten != NULL)
*ptrBytesWritten = (int32_t)bytesWritten;
return 0;
}
#endif
#endif

View file

@ -0,0 +1,19 @@
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

View file

@ -0,0 +1,60 @@
/*
* 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
#if (TRC_USE_TRACEALYZER_RECORDER == 1)
#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
#include <trcTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Type flags */
#define TRC_STREAM_PORT_RINGBUFFER_MODE_STOP_WHEN_FULL (0U)
#define TRC_STREAM_PORT_RINGBUFFER_MODE_OVERWRITE_WHEN_FULL (1U)
/**
* @def TRC_CFG_STREAM_PORT_BUFFER_SIZE
*
* @brief Defines the size of the ring buffer use for storing trace events.
*/
#define TRC_CFG_STREAM_PORT_BUFFER_SIZE 10000
/**
* @def TRC_CFG_STREAM_PORT_BUFFER_MODE
*
* @brief Configures the behavior of the ring buffer when full.
*
* With TRC_CFG_STREAM_PORT_MODE set to TRC_STREAM_PORT_RINGBUFFER_MODE_OVERWRITE_WHEN_FULL, 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_STREAM_PORT_MODE is TRC_STREAM_PORT_RINGBUFFER_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_STREAM_PORT_RINGBUFFER_MODE TRC_STREAM_PORT_RINGBUFFER_MODE_OVERWRITE_WHEN_FULL
#ifdef __cplusplus
}
#endif
#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/
#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/
#endif /* TRC_STREAM_PORT_CONFIG_H */

View file

@ -0,0 +1,201 @@
/*
* 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 */

View file

@ -0,0 +1,130 @@
/*
* 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)*/

View file

@ -1,9 +1,11 @@
Tracealyzer Stream Port for STM32 USB CDC (Virtual COM Port) 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, 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 allowing for streaming the trace data over a USB connection. The stream port is defined by a set of macros in
trcStreamingPort.h, found in the "include" directory, that relies on functions in trcStreamingPort.c. 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). This particular stream port targets STM32 devices using USB CDC (virtual COM port).
It was been tested with STM32F767 and STM32L475. It was been tested with STM32F767 and STM32L475.
@ -34,7 +36,7 @@ The default TX and RX buffers are not used by the trace recorder library, so thi
3. Open trcConfig.h and set TRC_CFG_RECORDER_MODE to TRC_RECORDER_MODE_STREAMING. 3. Open trcConfig.h and set TRC_CFG_RECORDER_MODE to TRC_RECORDER_MODE_STREAMING.
4. Copy trcStreamingPort.c and include/trcStreamingPort.h into your project. 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). 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. This should be placed after the HW setup but before making any RTOS calls.
@ -82,13 +84,10 @@ You may try the following to start with:
Also see the "tuning" guide at https://percepio.com/2018/10/11/tuning-your-custom-trace-streaming/ 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. Also note that this USB stream port has a diagnostics option that might come handy.
Enable USB_PERF_DIAGNOSTICS in trcStreamingPort.h. This will save additional "user events" 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 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). remaining capacity in the trace buffer (if this goes down to zero, data is lost).
#define USB_PERF_DIAGNOSTICS 1 #define USB_PERF_DIAGNOSTICS 1
If you need assistence, feel free to contact support@percepio.com. If you need assistence, feel free to contact support@percepio.com.
Percepio AB
https://percepio.com

View file

@ -0,0 +1,39 @@
/*
* 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 */

View file

@ -0,0 +1,110 @@
/*
* 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 */

View file

@ -1,82 +0,0 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcStreamingPort.h
*
* The interface definitions for trace streaming ("stream ports").
* This "stream port" sets up the recorder to use USB CDC as streaming channel.
* The example is for STM32 using STM32Cube.
*
* Terms of Use
* This file is part of the trace recorder library (RECORDER), which is the
* intellectual property of Percepio AB (PERCEPIO) and provided under a
* license as follows.
* The RECORDER may be used free of charge for the purpose of recording data
* intended for analysis in PERCEPIO products. It may not be used or modified
* for other purposes without explicit permission from PERCEPIO.
* You may distribute the RECORDER in its original source code form, assuming
* this text (terms of use, disclaimer, copyright notice) is unchanged. You are
* allowed to distribute the RECORDER with minor modifications intended for
* configuration or porting of the RECORDER, e.g., to allow using it on a
* specific processor, processor family or with a specific communication
* interface. Any such modifications should be documented directly below
* this comment block.
*
* Disclaimer
* The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty
* as to its use or performance. PERCEPIO does not and cannot warrant the
* performance or results you may obtain by using the RECORDER or documentation.
* PERCEPIO make no warranties, express or implied, as to noninfringement of
* third party rights, merchantability, or fitness for any particular purpose.
* In no event will PERCEPIO, its technology partners, or distributors be liable
* to you for any consequential, incidental or special damages, including any
* lost profits or lost savings, even if a representative of PERCEPIO has been
* advised of the possibility of such damages, or for any claim by any third
* party. Some jurisdictions do not allow the exclusion or limitation of
* incidental, consequential or special damages, or the exclusion of implied
* warranties or limitations on how long an implied warranty may last, so the
* above limitations may not apply to you.
*
* Tabs are used for indent in this file (1 tab = 4 spaces)
*
* Copyright Percepio AB, 2018.
* www.percepio.com
******************************************************************************/
#ifndef TRC_STREAMING_PORT_H
#define TRC_STREAMING_PORT_H
#include "usb_device.h"
#include "usbd_CDC_if.h"
#ifdef __cplusplus
extern "C" {
#endif
/* The time to wait if the USB interface is busy. */
#define TRC_CFG_DELAY_ON_BUSY 3
/* For FreeRTOS. Modify for other RTOSes. */
#define TRC_OS_DELAY(x) vTaskDelay(x)
void trcCDCInit(void);
int32_t trcCDCReceive(void *data, uint32_t size, int32_t* NumBytes);
int32_t trcCDCTransmit(void* data, uint32_t size, int32_t * noOfBytesSent );
#define TRC_STREAM_PORT_INIT() \
trcCDCInit();\
TRC_STREAM_PORT_MALLOC();
#define TRC_STREAM_PORT_READ_DATA(_ptrData, _size, _ptrBytesRead) trcCDCReceive(_ptrData, _size, _ptrBytesRead)
#define TRC_STREAM_PORT_WRITE_DATA(_ptrData, _size, _ptrBytesSent) trcCDCTransmit(_ptrData, _size, _ptrBytesSent)
#ifdef __cplusplus
}
#endif
#endif /* TRC_STREAMING_PORT_H */

View file

@ -0,0 +1,151 @@
/*
* 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)*/

View file

@ -1,164 +0,0 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcStreamingPort.c
*
* Supporting functions for trace streaming ("stream ports").
* This "stream port" sets up the recorder to use USB CDC as streaming channel.
* The example is for STM32 using STM32Cube.
*
* Terms of Use
* This file is part of the trace recorder library (RECORDER), which is the
* intellectual property of Percepio AB (PERCEPIO) and provided under a
* license as follows.
* The RECORDER may be used free of charge for the purpose of recording data
* intended for analysis in PERCEPIO products. It may not be used or modified
* for other purposes without explicit permission from PERCEPIO.
* You may distribute the RECORDER in its original source code form, assuming
* this text (terms of use, disclaimer, copyright notice) is unchanged. You are
* allowed to distribute the RECORDER with minor modifications intended for
* configuration or porting of the RECORDER, e.g., to allow using it on a
* specific processor, processor family or with a specific communication
* interface. Any such modifications should be documented directly below
* this comment block.
*
* Disclaimer
* The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty
* as to its use or performance. PERCEPIO does not and cannot warrant the
* performance or results you may obtain by using the RECORDER or documentation.
* PERCEPIO make no warranties, express or implied, as to noninfringement of
* third party rights, merchantability, or fitness for any particular purpose.
* In no event will PERCEPIO, its technology partners, or distributors be liable
* to you for any consequential, incidental or special damages, including any
* lost profits or lost savings, even if a representative of PERCEPIO has been
* advised of the possibility of such damages, or for any claim by any third
* party. Some jurisdictions do not allow the exclusion or limitation of
* incidental, consequential or special damages, or the exclusion of implied
* warranties or limitations on how long an implied warranty may last, so the
* above limitations may not apply to you.
*
* Tabs are used for indent in this file (1 tab = 4 spaces)
*
* Copyright Percepio AB, 2018.
* www.percepio.com
******************************************************************************/
#include "trcRecorder.h"
#if (TRC_USE_TRACEALYZER_RECORDER == 1)
#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
#include "stdint.h"
typedef struct{
uint32_t idx;
uint8_t data[64];
}recBuf;
recBuf commandBuffer;
static int8_t CDC_Receive_FS_modified (uint8_t* pbuf, uint32_t *Len);
extern USBD_CDC_ItfTypeDef USBD_Interface_fops_FS;
static int8_t (* CDC_Receive_FS)(uint8_t *Buf, uint32_t *Len);
static int8_t CDC_Receive_FS_modified (uint8_t* Buf, uint32_t *Len)
{
for( uint32_t i=0;i<* Len;i++)
{
commandBuffer.data[commandBuffer.idx]=Buf[i];
commandBuffer.idx++;
}
CDC_Receive_FS(Buf, Len);
return (USBD_OK);
}
void trcCDCInit(void)
{
/* Store the original "Receive" function, from the static initialization */
CDC_Receive_FS = USBD_Interface_fops_FS.Receive;
/* Update the function pointer with our modified variant */
USBD_Interface_fops_FS.Receive = CDC_Receive_FS_modified;
MX_USB_DEVICE_Init();
}
/* The READ function, used in trcStreamingPort.h */
int32_t trcCDCReceive(void *data, uint32_t size, int32_t* NumBytes)
{
uint32_t i,diff;
if(commandBuffer.idx>0)
{
if (size >= commandBuffer.idx) // more than what is stored, number of bytes will be .idx
{
memcpy(data,commandBuffer.data, commandBuffer.idx);
*NumBytes=commandBuffer.idx;
commandBuffer.idx=0; // Make the buffer ready for a new command
}
else //If some data in the buffer is not read
{
diff = commandBuffer.idx-size;
memcpy(data,commandBuffer.data, size);
for(i=0;i<diff;i++)
{
commandBuffer.data[i]=commandBuffer.data[i+size];
}
*NumBytes=size;
commandBuffer.idx=diff;
}
}
else
{
*NumBytes=0;
}
return 0;
}
/* The WRITE function, used in trcStreamingPort.h */
int32_t trcCDCTransmit(void* data, uint32_t size, int32_t * noOfBytesSent )
{
static int fail_counter = 0;
int32_t result;
*noOfBytesSent = 0;
result=CDC_Transmit_FS(data, size);
if (result == USBD_OK)
{
fail_counter = 0;
*noOfBytesSent = size;
return 0;
}
else
{
fail_counter++;
/* We keep trying to send more data. If busy, we delay for a while. This function will be called again afterwards. */
TRC_OS_DELAY( TRC_CFG_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 -1;
}
}
return 0;
}
#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/
#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/

View file

@ -1,10 +1,12 @@
Tracealyzer Stream Port for TCP/IP (lwIP example) Tracealyzer Stream Port for TCP/IP (lwIP example)
Percepio AB
www.percepio.com
------------------------------------------------- -------------------------------------------------
This directory contains a "stream port" for the Tracealyzer recorder library, 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 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 Tracealyzer RTOS trace. The stream port is defined by a set of macros in
trcStreamingPort.h, found in the "include" directory. trcStreamPort.h, found in the "include" directory.
This particular stream port targets TCP/IP. This example assumes lwIP but is This particular stream port targets TCP/IP. This example assumes lwIP but is
easy to modify for other TCP/IP stacks. easy to modify for other TCP/IP stacks.
@ -16,7 +18,7 @@ Instructions:
https://percepio.com/docs/FreeRTOS/manual/index.html#Creating_and_Loading_Traces___Introduction 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 2. Make sure all .c and .h files from this stream port folder is included in
your build, and that no other variant of trcStreamingPort.h is included. your build, and that no other variant of trcStreamPort.h is included.
3. In lwipopts.h, make sure you have this line: 3. In lwipopts.h, make sure you have this line:
@ -45,6 +47,3 @@ TzCtrl task. This can be done using vTraceSetFilterGroup() and vTraceSetFilterMa
Note that lwIP is not included in the stream port, but assumed to exist in the project already. 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. See also http://percepio.com/2016/10/05/rtos-tracing.
Percepio AB
www.percepio.com

View file

@ -0,0 +1,41 @@
/*
* 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 */

View file

@ -0,0 +1,75 @@
/*
* 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 */

View file

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

View file

@ -0,0 +1,205 @@
/*
* 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)*/

View file

@ -1,180 +0,0 @@
/*******************************************************************************
* Trace Recorder Library for Tracealyzer v4.4.0
* Percepio AB, www.percepio.com
*
* trcStreamingPort.c
*
* 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.
*
* Terms of Use
* This file is part of the trace recorder library (RECORDER), which is the
* intellectual property of Percepio AB (PERCEPIO) and provided under a
* license as follows.
* The RECORDER may be used free of charge for the purpose of recording data
* intended for analysis in PERCEPIO products. It may not be used or modified
* for other purposes without explicit permission from PERCEPIO.
* You may distribute the RECORDER in its original source code form, assuming
* this text (terms of use, disclaimer, copyright notice) is unchanged. You are
* allowed to distribute the RECORDER with minor modifications intended for
* configuration or porting of the RECORDER, e.g., to allow using it on a
* specific processor, processor family or with a specific communication
* interface. Any such modifications should be documented directly below
* this comment block.
*
* Disclaimer
* The RECORDER is being delivered to you AS IS and PERCEPIO makes no warranty
* as to its use or performance. PERCEPIO does not and cannot warrant the
* performance or results you may obtain by using the RECORDER or documentation.
* PERCEPIO make no warranties, express or implied, as to noninfringement of
* third party rights, merchantability, or fitness for any particular purpose.
* In no event will PERCEPIO, its technology partners, or distributors be liable
* to you for any consequential, incidental or special damages, including any
* lost profits or lost savings, even if a representative of PERCEPIO has been
* advised of the possibility of such damages, or for any claim by any third
* party. Some jurisdictions do not allow the exclusion or limitation of
* incidental, consequential or special damages, or the exclusion of implied
* warranties or limitations on how long an implied warranty may last, so the
* above limitations may not apply to you.
*
* Tabs are used for indent in this file (1 tab = 4 spaces)
*
* Copyright Percepio AB, 2018.
* www.percepio.com
******************************************************************************/
#include "trcRecorder.h"
#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
#if (TRC_USE_TRACEALYZER_RECORDER == 1)
/* TCP/IP includes - for lwIP in this case */
#include "lwip/tcpip.h"
#include "lwip/sockets.h"
#include "lwip/errno.h"
#define TRC_TCPIP_PORT 12000
int sock = -1, new_sd = -1;
int flags = 0;
int remoteSize;
struct sockaddr_in address, remote;
int32_t trcSocketSend( void* data, int32_t size, int32_t* bytesWritten )
{
if (new_sd < 0)
return -1;
if (bytesWritten == NULL)
return -1;
*bytesWritten = send( new_sd, data, size, 0 );
if (*bytesWritten < 0)
{
/* EWOULDBLOCK may be expected when buffers are full */
if ((errno != 0) && (errno != EWOULDBLOCK))
{
closesocket(new_sd);
new_sd = -1;
return -1;
}
else
*bytesWritten = 0;
}
return 0;
}
int32_t trcSocketReceive( void* data, int32_t size, int32_t* bytesRead )
{
if (new_sd < 0)
return -1;
*bytesRead = recv( new_sd, data, size, 0 );
/* EWOULDBLOCK may be expected when there is no data to receive */
if (errno != 0 && errno != EWOULDBLOCK)
{
closesocket(new_sd);
new_sd = -1;
return -1;
}
return 0;
}
int32_t trcSocketInitializeListener()
{
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_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;
}
int32_t trcSocketAccept()
{
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;
}
/************** MODIFY THE ABOVE PART TO USE YOUR TPC/IP STACK ****************/
int32_t trcTcpWrite(void* data, uint32_t size, int32_t *ptrBytesWritten)
{
return trcSocketSend(data, size, ptrBytesWritten);
}
int32_t trcTcpRead(void* data, uint32_t size, int32_t *ptrBytesRead)
{
trcSocketInitializeListener();
trcSocketAccept();
return trcSocketReceive(data, size, ptrBytesRead);
}
#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/
#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/

View file

@ -1,9 +1,11 @@
Tracealyzer Stream Port for TCP/IP (Win32 example) Tracealyzer Stream Port for TCP/IP (Win32 example)
Percepio AB
www.percepio.com
------------------------------------------------- -------------------------------------------------
This directory contains a "stream port" for the Tracealyzer recorder library, 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 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 trcStreamingPort.h, interface. The stream port is defined by a set of macros in trcStreamPort.h,
found in the "include" directory. found in the "include" directory.
This particular stream port is for streaming over TCP/IP on Windows, intended This particular stream port is for streaming over TCP/IP on Windows, intended
@ -18,7 +20,7 @@ need will Visual Studio, but there are free versions (Express or Community).
3. Make sure the recorder library is configured for streaming mode (see 3. Make sure the recorder library is configured for streaming mode (see
trcConfig.h). trcConfig.h).
4. Make sure the project's include paths contains trcStreamingPort.h found in 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 this include folder (and not any other stream port), and the related code
in this folder. in this folder.
@ -33,6 +35,3 @@ 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". 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. See also http://percepio.com/2016/10/05/rtos-tracing.
Percepio AB
www.percepio.com

View file

@ -0,0 +1,41 @@
/*
* 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 */

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