1# Copyright (c) 2025, Nordic Semiconductor ASA
2# SPDX-License-Identifier: Apache-2.0
3
4config UART_NATIVE_PTY
5	bool "PTY based UART driver for native_sim"
6	default y
7	depends on (DT_HAS_ZEPHYR_NATIVE_PTY_UART_ENABLED || DT_HAS_ZEPHYR_NATIVE_POSIX_UART_ENABLED)
8	select SERIAL_HAS_DRIVER
9	select SERIAL_SUPPORT_ASYNC
10	select SERIAL_SUPPORT_INTERRUPT
11	help
12	  This enables a PTY based UART driver for the POSIX ARCH with up to 2 UARTs.
13	  For the first UART port, the driver can be configured
14	  to either connect to the terminal from which the executable was run, or into
15	  one dedicated pseudoterminal for that UART.
16
17config UART_NATIVE_POSIX
18	bool "UART driver for native_sim (deprecated)"
19	select SERIAL_HAS_DRIVER
20	select DEPRECATED
21	select UART_NATIVE_PTY
22	help
23	  Deprecated option, use UART_NATIVE_PTY instead
24
25if (UART_NATIVE_PTY || UART_NATIVE_POSIX)
26
27choice UART_NATIVE_PTY_0
28	prompt "Native PTY Port 0 connection"
29	default UART_NATIVE_PTY_0_ON_STDINOUT if NATIVE_UART_0_ON_STDINOUT
30	default UART_NATIVE_PTY_0_ON_OWN_PTY
31
32config UART_NATIVE_PTY_0_ON_OWN_PTY
33	bool "Connect the first PTY UART to its own pseudo terminal"
34	help
35	  Connect this UART to its own pseudoterminal. This is the preferred
36	  option for users who want to use Zephyr's shell.
37	  Moreover this option does not conflict with any other native
38	  backend which may use the invoking shell standard input/output.
39	  Note it can be overridden from command line
40
41config UART_NATIVE_PTY_0_ON_STDINOUT
42	bool "Connect the first PTY UART to the invoking shell stdin/stdout"
43	help
44	  Connect this UART to the stdin & stdout of the calling shell/terminal
45	  which invoked the native executable. This is good enough for
46	  automated testing, or when feeding from a file/pipe.
47	  Note that other, non UART messages, will also be printed to the
48	  terminal.
49	  It is strongly discouraged to try to use this option with the new
50	  shell interactively, as the default terminal configuration is NOT
51	  appropriate for interactive use.
52
53endchoice
54
55choice NATIVE_UART_0
56	prompt "Native UART Port 0 connection (deprecated)"
57	default NATIVE_UART_0_ON_OWN_PTY
58
59config NATIVE_UART_0_ON_OWN_PTY
60	bool "Connect the UART to its own pseudo terminal (deprecated)"
61	help
62	  Deprecated, use UART_NATIVE_PTY_0_ON_OWN_PTY instead.
63
64config NATIVE_UART_0_ON_STDINOUT
65	bool "Connect the UART to the invoking shell stdin/stdout (deprecated)"
66	select DEPRECATED
67	help
68	  Deprecated, use UART_NATIVE_PTY_0_ON_STDINOUT instead.
69
70endchoice
71
72config UART_NATIVE_WAIT_PTS_READY_ENABLE
73	bool "Support waiting for pseudo terminal client readiness (deprecated)"
74	select DEPRECATED
75	help
76	  This option is deprecated and does not do anything anymore. (The command line
77	  option --wait_uart is always available).
78
79config UART_NATIVE_POSIX_PORT_1_ENABLE
80	bool "Second UART port (deprecated)"
81	select DEPRECATED
82	help
83	  This option does not do anything anymore. Use DTS to instantiate as many
84	  "zephyr,native-pty-uart" compatible nodes as you want.
85
86config UART_NATIVE_PTY_AUTOATTACH_DEFAULT_CMD
87	string "Default command to attach a PTY UART to a new terminal"
88	default NATIVE_UART_AUTOATTACH_DEFAULT_CMD
89	help
90	  If the native executable is called with the --attach_uart
91	  command line option, this will be the default command which will be
92	  run to attach a new terminal to the 1st UART.
93	  Note that this command must have one, and only one, '%s' as
94	  placeholder for the pseudoterminal device name (e.g. /dev/pts/35)
95	  This is only applicable if the UART_0 is configured to use its own
96	  PTY with NATIVE_UART_0_ON_OWN_PTY.
97	  The 2nd UART will not be affected by this option.
98	  If you are using GNOME, then you can use this command string
99	  'gnome-terminal -- screen %s'
100
101config NATIVE_UART_AUTOATTACH_DEFAULT_CMD
102	string "Default command to attach the UART to a new terminal (deprecated)"
103	default "xterm -e screen %s &"
104	help
105	  Deprecated. Use UART_NATIVE_PTY_AUTOATTACH_DEFAULT_CMD instead
106
107endif # UART_NATIVE_PTY || UART_NATIVE_POSIX
108