From: Daan De Meyer Date: Wed, 13 Dec 2023 13:23:54 +0000 (+0100) Subject: Default to ttyAMA0 when building/booting arm images X-Git-Tag: v20~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7fe36d4c523e996c1906a7d9d6f04e28139aaadc;p=thirdparty%2Fmkosi.git Default to ttyAMA0 when building/booting arm images On ARM, the first serial console is generally called ttyAMA0, so let's configure that as the console instead of ttyS0. --- diff --git a/mkosi/architecture.py b/mkosi/architecture.py index f4388ea35..5f1cfe968 100644 --- a/mkosi/architecture.py +++ b/mkosi/architecture.py @@ -117,6 +117,12 @@ class Architecture(StrEnum): return a + def default_serial_tty(self) -> str: + return { + Architecture.arm : "ttyAMA0", + Architecture.arm64 : "ttyAMA0", + }.get(self, "ttyS0") + def supports_smbios(self) -> bool: return self in (Architecture.x86, Architecture.x86_64, Architecture.arm, Architecture.arm64) diff --git a/mkosi/config.py b/mkosi/config.py index 79323ba6e..927e8a413 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -402,6 +402,10 @@ def config_default_source_date_epoch(namespace: argparse.Namespace) -> Optional[ return config_parse_source_date_epoch(os.environ.get("SOURCE_DATE_EPOCH"), None) +def config_default_kernel_command_line(namespace: argparse.Namespace) -> list[str]: + return [f"console={namespace.architecture.default_serial_tty()}"] + + def make_enum_parser(type: type[enum.Enum]) -> Callable[[str], enum.Enum]: def parse_enum(value: str) -> enum.Enum: try: @@ -1736,7 +1740,8 @@ SETTINGS = ( metavar="OPTIONS", section="Content", parse=config_make_list_parser(delimiter=" "), - default=["console=ttyS0"], + default_factory_depends=("architecture",), + default_factory=config_default_kernel_command_line, help="Set the kernel command line (only bootable images)", ), MkosiConfigSetting( @@ -2798,15 +2803,16 @@ def load_credentials(args: argparse.Namespace) -> dict[str, str]: def load_kernel_command_line_extra(args: argparse.Namespace) -> list[str]: + tty = args.architecture.default_serial_tty() columns, lines = shutil.get_terminal_size() cmdline = [ # Make sure we set up networking in the VM/container. "systemd.wants=network.target", # Make sure we don't load vmw_vmci which messes with virtio vsock. "module_blacklist=vmw_vmci", - f"systemd.tty.term.ttyS0={os.getenv('TERM', 'vt220')}", - f"systemd.tty.columns.ttyS0={columns}", - f"systemd.tty.rows.ttyS0={lines}", + f"systemd.tty.term.{tty}={os.getenv('TERM', 'vt220')}", + f"systemd.tty.columns.{tty}={columns}", + f"systemd.tty.rows.{tty}={lines}", ] if not any(s.startswith("ip=") for s in args.kernel_command_line_extra): @@ -2828,7 +2834,7 @@ def load_kernel_command_line_extra(args: argparse.Namespace) -> list[str]: f"systemd.tty.term.console={os.getenv('TERM', 'vt220')}", f"systemd.tty.columns.console={columns}", f"systemd.tty.rows.console={lines}", - "console=ttyS0", + f"console={tty}", ] for s in args.kernel_command_line_extra: diff --git a/mkosi/distributions/fedora.py b/mkosi/distributions/fedora.py index 378eb2d4d..d9dd0774d 100644 --- a/mkosi/distributions/fedora.py +++ b/mkosi/distributions/fedora.py @@ -59,6 +59,7 @@ class Installer(DistributionInstaller): "pacman", "python3-cryptography", "qemu-kvm-core", + "qemu-system-aarch64-core", "shadow-utils", "socat", "squashfs-tools",