From 1769bb7d39a14a96a12f52dc7e6341bc5e27f05a Mon Sep 17 00:00:00 2001 From: richardbarry Date: Tue, 16 Jul 2013 11:55:14 +0000 Subject: [PATCH] Update FreeRTOS+Trace recorder code. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1983 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- .../ConfigurationTemplate/trcConfig.h | 73 +++---------------- .../ConfigurationTemplate/trcHardwarePort.h | 65 ++++++----------- .../FreeRTOS-Plus-Trace/Include/trcBase.h | 23 +++--- .../FreeRTOS-Plus-Trace/Include/trcKernel.h | 4 +- .../Include/{trcHooks.h => trcKernelHooks.h} | 2 +- .../Include/trcKernelPort.h | 40 ++++++++-- .../FreeRTOS-Plus-Trace/Include/trcTypes.h | 2 +- .../FreeRTOS-Plus-Trace/Include/trcUser.h | 32 ++++---- .../Source/FreeRTOS-Plus-Trace/readme.txt | 2 +- .../Source/FreeRTOS-Plus-Trace/trcBase.c | 23 +++--- .../FreeRTOS-Plus-Trace/trcHardwarePort.c | 13 +++- .../Source/FreeRTOS-Plus-Trace/trcKernel.c | 43 ++++++++++- .../FreeRTOS-Plus-Trace/trcKernelPort.c | 2 +- .../Source/FreeRTOS-Plus-Trace/trcUser.c | 17 ++++- 14 files changed, 181 insertions(+), 160 deletions(-) rename FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/{trcHooks.h => trcKernelHooks.h} (97%) diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/ConfigurationTemplate/trcConfig.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/ConfigurationTemplate/trcConfig.h index f016dbc86..f7d3ff044 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/ConfigurationTemplate/trcConfig.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/ConfigurationTemplate/trcConfig.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Tracealyzer v2.4.1 Recorder Library + * Tracealyzer v2.5.0 Recorder Library * Percepio AB, www.percepio.com * * trcConfig.h @@ -156,10 +156,9 @@ * check the actual usage in Tracealyzer. This is shown by selecting * View -> Trace Details -> Resource Usage -> Object Table * - * NOTE 2: Remember to account for all tasks created by the kernel, such as the - * IDLE task, timer task, and any tasks created by other 3rd party - * software components, such as communication stacks. The recorder also has an - * optional monitor task to account for, if this is used. + * NOTE 2: Remember to account for all tasks and other objects created by + * the kernel, such as the IDLE task, any timer tasks, and any tasks created + * by other 3rd party software components, such as communication stacks. * Moreover, one task slot is used to indicate "(startup)", i.e., a fictive * task that represent the time before the scheduler starts. * NTask should thus be at least 2-3 slots larger than your application task count. @@ -167,9 +166,9 @@ ******************************************************************************/ #define NTask 15 #define NISR 5 -#define NQueue 5 -#define NSemaphore 5 -#define NMutex 5 +#define NQueue 10 +#define NSemaphore 10 +#define NMutex 10 /* Maximum object name length for each class (includes zero termination) */ #define NameLenTask 15 @@ -265,8 +264,8 @@ * much faster than a printf and can therefore be used in timing critical code. * See vTraceUserEvent() and vTracePrintF() in trcUser.h * - * Note that Tracealyzer Standard Edition or Professional Edition is required - * for User Events, they are not displayed in Tracealyzer Free Edition. + * Note that Tracealyzer Professional Edition is required for User Events, + * they are not displayed in Tracealyzer Free Edition. *****************************************************************************/ #define INCLUDE_USER_EVENTS 1 @@ -441,60 +440,6 @@ #define INCLUDE_SAVE_TO_FILE 0 #endif -/****************************************************************************** - * TRACE_PROGRESS_MONITOR_TASK_PRIORITY - * - * Macro which sets the priority of the "recorder status monitor" task. - * - * This task, vTraceMonitorTask in trcUser.c, periodically writes - * the recorder status using the vTraceConsoleMessage macro, which is to - * be mapped to your console "printf" routine. The task is named TraceMon but - * is intentionally excluded from the demo trace. - * - * Default is tskIDLE_PRIORITY + 1 - * Note that if your system constantly has a high CPU load from high-priority - * tasks, this might not be get a chance to execute. - * - * See vTraceMonitorTask in trcUser.c - *****************************************************************************/ -#define TRACE_PROGRESS_MONITOR_TASK_PRIORITY (tskIDLE_PRIORITY + 1) - -/****************************************************************************** - * TRACE_PROGRESS_MONITOR_TASK_STACKSIZE - * - * Macro which sets the stack size of the "recorder status monitor" task. - * - * This task, vTraceMonitorTask in trcUser.c, periodically writes - * the recorder status using the vTraceConsoleMessage macro, which is to - * be mapped to your console "printf" routine. The task is intentionally - * excluded from the demo trace. - * - * See vTraceMonitorTask in trcUser.c - *****************************************************************************/ -#define TRACE_PROGRESS_MONITOR_TASK_STACKSIZE 500 - -/****************************************************************************** - * TRACE_PROGRESS_MONITOR_TASK_PERIOD - * - * Macro which sets the period of the "recorder status monitor" task. - * - * This task, vTraceMonitorTask in trcUser.c, periodically writes - * the recorder status using the vTraceConsoleMessage macro, which is to - * be mapped to your console "printf" routine. The task is named TraceMon but - * is intentionally excluded from the demo trace. - * - * Default is 1000 ticks (typically 1 second). On the Windows port, a lower - * value is suggested since the Windows port runs very slowly, often 20-40 - * times slower than the simulated time. - * - * See vTraceMonitorTask in trcUser.c - *****************************************************************************/ -#ifdef WIN32 - #define TRACE_PROGRESS_MONITOR_TASK_PERIOD 100 -#else - #define TRACE_PROGRESS_MONITOR_TASK_PERIOD 1000 -#endif - /****************************************************************************** * TEAM_LICENSE_CODE * diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/ConfigurationTemplate/trcHardwarePort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/ConfigurationTemplate/trcHardwarePort.h index 0b6ccab54..993882b17 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/ConfigurationTemplate/trcHardwarePort.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/ConfigurationTemplate/trcHardwarePort.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Tracealyzer v2.4.1 Recorder Library + * Tracealyzer v2.5.0 Recorder Library * Percepio AB, www.percepio.com * * trcHardwarePort.h @@ -77,8 +77,8 @@ * 1 ms get an execution time of zero. * * PORT_Win32 - * "Accurate" timestamping based on the Windows performance counter. Note that - * this gives the host machine time. + * "Accurate" timestamping based on the Windows performance counter for Win32 builds. + * Note that this gives the host machine time, not the kernel time. * * Officially supported hardware timer ports: * - PORT_Atmel_AT91SAM7 @@ -227,24 +227,25 @@ #define IRQ_PRIORITY_ORDER 1 // Please update according to your hardware... #elif (SELECTED_PORT == PORT_Atmel_AT91SAM7) +#error HWTC_PERIOD must point to the reload register! Not verified for this hardware port! /* HWTC_PERIOD is hardcoded for AT91SAM7X256-EK Board (48 MHz) A more generic solution is to get the period from pxPIT->PITC_PIMR */ #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING #define HWTC_COUNT (AT91C_BASE_PITC->PITC_PIIR & 0xFFFFF) - #define HWTC_PERIOD 2995 + #define HWTC_PERIOD (AT91C_BASE_PITC->PITC_PIMR + 1) #define HWTC_DIVISOR 1 #define IRQ_PRIORITY_ORDER 1 // higher IRQ priority values are more significant -#elif (SELECTED_PORT == PORT_Atmel_UC3A0) +#elif (SELECTED_PORT == PORT_Atmel_UC3A0) +#error HWTC_PERIOD must point to the reload register! Not yet updated for this hardware port! /* For Atmel AVR32 (AT32UC3A) */ - #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING #define HWTC_COUNT sysreg_read(AVR32_COUNT) - #define HWTC_PERIOD ( TRACE_CPU_CLOCK_HZ / TRACE_TICK_RATE_HZ ) + #define HWTC_PERIOD #define HWTC_DIVISOR 1 #define IRQ_PRIORITY_ORDER 1 // higher IRQ priority values are more significant @@ -266,12 +267,12 @@ #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING #define HWTC_COUNT (CMT0.CMCNT) - #define HWTC_PERIOD ((((TRACE_PERIPHERAL_CLOCK_HZ/TRACE_TICK_RATE_HZ)-1)/8)) + #define HWTC_PERIOD (CMT0.CMCOR + 1) #define HWTC_DIVISOR 1 #define IRQ_PRIORITY_ORDER 1 // higher IRQ priority values are more significant -#elif (SELECTED_PORT == PORT_Microchip_dsPIC_AND_PIC24) +#elif (SELECTED_PORT == PORT_Microchip_dsPIC_AND_PIC24) /* For Microchip PIC24 and dsPIC (16 bit) */ @@ -289,18 +290,20 @@ #define IRQ_PRIORITY_ORDER 0 // lower IRQ priority values are more significant #elif (SELECTED_PORT == PORT_NXP_LPC210X) +#error HWTC_PERIOD must point to the reload register! Not yet updated for this hardware port! /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */ /* Tested with LPC2106, but should work with most LPC21XX chips. */ #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING #define HWTC_COUNT *((uint32_t *)0xE0004008 ) - #define HWTC_PERIOD ( TRACE_CPU_CLOCK_HZ / TRACE_TICK_RATE_HZ ) + #define HWTC_PERIOD #define HWTC_DIVISOR 1 #define IRQ_PRIORITY_ORDER 0 // lower IRQ priority values are more significant #elif (SELECTED_PORT == PORT_TEXAS_INSTRUMENTS_TMS570) +#error HWTC_PERIOD must point to the reload register! Not verified for this hardware port! /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */ #define RTIFRC0 *((uint32_t *)0xFFFFFC10) @@ -314,6 +317,7 @@ #define IRQ_PRIORITY_ORDER 0 // lower IRQ priority values are more significant #elif (SELECTED_PORT == PORT_TEXAS_INSTRUMENTS_MSP430) +#error HWTC_PERIOD must point to the reload register! Not verified for this hardware port! /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */ #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING @@ -333,29 +337,32 @@ #define IRQ_PRIORITY_ORDER 0 // lower IRQ priority values are more significant -#elif (SELECTED_PORT == PORT_XILINX_PPC405) +#elif (SELECTED_PORT == PORT_XILINX_PPC405) +#error HWTC_PERIOD must point to the reload register! Not verified for this hardware port! /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */ #define HWTC_COUNT_DIRECTION DIRECTION_DECREMENTING #define HWTC_COUNT mfspr( 0x3db) - #define HWTC_PERIOD ( TRACE_CPU_CLOCK_HZ / TRACE_TICK_RATE_HZ ) + #define HWTC_PERIOD #define HWTC_DIVISOR 1 #define IRQ_PRIORITY_ORDER 0 // lower IRQ priority values are more significant -#elif (SELECTED_PORT == PORT_XILINX_PPC440) +#elif (SELECTED_PORT == PORT_XILINX_PPC440) +#error HWTC_PERIOD must point to the reload register! Not verified for this hardware port! /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */ /* This should work with most PowerPC chips */ #define HWTC_COUNT_DIRECTION DIRECTION_DECREMENTING #define HWTC_COUNT mfspr( 0x016 ) - #define HWTC_PERIOD ( TRACE_CPU_CLOCK_HZ / TRACE_TICK_RATE_HZ ) + #define HWTC_PERIOD #define HWTC_DIVISOR 1 #define IRQ_PRIORITY_ORDER 0 // lower IRQ priority values are more significant #elif (SELECTED_PORT == PORT_XILINX_MICROBLAZE) +#error HWTC_PERIOD must point to the reload register! Not verified for this hardware port! /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */ /* This should work with most Microblaze configurations. @@ -366,7 +373,7 @@ #define HWTC_COUNT_DIRECTION DIRECTION_DECREMENTING #define HWTC_COUNT XTmrCtr_GetTimerCounterReg( XPAR_TMRCTR_0_BASEADDR, 0 ) - #define HWTC_PERIOD ( TRACE_CPU_CLOCK_HZ / TRACE_TICK_RATE_HZ ) + #define HWTC_PERIOD #define HWTC_DIVISOR 16 #define IRQ_PRIORITY_ORDER 0 // lower IRQ priority values are more significant @@ -451,32 +458,4 @@ void vTracePortGetTimeStamp(uint32_t *puiTimestamp); ******************************************************************************/ void vTracePortEnd(void); -#if (INCLUDE_SAVE_TO_FILE == 1) - -/******************************************************************************* - * vTracePortSetOutFile - * - * Sets the filename/path used in vTracePortSave. - * This is set in a separate function, since the Win32 port calls vTracePortSave - * in vTracePortEnd if WIN32_PORT_SAVE_WHEN_STOPPED is set. - ******************************************************************************/ -void vTracePortSetOutFile(char* path); - -/****************************************************************************** - * vTracePortSave - * - * Saves the trace to a file on a target-side file system. The path is set in a - * separate function, vTracePortSetOutFile, since the Win32 port may call - * vTracePortSave in vTracePortEnd, if using WIN32_PORT_SAVE_WHEN_STOPPED. - ******************************************************************************/ -void vTracePortSave(void); - -#else - -#define vTraceConsoleMessage(x) -#define vTracePortSetOutFile(path) -#define vTracePortSave(void) - -#endif - #endif diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcBase.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcBase.h index 9196f73d2..e48dc88ec 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcBase.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcBase.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Tracealyzer v2.4.1 Recorder Library + * Tracealyzer v2.5.0 Recorder Library * Percepio AB, www.percepio.com * * trcBase.h @@ -183,11 +183,18 @@ typedef struct uint16_t dts; /* differential timestamp - time since last event */ } TSEvent, TREvent; +typedef struct +{ + uint8_t type; + uint8_t dummy; + uint16_t dts; /* differential timestamp - time since last event */ +} LPEvent; + typedef struct { uint8_t type; uint8_t objHandle; - uint16_t dts; + uint16_t dts; /* differential timestamp - time since last event */ } KernelCall; typedef struct @@ -195,13 +202,13 @@ typedef struct uint8_t type; objectHandleType objHandle; uint8_t param; - uint8_t dts; + uint8_t dts; /* differential timestamp - time since last event */ } KernelCallWithParamAndHandle; typedef struct { uint8_t type; - uint8_t dts; + uint8_t dts; /* differential timestamp - time since last event */ uint16_t param; } KernelCallWithParam16; @@ -449,14 +456,6 @@ uint16_t uiIndexOfObject(objectHandleType objecthandle, ******************************************************************************/ void vTraceError(const char* msg); -/******************************************************************************* - * xTraceGetLastError - * - * Gives the last error message, if any. NULL if no error message is stored. - * The message is cleared on read. - ******************************************************************************/ -char* xTraceGetLastError(void); - /******************************************************************************* * prvTraceInitTraceData * diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernel.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernel.h index 709e128c9..4c8bdd509 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernel.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernel.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Tracealyzer v2.4.1 Recorder Library + * Tracealyzer v2.5.0 Recorder Library * Percepio AB, www.percepio.com * * trcKernel.h @@ -48,6 +48,8 @@ void vTraceStoreTaskReady(objectHandleType handle); #endif +void vTraceStoreLowPower(uint32_t flag); + void vTraceStoreTaskswitch(objectHandleType task_handle); void vTraceStoreKernelCall(uint32_t eventcode, traceObjectClass objectClass, uint32_t byteParam); diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcHooks.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelHooks.h similarity index 97% rename from FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcHooks.h rename to FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelHooks.h index 66c381406..69431ee95 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcHooks.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelHooks.h @@ -1,5 +1,5 @@ /******************************************************************************* -* Tracealyzer v2.4.1 Recorder Library +* Tracealyzer v2.5.0 Recorder Library * Percepio AB, www.percepio.com * * trcKernelHooks.h diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelPort.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelPort.h index 009c3c9e4..a775883b2 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelPort.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelPort.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Tracealyzer v2.4.1 Recorder Library + * Tracealyzer v2.5.0 Recorder Library * Percepio AB, www.percepio.com * * trcKernelPort.h @@ -47,10 +47,7 @@ /* Defines that must be set for the recorder to work properly */ #define TRACE_KERNEL_VERSION 0x1AA1 -#define TRACE_CPU_CLOCK_HZ configCPU_CLOCK_HZ /* Defined in "FreeRTOS.h" */ -#define TRACE_PERIPHERAL_CLOCK_HZ configPERIPHERAL_CLOCK_HZ /* Defined in "FreeRTOS.h" */ #define TRACE_TICK_RATE_HZ configTICK_RATE_HZ /* Defined in "FreeRTOS.h" */ -#define TRACE_CPU_CLOCKS_PER_TICK configCPU_CLOCKS_PER_TICK /* Defined in "FreeRTOS.h" */ /************************************************************************/ /* KERNEL SPECIFIC OBJECT CONFIGURATION */ @@ -99,12 +96,16 @@ /* Includes */ #include "trcTypes.h" #include "trcConfig.h" -#include "trcHooks.h" +#include "trcKernelHooks.h" #include "trcHardwarePort.h" #include "trcBase.h" #include "trcKernel.h" #include "trcUser.h" +#if (INCLUDE_NEW_TIME_EVENTS == 1 && configUSE_TICKLESS_IDLE != 0) +#error "NewTime events can not be used in combination with tickless idle!" +#endif + /* Initialization of the object property table */ void vTraceInitObjectPropertyTable(void); @@ -296,6 +297,9 @@ const char* pszTraceGetErrorNotEnoughHandles(traceObjectClass objectclass); #define RESERVED_DUMMY_CODE (EVENTGROUP_SYS + 3) /*0xAB*/ +#define LOW_POWER_BEGIN (EVENTGROUP_SYS + 4) /*0xAC*/ +#define LOW_POWER_END (EVENTGROUP_SYS + 5) /*0xAD*/ + /************************************************************************/ @@ -360,12 +364,34 @@ void* prvTraceGetCurrentTaskHandle(void); #define TRACE_GET_OBJECT_EVENT_CODE(SERVICE, RESULT, CLASS, pxObject) (uint8_t)(EVENTGROUP_##SERVICE##_##RESULT + TRACE_GET_OBJECT_TRACE_CLASS(CLASS, pxObject)) #define TRACE_GET_TASK_EVENT_CODE(SERVICE, RESULT, CLASS, pxTCB) (EVENTGROUP_##SERVICE##_##RESULT + TRACE_CLASS_TASK) - - /************************************************************************/ /* KERNEL SPECIFIC WRAPPERS THAT SHOULD BE CALLED BY THE KERNEL */ /************************************************************************/ +#if (configUSE_TICKLESS_IDLE != 0) + +#undef traceLOW_POWER_IDLE_BEGIN +#define traceLOW_POWER_IDLE_BEGIN() \ + { \ + extern uint32_t trace_disable_timestamp; \ + vTraceStoreLowPower(0); \ + trace_disable_timestamp = 1; \ + } + +#undef traceLOW_POWER_IDLE_END +#define traceLOW_POWER_IDLE_END() \ + { \ + extern uint32_t trace_disable_timestamp; \ + trace_disable_timestamp = 0; \ + vTraceStoreLowPower(1); \ + } + +/* A macro that will update the tick count when returning from tickless idle */ +#undef traceINCREASE_TICK_COUNT( xCount ) +#define traceINCREASE_TICK_COUNT( xCount ) { extern uint32_t uiTraceTickCount; uiTraceTickCount += xTickCount; } + +#endif + /* Called for each task that becomes ready */ #undef traceMOVED_TASK_TO_READY_STATE #define traceMOVED_TASK_TO_READY_STATE( pxTCB ) \ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcTypes.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcTypes.h index a01791216..e60b34ab9 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcTypes.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcTypes.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Tracealyzer v2.4.1 Recorder Library + * Tracealyzer v2.5.0 Recorder Library * Percepio AB, www.percepio.com * * trcTypes.h diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcUser.h b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcUser.h index 273e87074..c6904008b 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcUser.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcUser.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Tracealyzer v2.4.1 Recorder Library + * Tracealyzer v2.5.0 Recorder Library * Percepio AB, www.percepio.com * * trcUser.h @@ -109,18 +109,6 @@ uint32_t uiTraceStart(void); ******************************************************************************/ void vTraceStart(void); -/******************************************************************************* - * vTraceStartStatusMonitor - * - * This starts a task to monitor the status of the recorder module. - * This task periodically prints a line to the console window, which shows the - * recorder status, the number of events recorded and the latest timestamp. - * This task calls vTracePortEnd (trcHardwarePort.c) when it detects that the - * recorder has been stopped. This allows for adding custom actions, e.g., to - * store the trace to a file in case a file system is available on the device. - ******************************************************************************/ -void vTraceStartStatusMonitor(void); - /******************************************************************************* * vTraceStop * @@ -129,6 +117,14 @@ void vTraceStartStatusMonitor(void); ******************************************************************************/ void vTraceStop(void); +/******************************************************************************* + * xTraceGetLastError + * + * Gives the last error message, if any. NULL if no error message is stored. + * Any error message is also presented when opening a trace file. + ******************************************************************************/ +char* xTraceGetLastError(void); + /******************************************************************************* * vTraceClear * @@ -137,6 +133,16 @@ void vTraceStop(void); ******************************************************************************/ void vTraceClear(void); +/******************************************************************************* +* vTraceClearError +* +* Removes any previous error message generated by recorder calling vTraceError. +* By calling this function, it may be possible to start/restart the trace +* despite errors in the recorder, but there is no guarantee that the trace +* recorder will work correctly in that case, depending on the type of error. +******************************************************************************/ +void vTraceClearError(int resetErrorMessage); + #if (INCLUDE_ISR_TRACING == 1) /******************************************************************************* diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/readme.txt b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/readme.txt index d8337b1a8..883f85ebb 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/readme.txt +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/readme.txt @@ -4,7 +4,7 @@ Tracealyzer Trace Recorder Library Percepio AB www.percepio.com -This directory contains the a generic trace recorder library for Tracealyzer v2.4. +This directory contains the a generic trace recorder library for Tracealyzer v2.5. For information on how to upload the trace data from your target system RAM to Tracealyzer, see "debugger trace upload.txt" diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcBase.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcBase.c index 67f34bc33..bfd6cb28c 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcBase.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcBase.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Tracealyzer v2.4.1 Recorder Library + * Tracealyzer v2.5.0 Recorder Library * Percepio AB, www.percepio.com * * trcBase.c @@ -54,6 +54,8 @@ uint8_t excludedEventCodes[NEventCodes / 8 + 1] = { 0 }; /* Keeps track of available handles */ objectHandleStackType objectHandleStacks = { { 0 }, { 0 }, { 0 }, { 0 }, { 0 } }; +uint32_t init_hwtc_count; + /******************************************************************************* * RecorderData * @@ -101,6 +103,8 @@ RecorderDataType* RecorderDataPtr = NULL; /* This version of the function dynamically allocates the trace data */ void prvTraceInitTraceData() { + init_hwtc_count = HWTC_COUNT; + #if TRACE_DATA_ALLOCATION == TRACE_DATA_ALLOCATION_STATIC RecorderDataPtr = &RecorderData; #elif TRACE_DATA_ALLOCATION == TRACE_DATA_ALLOCATION_DYNAMIC @@ -217,11 +221,9 @@ uint16_t uiIndexOfObject(objectHandleType objecthandle, uint8_t objectclass) TRACE_ASSERT(objectclass < TRACE_NCLASSES, "uiIndexOfObject: Invalid value for objectclass", 0); TRACE_ASSERT(objecthandle > 0 && objecthandle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass], "uiIndexOfObject: Invalid value for objecthandle", 0); - if ((objectclass < TRACE_NCLASSES) && (objecthandle > 0) && (objecthandle <= - RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass])) + if ((objectclass < TRACE_NCLASSES) && (objecthandle > 0) && (objecthandle <= RecorderDataPtr->ObjectPropertyTable.NumberOfObjectsPerClass[objectclass])) { - return (uint16_t)(RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[objectclass] + - (RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[objectclass] * (objecthandle-1))); + return (uint16_t)(RecorderDataPtr->ObjectPropertyTable.StartIndexOfClass[objectclass] + (RecorderDataPtr->ObjectPropertyTable.TotalPropertyBytesPerClass[objectclass] * (objecthandle-1))); } vTraceError("Object table lookup with invalid object handle or object class!"); @@ -554,23 +556,20 @@ uint16_t prvTraceGetDTS(uint16_t param_maxDTS) TRACE_ASSERT(param_maxDTS == 0xFF || param_maxDTS == 0xFFFF, "prvTraceGetDTS: Invalid value for param_maxDTS", 0); - if (RecorderDataPtr->frequency == 0) + if (RecorderDataPtr->frequency == 0 && init_hwtc_count != HWTC_COUNT) { /* If HWTC_PERIOD is mapped to the timer reload register, such as in the Cortex M port, it might not be initialized before the Kernel scheduler has been started has been - started. We therefore store the frequency of the timer at - the first timestamped event after the scheduler has started. - (Note that this function is called also by vTraceStart and - uiTraceStart, which might be called before the scheduler - has been started.) */ + started. We therefore store the frequency of the timer + once the counter register has changed. */ #if (SELECTED_PORT == PORT_Win32) RecorderDataPtr->frequency = 100000; #elif (SELECTED_PORT == PORT_HWIndependent) RecorderDataPtr->frequency = TRACE_TICK_RATE_HZ; #else - RecorderDataPtr->frequency = TRACE_CPU_CLOCK_HZ / (uint32_t)HWTC_DIVISOR; + RecorderDataPtr->frequency = (HWTC_PERIOD * TRACE_TICK_RATE_HZ) / (uint32_t)HWTC_DIVISOR; #endif } diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcHardwarePort.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcHardwarePort.c index 754b3211d..6570e3553 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcHardwarePort.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcHardwarePort.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Tracealyzer v2.4.1 Recorder Library + * Tracealyzer v2.5.0 Recorder Library * Percepio AB, www.percepio.com * * trcHardwarePort.c @@ -42,6 +42,8 @@ #include +uint32_t trace_disable_timestamp = 0; +uint32_t last_timestamp = 0; /******************************************************************************* * uiTraceTickCount @@ -71,6 +73,13 @@ void vTracePortGetTimeStamp(uint32_t *pTimestamp) uint32_t traceTickCount = 0; uint32_t hwtc_count = 0; + if (trace_disable_timestamp == 1) + { + if (pTimestamp) + *pTimestamp = last_timestamp; + return; + } + /* Retrieve HWTC_COUNT only once since the same value should be used all throughout this function. */ #if (HWTC_COUNT_DIRECTION == DIRECTION_INCREMENTING) hwtc_count = HWTC_COUNT; @@ -109,6 +118,8 @@ void vTracePortGetTimeStamp(uint32_t *pTimestamp) *pTimestamp = traceTickCount * (HWTC_PERIOD / HWTC_DIVISOR); /* Increase timestamp by (hwtc_count + "lost hardware ticks from scaling down period") / HWTC_DIVISOR. */ *pTimestamp += (hwtc_count + traceTickCount * (HWTC_PERIOD % HWTC_DIVISOR)) / HWTC_DIVISOR; + + last_timestamp = *pTimestamp; } /* Store the previous values. */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernel.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernel.c index b18e2d840..78334daa3 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernel.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernel.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Tracealyzer v2.4.1 Recorder Library + * Tracealyzer v2.5.0 Recorder Library * Percepio AB, www.percepio.com * * trcKernel.c @@ -96,6 +96,47 @@ void vTraceStoreTaskReady(objectHandleType handle) } #endif +/******************************************************************************* + * vTraceStoreLowPower + * + * This function stores a low power state. + ******************************************************************************/ +void vTraceStoreLowPower(uint32_t flag) +{ + uint16_t dts; + LPEvent* lp; + + TRACE_ASSERT(flag <= 1, "vTraceStoreLowPower: Invalid flag value", ); + + if (recorder_busy) + { + /*********************************************************************** + * This should never occur, as the tick- and kernel call ISR is on lowest + * interrupt priority and always are disabled during the critical sections + * of the recorder. + ***********************************************************************/ + + vTraceError("Recorder busy - high priority ISR using syscall? (1)"); + return; + } + + if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */ + { + dts = (uint16_t)prvTraceGetDTS(0xFFFF); + if (RecorderDataPtr->recorderActive) /* Need to repeat this check! */ + { + lp = (LPEvent*)xTraceNextFreeEventBufferSlot(); + if (lp != NULL) + { + lp->type = LOW_POWER_BEGIN + flag; /* BEGIN or END depending on flag */ + lp->dts = dts; + + prvTraceUpdateCounters(); + } + } + } +} + /******************************************************************************* * vTraceStoreKernelCall * diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernelPort.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernelPort.c index 427d770e2..610b3b39c 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernelPort.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernelPort.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Tracealyzer v2.4.1 Recorder Library + * Tracealyzer v2.5.0 Recorder Library * Percepio AB, www.percepio.com * * trcKernelPort.c diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcUser.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcUser.c index 114ac1ec7..6cf8c1f9c 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcUser.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcUser.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Tracealyzer v2.4.1 Recorder Library + * Tracealyzer v2.5.0 Recorder Library * Percepio AB, www.percepio.com * * trcUser.c @@ -191,7 +191,6 @@ void vTraceStop(void) * xTraceGetLastError * * Gives the last error message, if any. NULL if no error message is stored. - * The message is cleared on read. * Any error message is also presented when opening a trace file. ******************************************************************************/ char* xTraceGetLastError(void) @@ -199,6 +198,20 @@ char* xTraceGetLastError(void) return traceErrorMessage; } +/******************************************************************************* +* vTraceClearError +* +* Removes any previous error message generated by recorder calling vTraceError. +* By calling this function, it may be possible to start/restart the trace +* despite errors in the recorder, but there is no guarantee that the trace +* recorder will work correctly in that case, depending on the type of error. +******************************************************************************/ +void vTraceClearError(int resetErrorMessage) +{ + traceErrorMessage = NULL; + RecorderDataPtr->internalErrorOccured = 0; +} + /******************************************************************************* * vTraceGetTraceBuffer * -- 2.39.5