Initial version
This commit is contained in:
@ -0,0 +1,478 @@
|
||||
/*******************************************************************************
|
||||
* Trace Recorder Library for Tracealyzer v4.1.5
|
||||
* Percepio AB, www.percepio.com
|
||||
*
|
||||
* trcHardwarePort.h
|
||||
*
|
||||
* 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
|
||||
#define TRC_HARDWARE_PORT_H
|
||||
|
||||
#include "trcPortDefines.h"
|
||||
|
||||
|
||||
#if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_NOT_SET)
|
||||
#error "TRC_CFG_HARDWARE_PORT not selected - see trcConfig.h"
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* TRC_IRQ_PRIORITY_ORDER
|
||||
*
|
||||
* Macro which should be defined as an integer of 0 or 1.
|
||||
*
|
||||
* This should be 0 if lower IRQ priority values implies higher priority
|
||||
* levels, such as on ARM Cortex M. If the opposite scheme is used, i.e.,
|
||||
* if higher IRQ priority values means higher priority, this should be 1.
|
||||
*
|
||||
* This setting is not critical. It is used only to sort and colorize the
|
||||
* interrupts in priority order, in case you record interrupts using
|
||||
* the vTraceStoreISRBegin and vTraceStoreISREnd routines.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* HWTC Macros
|
||||
*
|
||||
* These macros provides a hardware isolation layer representing the
|
||||
* hardware timer/counter used for the event timestamping.
|
||||
*
|
||||
* TRC_HWTC_COUNT: How to read the current value of the timer/counter.
|
||||
*
|
||||
* TRC_HWTC_TYPE: Tells the type of timer/counter used for TRC_HWTC_COUNT:
|
||||
*
|
||||
* - TRC_FREE_RUNNING_32BIT_INCR:
|
||||
* Free-running 32-bit timer/counter, counting upwards from 0.
|
||||
*
|
||||
* - TRC_FREE_RUNNING_32BIT_DECR
|
||||
* Free-running 32-bit timer/counter, counting downwards from 0xFFFFFFFF.
|
||||
*
|
||||
* - TRC_OS_TIMER_INCR
|
||||
* Periodic timer that drives the OS tick interrupt, counting upwards
|
||||
* from 0 until (TRC_HWTC_PERIOD-1).
|
||||
*
|
||||
* - TRC_OS_TIMER_DECR
|
||||
* Periodic timer that drives the OS tick interrupt, counting downwards
|
||||
* from TRC_HWTC_PERIOD-1 until 0.
|
||||
*
|
||||
* - TRC_CUSTOM_TIMER_INCR
|
||||
* A custom timer or counter independent of the OS tick, counting
|
||||
* downwards from TRC_HWTC_PERIOD-1 until 0. (Currently only supported
|
||||
* in streaming mode).
|
||||
*
|
||||
* - TRC_CUSTOM_TIMER_DECR
|
||||
* A custom timer independent of the OS tick, counting downwards
|
||||
* from TRC_HWTC_PERIOD-1 until 0. (Currently only supported
|
||||
* in streaming mode).
|
||||
*
|
||||
* TRC_HWTC_PERIOD: The number of HWTC_COUNT ticks until the timer wraps
|
||||
* around. If using TRC_FREE_RUNNING_32BIT_INCR/DECR, this should be 0.
|
||||
*
|
||||
* TRC_HWTC_FREQ_HZ: The clock rate of the TRC_HWTC_COUNT counter in Hz. If using
|
||||
* TRC_OS_TIMER_INCR/DECR, this is should be TRC_HWTC_PERIOD * TRACE_TICK_RATE_HZ.
|
||||
* If using a free-running timer, this is often TRACE_CPU_CLOCK_HZ (if running at
|
||||
* the core clock rate). If using TRC_CUSTOM_TIMER_INCR/DECR, this should match
|
||||
* the clock rate of your custom timer (i.e., TRC_HWTC_COUNT). If the default value
|
||||
* of TRC_HWTC_FREQ_HZ is incorrect for your setup, you can override it by calling
|
||||
* vTraceSetFrequency before calling vTraceEnable.
|
||||
*
|
||||
* TRC_HWTC_DIVISOR (used in snapshot mode only):
|
||||
* In snapshot mode, the timestamp resolution is TRC_HWTC_FREQ_HZ/TRC_HWTC_DIVISOR.
|
||||
* If the timer frequency is very high (hundreds of MHz), we recommend increasing
|
||||
* the TRC_HWTC_DIVISOR prescaler, to reduce the bandwidth needed to store
|
||||
* timestamps. This since extra "XTS" events are inserted if the time since the
|
||||
* previous event exceeds a certain limit (255 or 65535 depending on event type).
|
||||
* It is advised to keep the time between most events below 65535 native ticks
|
||||
* (after division by TRC_HWTC_DIVISOR) to avoid frequent XTS events.
|
||||
******************************************************************************/
|
||||
|
||||
#if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_NOT_SET)
|
||||
#error "TRC_CFG_HARDWARE_PORT not selected - see trcConfig.h"
|
||||
#endif
|
||||
|
||||
#if (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Win32)
|
||||
/* This can be used as a template for any free-running 32-bit counter */
|
||||
#define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
|
||||
#define TRC_HWTC_COUNT (ulGetRunTimeCounterValue())
|
||||
#define TRC_HWTC_PERIOD 0
|
||||
#define TRC_HWTC_DIVISOR 1
|
||||
#define TRC_HWTC_FREQ_HZ 100000
|
||||
|
||||
#define TRC_IRQ_PRIORITY_ORDER 1
|
||||
|
||||
#define TRC_PORT_SPECIFIC_INIT()
|
||||
|
||||
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_HWIndependent)
|
||||
/* Timestamping by OS tick only (typically 1 ms resolution) */
|
||||
#define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
|
||||
#define TRC_HWTC_COUNT 0
|
||||
#define TRC_HWTC_PERIOD 1
|
||||
#define TRC_HWTC_DIVISOR 1
|
||||
#define TRC_HWTC_FREQ_HZ TRACE_TICK_RATE_HZ
|
||||
|
||||
/* Set the meaning of IRQ priorities in ISR tracing - see above */
|
||||
#define TRC_IRQ_PRIORITY_ORDER NOT_SET
|
||||
|
||||
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_ARM_Cortex_M)
|
||||
|
||||
#ifndef __CORTEX_M
|
||||
#error "Can't find the CMSIS API. Please include your processor's header file in trcConfig.h"
|
||||
#endif
|
||||
|
||||
/**************************************************************************
|
||||
* For Cortex-M3, M4 and M7, the DWT cycle counter is used for timestamping.
|
||||
* For Cortex-M0 and M0+, the SysTick timer is used since DWT is not
|
||||
* available. Systick timestamping can also be forced on Cortex-M3, M4 and
|
||||
* M7 by defining the preprocessor directive TRC_CFG_ARM_CM_USE_SYSTICK,
|
||||
* either directly below or in trcConfig.h.
|
||||
*
|
||||
* #define TRC_CFG_ARM_CM_USE_SYSTICK
|
||||
**************************************************************************/
|
||||
|
||||
#if ((__CORTEX_M >= 0x03) && (! defined TRC_CFG_ARM_CM_USE_SYSTICK))
|
||||
|
||||
void prvTraceInitCortexM(void);
|
||||
|
||||
#define TRC_REG_DEMCR (*(volatile uint32_t*)0xE000EDFC)
|
||||
#define TRC_REG_DWT_CTRL (*(volatile uint32_t*)0xE0001000)
|
||||
#define TRC_REG_DWT_CYCCNT (*(volatile uint32_t*)0xE0001004)
|
||||
#define TRC_REG_DWT_EXCCNT (*(volatile uint32_t*)0xE000100C)
|
||||
|
||||
#define TRC_REG_ITM_LOCKACCESS (*(volatile uint32_t*)0xE0001FB0)
|
||||
#define TRC_ITM_LOCKACCESS_UNLOCK (0xC5ACCE55)
|
||||
|
||||
/* Bit mask for TRCENA bit in DEMCR - Global enable for DWT and ITM */
|
||||
#define TRC_DEMCR_TRCENA (1 << 24)
|
||||
|
||||
/* Bit mask for NOPRFCNT bit in DWT_CTRL. If 1, DWT_EXCCNT is not supported */
|
||||
#define TRC_DWT_CTRL_NOPRFCNT (1 << 24)
|
||||
|
||||
/* Bit mask for NOCYCCNT bit in DWT_CTRL. If 1, DWT_CYCCNT is not supported */
|
||||
#define TRC_DWT_CTRL_NOCYCCNT (1 << 25)
|
||||
|
||||
/* Bit mask for EXCEVTENA_ bit in DWT_CTRL. Set to 1 to enable DWT_EXCCNT */
|
||||
#define TRC_DWT_CTRL_EXCEVTENA (1 << 18)
|
||||
|
||||
/* Bit mask for EXCEVTENA_ bit in DWT_CTRL. Set to 1 to enable DWT_CYCCNT */
|
||||
#define TRC_DWT_CTRL_CYCCNTENA (1)
|
||||
|
||||
#define TRC_PORT_SPECIFIC_INIT() prvTraceInitCortexM()
|
||||
|
||||
#define TRC_HWTC_TYPE TRC_FREE_RUNNING_32BIT_INCR
|
||||
#define TRC_HWTC_COUNT TRC_REG_DWT_CYCCNT
|
||||
#define TRC_HWTC_PERIOD 0
|
||||
#define TRC_HWTC_DIVISOR 4
|
||||
#define TRC_HWTC_FREQ_HZ TRACE_CPU_CLOCK_HZ
|
||||
#define TRC_IRQ_PRIORITY_ORDER 0
|
||||
|
||||
#else
|
||||
|
||||
#define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
|
||||
#define TRC_HWTC_COUNT (*((volatile uint32_t*)0xE000E018))
|
||||
#define TRC_HWTC_PERIOD ((*((volatile uint32_t*)0xE000E014)) + 1)
|
||||
#define TRC_HWTC_DIVISOR 4
|
||||
#define TRC_HWTC_FREQ_HZ TRACE_CPU_CLOCK_HZ
|
||||
#define TRC_IRQ_PRIORITY_ORDER 0
|
||||
|
||||
#endif
|
||||
|
||||
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Renesas_RX600)
|
||||
|
||||
#include "iodefine.h"
|
||||
|
||||
#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
|
||||
|
||||
#define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
|
||||
#define TRC_HWTC_COUNT (CMT0.CMCNT)
|
||||
|
||||
#elif (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT)
|
||||
|
||||
/* Decreasing counters better for Tickless Idle? */
|
||||
#define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
|
||||
#define TRC_HWTC_COUNT (CMT0.CMCOR - CMT0.CMCNT)
|
||||
|
||||
#endif
|
||||
|
||||
#define TRC_HWTC_PERIOD (CMT0.CMCOR + 1)
|
||||
#define TRC_HWTC_DIVISOR 1
|
||||
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD)
|
||||
#define TRC_IRQ_PRIORITY_ORDER 1
|
||||
|
||||
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_MICROCHIP_PIC24_PIC32)
|
||||
|
||||
#define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
|
||||
#define TRC_HWTC_COUNT (TMR1)
|
||||
#define TRC_HWTC_PERIOD (PR1 + 1)
|
||||
#define TRC_HWTC_DIVISOR 1
|
||||
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD)
|
||||
#define TRC_IRQ_PRIORITY_ORDER 0
|
||||
|
||||
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_TEXAS_INSTRUMENTS_TMS570_RM48)
|
||||
|
||||
#define TRC_RTIFRC0 *((uint32_t *)0xFFFFFC10)
|
||||
#define TRC_RTICOMP0 *((uint32_t *)0xFFFFFC50)
|
||||
#define TRC_RTIUDCP0 *((uint32_t *)0xFFFFFC54)
|
||||
|
||||
#define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
|
||||
#define TRC_HWTC_COUNT (TRC_RTIFRC0 - (TRC_RTICOMP0 - TRC_RTIUDCP0))
|
||||
#define TRC_HWTC_PERIOD (TRC_RTIUDCP0)
|
||||
#define TRC_HWTC_DIVISOR 1
|
||||
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD)
|
||||
#define TRC_IRQ_PRIORITY_ORDER 0
|
||||
|
||||
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Atmel_AT91SAM7)
|
||||
|
||||
/* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */
|
||||
|
||||
#define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
|
||||
#define TRC_HWTC_COUNT ((uint32_t)(AT91C_BASE_PITC->PITC_PIIR & 0xFFFFF))
|
||||
#define TRC_HWTC_PERIOD ((uint32_t)(AT91C_BASE_PITC->PITC_PIMR + 1))
|
||||
#define TRC_HWTC_DIVISOR 1
|
||||
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD)
|
||||
#define TRC_IRQ_PRIORITY_ORDER 1
|
||||
|
||||
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Atmel_UC3A0)
|
||||
|
||||
/* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO*/
|
||||
|
||||
/* For Atmel AVR32 (AT32UC3A) */
|
||||
|
||||
#define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
|
||||
#define TRC_HWTC_COUNT ((uint32_t)sysreg_read(AVR32_COUNT))
|
||||
#define TRC_HWTC_PERIOD ((uint32_t)(sysreg_read(AVR32_COMPARE) + 1))
|
||||
#define TRC_HWTC_DIVISOR 1
|
||||
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD)
|
||||
#define TRC_IRQ_PRIORITY_ORDER 1
|
||||
|
||||
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_NXP_LPC210X)
|
||||
|
||||
/* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */
|
||||
|
||||
/* Tested with LPC2106, but should work with most LPC21XX chips. */
|
||||
|
||||
#define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
|
||||
#define TRC_HWTC_COUNT *((uint32_t *)0xE0004008 )
|
||||
#define TRC_HWTC_PERIOD *((uint32_t *)0xE0004018 )
|
||||
#define TRC_HWTC_DIVISOR 1
|
||||
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD)
|
||||
#define TRC_IRQ_PRIORITY_ORDER 0
|
||||
|
||||
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_TEXAS_INSTRUMENTS_MSP430)
|
||||
|
||||
/* UNOFFICIAL PORT - NOT YET VERIFIED */
|
||||
|
||||
#define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
|
||||
#define TRC_HWTC_COUNT (TA0R)
|
||||
#define TRC_HWTC_PERIOD (((uint16_t)TACCR0)+1)
|
||||
#define TRC_HWTC_DIVISOR 1
|
||||
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD)
|
||||
#define TRC_IRQ_PRIORITY_ORDER 1
|
||||
|
||||
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XILINX_PPC405)
|
||||
|
||||
/* UNOFFICIAL PORT - NOT YET VERIFIED */
|
||||
|
||||
#define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
|
||||
#define TRC_HWTC_COUNT mfspr(0x3db)
|
||||
#define TRC_HWTC_PERIOD (TRACE_CPU_CLOCK_HZ / TRACE_TICK_RATE_HZ)
|
||||
#define TRC_HWTC_DIVISOR 1
|
||||
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD)
|
||||
#define TRC_IRQ_PRIORITY_ORDER 0
|
||||
|
||||
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XILINX_PPC440)
|
||||
|
||||
/* UNOFFICIAL PORT */
|
||||
|
||||
/* This should work with most PowerPC chips */
|
||||
|
||||
#define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
|
||||
#define TRC_HWTC_COUNT mfspr(0x016)
|
||||
#define TRC_HWTC_PERIOD (TRACE_CPU_CLOCK_HZ / TRACE_TICK_RATE_HZ)
|
||||
#define TRC_HWTC_DIVISOR 1
|
||||
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD)
|
||||
#define TRC_IRQ_PRIORITY_ORDER 0
|
||||
|
||||
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_XILINX_MICROBLAZE)
|
||||
|
||||
/* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */
|
||||
|
||||
/* This should work with most Microblaze configurations.
|
||||
* It uses the AXI Timer 0 - the tick interrupt source.
|
||||
* If an AXI Timer 0 peripheral is available on your hardware platform, no modifications are required.
|
||||
*/
|
||||
#include "xtmrctr_l.h"
|
||||
|
||||
#define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
|
||||
#define TRC_HWTC_COUNT XTmrCtr_GetTimerCounterReg( XPAR_TMRCTR_0_BASEADDR, 0 )
|
||||
#define TRC_HWTC_PERIOD (XTmrCtr_mGetLoadReg( XPAR_TMRCTR_0_BASEADDR, 0) + 1)
|
||||
#define TRC_HWTC_DIVISOR 16
|
||||
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD)
|
||||
#define TRC_IRQ_PRIORITY_ORDER 0
|
||||
|
||||
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_Altera_NiosII)
|
||||
|
||||
/* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */
|
||||
|
||||
#include "system.h"
|
||||
#include "sys/alt_timestamp.h"
|
||||
|
||||
#define TRC_HWTC_TYPE TRC_OS_TIMER_INCR
|
||||
#define TRC_HWTC_COUNT (uint32_t)alt_timestamp()
|
||||
#define TRC_HWTC_PERIOD 0xFFFFFFFF
|
||||
#define TRC_HWTC_FREQ_HZ TIMESTAMP_TIMER_FREQ
|
||||
#define TRC_HWTC_DIVISOR 1
|
||||
#define TRC_IRQ_PRIORITY_ORDER 0
|
||||
|
||||
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_ARM_CORTEX_A9)
|
||||
|
||||
/* INPUT YOUR PERIPHERAL BASE ADDRESS HERE */
|
||||
#define TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS 0xSOMETHING
|
||||
|
||||
#define TRC_CA9_MPCORE_PRIVATE_MEMORY_OFFSET 0x0600
|
||||
#define TRC_CA9_MPCORE_PRIVCTR_PERIOD_REG (*(volatile uint32_t*)(TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS + TRC_CA9_MPCORE_PRIVATE_MEMORY_OFFSET + 0x00))
|
||||
#define TRC_CA9_MPCORE_PRIVCTR_COUNTER_REG (*(volatile uint32_t*)(TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS + TRC_CA9_MPCORE_PRIVATE_MEMORY_OFFSET + 0x04))
|
||||
#define TRC_CA9_MPCORE_PRIVCTR_CONTROL_REG (*(volatile uint32_t*)(TRC_CA9_MPCORE_PERIPHERAL_BASE_ADDRESS + TRC_CA9_MPCORE_PRIVATE_MEMORY_OFFSET + 0x08))
|
||||
|
||||
#define TRC_CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_MASK 0x0000FF00
|
||||
#define TRC_CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_SHIFT 8
|
||||
#define TRC_CA9_MPCORE_PRIVCTR_PRESCALER (((TRC_CA9_MPCORE_PRIVCTR_CONTROL_REG & TRC_CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_MASK) >> TRC_CA9_MPCORE_PRIVCTR_CONTROL_PRESCALER_SHIFT) + 1)
|
||||
|
||||
#define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
|
||||
#define TRC_HWTC_COUNT TRC_CA9_MPCORE_PRIVCTR_COUNTER_REG
|
||||
#define TRC_HWTC_PERIOD (TRC_CA9_MPCORE_PRIVCTR_PERIOD_REG + 1)
|
||||
|
||||
/****************************************************************************************
|
||||
NOTE: The private timer ticks with a very high frequency (half the core-clock usually),
|
||||
depending on the prescaler used. If a low prescaler is used, the number of HW ticks between
|
||||
the trace events gets large, and thereby inefficient to store (sometimes extra events are
|
||||
needed). To improve efficiency, you may use the TRC_HWTC_DIVISOR as an additional prescaler.
|
||||
*****************************************************************************************/
|
||||
#define TRC_HWTC_DIVISOR 1
|
||||
|
||||
#define TRC_HWTC_FREQ_HZ (TRACE_TICK_RATE_HZ * TRC_HWTC_PERIOD)
|
||||
#define TRC_IRQ_PRIORITY_ORDER 0
|
||||
|
||||
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_POWERPC_Z4)
|
||||
|
||||
/* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */
|
||||
|
||||
#define TRC_HWTC_TYPE TRC_OS_TIMER_DECR
|
||||
//#define HWTC_COUNT_DIRECTION DIRECTION_DECREMENTING
|
||||
#define TRC_HWTC_COUNT PIT.TIMER[configTICK_PIT_CHANNEL].CVAL.R // must be the PIT channel used for the systick
|
||||
#define TRC_HWTC_PERIOD ((configPIT_CLOCK_HZ / configTICK_RATE_HZ) - 1U) // TODO FIXME or maybe not -1? what's the right "period" value?
|
||||
#define TRC_HWTC_FREQ_HZ configPIT_CLOCK_HZ
|
||||
#define TRC_HWTC_DIVISOR 1
|
||||
#define TRC_IRQ_PRIORITY_ORDER 1 // higher IRQ priority values are more significant
|
||||
|
||||
#elif (TRC_CFG_HARDWARE_PORT == TRC_HARDWARE_PORT_APPLICATION_DEFINED)
|
||||
|
||||
#if !( defined (TRC_HWTC_TYPE) && defined (TRC_HWTC_COUNT) && defined (TRC_HWTC_PERIOD) && defined (TRC_HWTC_FREQ_HZ) && defined (TRC_IRQ_PRIORITY_ORDER) )
|
||||
#error "The hardware port is not completely defined!"
|
||||
#endif
|
||||
|
||||
#elif (TRC_CFG_HARDWARE_PORT != TRC_HARDWARE_PORT_NOT_SET)
|
||||
|
||||
#error "TRC_CFG_HARDWARE_PORT had unsupported value!"
|
||||
#define TRC_CFG_HARDWARE_PORT TRC_HARDWARE_PORT_NOT_SET
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef TRC_HWTC_DIVISOR
|
||||
#define TRC_HWTC_DIVISOR 1
|
||||
#endif
|
||||
|
||||
#ifndef TRC_PORT_SPECIFIC_INIT
|
||||
#define TRC_PORT_SPECIFIC_INIT()
|
||||
#endif
|
||||
|
||||
/* If Win32 port */
|
||||
#ifdef WIN32
|
||||
|
||||
#undef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0600
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <direct.h>
|
||||
|
||||
/***************************************************************************
|
||||
* The Win32 port by default saves the trace to file and then kills the
|
||||
* program when the recorder is stopped, to facilitate quick, simple tests
|
||||
* of the recorder.
|
||||
***************************************************************************/
|
||||
#define WIN32_PORT_SAVE_WHEN_STOPPED 1
|
||||
#define WIN32_PORT_EXIT_WHEN_STOPPED 1
|
||||
|
||||
#endif
|
||||
|
||||
#if (TRC_CFG_HARDWARE_PORT != TRC_HARDWARE_PORT_NOT_SET)
|
||||
|
||||
#ifndef TRC_HWTC_TYPE
|
||||
#error "TRC_HWTC_TYPE is not set!"
|
||||
#endif
|
||||
|
||||
#ifndef TRC_HWTC_COUNT
|
||||
#error "TRC_HWTC_COUNT is not set!"
|
||||
#endif
|
||||
|
||||
#ifndef TRC_HWTC_PERIOD
|
||||
#error "TRC_HWTC_PERIOD is not set!"
|
||||
#endif
|
||||
|
||||
#ifndef TRC_HWTC_DIVISOR
|
||||
#error "TRC_HWTC_DIVISOR is not set!"
|
||||
#endif
|
||||
|
||||
#ifndef TRC_IRQ_PRIORITY_ORDER
|
||||
#error "TRC_IRQ_PRIORITY_ORDER is not set!"
|
||||
#elif (TRC_IRQ_PRIORITY_ORDER != 0) && (TRC_IRQ_PRIORITY_ORDER != 1)
|
||||
#error "TRC_IRQ_PRIORITY_ORDER has bad value!"
|
||||
#endif
|
||||
|
||||
#if (TRC_HWTC_DIVISOR < 1)
|
||||
#error "TRC_HWTC_DIVISOR must be a non-zero positive value!"
|
||||
#endif
|
||||
|
||||
#ifndef TRC_HWTC_FREQ_HZ
|
||||
#error "TRC_HWTC_FREQ_HZ not defined!"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /*TRC_SNAPSHOT_HARDWARE_PORT_H*/
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,137 @@
|
||||
/*******************************************************************************
|
||||
* Trace Recorder Library for Tracealyzer v4.1.5
|
||||
* Percepio AB, www.percepio.com
|
||||
*
|
||||
* trcPortDefines.h
|
||||
*
|
||||
* 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
|
||||
#define TRC_PORTDEFINES_H
|
||||
|
||||
#define TRC_FREE_RUNNING_32BIT_INCR 1
|
||||
#define TRC_FREE_RUNNING_32BIT_DECR 2
|
||||
#define TRC_OS_TIMER_INCR 3
|
||||
#define TRC_OS_TIMER_DECR 4
|
||||
#define TRC_CUSTOM_TIMER_INCR 5
|
||||
#define TRC_CUSTOM_TIMER_DECR 6
|
||||
|
||||
/* Start options for vTraceEnable. */
|
||||
#define TRC_INIT 0
|
||||
#define TRC_START 1
|
||||
#define TRC_START_AWAIT_HOST 2
|
||||
|
||||
/* Command codes for TzCtrl task */
|
||||
#define CMD_SET_ACTIVE 1 /* Start (param1 = 1) or Stop (param1 = 0) */
|
||||
|
||||
/* The final command code, used to validate commands. */
|
||||
#define CMD_LAST_COMMAND 1
|
||||
|
||||
#define TRC_RECORDER_MODE_SNAPSHOT 0
|
||||
#define TRC_RECORDER_MODE_STREAMING 1
|
||||
|
||||
#define TRC_RECORDER_BUFFER_ALLOCATION_STATIC (0x00)
|
||||
#define TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC (0x01)
|
||||
#define TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM (0x02)
|
||||
|
||||
/* Filter Groups */
|
||||
#define FilterGroup0 (uint16_t)0x0001
|
||||
#define FilterGroup1 (uint16_t)0x0002
|
||||
#define FilterGroup2 (uint16_t)0x0004
|
||||
#define FilterGroup3 (uint16_t)0x0008
|
||||
#define FilterGroup4 (uint16_t)0x0010
|
||||
#define FilterGroup5 (uint16_t)0x0020
|
||||
#define FilterGroup6 (uint16_t)0x0040
|
||||
#define FilterGroup7 (uint16_t)0x0080
|
||||
#define FilterGroup8 (uint16_t)0x0100
|
||||
#define FilterGroup9 (uint16_t)0x0200
|
||||
#define FilterGroup10 (uint16_t)0x0400
|
||||
#define FilterGroup11 (uint16_t)0x0800
|
||||
#define FilterGroup12 (uint16_t)0x1000
|
||||
#define FilterGroup13 (uint16_t)0x2000
|
||||
#define FilterGroup14 (uint16_t)0x4000
|
||||
#define FilterGroup15 (uint16_t)0x8000
|
||||
|
||||
/******************************************************************************
|
||||
* Supported ports
|
||||
*
|
||||
* TRC_HARDWARE_PORT_HWIndependent
|
||||
* A hardware independent fallback option for event timestamping. Provides low
|
||||
* resolution timestamps based on the OS tick.
|
||||
* This may be used on the Win32 port, but may also be used on embedded hardware
|
||||
* platforms. All time durations will be truncated to the OS tick frequency,
|
||||
* typically 1 KHz. This means that a task or ISR that executes in less than
|
||||
* 1 ms get an execution time of zero.
|
||||
*
|
||||
* TRC_HARDWARE_PORT_APPLICATION_DEFINED
|
||||
* Allows for defining the port macros in other source code files.
|
||||
*
|
||||
* TRC_HARDWARE_PORT_Win32
|
||||
* "Accurate" timestamping based on the Windows performance counter for Win32
|
||||
* builds. Note that this gives the host machine time, not the kernel time.
|
||||
*
|
||||
* Hardware specific ports
|
||||
* To get accurate timestamping, a hardware timer is necessary. Below are the
|
||||
* available ports. Some of these are "unofficial", meaning that
|
||||
* they have not yet been verified by Percepio but have been contributed by
|
||||
* external developers. They should work, otherwise let us know by emailing
|
||||
* support@percepio.com. Some work on any OS platform, while other are specific
|
||||
* to a certain operating system.
|
||||
*****************************************************************************/
|
||||
|
||||
/****** Port Name ************************************* Code ** Official ** OS Platform *********/
|
||||
#define TRC_HARDWARE_PORT_APPLICATION_DEFINED 98 /* - - */
|
||||
#define TRC_HARDWARE_PORT_NOT_SET 99 /* - - */
|
||||
#define TRC_HARDWARE_PORT_HWIndependent 0 /* Yes Any */
|
||||
#define TRC_HARDWARE_PORT_Win32 1 /* Yes FreeRTOS on Win32 */
|
||||
#define TRC_HARDWARE_PORT_Atmel_AT91SAM7 2 /* No Any */
|
||||
#define TRC_HARDWARE_PORT_Atmel_UC3A0 3 /* No Any */
|
||||
#define TRC_HARDWARE_PORT_ARM_Cortex_M 4 /* Yes Any */
|
||||
#define TRC_HARDWARE_PORT_Renesas_RX600 6 /* Yes Any */
|
||||
#define TRC_HARDWARE_PORT_MICROCHIP_PIC24_PIC32 7 /* Yes Any */
|
||||
#define TRC_HARDWARE_PORT_TEXAS_INSTRUMENTS_TMS570_RM48 8 /* Yes Any */
|
||||
#define TRC_HARDWARE_PORT_TEXAS_INSTRUMENTS_MSP430 9 /* No Any */
|
||||
#define TRC_HARDWARE_PORT_XILINX_PPC405 11 /* No FreeRTOS */
|
||||
#define TRC_HARDWARE_PORT_XILINX_PPC440 12 /* No FreeRTOS */
|
||||
#define TRC_HARDWARE_PORT_XILINX_MICROBLAZE 13 /* No Any */
|
||||
#define TRC_HARDWARE_PORT_NXP_LPC210X 14 /* No Any */
|
||||
#define TRC_HARDWARE_PORT_ARM_CORTEX_A9 15 /* Yes Any */
|
||||
#define TRC_HARDWARE_PORT_POWERPC_Z4 16 /* No FreeRTOS */
|
||||
#define TRC_HARDWARE_PORT_Altera_NiosII 17 /* No Any */
|
||||
#endif /*TRC_PORTDEFINES_H*/
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,5 @@
|
||||
[InternetShortcut]
|
||||
URL=http://www.freertos.org/trace
|
||||
IDList=
|
||||
[{000214A0-0000-0000-C000-000000000046}]
|
||||
Prop3=19,2
|
@ -0,0 +1,301 @@
|
||||
/*******************************************************************************
|
||||
* Trace Recorder Library for Tracealyzer v4.1.4
|
||||
* Percepio AB, www.percepio.com
|
||||
*
|
||||
* trcConfig.h
|
||||
*
|
||||
* Main configuration parameters for the trace recorder library.
|
||||
* 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
|
||||
#define TRC_CONFIG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "trcPortDefines.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Include of processor header file
|
||||
*
|
||||
* Here you may need to include the header file for your processor. This is
|
||||
* required at least for the ARM Cortex-M port, that uses the ARM CMSIS API.
|
||||
* Try that in case of build problems. Otherwise, remove the #error line below.
|
||||
*****************************************************************************/
|
||||
#error "Trace Recorder: Please include your processor's header file here and remove this line."
|
||||
|
||||
/*******************************************************************************
|
||||
* Configuration Macro: TRC_CFG_HARDWARE_PORT
|
||||
*
|
||||
* Specify what hardware port to use (i.e., the "timestamping driver").
|
||||
*
|
||||
* All ARM Cortex-M MCUs are supported by "TRC_HARDWARE_PORT_ARM_Cortex_M".
|
||||
* This port uses the DWT cycle counter for Cortex-M3/M4/M7 devices, which is
|
||||
* available on most such devices. In case your device don't have DWT support,
|
||||
* you will get an error message opening the trace. In that case, you may
|
||||
* force the recorder to use SysTick timestamping instead, using this define:
|
||||
*
|
||||
* #define TRC_CFG_ARM_CM_USE_SYSTICK
|
||||
*
|
||||
* For ARM Cortex-M0/M0+ devices, SysTick mode is used automatically.
|
||||
*
|
||||
* See trcHardwarePort.h for available ports and information on how to
|
||||
* define your own port, if not already present.
|
||||
******************************************************************************/
|
||||
#define TRC_CFG_HARDWARE_PORT TRC_HARDWARE_PORT_NOT_SET
|
||||
|
||||
/*******************************************************************************
|
||||
* Configuration Macro: TRC_CFG_RECORDER_MODE
|
||||
*
|
||||
* 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 If using FreeRTOS v7.3.x
|
||||
* TRC_FREERTOS_VERSION_7_4 If using FreeRTOS v7.4.x
|
||||
* TRC_FREERTOS_VERSION_7_5_OR_7_6 If using FreeRTOS v7.5.0 - v7.6.0
|
||||
* TRC_FREERTOS_VERSION_8_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 or later
|
||||
*****************************************************************************/
|
||||
#define TRC_CFG_FREERTOS_VERSION TRC_FREERTOS_VERSION_10_0_0
|
||||
|
||||
/*******************************************************************************
|
||||
* 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 disabled (= 0), all events are recorded (unless filtered in other ways).
|
||||
*
|
||||
* Default value is 0 (= include additional events).
|
||||
******************************************************************************/
|
||||
#define TRC_CFG_SCHEDULING_ONLY 0
|
||||
|
||||
/******************************************************************************
|
||||
* TRC_CFG_INCLUDE_MEMMANG_EVENTS
|
||||
*
|
||||
* Macro which should be defined as either zero (0) or one (1).
|
||||
*
|
||||
* This controls if malloc and free calls should be traced. Set this to zero (0)
|
||||
* to exclude malloc/free calls, or one (1) to include such events in the trace.
|
||||
*
|
||||
* Default value is 1.
|
||||
*****************************************************************************/
|
||||
#define TRC_CFG_INCLUDE_MEMMANG_EVENTS 1
|
||||
|
||||
/******************************************************************************
|
||||
* TRC_CFG_INCLUDE_USER_EVENTS
|
||||
*
|
||||
* Macro which should be defined as either zero (0) or one (1).
|
||||
*
|
||||
* If this is zero (0), all code related to User Events is excluded in order
|
||||
* to reduce code size. Any attempts of storing User Events are then silently
|
||||
* ignored.
|
||||
*
|
||||
* User Events are application-generated events, like "printf" but for the
|
||||
* trace log, generated using vTracePrint and vTracePrintF.
|
||||
* The formatting is done on host-side, by Tracealyzer. User Events are
|
||||
* therefore much faster than a console printf and can often be used
|
||||
* in timing critical code without problems.
|
||||
*
|
||||
* Note: In streaming mode, User Events are used to provide error messages
|
||||
* and warnings from the recorder (in case of incorrect configuration) for
|
||||
* display in Tracealyzer. Disabling user events will also disable these
|
||||
* warnings. You can however still catch them by calling xTraceGetLastError
|
||||
* or by putting breakpoints in prvTraceError and prvTraceWarning.
|
||||
*
|
||||
* Default value is 1.
|
||||
*****************************************************************************/
|
||||
#define TRC_CFG_INCLUDE_USER_EVENTS 1
|
||||
|
||||
/*****************************************************************************
|
||||
* TRC_CFG_INCLUDE_ISR_TRACING
|
||||
*
|
||||
* Macro which should be defined as either zero (0) or one (1).
|
||||
*
|
||||
* If this is zero (0), the code for recording Interrupt Service Routines is
|
||||
* excluded, in order to reduce code size.
|
||||
*
|
||||
* Default value is 1.
|
||||
*
|
||||
* Note: tracing ISRs requires that you insert calls to vTraceStoreISRBegin
|
||||
* and vTraceStoreISREnd in your interrupt handlers.
|
||||
*****************************************************************************/
|
||||
#define TRC_CFG_INCLUDE_ISR_TRACING 1
|
||||
|
||||
/*****************************************************************************
|
||||
* TRC_CFG_INCLUDE_READY_EVENTS
|
||||
*
|
||||
* Macro which should be defined as either zero (0) or one (1).
|
||||
*
|
||||
* If one (1), events are recorded when tasks enter scheduling state "ready".
|
||||
* This allows Tracealyzer to show the initial pending time before tasks enter
|
||||
* the execution state, and present accurate response times.
|
||||
* If zero (0), "ready events" are not created, which allows for recording
|
||||
* longer traces in the same amount of RAM.
|
||||
*
|
||||
* Default value is 1.
|
||||
*****************************************************************************/
|
||||
#define TRC_CFG_INCLUDE_READY_EVENTS 1
|
||||
|
||||
/*****************************************************************************
|
||||
* TRC_CFG_INCLUDE_OSTICK_EVENTS
|
||||
*
|
||||
* Macro which should be defined as either zero (0) or one (1).
|
||||
*
|
||||
* If this is one (1), events will be generated whenever the OS clock is
|
||||
* increased. If zero (0), OS tick events are not generated, which allows for
|
||||
* recording longer traces in the same amount of RAM.
|
||||
*
|
||||
* Default value is 1.
|
||||
*****************************************************************************/
|
||||
#define TRC_CFG_INCLUDE_OSTICK_EVENTS 1
|
||||
|
||||
/*****************************************************************************
|
||||
* 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
|
||||
*
|
||||
* 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
|
||||
|
||||
/*******************************************************************************
|
||||
* Configuration Macro: TRC_CFG_RECORDER_BUFFER_ALLOCATION
|
||||
*
|
||||
* Specifies how the recorder buffer is allocated (also in case of streaming, in
|
||||
* port using the recorder's internal temporary buffer)
|
||||
*
|
||||
* Values:
|
||||
* TRC_RECORDER_BUFFER_ALLOCATION_STATIC - Static allocation (internal)
|
||||
* TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC - Malloc in vTraceEnable
|
||||
* TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM - Use vTraceSetRecorderDataBuffer
|
||||
*
|
||||
* Static and dynamic mode does the allocation for you, either in compile time
|
||||
* (static) or in runtime (malloc).
|
||||
* The custom mode allows you to control how and where the allocation is made,
|
||||
* for details see TRC_ALLOC_CUSTOM_BUFFER and vTraceSetRecorderDataBuffer().
|
||||
******************************************************************************/
|
||||
#define TRC_CFG_RECORDER_BUFFER_ALLOCATION TRC_RECORDER_BUFFER_ALLOCATION_STATIC
|
||||
|
||||
/******************************************************************************
|
||||
* TRC_CFG_MAX_ISR_NESTING
|
||||
*
|
||||
* Defines how many levels of interrupt nesting the recorder can handle, in
|
||||
* case multiple ISRs are traced and ISR nesting is possible. If this
|
||||
* is exceeded, the particular ISR will not be traced and the recorder then
|
||||
* logs an error message. This setting is used to allocate an internal stack
|
||||
* for keeping track of the previous execution context (4 byte per entry).
|
||||
*
|
||||
* This value must be a non-zero positive constant, at least 1.
|
||||
*
|
||||
* Default value: 8
|
||||
*****************************************************************************/
|
||||
#define TRC_CFG_MAX_ISR_NESTING 8
|
||||
|
||||
/* Specific configuration, depending on Streaming/Snapshot mode */
|
||||
#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT)
|
||||
#include "trcSnapshotConfig.h"
|
||||
#elif (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
|
||||
#include "trcStreamingConfig.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _TRC_CONFIG_H */
|
@ -0,0 +1,377 @@
|
||||
/*******************************************************************************
|
||||
* Trace Recorder Library for Tracealyzer v4.1.4
|
||||
* Percepio AB, www.percepio.com
|
||||
*
|
||||
* trcSnapshotConfig.h
|
||||
*
|
||||
* Configuration parameters for trace recorder library in snapshot mode.
|
||||
* 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
|
||||
#define TRC_SNAPSHOT_CONFIG_H
|
||||
|
||||
#define TRC_SNAPSHOT_MODE_RING_BUFFER (0x01)
|
||||
#define TRC_SNAPSHOT_MODE_STOP_WHEN_FULL (0x02)
|
||||
|
||||
/******************************************************************************
|
||||
* TRC_CFG_SNAPSHOT_MODE
|
||||
*
|
||||
* Macro which should be defined as one of:
|
||||
* - TRC_SNAPSHOT_MODE_RING_BUFFER
|
||||
* - TRC_SNAPSHOT_MODE_STOP_WHEN_FULL
|
||||
* Default is TRC_SNAPSHOT_MODE_RING_BUFFER.
|
||||
*
|
||||
* With TRC_CFG_SNAPSHOT_MODE set to TRC_SNAPSHOT_MODE_RING_BUFFER, the
|
||||
* events are stored in a ring buffer, i.e., where the oldest events are
|
||||
* overwritten when the buffer becomes full. This allows you to get the last
|
||||
* events leading up to an interesting state, e.g., an error, without having
|
||||
* to store the whole run since startup.
|
||||
*
|
||||
* When TRC_CFG_SNAPSHOT_MODE is TRC_SNAPSHOT_MODE_STOP_WHEN_FULL, the
|
||||
* recording is stopped when the buffer becomes full. This is useful for
|
||||
* recording events following a specific state, e.g., the startup sequence.
|
||||
*****************************************************************************/
|
||||
#define TRC_CFG_SNAPSHOT_MODE TRC_SNAPSHOT_MODE_RING_BUFFER
|
||||
|
||||
/*******************************************************************************
|
||||
* TRC_CFG_EVENT_BUFFER_SIZE
|
||||
*
|
||||
* Macro which should be defined as an integer value.
|
||||
*
|
||||
* This defines the capacity of the event buffer, i.e., the number of records
|
||||
* it may store. Most events use one record (4 byte), although some events
|
||||
* require multiple 4-byte records. You should adjust this to the amount of RAM
|
||||
* available in the target system.
|
||||
*
|
||||
* Default value is 1000, which means that 4000 bytes is allocated for the
|
||||
* event buffer.
|
||||
******************************************************************************/
|
||||
#define TRC_CFG_EVENT_BUFFER_SIZE 1000
|
||||
|
||||
/*******************************************************************************
|
||||
* 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 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
|
||||
* vTracePrintF is stripped out, in case floating point values are not used or
|
||||
* supported by the platform used.
|
||||
*
|
||||
* Floating point values are only used in vTracePrintF and its subroutines, to
|
||||
* allow for storing float (%f) or double (%lf) arguments.
|
||||
*
|
||||
* vTracePrintF can be used with integer and string arguments in either case.
|
||||
*
|
||||
* Default value is 0.
|
||||
*****************************************************************************/
|
||||
#define TRC_CFG_INCLUDE_FLOAT_SUPPORT 0
|
||||
|
||||
/*******************************************************************************
|
||||
* TRC_CFG_SYMBOL_TABLE_SIZE
|
||||
*
|
||||
* Macro which should be defined as an integer value.
|
||||
*
|
||||
* This defines the capacity of the symbol table, in bytes. This symbol table
|
||||
* stores User Events labels and names of deleted tasks, queues, or other kernel
|
||||
* objects. If you don't use User Events or delete any kernel
|
||||
* objects you set this to a very low value. The minimum recommended value is 4.
|
||||
* A size of zero (0) is not allowed since a zero-sized array may result in a
|
||||
* 32-bit pointer, i.e., using 4 bytes rather than 0.
|
||||
*
|
||||
* Default value is 800.
|
||||
******************************************************************************/
|
||||
#define TRC_CFG_SYMBOL_TABLE_SIZE 800
|
||||
|
||||
#if (TRC_CFG_SYMBOL_TABLE_SIZE == 0)
|
||||
#error "TRC_CFG_SYMBOL_TABLE_SIZE may not be zero!"
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* 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 ********************************************************
|
||||
******************************************************************************
|
||||
* The remaining settings are not necessary to modify but allows for optimizing
|
||||
* the recorder setup for your specific needs, e.g., to exclude events that you
|
||||
* are not interested in, in order to get longer traces.
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* TRC_CFG_HEAP_SIZE_BELOW_16M
|
||||
*
|
||||
* An integer constant that can be used to reduce the buffer usage of memory
|
||||
* allocation events (malloc/free). This value should be 1 if the heap size is
|
||||
* below 16 MB (2^24 byte), and you can live with reported addresses showing the
|
||||
* lower 24 bits only. If 0, you get the full 32-bit addresses.
|
||||
*
|
||||
* Default value is 0.
|
||||
******************************************************************************/
|
||||
#define TRC_CFG_HEAP_SIZE_BELOW_16M 0
|
||||
|
||||
/******************************************************************************
|
||||
* TRC_CFG_USE_IMPLICIT_IFE_RULES
|
||||
*
|
||||
* Macro which should be defined as either zero (0) or one (1).
|
||||
* Default is 1.
|
||||
*
|
||||
* Tracealyzer groups the events into "instances" based on Instance Finish
|
||||
* Events (IFEs), produced either by default rules or calls to the recorder
|
||||
* functions vTraceInstanceFinishedNow and vTraceInstanceFinishedNext.
|
||||
*
|
||||
* If TRC_CFG_USE_IMPLICIT_IFE_RULES is one (1), the default IFE rules is
|
||||
* used, resulting in a "typical" grouping of events into instances.
|
||||
* If these rules don't give appropriate instances in your case, you can
|
||||
* override the default rules using vTraceInstanceFinishedNow/Next for one
|
||||
* or several tasks. The default IFE rules are then disabled for those tasks.
|
||||
*
|
||||
* If TRC_CFG_USE_IMPLICIT_IFE_RULES is zero (0), the implicit IFE rules are
|
||||
* disabled globally. You must then call vTraceInstanceFinishedNow or
|
||||
* vTraceInstanceFinishedNext to manually group the events into instances,
|
||||
* otherwise the tasks will appear a single long instance.
|
||||
*
|
||||
* The default IFE rules count the following events as "instance finished":
|
||||
* - Task delay, delay until
|
||||
* - Task suspend
|
||||
* - Blocking on "input" operations, i.e., when the task is waiting for the
|
||||
* next a message/signal/event. But only if this event is blocking.
|
||||
*
|
||||
* 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
|
||||
|
||||
/******************************************************************************
|
||||
* TRC_CFG_USE_16BIT_OBJECT_HANDLES
|
||||
*
|
||||
* Macro which should be defined as either zero (0) or one (1).
|
||||
*
|
||||
* If set to 0 (zero), the recorder uses 8-bit handles to identify kernel
|
||||
* objects such as tasks and queues. This limits the supported number of
|
||||
* concurrently active objects to 255 of each type (tasks, queues, mutexes,
|
||||
* etc.) Note: 255, not 256, since handle 0 is reserved.
|
||||
*
|
||||
* If set to 1 (one), the recorder uses 16-bit handles to identify kernel
|
||||
* objects such as tasks and queues. This limits the supported number of
|
||||
* concurrent objects to 65535 of each type (object class). However, since the
|
||||
* object property table is limited to 64 KB, the practical limit is about
|
||||
* 3000 objects in total.
|
||||
*
|
||||
* Default is 0 (8-bit handles)
|
||||
*
|
||||
* NOTE: An object with handle above 255 will use an extra 4-byte record in
|
||||
* the event buffer whenever the object is referenced. Moreover, some internal
|
||||
* tables in the recorder gets slightly larger when using 16-bit handles.
|
||||
*****************************************************************************/
|
||||
#define TRC_CFG_USE_16BIT_OBJECT_HANDLES 0
|
||||
|
||||
/******************************************************************************
|
||||
* TRC_CFG_USE_TRACE_ASSERT
|
||||
*
|
||||
* 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
|
||||
* separate user event buffer (UB).
|
||||
* In this mode, user events are stored separately from other events,
|
||||
* e.g., RTOS events. Thereby you can get a much longer history of
|
||||
* user events as they don't need to share the buffer space with more
|
||||
* frequent events.
|
||||
*
|
||||
* The UB is typically used with the snapshot ring-buffer mode, so the
|
||||
* recording can continue when the main buffer gets full. And since the
|
||||
* main buffer then overwrites the earliest events, Tracealyzer displays
|
||||
* "Unknown Actor" instead of task scheduling for periods with UB data only.
|
||||
*
|
||||
* In UB mode, user events are structured as UB channels, which contains
|
||||
* a channel name and a default format string. Register a UB channel using
|
||||
* xTraceRegisterUBChannel.
|
||||
*
|
||||
* Events and data arguments are written using vTraceUBEvent and
|
||||
* vTraceUBData. They are designed to provide efficient logging of
|
||||
* repeating events, using the same format string within each channel.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* traceString chn1 = xTraceRegisterString("Channel 1");
|
||||
* traceString fmt1 = xTraceRegisterString("Event!");
|
||||
* traceUBChannel UBCh1 = xTraceRegisterUBChannel(chn1, fmt1);
|
||||
*
|
||||
* traceString chn2 = xTraceRegisterString("Channel 2");
|
||||
* traceString fmt2 = xTraceRegisterString("X: %d, Y: %d");
|
||||
* traceUBChannel UBCh2 = xTraceRegisterUBChannel(chn2, fmt2);
|
||||
*
|
||||
* // Result in "[Channel 1] Event!"
|
||||
* vTraceUBEvent(UBCh1);
|
||||
*
|
||||
* // Result in "[Channel 2] X: 23, Y: 19"
|
||||
* vTraceUBData(UBCh2, 23, 19);
|
||||
*
|
||||
* You can also use the other user event functions, like vTracePrintF.
|
||||
* as they are then rerouted to the UB instead of the main event buffer.
|
||||
* vTracePrintF then looks up the correct UB channel based on the
|
||||
* provided channel name and format string, or creates a new UB channel
|
||||
* if no match is found. The format string should therefore not contain
|
||||
* "random" messages but mainly format specifiers. Random strings should
|
||||
* be stored using %s and with the string as an argument.
|
||||
*
|
||||
* // Creates a new UB channel ("Channel 2", "%Z: %d")
|
||||
* vTracePrintF(chn2, "%Z: %d", value1);
|
||||
*
|
||||
* // Finds the existing UB channel
|
||||
* vTracePrintF(chn2, "%Z: %d", value2);
|
||||
|
||||
******************************************************************************/
|
||||
#define TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER 0
|
||||
|
||||
/*******************************************************************************
|
||||
* TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE
|
||||
*
|
||||
* Macro which should be defined as an integer value.
|
||||
*
|
||||
* This defines the capacity of the user event buffer (UB), in number of slots.
|
||||
* A single user event can use multiple slots, depending on the arguments.
|
||||
*
|
||||
* Only applicable if TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER is 1.
|
||||
******************************************************************************/
|
||||
#define TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE 200
|
||||
|
||||
/*******************************************************************************
|
||||
* TRC_CFG_UB_CHANNELS
|
||||
*
|
||||
* Macro which should be defined as an integer value.
|
||||
*
|
||||
* This defines the number of User Event Buffer Channels (UB channels).
|
||||
* These are used to structure the events when using the separate user
|
||||
* event buffer, and contains both a User Event Channel (the name) and
|
||||
* a default format string for the channel.
|
||||
*
|
||||
* Only applicable if TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER is 1.
|
||||
******************************************************************************/
|
||||
#define TRC_CFG_UB_CHANNELS 32
|
||||
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
|
||||
#endif /*TRC_SNAPSHOT_CONFIG_H*/
|
@ -0,0 +1,170 @@
|
||||
/*******************************************************************************
|
||||
* Trace Recorder Library for Tracealyzer v4.1.4
|
||||
* Percepio AB, www.percepio.com
|
||||
*
|
||||
* trcStreamingConfig.h
|
||||
*
|
||||
* Configuration parameters for the trace recorder library in streaming mode.
|
||||
* 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
|
||||
#define TRC_STREAMING_CONFIG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* Configuration Macro: TRC_CFG_SYMBOL_TABLE_SLOTS
|
||||
*
|
||||
* The maximum number of symbols names that can be stored. This includes:
|
||||
* - Task names
|
||||
* - Named ISRs (vTraceSetISRProperties)
|
||||
* - Named kernel objects (vTraceStoreKernelObjectName)
|
||||
* - User event channels (xTraceRegisterString)
|
||||
*
|
||||
* 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
|
||||
* (as User Events) from TzCtrl task, that monitors this.
|
||||
******************************************************************************/
|
||||
#define TRC_CFG_SYMBOL_TABLE_SLOTS 40
|
||||
|
||||
/*******************************************************************************
|
||||
* Configuration Macro: TRC_CFG_SYMBOL_MAX_LENGTH
|
||||
*
|
||||
* The maximum length of symbol names, including:
|
||||
* - Task names
|
||||
* - Named ISRs (vTraceSetISRProperties)
|
||||
* - Named kernel objects (vTraceStoreKernelObjectName)
|
||||
* - User event channel names (xTraceRegisterString)
|
||||
*
|
||||
* 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
|
||||
* (as User Events) from TzCtrl task, that monitors this.
|
||||
******************************************************************************/
|
||||
#define TRC_CFG_SYMBOL_MAX_LENGTH 25
|
||||
|
||||
/*******************************************************************************
|
||||
* 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_CTRL_TASK_STACK_SIZE
|
||||
*
|
||||
* The stack size of the TzCtrl task, that receive commands.
|
||||
* We are aiming to remove this extra task in future versions.
|
||||
******************************************************************************/
|
||||
#define TRC_CFG_CTRL_TASK_STACK_SIZE (configMINIMAL_STACK_SIZE * 2)
|
||||
|
||||
/*******************************************************************************
|
||||
* Configuration Macro: TRC_CFG_CTRL_TASK_PRIORITY
|
||||
*
|
||||
* The priority of the TzCtrl task, that receive commands from Tracealyzer.
|
||||
* Most stream ports also rely on the TzCtrl task to transmit the data from the
|
||||
* internal buffer to the stream interface (all except for the J-Link port).
|
||||
* For such ports, make sure the TzCtrl priority is high enough to ensure
|
||||
* reliable periodic execution and transfer of the data.
|
||||
******************************************************************************/
|
||||
#define TRC_CFG_CTRL_TASK_PRIORITY 1
|
||||
|
||||
/*******************************************************************************
|
||||
* Configuration Macro: TRC_CFG_CTRL_TASK_DELAY
|
||||
*
|
||||
* The delay between every loop of the TzCtrl task. A high delay will reduce the
|
||||
* CPU load, but may cause missed events if the TzCtrl task is performing the
|
||||
* trace transfer.
|
||||
******************************************************************************/
|
||||
#define TRC_CFG_CTRL_TASK_DELAY ((10 * configTICK_RATE_HZ) / 1000)
|
||||
|
||||
/*******************************************************************************
|
||||
* 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 2
|
||||
|
||||
/*******************************************************************************
|
||||
* 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).
|
||||
*
|
||||
* Note: not used by the J-Link RTT stream port (see trcStreamingPort.h instead)
|
||||
******************************************************************************/
|
||||
#define TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE 2500
|
||||
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TRC_STREAMING_CONFIG_H */
|
@ -0,0 +1,152 @@
|
||||
-------------------------------------------------------------------------------
|
||||
Tracealyzer for FreeRTOS - Trace Recorder Library v3.1.1
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Tracealyzer for FreeRTOS is a sophisticated tool for tracing and visualization
|
||||
of FreeRTOS-based systems. Tracealyzer gives an unprecedented insight into the
|
||||
runtime behavior, which speeds up debugging, validation and optimization.
|
||||
|
||||
To learn more about this, see
|
||||
|
||||
- Getting Started (videos etc): http://percepio.com/gettingstarted/tz-freertos/
|
||||
|
||||
- User Manual (incl. Recorder API): http://percepio.com/docs/FreeRTOS/manual
|
||||
|
||||
- FAQ: http://percepio.com/category/faq/
|
||||
|
||||
In case you have any questions, don't hesitate to contact support@percepio.com
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Changes, v3.1.1 -> v3.1.2
|
||||
|
||||
- Fixed two bugs related to User Events, one in vTracePrintF and other in vTracePrint.
|
||||
|
||||
- Fixed a build problem related to a single reference of the old FreeRTOS type "xTaskHandle", in trcKernelPort.c.
|
||||
Changed to "TaskHandle_t", unless if using an older FreeRTOS kernel or the "compatibility mode".
|
||||
|
||||
- Removed traceCREATE_MUTEX hook for FreeRTOS v9 or later (no longer required)
|
||||
|
||||
- Updated the User Manual regarding snapshot trace via IAR Embedded Workbench.
|
||||
|
||||
- Renamed vTraceGetTraceBuffer to xTraceGetTraceBuffer, since returning a pointer.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Changes, v3.1.0 -> v3.1.1
|
||||
|
||||
After the major changes in the v3.1.0 trace recorder library, this update
|
||||
corrects a number of minor issues. Only minor functional improvements.
|
||||
|
||||
- You can now use TRC_ALLOC_CUSTOM_BUFFER to declare a trace buffer on a custom
|
||||
location (using linker directives).
|
||||
The related function vTraceSetRecorderDataBuffer has been promoted to the
|
||||
Common API (previously only supported in snapshot mode, but custom allocation
|
||||
is now generally supported also in streaming mode).
|
||||
|
||||
- Removed TRC_CFG_USE_LINKER_PRAGMA. No longer necessary thanks to the custom
|
||||
allocation mode.
|
||||
|
||||
- Added support for timestamping from custom periodic timers, required for
|
||||
accurate timestamping on Cortex-M0/M0+ devices when using tickless idle.
|
||||
Only for streaming mode so far. See TRC_CUSTOM_TIMER_INCR / DECR.
|
||||
|
||||
- ARM Cortex-M port: Made sure the DWT unit is initialized properly, in case
|
||||
the debugger doesn't handle this.
|
||||
|
||||
- ARM Cortex-M port: Added possibility to use Systick timestamping also on
|
||||
Cortex-M3/M4/M7 devices (that otherwise use DWT timestamping by default).
|
||||
To use this option, define the macro TRC_CFG_ARM_CM_USE_SYSTICK.
|
||||
|
||||
- J-Link streaming: The default RTT buffer has been changed from 0 to 1.
|
||||
|
||||
- J-Link streaming: The RTT buffer settings for buffer 1 and higher, are now
|
||||
found in trcStreamingPort.h. Note: These settings don't apply to buffer 0.
|
||||
|
||||
- vTracePrint has been optimized for better performance in string logging.
|
||||
|
||||
- Minor performance improvement related to symbol table transfer in streaming mode.
|
||||
|
||||
- Timer names now registered also in streaming mode.
|
||||
|
||||
- Timer start and stop event are now traced.
|
||||
|
||||
- Implemented support for queue registry (traceQUEUE_REGISTRY_ADD) also for streaming.
|
||||
|
||||
- Fixed a bug related to repeated calls of vTraceEnable.
|
||||
|
||||
- Fixed a bug where task-switches seemed to occur even though the scheduler was disabled.
|
||||
|
||||
- Renamed HARDWARE_PORT_TEXAS_INSTRUMENTS_TMS570_RM48, added prefix TRC.
|
||||
|
||||
- Fixed several language issues in the comments and documentation.
|
||||
|
||||
- Fixed several minor issues and warnings from different compilers
|
||||
(including PowerPC/gcc) and configurations.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Changes, v3.0.9 -> v3.1.0
|
||||
|
||||
- Merge of previously separated snapshot and streaming recorders into a single
|
||||
recorder supporting both streaming and snapshot as different modes.
|
||||
|
||||
- New common API for supporting both streaming and snapshot modes.
|
||||
|
||||
- New integration guide, see the User Manual.
|
||||
|
||||
- Major improvement of API documentation in source files and User Manual.
|
||||
|
||||
- New concept of "stream ports", giving a better structure defining streaming
|
||||
interfaces, and restructured the J-Link and TCP/IP streaming as stream ports.
|
||||
|
||||
- Added a stream port for USB CDC connections, with STM32 as example.
|
||||
Since Tracealyzer now can receive serial data on Windows COM ports, this is
|
||||
really easy to use.
|
||||
|
||||
- Added a warning (#error) for cases where FreeRTOS tickless idle mode is used
|
||||
together with timestamping using SysTick or other periodic interrupt timers,
|
||||
Tracing with tickless idle requires an independent time source to correctly
|
||||
capture the length of the idle periods.
|
||||
|
||||
- Major changes in the recorder API. Important examples are:
|
||||
|
||||
* Some configuration macros have changed names, e.g. for "hardware port".
|
||||
Make sure to remove any old "trcConfig.h" files if upgrading from an
|
||||
earlier version!
|
||||
|
||||
* Recorder configuration in trcConfig.h has been minimized and now only
|
||||
includes the important settings that are independent of recorder mode.
|
||||
Advanced settings for each mode are found in trcSnapshotConfig.h and
|
||||
trcStreamingConfig.h.
|
||||
|
||||
* vTraceEnable replaces Trace_Init and vTraceInitTraceData, as well as
|
||||
vTraceStart and uiTraceStart.
|
||||
|
||||
* vTraceStop now part of the common API and thereby available also in
|
||||
streaming. And since vTraceEnable can start the streaming directly
|
||||
you have the option control the tracing from target, e.g., for
|
||||
streaming to a device file system.
|
||||
|
||||
* vTraceStoreKernelObjectName from old streaming recorder has been replaced
|
||||
by vTraceSetQueueName, vTraceSetSemaphoreName, etc.
|
||||
|
||||
* vTraceSetISRProperties now returns a "traceHandle" that should be passed as
|
||||
parameter to vTraceStoreISRBegin and vTraceStoreISREnd.
|
||||
|
||||
* xTraceRegisterString has replaced the old functions xTraceOpenLabel and
|
||||
vTraceStoreUserEventChannelName. This now returns a "traceString" for use
|
||||
as "channel" parameter in vTracePrintF, and in other places where strings
|
||||
are stored.
|
||||
|
||||
* Removed vTraceStoreISREndManual and vTraceStoreISREndAuto, use
|
||||
vTraceStoreISREnd instead.
|
||||
|
||||
* Renamed the functions for saving User Events in a separate buffer:
|
||||
- xTraceRegisterChannelFormat -> xTraceRegisterUBChannel
|
||||
- vTraceChannelPrintF -> vTraceUBData
|
||||
- vTraceChannelUserEvent -> vTraceUBEvent
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright Percepio AB, 2017.
|
@ -0,0 +1,52 @@
|
||||
/************************************************************
|
||||
* Percepio Tracealyzer - ITM Trace Exporter for Keil uVision
|
||||
* Copyright (c) 2018, Percepio AB.
|
||||
* https://percepio.com
|
||||
************************************************************/
|
||||
|
||||
FUNC void tzSetEnable(int enable)
|
||||
{
|
||||
if (enable == 1)
|
||||
{
|
||||
printf("Starting Tracealyzer recorder\n");
|
||||
|
||||
// Forward the ITM data to file
|
||||
exec("ITMLOG 1 > .\\tracealyzer.psf");
|
||||
|
||||
// Send start command to Tracealyzer (not required if using vTraceEnable(TRC_START))
|
||||
exec("E CHAR tz_host_command_data = 1, 1, 0, 0, 0, 0, 0xFD, 0xFF");
|
||||
exec("tz_host_command_bytes_to_read = 8");
|
||||
}
|
||||
else if (enable == 0)
|
||||
{
|
||||
printf("Stopping Tracealyzer recorder...\n");
|
||||
|
||||
// Send stop command to Tracealyzer, to stop writing ITM data.
|
||||
exec("E CHAR tz_host_command_data = 1, 0, 0, 0, 0, 0, 0xFE, 0xFF");
|
||||
exec("tz_host_command_bytes_to_read = 8");
|
||||
|
||||
_sleep_(2000); // Wait a while to let all data be written the host file.
|
||||
|
||||
// Stop forwarding the ITM data to file and close the file.
|
||||
exec("ITMLOG 1 OFF");
|
||||
|
||||
printf("Tracealyzer recorder stopped.\n");
|
||||
|
||||
}
|
||||
else printf("Usage: tzSetEnable(0 or 1), where 0 is disable (stops recorder) and 1 enable (starts recording)");
|
||||
|
||||
}
|
||||
|
||||
|
||||
// The Tracealyzer ITM stream port for Keil µVision can be used in two ways.
|
||||
//
|
||||
// 1. Start tracing directly from startup.
|
||||
// Make sure tzSetEnable(1) is called below and vTraceEnable(TRC_START) in your target startup.
|
||||
//
|
||||
// 2. Start the trace manually, using the "Start Recording" button in Keil µVision.
|
||||
// In this case, comment out the below call to tzSetEnable and make sure you call vTraceEnable(TRC_INIT) in your target startup (not TRC_START).
|
||||
|
||||
tzSetEnable(1);
|
||||
|
||||
DEFINE BUTTON "Start Recording", "tzSetEnable(1)";
|
||||
DEFINE BUTTON "Stop Recording", "tzSetEnable(0)";
|
@ -0,0 +1,28 @@
|
||||
Tracealyzer Stream Port for ARM Cortex-M ITM
|
||||
--------------------------------------------
|
||||
2018-05-04
|
||||
|
||||
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
|
||||
trcStreamingPort.h, found in the "include" directory.
|
||||
|
||||
This particular stream port targets ARM's ITM interface, which together with
|
||||
a fast debug probe such as a Keil ULINKpro or ULINKplus provides excellent
|
||||
performance. This stream port does not use any RAM buffer for the trace, but
|
||||
writes the data directly to the ITM registers. This is very fast.
|
||||
|
||||
To setup Keil uVision for ITM tracing with a Keil ULINKpro (or ULINKplus),
|
||||
see Percepio Application Note PA-021 https://percepio.com/2018/05/04/keil-itm-support/
|
||||
|
||||
Learning more:
|
||||
- Tracealyzer User Manual (Help -> User Manual)
|
||||
- https://percepio.com/gettingstarted
|
||||
- Percepio Application Note PA-021 https://percepio.com/2018/05/04/keil-itm-support/
|
||||
- About ITM trace, https://percepio.com/2016/06/09/arm-itm/
|
||||
- About the recorder and custom streaming, http://percepio.com/2016/10/05/rtos-tracing
|
||||
|
||||
For questions, please contact support@percepio.com
|
||||
|
||||
Percepio AB
|
||||
www.percepio.com
|
@ -0,0 +1,91 @@
|
||||
/*******************************************************************************
|
||||
* Trace Recorder Library for Tracealyzer v4.1.5
|
||||
* 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.
|
||||
*
|
||||
* 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 */
|
@ -0,0 +1,71 @@
|
||||
|
||||
#include "trcRecorder.h"
|
||||
|
||||
#if (TRC_USE_TRACEALYZER_RECORDER == 1)
|
||||
#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
|
||||
|
||||
static void itm_write_32(uint32_t data);
|
||||
|
||||
volatile int32_t tz_host_command_bytes_to_read = 0; // This is set by the Tracealyzer host application (to the number of bytes written), after having written to tz_host_commands. Set to zero by the read function after the message in tz_host_commands has been read.
|
||||
volatile char tz_host_command_data[32];
|
||||
|
||||
/* 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)
|
||||
{
|
||||
if ( tz_host_command_bytes_to_read > 0)
|
||||
{
|
||||
int i;
|
||||
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;
|
||||
}
|
||||
|
||||
for (i=0; i < tz_host_command_bytes_to_read; i++)
|
||||
{
|
||||
bytesBuffer[i] = tz_host_command_data[i];
|
||||
}
|
||||
|
||||
tz_host_command_bytes_to_read = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void itm_write_32(uint32_t data)
|
||||
{
|
||||
if ((CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk) && // Trace enabled
|
||||
(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 */
|
||||
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;
|
||||
|
||||
while(bytesWritten < size)
|
||||
{
|
||||
itm_write_32(*ptr32);
|
||||
ptr32++;
|
||||
bytesWritten += 4;
|
||||
}
|
||||
|
||||
*ptrBytesWritten = bytesWritten;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
@ -0,0 +1,19 @@
|
||||
Tracealyzer Stream Port for Files
|
||||
-------------------------------------------------
|
||||
|
||||
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
|
||||
trcStreamingPort.h, found in the "include" directory.
|
||||
|
||||
This particular stream port is for streaming to a file via stdio.h (fwrite).
|
||||
|
||||
To use this stream port, make sure that include/trcStreamingPort.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
|
||||
trcStreamingPort.h are included by mistake!
|
||||
|
||||
See also http://percepio.com/2016/10/05/rtos-tracing.
|
||||
|
||||
Percepio AB
|
||||
www.percepio.com
|
@ -0,0 +1,87 @@
|
||||
/*******************************************************************************
|
||||
* Trace Recorder Library for Tracealyzer v4.1.5
|
||||
* 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 */
|
@ -0,0 +1,103 @@
|
||||
/*******************************************************************************
|
||||
* Trace Recorder Library for Tracealyzer v4.1.5
|
||||
* 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)*/
|
@ -0,0 +1,22 @@
|
||||
Tracealyzer Stream Port for SEGGER J-Link
|
||||
-----------------------------------------
|
||||
|
||||
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
|
||||
trcStreamingPort.h, found in the "include" directory.
|
||||
|
||||
This particular stream port targets SEGGER J-Link debug probes, using the RTT
|
||||
interface provided by SEGGER.
|
||||
|
||||
To use this stream port, make sure that include/trcStreamingPort.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
|
||||
trcStreamingPort.h are included by mistake!
|
||||
|
||||
Note that this stream port also contains SEGGER's RTT driver.
|
||||
|
||||
See also http://percepio.com/2016/10/05/rtos-tracing.
|
||||
|
||||
Percepio AB
|
||||
www.percepio.com
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,238 @@
|
||||
/*********************************************************************
|
||||
* SEGGER MICROCONTROLLER GmbH & Co. KG *
|
||||
* Solutions for real time microcontroller applications *
|
||||
**********************************************************************
|
||||
* *
|
||||
* (c) 2014 - 2016 SEGGER Microcontroller GmbH & Co. KG *
|
||||
* *
|
||||
* www.segger.com Support: support@segger.com *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* SEGGER RTT * Real Time Transfer for embedded targets *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* * This software may in its unmodified form be freely redistributed *
|
||||
* in source, linkable, or executable form. *
|
||||
* * The source code may be modified, provided the source code *
|
||||
* retains the above copyright notice, this list of conditions and *
|
||||
* the following disclaimer. *
|
||||
* * Modified versions of this software in source, executable, or *
|
||||
* linkable form may not be distributed without prior consent of *
|
||||
* SEGGER. *
|
||||
* * This software may only be used for communication with SEGGER *
|
||||
* J-Link debug probes. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
|
||||
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
|
||||
* DAMAGE. *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* RTT version: 6.00e *
|
||||
* *
|
||||
**********************************************************************
|
||||
---------------------------END-OF-HEADER------------------------------
|
||||
File : SEGGER_RTT.h
|
||||
Purpose : Implementation of SEGGER real-time transfer which allows
|
||||
real-time communication on targets which support debugger
|
||||
memory accesses while the CPU is running.
|
||||
Revision: $Rev: 4079 $
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef SEGGER_RTT_H
|
||||
#define SEGGER_RTT_H
|
||||
|
||||
#include "SEGGER_RTT_Conf.h"
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Defines, fixed
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Types
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
//
|
||||
// Description for a circular buffer (also called "ring buffer")
|
||||
// which is used as up-buffer (T->H)
|
||||
//
|
||||
typedef struct {
|
||||
const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
|
||||
char* pBuffer; // Pointer to start of buffer
|
||||
unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
|
||||
unsigned WrOff; // Position of next item to be written by either target.
|
||||
volatile unsigned RdOff; // Position of next item to be read by host. Must be volatile since it may be modified by host.
|
||||
unsigned Flags; // Contains configuration flags
|
||||
} SEGGER_RTT_BUFFER_UP;
|
||||
|
||||
//
|
||||
// Description for a circular buffer (also called "ring buffer")
|
||||
// which is used as down-buffer (H->T)
|
||||
//
|
||||
typedef struct {
|
||||
const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
|
||||
char* pBuffer; // Pointer to start of buffer
|
||||
unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
|
||||
volatile unsigned WrOff; // Position of next item to be written by host. Must be volatile since it may be modified by host.
|
||||
unsigned RdOff; // Position of next item to be read by target (down-buffer).
|
||||
unsigned Flags; // Contains configuration flags
|
||||
} SEGGER_RTT_BUFFER_DOWN;
|
||||
|
||||
//
|
||||
// RTT control block which describes the number of buffers available
|
||||
// as well as the configuration for each buffer
|
||||
//
|
||||
//
|
||||
typedef struct {
|
||||
char acID[16]; // Initialized to "SEGGER RTT"
|
||||
int MaxNumUpBuffers; // Initialized to SEGGER_RTT_MAX_NUM_UP_BUFFERS (type. 2)
|
||||
int MaxNumDownBuffers; // Initialized to SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (type. 2)
|
||||
SEGGER_RTT_BUFFER_UP aUp[SEGGER_RTT_MAX_NUM_UP_BUFFERS]; // Up buffers, transferring information up from target via debug probe to host
|
||||
SEGGER_RTT_BUFFER_DOWN aDown[SEGGER_RTT_MAX_NUM_DOWN_BUFFERS]; // Down buffers, transferring information down from host via debug probe to target
|
||||
} SEGGER_RTT_CB;
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Global data
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
extern SEGGER_RTT_CB _SEGGER_RTT;
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT API functions
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
int SEGGER_RTT_AllocDownBuffer (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
|
||||
int SEGGER_RTT_AllocUpBuffer (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
|
||||
int SEGGER_RTT_ConfigUpBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
|
||||
int SEGGER_RTT_ConfigDownBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
|
||||
int SEGGER_RTT_GetKey (void);
|
||||
unsigned SEGGER_RTT_HasData (unsigned BufferIndex);
|
||||
int SEGGER_RTT_HasKey (void);
|
||||
void SEGGER_RTT_Init (void);
|
||||
unsigned SEGGER_RTT_Read (unsigned BufferIndex, void* pBuffer, unsigned BufferSize);
|
||||
unsigned SEGGER_RTT_ReadNoLock (unsigned BufferIndex, void* pData, unsigned BufferSize);
|
||||
int SEGGER_RTT_SetNameDownBuffer (unsigned BufferIndex, const char* sName);
|
||||
int SEGGER_RTT_SetNameUpBuffer (unsigned BufferIndex, const char* sName);
|
||||
int SEGGER_RTT_SetFlagsDownBuffer (unsigned BufferIndex, unsigned Flags);
|
||||
int SEGGER_RTT_SetFlagsUpBuffer (unsigned BufferIndex, unsigned Flags);
|
||||
int SEGGER_RTT_WaitKey (void);
|
||||
unsigned SEGGER_RTT_Write (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
|
||||
unsigned SEGGER_RTT_WriteNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
|
||||
unsigned SEGGER_RTT_WriteSkipNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
|
||||
unsigned SEGGER_RTT_WriteString (unsigned BufferIndex, const char* s);
|
||||
void SEGGER_RTT_WriteWithOverwriteNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
|
||||
//
|
||||
// Function macro for performance optimization
|
||||
//
|
||||
#define SEGGER_RTT_HASDATA(n) (_SEGGER_RTT.aDown[n].WrOff - _SEGGER_RTT.aDown[n].RdOff)
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT "Terminal" API functions
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
int SEGGER_RTT_SetTerminal (char TerminalId);
|
||||
int SEGGER_RTT_TerminalOut (char TerminalId, const char* s);
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT printf functions (require SEGGER_RTT_printf.c)
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Defines
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
//
|
||||
// Operating modes. Define behavior if buffer is full (not enough space for entire message)
|
||||
//
|
||||
#define SEGGER_RTT_MODE_NO_BLOCK_SKIP (0U) // Skip. Do not block, output nothing. (Default)
|
||||
#define SEGGER_RTT_MODE_NO_BLOCK_TRIM (1U) // Trim: Do not block, output as much as fits.
|
||||
#define SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL (2U) // Block: Wait until there is space in the buffer.
|
||||
#define SEGGER_RTT_MODE_MASK (3U)
|
||||
|
||||
//
|
||||
// Control sequences, based on ANSI.
|
||||
// Can be used to control color, and clear the screen
|
||||
//
|
||||
#define RTT_CTRL_RESET "[0m" // Reset to default colors
|
||||
#define RTT_CTRL_CLEAR "[2J" // Clear screen, reposition cursor to top left
|
||||
|
||||
#define RTT_CTRL_TEXT_BLACK "[2;30m"
|
||||
#define RTT_CTRL_TEXT_RED "[2;31m"
|
||||
#define RTT_CTRL_TEXT_GREEN "[2;32m"
|
||||
#define RTT_CTRL_TEXT_YELLOW "[2;33m"
|
||||
#define RTT_CTRL_TEXT_BLUE "[2;34m"
|
||||
#define RTT_CTRL_TEXT_MAGENTA "[2;35m"
|
||||
#define RTT_CTRL_TEXT_CYAN "[2;36m"
|
||||
#define RTT_CTRL_TEXT_WHITE "[2;37m"
|
||||
|
||||
#define RTT_CTRL_TEXT_BRIGHT_BLACK "[1;30m"
|
||||
#define RTT_CTRL_TEXT_BRIGHT_RED "[1;31m"
|
||||
#define RTT_CTRL_TEXT_BRIGHT_GREEN "[1;32m"
|
||||
#define RTT_CTRL_TEXT_BRIGHT_YELLOW "[1;33m"
|
||||
#define RTT_CTRL_TEXT_BRIGHT_BLUE "[1;34m"
|
||||
#define RTT_CTRL_TEXT_BRIGHT_MAGENTA "[1;35m"
|
||||
#define RTT_CTRL_TEXT_BRIGHT_CYAN "[1;36m"
|
||||
#define RTT_CTRL_TEXT_BRIGHT_WHITE "[1;37m"
|
||||
|
||||
#define RTT_CTRL_BG_BLACK "[24;40m"
|
||||
#define RTT_CTRL_BG_RED "[24;41m"
|
||||
#define RTT_CTRL_BG_GREEN "[24;42m"
|
||||
#define RTT_CTRL_BG_YELLOW "[24;43m"
|
||||
#define RTT_CTRL_BG_BLUE "[24;44m"
|
||||
#define RTT_CTRL_BG_MAGENTA "[24;45m"
|
||||
#define RTT_CTRL_BG_CYAN "[24;46m"
|
||||
#define RTT_CTRL_BG_WHITE "[24;47m"
|
||||
|
||||
#define RTT_CTRL_BG_BRIGHT_BLACK "[4;40m"
|
||||
#define RTT_CTRL_BG_BRIGHT_RED "[4;41m"
|
||||
#define RTT_CTRL_BG_BRIGHT_GREEN "[4;42m"
|
||||
#define RTT_CTRL_BG_BRIGHT_YELLOW "[4;43m"
|
||||
#define RTT_CTRL_BG_BRIGHT_BLUE "[4;44m"
|
||||
#define RTT_CTRL_BG_BRIGHT_MAGENTA "[4;45m"
|
||||
#define RTT_CTRL_BG_BRIGHT_CYAN "[4;46m"
|
||||
#define RTT_CTRL_BG_BRIGHT_WHITE "[4;47m"
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/*************************** End of file ****************************/
|
@ -0,0 +1,259 @@
|
||||
/*********************************************************************
|
||||
* SEGGER MICROCONTROLLER GmbH & Co. KG *
|
||||
* Solutions for real time microcontroller applications *
|
||||
**********************************************************************
|
||||
* *
|
||||
* (c) 2014 - 2016 SEGGER Microcontroller GmbH & Co. KG *
|
||||
* *
|
||||
* www.segger.com Support: support@segger.com *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* SEGGER RTT * Real Time Transfer for embedded targets *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* * This software may in its unmodified form be freely redistributed *
|
||||
* in source, linkable, or executable form. *
|
||||
* * The source code may be modified, provided the source code *
|
||||
* retains the above copyright notice, this list of conditions and *
|
||||
* the following disclaimer. *
|
||||
* * Modified versions of this software in source, executable, or *
|
||||
* linkable form may not be distributed without prior consent of *
|
||||
* SEGGER. *
|
||||
* * This software may only be used for communication with SEGGER *
|
||||
* J-Link debug probes. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
|
||||
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
|
||||
* DAMAGE. *
|
||||
* *
|
||||
**********************************************************************
|
||||
* *
|
||||
* RTT version: 6.00e *
|
||||
* *
|
||||
**********************************************************************
|
||||
----------------------------------------------------------------------
|
||||
File : SEGGER_RTT_Conf.h
|
||||
Purpose : Implementation of SEGGER real-time transfer (RTT) which
|
||||
allows real-time communication on targets which support
|
||||
debugger memory accesses while the CPU is running.
|
||||
Revision: $Rev: 3892 $
|
||||
---------------------------END-OF-HEADER------------------------------
|
||||
*/
|
||||
|
||||
#ifndef SEGGER_RTT_CONF_H
|
||||
#define SEGGER_RTT_CONF_H
|
||||
|
||||
#ifdef __IAR_SYSTEMS_ICC__
|
||||
#include <intrinsics.h>
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Defines, configurable
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
#define SEGGER_RTT_MAX_NUM_UP_BUFFERS (3) // Max. number of up-buffers (T->H) available on this target (Default: 3)
|
||||
#define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (3) // Max. number of down-buffers (H->T) available on this target (Default: 3)
|
||||
|
||||
#define BUFFER_SIZE_UP (64) // Size of the buffer for terminal output of target, up to host (Default: 1k)
|
||||
#define BUFFER_SIZE_DOWN (16) // Size of the buffer for terminal input to target from host (Usually keyboard input) (Default: 16)
|
||||
|
||||
#define SEGGER_RTT_PRINTF_BUFFER_SIZE (64u) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64)
|
||||
|
||||
#define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP // Mode for pre-initialized terminal channel (buffer 0)
|
||||
|
||||
//
|
||||
// Target is not allowed to perform other RTT operations while string still has not been stored completely.
|
||||
// Otherwise we would probably end up with a mixed string in the buffer.
|
||||
// If using RTT from within interrupts, multiple tasks or multi processors, define the SEGGER_RTT_LOCK() and SEGGER_RTT_UNLOCK() function here.
|
||||
//
|
||||
// SEGGER_RTT_MAX_INTERRUPT_PRIORITY can be used in the sample lock routines on Cortex-M3/4.
|
||||
// Make sure to mask all interrupts which can send RTT data, i.e. generate SystemView events, or cause task switches.
|
||||
// When high-priority interrupts must not be masked while sending RTT data, SEGGER_RTT_MAX_INTERRUPT_PRIORITY needs to be adjusted accordingly.
|
||||
// (Higher priority = lower priority number)
|
||||
// Default value for embOS: 128u
|
||||
// Default configuration in FreeRTOS: configMAX_SYSCALL_INTERRUPT_PRIORITY: ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
||||
// In case of doubt mask all interrupts: 1 << (8 - BASEPRI_PRIO_BITS) i.e. 1 << 5 when 3 bits are implemented in NVIC
|
||||
// or define SEGGER_RTT_LOCK() to completely disable interrupts.
|
||||
//
|
||||
|
||||
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) // Interrupt priority to lock on SEGGER_RTT_LOCK on Cortex-M3/4 (Default: 0x20)
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT lock configuration for SEGGER Embedded Studio,
|
||||
* Rowley CrossStudio and GCC
|
||||
*/
|
||||
#if (defined __SES_ARM) || (defined __CROSSWORKS_ARM) || (defined __GNUC__)
|
||||
#ifdef __ARM_ARCH_6M__
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
__asm volatile ("mrs %0, primask \n\t" \
|
||||
"mov r1, $1 \n\t" \
|
||||
"msr primask, r1 \n\t" \
|
||||
: "=r" (LockState) \
|
||||
: \
|
||||
: "r1" \
|
||||
);
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __asm volatile ("msr primask, %0 \n\t" \
|
||||
: \
|
||||
: "r" (LockState) \
|
||||
: \
|
||||
); \
|
||||
}
|
||||
|
||||
#elif (defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__))
|
||||
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
|
||||
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
|
||||
#endif
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
__asm volatile ("mrs %0, basepri \n\t" \
|
||||
"mov r1, %1 \n\t" \
|
||||
"msr basepri, r1 \n\t" \
|
||||
: "=r" (LockState) \
|
||||
: "i"(SEGGER_RTT_MAX_INTERRUPT_PRIORITY) \
|
||||
: "r1" \
|
||||
);
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __asm volatile ("msr basepri, %0 \n\t" \
|
||||
: \
|
||||
: "r" (LockState) \
|
||||
: \
|
||||
); \
|
||||
}
|
||||
|
||||
#elif defined(__ARM_ARCH_7A__)
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
__asm volatile ("mrs r1, CPSR \n\t" \
|
||||
"mov %0, r1 \n\t" \
|
||||
"orr r1, r1, #0xC0 \n\t" \
|
||||
"msr CPSR_c, r1 \n\t" \
|
||||
: "=r" (LockState) \
|
||||
: \
|
||||
: "r1" \
|
||||
);
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __asm volatile ("mov r0, %0 \n\t" \
|
||||
"mrs r1, CPSR \n\t" \
|
||||
"bic r1, r1, #0xC0 \n\t" \
|
||||
"and r0, r0, #0xC0 \n\t" \
|
||||
"orr r1, r1, r0 \n\t" \
|
||||
"msr CPSR_c, r1 \n\t" \
|
||||
: \
|
||||
: "r" (LockState) \
|
||||
: "r0", "r1" \
|
||||
); \
|
||||
}
|
||||
#else
|
||||
#define SEGGER_RTT_LOCK()
|
||||
#define SEGGER_RTT_UNLOCK()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT lock configuration for IAR EWARM
|
||||
*/
|
||||
#ifdef __ICCARM__
|
||||
#if (defined (__ARM6M__) && (__CORE__ == __ARM6M__))
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
LockState = __get_PRIMASK(); \
|
||||
__set_PRIMASK(1);
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __set_PRIMASK(LockState); \
|
||||
}
|
||||
#elif ((defined (__ARM7EM__) && (__CORE__ == __ARM7EM__)) || (defined (__ARM7M__) && (__CORE__ == __ARM7M__)))
|
||||
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
|
||||
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
|
||||
#endif
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
LockState = __get_BASEPRI(); \
|
||||
__set_BASEPRI(SEGGER_RTT_MAX_INTERRUPT_PRIORITY);
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __set_BASEPRI(LockState); \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT lock configuration for IAR RX
|
||||
*/
|
||||
#ifdef __ICCRX__
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned long LockState; \
|
||||
LockState = __get_interrupt_state(); \
|
||||
__disable_interrupt();
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() __set_interrupt_state(LockState); \
|
||||
}
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT lock configuration for KEIL ARM
|
||||
*/
|
||||
#ifdef __CC_ARM
|
||||
#if (defined __TARGET_ARCH_6S_M)
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
register unsigned char PRIMASK __asm( "primask"); \
|
||||
LockState = PRIMASK; \
|
||||
PRIMASK = 1u; \
|
||||
__schedule_barrier();
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() PRIMASK = LockState; \
|
||||
__schedule_barrier(); \
|
||||
}
|
||||
#elif (defined(__TARGET_ARCH_7_M) || defined(__TARGET_ARCH_7E_M))
|
||||
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
|
||||
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
|
||||
#endif
|
||||
#define SEGGER_RTT_LOCK() { \
|
||||
unsigned int LockState; \
|
||||
register unsigned char BASEPRI __asm( "basepri"); \
|
||||
LockState = BASEPRI; \
|
||||
BASEPRI = SEGGER_RTT_MAX_INTERRUPT_PRIORITY; \
|
||||
__schedule_barrier();
|
||||
|
||||
#define SEGGER_RTT_UNLOCK() BASEPRI = LockState; \
|
||||
__schedule_barrier(); \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* RTT lock configuration fallback
|
||||
*/
|
||||
#ifndef SEGGER_RTT_LOCK
|
||||
#define SEGGER_RTT_LOCK() // Lock RTT (nestable) (i.e. disable interrupts)
|
||||
#endif
|
||||
|
||||
#ifndef SEGGER_RTT_UNLOCK
|
||||
#define SEGGER_RTT_UNLOCK() // Unlock RTT (nestable) (i.e. enable previous interrupt lock state)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/*************************** End of file ****************************/
|
@ -0,0 +1,196 @@
|
||||
/*******************************************************************************
|
||||
* Trace Recorder Library for Tracealyzer v4.1.5
|
||||
* 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 */
|
@ -0,0 +1,44 @@
|
||||
|
||||
#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;
|
||||
|
||||
if (bytesRead != size)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if (bytesWritten != size)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
@ -0,0 +1,22 @@
|
||||
Tracealyzer Stream Port for TCP/IP (lwIP example)
|
||||
-------------------------------------------------
|
||||
|
||||
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
|
||||
trcStreamingPort.h, found in the "include" directory.
|
||||
|
||||
This particular stream port targets TCP/IP. This example assumes lwIP but is
|
||||
easy to modify for other TCP/IP stacks.
|
||||
|
||||
To use this stream port, make sure that include/trcStreamingPort.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
|
||||
trcStreamingPort.h are included by mistake!
|
||||
|
||||
Note that lwIP is not included, but assumed to exist in the project already.
|
||||
|
||||
See also http://percepio.com/2016/10/05/rtos-tracing.
|
||||
|
||||
Percepio AB
|
||||
www.percepio.com
|
@ -0,0 +1,66 @@
|
||||
/*******************************************************************************
|
||||
* Trace Recorder Library for Tracealyzer v4.1.5
|
||||
* 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
|
||||
|
||||
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 */
|
@ -0,0 +1,186 @@
|
||||
/*******************************************************************************
|
||||
* Trace Recorder Library for Tracealyzer v4.1.5
|
||||
* 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"
|
||||
|
||||
int errno;
|
||||
|
||||
#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 );
|
||||
if ( *bytesRead < 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;
|
||||
}
|
||||
else
|
||||
*bytesRead = 0;
|
||||
}
|
||||
|
||||
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 );
|
||||
|
||||
flags = fcntl( new_sd, F_GETFL, 0 );
|
||||
fcntl( new_sd, F_SETFL, flags | O_NONBLOCK );
|
||||
|
||||
if( new_sd < 0 )
|
||||
{
|
||||
closesocket(new_sd);
|
||||
new_sd = -1;
|
||||
closesocket(sock);
|
||||
sock = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
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)*/
|
@ -0,0 +1,27 @@
|
||||
Tracealyzer Stream Port for USB CDC (STM32 example)
|
||||
---------------------------------------------------
|
||||
|
||||
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
|
||||
trcStreamingPort.h, found in the "include" directory.
|
||||
|
||||
This particular stream port targets USB CDC. This is an example for the STM32 USB
|
||||
stack (from the STM32CubeMX code generation tool, v1.4.1) and has been tested on
|
||||
a STM32F767ZI device on a Nucleo board. See this blog post:
|
||||
|
||||
http://percepio.com/2017/02/03/usb-trace-streaming-st-nucleo-f767zi-board/
|
||||
|
||||
However, it should be straight-forward to modify this for other USB stacks.
|
||||
|
||||
To use this stream port, make sure that include/trcStreamingPort.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
|
||||
trcStreamingPort.h are included by mistake!
|
||||
|
||||
Note that the USB stack not included, but assumed to exist in the project already.
|
||||
|
||||
See also http://percepio.com/2016/10/05/rtos-tracing.
|
||||
|
||||
Percepio AB
|
||||
www.percepio.com
|
@ -0,0 +1,83 @@
|
||||
/*******************************************************************************
|
||||
* Trace Recorder Library for Tracealyzer v4.1.5
|
||||
* 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Include files as needed, in this case it is files from STM32Cube FW_F7 V1.4.1 */
|
||||
#include "usb_device.h"
|
||||
#include "usbd_cdc.h"
|
||||
#include "usbd_CDC_if.h"
|
||||
#include "usb_device.h"
|
||||
|
||||
/* Tested on STM32 devices using Keil/CMSIS USB stack */
|
||||
|
||||
extern USBD_CDC_ItfTypeDef USBD_Interface_fops_FS;
|
||||
|
||||
uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len);
|
||||
|
||||
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() \
|
||||
MX_USB_DEVICE_Init(); \
|
||||
TRC_STREAM_PORT_MALLOC(); /*Dynamic allocation or empty if static */
|
||||
|
||||
#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 */
|
@ -0,0 +1,246 @@
|
||||
|
||||
#include "trcRecorder.h"
|
||||
|
||||
#if (TRC_USE_TRACEALYZER_RECORDER == 1)
|
||||
#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
/* Include files as needed, in this case it is files from STM32Cube FW_F7 V1.4.1 */
|
||||
#include "usb_device.h"
|
||||
#include "usbd_cdc.h"
|
||||
#include "usbd_CDC_if.h"
|
||||
#include "usb_device.h"
|
||||
|
||||
#define BUFSIZE 64
|
||||
|
||||
typedef struct{
|
||||
uint32_t idx;
|
||||
uint8_t data[BUFSIZE];
|
||||
}recBuf;
|
||||
|
||||
/* Define size for the receive and transmit buffer over CDC */
|
||||
#define APP_RX_DATA_SIZE 8
|
||||
#define APP_TX_DATA_SIZE 64
|
||||
|
||||
/* Received Data over USB are stored in this buffer */
|
||||
uint8_t UserRxBufferFS[APP_RX_DATA_SIZE];
|
||||
|
||||
/* Send Data over USB CDC are stored in this buffer */
|
||||
uint8_t UserTxBufferFS[APP_TX_DATA_SIZE];
|
||||
|
||||
extern USBD_HandleTypeDef hUsbDeviceFS;
|
||||
|
||||
extern PCD_HandleTypeDef hpcd_USB_OTG_FS;
|
||||
|
||||
recBuf commandBuffer;
|
||||
|
||||
static int8_t CDC_Init_FS (void);
|
||||
static int8_t CDC_DeInit_FS (void);
|
||||
static int8_t CDC_Control_FS (uint8_t cmd, uint8_t* pbuf, uint16_t length);
|
||||
static int8_t CDC_Receive_FS (uint8_t* pbuf, uint32_t *Len);
|
||||
|
||||
USBD_CDC_ItfTypeDef USBD_Interface_fops_FS =
|
||||
{
|
||||
CDC_Init_FS,
|
||||
CDC_DeInit_FS,
|
||||
CDC_Control_FS,
|
||||
CDC_Receive_FS
|
||||
};
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
/**
|
||||
* @brief CDC_Init_FS
|
||||
* Initializes the CDC media low layer over the FS USB IP
|
||||
* @param None
|
||||
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
|
||||
*/
|
||||
static int8_t CDC_Init_FS(void)
|
||||
{
|
||||
/* Set Application Buffers */
|
||||
USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, 0);
|
||||
USBD_CDC_SetRxBuffer(&hUsbDeviceFS, UserRxBufferFS);
|
||||
return (USBD_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CDC_DeInit_FS
|
||||
* DeInitializes the CDC media low layer
|
||||
* @param None
|
||||
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
|
||||
*/
|
||||
static int8_t CDC_DeInit_FS(void)
|
||||
{
|
||||
return (USBD_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CDC_Control_FS
|
||||
* Manage the CDC class requests
|
||||
* @param cmd: Command code
|
||||
* @param pbuf: Buffer containing command data (request parameters)
|
||||
* @param length: Number of data to be sent (in bytes)
|
||||
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
|
||||
*/
|
||||
static int8_t CDC_Control_FS (uint8_t cmd, uint8_t* pbuf, uint16_t length)
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case CDC_SEND_ENCAPSULATED_COMMAND:
|
||||
break;
|
||||
|
||||
case CDC_GET_ENCAPSULATED_RESPONSE:
|
||||
break;
|
||||
|
||||
case CDC_SET_COMM_FEATURE:
|
||||
break;
|
||||
|
||||
case CDC_GET_COMM_FEATURE:
|
||||
break;
|
||||
|
||||
case CDC_CLEAR_COMM_FEATURE:
|
||||
break;
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Line Coding Structure */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Offset | Field | Size | Value | Description */
|
||||
/* 0 | dwDTERate | 4 | Number |Data terminal rate, in bits per second*/
|
||||
/* 4 | bCharFormat | 1 | Number | Stop bits */
|
||||
/* 0 - 1 Stop bit */
|
||||
/* 1 - 1.5 Stop bits */
|
||||
/* 2 - 2 Stop bits */
|
||||
/* 5 | bParityType | 1 | Number | Parity */
|
||||
/* 0 - None */
|
||||
/* 1 - Odd */
|
||||
/* 2 - Even */
|
||||
/* 3 - Mark */
|
||||
/* 4 - Space */
|
||||
/* 6 | bDataBits | 1 | Number Data bits (5, 6, 7, 8 or 16). */
|
||||
/*******************************************************************************/
|
||||
case CDC_SET_LINE_CODING:
|
||||
break;
|
||||
|
||||
case CDC_GET_LINE_CODING:
|
||||
break;
|
||||
|
||||
case CDC_SET_CONTROL_LINE_STATE:
|
||||
break;
|
||||
|
||||
case CDC_SEND_BREAK:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return (USBD_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CDC_Receive_FS
|
||||
* Data received over USB OUT endpoint are sent over CDC interface
|
||||
* through this function.
|
||||
*
|
||||
* @note
|
||||
* This function will block any OUT packet reception on USB endpoint
|
||||
* until exiting this function. If you exit this function before transfer
|
||||
* is complete on CDC interface (i.e. using DMA controller) it will result
|
||||
* in receiving more data while previous ones are still not sent.
|
||||
*
|
||||
* @param Buf: Buffer of data to be received
|
||||
* @param Len: Number of data received (in bytes)
|
||||
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
|
||||
*/
|
||||
static int8_t CDC_Receive_FS (uint8_t* Buf, uint32_t *Len)
|
||||
{
|
||||
for( uint32_t i=0;i<* Len;i++)
|
||||
{
|
||||
commandBuffer.data[commandBuffer.idx]=Buf[i];
|
||||
commandBuffer.idx++;
|
||||
}
|
||||
USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]);
|
||||
USBD_CDC_ReceivePacket(&hUsbDeviceFS);
|
||||
|
||||
return (USBD_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CDC_Transmit_FS
|
||||
* Data send over USB IN endpoint are sent over CDC interface
|
||||
* through this function.
|
||||
* @note
|
||||
*
|
||||
*
|
||||
* @param Buf: Buffer of data to be send
|
||||
* @param Len: Number of data to be send (in bytes)
|
||||
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL or USBD_BUSY
|
||||
*/
|
||||
uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len)
|
||||
{
|
||||
uint8_t result = USBD_OK;
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData;
|
||||
if (hcdc->TxState != 0){
|
||||
return USBD_BUSY;
|
||||
}
|
||||
USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len);
|
||||
result = USBD_CDC_TransmitPacket(&hUsbDeviceFS);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* 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 )
|
||||
{
|
||||
int32_t result;
|
||||
result=CDC_Transmit_FS(data, size);
|
||||
*noOfBytesSent = size;
|
||||
|
||||
/* Return value should be 0 on success (not sure what the value of USBD_OK is) */
|
||||
if (result == USBD_OK)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles USB On The Go FS global interrupt.
|
||||
*/
|
||||
void OTG_FS_IRQHandler(void)
|
||||
{
|
||||
HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS);
|
||||
}
|
||||
|
||||
#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/
|
||||
#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/
|
||||
|
@ -0,0 +1,337 @@
|
||||
-------------------------------------------------------------------------------
|
||||
Tracealyzer Recorder Library for FreeRTOS
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Tracealyzer is a sophisticated tool for tracing and visualization
|
||||
of FreeRTOS-based software systems.
|
||||
|
||||
Tracealyzer gives an unprecedented insight into the runtime behavior, which
|
||||
speeds up debugging, validation and optimization.
|
||||
|
||||
This, the Trace Recorder Library, is the target-side part of Tracealyzer, that
|
||||
performs the actual tracing. The resulting data can then be viewed in the
|
||||
Tracealyzer PC application, found at https://percepio.com/tracealyzer
|
||||
|
||||
To learn more, see these links.
|
||||
|
||||
- Getting Started (videos etc): https://percepio.com/gettingstarted
|
||||
|
||||
- FAQ: https://percepio.com/category/faq
|
||||
|
||||
In case you have any questions, don't hesitate to contact support@percepio.com
|
||||
|
||||
Tracealyzer supports FreeRTOS v7.3 and newer, including Amazon FreeRTOS.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Changes, v4.1.4 -> v4.1.5
|
||||
|
||||
- Fixed a bug in the ITM stream port, that required Port 0 to be enabled.
|
||||
- Added missing include of stdio.h (needed by vTraceConsoleChannelPrintF).
|
||||
- Moved standard includes from trcRecorder.h into the .c files needing them.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Changes, v4.1.2 -> v4.1.4
|
||||
|
||||
- Fixed a compile error when certain FreeRTOS settings were used
|
||||
- Disabled filter support for FreeRTOS v7.3 since it uses "char" for object id
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Changes, v4.1.0 -> v4.1.2
|
||||
|
||||
- Added vTraceConsoleChannelPrintF(...)
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Changes, v4.0.3 -> v4.1.0
|
||||
|
||||
- Improved performance of User Events
|
||||
- Fixed handling of format strings ending with '%'
|
||||
- Improved handling of creative user configuration macros
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Changes, v4.0.2 -> v4.0.3
|
||||
|
||||
- Minor fix for TCP/IP stream port.
|
||||
- Corrected default RTT mode setting.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Changes, v4.0.1 -> v4.0.2
|
||||
|
||||
- Memory allocation trace events now ignore filters.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Changes, v4.0.0 -> v4.0.1
|
||||
|
||||
- Minor fixes to default values.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Changes, v3.3.0 -> v4.0.0
|
||||
|
||||
- Fixed some issues with filters.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Changes, v3.2.0 -> v3.3.0
|
||||
|
||||
- Added support for FreeRTOS v10, including the new object types Message Buffer
|
||||
and Stream Buffer.
|
||||
|
||||
- Improved the object-level filtering to also support Timer, Event Group,
|
||||
Message Buffer and Stream Buffer objects.
|
||||
|
||||
- Fixed a few remaining build problems with older FreeRTOS versions (v7.x).
|
||||
|
||||
- vTraceStoreISRBegin now reports an error on invalid handles, i.e., if the
|
||||
initialization of the handle (xTraceSetISRProperties) had not been made.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Changes, v3.1.2 -> v3.2.0
|
||||
|
||||
- Added new filtering system - that works in both snapshot and streaming mode.
|
||||
Filtering was previously not supported in streaming mode, but can be very
|
||||
useful for slower streaming interfaces. By exluding irrelevant events, the
|
||||
amount of data produced can be reduced a lot.
|
||||
|
||||
* New functions vTraceSetFilterGroup and vTraceSetFilterMask allows for
|
||||
excluding all events from specific objects (like a semaphore or queue).
|
||||
|
||||
* Added new "generic" filters (preprocessor level) to trcConfig.h, that
|
||||
exclude all events of a particular types.
|
||||
- TRC_CFG_INCLUDE_NOTIFY_EVENTS
|
||||
- TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS
|
||||
- TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS
|
||||
- TRC_CFG_INCLUDE_TIMER_EVENTS
|
||||
|
||||
* Upgraded some previous filters from "Snapshot only" to the Common API
|
||||
and thereby moved them from trcSnapshotConfig.h to trcConfig.h.
|
||||
- TRC_CFG_SCHEDULING_ONLY
|
||||
- TRC_CFG_INCLUDE_MEMMANG_EVENTS
|
||||
- TRC_CFG_INCLUDE_USER_EVENTS
|
||||
- TRC_CFG_INCLUDE_ISR_TRACING
|
||||
- TRC_CFG_INCLUDE_READY_EVENTS
|
||||
- TRC_CFG_INCLUDE_OSTICK_EVENTS
|
||||
|
||||
* Removed the old filter system from trcSnapshotRecorder.c.
|
||||
|
||||
- Improved streaming interface - Now only two (2) macros are needed to be
|
||||
defined in most cases, read and write. This makes it a lot easier to make
|
||||
custom stream ports.
|
||||
|
||||
* Many definitions that were identical in most stream ports, have been
|
||||
replaced by default definitions in the recorder core. If needed, they
|
||||
can be overriden by custom definitions in trcStreamingPort.h.
|
||||
|
||||
* Stream ports are now assumed to use recorder's internal event buffer.
|
||||
Other stream ports that writes directly to the streaming interface
|
||||
(like J-Link) should define TRC_STREAM_PORT_USE_INTERNAL_BUFFER
|
||||
as zero (0) to make it work correctly.
|
||||
|
||||
* Macro TRC_STREAM_PORT_PERIODIC_SEND_DATA has been replaced by
|
||||
TRC_STREAM_PORT_WRITE_DATA. Together with TRC_STREAM_PORT_READ_DATA,
|
||||
this is all that is necessary for a typical stream port.
|
||||
|
||||
* Return values from the stream port macros READ_DATA and WRITE_DATA are
|
||||
now checked. Expects 0 on success, anything else produces a warning
|
||||
that can be retrived using xTraceGetLastError() and also seen in
|
||||
Tracealyzer if a trace was produced.
|
||||
|
||||
* Stream ports should no longer call prvPagedEventBufferInit explicitly
|
||||
(e.g. in TRC_STREAM_PORT_ON_TRACE_BEGIN). This is now called
|
||||
automatically if TRC_STREAM_PORT_USE_INTERNAL_BUFFER == 1.
|
||||
|
||||
* Macros TRC_STREAM_PORT_ON_TRACE_BEGIN and TRC_STREAM_PORT_ON_TRACE_END
|
||||
are now unused by default and don't need to be defined.
|
||||
You can however use them to hook in some own function at these events.
|
||||
|
||||
- Added two new stream ports
|
||||
|
||||
* TCPIP-Win32: allows for testing the streaming on Windows ports of your
|
||||
RTOS, using Winsock.
|
||||
|
||||
* File: example of streaming to a local file system (tested on Windows,
|
||||
but easy to modify).
|
||||
|
||||
- Added support for FreeRTOS v9.0.1
|
||||
|
||||
* Replaced FreeRTOS version code TRC_FREERTOS_VERSION_9_X with
|
||||
- TRC_FREERTOS_VERSION_9_0_0
|
||||
- TRC_FREERTOS_VERSION_9_0_1
|
||||
|
||||
* Using TRC_FREERTOS_VERSION_9_X is no longer allowed.
|
||||
|
||||
- Added additional events for xQueuePeek, for blocking and timeouts events.
|
||||
|
||||
- Added event for traceTIMER_EXPIRED, showing when the timer callback
|
||||
function is called.
|
||||
|
||||
- Improved diagnostics in streaming mode, in case of errors in the recorder.
|
||||
|
||||
* Added prvTraceWarning() - registers a "warning" error code, without
|
||||
stopping the recorder. Called if READ_DATA or WRITE_DATA returns a
|
||||
non-zero value, and in several other cases where the recorder
|
||||
configuration is incorrect (e.g., too small symbol table).
|
||||
|
||||
* Added several new warning codes (PSF_WARNING_XYZ), corresponding to the
|
||||
issues detected by prvCheckRecorderStatus.
|
||||
|
||||
* Fixed duplicate definitions of warning messages, so the warnings reported
|
||||
to Tracealyzer are the same as those provided in xTraceGetLastError().
|
||||
|
||||
* Added better explainations of warning/error messages in the body of
|
||||
xTraceGetLastError (in streaming mode).
|
||||
|
||||
- Added xTraceIsRecordingEnabled() to Common API.
|
||||
|
||||
- Added "unofficial" hardware port for Altera Nios-II.
|
||||
This is a user contribition, not yet verified by Percerpio.
|
||||
|
||||
- Fixed bug in vTraceEnable - option TRC_START_AWAIT_HOST was ignored if already initialized.
|
||||
|
||||
- Fixed a few remaining compiler warnings.
|
||||
|
||||
- Changed order of some settings in trcConfig.h - moved advanced stuff to the
|
||||
bottom.
|
||||
|
||||
- Removed SEGGER_RTT_Printf.c from the J-Link stream port since not required
|
||||
for Tracealyzer.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Changes, v3.1.1 -> v3.1.2
|
||||
- Fixed two bugs related to User Events, one in vTracePrintF and other in vTracePrint.
|
||||
|
||||
- Fixed a build problem related to a single reference of the old FreeRTOS type "xTaskHandle", in trcKernelPort.c.
|
||||
Changed to "TaskHandle_t", unless if using an older FreeRTOS kernel or the "compatibility mode".
|
||||
|
||||
- Removed traceCREATE_MUTEX hook for FreeRTOS v9 or later (no longer required)
|
||||
|
||||
- Updated the User Manual regarding snapshot trace via IAR Embedded Workbench.
|
||||
|
||||
- Renamed vTraceGetTraceBuffer to xTraceGetTraceBuffer, since returning a pointer.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Changes, v3.1.0 -> v3.1.1
|
||||
|
||||
After the major changes in the v3.1.0 trace recorder library, this update
|
||||
corrects a number of minor issues. Only minor functional improvements.
|
||||
|
||||
- You can now use TRC_ALLOC_CUSTOM_BUFFER to declare a trace buffer on a custom
|
||||
location (using linker directives).
|
||||
The related function vTraceSetRecorderDataBuffer has been promoted to the
|
||||
Common API (previously only supported in snapshot mode, but custom allocation
|
||||
is now generally supported also in streaming mode).
|
||||
|
||||
- Removed TRC_CFG_USE_LINKER_PRAGMA. No longer necessary thanks to the custom
|
||||
allocation mode.
|
||||
|
||||
- Added support for timestamping from custom periodic timers, required for
|
||||
accurate timestamping on Cortex-M0/M0+ devices when using tickless idle.
|
||||
Only for streaming mode so far. See TRC_CUSTOM_TIMER_INCR / DECR.
|
||||
|
||||
- ARM Cortex-M port: Made sure the DWT unit is initialized properly, in case
|
||||
the debugger doesn't handle this.
|
||||
|
||||
- ARM Cortex-M port: Added possibility to use Systick timestamping also on
|
||||
Cortex-M3/M4/M7 devices (that otherwise use DWT timestamping by default).
|
||||
To use this option, define the macro TRC_CFG_ARM_CM_USE_SYSTICK.
|
||||
|
||||
- J-Link streaming: The default RTT buffer has been changed from 0 to 1.
|
||||
|
||||
- J-Link streaming: The RTT buffer settings for buffer 1 and higher, are now
|
||||
found in trcStreamingPort.h. Note: These settings don't apply to buffer 0.
|
||||
|
||||
- vTracePrint has been optimized for better performance in string logging.
|
||||
|
||||
- Minor performance improvement related to symbol table transfer in streaming mode.
|
||||
|
||||
- Timer names now registered also in streaming mode.
|
||||
|
||||
- Timer start and stop event are now traced.
|
||||
|
||||
- Implemented support for queue registry (traceQUEUE_REGISTRY_ADD) also for streaming.
|
||||
|
||||
- Fixed a bug related to repeated calls of vTraceEnable.
|
||||
|
||||
- Fixed a bug where task-switches seemed to occur even though the scheduler was disabled.
|
||||
|
||||
- Renamed HARDWARE_PORT_TEXAS_INSTRUMENTS_TMS570_RM48, added prefix TRC.
|
||||
|
||||
- Fixed several language issues in the comments and documentation.
|
||||
|
||||
- Fixed several minor issues and warnings from different compilers
|
||||
(including PowerPC/gcc) and configurations.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Changes, v3.0.9 -> v3.1.0
|
||||
|
||||
- Merge of previously separated snapshot and streaming recorders into a single
|
||||
recorder supporting both streaming and snapshot as different modes.
|
||||
|
||||
- New common API for supporting both streaming and snapshot modes.
|
||||
|
||||
- New integration guide, see the User Manual.
|
||||
|
||||
- Major improvement of API documentation in source files and User Manual.
|
||||
|
||||
- New concept of "stream ports", giving a better structure defining streaming
|
||||
interfaces, and restructured the J-Link and TCP/IP streaming as stream ports.
|
||||
|
||||
- Added a stream port for USB CDC connections, with STM32 as example.
|
||||
Since Tracealyzer now can receive serial data on Windows COM ports, this is
|
||||
really easy to use.
|
||||
|
||||
- Added a warning (#error) for cases where FreeRTOS tickless idle mode is used
|
||||
together with timestamping using SysTick or other periodic interrupt timers,
|
||||
Tracing with tickless idle requires an independent time source to correctly
|
||||
capture the length of the idle periods.
|
||||
|
||||
- Major changes in the recorder API. Important examples are:
|
||||
|
||||
* Some configuration macros have changed names, e.g. for "hardware port".
|
||||
Make sure to remove any old "trcConfig.h" files if upgrading from an
|
||||
earlier version!
|
||||
|
||||
* Recorder configuration in trcConfig.h has been minimized and now only
|
||||
includes the important settings that are independent of recorder mode.
|
||||
Advanced settings for each mode are found in trcSnapshotConfig.h and
|
||||
trcStreamingConfig.h.
|
||||
|
||||
* vTraceEnable replaces Trace_Init and vTraceInitTraceData, as well as
|
||||
vTraceStart and uiTraceStart.
|
||||
|
||||
* vTraceStop now part of the common API and thereby available also in
|
||||
streaming. And since vTraceEnable can start the streaming directly
|
||||
you have the option control the tracing from target, e.g., for
|
||||
streaming to a device file system.
|
||||
|
||||
* vTraceStoreKernelObjectName from old streaming recorder has been replaced
|
||||
by vTraceSetQueueName, vTraceSetSemaphoreName, etc.
|
||||
|
||||
* vTraceSetISRProperties now returns a "traceHandle" that should be passed as
|
||||
parameter to vTraceStoreISRBegin and vTraceStoreISREnd.
|
||||
|
||||
* xTraceRegisterString has replaced the old functions xTraceOpenLabel and
|
||||
vTraceStoreUserEventChannelName. This now returns a "traceString" for use
|
||||
as "channel" parameter in vTracePrintF, and in other places where strings
|
||||
are stored.
|
||||
|
||||
* Removed vTraceStoreISREndManual and vTraceStoreISREndAuto, use
|
||||
vTraceStoreISREnd instead.
|
||||
|
||||
* Renamed the functions for saving User Events in a separate buffer:
|
||||
- xTraceRegisterChannelFormat -> xTraceRegisterUBChannel
|
||||
- vTraceChannelPrintF -> vTraceUBData
|
||||
- vTraceChannelUserEvent -> vTraceUBEvent
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright Percepio AB, 2018.
|
@ -0,0 +1,833 @@
|
||||
/*******************************************************************************
|
||||
* Trace Recorder Library for Tracealyzer v4.1.5
|
||||
* Percepio AB, www.percepio.com
|
||||
*
|
||||
* trcKernelPort.c
|
||||
*
|
||||
* The FreeRTOS-specific parts of 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
|
||||
******************************************************************************/
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
#if (!defined(TRC_USE_TRACEALYZER_RECORDER) && configUSE_TRACE_FACILITY == 1)
|
||||
#error Trace Recorder: You need to include trcRecorder.h at the end of your FreeRTOSConfig.h!
|
||||
#endif
|
||||
|
||||
#if (defined(TRC_USE_TRACEALYZER_RECORDER) && TRC_USE_TRACEALYZER_RECORDER == 1)
|
||||
|
||||
#ifndef TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS
|
||||
/* TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS is missing in trcConfig.h. */
|
||||
#error "TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS must be defined in trcConfig.h."
|
||||
#endif
|
||||
|
||||
#ifndef TRC_CFG_INCLUDE_TIMER_EVENTS
|
||||
/* TRC_CFG_INCLUDE_TIMER_EVENTS is missing in trcConfig.h. */
|
||||
#error "TRC_CFG_INCLUDE_TIMER_EVENTS must be defined in trcConfig.h."
|
||||
#endif
|
||||
|
||||
#ifndef TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS
|
||||
/* TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS is missing in trcConfig.h. */
|
||||
#error "TRC_CFG_INCLUDE_PEND_FUNC_CALL_EVENTS must be defined in trcConfig.h."
|
||||
#endif
|
||||
|
||||
#ifndef TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS
|
||||
/* TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS is missing in trcConfig.h. Define this as 1 if using FreeRTOS v10 or later and like to trace stream buffer or message buffer events, otherwise 0. */
|
||||
#error "TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS must be defined in trcConfig.h."
|
||||
#endif
|
||||
|
||||
#if (configUSE_TICKLESS_IDLE != 0 && (TRC_HWTC_TYPE == TRC_OS_TIMER_INCR || TRC_HWTC_TYPE == TRC_OS_TIMER_DECR))
|
||||
/*
|
||||
The below error message is to alert you on the following issue:
|
||||
|
||||
The hardware port selected in trcConfig.h uses the operating system timer for the
|
||||
timestamping, i.e., the periodic interrupt timer that drives the OS tick interrupt.
|
||||
|
||||
When using "tickless idle" mode, the recorder needs an independent time source in
|
||||
order to correctly record the durations of the idle times. Otherwise, the trace may appear
|
||||
to have a different length than in reality, and the reported CPU load is also affected.
|
||||
|
||||
You may override this warning by defining the TRC_CFG_ACKNOWLEDGE_TICKLESS_IDLE_WARNING
|
||||
macro in your trcConfig.h file. But then the time scale may be incorrect during
|
||||
tickless idle periods.
|
||||
|
||||
To get this correct, override the default timestamping by setting TRC_CFG_HARDWARE_PORT
|
||||
in trcConfig.h to TRC_HARDWARE_PORT_APPLICATION_DEFINED and define the HWTC macros
|
||||
accordingly, using a free running counter or an independent periodic interrupt timer.
|
||||
See trcHardwarePort.h for details.
|
||||
|
||||
For ARM Cortex-M3, M4 and M7 MCUs this is not an issue, since the recorder uses the
|
||||
DWT cycle counter for timestamping in these cases.
|
||||
*/
|
||||
|
||||
#ifndef TRC_CFG_ACKNOWLEDGE_TICKLESS_IDLE_WARNING
|
||||
#error Trace Recorder: This timestamping mode is not recommended with Tickless Idle.
|
||||
#endif
|
||||
#endif /* (configUSE_TICKLESS_IDLE != 0 && (TRC_HWTC_TYPE == TRC_OS_TIMER_INCR || TRC_HWTC_TYPE == TRC_OS_TIMER_DECR)) */
|
||||
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
|
||||
#if (TRC_CFG_INCLUDE_TIMER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X)
|
||||
/* If the project does not include the FreeRTOS timers, TRC_CFG_INCLUDE_TIMER_EVENTS must be set to 0 */
|
||||
#include "timers.h"
|
||||
#endif /* (TRC_CFG_INCLUDE_TIMER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X) */
|
||||
|
||||
#if (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X)
|
||||
/* If the project does not include the FreeRTOS event groups, TRC_CFG_INCLUDE_TIMER_EVENTS must be set to 0 */
|
||||
#include "event_groups.h"
|
||||
#endif /* (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X) */
|
||||
|
||||
#if (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0)
|
||||
/* If the project does not include the FreeRTOS stream buffers, TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS must be set to 0 */
|
||||
#include "stream_buffer.h"
|
||||
#endif /* (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */
|
||||
|
||||
uint32_t prvTraceGetQueueNumber(void* handle);
|
||||
|
||||
#if (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_8_X)
|
||||
|
||||
extern unsigned char ucQueueGetQueueNumber( xQueueHandle pxQueue );
|
||||
extern void vQueueSetQueueNumber( xQueueHandle pxQueue, unsigned char ucQueueNumber );
|
||||
extern unsigned char ucQueueGetQueueType( xQueueHandle pxQueue );
|
||||
|
||||
uint32_t prvTraceGetQueueNumber(void* handle)
|
||||
{
|
||||
return (uint32_t)ucQueueGetQueueNumber(handle);
|
||||
}
|
||||
#else
|
||||
uint32_t prvTraceGetQueueNumber(void* handle)
|
||||
{
|
||||
return (uint32_t)uxQueueGetQueueNumber(handle);
|
||||
}
|
||||
#endif /* (TRC_CFG_FREERTOS_VERSION < TRC_FREERTOS_VERSION_8_X) */
|
||||
|
||||
uint8_t prvTraceGetQueueType(void* handle)
|
||||
{
|
||||
// This is either declared in header file in FreeRTOS 8 and later, or as extern above
|
||||
return ucQueueGetQueueType(handle);
|
||||
}
|
||||
|
||||
/* Tasks */
|
||||
uint16_t prvTraceGetTaskNumberLow16(void* handle)
|
||||
{
|
||||
return TRACE_GET_LOW16(uxTaskGetTaskNumber(handle));
|
||||
}
|
||||
|
||||
uint16_t prvTraceGetTaskNumberHigh16(void* handle)
|
||||
{
|
||||
return TRACE_GET_HIGH16(uxTaskGetTaskNumber(handle));
|
||||
}
|
||||
|
||||
void prvTraceSetTaskNumberLow16(void* handle, uint16_t value)
|
||||
{
|
||||
vTaskSetTaskNumber(handle, TRACE_SET_LOW16(uxTaskGetTaskNumber(handle), value));
|
||||
}
|
||||
|
||||
void prvTraceSetTaskNumberHigh16(void* handle, uint16_t value)
|
||||
{
|
||||
vTaskSetTaskNumber(handle, TRACE_SET_HIGH16(uxTaskGetTaskNumber(handle), value));
|
||||
}
|
||||
|
||||
uint16_t prvTraceGetQueueNumberLow16(void* handle)
|
||||
{
|
||||
return TRACE_GET_LOW16(prvTraceGetQueueNumber(handle));
|
||||
}
|
||||
|
||||
uint16_t prvTraceGetQueueNumberHigh16(void* handle)
|
||||
{
|
||||
return TRACE_GET_HIGH16(prvTraceGetQueueNumber(handle));
|
||||
}
|
||||
|
||||
void prvTraceSetQueueNumberLow16(void* handle, uint16_t value)
|
||||
{
|
||||
vQueueSetQueueNumber(handle, TRACE_SET_LOW16(prvTraceGetQueueNumber(handle), value));
|
||||
}
|
||||
|
||||
void prvTraceSetQueueNumberHigh16(void* handle, uint16_t value)
|
||||
{
|
||||
vQueueSetQueueNumber(handle, TRACE_SET_HIGH16(prvTraceGetQueueNumber(handle), value));
|
||||
}
|
||||
|
||||
#if (TRC_CFG_INCLUDE_TIMER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0)
|
||||
|
||||
uint16_t prvTraceGetTimerNumberLow16(void* handle)
|
||||
{
|
||||
return TRACE_GET_LOW16(uxTimerGetTimerNumber(handle));
|
||||
}
|
||||
|
||||
uint16_t prvTraceGetTimerNumberHigh16(void* handle)
|
||||
{
|
||||
return TRACE_GET_HIGH16(uxTimerGetTimerNumber(handle));
|
||||
}
|
||||
|
||||
void prvTraceSetTimerNumberLow16(void* handle, uint16_t value)
|
||||
{
|
||||
vTimerSetTimerNumber(handle, TRACE_SET_LOW16(uxTimerGetTimerNumber(handle), value));
|
||||
}
|
||||
|
||||
void prvTraceSetTimerNumberHigh16(void* handle, uint16_t value)
|
||||
{
|
||||
vTimerSetTimerNumber(handle, TRACE_SET_HIGH16(uxTimerGetTimerNumber(handle), value));
|
||||
}
|
||||
#endif /* (TRC_CFG_INCLUDE_TIMER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */
|
||||
|
||||
#if (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0)
|
||||
|
||||
uint16_t prvTraceGetEventGroupNumberLow16(void* handle)
|
||||
{
|
||||
return TRACE_GET_LOW16(uxEventGroupGetNumber(handle));
|
||||
}
|
||||
|
||||
uint16_t prvTraceGetEventGroupNumberHigh16(void* handle)
|
||||
{
|
||||
return TRACE_GET_HIGH16(uxEventGroupGetNumber(handle));
|
||||
}
|
||||
|
||||
void prvTraceSetEventGroupNumberLow16(void* handle, uint16_t value)
|
||||
{
|
||||
vEventGroupSetNumber(handle, TRACE_SET_LOW16(uxEventGroupGetNumber(handle), value));
|
||||
}
|
||||
|
||||
void prvTraceSetEventGroupNumberHigh16(void* handle, uint16_t value)
|
||||
{
|
||||
vEventGroupSetNumber(handle, TRACE_SET_HIGH16(uxEventGroupGetNumber(handle), value));
|
||||
}
|
||||
#endif /* (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */
|
||||
|
||||
#if (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0)
|
||||
|
||||
uint16_t prvTraceGetStreamBufferNumberLow16(void* handle)
|
||||
{
|
||||
return TRACE_GET_LOW16(uxStreamBufferGetStreamBufferNumber(handle));
|
||||
}
|
||||
|
||||
uint16_t prvTraceGetStreamBufferNumberHigh16(void* handle)
|
||||
{
|
||||
return TRACE_GET_HIGH16(uxStreamBufferGetStreamBufferNumber(handle));
|
||||
}
|
||||
|
||||
void prvTraceSetStreamBufferNumberLow16(void* handle, uint16_t value)
|
||||
{
|
||||
vStreamBufferSetStreamBufferNumber(handle, TRACE_SET_LOW16(uxStreamBufferGetStreamBufferNumber(handle), value));
|
||||
}
|
||||
|
||||
void prvTraceSetStreamBufferNumberHigh16(void* handle, uint16_t value)
|
||||
{
|
||||
vStreamBufferSetStreamBufferNumber(handle, TRACE_SET_HIGH16(uxStreamBufferGetStreamBufferNumber(handle), value));
|
||||
}
|
||||
#endif /* (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */
|
||||
|
||||
#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
|
||||
|
||||
static void* pCurrentTCB = NULL;
|
||||
#if (defined(configENABLE_BACKWARD_COMPATIBILITY) && configENABLE_BACKWARD_COMPATIBILITY == 0)
|
||||
/* We're explicitly not using compatibility mode */
|
||||
static TaskHandle_t HandleTzCtrl = NULL; /* TzCtrl task TCB */
|
||||
#else
|
||||
/* We're using compatibility mode, or we're running an old kernel */
|
||||
static xTaskHandle HandleTzCtrl = NULL; /* TzCtrl task TCB */
|
||||
#endif
|
||||
|
||||
#if defined(configSUPPORT_STATIC_ALLOCATION)
|
||||
#if (configSUPPORT_STATIC_ALLOCATION == 1)
|
||||
static StackType_t stackTzCtrl[TRC_CFG_CTRL_TASK_STACK_SIZE];
|
||||
static StaticTask_t tcbTzCtrl;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Monitored by TzCtrl task, that give warnings as User Events */
|
||||
extern volatile uint32_t NoRoomForSymbol;
|
||||
extern volatile uint32_t NoRoomForObjectData;
|
||||
extern volatile uint32_t LongestSymbolName;
|
||||
extern volatile uint32_t MaxBytesTruncated;
|
||||
|
||||
/* Keeps track of previous values, to only react on changes. */
|
||||
static uint32_t NoRoomForSymbol_last = 0;
|
||||
static uint32_t NoRoomForObjectData_last = 0;
|
||||
static uint32_t LongestSymbolName_last = 0;
|
||||
static uint32_t MaxBytesTruncated_last = 0;
|
||||
|
||||
/* User Event Channel for giving warnings regarding NoRoomForSymbol etc. */
|
||||
traceString trcWarningChannel;
|
||||
|
||||
#define TRC_PORT_MALLOC(size) pvPortMalloc(size)
|
||||
|
||||
TRC_STREAM_PORT_ALLOCATE_FIELDS()
|
||||
|
||||
/* Called by TzCtrl task periodically (Normally every 100 ms) */
|
||||
static void prvCheckRecorderStatus(void);
|
||||
|
||||
extern void prvTraceWarning(int errCode);
|
||||
|
||||
/* The TzCtrl task - receives commands from Tracealyzer (start/stop) */
|
||||
static portTASK_FUNCTION( TzCtrl, pvParameters );
|
||||
|
||||
/*******************************************************************************
|
||||
* vTraceEnable
|
||||
*
|
||||
* Function that enables the tracing and creates the control task. It will halt
|
||||
* execution until a Start command has been received if haltUntilStart is true.
|
||||
*
|
||||
******************************************************************************/
|
||||
void vTraceEnable(int startOption)
|
||||
{
|
||||
int32_t bytes = 0;
|
||||
int32_t status;
|
||||
extern uint32_t RecorderEnabled;
|
||||
TracealyzerCommandType msg;
|
||||
|
||||
/* Only do this first time...*/
|
||||
if (HandleTzCtrl == NULL)
|
||||
{
|
||||
TRC_STREAM_PORT_INIT();
|
||||
|
||||
/* Note: Requires that TRC_CFG_INCLUDE_USER_EVENTS is 1. */
|
||||
trcWarningChannel = xTraceRegisterString("Warnings from Recorder");
|
||||
|
||||
/* Creates the TzCtrl task - receives trace commands (start, stop, ...) */
|
||||
#if defined(configSUPPORT_STATIC_ALLOCATION) && (configSUPPORT_STATIC_ALLOCATION == 1)
|
||||
HandleTzCtrl = xTaskCreateStatic(TzCtrl, STRING_CAST("TzCtrl"), TRC_CFG_CTRL_TASK_STACK_SIZE, NULL, TRC_CFG_CTRL_TASK_PRIORITY, stackTzCtrl, &tcbTzCtrl);
|
||||
#else
|
||||
xTaskCreate( TzCtrl, STRING_CAST("TzCtrl"), TRC_CFG_CTRL_TASK_STACK_SIZE, NULL, TRC_CFG_CTRL_TASK_PRIORITY, &HandleTzCtrl );
|
||||
#endif
|
||||
|
||||
if (HandleTzCtrl == NULL)
|
||||
{
|
||||
prvTraceError(PSF_ERROR_TZCTRLTASK_NOT_CREATED);
|
||||
}
|
||||
}
|
||||
|
||||
if (startOption == TRC_START_AWAIT_HOST)
|
||||
{
|
||||
/* We keep trying to read commands until the recorder has been started */
|
||||
do
|
||||
{
|
||||
bytes = 0;
|
||||
|
||||
status = TRC_STREAM_PORT_READ_DATA(&msg, sizeof(TracealyzerCommandType), (int32_t*)&bytes);
|
||||
|
||||
if (status != 0)
|
||||
{
|
||||
prvTraceWarning(PSF_WARNING_STREAM_PORT_READ);
|
||||
}
|
||||
|
||||
if ((status == 0) && (bytes == sizeof(TracealyzerCommandType)))
|
||||
{
|
||||
if (prvIsValidCommand(&msg))
|
||||
{
|
||||
if (msg.cmdCode == CMD_SET_ACTIVE && msg.param1 == 1)
|
||||
{
|
||||
/* On start, init and reset the timestamping */
|
||||
TRC_PORT_SPECIFIC_INIT();
|
||||
}
|
||||
|
||||
prvProcessCommand(&msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
while (RecorderEnabled == 0);
|
||||
}
|
||||
else if (startOption == TRC_START)
|
||||
{
|
||||
/* We start streaming directly - this assumes that the interface is ready! */
|
||||
TRC_PORT_SPECIFIC_INIT();
|
||||
|
||||
msg.cmdCode = CMD_SET_ACTIVE;
|
||||
msg.param1 = 1;
|
||||
prvProcessCommand(&msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* On TRC_INIT */
|
||||
TRC_PORT_SPECIFIC_INIT();
|
||||
}
|
||||
}
|
||||
|
||||
#if (TRC_CFG_SCHEDULING_ONLY == 0)
|
||||
/*******************************************************************************
|
||||
* vTraceSetQueueName(void* object, const char* name)
|
||||
*
|
||||
* Parameter object: pointer to the Queue that shall be named
|
||||
* Parameter name: the name to set (const string literal)
|
||||
*
|
||||
* Sets a name for Queue objects for display in Tracealyzer.
|
||||
******************************************************************************/
|
||||
void vTraceSetQueueName(void* object, const char* name)
|
||||
{
|
||||
vTraceStoreKernelObjectName(object, name);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* vTraceSetSemaphoreName(void* object, const char* name)
|
||||
*
|
||||
* Parameter object: pointer to the Semaphore that shall be named
|
||||
* Parameter name: the name to set (const string literal)
|
||||
*
|
||||
* Sets a name for Semaphore objects for display in Tracealyzer.
|
||||
******************************************************************************/
|
||||
void vTraceSetSemaphoreName(void* object, const char* name)
|
||||
{
|
||||
vTraceStoreKernelObjectName(object, name);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* vTraceSetMutexName(void* object, const char* name)
|
||||
*
|
||||
* Parameter object: pointer to the Mutex that shall be named
|
||||
* Parameter name: the name to set (const string literal)
|
||||
*
|
||||
* Sets a name for Mutex objects for display in Tracealyzer.
|
||||
******************************************************************************/
|
||||
void vTraceSetMutexName(void* object, const char* name)
|
||||
{
|
||||
vTraceStoreKernelObjectName(object, name);
|
||||
}
|
||||
|
||||
#if (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X)
|
||||
/*******************************************************************************
|
||||
* vTraceSetEventGroupName(void* object, const char* name)
|
||||
*
|
||||
* Parameter object: pointer to the vTraceSetEventGroupName that shall be named
|
||||
* Parameter name: the name to set (const string literal)
|
||||
*
|
||||
* Sets a name for EventGroup objects for display in Tracealyzer.
|
||||
******************************************************************************/
|
||||
void vTraceSetEventGroupName(void* object, const char* name)
|
||||
{
|
||||
vTraceStoreKernelObjectName(object, name);
|
||||
}
|
||||
#endif /* (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X) */
|
||||
|
||||
#if (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0)
|
||||
/*******************************************************************************
|
||||
* vTraceSetStreamBufferName(void* object, const char* name)
|
||||
*
|
||||
* Parameter object: pointer to the StreamBuffer that shall be named
|
||||
* Parameter name: the name to set (const string literal)
|
||||
*
|
||||
* Sets a name for StreamBuffer objects for display in Tracealyzer.
|
||||
******************************************************************************/
|
||||
void vTraceSetStreamBufferName(void* object, const char* name)
|
||||
{
|
||||
vTraceStoreKernelObjectName(object, name);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* vTraceSetMessageBufferName(void* object, const char* name)
|
||||
*
|
||||
* Parameter object: pointer to the MessageBuffer that shall be named
|
||||
* Parameter name: the name to set (const string literal)
|
||||
*
|
||||
* Sets a name for MessageBuffer objects for display in Tracealyzer.
|
||||
******************************************************************************/
|
||||
void vTraceSetMessageBufferName(void* object, const char* name)
|
||||
{
|
||||
vTraceStoreKernelObjectName(object, name);
|
||||
}
|
||||
#endif /* (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */
|
||||
|
||||
#endif /* (TRC_CFG_SCHEDULING_ONLY == 0) */
|
||||
|
||||
/*******************************************************************************
|
||||
* prvGetCurrentTaskHandle
|
||||
*
|
||||
* Function that returns the handle to the currently executing task.
|
||||
*
|
||||
******************************************************************************/
|
||||
void* prvTraceGetCurrentTaskHandle(void)
|
||||
{
|
||||
return xTaskGetCurrentTaskHandle();
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* prvIsNewTCB
|
||||
*
|
||||
* Tells if this task is already executing, or if there has been a task-switch.
|
||||
* Assumed to be called within a trace hook in kernel context.
|
||||
******************************************************************************/
|
||||
uint32_t prvIsNewTCB(void* pNewTCB)
|
||||
{
|
||||
if (pCurrentTCB != pNewTCB)
|
||||
{
|
||||
pCurrentTCB = pNewTCB;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* prvTraceIsSchedulerSuspended
|
||||
*
|
||||
* Returns true if the RTOS scheduler currently is disabled, thus preventing any
|
||||
* task-switches from occurring. Only called from vTraceStoreISREnd.
|
||||
******************************************************************************/
|
||||
unsigned char prvTraceIsSchedulerSuspended(void)
|
||||
{
|
||||
/* Assumed to be available in FreeRTOS. According to the FreeRTOS docs,
|
||||
INCLUDE_xTaskGetSchedulerState or configUSE_TIMERS must be set to 1 in
|
||||
FreeRTOSConfig.h for this function to be available. */
|
||||
|
||||
return xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* prvCheckRecorderStatus
|
||||
*
|
||||
* Called by TzCtrl task periodically (every 100 ms - seems reasonable).
|
||||
* Checks a number of diagnostic variables and give warnings as user events,
|
||||
* in most cases including a suggested solution.
|
||||
******************************************************************************/
|
||||
static void prvCheckRecorderStatus(void)
|
||||
{
|
||||
if (NoRoomForSymbol > NoRoomForSymbol_last)
|
||||
{
|
||||
if (NoRoomForSymbol > 0)
|
||||
{
|
||||
prvTraceWarning(PSF_WARNING_SYMBOL_TABLE_SLOTS);
|
||||
}
|
||||
NoRoomForSymbol_last = NoRoomForSymbol;
|
||||
}
|
||||
|
||||
if (NoRoomForObjectData > NoRoomForObjectData_last)
|
||||
{
|
||||
if (NoRoomForObjectData > 0)
|
||||
{
|
||||
prvTraceWarning(PSF_WARNING_OBJECT_DATA_SLOTS);
|
||||
}
|
||||
NoRoomForObjectData_last = NoRoomForObjectData;
|
||||
}
|
||||
|
||||
if (LongestSymbolName > LongestSymbolName_last)
|
||||
{
|
||||
if (LongestSymbolName > (TRC_CFG_SYMBOL_MAX_LENGTH))
|
||||
{
|
||||
prvTraceWarning(PSF_WARNING_SYMBOL_MAX_LENGTH);
|
||||
}
|
||||
LongestSymbolName_last = LongestSymbolName;
|
||||
}
|
||||
|
||||
if (MaxBytesTruncated > MaxBytesTruncated_last)
|
||||
{
|
||||
if (MaxBytesTruncated > 0)
|
||||
{
|
||||
prvTraceWarning(PSF_WARNING_STRING_TOO_LONG);
|
||||
}
|
||||
MaxBytesTruncated_last = MaxBytesTruncated;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* TzCtrl
|
||||
*
|
||||
* Task for sending the trace data from the internal buffer to the stream
|
||||
* interface (assuming TRC_STREAM_PORT_USE_INTERNAL_BUFFER == 1) and for
|
||||
* receiving commands from Tracealyzer. Also does some diagnostics.
|
||||
******************************************************************************/
|
||||
static portTASK_FUNCTION( TzCtrl, pvParameters )
|
||||
{
|
||||
TracealyzerCommandType msg;
|
||||
int32_t bytes = 0;
|
||||
int32_t status = 0;
|
||||
(void)pvParameters;
|
||||
|
||||
while (1)
|
||||
{
|
||||
do
|
||||
{
|
||||
/* Listen for new commands */
|
||||
bytes = 0;
|
||||
status = TRC_STREAM_PORT_READ_DATA(&msg, sizeof(TracealyzerCommandType), (int32_t*)&bytes);
|
||||
|
||||
if (status != 0)
|
||||
{
|
||||
prvTraceWarning(PSF_WARNING_STREAM_PORT_READ);
|
||||
}
|
||||
|
||||
if ((status == 0) && (bytes == sizeof(TracealyzerCommandType)))
|
||||
{
|
||||
if (prvIsValidCommand(&msg))
|
||||
{
|
||||
prvProcessCommand(&msg); /* Start or Stop currently... */
|
||||
}
|
||||
}
|
||||
|
||||
/* If the internal buffer is disabled, the COMMIT macro instead sends the data directly
|
||||
from the "event functions" (using TRC_STREAM_PORT_WRITE_DATA). */
|
||||
#if (TRC_STREAM_PORT_USE_INTERNAL_BUFFER == 1)
|
||||
/* If there is a buffer page, this sends it to the streaming interface using TRC_STREAM_PORT_WRITE_DATA. */
|
||||
bytes = prvPagedEventBufferTransfer();
|
||||
#endif
|
||||
|
||||
/* If there was data sent or received (bytes != 0), loop around and repeat, if there is more data to send or receive.
|
||||
Otherwise, step out of this loop and sleep for a while. */
|
||||
|
||||
} while (bytes != 0);
|
||||
|
||||
prvCheckRecorderStatus();
|
||||
|
||||
vTaskDelay(TRC_CFG_CTRL_TASK_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/
|
||||
|
||||
|
||||
#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT)
|
||||
|
||||
/* Internal flag to tell the context of tracePEND_FUNC_CALL_FROM_ISR */
|
||||
int uiInEventGroupSetBitsFromISR = 0;
|
||||
|
||||
/******************************************************************************
|
||||
* TraceQueueClassTable
|
||||
* Translates a FreeRTOS QueueType into trace objects classes (TRACE_CLASS_).
|
||||
* Has one entry for each QueueType, gives TRACE_CLASS ID.
|
||||
******************************************************************************/
|
||||
traceObjectClass TraceQueueClassTable[5] = {
|
||||
TRACE_CLASS_QUEUE,
|
||||
TRACE_CLASS_MUTEX,
|
||||
TRACE_CLASS_SEMAPHORE,
|
||||
TRACE_CLASS_SEMAPHORE,
|
||||
TRACE_CLASS_MUTEX
|
||||
};
|
||||
|
||||
#if (TRC_CFG_SCHEDULING_ONLY == 0)
|
||||
/*******************************************************************************
|
||||
* vTraceSetQueueName(void* object, const char* name)
|
||||
*
|
||||
* Parameter object: pointer to the Queue that shall be named
|
||||
* Parameter name: the name to set (const string literal)
|
||||
*
|
||||
* Sets a name for Queue objects for display in Tracealyzer.
|
||||
******************************************************************************/
|
||||
void vTraceSetQueueName(void* object, const char* name)
|
||||
{
|
||||
prvTraceSetObjectName(TRACE_CLASS_QUEUE, TRACE_GET_OBJECT_NUMBER(QUEUE, object), name);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* vTraceSetSemaphoreName(void* object, const char* name)
|
||||
*
|
||||
* Parameter object: pointer to the Semaphore that shall be named
|
||||
* Parameter name: the name to set (const string literal)
|
||||
*
|
||||
* Sets a name for Semaphore objects for display in Tracealyzer.
|
||||
******************************************************************************/
|
||||
void vTraceSetSemaphoreName(void* object, const char* name)
|
||||
{
|
||||
prvTraceSetObjectName(TRACE_CLASS_SEMAPHORE, TRACE_GET_OBJECT_NUMBER(QUEUE, object), name);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* vTraceSetMutexName(void* object, const char* name)
|
||||
*
|
||||
* Parameter object: pointer to the Mutex that shall be named
|
||||
* Parameter name: the name to set (const string literal)
|
||||
*
|
||||
* Sets a name for Semaphore objects for display in Tracealyzer.
|
||||
******************************************************************************/
|
||||
void vTraceSetMutexName(void* object, const char* name)
|
||||
{
|
||||
prvTraceSetObjectName(TRACE_CLASS_MUTEX, TRACE_GET_OBJECT_NUMBER(QUEUE, object), name);
|
||||
}
|
||||
|
||||
#if (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X)
|
||||
/*******************************************************************************
|
||||
* vTraceSetEventGroupName(void* object, const char* name)
|
||||
*
|
||||
* Parameter object: pointer to the EventGroup that shall be named
|
||||
* Parameter name: the name to set (const string literal)
|
||||
*
|
||||
* Sets a name for EventGroup objects for display in Tracealyzer.
|
||||
******************************************************************************/
|
||||
void vTraceSetEventGroupName(void* object, const char* name)
|
||||
{
|
||||
prvTraceSetObjectName(TRACE_CLASS_EVENTGROUP, TRACE_GET_OBJECT_NUMBER(EVENTGROUP, object), name);
|
||||
}
|
||||
#endif /* (TRC_CFG_INCLUDE_EVENT_GROUP_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_8_X) */
|
||||
|
||||
#if (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0)
|
||||
/*******************************************************************************
|
||||
* vTraceSetStreamBufferName(void* object, const char* name)
|
||||
*
|
||||
* Parameter object: pointer to the StreamBuffer that shall be named
|
||||
* Parameter name: the name to set (const string literal)
|
||||
*
|
||||
* Sets a name for StreamBuffer objects for display in Tracealyzer.
|
||||
******************************************************************************/
|
||||
void vTraceSetStreamBufferName(void* object, const char* name)
|
||||
{
|
||||
prvTraceSetObjectName(TRACE_CLASS_STREAMBUFFER, TRACE_GET_OBJECT_NUMBER(STREAMBUFFER, object), name);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* vTraceSetMessageBufferName(void* object, const char* name)
|
||||
*
|
||||
* Parameter object: pointer to the MessageBuffer that shall be named
|
||||
* Parameter name: the name to set (const string literal)
|
||||
*
|
||||
* Sets a name for MessageBuffer objects for display in Tracealyzer.
|
||||
******************************************************************************/
|
||||
void vTraceSetMessageBufferName(void* object, const char* name)
|
||||
{
|
||||
prvTraceSetObjectName(TRACE_CLASS_MESSAGEBUFFER, TRACE_GET_OBJECT_NUMBER(STREAMBUFFER, object), name);
|
||||
}
|
||||
#endif /* (TRC_CFG_INCLUDE_STREAM_BUFFER_EVENTS == 1 && TRC_CFG_FREERTOS_VERSION >= TRC_FREERTOS_VERSION_10_0_0) */
|
||||
|
||||
#endif /* (TRC_CFG_SCHEDULING_ONLY == 0) */
|
||||
|
||||
void* prvTraceGetCurrentTaskHandle()
|
||||
{
|
||||
return xTaskGetCurrentTaskHandle();
|
||||
}
|
||||
|
||||
/* Initialization of the object property table */
|
||||
void vTraceInitObjectPropertyTable()
|
||||
{
|
||||
RecorderDataPtr->ObjectPropertyTable.NumberOfObjectClasses = TRACE_NCLASSES;
|
||||
RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[0] = TRC_CFG_NQUEUE;
|
||||
RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[1] = TRC_CFG_NSEMAPHORE;
|
||||
RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[2] = TRC_CFG_NMUTEX;
|
||||
RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[3] = TRC_CFG_NTASK;
|
||||
RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[4] = TRC_CFG_NISR;
|
||||
RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[5] = TRC_CFG_NTIMER;
|
||||
RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[6] = TRC_CFG_NEVENTGROUP;
|
||||
RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[7] = TRC_CFG_NSTREAMBUFFER;
|
||||
RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[8] = TRC_CFG_NMESSAGEBUFFER;
|
||||
RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[0] = TRC_CFG_NAME_LEN_QUEUE;
|
||||
RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[1] = TRC_CFG_NAME_LEN_SEMAPHORE;
|
||||
RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[2] = TRC_CFG_NAME_LEN_MUTEX;
|
||||
RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[3] = TRC_CFG_NAME_LEN_TASK;
|
||||
RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[4] = TRC_CFG_NAME_LEN_ISR;
|
||||
RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[5] = TRC_CFG_NAME_LEN_TIMER;
|
||||
RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[6] = TRC_CFG_NAME_LEN_EVENTGROUP;
|
||||
RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[7] = TRC_CFG_NAME_LEN_STREAMBUFFER;
|
||||
RecorderDataPtr->ObjectPropertyTable.NameLengthPerClass[8] = TRC_CFG_NAME_LEN_MESSAGEBUFFER;
|
||||
RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[0] = PropertyTableSizeQueue;
|
||||
RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[1] = PropertyTableSizeSemaphore;
|
||||
RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[2] = PropertyTableSizeMutex;
|
||||
RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[3] = PropertyTableSizeTask;
|
||||
RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[4] = PropertyTableSizeISR;
|
||||
RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[5] = PropertyTableSizeTimer;
|
||||
RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[6] = PropertyTableSizeEventGroup;
|
||||
RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[7] = PropertyTableSizeStreamBuffer;
|
||||
RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[8] = PropertyTableSizeMessageBuffer;
|
||||
RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[0] = StartIndexQueue;
|
||||
RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[1] = StartIndexSemaphore;
|
||||
RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[2] = StartIndexMutex;
|
||||
RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[3] = StartIndexTask;
|
||||
RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[4] = StartIndexISR;
|
||||
RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[5] = StartIndexTimer;
|
||||
RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[6] = StartIndexEventGroup;
|
||||
RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[7] = StartIndexStreamBuffer;
|
||||
RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[8] = StartIndexMessageBuffer;
|
||||
RecorderDataPtr->ObjectPropertyTable.ObjectPropertyTableSizeInBytes = TRACE_OBJECT_TABLE_SIZE;
|
||||
}
|
||||
|
||||
/* Initialization of the handle mechanism, see e.g, prvTraceGetObjectHandle */
|
||||
void vTraceInitObjectHandleStack()
|
||||
{
|
||||
objectHandleStacks.indexOfNextAvailableHandle[0] = objectHandleStacks.lowestIndexOfClass[0] = 0;
|
||||
objectHandleStacks.indexOfNextAvailableHandle[1] = objectHandleStacks.lowestIndexOfClass[1] = (TRC_CFG_NQUEUE);
|
||||
objectHandleStacks.indexOfNextAvailableHandle[2] = objectHandleStacks.lowestIndexOfClass[2] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE);
|
||||
objectHandleStacks.indexOfNextAvailableHandle[3] = objectHandleStacks.lowestIndexOfClass[3] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX);
|
||||
objectHandleStacks.indexOfNextAvailableHandle[4] = objectHandleStacks.lowestIndexOfClass[4] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK);
|
||||
objectHandleStacks.indexOfNextAvailableHandle[5] = objectHandleStacks.lowestIndexOfClass[5] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK) + (TRC_CFG_NISR);
|
||||
objectHandleStacks.indexOfNextAvailableHandle[6] = objectHandleStacks.lowestIndexOfClass[6] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK) + (TRC_CFG_NISR) + (TRC_CFG_NTIMER);
|
||||
objectHandleStacks.indexOfNextAvailableHandle[7] = objectHandleStacks.lowestIndexOfClass[7] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK) + (TRC_CFG_NISR) + (TRC_CFG_NTIMER) + (TRC_CFG_NEVENTGROUP);
|
||||
objectHandleStacks.indexOfNextAvailableHandle[8] = objectHandleStacks.lowestIndexOfClass[8] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK) + (TRC_CFG_NISR) + (TRC_CFG_NTIMER) + (TRC_CFG_NEVENTGROUP) + (TRC_CFG_NSTREAMBUFFER);
|
||||
|
||||
objectHandleStacks.highestIndexOfClass[0] = (TRC_CFG_NQUEUE) - 1;
|
||||
objectHandleStacks.highestIndexOfClass[1] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) - 1;
|
||||
objectHandleStacks.highestIndexOfClass[2] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) - 1;
|
||||
objectHandleStacks.highestIndexOfClass[3] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK) - 1;
|
||||
objectHandleStacks.highestIndexOfClass[4] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK) + (TRC_CFG_NISR) - 1;
|
||||
objectHandleStacks.highestIndexOfClass[5] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK) + (TRC_CFG_NISR) + (TRC_CFG_NTIMER) - 1;
|
||||
objectHandleStacks.highestIndexOfClass[6] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK) + (TRC_CFG_NISR) + (TRC_CFG_NTIMER) + (TRC_CFG_NEVENTGROUP) - 1;
|
||||
objectHandleStacks.highestIndexOfClass[7] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK) + (TRC_CFG_NISR) + (TRC_CFG_NTIMER) + (TRC_CFG_NEVENTGROUP) + (TRC_CFG_NSTREAMBUFFER) - 1;
|
||||
objectHandleStacks.highestIndexOfClass[8] = (TRC_CFG_NQUEUE) + (TRC_CFG_NSEMAPHORE) + (TRC_CFG_NMUTEX) + (TRC_CFG_NTASK) + (TRC_CFG_NISR) + (TRC_CFG_NTIMER) + (TRC_CFG_NEVENTGROUP) + (TRC_CFG_NSTREAMBUFFER) + (TRC_CFG_NMESSAGEBUFFER) - 1;
|
||||
}
|
||||
|
||||
/* Returns the "Not enough handles" error message for this object class */
|
||||
const char* pszTraceGetErrorNotEnoughHandles(traceObjectClass objectclass)
|
||||
{
|
||||
switch(objectclass)
|
||||
{
|
||||
case TRACE_CLASS_TASK:
|
||||
return "Not enough TASK handles - increase TRC_CFG_NTASK in trcSnapshotConfig.h";
|
||||
case TRACE_CLASS_ISR:
|
||||
return "Not enough ISR handles - increase TRC_CFG_NISR in trcSnapshotConfig.h";
|
||||
case TRACE_CLASS_SEMAPHORE:
|
||||
return "Not enough SEMAPHORE handles - increase TRC_CFG_NSEMAPHORE in trcSnapshotConfig.h";
|
||||
case TRACE_CLASS_MUTEX:
|
||||
return "Not enough MUTEX handles - increase TRC_CFG_NMUTEX in trcSnapshotConfig.h";
|
||||
case TRACE_CLASS_QUEUE:
|
||||
return "Not enough QUEUE handles - increase TRC_CFG_NQUEUE in trcSnapshotConfig.h";
|
||||
case TRACE_CLASS_TIMER:
|
||||
return "Not enough TIMER handles - increase TRC_CFG_NTIMER in trcSnapshotConfig.h";
|
||||
case TRACE_CLASS_EVENTGROUP:
|
||||
return "Not enough EVENTGROUP handles - increase TRC_CFG_NEVENTGROUP in trcSnapshotConfig.h";
|
||||
case TRACE_CLASS_STREAMBUFFER:
|
||||
return "Not enough STREAMBUFFER handles - increase TRC_CFG_NSTREAMBUFFER in trcSnapshotConfig.h";
|
||||
case TRACE_CLASS_MESSAGEBUFFER:
|
||||
return "Not enough MESSAGEBUFFER handles - increase TRC_CFG_NMESSAGEBUFFER in trcSnapshotConfig.h";
|
||||
default:
|
||||
return "pszTraceGetErrorHandles: Invalid objectclass!";
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* prvTraceIsSchedulerSuspended
|
||||
*
|
||||
* Returns true if the RTOS scheduler currently is disabled, thus preventing any
|
||||
* task-switches from occurring. Only called from vTraceStoreISREnd.
|
||||
******************************************************************************/
|
||||
#if (TRC_CFG_INCLUDE_ISR_TRACING == 1)
|
||||
unsigned char prvTraceIsSchedulerSuspended(void)
|
||||
{
|
||||
/* Assumed to be available in FreeRTOS. According to the FreeRTOS docs,
|
||||
INCLUDE_xTaskGetSchedulerState or configUSE_TIMERS must be set to 1 in
|
||||
FreeRTOSConfig.h for this function to be available. */
|
||||
|
||||
return xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Snapshot mode */
|
||||
|
||||
#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user