From 931ff2107ecce00887258959bf3ed1fe16e84f90 Mon Sep 17 00:00:00 2001 From: Manuel Traut Date: Thu, 29 Feb 2024 16:00:13 +0100 Subject: [PATCH] Add support for embedding devicetree into UKI Resolves #2439 To easily use the dtbs provided with kernel packages allow specifying a devicetree name in mkosi. It can be passed as parameter to ukify. The dtb is typically installed by the kernel package. Signed-off-by: Manuel Traut --- mkosi/__init__.py | 5 +++++ mkosi/config.py | 8 ++++++++ tests/test_json.py | 2 ++ 3 files changed, 15 insertions(+) diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 74e20fe300..b7997806a5 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -1872,6 +1872,11 @@ def build_uki( "--ro-bind", stub, stub, ] + if context.config.devicetree: + dtb = context.root / f"usr/lib/linux-image-{kver}" / context.config.devicetree + cmd += ["--devicetree", dtb] + options += ["--ro-bind", dtb, dtb] + if context.config.secure_boot: assert context.config.secure_boot_key assert context.config.secure_boot_certificate diff --git a/mkosi/config.py b/mkosi/config.py index a82c301224..5a314508aa 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -1255,6 +1255,7 @@ class Config: initrds: list[Path] initrd_packages: list[str] microcode_host: bool + devicetree: Optional[Path] kernel_command_line: list[str] kernel_modules_include: list[str] kernel_modules_exclude: list[str] @@ -2134,6 +2135,12 @@ def parse_ini(path: Path, only_sections: Collection[str] = ()) -> Iterator[tuple parse=config_make_list_parser(delimiter=","), help="Add additional packages to the default initrd", ), + ConfigSetting( + dest="devicetree", + section="Content", + parse=config_parse_string, + help="Devicetree included in UKI", + ), ConfigSetting( dest="kernel_command_line", metavar="OPTIONS", @@ -3548,6 +3555,7 @@ def bold(s: Any) -> str: Shim Bootloader: {config.shim_bootloader} Initrds: {line_join_list(config.initrds)} Initrd Packages: {line_join_list(config.initrd_packages)} + Devicetree: {config.devicetree} Kernel Command Line: {line_join_list(config.kernel_command_line)} Kernel Modules Include: {line_join_list(config.kernel_modules_include)} Kernel Modules Exclude: {line_join_list(config.kernel_modules_exclude)} diff --git a/tests/test_json.py b/tests/test_json.py index 2d0f2b8802..d39141a585 100644 --- a/tests/test_json.py +++ b/tests/test_json.py @@ -145,6 +145,7 @@ def test_config() -> None: "/efi/initrd1", "/efi/initrd2" ], + "Devicetree": "freescale/imx8mm-verdin-nonwifi-dev.dtb", "KernelCommandLine": [], "KernelCommandLineExtra": [ "look", @@ -320,6 +321,7 @@ def test_config() -> None: compress_output = Compression.bz2, credentials = {"credkey": "credval"}, dependencies = ("dep1",), + devicetree = Path("freescale/imx8mm-verdin-nonwifi-dev.dtb"), distribution = Distribution.fedora, environment = {}, environment_files = [],