* [PATCH 1/2] wic/bootimg-efi: Factor out some common bits @ 2022-07-30 8:24 Jan Kiszka 2022-07-30 8:24 ` [PATCH 2/2] wic/bootimg-efi: Add support for loading devicetree files Jan Kiszka 0 siblings, 1 reply; 4+ messages in thread From: Jan Kiszka @ 2022-07-30 8:24 UTC (permalink / raw) To: OE-core From: Jan Kiszka <jan.kiszka@siemens.com> The paths for configuring grub and systemd-boot have some common bits around copying the initrd files. This will even grow when adding dtb support. Factor this out into a class function. Along this, avoid evaluating 'create-unified-kernel-image' multiple times in do_configure_systemdboot and suppress a bogus warning about "Ignoring missing initrd" when it is turned on. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> --- scripts/lib/wic/plugins/source/bootimg-efi.py | 46 +++++++++---------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py index 0391aebdc8..aa76888c9b 100644 --- a/scripts/lib/wic/plugins/source/bootimg-efi.py +++ b/scripts/lib/wic/plugins/source/bootimg-efi.py @@ -34,6 +34,20 @@ class BootimgEFIPlugin(SourcePlugin): name = 'bootimg-efi' + @classmethod + def _copy_additional_files(cls, hdddir, initrd): + if initrd: + bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") + if not bootimg_dir: + raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") + + initrds = initrd.split(';') + for rd in initrds: + cp_cmd = "cp %s/%s %s" % (bootimg_dir, rd, hdddir) + exec_cmd(cp_cmd, True) + else: + logger.debug("Ignoring missing initrd") + @classmethod def do_configure_grubefi(cls, hdddir, creator, cr_workdir, source_params): """ @@ -54,17 +68,7 @@ class BootimgEFIPlugin(SourcePlugin): initrd = source_params.get('initrd') - if initrd: - bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") - if not bootimg_dir: - raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") - - initrds = initrd.split(';') - for rd in initrds: - cp_cmd = "cp %s/%s %s" % (bootimg_dir, rd, hdddir) - exec_cmd(cp_cmd, True) - else: - logger.debug("Ignoring missing initrd") + cls._copy_additional_files(hdddir, initrd) if not custom_cfg: # Create grub configuration using parameters from wks file @@ -119,25 +123,17 @@ class BootimgEFIPlugin(SourcePlugin): bootloader = creator.ks.bootloader + unified_image = source_params.get('create-unified-kernel-image') == "true" + loader_conf = "" - if source_params.get('create-unified-kernel-image') != "true": + if not unified_image: loader_conf += "default boot\n" loader_conf += "timeout %d\n" % bootloader.timeout initrd = source_params.get('initrd') - if initrd and source_params.get('create-unified-kernel-image') != "true": - # obviously we need to have a common common deploy var - bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") - if not bootimg_dir: - raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") - - initrds = initrd.split(';') - for rd in initrds: - cp_cmd = "cp %s/%s %s" % (bootimg_dir, rd, hdddir) - exec_cmd(cp_cmd, True) - else: - logger.debug("Ignoring missing initrd") + if not unified_image: + cls._copy_additional_files(hdddir, initrd) logger.debug("Writing systemd-boot config " "%s/hdd/boot/loader/loader.conf", cr_workdir) @@ -185,7 +181,7 @@ class BootimgEFIPlugin(SourcePlugin): for rd in initrds: boot_conf += "initrd /%s\n" % rd - if source_params.get('create-unified-kernel-image') != "true": + if not unified_image: logger.debug("Writing systemd-boot config " "%s/hdd/boot/loader/entries/boot.conf", cr_workdir) cfg = open("%s/hdd/boot/loader/entries/boot.conf" % cr_workdir, "w") -- 2.35.3 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] wic/bootimg-efi: Add support for loading devicetree files 2022-07-30 8:24 [PATCH 1/2] wic/bootimg-efi: Factor out some common bits Jan Kiszka @ 2022-07-30 8:24 ` Jan Kiszka 2022-08-01 14:12 ` [OE-core] " Luca Ceresoli 0 siblings, 1 reply; 4+ messages in thread From: Jan Kiszka @ 2022-07-30 8:24 UTC (permalink / raw) To: OE-core From: Jan Kiszka <jan.kiszka@siemens.com> 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). Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> --- scripts/lib/wic/plugins/source/bootimg-efi.py | 39 +++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py index aa76888c9b..eb48554e59 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): name = 'bootimg-efi' @classmethod - def _copy_additional_files(cls, hdddir, initrd): - if initrd: - bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") - if not bootimg_dir: - raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") + def _copy_additional_files(cls, hdddir, initrd, dtb): + bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") + if not bootimg_dir: + raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") + if initrd: initrds = initrd.split(';') for rd in initrds: cp_cmd = "cp %s/%s %s" % (bootimg_dir, rd, hdddir) @@ -48,6 +48,12 @@ class BootimgEFIPlugin(SourcePlugin): else: logger.debug("Ignoring missing initrd") + if dtb: + if ';' in dtb: + raise WicError("Only one DTB supported, exiting") + cp_cmd = "cp %s/%s %s" % (bootimg_dir, dtb, hdddir) + exec_cmd(cp_cmd, True) + @classmethod def do_configure_grubefi(cls, hdddir, creator, cr_workdir, source_params): """ @@ -67,8 +73,9 @@ class BootimgEFIPlugin(SourcePlugin): "get it from %s." % configfile) initrd = source_params.get('initrd') + dtb = source_params.get('dtb') - cls._copy_additional_files(hdddir, initrd) + cls._copy_additional_files(hdddir, initrd, dtb) if not custom_cfg: # Create grub configuration using parameters from wks file @@ -102,6 +109,9 @@ class BootimgEFIPlugin(SourcePlugin): grubefi_conf += " /%s" % rd grubefi_conf += "\n" + if dtb: + grubefi_conf += "devicetree /%s\n" % dtb + grubefi_conf += "}\n" logger.debug("Writing grubefi config %s/hdd/boot/EFI/BOOT/grub.cfg", @@ -131,9 +141,10 @@ class BootimgEFIPlugin(SourcePlugin): loader_conf += "timeout %d\n" % bootloader.timeout initrd = source_params.get('initrd') + dtb = source_params.get('dtb') if not unified_image: - cls._copy_additional_files(hdddir, initrd) + cls._copy_additional_files(hdddir, initrd, dtb) logger.debug("Writing systemd-boot config " "%s/hdd/boot/loader/loader.conf", cr_workdir) @@ -181,6 +192,9 @@ class BootimgEFIPlugin(SourcePlugin): for rd in initrds: boot_conf += "initrd /%s\n" % rd + if dtb: + boot_conf += "devicetree /%s\n" % dtb + if not unified_image: logger.debug("Writing systemd-boot config " "%s/hdd/boot/loader/entries/boot.conf", cr_workdir) @@ -316,6 +330,15 @@ class BootimgEFIPlugin(SourcePlugin): shutil.copyfileobj(in_file, initrd) initrd.close() + dtb = source_params.get('dtb') + if dtb: + if ';' in dtb: + raise WicError("Only one DTB supported, exiting") + dtb_params = '--add-section .dtb=%s/%s --change-section-vma .dtb=0x40000' % \ + (deploy_dir, dtb) + else: + dtb_params = '' + # Searched by systemd-boot: # https://systemd.io/BOOT_LOADER_SPECIFICATION/#type-2-efi-unified-kernel-images install_cmd = "install -d %s/EFI/Linux" % hdddir @@ -327,11 +350,13 @@ class BootimgEFIPlugin(SourcePlugin): objcopy_cmd = "objcopy \ --add-section .osrel=%s --change-section-vma .osrel=0x20000 \ --add-section .cmdline=%s --change-section-vma .cmdline=0x30000 \ + %s \ --add-section .linux=%s --change-section-vma .linux=0x2000000 \ --add-section .initrd=%s --change-section-vma .initrd=0x3000000 \ %s %s" % \ ("%s/usr/lib/os-release" % staging_dir_host, cmdline.name, + dtb_params, "%s/%s" % (staging_kernel_dir, kernel), initrd.name, efi_stub, -- 2.35.3 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [OE-core] [PATCH 2/2] wic/bootimg-efi: Add support for loading devicetree files 2022-07-30 8:24 ` [PATCH 2/2] wic/bootimg-efi: Add support for loading devicetree files Jan Kiszka @ 2022-08-01 14:12 ` Luca Ceresoli 2022-08-02 6:38 ` Jan Kiszka 0 siblings, 1 reply; 4+ messages in thread From: Luca Ceresoli @ 2022-08-01 14:12 UTC (permalink / raw) To: Jan Kiszka; +Cc: OE-core, Ross Burton Hello Jan, On Sat, 30 Jul 2022 10:24:43 +0200 "Jan Kiszka" <jan.kiszka@siemens.com> wrote: > From: Jan Kiszka <jan.kiszka@siemens.com> > > 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). > > Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> > --- [...] > @@ -327,11 +350,13 @@ class BootimgEFIPlugin(SourcePlugin): > objcopy_cmd = "objcopy \ > --add-section .osrel=%s --change-section-vma .osrel=0x20000 \ > --add-section .cmdline=%s --change-section-vma .cmdline=0x30000 \ > + %s \ > --add-section .linux=%s --change-section-vma .linux=0x2000000 \ > --add-section .initrd=%s --change-section-vma .initrd=0x3000000 \ > %s %s" % \ > ("%s/usr/lib/os-release" % staging_dir_host, > cmdline.name, > + dtb_params, > "%s/%s" % (staging_kernel_dir, kernel), > initrd.name, > efi_stub, This hunk conflicts with the changes introduced by [0], which is already in my testing branch. I have applied your patch with a little change to resolve the conflict, can you please have a look at the result [1] to ensure I correctly followed the logic of your patch? [0] https://lists.openembedded.org/g/openembedded-core/message/168553 [1] https://git.openembedded.org/openembedded-core-contrib/commit/?h=lucaceresoli/master-next&id=7547ec3e2065e55a8caa6118fc962130b8c6bd98 Best regards. -- Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [OE-core] [PATCH 2/2] wic/bootimg-efi: Add support for loading devicetree files 2022-08-01 14:12 ` [OE-core] " Luca Ceresoli @ 2022-08-02 6:38 ` Jan Kiszka 0 siblings, 0 replies; 4+ messages in thread From: Jan Kiszka @ 2022-08-02 6:38 UTC (permalink / raw) To: Luca Ceresoli; +Cc: OE-core, Ross Burton On 01.08.22 16:12, Luca Ceresoli wrote: > Hello Jan, > > On Sat, 30 Jul 2022 10:24:43 +0200 > "Jan Kiszka" <jan.kiszka@siemens.com> wrote: > >> From: Jan Kiszka <jan.kiszka@siemens.com> >> >> 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). >> >> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> >> --- > > [...] > >> @@ -327,11 +350,13 @@ class BootimgEFIPlugin(SourcePlugin): >> objcopy_cmd = "objcopy \ >> --add-section .osrel=%s --change-section-vma .osrel=0x20000 \ >> --add-section .cmdline=%s --change-section-vma .cmdline=0x30000 \ >> + %s \ >> --add-section .linux=%s --change-section-vma .linux=0x2000000 \ >> --add-section .initrd=%s --change-section-vma .initrd=0x3000000 \ >> %s %s" % \ >> ("%s/usr/lib/os-release" % staging_dir_host, >> cmdline.name, >> + dtb_params, >> "%s/%s" % (staging_kernel_dir, kernel), >> initrd.name, >> efi_stub, > > This hunk conflicts with the changes introduced by [0], which is > already in my testing branch. I have applied your patch with a little > change to resolve the conflict, can you please have a look at the result > [1] to ensure I correctly followed the logic of your patch? > > [0] https://lists.openembedded.org/g/openembedded-core/message/168553 > [1] > https://git.openembedded.org/openembedded-core-contrib/commit/?h=lucaceresoli/master-next&id=7547ec3e2065e55a8caa6118fc962130b8c6bd98 > > Best regards. Looks good, thanks! Jan -- Siemens AG, Technology Competence Center Embedded Linux ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-08-02 6:39 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-07-30 8:24 [PATCH 1/2] wic/bootimg-efi: Factor out some common bits Jan Kiszka 2022-07-30 8:24 ` [PATCH 2/2] wic/bootimg-efi: Add support for loading devicetree files Jan Kiszka 2022-08-01 14:12 ` [OE-core] " Luca Ceresoli 2022-08-02 6:38 ` Jan Kiszka
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.