[PATCH 2/3] scripts/runfvp: add Screen support
Gyorgy Szing <[email protected]> Thu, 23 Apr 2026 17:37:20 +0200
| Newsgroups | org.yoctoproject.lists.meta-arm |
|---|---|
| Message-ID | <[email protected]> |
Add support for Screen the GNU terminal multiplexer. The -t/--terminal option now accepts "screen" as a terminal type. When selected, the tool must be run from within an existing Screen session, and each FVP terminal is opened in a new Screen window. Signed-off-by: Gyorgy Szing <[email protected]> --- documentation/runfvp.md | 3 +++ meta-arm/lib/fvp/terminal.py | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/documentation/runfvp.md b/documentation/runfvp.md index aed99971..8c9b5f40 100644 --- a/documentation/runfvp.md +++ b/documentation/runfvp.md @@ -33,6 +33,8 @@ The tool attempts to automatically select a suitable te= rminal type. To see which `runfvp` determines availability by checking for required executables in= your PATH as well as environment variables specific to each terminal typ= e. If any of these checks fail, the corresponding terminal type is disabl= ed. The --help output also lists all currently available terminal types. =20 +When using `-terminals=3Dscreen`, `runfvp` must be launched from within = an existing [`screen`][screen] session. Normally, screen sets the `STY` e= nvironment variable to reference the current session. However, if the ses= sion is renamed or if `kas` is started from within the screen session, th= is value may become invalid or be lost. In such cases, `STY` must be set = manually. Use `screen -ls` to view the list of currently attached session= s. + The default terminal can also be configured by writing a [INI-style][INI= ] configuration file to `~/.config/runfvp.conf`: =20 ``` @@ -144,3 +146,4 @@ FVP_ENV_PASSTHROUGH =3D "ARMLMD_LICENSE_FILE FM_TRACE= _PLUGINS" [FVP]: https://developer.arm.com/tools-and-software/simulation-models/fi= xed-virtual-platforms [tmux]: https://tmux.github.io/ [INI]: https://docs.python.org/3/library/configparser.html +[screen]: https://www.gnu.org/software/screen/ diff --git a/meta-arm/lib/fvp/terminal.py b/meta-arm/lib/fvp/terminal.py index c0087fa1..fb6050d6 100644 --- a/meta-arm/lib/fvp/terminal.py +++ b/meta-arm/lib/fvp/terminal.py @@ -1,4 +1,3 @@ -import shutil import collections import pathlib import os @@ -37,6 +36,20 @@ def check_executable(*cmd) -> bool: return exitcode =3D=3D 0 =20 =20 +def screen_is_ready(*, silent: bool =3D False) -> bool: + log_print =3D (lambda *_args, **_kwargs: None) if silent else logger= .error + + if not check_executable("screen", "--version"): + log_print("--terminal screen requires screen to be available and= runnable, but startup failed.") + return False + + if not os.environ.get("STY"): + log_print("--terminal screen requires runfvp to be started from = a screen session.\n\tEnsure $STY is set in the environment.") + return False + + return True + + def tmux_is_ready(*, silent: bool =3D False) -> bool: log_print =3D (lambda *_args, **_kwargs: None) if silent else logger= .error =20 @@ -126,6 +139,8 @@ class Terminals: terminals =3D Terminals() # TODO: option to switch between telnet and netcat connect_command =3D "telnet localhost %port" +sty =3D os.environ.get("STY") +terminals.add_terminal(2, "screen", f'screen -S "{sty}" -X screen -t "{{= name}} - %title" -L {connect_command}', screen_is_ready) terminals.add_terminal(2, "tmux", f'tmux new-window -n "{{name}}" "{conn= ect_command}"', tmux_is_ready) terminals.add_terminal(2, "gnome-terminal", f'gnome-terminal --window --= title "{{name}} - %title" --command "{connect_command}"', gterm_is_ready) terminals.add_terminal(1, "xterm", f'xterm -title "{{name}} - %title" -e= {connect_command}', xterm_is_ready) --=20 2.43.0