1# Shell backends configuration options
2
3# Copyright (c) 2018 Nordic Semiconductor ASA
4# SPDX-License-Identifier: Apache-2.0
5
6menuconfig SHELL_BACKENDS
7	bool "Shell backends"
8	default y
9	help
10	  Enable shell backends.
11
12if SHELL_BACKENDS
13
14# Workaround for not being able to have commas in macro arguments
15DT_CHOSEN_Z_SHELL_UART := zephyr,shell-uart
16
17config SHELL_BACKEND_SERIAL
18	bool "Serial backend"
19	# Serial (UART) requires interrupts and the RTT backend cannot be used from an ISR context.
20	default n if SHELL_BACKEND_RTT
21	default "$(dt_chosen_enabled,$(DT_CHOSEN_Z_SHELL_UART))"
22	select SERIAL
23	select RING_BUFFER
24	help
25	  Enable serial backend.
26
27if SHELL_BACKEND_SERIAL
28
29config SHELL_BACKEND_SERIAL_INIT_PRIORITY
30	int "Initialization priority"
31	default APPLICATION_INIT_PRIORITY
32	range 0 99
33	help
34	  Initialization priority for UART backend. This must be bigger than
35	  the initialization priority of the used serial device.
36
37config SHELL_PROMPT_UART
38	string "Displayed prompt name"
39	default "uart:~$ "
40	help
41	  Displayed prompt name for UART backend. If prompt is set, the shell will
42	  send two newlines during initialization.
43
44config SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN
45	bool "Interrupt driven"
46	default y
47	depends on SERIAL_SUPPORT_INTERRUPT
48
49config SHELL_ASYNC_API
50	bool "Asynchronous shell API"
51	default n
52	depends on UART_ASYNC_API
53	help
54	  This option enables asynchronous shell API.
55
56choice SHELL_BACKEND_SERIAL_API
57	prompt "Mode"
58	default SHELL_BACKEND_SERIAL_API_ASYNC if SHELL_ASYNC_API
59	default SHELL_BACKEND_SERIAL_API_INTERRUPT_DRIVEN if SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN
60	default SHELL_BACKEND_SERIAL_API_POLLING
61
62config SHELL_BACKEND_SERIAL_API_POLLING
63	prompt "Polling"
64
65config SHELL_BACKEND_SERIAL_API_INTERRUPT_DRIVEN
66	bool "Interrupt driven"
67	depends on SERIAL_SUPPORT_INTERRUPT
68	select UART_INTERRUPT_DRIVEN
69
70
71config SHELL_BACKEND_SERIAL_API_ASYNC
72	bool "Asynchronous"
73	depends on SERIAL_SUPPORT_ASYNC
74	select UART_ASYNC_RX_HELPER
75
76endchoice
77
78config SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE
79	int "Set TX ring buffer size"
80	default 8
81	depends on SHELL_BACKEND_SERIAL_API_INTERRUPT_DRIVEN
82	help
83	  If UART is utilizing DMA transfers then increasing ring buffer size
84	  increases transfers length and reduces number of interrupts.
85
86config SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE
87	int "Set RX ring buffer size"
88	depends on SHELL_BACKEND_SERIAL_API_INTERRUPT_DRIVEN || SHELL_BACKEND_SERIAL_API_POLLING
89	default 256 if MCUMGR_TRANSPORT_SHELL
90	default 64
91	help
92	  RX ring buffer size impacts accepted latency of handling incoming
93	  bytes by shell. If shell input is coming from the keyboard then it is
94	  usually enough if ring buffer is few bytes (more than one due to
95	  escape sequences). However, if bulk data is transferred it may be
96	  required to increase it.
97
98if SHELL_BACKEND_SERIAL_API_ASYNC
99
100config SHELL_BACKEND_SERIAL_ASYNC_RX_TIMEOUT
101	int "RX inactivity timeout (in microseconds)"
102	default 10000
103	help
104	  Inactivity timeout after which received data is reported.
105
106config SHELL_BACKEND_SERIAL_ASYNC_RX_BUFFER_COUNT
107	int "Number of RX buffers"
108	default 4
109	range 2 64
110	help
111	  Number of RX buffers. Some UART driver implementations changes buffers
112	  on timeout so this number should be big enough to cover handling on
113	  time incoming data. 4 should be enough for almost all the cases unless
114	  CPU load is high and there is very high shell thread latency.
115
116config SHELL_BACKEND_SERIAL_ASYNC_RX_BUFFER_SIZE
117	int "Size of the RX buffer"
118	default 16
119	help
120	  Size of a single RX buffer. Together with buffer count it defines the
121	  space that can hold RX data. It may be decreased if shell input is
122	  slow and may need to be increased if long messages are pasted directly
123	  to the shell prompt.
124
125endif # SHELL_BACKEND_SERIAL_API_ASYNC
126
127config SHELL_BACKEND_SERIAL_RX_POLL_PERIOD
128	int "RX polling period (in milliseconds)"
129	default 10
130	depends on SHELL_BACKEND_SERIAL_API_POLLING
131	help
132	  Determines how often UART is polled for RX byte.
133
134config SHELL_BACKEND_SERIAL_CHECK_DTR
135	bool "Check DTR signal before TX"
136	depends on SHELL_BACKEND_SERIAL_API_INTERRUPT_DRIVEN
137	depends on UART_LINE_CTRL
138	help
139	  Check DTR signal before TX.
140
141module = SHELL_BACKEND_SERIAL
142default-timeout = 100
143source "subsys/shell/Kconfig.template.shell_log_queue_timeout"
144
145default-size = 512
146source "subsys/shell/Kconfig.template.shell_log_queue_size"
147
148choice
149	prompt "Initial log level limit"
150	default SHELL_BACKEND_SERIAL_LOG_LEVEL_DEFAULT
151
152config SHELL_BACKEND_SERIAL_LOG_LEVEL_DEFAULT
153	bool "System limit (LOG_MAX_LEVEL)"
154
155config SHELL_BACKEND_SERIAL_LOG_LEVEL_DBG
156	bool "Debug"
157
158config SHELL_BACKEND_SERIAL_LOG_LEVEL_INF
159	bool "Info"
160
161config SHELL_BACKEND_SERIAL_LOG_LEVEL_WRN
162	bool "Warning"
163
164config SHELL_BACKEND_SERIAL_LOG_LEVEL_ERR
165	bool "Error"
166
167config SHELL_BACKEND_SERIAL_LOG_LEVEL_NONE
168	bool "None"
169
170endchoice
171
172config SHELL_BACKEND_SERIAL_LOG_LEVEL
173	int
174	default 0 if SHELL_BACKEND_SERIAL_LOG_LEVEL_NONE
175	default 1 if SHELL_BACKEND_SERIAL_LOG_LEVEL_ERR
176	default 2 if SHELL_BACKEND_SERIAL_LOG_LEVEL_WRN
177	default 3 if SHELL_BACKEND_SERIAL_LOG_LEVEL_INF
178	default 4 if SHELL_BACKEND_SERIAL_LOG_LEVEL_DBG
179	default 5 if SHELL_BACKEND_SERIAL_LOG_LEVEL_DEFAULT
180
181endif # SHELL_BACKEND_SERIAL
182
183config SHELL_BACKEND_RTT
184	bool "RTT backend"
185	select CONSOLE
186	select RTT_CONSOLE
187	select SEGGER_RTT_CUSTOM_LOCKING
188	depends on USE_SEGGER_RTT
189	help
190	  Enable RTT backend.
191
192if SHELL_BACKEND_RTT
193
194config SHELL_PROMPT_RTT
195	string "Displayed prompt name"
196	default "rtt:~$ "
197	help
198	  Displayed prompt name for RTT backend. If prompt is set, the shell will
199	  send two newlines during initialization.
200
201config SHELL_BACKEND_RTT_BUFFER
202	int "Buffer number used for shell input and output."
203	range 0 SEGGER_RTT_MAX_NUM_UP_BUFFERS
204	default 0
205	help
206	  Select index of up-buffer used for shell output, by default it uses
207	  terminal up-buffer and its settings.
208
209config SHELL_BACKEND_RTT_RETRY_CNT
210	int "Number of retries"
211	default 4
212	help
213	  Number of TX retries before dropping the data and assuming that
214	  RTT session is inactive.
215
216config SHELL_BACKEND_RTT_RETRY_DELAY_MS
217	int "Delay between TX retries in milliseconds"
218	default 5
219	help
220	  Sleep period between TX retry attempts. During RTT session, host pulls
221	  data periodically. Period starts from 1-2 milliseconds and can be
222	  increased if traffic on RTT increases (also from host to device). In
223	  case of heavy traffic data can be lost and it may be necessary to
224	  increase delay or number of retries.
225
226config SHELL_RTT_RX_POLL_PERIOD
227	int "RX polling period (in milliseconds)"
228	default 10
229	help
230	  Determines how often RTT is polled for RX byte.
231
232module = SHELL_BACKEND_RTT
233default-timeout = 100
234source "subsys/shell/Kconfig.template.shell_log_queue_timeout"
235
236default-size = 512
237source "subsys/shell/Kconfig.template.shell_log_queue_size"
238
239choice
240	prompt "Initial log level limit"
241	default SHELL_RTT_INIT_LOG_LEVEL_DEFAULT
242
243config SHELL_RTT_INIT_LOG_LEVEL_DEFAULT
244	bool "System limit (LOG_MAX_LEVEL)"
245
246config SHELL_RTT_INIT_LOG_LEVEL_DBG
247	bool "Debug"
248
249config SHELL_RTT_INIT_LOG_LEVEL_INF
250	bool "Info"
251
252config SHELL_RTT_INIT_LOG_LEVEL_WRN
253	bool "Warning"
254
255config SHELL_RTT_INIT_LOG_LEVEL_ERR
256	bool "Error"
257
258config SHELL_RTT_INIT_LOG_LEVEL_NONE
259	bool "None"
260
261endchoice
262
263config SHELL_RTT_INIT_LOG_LEVEL
264	int
265	default 0 if SHELL_RTT_INIT_LOG_LEVEL_NONE
266	default 1 if SHELL_RTT_INIT_LOG_LEVEL_ERR
267	default 2 if SHELL_RTT_INIT_LOG_LEVEL_WRN
268	default 3 if SHELL_RTT_INIT_LOG_LEVEL_INF
269	default 4 if SHELL_RTT_INIT_LOG_LEVEL_DBG
270	default 5 if SHELL_RTT_INIT_LOG_LEVEL_DEFAULT
271
272module = SHELL_RTT
273module-str = RTT shell backend
274source "subsys/logging/Kconfig.template.log_config"
275
276endif # SHELL_BACKEND_RTT
277
278config SHELL_BACKEND_MQTT
279	bool "MQTT backend"
280	depends on NET_TCP
281	depends on NET_IPV4
282	depends on NETWORKING
283	select DNS_RESOLVER
284	select HWINFO
285	select MQTT_LIB
286	select NET_MGMT
287	select NET_MGMT_EVENT
288	help
289	  Enable MQTT backend.
290
291if SHELL_BACKEND_MQTT
292
293config SHELL_MQTT_SERVER_ADDR
294	string "MQTT server address"
295	default "192.168.0.100"
296	help
297	  MQTT server address.
298
299config SHELL_MQTT_SERVER_PORT
300	int "MQTT server port"
301	default 1883
302	help
303	  MQTT server port.
304
305config SHELL_MQTT_SERVER_USERNAME
306	string "MQTT server username"
307	help
308	  MQTT server username.
309
310config SHELL_MQTT_SERVER_PASSWORD
311	string "MQTT server password"
312	help
313	  MQTT server password.
314
315config SHELL_MQTT_RX_BUF_SIZE
316	int "RX buffer size"
317	default 256
318	help
319	  Buffer size for the MQTT data reception.
320
321config SHELL_MQTT_TX_BUF_SIZE
322	int "TX buffer size"
323	range 32 $(UINT16_MAX)
324	default 256
325	help
326	  Buffer size for the MQTT data transmission.
327
328module = SHELL_BACKEND_MQTT
329default-timeout = 100
330source "subsys/shell/Kconfig.template.shell_log_queue_timeout"
331
332default-size = 512
333source "subsys/shell/Kconfig.template.shell_log_queue_size"
334
335choice
336	prompt "Initial log level limit"
337	default SHELL_MQTT_INIT_LOG_LEVEL_DEFAULT
338
339config SHELL_MQTT_INIT_LOG_LEVEL_DEFAULT
340	bool "System limit (LOG_MAX_LEVEL)"
341
342config SHELL_MQTT_INIT_LOG_LEVEL_DBG
343	bool "Debug"
344
345config SHELL_MQTT_INIT_LOG_LEVEL_INF
346	bool "Info"
347
348config SHELL_MQTT_INIT_LOG_LEVEL_WRN
349	bool "Warning"
350
351config SHELL_MQTT_INIT_LOG_LEVEL_ERR
352	bool "Error"
353
354config SHELL_MQTT_INIT_LOG_LEVEL_NONE
355	bool "None"
356
357endchoice # SHELL_MQTT_INIT_LOG_LEVEL
358
359config SHELL_MQTT_INIT_LOG_LEVEL
360	int
361	default 0 if SHELL_MQTT_INIT_LOG_LEVEL_NONE
362	default 1 if SHELL_MQTT_INIT_LOG_LEVEL_ERR
363	default 2 if SHELL_MQTT_INIT_LOG_LEVEL_WRN
364	default 3 if SHELL_MQTT_INIT_LOG_LEVEL_INF
365	default 4 if SHELL_MQTT_INIT_LOG_LEVEL_DBG
366	default 5 if SHELL_MQTT_INIT_LOG_LEVEL_DEFAULT
367
368module = SHELL_MQTT
369module-str = MQTT shell backend
370source "subsys/logging/Kconfig.template.log_config"
371
372endif # SHELL_BACKEND_MQTT
373
374config SHELL_BACKEND_RPMSG
375	bool "RPMsg backend."
376	depends on OPENAMP
377	help
378	  Enable RPMsg backend.
379
380if SHELL_BACKEND_RPMSG
381
382config SHELL_PROMPT_RPMSG
383	string "Displayed prompt name"
384	default "ipc:~$ "
385	help
386	  Displayed prompt name for RPMsg backend. If prompt is set, the shell will
387	  send two newlines during initialization.
388
389config SHELL_RPMSG_SERVICE_NAME
390	string "Service name"
391	default "rpmsg-tty"
392	help
393	  The service name associated with the RPMsg endpoint.
394
395config SHELL_RPMSG_SRC_ADDR
396	hex "Local address"
397	default 0xffffffff # The ANY address
398	help
399	  Local address of the RPMsg endpoint.
400
401config SHELL_RPMSG_DST_ADDR
402	hex "Remote address"
403	default 0xffffffff # The ANY address
404	help
405	  Target address of the RPMsg endpoint.
406
407config SHELL_RPMSG_MAX_RX
408	int "Receive buffer size"
409	default 10
410	help
411	  The maximum number of received messages to be queued.
412
413module = SHELL_BACKEND_RPMSG
414default-timeout = 100
415source "subsys/shell/Kconfig.template.shell_log_queue_timeout"
416
417default-size = 512
418source "subsys/shell/Kconfig.template.shell_log_queue_size"
419
420choice
421	prompt "Initial log level limit"
422	default SHELL_RPMSG_INIT_LOG_LEVEL_DEFAULT
423
424config SHELL_RPMSG_INIT_LOG_LEVEL_DEFAULT
425	bool "System limit (LOG_MAX_LEVEL)"
426
427config SHELL_RPMSG_INIT_LOG_LEVEL_DBG
428	bool "Debug"
429
430config SHELL_RPMSG_INIT_LOG_LEVEL_INF
431	bool "Info"
432
433config SHELL_RPMSG_INIT_LOG_LEVEL_WRN
434	bool "Warning"
435
436config SHELL_RPMSG_INIT_LOG_LEVEL_ERR
437	bool "Error"
438
439config SHELL_RPMSG_INIT_LOG_LEVEL_NONE
440	bool "None"
441
442endchoice # SHELL_RPMSG_INIT_LOG_LEVEL
443
444config SHELL_RPMSG_INIT_LOG_LEVEL
445	int
446	default 0 if SHELL_RPMSG_INIT_LOG_LEVEL_NONE
447	default 1 if SHELL_RPMSG_INIT_LOG_LEVEL_ERR
448	default 2 if SHELL_RPMSG_INIT_LOG_LEVEL_WRN
449	default 3 if SHELL_RPMSG_INIT_LOG_LEVEL_INF
450	default 4 if SHELL_RPMSG_INIT_LOG_LEVEL_DBG
451	default 5 if SHELL_RPMSG_INIT_LOG_LEVEL_DEFAULT
452
453module = SHELL_RPMSG
454module-str = RPMsg shell backend
455source "subsys/logging/Kconfig.template.log_config"
456
457endif # SHELL_BACKEND_RPMSG
458
459config SHELL_BACKEND_TELNET
460	bool "TELNET backend."
461	depends on NET_TCP
462	depends on NET_IPV4 || NET_IPV6
463	select NET_SOCKETS_SERVICE
464	select NET_SOCKETS
465	help
466	  Enable TELNET backend.
467
468if SHELL_BACKEND_TELNET
469
470config SHELL_TELNET_INIT_PRIORITY
471	int "Initialization priority"
472	default 95
473	range 0 99
474	help
475	  Initialization priority for telnet shell backend. This must be higher
476	  than socket service initialization priority, as socket service has to
477	  be initialized earlier.
478
479config SHELL_PROMPT_TELNET
480	string "Displayed prompt name"
481	default "~$ "
482	help
483	  Displayed prompt name for TELNET backend. If prompt is set, the shell will
484	  send two newlines during initialization.
485
486config SHELL_TELNET_PORT
487	int "Telnet port number"
488	default 23
489	help
490	  This option is used to configure on which port telnet is going
491	  to be bound.
492
493config SHELL_TELNET_LINE_BUF_SIZE
494	int "Telnet line buffer size"
495	default 80
496	help
497	  This option can be used to modify the size of the buffer storing
498	  shell output line, prior to sending it through the network.
499	  Of course an output line can be longer than such size, it just
500	  means sending it will start as soon as it reaches this size.
501	  It really depends on what type of output is expected.
502	  A lot of short lines: better reduce this value. On the contrary,
503	  raise it.
504
505config SHELL_TELNET_SEND_TIMEOUT
506	int "Telnet line send timeout"
507	default 100
508	help
509	  This option can be used to modify the duration of the timer that kick
510	  in when a line buffer is not empty but did not yet meet the line feed.
511
512config SHELL_TELNET_SUPPORT_COMMAND
513	bool "Add support for telnet commands (IAC) [EXPERIMENTAL]"
514	select EXPERIMENTAL
515	help
516	  Current support is so limited it's not interesting to enable it.
517	  However, if proven to be needed at some point, it will be possible
518	  to extend such support. It does have support for echo and "character
519	  at a time" mode, which enable the history and line-editing features
520	  of the shell.
521	  IMPORTANT: This will increase network usage as a TCP packet will be
522	  sent each time a character is typed in the telnet client.
523
524module = SHELL_TELNET
525default-timeout = 100
526source "subsys/shell/Kconfig.template.shell_log_queue_timeout"
527
528default-size = 512
529source "subsys/shell/Kconfig.template.shell_log_queue_size"
530
531choice
532	prompt "Initial log level limit"
533	default SHELL_TELNET_INIT_LOG_LEVEL_DEFAULT
534
535config SHELL_TELNET_INIT_LOG_LEVEL_DEFAULT
536	bool "System limit (LOG_MAX_LEVEL)"
537
538config SHELL_TELNET_INIT_LOG_LEVEL_DBG
539	bool "Debug"
540
541config SHELL_TELNET_INIT_LOG_LEVEL_INF
542	bool "Info"
543
544config SHELL_TELNET_INIT_LOG_LEVEL_WRN
545	bool "Warning"
546
547config SHELL_TELNET_INIT_LOG_LEVEL_ERR
548	bool "Error"
549
550config SHELL_TELNET_INIT_LOG_LEVEL_NONE
551	bool "None"
552
553endchoice
554
555config SHELL_TELNET_INIT_LOG_LEVEL
556	int
557	default 0 if SHELL_TELNET_INIT_LOG_LEVEL_NONE
558	default 1 if SHELL_TELNET_INIT_LOG_LEVEL_ERR
559	default 2 if SHELL_TELNET_INIT_LOG_LEVEL_WRN
560	default 3 if SHELL_TELNET_INIT_LOG_LEVEL_INF
561	default 4 if SHELL_TELNET_INIT_LOG_LEVEL_DBG
562	default 5 if SHELL_TELNET_INIT_LOG_LEVEL_DEFAULT
563
564module = SHELL_TELNET
565module-str = TELNET shell backend
566source "subsys/logging/Kconfig.template.log_config"
567
568endif # SHELL_TELNET_BACKEND
569
570config SHELL_BACKEND_DUMMY
571	bool "Dummy backend."
572	help
573	  Enable dummy backend which can be used to execute commands with no
574	  need for physical transport interface.
575
576if SHELL_BACKEND_DUMMY
577
578config SHELL_PROMPT_DUMMY
579	string "Displayed prompt name"
580	default "~$ "
581	help
582	  Displayed prompt name for DUMMY backend. If prompt is set, the shell will
583	  send two newlines during initialization.
584
585config SHELL_BACKEND_DUMMY_BUF_SIZE
586	int "Size of dummy buffer size"
587	default 400 if LOG_PRINTK
588	default 300
589	help
590	  This is size of output buffer that will be used by dummy backend, this limits number of
591	  characters that will be captured from command output.
592
593choice
594	prompt "Initial log level limit"
595	default SHELL_DUMMY_INIT_LOG_LEVEL_INF
596
597config SHELL_DUMMY_INIT_LOG_LEVEL_DEFAULT
598	bool "System limit (LOG_MAX_LEVEL)"
599
600config SHELL_DUMMY_INIT_LOG_LEVEL_DBG
601	bool "Debug"
602
603config SHELL_DUMMY_INIT_LOG_LEVEL_INF
604	bool "Info"
605
606config SHELL_DUMMY_INIT_LOG_LEVEL_WRN
607	bool "Warning"
608
609config SHELL_DUMMY_INIT_LOG_LEVEL_ERR
610	bool "Error"
611
612config SHELL_DUMMY_INIT_LOG_LEVEL_NONE
613	bool "None"
614
615endchoice
616
617config SHELL_DUMMY_INIT_LOG_LEVEL
618	int
619	default 0 if SHELL_DUMMY_INIT_LOG_LEVEL_NONE
620	default 1 if SHELL_DUMMY_INIT_LOG_LEVEL_ERR
621	default 2 if SHELL_DUMMY_INIT_LOG_LEVEL_WRN
622	default 3 if SHELL_DUMMY_INIT_LOG_LEVEL_INF
623	default 4 if SHELL_DUMMY_INIT_LOG_LEVEL_DBG
624	default 5 if SHELL_DUMMY_INIT_LOG_LEVEL_DEFAULT
625
626endif # SHELL_BACKEND_DUMMY
627
628config SHELL_BACKEND_ADSP_MEMORY_WINDOW
629	bool "Shell backend implemented over mapped memory window."
630	depends on SOC_FAMILY_INTEL_ADSP
631	help
632	  Enable ADSP memory window backend which can be used to execute commands
633	  from remote host processor that has access to the same memory window.
634
635if SHELL_BACKEND_ADSP_MEMORY_WINDOW
636
637config SHELL_BACKEND_ADSP_MEMORY_WINDOW_PROMPT
638	string "Displayed prompt name"
639	default "~$ "
640	help
641	  Displayed prompt name for ADSP memory window backend. If prompt is set,
642	  the shell will send two newlines during initialization.
643
644config SHELL_BACKEND_ADSP_MEMORY_WINDOW_POLL_INTERVAL
645	int "Poll interval (in microseconds)"
646	default 100
647	help
648	  This option can be used to modify the poll interval the backend uses
649	  to check for new commands.
650
651endif # SHELL_BACKEND_ADSP_MEMORY_WINDOW
652
653endif # SHELL_BACKENDS
654