# Copyright (c) 2021 Percepio AB # SPDX-License-Identifier: Apache-2.0 config PERCEPIO_TRC_CFG_RECORDER_RTOS_FREERTOS bool default n config PERCEPIO_TRC_CFG_RECORDER_RTOS_THREADX bool default n config PERCEPIO_TRC_CFG_RECORDER_RTOS_ZEPHYR bool default n config PERCEPIO_TRC_CFG_RECORDER_RTOS_BAREMETAL bool default n choice PERCEPIO_TRC_CFG_START_MODE prompt "Recorder Start Mode" default PERCEPIO_TRC_START_MODE_START_FROM_HOST help TRC_START: Starts the tracing directly. In snapshot mode this allows for starting the trace at any point in your code, assuming vTraceEnable(TRC_INIT) has been called in the startup. Can also be used for streaming without Tracealyzer control, e.g. to a local flash file system (assuming such a "stream port", see trcStreamingPort.h). TRC_START_AWAIT_HOST: For streaming mode only. Initializes the trace recorder if necessary and waits for a Start command from Tracealyzer ("Start Recording" button). This call is intentionally blocking! By calling vTraceEnable with this option from the startup code, you start tracing at this point and capture the early events. TRC_START_FROM_HOST: Initializes the trace recorder, but does not start the tracing. In snapshot mode, this must be followed by a vTraceEnable(TRC_START) sometime later. config PERCEPIO_TRC_START_MODE_START bool "Start" config PERCEPIO_TRC_START_MODE_START_AWAIT_HOST bool "Start Await Host" depends on PERCEPIO_TRC_RECORDER_MODE_STREAMING && !PERCEPIO_TRC_CFG_STREAM_PORT_RINGBUFFER config PERCEPIO_TRC_START_MODE_START_FROM_HOST bool "Start From Host" depends on PERCEPIO_TRC_RECORDER_MODE_STREAMING && !PERCEPIO_TRC_CFG_STREAM_PORT_RINGBUFFER endchoice choice PERCEPIO_TRC_CFG_STREAM_PORT prompt "Stream Port" depends on PERCEPIO_TRC_RECORDER_MODE_STREAMING default PERCEPIO_TRC_CFG_STREAM_PORT_RTT config PERCEPIO_TRC_CFG_STREAM_PORT_RTT bool "RTT" depends on (ARM && PERCEPIO_TRC_CFG_RECORDER_RTOS_ZEPHYR) || \ PERCEPIO_TRC_CFG_RECORDER_RTOS_THREADX || \ PERCEPIO_TRC_CFG_RECORDER_RTOS_FREERTOS select USE_SEGGER_RTT if PERCEPIO_TRC_CFG_RECORDER_RTOS_ZEPHYR config PERCEPIO_TRC_CFG_STREAM_PORT_ITM bool "ITM" depends on (ARM && PERCEPIO_TRC_CFG_RECORDER_RTOS_ZEPHYR) || \ PERCEPIO_TRC_CFG_RECORDER_RTOS_THREADX || \ PERCEPIO_TRC_CFG_RECORDER_RTOS_FREERTOS config PERCEPIO_TRC_CFG_STREAM_PORT_RINGBUFFER bool "Ring Buffer" config PERCEPIO_TRC_CFG_STREAM_PORT_FILE bool "File" config PERCEPIO_TRC_CFG_STREAM_PORT_TCPIP bool "TCP/IP" depends on !PERCEPIO_TRC_CFG_RECORDER_RTOS_ZEPHYR config PERCEPIO_TRC_CFG_STREAM_PORT_STM32_USB_CDC bool "STM32 USB CDC" depends on !PERCEPIO_TRC_CFG_RECORDER_RTOS_ZEPHYR config PERCEPIO_TRC_CFG_STREAM_PORT_ZEPHYR_SEMIHOST bool "Semihost" depends on PERCEPIO_TRC_CFG_RECORDER_RTOS_ZEPHYR && \ QEMU_TARGET && SEMIHOST endchoice if PERCEPIO_TRC_CFG_STREAM_PORT_RTT rsource "../streamports/Jlink_RTT/Kconfig" endif if PERCEPIO_TRC_CFG_STREAM_PORT_ITM rsource "../streamports/ARM_ITM/Kconfig" endif if PERCEPIO_TRC_CFG_STREAM_PORT_RINGBUFFER rsource "../streamports/RingBuffer/Kconfig" endif if PERCEPIO_TRC_CFG_STREAM_PORT_FILE rsource "../streamports/File/Kconfig" endif if PERCEPIO_TRC_CFG_STREAM_PORT_ZEPHYR_SEMIHOST rsource "../kernelports/Zephyr/streamports/Semihost/Kconfig" endif choice PERCEPIO_TRC_CFG_RECORDER_BUFFER_ALLOCATION prompt "Recorder Allocation Mode" default PERCEPIO_TRC_RECORDER_BUFFER_ALLOCATION_STATIC help Specifies how the recorder buffer is allocated (also in case of streaming, in port using the recorders internal temporary buffer) Values: PERCEPIO_TRC_RECORDER_BUFFER_ALLOCATION_STATIC - Static allocation (internal) PERCEPIO_TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC - Malloc in vTraceEnable PERCEPIO_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 PERCEPIO_TRC_ALLOC_CUSTOM_BUFFER and vTraceSetRecorderDataBuffer(). config PERCEPIO_TRC_RECORDER_BUFFER_ALLOCATION_STATIC bool "Static allocation" config PERCEPIO_TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC bool "Dynamic allocation" config PERCEPIO_TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM bool "Custom allocation" endchoice menu "Coverage" depends on !PERCEPIO_TRC_CFG_RECORDER_RTOS_ZEPHYR config PERCEPIO_TRC_CFG_SCHEDULING_ONLY bool "Only Record Scheduling Events" default n config PERCEPIO_TRC_CFG_INCLUDE_MEMMANG_EVENTS bool "Trace Memory Management Events" depends on !PERCEPIO_TRC_CFG_SCHEDULING_ONLY default y help This controls if malloc and free calls should be traced. Disable this to exclude malloc/free calls, or enable it to include such events in the trace. config PERCEPIO_TRC_CFG_INCLUDE_USER_EVENTS bool "Trace User Events" depends on !PERCEPIO_TRC_CFG_SCHEDULING_ONLY default y help If this is disabled, all code related to User Events is excluded in order to reduce code size. Any attempts to store 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. config PERCEPIO_TRC_CFG_INCLUDE_ISR_TRACING bool "Trace ISR Events" depends on !PERCEPIO_TRC_CFG_SCHEDULING_ONLY default y help If this is disabled, the code for recording Interrupt Service Routines is excluded, in order to reduce code size. This means that any calls to vTraceStoreISRBegin/vTraceStoreISREnd will be ignored. This does not completely disable ISR tracing, in cases where an ISR is calling a traced kernel service. These events will still be recorded and show up in anonymous ISR instances in Tracealyzer, with names such as "ISR sending to ". To disable such tracing, please refer to vTraceSetFilterGroup and vTraceSetFilterMask. config PERCEPIO_TRC_CFG_INCLUDE_READY_EVENTS bool "Trace Task Ready Events" depends on !PERCEPIO_TRC_CFG_SCHEDULING_ONLY default y help If enabled, 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 disabled, "ready events" are not created, which allows for recording longer traces in the same amount of RAM. config PERCEPIO_TRC_CFG_INCLUDE_OSTICK_EVENTS bool "Trace OS Tick Events" depends on !PERCEPIO_TRC_CFG_SCHEDULING_ONLY default y help If this is enabled, events will be generated whenever the OS clock is increased. If disabled, OS tick events are not generated, which allows for recording longer traces in the same amount of RAM. endmenu menu "Control Task" config PERCEPIO_TRC_CFG_CTRL_TASK_PRIORITY int "Control Task Priority" range 0 32 if PERCEPIO_TRC_CFG_RECORDER_RTOS_FREERTOS || PERCEPIO_TRC_CFG_RECORDER_RTOS_THREADX range -32 32 if PERCEPIO_TRC_CFG_RECORDER_RTOS_ZEPHYR default 4 help In streaming mode, TzCtrl is used to receive start/stop commands from Tracealyzer and in some cases also to transmit the trace data (for stream ports that uses the internal buffer, like TCP/IP). For such stream ports, make sure the TzCtrl priority is high enough to ensure reliable periodic execution and transfer of the data, but low enough to avoid disturbing any time-sensitive functions. In Snapshot mode, TzCtrl is only used for the stack usage monitoring and is not created if stack monitoring is disabled. PERCEPIO_TRC_CFG_CTRL_TASK_PRIORITY should be low, to avoid disturbing any time-sensitive tasks. config PERCEPIO_TRC_CFG_CTRL_TASK_DELAY int "Control Task Delay" range 1 1000000000 default 10 help The delay between loops of the TzCtrl task (see PERCEPIO_TRC_CFG_CTRL_TASK_PRIORITY), which affects the frequency of the stack monitoring. In streaming mode, this also affects the trace data transfer if you are using a stream port leveraging the internal buffer (like TCP/IP). A shorter delay increases the CPU load of TzCtrl somewhat, but may improve the performance of of the trace streaming, especially if the trace buffer is small. config PERCEPIO_TRC_CFG_CTRL_TASK_STACK_SIZE int "Control Task Stack Size" range 1 1048576 default 256 help The stack size of the Tracealyzer Control (TzCtrl) task. See PERCEPIO_TRC_CFG_CTRL_TASK_PRIORITY for further information about TzCtrl. endmenu menuconfig PERCEPIO_TRC_CFG_ENABLE_STACK_MONITOR bool "Stack Monitor" select TRACING_STACK if PERCEPIO_TRC_CFG_RECORDER_RTOS_ZEPHYR select THREAD_STACK_INFO if PERCEPIO_TRC_CFG_RECORDER_RTOS_ZEPHYR default y help If enabled (1), the recorder periodically reports the unused stack space of all active tasks. The stack monitoring runs in the Tracealyzer Control task, TzCtrl. This task is always created by the recorder when in streaming mode. In snapshot mode, the TzCtrl task is only used for stack monitoring and is not created unless this is enabled. if PERCEPIO_TRC_CFG_ENABLE_STACK_MONITOR config PERCEPIO_TRC_CFG_STACK_MONITOR_MAX_TASKS int "Stack Monitor Max Tasks" range 1 64 default 15 help This controls how many tasks that can be monitored by the stack monitor. If this is too small, some tasks will be excluded and a warning is shown. config PERCEPIO_TRC_CFG_STACK_MONITOR_MAX_REPORTS int "Stack Monitor Max Reports" range 1 64 default 1 help This defines how many tasks that will be subject to stack usage analysis for each execution of the Tracealyzer Control task (TzCtrl). Note that the stack monitoring cycles between the tasks, so this does not affect WHICH tasks that are monitored, but HOW OFTEN each task stack is analyzed. This setting can be combined with PERCEPIO_TRC_CFG_CTRL_TASK_DELAY to tune the frequency of the stack monitoring. This is motivated since the stack analysis can take some time to execute. However, note that the stack analysis runs in a separate task (TzCtrl) that can be executed on low priority. This way, you can avoid that the stack analysis disturbs any time-sensitive tasks. endif # PERCEPIO_TRC_CFG_ENABLE_STACK_MONITOR menu "ISR" config PERCEPIO_TRC_CFG_MAX_ISR_NESTING int "Max ISR Nesting" range 1 1048576 default 8 help 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). config PERCEPIO_TRC_CFG_ISR_TAILCHAINING_THRESHOLD int "ISR Tailchaining Threshold" range 0 4194304 default 0 help 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 PERCEPIO_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. endmenu menu "Debug" config PERCEPIO_TRC_CFG_RECORDER_DATA_INIT int "Data Init" default 1 help Macro that states wether the recorder data should have an initial value. In very specific cases where traced objects are created before main(), the recorder will need to be started even before that. In these cases, the recorder data would be initialized by xTraceInitialize() but could then later be overwritten by the initialization value. If this is an issue for you, set PERCEPIO_TRC_CFG_RECORDER_DATA_INIT to 0. The following code can then be used before any traced objects are created: extern uint32_t RecorderEnabled; RecorderEnabled = 0; xTraceInitialize(); After the clocks are properly initialized, use vTraceEnable(...) to start the tracing. config PERCEPIO_TRC_CFG_USE_TRACE_ASSERT bool "Trace Asserts" default n help Enable or disable debug asserts. Information regarding any assert that is triggered will be in trcAssert.c. endmenu if PERCEPIO_TRC_RECORDER_MODE_SNAPSHOT menu "Snapshot Config" choice PERCEPIO_TRC_CFG_SNAPSHOT_MODE prompt "Snapshot Mode" default PERCEPIO_TRC_SNAPSHOT_MODE_RING_BUFFER help With PERCEPIO_TRC_CFG_SNAPSHOT_MODE set to PERCEPIO_TRC_CFG_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 PERCEPIO_TRC_CFG_SNAPSHOT is PERCEPIO_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. config PERCEPIO_TRC_SNAPSHOT_MODE_RING_BUFFER bool "Ring buffer mode" config PERCEPIO_TRC_SNAPSHOT_MODE_RING_STOP_WHEN_FULL bool "Stop when full" endchoice config PERCEPIO_TRC_CFG_EVENT_BUFFER_SIZE int "Event Buffer Size" range 1 4194304 default 1000 help 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. config PERCEPIO_TRC_CFG_INCLUDE_FLOAT_SUPPORT bool "Include Float Support" default 0 help 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. config PERCEPIO_TRC_CFG_SYMBOL_TABLE_SIZE int "Symbol Table Size" range 1 4194304 default 800 help This defines the capacity of the symbol table, in bytes. This symbol table stores User Event 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. menu "Advanced Settings" config PERCEPIO_TRC_CFG_HEAP_SIZE_BELOW_16M bool "Heap Size Below 16M" default n help 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 set to 0, you get the full 32-bit addresses. config PERCEPIO_TRC_CFG_USE_IMPLICIT_IFE_RULES bool "Use Implicit IFE Rules" default y help 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 PERCEPIO_TRC_CFG_USE_IMPLICIT_IFE_RULES is one (1), the default IFE rules are 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 PERCEPIO_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. config PERCEPIO_TRC_CFG_USE_16BIT_OBJECT_HANDLES bool "Use 16 Bit Object Handles" default n help 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. config PERCEPIO_TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER bool "Use Separate User Event Buffer" default n help Set PERCEPIO_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); config PERCEPIO_TRC_CFG_SEPARATE_USER_EVENT_BUFFER_SIZE int "Separate User Event Buffer Size" depends on PERCEPIO_TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER range 1 4194304 default 200 help This defines the capacity of the user event buffer (UB), in number of slots. A single user event can use multiple slots, depending on its arguments. config PERCEPIO_TRC_CFG_UB_CHANNELS int "User Event Buffer Channels" depends on PERCEPIO_TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER range 0 4194304 default 32 help 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. endmenu # "Advanced Settings" endmenu # "Snapshot Config" endif # PERCEPIO_TRC_RECORDER_MODE_SNAPSHOT if PERCEPIO_TRC_RECORDER_MODE_STREAMING menu "Streaming Config" config PERCEPIO_TRC_CFG_ENTRY_SLOTS int "Entry Slots" range 1 4194304 default 50 help The maximum number of objects and symbols that can be stored. This includes: - Task names - Named ISRs (vTraceSetISRProperties) - Named kernel objects (vTraceStoreKernelObjectName) - User event channels (xTraceStringRegister) 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 (logged as User Events) from the TzCtrl task, which monitors this. config PERCEPIO_TRC_CFG_ENTRY_SYMBOL_MAX_LENGTH int "Symbol Max Length" range 1 28 default 28 help The maximum length of symbol names, including: - Task names - Named ISRs (vTraceSetISRProperties) - Named kernel objects (vTraceStoreKernelObjectName) - User event channel names (xTraceStringRegister) 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 (logged as User Events) from the TzCtrl task, which monitors this. endmenu # "Streaming Config" endif # PERCEPIO_TRC_RECORDER_MODE_STREAMING