@@ -139,7 +139,7 @@ python do_compile() {
bb.fatal("Could not find a valid initramfs type for %s, the supported types are: %s" % (d.getVar('INITRAMFS_IMAGE_NAME'), d.getVar('FIT_SUPPORTED_INITRAMFS_FSTYPES')))
# Generate the configuration section
- root_node.fitimage_emit_section_config(d.getVar("FIT_CONF_DEFAULT_DTB"))
+ root_node.fitimage_emit_section_config(d.getVar("FIT_CONF_DEFAULT_DTB"), d.getVar("FIT_CONF_MAPPINGS"))
# Write the its file
root_node.write_its_file(itsfile)
@@ -47,6 +47,18 @@ FIT_LINUX_BIN ?= "linux.bin"
# Allow user to select the default DTB for FIT image when multiple dtb's exists.
FIT_CONF_DEFAULT_DTB ?= ""
+# Allow user to specify DTB configuration node mappings.
+# The format is a space-separated list of mappings. Supported mapping types are:
+# dtb-conf:DTB_NAME:NEW_NAME - Rename the configuration node for a DTB
+# dtb-extra-conf:DTB_NAME:EXTRA_NAME - Add an additional configuration node for a DTB
+# Example:
+# FIT_CONF_MAPPINGS = "\
+# dtb-extra-conf:am335x-bonegreen:bonegreen \
+# dtb-conf:am335x-boneblack:bbblack"
+# Two DTBs (am335x-bonegreen and am335x-boneblack) result in three
+# configuration nodes: am335x-bonegreen, bonegreen, bbblack
+FIT_CONF_MAPPINGS ?= ""
+
# length of address in number of <u32> cells
# ex: 1 32bits address, 2 64bits address
FIT_ADDRESS_CELLS ?= "1"
@@ -331,7 +331,6 @@ class ItsNodeRootKernel(ItsNode):
dtb_id = os.path.basename(dtb_path)
dtb_alias_node = ItsNodeDtbAlias("fdt-" + dtb_id, dtb_alias_id, compatible)
self._dtb_alias.append(dtb_alias_node)
- bb.warn(f"compatible: {compatible}, dtb_alias_id: {dtb_alias_id}, dtb_id: {dtb_id}, dtb_path: {dtb_path}")
def fitimage_emit_section_boot_script(self, bootscr_id, bootscr_path):
"""Emit the fitImage ITS u-boot script section"""
@@ -462,15 +461,63 @@ class ItsNodeRootKernel(ItsNode):
}
)
- def fitimage_emit_section_config(self, default_dtb_image=None):
+ def fitimage_emit_section_config(self, default_dtb_image=None, mappings=None):
if self._dtbs:
+ dtb_extra_confs = []
+ dtb_confs = {}
+ if mappings:
+ for mapping in mappings.split():
+ try:
+ mapping_type, dtb_name, alt_name = mapping.split(':')
+ except ValueError:
+ bb.fatal("FIT configuration mapping '%s' is invalid. Expected format: 'mapping_type:dtb_name:alternative_name'" % mapping)
+ if mapping_type == "dtb-conf":
+ if dtb_name in dtb_confs:
+ bb.fatal("FIT configuration mapping 'dtb-conf:%s' specified multiple times" % dtb_name)
+ dtb_confs[dtb_name] = alt_name
+ elif mapping_type == "dtb-extra-conf":
+ dtb_extra_confs.append((dtb_name, alt_name))
+ else:
+ bb.fatal("FIT configuration mapping-type '%s' is invalid" % mapping_type)
+
+ # Process regular DTBs
for dtb in self._dtbs:
dtb_name = dtb.name
if dtb.name.startswith("fdt-"):
dtb_name = dtb.name[len("fdt-"):]
- self._fitimage_emit_one_section_config(self._conf_prefix + dtb_name, dtb)
- for dtb in self._dtb_alias:
- self._fitimage_emit_one_section_config(self._conf_prefix + dtb.alias_name, dtb)
+
+ dtb_renamed = dtb_name
+ if dtb_name in dtb_confs:
+ dtb_renamed = dtb_confs.pop(dtb_name)
+ self._fitimage_emit_one_section_config(self._conf_prefix + dtb_renamed, dtb)
+
+ # Process extra configurations for this DTB
+ for dtb_extra_name, dtb_extra_alias in dtb_extra_confs[:]:
+ if dtb_name == dtb_extra_name:
+ dtb_extra_confs.remove((dtb_extra_name, dtb_extra_alias))
+ self._fitimage_emit_one_section_config(self._conf_prefix + dtb_extra_alias, dtb)
+
+ # Process external DTB sym-link aliases
+ for dtb_alias in self._dtb_alias:
+ alias_name = dtb_alias.alias_name
+ dtb_renamed = alias_name
+ if alias_name in dtb_confs:
+ dtb_renamed = dtb_confs.pop(alias_name)
+ self._fitimage_emit_one_section_config(self._conf_prefix + dtb_renamed, dtb_alias)
+
+ # Process extra configurations for this DTB alias
+ for dtb_extra_name, dtb_extra_alias in dtb_extra_confs[:]:
+ if alias_name == dtb_extra_name:
+ dtb_extra_confs.remove((dtb_extra_name, dtb_extra_alias))
+ self._fitimage_emit_one_section_config(self._conf_prefix + dtb_extra_alias, dtb_alias)
+
+ # Verify all mappings were used
+ if dtb_confs or dtb_extra_confs:
+ unused_conf = (
+ ["dtb-conf:%s:%s" % (name, alt) for name, alt in dtb_confs.items()] +
+ ["dtb-extra-conf:%s:%s" % (name, alias) for name, alias in dtb_extra_confs]
+ )
+ bb.fatal("FIT configuration mapping(s) not matched with any DTB: %s" % ', '.join(unused_conf))
else:
# Currently exactly one kernel is supported.
self._fitimage_emit_one_section_config(self._conf_prefix + "1")