From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7128466769373560832 X-Received: by 2002:a05:6000:381:b0:221:7542:61bb with SMTP id u1-20020a056000038100b00221754261bbmr2309652wrf.305.1659725507953; Fri, 05 Aug 2022 11:51:47 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:adf:d236:0:b0:21e:e644:c8 with SMTP id k22-20020adfd236000000b0021ee64400c8ls8128728wrh.3.-pod-prod-gmail; Fri, 05 Aug 2022 11:51:46 -0700 (PDT) X-Google-Smtp-Source: AA6agR5NiQJFCiyxmR2hYbDs2ZdOSwJzuFLy8DOF1gvtU/6PtMuElhHmHJ4eZ/qS2YihWcQkLyD6 X-Received: by 2002:a5d:4f86:0:b0:21e:f78b:33f1 with SMTP id d6-20020a5d4f86000000b0021ef78b33f1mr5377807wru.38.1659725506884; Fri, 05 Aug 2022 11:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659725506; cv=none; d=google.com; s=arc-20160816; b=fhIxf8t0rmBcShhlPvQroCNhkVfUtXThCvd1n7BrbyahNah7BH1PwSyXs68F1R1aOy BCAQxlssm+Lr742TSLN2ACg3tm0g8PLjLQOnmlCftNpTx1vGXOgzzdRMbxcadrMpqj0w 3TijkR6Eud8fy7qhdIWhVxCNh0FoCc9am+IYZkfJys/TlzEEnT1qyO4buw2Bt54xkeet BQ+TL9VdMYCLykK4W/QmsjTS2/TAUtu0vLi4MJHGN/AUSIsCZdiUE6PSYkqqzc5Rvp4G DVCgVatCs9Eusb943eoDAr40lcyyXz1zXjhwAuu12N1Bl/1T+GCP6M6/ag8MmJa7vXYm II4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=feedback-id:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=Jz6AZTxlII3bfuknHqmrq/+8axVCZJFQ6kcpvZvSh24=; b=tL293bGDyZidpDoHWdXLA0F/p+mfejL8NU4+aSSGJ30TV14KsZH0uiU5tpDkm7f3xE Lv6CE27qjBN11e8mnG9zkGRAGRuyAuM0FbvzwQ1FN1rPdeui8LGoW2KzqusSIl668kdW AqGmsUwpp6iBEIUsKkGmGXLO0Ox/4g8aVOtVy+lfVRPGu/6HSBkPwVr27fFHhQfpvTQR nuxGUg8VrsTarSw0qDtQjgbZr0dA/m9PW5oOCP54aLRRrrtTeRwfgk+NS9AfWKfz4LYw APbGdSF+s4bjSiYqwczKm6z6QOyxaL9vJIx4Ds590cJt17IiOHwL7taQr9r0GtBEzDij Snow== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=F844qnNv; spf=pass (google.com: domain of fm-294854-202208051851460830672839c727f8ab-gs2waq@rts-flowmailer.siemens.com designates 185.136.65.227 as permitted sender) smtp.mailfrom=fm-294854-202208051851460830672839c727f8ab-Gs2WAq@rts-flowmailer.siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from mta-65-227.siemens.flowmailer.net (mta-65-227.siemens.flowmailer.net. [185.136.65.227]) by gmr-mx.google.com with ESMTPS id 189-20020a1c19c6000000b003a31bb11cdfsi470323wmz.2.2022.08.05.11.51.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Aug 2022 11:51:46 -0700 (PDT) Received-SPF: pass (google.com: domain of fm-294854-202208051851460830672839c727f8ab-gs2waq@rts-flowmailer.siemens.com designates 185.136.65.227 as permitted sender) client-ip=185.136.65.227; Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=F844qnNv; spf=pass (google.com: domain of fm-294854-202208051851460830672839c727f8ab-gs2waq@rts-flowmailer.siemens.com designates 185.136.65.227 as permitted sender) smtp.mailfrom=fm-294854-202208051851460830672839c727f8ab-Gs2WAq@rts-flowmailer.siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: by mta-65-227.siemens.flowmailer.net with ESMTPSA id 202208051851460830672839c727f8ab for ; Fri, 05 Aug 2022 20:51:46 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm2; d=siemens.com; i=jan.kiszka@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=Jz6AZTxlII3bfuknHqmrq/+8axVCZJFQ6kcpvZvSh24=; b=F844qnNvDtU/Uj4WaJVhZflSmj/3dBa8mpkAOt0BH2EbScsfyip03YtgzvfHHes/KvXtzr HXbzUfJjJhYJ9i+pjr4OYwn3wqj12aw8C6MP43ofZsE+gwAjpr4iPvkApRVN0/BsBW7LjPd5 CYgkZ0vsgh3rWzPDbwko7Kc/z4aoU=; From: Jan Kiszka To: isar-users Cc: Henning Schild Subject: [PATCH 9/9] wic: bootimg-efi-isar: Sync with latest upstream changes Date: Fri, 5 Aug 2022 20:51:44 +0200 Message-Id: <8341c6f1875328531a6c50cf9724a856d71d3e90.1659725504.git.jan.kiszka@siemens.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-294854:519-21489:flowmailer X-TUID: vJ+8e8KbFHrZ From: Jan Kiszka Specifically brings in DTB support for grub and systemd-boot. It also changes the generation of unified kernel images in a way that is definitely not compatible with Isar. Not sure if this feature was used before (isar-cip-core uses EFI Boot Guard for that purpose), but it's still patched here to not call non-existing objcopy binaries, just in case. Signed-off-by: Jan Kiszka --- .../wic/plugins/source/bootimg-efi-isar.py | 97 +++++++++++-------- 1 file changed, 59 insertions(+), 38 deletions(-) diff --git a/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py b/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py index a24e04f3..6e6cd6ec 100644 --- a/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py +++ b/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py @@ -40,6 +40,26 @@ class BootimgEFIPlugin(SourcePlugin): name = 'bootimg-efi-isar' + @classmethod + 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) + exec_cmd(cp_cmd, True) + 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): """ @@ -59,18 +79,9 @@ class BootimgEFIPlugin(SourcePlugin): "get it from %s." % configfile) initrd = source_params.get('initrd') + dtb = source_params.get('dtb') - 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, dtb) if not custom_cfg: # Create grub configuration using parameters from wks file @@ -108,6 +119,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", @@ -129,25 +143,18 @@ 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') + dtb = source_params.get('dtb') - 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, dtb) logger.debug("Writing systemd-boot config " "%s/hdd/boot/loader/loader.conf", cr_workdir) @@ -197,7 +204,10 @@ class BootimgEFIPlugin(SourcePlugin): for rd in initrds: boot_conf += "initrd /%s\n" % rd - if source_params.get('create-unified-kernel-image') != "true": + 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) cfg = open("%s/hdd/boot/loader/entries/boot.conf" % cr_workdir, "w") @@ -332,27 +342,38 @@ 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 exec_cmd(install_cmd) staging_dir_host = get_bitbake_var("STAGING_DIR_HOST") + target_sys = get_bitbake_var("TARGET_SYS") # https://www.freedesktop.org/software/systemd/man/systemd-stub.html - objcopy_cmd = "objcopy \ - --add-section .osrel=%s --change-section-vma .osrel=0x20000 \ - --add-section .cmdline=%s --change-section-vma .cmdline=0x30000 \ - --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, - "%s/%s" % (staging_kernel_dir, kernel), - initrd.name, - efi_stub, - "%s/EFI/Linux/linux.efi" % hdddir) - exec_cmd(objcopy_cmd) + objcopy_cmd = "%s-objcopy" % target_sys + # Isar runs this natively + objcopy_cmd = "objcopy" + objcopy_cmd += " --add-section .osrel=%s/usr/lib/os-release" % staging_dir_host + objcopy_cmd += " --change-section-vma .osrel=0x20000" + objcopy_cmd += " --add-section .cmdline=%s" % cmdline.name + objcopy_cmd += " --change-section-vma .cmdline=0x30000" + objcopy_cmd += dtb_params + objcopy_cmd += " --add-section .linux=%s/%s" % (staging_kernel_dir, kernel) + objcopy_cmd += " --change-section-vma .linux=0x2000000" + objcopy_cmd += " --add-section .initrd=%s" % initrd.name + objcopy_cmd += " --change-section-vma .initrd=0x3000000" + objcopy_cmd += " %s %s/EFI/Linux/linux.efi" % (efi_stub, hdddir) + exec_native_cmd(objcopy_cmd, native_sysroot) else: install_cmd = "install -m 0644 %s/%s %s/%s" % \ (staging_kernel_dir, kernel, hdddir, kernel) -- 2.35.3