return kmods
+def find_devicetree(context: Context, kver: str) -> Path:
+ assert context.config.devicetree
+
+ for d in (
+ context.root / f"usr/lib/firmware/{kver}/device-tree",
+ context.root / f"usr/lib/linux-image-{kver}",
+ context.root / f"usr/lib/modules/{kver}/dtb",
+ ):
+ dtb = d / context.config.devicetree
+ if dtb.exists():
+ return dtb
+
+ die(f"Requested devicetree {context.config.devicetree} not found")
+
+
def join_initrds(initrds: Sequence[Path], output: Path) -> Path:
assert initrds
*flatten(["--ro-bind", os.fspath(profile), os.fspath(workdir(profile))] for profile in profiles),
] # fmt: skip
+ if context.config.devicetree:
+ dtb = find_devicetree(context, kver)
+ arguments += ["--devicetree", workdir(dtb)]
+ options += ["--ro-bind", dtb, workdir(dtb)]
+
if context.config.secure_boot:
assert context.config.secure_boot_key
assert context.config.secure_boot_certificate
kmods = build_kernel_modules_initrd(context, kver)
+ dtb = None
+ if context.config.devicetree:
+ dtb = dst / context.config.devicetree
+ with umask(~0o700):
+ dtb.parent.mkdir(parents=True, exist_ok=True)
+
with umask(~0o600):
if (
want_efi(context.config)
]
initrds += [Path(shutil.copy2(kmods, dst / "kernel-modules.initrd"))]
+ if dtb:
+ shutil.copy2(find_devicetree(context, kver), dtb)
+
with entry.open("w") as f:
f.write(
textwrap.dedent(
for initrd in initrds:
f.write(f"initrd /{initrd.relative_to(context.root / 'boot')}\n")
+ if dtb:
+ f.write(f"devicetree /{dtb.relative_to(context.root / 'boot')}\n")
+
if want_grub_efi(context) or want_grub_bios(context, partitions):
config = prepare_grub_config(context)
assert config
initrd_packages: list[str]
initrd_volatile_packages: list[str]
microcode_host: bool
+ devicetree: Optional[Path]
kernel_command_line: list[str]
kernel_modules_include: list[str]
kernel_modules_exclude: list[str]
parse=config_make_list_parser(delimiter=","),
help="Packages to install in the initrd that are not cached",
),
+ ConfigSetting(
+ dest="devicetree",
+ section="Content",
+ parse=config_parse_string,
+ help="Devicetree to be used by the booting kernel",
+ ),
ConfigSetting(
dest="kernel_command_line",
metavar="OPTIONS",
Initrds: {line_join_list(config.initrds)}
Initrd Packages: {line_join_list(config.initrd_packages)}
Initrd Volatile Packages: {line_join_list(config.initrd_volatile_packages)}
+ Devicetree: {none_to_none(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)}
: Similar to `VolatilePackages=`, except it applies to the default
initrd.
+`Devicetree=`, `--devicetree=`
+: When set, specifies a Devicetree blob to be used by the booting system,
+ instead of the one provided by firmware. **mkosi** will search for the
+ specified file relative to common paths where Linux distributions install
+ Devicetree files. It should typically have the format `<vendor>/<board>.dtb`.
+
`MicrocodeHost=`, `--microcode-host=`
: When set to true only include microcode for the host's CPU in the image.
"Dependencies": [
"dep1"
],
+ "Devicetree": "freescale/imx8mm-verdin-nonwifi-dev.dtb",
"Distribution": "fedora",
"Drives": [
{
make_initrd=False,
manifest_format=[ManifestFormat.json, ManifestFormat.changelog],
microcode_host=True,
+ devicetree=Path("freescale/imx8mm-verdin-nonwifi-dev.dtb"),
minimum_version=GenericVersion("123"),
mirror=None,
nspawn_settings=None,