kernel-fit-image: Add KERNEL_DTBVENDORED support for FIT_CONF_DEFAULT_DTB
PATCH v2 1/2 kernel-fit-image: Add KERNEL_DTBVENDORED support for FIT_CONF_DEFAULT_DTB
When specifying a FIT_CONF_DEFAULT_DTB for a machine, you have to exactly align the name with what will be in the fitImage file or you will get a build error. If you also turn on KERNEL_DTBVENDORED then you must also specify the vendor directory as part of the dtb name that you want for the default, but you must manually do the same mapping that the kernel-fit-image class is doing when it generates the fit-image.its file.
This patch just adds the same logic to figure out the value for the requested default dtb and eliminate the need to understand the internal mapping of the class. It should make specifying the value more intuitive. The same value that you put in the KERNEL_DEVICETREE can be used in the FIT_CONF_DEFAULT_DTB and the new code will correctly honor the KERNEL_DTBVENDORED setting.
Before:
KERNEL_DEVICETREE = "
ti/k3-am62p5-sk.dtb \
... \
"
FIT_CONF_DEFAULT_DTB = "ti_k3-am62p5-sk.dtb"After:
KERNEL_DEVICETREE = "
ti/k3-am62p5-sk.dtb \
... \
"
FIT_CONF_DEFAULT_DTB = "ti/k3-am62p5-sk.dtb"---
v2: Created apply_dtbvendored function to handle the mapping to make sure consistency in the multiple places the mapping is needed.
meta/classes-recipe/kernel-fit-image.bbclass | 21 +++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-)
meta/classes-recipe/kernel-fit-image.bbclass +16 -5
@@ -55,6 +55,13 @@ FIT_KERNEL_SIGN_ENABLE ?= "${UBOOT_SIGN_ENABLE}" FIT_KERNEL_SIGN_KEYNAME ?= "${UBOOT_SIGN_KEYNAME}" FIT_KERNEL_SIGN_KEYDIR ?= "${UBOOT_SIGN_KEYDIR}" +def apply_dtbvendored(d,dtb): + if d.getVar('KERNEL_DTBVENDORED') != "1": + mapped_name = os.path.basename(dtb) + else: + mapped_name = dtb.replace('/', '_') + return mapped_name + python do_compile() { import shutil import oe.fitimage
@@ -97,10 +104,7 @@ python do_compile() { # With vendored DTs, use the DT name as listed in KERNEL_DEVICETREE # and replace any path separators with underscores, this behaves the # same way as KERNEL_DTBVENDORED = "1" did in OE 5.0 and older. - if d.getVar('KERNEL_DTBVENDORED') != "1": - conf_name = dtb_name - else: - conf_name = dtb.replace('/', '_') + conf_name = apply_dtbvendored(d, dtb) # Skip DTB if it's also provided in EXTERNAL_KERNEL_DEVICETREE directory if external_kernel_devicetree:
@@ -195,8 +199,15 @@ python do_compile() { loadable_loadaddress, loadable_entrypoint) + # Figure out if we have a default dtb and if we need to honor the + # KERNEL_DTBVENDORED variable to tweak the name to match what will be + # in the fitImage. + default_dtb = d.getVar("FIT_CONF_DEFAULT_DTB") + if default_dtb: + default_dtb = apply_dtbvendored(d, default_dtb) + # Generate the configuration section - root_node.fitimage_emit_section_config(d.getVar("FIT_CONF_DEFAULT_DTB"), d.getVar("FIT_CONF_MAPPINGS")) + root_node.fitimage_emit_section_config(default_dtb, d.getVar("FIT_CONF_MAPPINGS")) # Write the its file root_node.write_its_file(itsfile)
Signature · 1 line
2.43.0
PATCH v2 2/2 oe-selftest: fitimage: Add tests for KERNEL_DTBVENDORED
The recent changes to fixing KERNEL_DTBVENDORED support and then adding the same mapping for FIT_CONF_DEFAULT_DTB exposed that we were missing tests for these two cases.
---
v2: Added selftest test cases.
meta/lib/oeqa/selftest/cases/fitimage.py | 55 ++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 4 deletions(-)
meta/lib/oeqa/selftest/cases/fitimage.py +51 -4
@@ -107,7 +107,7 @@ class FitImageTestCase(OESelftestTestCase): _MACHINE_SETTINGS = { "qemuarm": { "KERNEL_DEVICETREE": "arm/versatile-pb.dtb arm/versatile-ab.dtb", - "FIT_CONF_DEFAULT_DTB": "versatile-pb.dtb", + "FIT_CONF_DEFAULT_DTB": "arm/versatile-pb.dtb", "UBOOT_MACHINE": "am57xx_evm_defconfig", "UBOOT_DTB_BINARY": "u-boot.dtb", "UBOOT_ARCH": "arm",
@@ -117,7 +117,7 @@ class FitImageTestCase(OESelftestTestCase): }, "qemuarm64": { "KERNEL_DEVICETREE": "arm/foundation-v8.dtb", - "FIT_CONF_DEFAULT_DTB": "foundation-v8.dtb", + "FIT_CONF_DEFAULT_DTB": "arm/foundation-v8.dtb", "UBOOT_MACHINE": "pine64_plus_defconfig", "UBOOT_DTB_BINARY": "u-boot.dtb", "UBOOT_ARCH": "arm64",
@@ -424,6 +424,16 @@ class FitImageTestCase(OESelftestTestCase): pass return a_comment + @staticmethod + def _apply_dtbvendored(bb_vars,dtb): + """ This is (and should remain) the same logic that is in kernel-fit-image.bbclass + """ + if bb_vars.get('KERNEL_DTBVENDORED') != "1": + mapped_name = os.path.basename(dtb) + else: + mapped_name = dtb.replace('/', '_') + return mapped_name + @staticmethod def _get_dtb_files(bb_vars): """Return a list of devicetree names
@@ -436,7 +446,7 @@ class FitImageTestCase(OESelftestTestCase): all_dtbs = [] dtb_symlinks = [] if kernel_devicetree: - all_dtbs += [os.path.basename(dtb) for dtb in kernel_devicetree.split()] + all_dtbs += [FitImageTestCase._apply_dtbvendored(bb_vars, 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 == "test-dtbs-as-ext":
@@ -678,6 +688,7 @@ class KernelFitImageBase(FitImageTestCase): 'INITRAMFS_IMAGE', 'KERNEL_DEPLOYSUBDIR', 'KERNEL_DEVICETREE', + 'KERNEL_DTBVENDORED', 'KERNEL_FIT_LINK_NAME', 'MACHINE', 'PREFERRED_PROVIDER_virtual/dtb',
@@ -918,7 +929,7 @@ class KernelFitImageBase(FitImageTestCase): fit_conf_default_dtb = bb_vars.get('FIT_CONF_DEFAULT_DTB') if fit_conf_default_dtb: fit_conf_prefix = bb_vars.get('FIT_CONF_PREFIX', "conf-") - its_field_check.append('default = "' + fit_conf_prefix + fit_conf_default_dtb + '";') + its_field_check.append('default = "' + fit_conf_prefix + self._apply_dtbvendored(bb_vars, fit_conf_default_dtb) + '";') # configuration nodes (one per DTB and also one per symlink) dtb_files, dtb_symlinks = FitImageTestCase._get_dtb_files(bb_vars)
@@ -1441,6 +1452,42 @@ FIT_HASH_ALG = "sha256" self._gen_atf_tee_dummy_images(bb_vars) self._test_fitimage(bb_vars) + def test_vendored_dtb_without_kernel_dtbvendored(self): + """ + Summary: Check if FIT image and Image Tree Source (its) are created correctly with KERNEL_DTBVENDORED turned off. + Expected: 1) its and FIT image are built successfully + 2) Dumping the FIT image indicates the devicetree overlay + """ + machine = self._get_machine_or_skip() + config = """ +KERNEL_DTBVENDORED = "0" +""" + config = FitImageTestCase._config_add_machine_settings(config, machine, keys=["KERNEL_DEVICETREE", "UBOOT_MACHINE", "UBOOT_DTB_BINARY", "UBOOT_ARCH"]) + config = self._config_add_kernel_classes(config) + config = self._config_add_uboot_env(config) + self.write_config(config) + bb_vars = self._fit_get_bb_vars() + self._gen_atf_tee_dummy_images(bb_vars) + self._test_fitimage(bb_vars) + + def test_vendored_dtb_with_kernel_dtbvendored(self): + """ + Summary: Check if FIT image and Image Tree Source (its) are created correctly with KERNEL_DTBVENDORED turned on. + Expected: 1) its and FIT image are built successfully + 2) Dumping the FIT image indicates the devicetree overlay + """ + machine = self._get_machine_or_skip() + config = """ +KERNEL_DTBVENDORED = "1" +""" + config = FitImageTestCase._config_add_machine_settings(config, machine, keys=["KERNEL_DEVICETREE", "UBOOT_MACHINE", "UBOOT_DTB_BINARY", "UBOOT_ARCH"]) + config = self._config_add_kernel_classes(config) + config = self._config_add_uboot_env(config) + self.write_config(config) + bb_vars = self._fit_get_bb_vars() + self._gen_atf_tee_dummy_images(bb_vars) + self._test_fitimage(bb_vars) + class FitImagePyTests(KernelFitImageBase): """Test cases for the fitimage.py module without calling bitbake"""
Signature · 1 line
2.43.0