1# Copyright (c) 2021 Nordic Semiconductor ASA
2# SPDX-License-Identifier: Apache-2.0
3
4menu "Backends"
5
6config LOG_BACKEND_UART
7	bool "Enable UART backend"
8	depends on UART_CONSOLE
9	default y if !SHELL_BACKEND_SERIAL
10	help
11	  When enabled backend is using UART to output logs.
12
13if LOG_BACKEND_UART
14
15config LOG_BACKEND_UART_OUTPUT_DICTIONARY
16	bool
17	depends on LOG2
18	select LOG_DICTIONARY_SUPPORT
19	help
20	  UART backend is in dictionary-based logging output mode.
21
22choice
23	prompt "UART Backend Output Mode"
24	default LOG_BACKEND_UART_OUTPUT_TEXT
25
26config LOG_BACKEND_UART_OUTPUT_TEXT
27	bool "Text"
28	help
29	  Output in text.
30
31config LOG_BACKEND_UART_SYST_ENABLE
32	bool "MIPI SyS-T"
33	depends on LOG_BACKEND_UART
34	depends on LOG_MIPI_SYST_ENABLE
35	help
36	  When enabled backend is using UART to output syst format logs.
37
38config LOG_BACKEND_UART_OUTPUT_DICTIONARY_HEX
39	bool "Dictionary (hexadecimal)"
40	depends on LOG2
41	select LOG_BACKEND_UART_OUTPUT_DICTIONARY
42	help
43	  Dictionary-based logging output in hexadecimal.
44
45config LOG_BACKEND_UART_OUTPUT_DICTIONARY_BIN
46	bool "Dictionary (binary)"
47	depends on LOG2
48	select LOG_BACKEND_UART_OUTPUT_DICTIONARY
49	help
50	  Dictionary-based logging output in binary.
51
52endchoice
53
54endif # LOG_BACKEND_UART
55
56config LOG_BACKEND_SWO
57	bool "Enable Serial Wire Output (SWO) backend"
58	depends on HAS_SWO
59	help
60	  When enabled, backend will use SWO for logging.
61
62if LOG_BACKEND_SWO
63
64config LOG_BACKEND_SWO_FREQ_HZ
65	int "Set SWO output frequency"
66	default 0
67	help
68	  Set SWO output frequency. Value 0 will select maximum frequency
69	  supported by the given MCU. Not all debug probes support high
70	  frequency SWO operation. In this case the frequency has to be set
71	  manually.
72
73	  SWO value defined by this option will be configured at boot. Most SWO
74	  viewer programs will configure SWO frequency when attached to the
75	  debug probe. Such configuration will persist only until the device
76	  reset. To ensure flawless operation the frequency configured here and
77	  by the SWO viewer program has to match.
78
79config LOG_BACKEND_SWO_SYST_ENABLE
80	bool "Enable SWO syst backend"
81	depends on LOG_MIPI_SYST_ENABLE
82	help
83	  When enabled backend is using SWO to output syst format logs.
84
85endif # LOG_BACKEND_SWO
86
87config LOG_BACKEND_RTT
88	bool "Enable Segger J-Link RTT backend"
89	depends on USE_SEGGER_RTT
90	default y if !SHELL_BACKEND_RTT
91	select SEGGER_RTT_CUSTOM_LOCKING
92	help
93	  When enabled, backend will use RTT for logging. This backend works on a per
94	  message basis. Only a whole message (terminated with a carriage return: '\r')
95	  is transferred to up-buffer at once depending on available space and
96	  selected mode.
97	  In panic mode backend always blocks and waits until there is space
98	  in up-buffer for a message and message is transferred to host.
99
100if LOG_BACKEND_RTT
101
102choice
103	prompt "Logger behavior"
104	default LOG_BACKEND_RTT_MODE_BLOCK
105
106config LOG_BACKEND_RTT_MODE_DROP
107	bool "Drop messages that do not fit in up-buffer."
108	help
109	  If there is not enough space in up-buffer for a message, drop it.
110	  Number of dropped messages will be logged.
111	  Increase up-buffer size helps to reduce dropping of messages.
112
113config LOG_BACKEND_RTT_MODE_BLOCK
114	bool "Block until message is transferred to host."
115	help
116	  Waits until there is enough space in the up-buffer for a message.
117
118config LOG_BACKEND_RTT_SYST_ENABLE
119	bool "Enable RTT syst backend"
120	depends on LOG_MIPI_SYST_ENABLE
121	help
122	  When enabled backend is using RTT to output syst format logs.
123
124endchoice
125
126config LOG_BACKEND_RTT_MESSAGE_SIZE
127	int "Size of internal buffer for storing messages."
128	range 32 256
129	default 128
130	depends on LOG_BACKEND_RTT_MODE_DROP
131	help
132	  This option defines maximum message size transferable to up-buffer.
133
134if LOG_BACKEND_RTT_MODE_BLOCK
135
136config LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE
137	int "Size of the output buffer"
138	default 16
139	help
140	  Buffer is used by log_output module for preparing output data (e.g.
141	  string formatting).
142
143config LOG_BACKEND_RTT_RETRY_CNT
144	int "Number of retries"
145	default 4
146	help
147	  Number of TX retries before dropping the data and assuming that
148	  RTT session is inactive.
149
150config LOG_BACKEND_RTT_RETRY_DELAY_MS
151	int "Delay between TX retries in milliseconds"
152	default 5
153	help
154	  Sleep period between TX retry attempts. During RTT session, host pulls
155	  data periodically. Period starts from 1-2 milliseconds and can be
156	  increased if traffic on RTT increases (also from host to device). In
157	  case of heavy traffic data can be lost and it may be necessary to
158	  increase delay or number of retries.
159
160endif # LOG_BACKEND_RTT_MODE_BLOCK
161
162config LOG_BACKEND_RTT_BUFFER
163	int "Buffer number used for logger output."
164	range 0 SEGGER_RTT_MAX_NUM_UP_BUFFERS
165	default 0
166	help
167	  Select index of up-buffer used for logger output, by default it uses
168	  terminal up-buffer and its settings.
169
170config LOG_BACKEND_RTT_BUFFER_SIZE
171	int "Size of reserved up-buffer for logger output."
172	default 1024
173	depends on LOG_BACKEND_RTT_BUFFER > 0
174	help
175	  Specify reserved size of up-buffer used for logger output.
176
177# Enable processing of printk calls using log if terminal buffer is used.
178# Same buffer is used by RTT console. If printk would go through RTT console
179# that will lead to corruption of RTT data which is not protected against being
180# interrupted by an interrupt.
181config LOG_BACKEND_RTT_FORCE_PRINTK
182	bool
183	default y if LOG_BACKEND_RTT_BUFFER = 0 && RTT_CONSOLE
184	select LOG_PRINTK
185
186endif # LOG_BACKEND_RTT
187
188config LOG_BACKEND_SPINEL
189	bool "Enable OpenThread dedicated Spinel protocol backend"
190	depends on !LOG_BACKEND_UART
191	depends on NET_L2_OPENTHREAD
192	help
193	  When enabled, backend will use OpenThread dedicated SPINEL protocol for logging.
194	  This protocol is byte oriented and wrapps given messages into serial frames.
195	  Backend should be enabled only to OpenThread purposes and when UART backend is disabled
196	  or works on antoher UART device to avoid interference.
197
198if LOG_BACKEND_SPINEL
199
200config LOG_BACKEND_SPINEL_BUFFER_SIZE
201	int "Size of reserved up-buffer for logger output."
202	default 64
203	help
204	  Specify reserved size of up-buffer used for logger output.
205
206endif # LOG_BACKEND_SPINEL
207
208config LOG_BACKEND_NATIVE_POSIX
209	bool "Enable native backend"
210	depends on ARCH_POSIX
211	help
212	  Enable backend in native_posix
213
214config LOG_BACKEND_XTENSA_SIM
215	bool "Enable xtensa simulator backend"
216	depends on SOC_XTENSA_SAMPLE_CONTROLLER || SOC_FAMILY_INTEL_ADSP
217	help
218	  Enable backend in xtensa simulator
219
220config LOG_BACKEND_XTENSA_OUTPUT_BUFFER_SIZE
221	int "Size of the output buffer"
222	default 16
223	depends on LOG_BACKEND_XTENSA_SIM
224	help
225	  Buffer is used by log_output module for preparing output data (e.g.
226	  string formatting).
227
228# Immediate mode cannot be used with network backend as it would cause the sent
229# rsyslog message to be malformed.
230config LOG_BACKEND_NET
231	bool "Enable networking backend"
232	depends on NETWORKING && NET_UDP && !LOG_IMMEDIATE
233	select NET_CONTEXT_NET_PKT_POOL
234	help
235	  Send syslog messages to network server.
236	  See RFC 5424 (syslog protocol) and RFC 5426 (syslog over UDP)
237	  specifications for details.
238
239if LOG_BACKEND_NET
240
241config LOG_BACKEND_NET_SERVER
242	string "Syslog server IP address"
243	help
244	  This can be either IPv4 or IPv6 address.
245	  Server listen UDP port number can be configured here too.
246	  Following syntax is supported:
247	  192.0.2.1:514
248	  192.0.2.42
249	  [2001:db8::1]:514
250	  [2001:db8::2]
251	  2001:db::42
252
253config LOG_BACKEND_NET_MAX_BUF
254	int "How many network buffers to allocate for sending messages"
255	range 3 256
256	default 3
257	help
258	  Each syslog message should fit into a network packet that will be
259	  sent to server. This number tells how many syslog messages can be
260	  in transit to the server.
261
262config LOG_BACKEND_NET_MAX_BUF_SIZE
263	int "Max syslog message size"
264	range 64 1180
265	default 1180 if NET_IPV6
266	default 480 if NET_IPV4
267	default 256
268	help
269	  As each syslog message needs to fit to UDP packet, set this value
270	  so that messages are not truncated.
271	  The RFC 5426 recommends that for IPv4 the size is 480 octets and for
272	  IPv6 the size is 1180 octets. As each buffer will use RAM, the value
273	  should be selected so that typical messages will fit the buffer.
274
275config LOG_BACKEND_NET_SYST_ENABLE
276	bool "Enable networking syst backend"
277	depends on LOG_MIPI_SYST_ENABLE
278	help
279	  When enabled backend is using networking to output syst format logs.
280
281config LOG_BACKEND_NET_AUTOSTART
282	bool "Automatically start networking backend"
283	default y if NET_CONFIG_NEED_IPV4 || NET_CONFIG_NEED_IPV6
284	help
285	  When enabled automatically start the networking backend on
286	  application start. If no routes to the logging server are available
287	  on application startup, this must be set to n and the backend must be
288	  started by the application later on. Otherwise the logging
289	  thread might block.
290
291endif # LOG_BACKEND_NET
292
293config LOG_BACKEND_ADSP
294	bool "Enable Intel ADSP buffer backend"
295	depends on SOC_FAMILY_INTEL_ADSP
296	help
297	  Enable backend for the host trace protocol of the Intel ADSP
298	  family of audio processors
299
300config LOG_BACKEND_FS
301	bool "Enable file system backend"
302	depends on FILE_SYSTEM
303	help
304	  When enabled, backend is using the configured file system to output logs.
305	  As the file system must be mounted for the logging to work, it must be
306	  either configured for auto-mount or manually mounted by the application.
307	  Log messages are discarded as long as the file system is not mounted.
308
309if LOG_BACKEND_FS
310
311config LOG_BACKEND_FS_OUTPUT_DICTIONARY
312	bool
313	depends on LOG2
314	select LOG_DICTIONARY_SUPPORT
315	help
316	  FS backend is in dictionary-based logging output mode.
317
318choice
319	prompt "FS Backend Output Mode"
320	default LOG_BACKEND_FS_OUTPUT_TEXT
321
322config LOG_BACKEND_FS_OUTPUT_TEXT
323	bool "Text"
324	help
325	  Output in text.
326
327config LOG_BACKEND_FS_OUTPUT_DICTIONARY_BIN
328	bool "Dictionary (binary)"
329	depends on LOG2
330	select LOG_BACKEND_FS_OUTPUT_DICTIONARY
331	help
332	  Dictionary-based logging output in binary.
333
334endchoice
335
336config LOG_BACKEND_FS_OVERWRITE
337	bool "Enable old log files overwrite"
338	default y
339	help
340	  When enabled backend overwrites oldest log files.
341	  In other case, when memory is full, new messages are dropped.
342
343config LOG_BACKEND_FS_FILE_PREFIX
344	string "Log file name prefix"
345	default "log."
346	help
347	  User defined name of log files saved in the file system.
348	  The prefix is followed by the number of log file.
349
350config LOG_BACKEND_FS_DIR
351	string "Log directory"
352	default "/lfs1"
353	help
354	  Directory to which log files will be written.
355
356config LOG_BACKEND_FS_FILE_SIZE
357	int "User defined log file size"
358	default 4096
359	range 128 1073741824
360	help
361	  Max log file size (in bytes).
362
363config LOG_BACKEND_FS_FILES_LIMIT
364	int "Max number of files containing logs"
365	default 10
366	help
367	  Limit of number of files with logs. It is also limited by
368	  size of file system partition.
369
370endif # LOG_BACKEND_FS
371
372endmenu
373