From patchwork Mon Jun 2 07:56:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Freihofer, Adrian" X-Patchwork-Id: 64082 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E969C71137 for ; Mon, 2 Jun 2025 07:57:34 +0000 (UTC) Received: from mta-65-225.siemens.flowmailer.net (mta-65-225.siemens.flowmailer.net [185.136.65.225]) by mx.groups.io with SMTP id smtpd.web11.44197.1748851049082500892 for ; Mon, 02 Jun 2025 00:57:30 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=adrian.freihofer@siemens.com header.s=fm2 header.b=ZLo417i/; spf=pass (domain: rts-flowmailer.siemens.com, ip: 185.136.65.225, mailfrom: fm-1329275-20250602075726a80d319c034d63105f-weom9_@rts-flowmailer.siemens.com) Received: by mta-65-225.siemens.flowmailer.net with ESMTPSA id 20250602075726a80d319c034d63105f for ; Mon, 02 Jun 2025 09:57:26 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm2; d=siemens.com; i=adrian.freihofer@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=FwYPLh2/Vfhxj8SVsKjpaNDozZDzFZDwy8ZJHJZFqGs=; b=ZLo417i/PY/MlHvTWGkHqniZSxBoS6J9vAx3VtQcdbLC9vMo516xqL7fiQbIu8mxUeHLMN 6pi2L5WTWROD1mn/EdXViaoCxG8b1Wh8GjXdosKLgyAFen8cEJHfKqAdkiOL5rvFRKMA5I8J CsJqAAX2CGqcPxJCOLfs4H5w2+c7uo8drAfyhB7crxA1jzusALBvRVpSG9Agls2HQJk7tQPZ PTp3LHRZvVqqxK0DTRcohrMzVmlyHSRXuuro6V8R0bmD/99/X22SxiPtEaLfRX7eqTXOcfCx n6UAv1M9FchpQS1TIxLj9rZ0oIYCm4DtSqpUTwKnyzU52YTQyC2sW4Mg==; From: AdrianF To: openembedded-core@lists.openembedded.org Cc: marex@denx.de, a.fatoum@pengutronix.de, Adrian Freihofer Subject: [PATCH v6 03/21] oe-selftest: fitimage: test external dtb Date: Mon, 2 Jun 2025 09:56:13 +0200 Message-ID: <20250602075714.32122-4-adrian.freihofer@siemens.com> In-Reply-To: <20250602075714.32122-1-adrian.freihofer@siemens.com> References: <20250602075714.32122-1-adrian.freihofer@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1329275:519-21489:flowmailer List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 02 Jun 2025 07:57:34 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/217690 From: Adrian Freihofer There are several ways to insert external devicetrees and devicetree overlays into the kernel and thus at least to some extent into the FIT image. So far there is no test coverage. Let's improve this as much as possible without fully understanding all use cases. This first test adds a devicetree overlay to a build configuration without signing, since signing is apparently not yet meaningful when PREFERRED_PROVIDER_virtual/dtb = “bborg-relay-00a2” is used. It is also not entirely clear how these external devicetree overlays are used by the configuration nodes of the FIT image. Currently, one configuration is created per dtb dtbo node, which is not really useful for dtbo nodes. Before this test can be extended to test devicetree overlays and signing, the code that creates the configuration nodes in its file probably needs some improvements in terms of more flexibility in defining the references from configuration nodes to image nodes. Signed-off-by: Adrian Freihofer --- meta/lib/oeqa/selftest/cases/fitimage.py | 73 ++++++++++++++++++++---- 1 file changed, 61 insertions(+), 12 deletions(-) diff --git a/meta/lib/oeqa/selftest/cases/fitimage.py b/meta/lib/oeqa/selftest/cases/fitimage.py index b39f2622dff..31116979ef7 100644 --- a/meta/lib/oeqa/selftest/cases/fitimage.py +++ b/meta/lib/oeqa/selftest/cases/fitimage.py @@ -161,10 +161,23 @@ class FitImageTestCase(OESelftestTestCase): @staticmethod def _get_dtb_files(bb_vars): + """Return a list of devicetree names + + The list should be used to check the dtb and conf nodes in the FIT image or its file. + In addition to the entries from KERNEL_DEVICETREE, the external devicetree and the + external devicetree overlay added by the test recipe bbb-dtbs-as-ext are handled as well. + """ kernel_devicetree = bb_vars.get('KERNEL_DEVICETREE') + all_dtbs = [] + dtb_symlinks = [] if kernel_devicetree: - return [os.path.basename(dtb) for dtb in kernel_devicetree.split()] - return [] + all_dtbs += [os.path.basename(dtb) for dtb in kernel_devicetree.split()] + # Support only the test recipe which provides 1 devicetree and 1 devicetree overlay + pref_prov_dtb = bb_vars.get('PREFERRED_PROVIDER_virtual/dtb') + if pref_prov_dtb == "bbb-dtbs-as-ext": + all_dtbs += ["am335x-bonegreen-ext.dtb", "BBORG_RELAY-00A2.dtbo"] + dtb_symlinks.append("am335x-bonegreen-ext-alias.dtb") + return (all_dtbs, dtb_symlinks) def _is_req_dict_in_dict(self, found_dict, req_dict): """ @@ -379,6 +392,7 @@ class KernelFitImageTests(FitImageTestCase): 'KERNEL_DEVICETREE', 'KERNEL_FIT_LINK_NAME', 'MACHINE', + 'PREFERRED_PROVIDER_virtual/dtb', 'UBOOT_ARCH', 'UBOOT_ENTRYPOINT', 'UBOOT_LOADADDRESS', @@ -452,7 +466,7 @@ class KernelFitImageTests(FitImageTestCase): ['/', 'images', 'kernel-1', 'signature-1'], ] """ - dtb_files = FitImageTestCase._get_dtb_files(bb_vars) + dtb_files, dtb_symlinks = FitImageTestCase._get_dtb_files(bb_vars) fit_sign_individual = bb_vars['FIT_SIGN_INDIVIDUAL'] fit_uboot_env = bb_vars['FIT_UBOOT_ENV'] initramfs_image = bb_vars['INITRAMFS_IMAGE'] @@ -470,9 +484,9 @@ class KernelFitImageTests(FitImageTestCase): if initramfs_image and initramfs_image_bundle != "1": images.append('ramdisk-1') - # configuration nodes + # configuration nodes (one per DTB and also one per symlink) if dtb_files: - configurations = [ 'conf-' + conf for conf in dtb_files ] + configurations = [ 'conf-' + conf for conf in dtb_files + dtb_symlinks] else: configurations = [ 'conf-1' ] @@ -548,7 +562,7 @@ class KernelFitImageTests(FitImageTestCase): def _get_req_sections(self, bb_vars): """Generate a dictionary of expected sections in the output of dumpimage""" - dtb_files = FitImageTestCase._get_dtb_files(bb_vars) + dtb_files, dtb_symlinks = FitImageTestCase._get_dtb_files(bb_vars) fit_hash_alg = bb_vars['FIT_HASH_ALG'] fit_sign_alg = bb_vars['FIT_SIGN_ALG'] fit_sign_individual = bb_vars['FIT_SIGN_INDIVIDUAL'] @@ -584,11 +598,20 @@ class KernelFitImageTests(FitImageTestCase): } # Create a configuration section for each DTB if dtb_files: - for dtb in dtb_files: - req_sections['conf-' + dtb] = { - "Kernel": "kernel-1", - "FDT": 'fdt-' + dtb, - } + for dtb in dtb_files + dtb_symlinks: + # Assume that DTBs with an "-alias" in its name are symlink DTBs created e.g. by the + # bbb-dtbs-as-ext test recipe. Make the configuration node pointing to the real DTB. + real_dtb = dtb.replace("-alias", "") + # dtb overlays do not refer to a kernel (yet?) + if dtb.endswith('.dtbo'): + req_sections['conf-' + dtb] = { + "FDT": 'fdt-' + real_dtb, + } + else: + req_sections['conf-' + dtb] = { + "Kernel": "kernel-1", + "FDT": 'fdt-' + real_dtb, + } if initramfs_image and initramfs_image_bundle != "1": req_sections['conf-' + dtb]['Init Ramdisk'] = "ramdisk-1" else: @@ -635,7 +658,12 @@ class KernelFitImageTests(FitImageTestCase): self.assertEqual(sign_algo, req_sign_algo, 'Signature algorithm for %s not expected value' % section) sign_value = values.get('Sign value', None) self.assertEqual(len(sign_value), fit_sign_alg_len, 'Signature value for section %s not expected length' % section) - dtb_path = os.path.join(deploy_dir_image, section.replace('conf-', '')) + dtb_file_name = section.replace('conf-', '') + dtb_path = os.path.join(deploy_dir_image, dtb_file_name) + # External devicetrees created by devicetree.bbclass are in a subfolder and have priority + dtb_path_ext = os.path.join(deploy_dir_image, "devicetree", dtb_file_name) + if os.path.exists(dtb_path_ext): + dtb_path = dtb_path_ext self._verify_fit_image_signature(uboot_tools_bindir, fitimage_path, dtb_path, section) else: # Image nodes always need a hash which gets indirectly signed by the config signature @@ -696,6 +724,27 @@ FIT_DESC = "A model description" self._test_fitimage(bb_vars) + def test_fit_image_ext_dtb_dtbo(self): + """ + Summary: Check if FIT image and Image Tree Source (its) are created correctly. + Expected: 1) its and FIT image are built successfully + 2) The its file contains also the external devicetree overlay + 3) Dumping the FIT image indicates the devicetree overlay + """ + config = """ +# Enable creation of fitImage +MACHINE = "beaglebone-yocto" +KERNEL_IMAGETYPES += " fitImage " +KERNEL_CLASSES = " kernel-fitimage " +# Add a devicetree overlay which does not need kernel sources +PREFERRED_PROVIDER_virtual/dtb = "bbb-dtbs-as-ext" +""" + config = self._config_add_uboot_env(config) + self.write_config(config) + bb_vars = self._fit_get_bb_vars() + self._test_fitimage(bb_vars) + + def test_sign_fit_image_configurations(self): """ Summary: Check if FIT image and Image Tree Source (its) are created