Skip to content

Commit

Permalink
Add support for embedding devicetree into UKI
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mt-at-mt authored and manut committed Mar 1, 2024
1 parent 5597b39 commit 931ff21
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mkosi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions mkosi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)}
Expand Down
2 changes: 2 additions & 0 deletions tests/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def test_config() -> None:
"/efi/initrd1",
"/efi/initrd2"
],
"Devicetree": "freescale/imx8mm-verdin-nonwifi-dev.dtb",
"KernelCommandLine": [],
"KernelCommandLineExtra": [
"look",
Expand Down Expand Up @@ -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 = [],
Expand Down

0 comments on commit 931ff21

Please sign in to comment.