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