diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2022-07-30 10:24:43 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-02 11:30:00 +0100 |
commit | e0825355ae00b6d2aa5117a36b3490da5d5f645a (patch) | |
tree | 9b430587f5af78281c2d8e00346620ea17fb6a6b /scripts/lib/wic/plugins | |
parent | be0ca8e685cb8aa6eb408147323f951635c8df0f (diff) | |
download | poky-e0825355ae00b6d2aa5117a36b3490da5d5f645a.tar.gz |
wic/bootimg-efi: Add support for loading devicetree files
For device tree using systems, add support to set a custom devices tree
during UEFI boot. This requires to copy the DTB file to the boot
partition and to add the respective loader entries to the configuration
files.
Both grub and systemd-boot support only loading a specific device tree.
Therefore refuse to work if the 'dtb' parameter contains more than one
entry.
Out of scope for now are overlays (only supported by systemd-boot).
(From OE-Core rev: c5a14f39a6717a99b510cb97aa2fb403d4b98d99)
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
[Luca: rebased on commit 98e9d435b278 ("wic/bootimg-efi: use cross objcopy when building unified kernel image")]
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic/plugins')
-rw-r--r-- | scripts/lib/wic/plugins/source/bootimg-efi.py | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py index 57e79f4516..634a808d78 100644 --- a/scripts/lib/wic/plugins/source/bootimg-efi.py +++ b/scripts/lib/wic/plugins/source/bootimg-efi.py | |||
@@ -35,12 +35,12 @@ class BootimgEFIPlugin(SourcePlugin): | |||
35 | name = 'bootimg-efi' | 35 | name = 'bootimg-efi' |
36 | 36 | ||
37 | @classmethod | 37 | @classmethod |
38 | def _copy_additional_files(cls, hdddir, initrd): | 38 | def _copy_additional_files(cls, hdddir, initrd, dtb): |
39 | if initrd: | 39 | bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") |
40 | bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") | 40 | if not bootimg_dir: |
41 | if not bootimg_dir: | 41 | raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") |
42 | raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") | ||
43 | 42 | ||
43 | if initrd: | ||
44 | initrds = initrd.split(';') | 44 | initrds = initrd.split(';') |
45 | for rd in initrds: | 45 | for rd in initrds: |
46 | cp_cmd = "cp %s/%s %s" % (bootimg_dir, rd, hdddir) | 46 | cp_cmd = "cp %s/%s %s" % (bootimg_dir, rd, hdddir) |
@@ -48,6 +48,12 @@ class BootimgEFIPlugin(SourcePlugin): | |||
48 | else: | 48 | else: |
49 | logger.debug("Ignoring missing initrd") | 49 | logger.debug("Ignoring missing initrd") |
50 | 50 | ||
51 | if dtb: | ||
52 | if ';' in dtb: | ||
53 | raise WicError("Only one DTB supported, exiting") | ||
54 | cp_cmd = "cp %s/%s %s" % (bootimg_dir, dtb, hdddir) | ||
55 | exec_cmd(cp_cmd, True) | ||
56 | |||
51 | @classmethod | 57 | @classmethod |
52 | def do_configure_grubefi(cls, hdddir, creator, cr_workdir, source_params): | 58 | def do_configure_grubefi(cls, hdddir, creator, cr_workdir, source_params): |
53 | """ | 59 | """ |
@@ -67,8 +73,9 @@ class BootimgEFIPlugin(SourcePlugin): | |||
67 | "get it from %s." % configfile) | 73 | "get it from %s." % configfile) |
68 | 74 | ||
69 | initrd = source_params.get('initrd') | 75 | initrd = source_params.get('initrd') |
76 | dtb = source_params.get('dtb') | ||
70 | 77 | ||
71 | cls._copy_additional_files(hdddir, initrd) | 78 | cls._copy_additional_files(hdddir, initrd, dtb) |
72 | 79 | ||
73 | if not custom_cfg: | 80 | if not custom_cfg: |
74 | # Create grub configuration using parameters from wks file | 81 | # Create grub configuration using parameters from wks file |
@@ -102,6 +109,9 @@ class BootimgEFIPlugin(SourcePlugin): | |||
102 | grubefi_conf += " /%s" % rd | 109 | grubefi_conf += " /%s" % rd |
103 | grubefi_conf += "\n" | 110 | grubefi_conf += "\n" |
104 | 111 | ||
112 | if dtb: | ||
113 | grubefi_conf += "devicetree /%s\n" % dtb | ||
114 | |||
105 | grubefi_conf += "}\n" | 115 | grubefi_conf += "}\n" |
106 | 116 | ||
107 | logger.debug("Writing grubefi config %s/hdd/boot/EFI/BOOT/grub.cfg", | 117 | logger.debug("Writing grubefi config %s/hdd/boot/EFI/BOOT/grub.cfg", |
@@ -131,9 +141,10 @@ class BootimgEFIPlugin(SourcePlugin): | |||
131 | loader_conf += "timeout %d\n" % bootloader.timeout | 141 | loader_conf += "timeout %d\n" % bootloader.timeout |
132 | 142 | ||
133 | initrd = source_params.get('initrd') | 143 | initrd = source_params.get('initrd') |
144 | dtb = source_params.get('dtb') | ||
134 | 145 | ||
135 | if not unified_image: | 146 | if not unified_image: |
136 | cls._copy_additional_files(hdddir, initrd) | 147 | cls._copy_additional_files(hdddir, initrd, dtb) |
137 | 148 | ||
138 | logger.debug("Writing systemd-boot config " | 149 | logger.debug("Writing systemd-boot config " |
139 | "%s/hdd/boot/loader/loader.conf", cr_workdir) | 150 | "%s/hdd/boot/loader/loader.conf", cr_workdir) |
@@ -181,6 +192,9 @@ class BootimgEFIPlugin(SourcePlugin): | |||
181 | for rd in initrds: | 192 | for rd in initrds: |
182 | boot_conf += "initrd /%s\n" % rd | 193 | boot_conf += "initrd /%s\n" % rd |
183 | 194 | ||
195 | if dtb: | ||
196 | boot_conf += "devicetree /%s\n" % dtb | ||
197 | |||
184 | if not unified_image: | 198 | if not unified_image: |
185 | logger.debug("Writing systemd-boot config " | 199 | logger.debug("Writing systemd-boot config " |
186 | "%s/hdd/boot/loader/entries/boot.conf", cr_workdir) | 200 | "%s/hdd/boot/loader/entries/boot.conf", cr_workdir) |
@@ -316,6 +330,15 @@ class BootimgEFIPlugin(SourcePlugin): | |||
316 | shutil.copyfileobj(in_file, initrd) | 330 | shutil.copyfileobj(in_file, initrd) |
317 | initrd.close() | 331 | initrd.close() |
318 | 332 | ||
333 | dtb = source_params.get('dtb') | ||
334 | if dtb: | ||
335 | if ';' in dtb: | ||
336 | raise WicError("Only one DTB supported, exiting") | ||
337 | dtb_params = '--add-section .dtb=%s/%s --change-section-vma .dtb=0x40000' % \ | ||
338 | (deploy_dir, dtb) | ||
339 | else: | ||
340 | dtb_params = '' | ||
341 | |||
319 | # Searched by systemd-boot: | 342 | # Searched by systemd-boot: |
320 | # https://systemd.io/BOOT_LOADER_SPECIFICATION/#type-2-efi-unified-kernel-images | 343 | # https://systemd.io/BOOT_LOADER_SPECIFICATION/#type-2-efi-unified-kernel-images |
321 | install_cmd = "install -d %s/EFI/Linux" % hdddir | 344 | install_cmd = "install -d %s/EFI/Linux" % hdddir |
@@ -330,6 +353,7 @@ class BootimgEFIPlugin(SourcePlugin): | |||
330 | objcopy_cmd += " --change-section-vma .osrel=0x20000" | 353 | objcopy_cmd += " --change-section-vma .osrel=0x20000" |
331 | objcopy_cmd += " --add-section .cmdline=%s" % cmdline.name | 354 | objcopy_cmd += " --add-section .cmdline=%s" % cmdline.name |
332 | objcopy_cmd += " --change-section-vma .cmdline=0x30000" | 355 | objcopy_cmd += " --change-section-vma .cmdline=0x30000" |
356 | objcopy_cmd += dtb_params | ||
333 | objcopy_cmd += " --add-section .linux=%s/%s" % (staging_kernel_dir, kernel) | 357 | objcopy_cmd += " --add-section .linux=%s/%s" % (staging_kernel_dir, kernel) |
334 | objcopy_cmd += " --change-section-vma .linux=0x2000000" | 358 | objcopy_cmd += " --change-section-vma .linux=0x2000000" |
335 | objcopy_cmd += " --add-section .initrd=%s" % initrd.name | 359 | objcopy_cmd += " --add-section .initrd=%s" % initrd.name |