[PATCH v3 1/2] binman: add a new entry type to support .bin file generation for the i.MX95 platform
Alice Guo (OSS)
alice.guo at oss.nxp.com
Sun Aug 10 23:59:35 CEST 2025
From: Alice Guo <alice.guo at nxp.com>
To support passing specific commands defined in enum imx8image_cmd to
the imx8image_copy_image() function, this patch introduces a new entry
type nxp-imx9image. This entry generates a plain text data file
containing the relevant commands, enabling flexible configuration during
image creation.
Signed-off-by: Alice Guo <alice.guo at nxp.com>
---
tools/binman/entries.rst | 12 ++++++
tools/binman/etype/nxp_imx9image.py | 85 +++++++++++++++++++++++++++++++++++++
2 files changed, 97 insertions(+)
diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
index 12a39d070e4..8922d6cd070 100644
--- a/tools/binman/entries.rst
+++ b/tools/binman/entries.rst
@@ -1689,6 +1689,18 @@ together. See imx95_evk.rst for how to get DDR PHY Firmware Images.
+.. _etype_nxp_imx9image:
+
+Entry: nxp_imx9image: data file generator and mkimage invocation
+-----------------------------------------------------------------------------
+
+This entry is used to generate a data file that is passed to mkimage with the -n
+option. Each line in this data file represents a command defined in the enum
+imx8image_cmd. The imx8image_copy_image() function parses all commands and
+constructs a .bin file accordingly.
+
+
+
.. _etype_opensbi:
Entry: opensbi: RISC-V OpenSBI fw_dynamic blob
diff --git a/tools/binman/etype/nxp_imx9image.py b/tools/binman/etype/nxp_imx9image.py
new file mode 100644
index 00000000000..af893cf27d7
--- /dev/null
+++ b/tools/binman/etype/nxp_imx9image.py
@@ -0,0 +1,85 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright 2025 NXP
+
+import os
+from binman.etype.mkimage import Entry_mkimage
+from dtoc import fdt_util
+from u_boot_pylib import tools
+
+class Entry_nxp_imx9image(Entry_mkimage):
+ """NXP i.MX9 .bin configuration file generator and mkimage invocation
+
+ Properties arguments:
+ - append: appends the specified blob file as-is
+ - boot-from: indicates the boot device to be used
+ - cntr-version: sets the image container format version
+ - container: indicates that it is a new container
+ - dummy-ddr: specifies the memory address for storing the DDR training
+ data image
+ - dummy-v2x: specifies the memory address for storing V2X firmware
+ - hold: reserves a specified number of bytes after the previous image
+ - image: defines the option type, image filename, and the memory address
+ where the image will be stored
+ - soc-type: specifies the target SoC for which the .bin file is generated
+ """
+
+ def __init__(self, section, etype, node):
+ super().__init__(section, etype, node)
+ self.config_filename = None
+
+ def ReadNode(self):
+ super().ReadNode()
+ cfg_path = fdt_util.GetString(self._node, 'cfg-path')
+ self.config_filename = tools.get_output_filename(cfg_path)
+ accepted_keys = [
+ 'append', 'boot-from', 'cntr-version', 'container', 'dummy-ddr',
+ 'dummy-v2x', 'hold', 'image', 'soc-type'
+ ]
+
+ try:
+ with open(self.config_filename, 'w', encoding='utf-8') as f:
+ for prop in self._node.props.values():
+ key = prop.name
+ value = prop.value
+
+ if not any(key.startswith(prefix) for prefix in accepted_keys):
+ continue
+
+ formatted_key = key.replace('-', '_')
+
+ if key.startswith('image'):
+ if isinstance(value, list) and len(value) == 3:
+ combined = ' '.join(str(v) for v in value)
+ f.write(f'image {combined}\n')
+ else:
+ self.Raise(f"Invalid value for image: {value}")
+ elif isinstance(value, str):
+ f.write(f'{formatted_key} {value}\n')
+ elif isinstance(value, bool):
+ f.write(f'{formatted_key}\n')
+ elif isinstance(value, bytes):
+ hex_value = hex(int.from_bytes(value, byteorder='big'))
+ f.write(f'{formatted_key} {hex_value}\n')
+ else:
+ self.Raise(f"Unsupported property '{key}'")
+ except Exception as e:
+ self.Raise(f"Failed to write '{self.config_filename}': {e}")
+
+ def BuildSectionData(self, required):
+ data, input_fname, uniq = self.collect_contents_to_file(self._entries.values(), 'imx9image')
+
+ outfile = f'imx9image-out.{uniq}'
+ output_fname = tools.get_output_filename(outfile)
+
+ args = [
+ '-d', input_fname, '-n', self.config_filename, '-T', 'imx8image',
+ output_fname
+ ]
+
+ result = self.mkimage.run_cmd(*args)
+ if result is not None and os.path.exists(output_fname):
+ return tools.read_file(output_fname)
+
+ self.record_missing_bintool(self.mkimage)
+ return data
--
2.43.0
More information about the U-Boot
mailing list