1 /* 2 * Trace Recorder for Tracealyzer v4.5.1 3 * Copyright 2021 Percepio AB 4 * www.percepio.com 5 * 6 * SPDX-License-Identifier: Apache-2.0 7 * 8 * Main configuration parameters for the trace recorder library. 9 * More settings can be found in trcStreamingConfig.h and trcSnapshotConfig.h. 10 */ 11 12 #ifndef TRC_CONFIG_H 13 #define TRC_CONFIG_H 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 #define TRC_CFG_USE_TRACE_FACILITY 1 20 21 #include "trcPortDefines.h" 22 23 /****************************************************************************** 24 * Include of processor header file 25 * 26 * Here you may need to include the header file for your processor. This is 27 * required at least for the ARM Cortex-M port, that uses the ARM CMSIS API. 28 * Try that in case of build problems. Otherwise, remove the #error line below. 29 *****************************************************************************/ 30 //#error "Trace Recorder: Please include your processor's header file here and remove this line." 31 32 /******************************************************************************* 33 * Configuration Macro: TRC_CFG_HARDWARE_PORT 34 * 35 * Specify what hardware port to use (i.e., the "timestamping driver"). 36 * 37 * All ARM Cortex-M MCUs are supported by "TRC_HARDWARE_PORT_ARM_Cortex_M". 38 * This port uses the DWT cycle counter for Cortex-M3/M4/M7 devices, which is 39 * available on most such devices. In case your device don't have DWT support, 40 * you will get an error message opening the trace. In that case, you may 41 * force the recorder to use SysTick timestamping instead, using this define: 42 * 43 * #define TRC_CFG_ARM_CM_USE_SYSTICK 44 * 45 * For ARM Cortex-M0/M0+ devices, SysTick mode is used automatically. 46 * 47 * See trcHardwarePort.h for available ports and information on how to 48 * define your own port, if not already present. 49 ******************************************************************************/ 50 #define TRC_CFG_HARDWARE_PORT TRC_HARDWARE_PORT_Win32 51 52 /******************************************************************************* 53 * Configuration Macro: TRC_CFG_RECORDER_MODE 54 * 55 * Specify what recording mode to use. Snapshot means that the data is saved in 56 * an internal RAM buffer, for later upload. Streaming means that the data is 57 * transferred continuously to the host PC. 58 * 59 * For more information, see http://percepio.com/2016/10/05/rtos-tracing/ 60 * and the Tracealyzer User Manual. 61 * 62 * Values: 63 * TRC_RECORDER_MODE_SNAPSHOT 64 * TRC_RECORDER_MODE_STREAMING 65 ******************************************************************************/ 66 #define TRC_CFG_RECORDER_MODE TRC_RECORDER_MODE_SNAPSHOT 67 68 /****************************************************************************** 69 * TRC_CFG_INCLUDE_USER_EVENTS 70 * 71 * Macro which should be defined as either zero (0) or one (1). 72 * 73 * If this is zero (0), all code related to User Events is excluded in order 74 * to reduce code size. Any attempts of storing User Events are then silently 75 * ignored. 76 * 77 * User Events are application-generated events, like "printf" but for the 78 * trace log, generated using vTracePrint and vTracePrintF. 79 * The formatting is done on host-side, by Tracealyzer. User Events are 80 * therefore much faster than a console printf and can often be used 81 * in timing critical code without problems. 82 * 83 * Note: In streaming mode, User Events are used to provide error messages 84 * and warnings from the recorder (in case of incorrect configuration) for 85 * display in Tracealyzer. Disabling user events will also disable these 86 * warnings. You can however still catch them by calling xTraceGetLastError 87 * or by putting breakpoints in prvTraceError and prvTraceWarning. 88 * 89 * Default value is 1. 90 *****************************************************************************/ 91 #define TRC_CFG_INCLUDE_USER_EVENTS 1 92 93 /***************************************************************************** 94 * TRC_CFG_INCLUDE_ISR_TRACING 95 * 96 * Macro which should be defined as either zero (0) or one (1). 97 * 98 * If this is zero (0), the code for recording Interrupt Service Routines is 99 * excluded, in order to reduce code size. This means that any calls to 100 * vTraceStoreISRBegin/vTraceStoreISREnd will be ignored. 101 * This does not completely disable ISR tracing, in cases where an ISR is 102 * calling a traced kernel service. These events will still be recorded and 103 * show up in anonymous ISR instances in Tracealyzer, with names such as 104 * "ISR sending to <queue name>". 105 * To disable such tracing, please refer to vTraceSetFilterGroup and 106 * vTraceSetFilterMask. 107 * 108 * Default value is 1. 109 * 110 * Note: tracing ISRs requires that you insert calls to vTraceStoreISRBegin 111 * and vTraceStoreISREnd in your interrupt handlers. 112 *****************************************************************************/ 113 #define TRC_CFG_INCLUDE_ISR_TRACING 1 114 115 /***************************************************************************** 116 * TRC_CFG_INCLUDE_OSTICK_EVENTS 117 * 118 * Macro which should be defined as either zero (0) or one (1). 119 * 120 * If this is one (1), events will be generated whenever the OS clock is 121 * increased. If zero (0), OS tick events are not generated, which allows for 122 * recording longer traces in the same amount of RAM. 123 * 124 * Default value is 1. 125 *****************************************************************************/ 126 #define TRC_CFG_INCLUDE_OSTICK_EVENTS 1 127 128 /****************************************************************************** 129 * TRC_CFG_ENABLE_STACK_MONITOR 130 * 131 * If enabled (1), the recorder periodically reports the unused stack space of 132 * all active tasks. 133 * The stack monitoring runs in the Tracealyzer Control task, TzCtrl. This task 134 * is always created by the recorder when in streaming mode. 135 * In snapshot mode, the TzCtrl task is only used for stack monitoring and is 136 * not created unless this is enabled. 137 *****************************************************************************/ 138 #define TRC_CFG_ENABLE_STACK_MONITOR 1 139 140 /****************************************************************************** 141 * TRC_CFG_STACK_MONITOR_MAX_TASKS 142 * 143 * Macro which should be defined as a non-zero integer value. 144 * 145 * This controls how many tasks that can be monitored by the stack monitor. 146 * If this is too small, some tasks will be excluded and a warning is shown. 147 * 148 * Default value is 10. 149 *****************************************************************************/ 150 #define TRC_CFG_STACK_MONITOR_MAX_TASKS 20 151 152 /****************************************************************************** 153 * TRC_CFG_STACK_MONITOR_MAX_REPORTS 154 * 155 * Macro which should be defined as a non-zero integer value. 156 * 157 * This defines how many tasks that will be subject to stack usage analysis for 158 * each execution of the Tracealyzer Control task (TzCtrl). Note that the stack 159 * monitoring cycles between the tasks, so this does not affect WHICH tasks that 160 * are monitored, but HOW OFTEN each task stack is analyzed. 161 * 162 * This setting can be combined with TRC_CFG_CTRL_TASK_DELAY to tune the 163 * frequency of the stack monitoring. This is motivated since the stack analysis 164 * can take some time to execute. 165 * However, note that the stack analysis runs in a separate task (TzCtrl) that 166 * can be executed on low priority. This way, you can avoid that the stack 167 * analysis disturbs any time-sensitive tasks. 168 * 169 * Default value is 1. 170 *****************************************************************************/ 171 #define TRC_CFG_STACK_MONITOR_MAX_REPORTS 10 172 173 /******************************************************************************* 174 * Configuration Macro: TRC_CFG_CTRL_TASK_PRIORITY 175 * 176 * The scheduling priority of the Tracealyzer Control (TzCtrl) task. 177 * 178 * In streaming mode, TzCtrl is used to receive start/stop commands from 179 * Tracealyzer and in some cases also to transmit the trace data (for stream 180 * ports that uses the internal buffer, like TCP/IP). For such stream ports, 181 * make sure the TzCtrl priority is high enough to ensure reliable periodic 182 * execution and transfer of the data, but low enough to avoid disturbing any 183 * time-sensitive functions. 184 * 185 * In Snapshot mode, TzCtrl is only used for the stack usage monitoring and is 186 * not created if stack monitoring is disabled. TRC_CFG_CTRL_TASK_PRIORITY should 187 * be low, to avoid disturbing any time-sensitive tasks. 188 ******************************************************************************/ 189 #define TRC_CFG_CTRL_TASK_PRIORITY 1 190 191 /******************************************************************************* 192 * Configuration Macro: TRC_CFG_CTRL_TASK_DELAY 193 * 194 * The delay between loops of the TzCtrl task (see TRC_CFG_CTRL_TASK_PRIORITY), 195 * which affects the frequency of the stack monitoring. 196 * 197 * In streaming mode, this also affects the trace data transfer if you are using 198 * a stream port leveraging the internal buffer (like TCP/IP). A shorter delay 199 * increases the CPU load of TzCtrl somewhat, but may improve the performance of 200 * of the trace streaming, especially if the trace buffer is small. 201 ******************************************************************************/ 202 #define TRC_CFG_CTRL_TASK_DELAY 2 203 204 /******************************************************************************* 205 * Configuration Macro: TRC_CFG_CTRL_TASK_STACK_SIZE 206 * 207 * The stack size of the Tracealyzer Control (TzCtrl) task. 208 * See TRC_CFG_CTRL_TASK_PRIORITY for further information about TzCtrl. 209 ******************************************************************************/ 210 #define TRC_CFG_CTRL_TASK_STACK_SIZE (configMINIMAL_STACK_SIZE * 2) 211 212 /******************************************************************************* 213 * Configuration Macro: TRC_CFG_RECORDER_BUFFER_ALLOCATION 214 * 215 * Specifies how the recorder buffer is allocated (also in case of streaming, in 216 * port using the recorder's internal temporary buffer) 217 * 218 * Values: 219 * TRC_RECORDER_BUFFER_ALLOCATION_STATIC - Static allocation (internal) 220 * TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC - Malloc in vTraceEnable 221 * TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM - Use vTraceSetRecorderDataBuffer 222 * 223 * Static and dynamic mode does the allocation for you, either in compile time 224 * (static) or in runtime (malloc). 225 * The custom mode allows you to control how and where the allocation is made, 226 * for details see TRC_ALLOC_CUSTOM_BUFFER and vTraceSetRecorderDataBuffer(). 227 ******************************************************************************/ 228 #define TRC_CFG_RECORDER_BUFFER_ALLOCATION TRC_RECORDER_BUFFER_ALLOCATION_STATIC 229 230 /****************************************************************************** 231 * TRC_CFG_MAX_ISR_NESTING 232 * 233 * Defines how many levels of interrupt nesting the recorder can handle, in 234 * case multiple ISRs are traced and ISR nesting is possible. If this 235 * is exceeded, the particular ISR will not be traced and the recorder then 236 * logs an error message. This setting is used to allocate an internal stack 237 * for keeping track of the previous execution context (4 byte per entry). 238 * 239 * This value must be a non-zero positive constant, at least 1. 240 * 241 * Default value: 8 242 *****************************************************************************/ 243 #define TRC_CFG_MAX_ISR_NESTING 8 244 245 /****************************************************************************** 246 * TRC_CFG_ACKNOWLEDGE_QUEUE_SET_SEND 247 * 248 * When using FreeRTOS v10.3.0 or v10.3.1, please make sure that the trace 249 * point in prvNotifyQueueSetContainer() in queue.c is renamed from 250 * traceQUEUE_SEND to traceQUEUE_SET_SEND in order to tell them apart from 251 * other traceQUEUE_SEND trace points. Then set this to TRC_ACKNOWLEDGED. 252 *****************************************************************************/ 253 #define TRC_CFG_ACKNOWLEDGE_QUEUE_SET_SEND TRC_ACKNOWLEDGED 254 255 /* Specific configuration, depending on Streaming/Snapshot mode */ 256 #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT) 257 #include "trcSnapshotConfig.h" 258 #elif (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING) 259 #include "trcStreamingConfig.h" 260 #endif 261 262 #ifdef __cplusplus 263 } 264 #endif 265 266 #endif /* _TRC_CONFIG_H */ 267