1 /*
2  * Trace Recorder for Tracealyzer v4.8.1
3  * Copyright 2023 Percepio AB
4  * www.percepio.com
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  *
8  * The configuration for trace streaming ("stream ports").
9  */
10 
11 #ifndef TRC_STREAM_PORT_CONFIG_H
12 #define TRC_STREAM_PORT_CONFIG_H
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 /**
19  * @def TRC_CFG_STREAM_PORT_USE_INTERNAL_BUFFER
20  *
21  * @brief This define will determine whether to use the internal buffer or not.
22  * If file writing creates additional trace events (i.e. it uses semaphores or mutexes),
23  * then the internal buffer must be enabled to avoid infinite recursion.
24  */
25 #define TRC_CFG_STREAM_PORT_USE_INTERNAL_BUFFER 0
26 
27 /**
28  * @def TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_SIZE
29  *
30  * @brief Configures the size of the internal buffer if used.
31  */
32 #define TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_SIZE 5120
33 
34 /**
35  * @def TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_WRITE_MODE
36  *
37  * @brief This should be set to TRC_INTERNAL_EVENT_BUFFER_OPTION_WRITE_MODE_DIRECT for best performance.
38  */
39 #define TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_WRITE_MODE TRC_INTERNAL_EVENT_BUFFER_OPTION_WRITE_MODE_DIRECT
40 
41 /**
42  * @def TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_TRANSFER_MODE
43  *
44  * @brief Defines if the internal buffer will attempt to transfer all data each time or limit it to a chunk size.
45  */
46 #define TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_TRANSFER_MODE TRC_INTERNAL_EVENT_BUFFER_OPTION_TRANSFER_MODE_ALL
47 
48 /**
49  * @def TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_CHUNK_SIZE
50  *
51  * @brief Defines the maximum chunk size when transferring
52  * internal buffer events in chunks.
53  */
54 #define TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_CHUNK_SIZE 1024
55 
56 /**
57  * @def TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_CHUNK_TRANSFER_AGAIN_SIZE_LIMIT
58  *
59  * @brief Defines the number of transferred bytes needed to trigger another transfer.
60  * It also depends on TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_CHUNK_TRANSFER_AGAIN_COUNT_LIMIT to set a maximum number
61  * of additional transfers this loop.
62  * This will increase throughput by immediately doing a transfer and not wait for another xTraceTzCtrl() loop.
63  */
64 #define TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_CHUNK_TRANSFER_AGAIN_SIZE_LIMIT 256
65 
66 /**
67  * @def TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_CHUNK_TRANSFER_AGAIN_COUNT_LIMIT
68  *
69  * @brief Defines the maximum number of times to trigger another transfer before returning to xTraceTzCtrl().
70  * It also depends on TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_CHUNK_TRANSFER_AGAIN_SIZE_LIMIT to see if a meaningful amount of data was
71  * transferred in the last loop.
72  * This will increase throughput by immediately doing a transfer and not wait for another xTraceTzCtrl() loop.
73  */
74 #define TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_CHUNK_TRANSFER_AGAIN_COUNT_LIMIT 5
75 
76 
77 /**
78 * @def TRC_CFG_STREAM_PORT_RTT_UP_BUFFER_SIZE
79 *
80 * @brief Defines the size of the "up" RTT buffer (target -> host) to use for writing
81 * the trace data, for RTT buffer 1 or higher.
82 *
83 * This setting is ignored for RTT buffer 0, which can't be reconfigured
84 * in runtime and therefore hard-coded to use the defines in SEGGER_RTT_Conf.h.
85 *
86 * Default buffer size for Tracealyzer is 5120 bytes.
87 *
88 * If you have a stand-alone J-Link probe, the can be decreased to around 1 KB.
89 * But integrated J-Link OB interfaces are slower and needs about 5-10 KB,
90 * depending on the amount of data produced.
91 */
92 #define TRC_CFG_STREAM_PORT_RTT_UP_BUFFER_SIZE 5120
93 
94 /**
95 * @def TRC_CFG_STREAM_PORT_RTT_DOWN_BUFFER_SIZE
96 *
97 * @brief Defines the size of the "down" RTT buffer (host -> target) to use for reading
98 * commands from Tracealyzer, for RTT buffer 1 or higher.
99 *
100 * Default buffer size for Tracealyzer is 32 bytes.
101 *
102 * This setting is ignored for RTT buffer 0, which can't be reconfigured
103 * in runtime and therefore hard-coded to use the defines in SEGGER_RTT_Conf.h.
104 */
105 #define TRC_CFG_STREAM_PORT_RTT_DOWN_BUFFER_SIZE 32
106 
107 /**
108 * @def TRC_CFG_STREAM_PORT_RTT_UP_BUFFER_INDEX
109 *
110 * @brief Defines the RTT buffer to use for writing the trace data. Make sure that
111 * the PC application has the same setting (File->Settings).
112 *
113 * Default: 1
114 *
115 * We don't recommend using RTT buffer 0, since mainly intended for terminals.
116 * If you prefer to use buffer 0, it must be configured in SEGGER_RTT_Conf.h.
117 */
118 #define TRC_CFG_STREAM_PORT_RTT_UP_BUFFER_INDEX 1
119 
120 /**
121 * @def TRC_CFG_STREAM_PORT_RTT_DOWN_BUFFER_INDEX
122 *
123 * @brief Defines the RTT buffer to use for reading the trace data. Make sure that
124 * the PC application has the same setting (File->Settings).
125 *
126 * Default: 1
127 *
128 * We don't recommend using RTT buffer 0, since mainly intended for terminals.
129 * If you prefer to use buffer 0, it must be configured in SEGGER_RTT_Conf.h.
130 */
131 #define TRC_CFG_STREAM_PORT_RTT_DOWN_BUFFER_INDEX 1
132 
133 /**
134 * @def TRC_CFG_STREAM_PORT_RTT_MODE
135 *
136 * @brief This stream port for J-Link streaming relies on SEGGER RTT, that contains an
137 * internal RAM buffer read by the J-Link probes during execution.
138 *
139 * Possible values:
140 * - SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
141 * - SEGGER_RTT_MODE_NO_BLOCK_SKIP (default)
142 *
143 * Using SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL ensure that you get a
144 * complete and valid trace. This may however cause blocking if your streaming
145 * interface isn't fast enough, which may disturb the real-time behavior.
146 *
147 * We therefore recommend SEGGER_RTT_MODE_NO_BLOCK_SKIP. In this mode,
148 * Tracealyzer will report lost events if the transfer is not
149 * fast enough. In that case, try increasing the size of the "up buffer".
150 */
151 #define TRC_CFG_STREAM_PORT_RTT_MODE SEGGER_RTT_MODE_NO_BLOCK_SKIP
152 
153 /**
154  * @def TRC_CFG_STREAM_PORT_RTT_NO_LOCK_WRITE
155  *
156  * @brief Sets if RTT should write without locking or not when writing
157  * RTT data. This should normally be disabled with an exception being
158  * Zephyr, where the SEGGER RTT locks aren't necessary and causes
159  * problems if enabled.
160  *
161  * Default: 0
162  */
163 #define TRC_CFG_STREAM_PORT_RTT_NO_LOCK_WRITE 0
164 
165 #ifdef __cplusplus
166 }
167 #endif
168 
169 #endif /* TRC_STREAM_PORT_CONFIG_H */
170