aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2022-01-28 20:37:53 +0100
committerSimon Glass <sjg@chromium.org>2022-01-30 20:40:58 -0700
commitfcc87efdf3772e6e8d060dc10d521442d7772ce9 (patch)
tree5173529e26ffbe12231b18fd86925c05f290c655 /tools
parent6c928c63a18cfc9e2a700cdd88a8db08a8680eb1 (diff)
downloadu-boot-fcc87efdf3772e6e8d060dc10d521442d7772ce9.zip
u-boot-fcc87efdf3772e6e8d060dc10d521442d7772ce9.tar.gz
u-boot-fcc87efdf3772e6e8d060dc10d521442d7772ce9.tar.bz2
binman: Skip node generation for images read from files
We can and should run the node generator only when creating a new image. When we read it back, there is no need to generate nodes - they already exits, and binman does not dive that deep into the image - and there is no way to provide the required fdt-list. So store the mode in the image object so that Entry_fit can simply skip generator nodes when reading them from an fdtmap. This unbreaks all read-backs of images that contain generator nodes in their fdtmap. To confirm this, add a corresponding test case. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> Add SPDX to dts file: Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/binman/etype/fit.py2
-rw-r--r--tools/binman/ftest.py18
-rw-r--r--tools/binman/image.py9
-rw-r--r--tools/binman/test/219_fit_gennode.dts26
4 files changed, 52 insertions, 3 deletions
diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
index 6e5f020..6ad4a68 100644
--- a/tools/binman/etype/fit.py
+++ b/tools/binman/etype/fit.py
@@ -194,7 +194,7 @@ class Entry_fit(Entry):
# the FIT (e.g. "/images/kernel/u-boot"), so don't call
# fsw.add_node() or _AddNode() for it.
pass
- elif subnode.name.startswith('@'):
+ elif self.GetImage().generate and subnode.name.startswith('@'):
if self._fdts:
# Generate notes for each FDT
for seq, fdt_fname in enumerate(self._fdts):
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index ca200ae..5400f76 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -5100,6 +5100,24 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
self.assertIn('Documentation is missing for modules: mkimage',
str(e.exception))
+ def testListWithGenNode(self):
+ """Check handling of an FDT map when the section cannot be found"""
+ entry_args = {
+ 'of-list': 'test-fdt1 test-fdt2',
+ }
+ data = self._DoReadFileDtb(
+ '219_fit_gennode.dts',
+ entry_args=entry_args,
+ use_real_dtb=True,
+ extra_indirs=[os.path.join(self._indir, TEST_FDT_SUBDIR)])
+
+ try:
+ tmpdir, updated_fname = self._SetupImageInTmpdir()
+ with test_util.capture_sys_output() as (stdout, stderr):
+ self._RunBinman('ls', '-i', updated_fname)
+ finally:
+ shutil.rmtree(tmpdir)
+
if __name__ == "__main__":
unittest.main()
diff --git a/tools/binman/image.py b/tools/binman/image.py
index 0f0c1d2..cb5279c 100644
--- a/tools/binman/image.py
+++ b/tools/binman/image.py
@@ -67,9 +67,13 @@ class Image(section.Entry_section):
does not exist in binman. This is useful if an image was created by
binman a newer version of binman but we want to list it in an older
version which does not support all the entry types.
+ generate: If true, generator nodes are processed. If false they are
+ ignored which is useful when an existing image is read back from a
+ file.
"""
def __init__(self, name, node, copy_to_orig=True, test=False,
- ignore_missing=False, use_expanded=False, missing_etype=False):
+ ignore_missing=False, use_expanded=False, missing_etype=False,
+ generate=True):
super().__init__(None, 'section', node, test=test)
self.copy_to_orig = copy_to_orig
self.name = 'main-section'
@@ -83,6 +87,7 @@ class Image(section.Entry_section):
self.use_expanded = use_expanded
self.test_section_timeout = False
self.bintools = {}
+ self.generate = generate
if not test:
self.ReadNode()
@@ -131,7 +136,7 @@ class Image(section.Entry_section):
# Return an Image with the associated nodes
root = dtb.GetRoot()
image = Image('image', root, copy_to_orig=False, ignore_missing=True,
- missing_etype=True)
+ missing_etype=True, generate=False)
image.image_node = fdt_util.GetString(root, 'image-node', 'image')
image.fdtmap_dtb = dtb
diff --git a/tools/binman/test/219_fit_gennode.dts b/tools/binman/test/219_fit_gennode.dts
new file mode 100644
index 0000000..e9eda29
--- /dev/null
+++ b/tools/binman/test/219_fit_gennode.dts
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ binman {
+ fit {
+ description = "test-desc";
+ #address-cells = <1>;
+ fit,fdt-list = "of-list";
+
+ images {
+ @fdt-SEQ {
+ description = "fdt-NAME.dtb";
+ type = "flat_dt";
+ compression = "none";
+ };
+ };
+ };
+ fdtmap {
+ };
+ };
+};