All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] meson: Demonstration of using binman to produce the image
@ 2021-11-24  4:09 Simon Glass
  2021-11-24  4:09 ` [PATCH 1/7] binman: Allow providing tools and blob directories Simon Glass
                   ` (12 more replies)
  0 siblings, 13 replies; 17+ messages in thread
From: Simon Glass @ 2021-11-24  4:09 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Jaehoon Chung, Marek Behún, Marek Szyprowski,
	Neil Armstrong, Pali Rohár, Walter Lozano, u-boot-amlogic

The Odroid-C2 is quite a complicated image with many steps. It is an ideal
example for how Binman can be used.

Add a binman description and update the instructions accordingly.


Simon Glass (7):
  binman: Allow providing tools and blob directories
  binman: Allow listing an image created by a newer version
  binman: Allow extracting a file in an alternative format
  dtoc: Add support for reading string-list properties
  binman: Support lists of external blobs
  binman: Rename _ReadSubnodes() to ReadEntries()
  RFC: Move Odroid-C2 to use binman to produce the image

 Makefile                                      |   2 +
 arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi  | 107 +++++++++++++++
 arch/arm/mach-meson/Kconfig                   |   1 +
 doc/board/amlogic/odroid-c4.rst               | 127 +++++-------------
 scripts/pylint.base                           |   2 +
 tools/binman/binman.rst                       |  65 ++++++++-
 tools/binman/cmdline.py                       |   2 +
 tools/binman/control.py                       |  28 +++-
 tools/binman/entries.rst                      |  25 +++-
 tools/binman/entry.py                         | 102 +++++++++++---
 tools/binman/entry_test.py                    |   9 ++
 tools/binman/etype/aml_encrypt.py             | 124 +++++++++++++++++
 tools/binman/etype/atf_fip.py                 |  16 ++-
 tools/binman/etype/blob.py                    |  16 ++-
 tools/binman/etype/blob_ext_list.py           |  58 ++++++++
 tools/binman/etype/cbfs.py                    |   8 +-
 tools/binman/etype/fdtmap.py                  |  12 ++
 tools/binman/etype/fit.py                     |   4 +-
 tools/binman/etype/intel_ifwi.py              |   4 +-
 tools/binman/etype/mkimage.py                 |   4 +-
 tools/binman/etype/section.py                 |  26 +++-
 tools/binman/ftest.py                         |  57 ++++++++
 tools/binman/image.py                         |  12 +-
 tools/binman/missing-blob-help                |   6 +
 tools/binman/test/213_aml_encrypt.dts         |  38 ++++++
 tools/binman/test/213_fdtmap_alt_format.dts   |  15 +++
 tools/binman/test/214_list_no_dtb.dts         |  23 ++++
 tools/binman/test/214_no_alt_format.dts       |  13 ++
 tools/binman/test/215_blob_ext_list.dts       |  14 ++
 .../binman/test/216_blob_ext_list_missing.dts |  14 ++
 tools/dtoc/fdt_util.py                        |  21 +++
 tools/dtoc/test_fdt.py                        |   9 ++
 32 files changed, 822 insertions(+), 142 deletions(-)
 create mode 100644 tools/binman/etype/aml_encrypt.py
 create mode 100644 tools/binman/etype/blob_ext_list.py
 create mode 100644 tools/binman/test/213_aml_encrypt.dts
 create mode 100644 tools/binman/test/213_fdtmap_alt_format.dts
 create mode 100644 tools/binman/test/214_list_no_dtb.dts
 create mode 100644 tools/binman/test/214_no_alt_format.dts
 create mode 100644 tools/binman/test/215_blob_ext_list.dts
 create mode 100644 tools/binman/test/216_blob_ext_list_missing.dts

-- 
2.34.0.rc2.393.gf8c9666880-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/7] binman: Allow providing tools and blob directories
  2021-11-24  4:09 [PATCH 0/7] meson: Demonstration of using binman to produce the image Simon Glass
@ 2021-11-24  4:09 ` Simon Glass
  2021-11-24  4:09 ` [PATCH 2/7] binman: Allow listing an image created by a newer version Simon Glass
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Simon Glass @ 2021-11-24  4:09 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Simon Glass, Marek Behún, Pali Rohár

At present it is necessary to symlink files containing external blobs into
the U-Boot tree in order for binman to find them. This is not very
convenient.

Add two new environment/Makefile variables to help with this. Add
documentation as well, fixing a related nit.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 Makefile                |  2 ++
 tools/binman/binman.rst | 31 ++++++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 0b08b2669f9..0c163d0545c 100644
--- a/Makefile
+++ b/Makefile
@@ -1303,11 +1303,13 @@ default_dt := $(if $(DEVICE_TREE),$(DEVICE_TREE),$(CONFIG_DEFAULT_DEVICE_TREE))
 
 quiet_cmd_binman = BINMAN  $@
 cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \
+		$(foreach f,$(BINMAN_TOOLPATHS),--toolpath $(f)) \
                 --toolpath $(objtree)/tools \
 		$(if $(BINMAN_VERBOSE),-v$(BINMAN_VERBOSE)) \
 		build -u -d u-boot.dtb -O . -m --allow-missing \
 		-I . -I $(srctree) -I $(srctree)/board/$(BOARDDIR) \
 		-I arch/$(ARCH)/dts -a of-list=$(CONFIG_OF_LIST) \
+		$(foreach f,$(BINMAN_INDIRS),-I $(f)) \
 		-a atf-bl31-path=${BL31} \
 		-a opensbi-path=${OPENSBI} \
 		-a default-dt=$(default_dt) \
diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst
index 35de93bd898..210d0c5c51b 100644
--- a/tools/binman/binman.rst
+++ b/tools/binman/binman.rst
@@ -942,7 +942,7 @@ Replacing files in an image
 ---------------------------
 
 You can replace files in an existing firmware image created by binman, provided
-that there is an 'fdtmap' entry in the image. For example:
+that there is an 'fdtmap' entry in the image. For example::
 
     $ binman replace -i image.bin section/cbfs/u-boot
 
@@ -1081,6 +1081,35 @@ the tool's output will be used for the target or for the host machine. If those
 aren't given, it will also try to derive target-specific versions from the
 CROSS_COMPILE environment variable during a cross-compilation.
 
+If the tool is not available in the path you can use BINMAN_TOOLPATHS to specify
+a space-separated list of paths to search, e.g.::
+
+   BINMAN_TOOLPATHS="/tools/g12a /tools/tegra" binman ...
+
+
+External blobs
+--------------
+
+Binary blobs, even if the source code is available, complicate building
+firmware. The instructions can involve multiple steps and the binaries may be
+hard to build or obtain. Binman at least provides a unified description of how
+to build the final image, no matter what steps are needed to get there.
+
+Binman also provides a `blob-ext` entry type that pulls in a binary blob from an
+external file. If the file is missing, binman can optionally complete the build
+and just report a warning. Use the `-M/--allow-missing` option to enble this.
+This is useful in CI systems which want to check that everything is correct but
+don't have access to the blobs.
+
+If the blobs are in a different directory, you can specify this with the `-I`
+option.
+
+For U-Boot, you can use set the BINMAN_INDIRS environment variable to provide a
+space-separated list of directories to search for binary blobs::
+
+   BINMAN_INDIRS="odroid-c4/fip/g12a \
+       odroid-c4/build/board/hardkernel/odroidc4/firmware \
+       odroid-c4/build/scp_task" binman ...
 
 Code coverage
 -------------
-- 
2.34.0.rc2.393.gf8c9666880-goog


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/7] binman: Allow listing an image created by a newer version
  2021-11-24  4:09 [PATCH 0/7] meson: Demonstration of using binman to produce the image Simon Glass
  2021-11-24  4:09 ` [PATCH 1/7] binman: Allow providing tools and blob directories Simon Glass
@ 2021-11-24  4:09 ` Simon Glass
  2021-11-24  4:09 ` [PATCH 3/7] binman: Allow extracting a file in an alternative format Simon Glass
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Simon Glass @ 2021-11-24  4:09 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Simon Glass

If an older version of binman is used to list images created by a newer
one, it is possible that it will contain entry types that are not
supported. At present this produces an error.

Adjust binman to use a plain 'blob' entry type to cope with this, so the
image can at least be listed.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/binman/binman.rst       |  5 +++
 tools/binman/entry.py         | 65 +++++++++++++++++++++++++++--------
 tools/binman/entry_test.py    |  9 +++++
 tools/binman/etype/section.py |  3 +-
 tools/binman/image.py         | 10 ++++--
 5 files changed, 74 insertions(+), 18 deletions(-)

diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst
index 210d0c5c51b..26f462ae16f 100644
--- a/tools/binman/binman.rst
+++ b/tools/binman/binman.rst
@@ -913,6 +913,11 @@ or with wildcards::
           u-boot-dtb        180   108  u-boot-dtb        80          3b5
       image-header          bf8     8  image-header     bf8
 
+If an older version of binman is used to list images created by a newer one, it
+is possible that it will contain entry types that are not supported. These still
+show with the correct type, but binman just sees them as blobs (plain binary
+data). Any special features of that etype are not supported by the old binman.
+
 
 Extracting files from images
 ----------------------------
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 2205bc8d923..e7a8365fd51 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -102,7 +102,7 @@ class Entry(object):
         self.allow_missing = False
 
     @staticmethod
-    def Lookup(node_path, etype, expanded):
+    def FindEntryClass(etype, expanded):
         """Look up the entry class for a node.
 
         Args:
@@ -113,10 +113,9 @@ class Entry(object):
 
         Returns:
             The entry class object if found, else None if not found and expanded
-                is True
-
-        Raise:
-            ValueError if expanded is False and the class is not found
+                is True, else a tuple:
+                    module name that could not be found
+                    exception received
         """
         # Convert something like 'u-boot@0' to 'u_boot' since we are only
         # interested in the type.
@@ -137,30 +136,66 @@ class Entry(object):
             except ImportError as e:
                 if expanded:
                     return None
-                raise ValueError("Unknown entry type '%s' in node '%s' (expected etype/%s.py, error '%s'" %
-                                 (etype, node_path, module_name, e))
+                return module_name, e
             modules[module_name] = module
 
         # Look up the expected class name
         return getattr(module, 'Entry_%s' % module_name)
 
     @staticmethod
-    def Create(section, node, etype=None, expanded=False):
+    def Lookup(node_path, etype, expanded, missing_etype=False):
+        """Look up the entry class for a node.
+
+        Args:
+            node_node (str): Path name of Node object containing information
+                about the entry to create (used for errors)
+            etype (str):   Entry type to use
+            expanded (bool): Use the expanded version of etype
+            missing_etype (bool): True to default to a blob etype if the
+                requested etype is not found
+
+        Returns:
+            The entry class object if found, else None if not found and expanded
+                is True
+
+        Raise:
+            ValueError if expanded is False and the class is not found
+        """
+        # Convert something like 'u-boot@0' to 'u_boot' since we are only
+        # interested in the type.
+        cls = Entry.FindEntryClass(etype, expanded)
+        if cls is None:
+            return None
+        elif isinstance(cls, tuple):
+            if missing_etype:
+                cls = Entry.FindEntryClass('blob', False)
+            if isinstance(cls, tuple): # This should not fail
+                module_name, e = cls
+                raise ValueError(
+                    "Unknown entry type '%s' in node '%s' (expected etype/%s.py, error '%s'" %
+                    (etype, node_path, module_name, e))
+        return cls
+
+    @staticmethod
+    def Create(section, node, etype=None, expanded=False, missing_etype=False):
         """Create a new entry for a node.
 
         Args:
-            section:  Section object containing this node
-            node:     Node object containing information about the entry to
-                      create
-            etype:    Entry type to use, or None to work it out (used for tests)
-            expanded: True to use expanded versions of entries, where available
+            section (entry_Section):  Section object containing this node
+            node (Node): Node object containing information about the entry to
+                create
+            etype (str): Entry type to use, or None to work it out (used for
+                tests)
+            expanded (bool): Use the expanded version of etype
+            missing_etype (bool): True to default to a blob etype if the
+                requested etype is not found
 
         Returns:
             A new Entry object of the correct type (a subclass of Entry)
         """
         if not etype:
             etype = fdt_util.GetString(node, 'type', node.name)
-        obj = Entry.Lookup(node.path, etype, expanded)
+        obj = Entry.Lookup(node.path, etype, expanded, missing_etype)
         if obj and expanded:
             # Check whether to use the expanded entry
             new_etype = etype + '-expanded'
@@ -170,7 +205,7 @@ class Entry(object):
             else:
                 obj = None
         if not obj:
-            obj = Entry.Lookup(node.path, etype, False)
+            obj = Entry.Lookup(node.path, etype, False, missing_etype)
 
         # Call its constructor to get the object we want.
         return obj(section, etype, node)
diff --git a/tools/binman/entry_test.py b/tools/binman/entry_test.py
index c3d5f3eef48..1b59c9056ec 100644
--- a/tools/binman/entry_test.py
+++ b/tools/binman/entry_test.py
@@ -10,6 +10,7 @@ import sys
 import unittest
 
 from binman import entry
+from binman.etype.blob import Entry_blob
 from dtoc import fdt
 from dtoc import fdt_util
 from patman import tools
@@ -100,5 +101,13 @@ class TestEntry(unittest.TestCase):
         self.assertIn("Unknown entry type 'missing' in node '/binman/u-boot'",
                       str(e.exception))
 
+    def testMissingEtype(self):
+        """Test use of a blob etype when the requested one is not available"""
+        ent = entry.Entry.Create(None, self.GetNode(), 'missing',
+                                 missing_etype=True)
+        self.assertTrue(isinstance(ent, Entry_blob))
+        self.assertEquals('missing', ent.etype)
+
+
 if __name__ == "__main__":
     unittest.main()
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 2e01dccc6db..6ce07dd37d7 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -185,7 +185,8 @@ class Entry_section(Entry):
             if node.name.startswith('hash') or node.name.startswith('signature'):
                 continue
             entry = Entry.Create(self, node,
-                                 expanded=self.GetImage().use_expanded)
+                                 expanded=self.GetImage().use_expanded,
+                                 missing_etype=self.GetImage().missing_etype)
             entry.ReadNode()
             entry.SetPrefix(self._name_prefix)
             self._entries[node.name] = entry
diff --git a/tools/binman/image.py b/tools/binman/image.py
index cdc58b39a40..891e8b488e9 100644
--- a/tools/binman/image.py
+++ b/tools/binman/image.py
@@ -63,9 +63,13 @@ class Image(section.Entry_section):
             to ignore 'u-boot-bin' in this case, and build it ourselves in
             binman with 'u-boot-dtb.bin' and 'u-boot.dtb'. See
             Entry_u_boot_expanded and Entry_blob_phase for details.
+        missing_etype: Use a default entry type ('blob') if the requested one
+            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.
     """
     def __init__(self, name, node, copy_to_orig=True, test=False,
-                 ignore_missing=False, use_expanded=False):
+                 ignore_missing=False, use_expanded=False, missing_etype=False):
         super().__init__(None, 'section', node, test=test)
         self.copy_to_orig = copy_to_orig
         self.name = 'main-section'
@@ -75,6 +79,7 @@ class Image(section.Entry_section):
         self.fdtmap_data = None
         self.allow_repack = False
         self._ignore_missing = ignore_missing
+        self.missing_etype = missing_etype
         self.use_expanded = use_expanded
         self.test_section_timeout = False
         if not test:
@@ -124,7 +129,8 @@ 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)
+        image = Image('image', root, copy_to_orig=False, ignore_missing=True,
+                      missing_etype=True)
 
         image.image_node = fdt_util.GetString(root, 'image-node', 'image')
         image.fdtmap_dtb = dtb
-- 
2.34.0.rc2.393.gf8c9666880-goog


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 3/7] binman: Allow extracting a file in an alternative format
  2021-11-24  4:09 [PATCH 0/7] meson: Demonstration of using binman to produce the image Simon Glass
  2021-11-24  4:09 ` [PATCH 1/7] binman: Allow providing tools and blob directories Simon Glass
  2021-11-24  4:09 ` [PATCH 2/7] binman: Allow listing an image created by a newer version Simon Glass
@ 2021-11-24  4:09 ` Simon Glass
  2021-11-24  4:09 ` [PATCH 4/7] dtoc: Add support for reading string-list properties Simon Glass
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Simon Glass @ 2021-11-24  4:09 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Simon Glass

In some cases entries encapsulate other data and it is useful to access
the data within. An example is the fdtmap which consists of a 16-byte
header, followed by a devicetree.

Provide an option to specify an alternative format when extracting files.
In the case of fdtmap, this is 'fdt', which produces an FDT file which can
be viewed with fdtdump.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/binman/binman.rst                     | 29 ++++++++++++++++
 tools/binman/cmdline.py                     |  2 ++
 tools/binman/control.py                     | 28 +++++++++++++---
 tools/binman/entries.rst                    | 11 +++++-
 tools/binman/entry.py                       | 37 +++++++++++++++++----
 tools/binman/etype/atf_fip.py               | 16 ++++++++-
 tools/binman/etype/cbfs.py                  |  8 ++---
 tools/binman/etype/fdtmap.py                | 12 +++++++
 tools/binman/etype/section.py               | 23 ++++++++++---
 tools/binman/ftest.py                       | 34 +++++++++++++++++++
 tools/binman/image.py                       |  2 +-
 tools/binman/test/213_fdtmap_alt_format.dts | 15 +++++++++
 tools/binman/test/214_no_alt_format.dts     | 13 ++++++++
 13 files changed, 208 insertions(+), 22 deletions(-)
 create mode 100644 tools/binman/test/213_fdtmap_alt_format.dts
 create mode 100644 tools/binman/test/214_no_alt_format.dts

diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst
index 26f462ae16f..10389a52c4b 100644
--- a/tools/binman/binman.rst
+++ b/tools/binman/binman.rst
@@ -942,6 +942,35 @@ or just a selection::
 
     $ binman extract -i image.bin "*u-boot*" -O outdir
 
+Some entry types have alternative formats, for example fdtmap which allows
+extracted just the devicetree binary without the fdtmap header::
+
+    $ binman extract -i /tmp/b/odroid-c4/image.bin -f out.dtb -F fdt fdtmap
+    $ fdtdump out.dtb
+    /dts-v1/;
+    // magic:               0xd00dfeed
+    // totalsize:           0x8ab (2219)
+    // off_dt_struct:       0x38
+    // off_dt_strings:      0x82c
+    // off_mem_rsvmap:      0x28
+    // version:             17
+    // last_comp_version:   2
+    // boot_cpuid_phys:     0x0
+    // size_dt_strings:     0x7f
+    // size_dt_struct:      0x7f4
+
+    / {
+        image-node = "binman";
+        image-pos = <0x00000000>;
+        size = <0x0011162b>;
+        ...
+
+Use `-F list` to see what alternative formats are available::
+
+    $ binman extract -i /tmp/b/odroid-c4/image.bin -F list
+    Flag (-F)   Entry type            Description
+    fdt         fdtmap                Extract the devicetree blob from the fdtmap
+
 
 Replacing files in an image
 ---------------------------
diff --git a/tools/binman/cmdline.py b/tools/binman/cmdline.py
index 2229316f10e..adc17547ae6 100644
--- a/tools/binman/cmdline.py
+++ b/tools/binman/cmdline.py
@@ -17,6 +17,8 @@ def make_extract_parser(subparsers):
     """
     extract_parser = subparsers.add_parser('extract',
                                            help='Extract files from an image')
+    extract_parser.add_argument('-F', '--format', type=str,
+        help='Select an alternative format for extracted data')
     extract_parser.add_argument('-i', '--image', type=str, required=True,
                                 help='Image filename to extract')
     extract_parser.add_argument('-f', '--filename', type=str,
diff --git a/tools/binman/control.py b/tools/binman/control.py
index 304fc70f56f..7288a2639d5 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -200,8 +200,24 @@ def ReadEntry(image_fname, entry_path, decomp=True):
     return entry.ReadData(decomp)
 
 
+def ShowAltFormats(image):
+    """Show alternative formats available for entries in the image
+
+    This shows a list of formats available.
+
+    Args:
+        image (Image): Image to check
+    """
+    alt_formats = {}
+    image.CheckAltFormats(alt_formats)
+    print('%-10s  %-20s  %s' % ('Flag (-F)', 'Entry type', 'Description'))
+    for name, val in alt_formats.items():
+        entry, helptext = val
+        print('%-10s  %-20s  %s' % (name, entry.etype, helptext))
+
+
 def ExtractEntries(image_fname, output_fname, outdir, entry_paths,
-                   decomp=True):
+                   decomp=True, alt_format=None):
     """Extract the data from one or more entries and write it to files
 
     Args:
@@ -217,6 +233,10 @@ def ExtractEntries(image_fname, output_fname, outdir, entry_paths,
     """
     image = Image.FromFile(image_fname)
 
+    if alt_format == 'list':
+        ShowAltFormats(image)
+        return
+
     # Output an entry to a single file, as a special case
     if output_fname:
         if not entry_paths:
@@ -224,7 +244,7 @@ def ExtractEntries(image_fname, output_fname, outdir, entry_paths,
         if len(entry_paths) != 1:
             raise ValueError('Must specify exactly one entry path to write with -f')
         entry = image.FindEntryPath(entry_paths[0])
-        data = entry.ReadData(decomp)
+        data = entry.ReadData(decomp, alt_format)
         tools.WriteFile(output_fname, data)
         tout.Notice("Wrote %#x bytes to file '%s'" % (len(data), output_fname))
         return
@@ -236,7 +256,7 @@ def ExtractEntries(image_fname, output_fname, outdir, entry_paths,
     tout.Notice('%d entries match and will be written' % len(einfos))
     for einfo in einfos:
         entry = einfo.entry
-        data = entry.ReadData(decomp)
+        data = entry.ReadData(decomp, alt_format)
         path = entry.GetPath()[1:]
         fname = os.path.join(outdir, path)
 
@@ -583,7 +603,7 @@ def Binman(args):
 
             if args.cmd == 'extract':
                 ExtractEntries(args.image, args.filename, args.outdir, args.paths,
-                               not args.uncompressed)
+                               not args.uncompressed, args.format)
 
             if args.cmd == 'replace':
                 ReplaceEntries(args.image, args.filename, args.indir, args.paths,
diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
index 84f828a6352..cf3a6e69599 100644
--- a/tools/binman/entries.rst
+++ b/tools/binman/entries.rst
@@ -468,6 +468,10 @@ Example output for a simple image with U-Boot and an FDT map::
 If allow-repack is used then 'orig-offset' and 'orig-size' properties are
 added as necessary. See the binman README.
 
+When extracting files, an alternative 'fdt' format is available for fdtmaps.
+Use `binman extract -F fdt ...` to use this. It will export a devicetree,
+without the fdtmap header, so it can be viewed with `fdtdump`.
+
 
 
 Entry: files: A set of files arranged in a section
@@ -1009,7 +1013,7 @@ SetImagePos(image_pos):
     Binman calls this after the image has been packed, to update the
     location that all the entries ended up at.
 
-ReadChildData(child, decomp):
+ReadChildData(child, decomp, alt_format):
     The default version of this may be good enough, if you are able to
     implement SetImagePos() correctly. But that is a bit of a bypass, so
     you can override this method to read from your custom file format. It
@@ -1022,6 +1026,11 @@ ReadChildData(child, decomp):
     uncompress it first, then return the uncompressed data (`decomp` is
     True). This is used by the `binman extract -U` option.
 
+    If your entry supports alternative formats, the alt_format provides the
+    alternative format that the user has selected. Your function should
+    return data in that format. This is used by the 'binman extract -l'
+    option.
+
     Binman calls this when reading in an image, in order to populate all the
     entries with the data from that image (`binman ls`).
 
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index e7a8365fd51..61642bf5017 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -815,7 +815,7 @@ features to produce new behaviours.
         self.AddEntryInfo(entries, indent, self.name, self.etype, self.size,
                           self.image_pos, self.uncomp_size, self.offset, self)
 
-    def ReadData(self, decomp=True):
+    def ReadData(self, decomp=True, alt_format=None):
         """Read the data for an entry from the image
 
         This is used when the image has been read in and we want to extract the
@@ -832,19 +832,20 @@ features to produce new behaviours.
         # although compressed sections are currently not supported
         tout.Debug("ReadChildData section '%s', entry '%s'" %
                    (self.section.GetPath(), self.GetPath()))
-        data = self.section.ReadChildData(self, decomp)
+        data = self.section.ReadChildData(self, decomp, alt_format)
         return data
 
-    def ReadChildData(self, child, decomp=True):
+    def ReadChildData(self, child, decomp=True, alt_format=None):
         """Read the data for a particular child entry
 
         This reads data from the parent and extracts the piece that relates to
         the given child.
 
         Args:
-            child: Child entry to read data for (must be valid)
-            decomp: True to decompress any compressed data before returning it;
-                False to return the raw, uncompressed data
+            child (Entry): Child entry to read data for (must be valid)
+            decomp (bool): True to decompress any compressed data before
+                returning it; False to return the raw, uncompressed data
+            alt_format (str): Alternative format to read in, or None
 
         Returns:
             Data for the child (bytes)
@@ -857,6 +858,20 @@ features to produce new behaviours.
         self.ProcessContentsUpdate(data)
         self.Detail('Loaded data size %x' % len(data))
 
+    def GetAltFormat(self, data, alt_format):
+        """Read the data for an extry in an alternative format
+
+        Supported formats are list in the documentation for each entry. An
+        example is fdtmap which provides .
+
+        Args:
+            data (bytes): Data to convert (this should have been produced by the
+                entry)
+            alt_format (str): Format to use
+
+        """
+        pass
+
     def GetImage(self):
         """Get the image containing this entry
 
@@ -997,3 +1012,13 @@ features to produce new behaviours.
         tout.Info("Node '%s': etype '%s': %s selected" %
                   (node.path, etype, new_etype))
         return True
+
+    def CheckAltFormats(self, alt_formats):
+        """Add any alternative formats supported by this entry type
+
+        Args:
+            alt_formats (dict): Dict to add alt_formats to:
+                key: Name of alt format
+                value: Help text
+        """
+        pass
diff --git a/tools/binman/etype/atf_fip.py b/tools/binman/etype/atf_fip.py
index f9039e14c0a..fad2dd0e0eb 100644
--- a/tools/binman/etype/atf_fip.py
+++ b/tools/binman/etype/atf_fip.py
@@ -250,7 +250,21 @@ class Entry_atf_fip(Entry_section):
             entry.offset = fent.offset
             entry.image_pos = self.image_pos + entry.offset
 
-    def ReadChildData(self, child, decomp=True):
+    def ReadChildData(self, child, decomp=True, alt_format=None):
+        """Read the data for a particular child entry
+
+        This reads data from the parent and extracts the piece that relates to
+        the given child.
+
+        Args:
+            child (Entry): Child entry to read data for (must be valid)
+            decomp (bool): True to decompress any compressed data before
+                returning it; False to return the raw, uncompressed data
+            alt_format (str): Alternative format to read in, or None
+
+        Returns:
+            bytes: Data for the child (bytes)
+        """
         if not self.reader:
             self.fip_data = super().ReadData(True)
             self.reader = FipReader(self.fip_data)
diff --git a/tools/binman/etype/cbfs.py b/tools/binman/etype/cbfs.py
index 2459388f842..cc1fbdf4b57 100644
--- a/tools/binman/etype/cbfs.py
+++ b/tools/binman/etype/cbfs.py
@@ -276,13 +276,13 @@ class Entry_cbfs(Entry):
     def GetEntries(self):
         return self._entries
 
-    def ReadData(self, decomp=True):
-        data = super().ReadData(True)
+    def ReadData(self, decomp=True, alt_format=None):
+        data = super().ReadData(True, alt_format)
         return data
 
-    def ReadChildData(self, child, decomp=True):
+    def ReadChildData(self, child, decomp=True, alt_format=None):
         if not self.reader:
-            data = super().ReadData(True)
+            data = super().ReadData(True, alt_format)
             self.reader = cbfs_util.CbfsReader(data)
         reader = self.reader
         cfile = reader.files.get(child.name)
diff --git a/tools/binman/etype/fdtmap.py b/tools/binman/etype/fdtmap.py
index 2339feeba8d..aaaf2de4383 100644
--- a/tools/binman/etype/fdtmap.py
+++ b/tools/binman/etype/fdtmap.py
@@ -74,6 +74,10 @@ class Entry_fdtmap(Entry):
 
     If allow-repack is used then 'orig-offset' and 'orig-size' properties are
     added as necessary. See the binman README.
+
+    When extracting files, an alternative 'fdt' format is available for fdtmaps.
+    Use `binman extract -F fdt ...` to use this. It will export a devicetree,
+    without the fdtmap header, so it can be viewed with `fdtdump`.
     """
     def __init__(self, section, etype, node):
         # Put these here to allow entry-docs and help to work without libfdt
@@ -86,6 +90,10 @@ class Entry_fdtmap(Entry):
         from dtoc.fdt import Fdt
 
         super().__init__(section, etype, node)
+        self.alt_formats = ['fdt']
+
+    def CheckAltFormats(self, alt_formats):
+        alt_formats['fdt'] = self, 'Extract the devicetree blob from the fdtmap'
 
     def _GetFdtmap(self):
         """Build an FDT map from the entries in the current image
@@ -147,3 +155,7 @@ class Entry_fdtmap(Entry):
         processing, e.g. the image-pos properties.
         """
         return self.ProcessContentsUpdate(self._GetFdtmap())
+
+    def GetAltFormat(self, data, alt_format):
+        if alt_format == 'fdt':
+            return data[FDTMAP_HDR_LEN:]
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 6ce07dd37d7..43436a11f27 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -80,7 +80,7 @@ class Entry_section(Entry):
         Binman calls this after the image has been packed, to update the
         location that all the entries ended up at.
 
-    ReadChildData(child, decomp):
+    ReadChildData(child, decomp, alt_format):
         The default version of this may be good enough, if you are able to
         implement SetImagePos() correctly. But that is a bit of a bypass, so
         you can override this method to read from your custom file format. It
@@ -93,6 +93,11 @@ class Entry_section(Entry):
         uncompress it first, then return the uncompressed data (`decomp` is
         True). This is used by the `binman extract -U` option.
 
+        If your entry supports alternative formats, the alt_format provides the
+        alternative format that the user has selected. Your function should
+        return data in that format. This is used by the 'binman extract -l'
+        option.
+
         Binman calls this when reading in an image, in order to populate all the
         entries with the data from that image (`binman ls`).
 
@@ -750,9 +755,9 @@ class Entry_section(Entry):
         """
         return self._sort
 
-    def ReadData(self, decomp=True):
+    def ReadData(self, decomp=True, alt_format=None):
         tout.Info("ReadData path='%s'" % self.GetPath())
-        parent_data = self.section.ReadData(True)
+        parent_data = self.section.ReadData(True, alt_format)
         offset = self.offset - self.section._skip_at_start
         data = parent_data[offset:offset + self.size]
         tout.Info(
@@ -761,9 +766,9 @@ class Entry_section(Entry):
                    self.size, len(data)))
         return data
 
-    def ReadChildData(self, child, decomp=True):
+    def ReadChildData(self, child, decomp=True, alt_format=None):
         tout.Debug(f"ReadChildData for child '{child.GetPath()}'")
-        parent_data = self.ReadData(True)
+        parent_data = self.ReadData(True, alt_format)
         offset = child.offset - self._skip_at_start
         tout.Debug("Extract for child '%s': offset %#x, skip_at_start %#x, result %#x" %
                    (child.GetPath(), child.offset, self._skip_at_start, offset))
@@ -775,6 +780,10 @@ class Entry_section(Entry):
                 tout.Info("%s: Decompressing data size %#x with algo '%s' to data size %#x" %
                             (child.GetPath(), len(indata), child.compress,
                             len(data)))
+        if alt_format:
+            new_data = child.GetAltFormat(data, alt_format)
+            if new_data is not None:
+                data = new_data
         return data
 
     def WriteChildData(self, child):
@@ -846,3 +855,7 @@ class Entry_section(Entry):
         if not self._ignore_missing:
             missing = ', '.join(missing)
             entry.Raise(f'Missing required properties/entry args: {missing}')
+
+    def CheckAltFormats(self, alt_formats):
+        for entry in self._entries.values():
+            entry.CheckAltFormats(alt_formats)
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index d8ddbc81c1f..0ce829d1225 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -4898,6 +4898,40 @@ class TestFunctional(unittest.TestCase):
         # There should be a U-Boot after the final FIP
         self.assertEqual(U_BOOT_DATA, data[-4:])
 
+    def testAltFormat(self):
+        """Test that alternative formats can be used to extract"""
+        self._DoReadFileRealDtb('213_fdtmap_alt_format.dts')
+
+        try:
+            tmpdir, updated_fname = self._SetupImageInTmpdir()
+            with test_util.capture_sys_output() as (stdout, _):
+                self._DoBinman('extract', '-i', updated_fname, '-F', 'list')
+            self.assertEqual(
+                '''Flag (-F)   Entry type            Description
+fdt         fdtmap                Extract the devicetree blob from the fdtmap
+''',
+                stdout.getvalue())
+
+            dtb = os.path.join(tmpdir, 'fdt.dtb')
+            self._DoBinman('extract', '-i', updated_fname, '-F', 'fdt', '-f',
+                           dtb, 'fdtmap')
+
+            # Check that we can read it and it can be scanning, meaning it does
+            # not have a 16-byte fdtmap header
+            data = tools.ReadFile(dtb)
+            dtb = fdt.Fdt.FromData(data)
+            dtb.Scan()
+
+            # Now check u-boot which has no alt_format
+            fname = os.path.join(tmpdir, 'fdt.dtb')
+            self._DoBinman('extract', '-i', updated_fname, '-F', 'dummy',
+                           '-f', fname, 'u-boot')
+            data = tools.ReadFile(fname)
+            self.assertEqual(U_BOOT_DATA, data)
+
+        finally:
+            shutil.rmtree(tmpdir)
+
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/tools/binman/image.py b/tools/binman/image.py
index 891e8b488e9..f0a7d65299e 100644
--- a/tools/binman/image.py
+++ b/tools/binman/image.py
@@ -223,7 +223,7 @@ class Image(section.Entry_section):
             entries = entry.GetEntries()
         return entry
 
-    def ReadData(self, decomp=True):
+    def ReadData(self, decomp=True, alt_format=None):
         tout.Debug("Image '%s' ReadData(), size=%#x" %
                    (self.GetPath(), len(self._data)))
         return self._data
diff --git a/tools/binman/test/213_fdtmap_alt_format.dts b/tools/binman/test/213_fdtmap_alt_format.dts
new file mode 100644
index 00000000000..d9aef04bcf6
--- /dev/null
+++ b/tools/binman/test/213_fdtmap_alt_format.dts
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		u-boot {
+		};
+		fdtmap {
+		};
+	};
+};
diff --git a/tools/binman/test/214_no_alt_format.dts b/tools/binman/test/214_no_alt_format.dts
new file mode 100644
index 00000000000..f00bcdd5764
--- /dev/null
+++ b/tools/binman/test/214_no_alt_format.dts
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		u-boot {
+		};
+	};
+};
-- 
2.34.0.rc2.393.gf8c9666880-goog


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 4/7] dtoc: Add support for reading string-list properties
  2021-11-24  4:09 [PATCH 0/7] meson: Demonstration of using binman to produce the image Simon Glass
                   ` (2 preceding siblings ...)
  2021-11-24  4:09 ` [PATCH 3/7] binman: Allow extracting a file in an alternative format Simon Glass
@ 2021-11-24  4:09 ` Simon Glass
  2021-11-24  4:09 ` [PATCH 5/7] binman: Support lists of external blobs Simon Glass
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Simon Glass @ 2021-11-24  4:09 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Simon Glass, Walter Lozano

Add a function to read a list of strings from the devicetree.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/dtoc/fdt_util.py | 21 +++++++++++++++++++++
 tools/dtoc/test_fdt.py |  9 +++++++++
 2 files changed, 30 insertions(+)

diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py
index 51bdbdcd3b2..19eb13aef33 100644
--- a/tools/dtoc/fdt_util.py
+++ b/tools/dtoc/fdt_util.py
@@ -163,6 +163,27 @@ def GetString(node, propname, default=None):
                          "a single string" % (node.name, propname))
     return value
 
+def GetStringList(node, propname, default=None):
+    """Get a string list from a property
+
+    Args:
+        node (Node): Node object to read from
+        propname (str): property name to read
+        default (list of str): Default value to use if the node/property do not
+            exist, or None
+
+    Returns:
+        String value read, or default if none
+    """
+    prop = node.props.get(propname)
+    if not prop:
+        return default
+    value = prop.value
+    if not isinstance(value, list):
+        strval = GetString(node, propname)
+        return [strval]
+    return value
+
 def GetBool(node, propname, default=False):
     """Get an boolean from a property
 
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index 7a4c7efaa4a..55b70e98764 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -615,6 +615,15 @@ class TestFdtUtil(unittest.TestCase):
         self.assertIn("property 'stringarray' has list value: expecting a "
                       'single string', str(e.exception))
 
+    def testGetStringList(self):
+        self.assertEqual(['message'],
+                         fdt_util.GetStringList(self.node, 'stringval'))
+        self.assertEqual(
+            ['multi-word', 'message'],
+            fdt_util.GetStringList(self.node, 'stringarray'))
+        self.assertEqual(['test'],
+                         fdt_util.GetStringList(self.node, 'missing', ['test']))
+
     def testGetBool(self):
         self.assertEqual(True, fdt_util.GetBool(self.node, 'boolval'))
         self.assertEqual(False, fdt_util.GetBool(self.node, 'missing'))
-- 
2.34.0.rc2.393.gf8c9666880-goog


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 5/7] binman: Support lists of external blobs
  2021-11-24  4:09 [PATCH 0/7] meson: Demonstration of using binman to produce the image Simon Glass
                   ` (3 preceding siblings ...)
  2021-11-24  4:09 ` [PATCH 4/7] dtoc: Add support for reading string-list properties Simon Glass
@ 2021-11-24  4:09 ` Simon Glass
  2021-11-24  4:09 ` [PATCH 6/7] binman: Rename _ReadSubnodes() to ReadEntries() Simon Glass
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Simon Glass @ 2021-11-24  4:09 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Simon Glass

Sometimes it is useful to have a list of related external blobs in a
single entry. An example is the DDR binaries used by meson. There are
9 files in total. Add support for this, so we don't have to have a
separate entry for each.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 scripts/pylint.base                           |  1 +
 tools/binman/entries.rst                      | 14 +++++
 tools/binman/etype/blob.py                    | 16 ++++-
 tools/binman/etype/blob_ext_list.py           | 58 +++++++++++++++++++
 tools/binman/ftest.py                         | 20 +++++++
 tools/binman/test/215_blob_ext_list.dts       | 14 +++++
 .../binman/test/216_blob_ext_list_missing.dts | 14 +++++
 7 files changed, 134 insertions(+), 3 deletions(-)
 create mode 100644 tools/binman/etype/blob_ext_list.py
 create mode 100644 tools/binman/test/215_blob_ext_list.dts
 create mode 100644 tools/binman/test/216_blob_ext_list_missing.dts

diff --git a/scripts/pylint.base b/scripts/pylint.base
index 3d891edf261..1b320e421e3 100644
--- a/scripts/pylint.base
+++ b/scripts/pylint.base
@@ -22,6 +22,7 @@ binman.state 3.30
 blob -1.94
 blob_dtb -10.00
 blob_ext -20.00
+blob_ext_list -0.32
 blob_named_by_arg -7.78
 blob_phase -5.00
 buildman.board 7.11
diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
index cf3a6e69599..c47f7df0980 100644
--- a/tools/binman/entries.rst
+++ b/tools/binman/entries.rst
@@ -223,6 +223,20 @@ See 'blob' for Properties / Entry arguments.
 
 
 
+Entry: blob-ext-list: List of externally built binary blobs
+-----------------------------------------------------------
+
+This is like blob-ext except that a number of blobs can be provided,
+typically with some sort of relationship, e.g. all are DDC parameters.
+
+If any of the external files needed by this llist is missing, binman can
+optionally ignore it and produce a broken image with a warning.
+
+Args:
+    filenames: List of filenames to read and include
+
+
+
 Entry: blob-named-by-arg: A blob entry which gets its filename property from its subclass
 -----------------------------------------------------------------------------------------
 
diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py
index fae86ca3ec0..8c1b809e8da 100644
--- a/tools/binman/etype/blob.py
+++ b/tools/binman/etype/blob.py
@@ -48,10 +48,10 @@ class Entry_blob(Entry):
         self.ReadBlobContents()
         return True
 
-    def ReadBlobContents(self):
+    def ReadFileContents(self, pathname):
         """Read blob contents into memory
 
-        This function compresses the data before storing if needed.
+        This function compresses the data before returning if needed.
 
         We assume the data is small enough to fit into memory. If this
         is used for large filesystem image that might not be true.
@@ -59,13 +59,23 @@ class Entry_blob(Entry):
         new Entry method which can read in chunks. Then we could copy
         the data in chunks and avoid reading it all at once. For now
         this seems like an unnecessary complication.
+
+        Args:
+            pathname (str): Pathname to read from
+
+        Returns:
+            bytes: Data read
         """
         state.TimingStart('read')
-        indata = tools.ReadFile(self._pathname)
+        indata = tools.ReadFile(pathname)
         state.TimingAccum('read')
         state.TimingStart('compress')
         data = self.CompressData(indata)
         state.TimingAccum('compress')
+        return data
+
+    def ReadBlobContents(self):
+        data = self.ReadFileContents(self._pathname)
         self.SetContents(data)
         return True
 
diff --git a/tools/binman/etype/blob_ext_list.py b/tools/binman/etype/blob_ext_list.py
new file mode 100644
index 00000000000..136ae819946
--- /dev/null
+++ b/tools/binman/etype/blob_ext_list.py
@@ -0,0 +1,58 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2016 Google, Inc
+# Written by Simon Glass <sjg@chromium.org>
+#
+# Entry-type module for a list of external blobs, not built by U-Boot
+#
+
+import os
+
+from binman.etype.blob import Entry_blob
+from dtoc import fdt_util
+from patman import tools
+from patman import tout
+
+class Entry_blob_ext_list(Entry_blob):
+    """List of externally built binary blobs
+
+    This is like blob-ext except that a number of blobs can be provided,
+    typically with some sort of relationship, e.g. all are DDC parameters.
+
+    If any of the external files needed by this llist is missing, binman can
+    optionally ignore it and produce a broken image with a warning.
+
+    Args:
+        filenames: List of filenames to read and include
+    """
+    def __init__(self, section, etype, node):
+        Entry_blob.__init__(self, section, etype, node)
+        self.external = True
+
+    def ReadNode(self):
+        super().ReadNode()
+        self._filenames = fdt_util.GetStringList(self._node, 'filenames')
+        self._pathnames = []
+
+    def ObtainContents(self):
+        missing = False
+        pathnames = []
+        for fname in self._filenames:
+            pathname = tools.GetInputFilename(
+                fname, self.external and self.section.GetAllowMissing())
+            # Allow the file to be missing
+            if not pathname:
+                missing = True
+            pathnames.append(pathname)
+        self._pathnames = pathnames
+
+        if missing:
+            self.SetContents(b'')
+            self.missing = True
+            return True
+
+        data = bytearray()
+        for pathname in pathnames:
+            data += self.ReadFileContents(pathname)
+
+        self.SetContents(data)
+        return True
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 0ce829d1225..acbe107d6ae 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -4932,6 +4932,26 @@ fdt         fdtmap                Extract the devicetree blob from the fdtmap
         finally:
             shutil.rmtree(tmpdir)
 
+    def testExtblobList(self):
+        """Test an image with an external blob list"""
+        data = self._DoReadFile('215_blob_ext_list.dts')
+        self.assertEqual(REFCODE_DATA + FSP_M_DATA, data)
+
+    def testExtblobListMissing(self):
+        """Test an image with a missing external blob"""
+        with self.assertRaises(ValueError) as e:
+            self._DoReadFile('216_blob_ext_list_missing.dts')
+        self.assertIn("Filename 'missing-file' not found in input path",
+                      str(e.exception))
+
+    def testExtblobListMissingOk(self):
+        """Test an image with an missing external blob that is allowed"""
+        with test_util.capture_sys_output() as (stdout, stderr):
+            self._DoTestFile('216_blob_ext_list_missing.dts',
+                             allow_missing=True)
+        err = stderr.getvalue()
+        self.assertRegex(err, "Image 'main-section'.*missing.*: blob-ext")
+
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/tools/binman/test/215_blob_ext_list.dts b/tools/binman/test/215_blob_ext_list.dts
new file mode 100644
index 00000000000..aad2f0300d3
--- /dev/null
+++ b/tools/binman/test/215_blob_ext_list.dts
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		blob-ext-list {
+			filenames = "refcode.bin", "fsp_m.bin";
+		};
+	};
+};
diff --git a/tools/binman/test/216_blob_ext_list_missing.dts b/tools/binman/test/216_blob_ext_list_missing.dts
new file mode 100644
index 00000000000..c02c335c760
--- /dev/null
+++ b/tools/binman/test/216_blob_ext_list_missing.dts
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		blob-ext-list {
+			filenames = "refcode.bin", "missing-file";
+		};
+	};
+};
-- 
2.34.0.rc2.393.gf8c9666880-goog


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 6/7] binman: Rename _ReadSubnodes() to ReadEntries()
  2021-11-24  4:09 [PATCH 0/7] meson: Demonstration of using binman to produce the image Simon Glass
                   ` (4 preceding siblings ...)
  2021-11-24  4:09 ` [PATCH 5/7] binman: Support lists of external blobs Simon Glass
@ 2021-11-24  4:09 ` Simon Glass
  2021-11-24  4:09 ` [PATCH 7/7] RFC: Move Odroid-C2 to use binman to produce the image Simon Glass
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Simon Glass @ 2021-11-24  4:09 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Simon Glass

This method name is more commonly used for this function. Use it
consistently.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/binman/etype/fit.py        | 4 ++--
 tools/binman/etype/intel_ifwi.py | 4 ++--
 tools/binman/etype/mkimage.py    | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
index 6936f5736a6..b41187df80a 100644
--- a/tools/binman/etype/fit.py
+++ b/tools/binman/etype/fit.py
@@ -136,10 +136,10 @@ class Entry_fit(Entry):
                                                                   str)])[0]
 
     def ReadNode(self):
-        self._ReadSubnodes()
+        self.ReadEntries()
         super().ReadNode()
 
-    def _ReadSubnodes(self):
+    def ReadEntries(self):
         def _AddNode(base_node, depth, node):
             """Add a node to the FIT
 
diff --git a/tools/binman/etype/intel_ifwi.py b/tools/binman/etype/intel_ifwi.py
index 903d39bdbeb..ecbd78df5e5 100644
--- a/tools/binman/etype/intel_ifwi.py
+++ b/tools/binman/etype/intel_ifwi.py
@@ -50,7 +50,7 @@ class Entry_intel_ifwi(Entry_blob_ext):
         self._ifwi_entries = OrderedDict()
 
     def ReadNode(self):
-        self._ReadSubnodes()
+        self.ReadEntries()
         super().ReadNode()
 
     def _BuildIfwi(self):
@@ -117,7 +117,7 @@ class Entry_intel_ifwi(Entry_blob_ext):
         same = orig_data == self.data
         return same
 
-    def _ReadSubnodes(self):
+    def ReadEntries(self):
         """Read the subnodes to find out what should go in this IFWI"""
         for node in self._node.subnodes:
             entry = Entry.Create(self.section, node)
diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py
index e49977522e3..c08fd9dc0b6 100644
--- a/tools/binman/etype/mkimage.py
+++ b/tools/binman/etype/mkimage.py
@@ -37,7 +37,7 @@ class Entry_mkimage(Entry):
         self._args = fdt_util.GetString(self._node, 'args').split(' ')
         self._mkimage_entries = OrderedDict()
         self.align_default = None
-        self._ReadSubnodes()
+        self.ReadEntries()
 
     def ObtainContents(self):
         data = b''
@@ -55,7 +55,7 @@ class Entry_mkimage(Entry):
         self.SetContents(tools.ReadFile(output_fname))
         return True
 
-    def _ReadSubnodes(self):
+    def ReadEntries(self):
         """Read the subnodes to find out what should go in this image"""
         for node in self._node.subnodes:
             entry = Entry.Create(self, node)
-- 
2.34.0.rc2.393.gf8c9666880-goog


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 7/7] RFC: Move Odroid-C2 to use binman to produce the image
  2021-11-24  4:09 [PATCH 0/7] meson: Demonstration of using binman to produce the image Simon Glass
                   ` (5 preceding siblings ...)
  2021-11-24  4:09 ` [PATCH 6/7] binman: Rename _ReadSubnodes() to ReadEntries() Simon Glass
@ 2021-11-24  4:09 ` Simon Glass
  2021-11-24 14:26   ` Neil Armstrong
  2021-12-05 19:46 ` [PATCH 6/7] binman: Rename _ReadSubnodes() to ReadEntries() Simon Glass
                   ` (5 subsequent siblings)
  12 siblings, 1 reply; 17+ messages in thread
From: Simon Glass @ 2021-11-24  4:09 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Jaehoon Chung, Marek Szyprowski, Neil Armstrong,
	u-boot-amlogic

This shows how binman can be used to replace the long and complicated
instructions with an automated build. It is still complicated to read
but users don't have to worry about the details.

It needs some tidying up and only supports Odroid-C2 at present.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi | 107 ++++++++++++++++
 arch/arm/mach-meson/Kconfig                  |   1 +
 doc/board/amlogic/odroid-c4.rst              | 127 +++++--------------
 scripts/pylint.base                          |   1 +
 tools/binman/etype/aml_encrypt.py            | 124 ++++++++++++++++++
 tools/binman/ftest.py                        |   3 +
 tools/binman/missing-blob-help               |   6 +
 tools/binman/test/213_aml_encrypt.dts        |  38 ++++++
 tools/binman/test/214_list_no_dtb.dts        |  23 ++++
 9 files changed, 338 insertions(+), 92 deletions(-)
 create mode 100644 tools/binman/etype/aml_encrypt.py
 create mode 100644 tools/binman/test/213_aml_encrypt.dts
 create mode 100644 tools/binman/test/214_list_no_dtb.dts

diff --git a/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi b/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi
index 963bf96b256..b221ce6920b 100644
--- a/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi
+++ b/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi
@@ -6,6 +6,113 @@
 
 #include "meson-sm1-u-boot.dtsi"
 
+/{
+	binman {
+		/* run --bootmk on all the included inputs */
+		aml-encrypt {
+			missing-msg = "aml-encrypt";
+			aml-algo = "g12a";
+			aml-op = "bootmk";
+			aml-level = "v3";
+
+			/* produce a bl2, containing signed bl2 binaries */
+			bl2 {
+				type = "aml-encrypt";
+				aml-algo = "g12a";
+				aml-op = "bl2sig";
+
+				/* sign the binary contaiing bl2 and acs */
+				aml-input {
+					type = "section";
+					bl2 {
+						type = "blob-ext";
+						size = <0xe000>;
+						filename = "bl2.bin";
+					};
+					acs {
+						type = "blob-ext";
+						size = <0x1000>;
+						filename = "acs.bin";
+					};
+				};
+			};
+
+			/* produce a bl30, containing signed bl30 binaries */
+			bl30 {
+				type = "aml-encrypt";
+				aml-algo = "g12a";
+				aml-op = "bl3sig";
+				aml-level = "v3";
+				aml-type = "bl30";
+
+				/* sign the binary contaiing bl30 and bl301 */
+				aml-input {
+					type = "aml-encrypt";
+					aml-algo = "g12a";
+					aml-op = "bl30sig";
+					aml-level = "v3";
+
+					/*
+					 * put bl30 and bl301 together, with
+					 * the necessary paddiung
+					 */
+					aml-input {
+						type = "section";
+						bl30 {
+							type = "blob-ext";
+							size = <0xa000>;
+							filename = "bl30.bin";
+						};
+						bl301 {
+							type = "blob-ext";
+							size = <0x3400>;
+							filename = "bl301.bin";
+						};
+					};
+				};
+			};
+
+			/* sign the bl31 binary */
+			bl31 {
+				type = "aml-encrypt";
+				aml-algo = "g12a";
+				aml-op = "bl3sig";
+				aml-input = "bl31.img";
+				aml-level = "v3";
+				aml-type = "bl31";
+			};
+
+			/* sign the bl33 binary (which is U-Boot) */
+			bl33 {
+				type = "aml-encrypt";
+				aml-algo = "g12a";
+				aml-op = "bl3sig";
+				aml-compress = "lz4";
+				aml-level = "v3";
+				aml-type = "bl33";
+
+				aml-input {
+					type = "u-boot";
+				};
+			};
+
+			/* add the various DDR blobs */
+			aml-ddrfw {
+				missing-msg = "aml-ddrfw";
+				type = "blob-ext-list";
+				filenames = "ddr4_1d.fw", "ddr4_2d.fw",
+					"ddr3_1d.fw", "piei.fw",
+					"lpddr4_1d.fw", "lpddr4_2d.fw",
+					"diag_lpddr4.fw", "aml_ddr.fw",
+					"lpddr3_1d.fw";
+			};
+		};
+
+		fdtmap {
+		};
+	};
+};
+
 &ethmac {
 	snps,reset-gpio = <&gpio GPIOZ_15 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>;
 	snps,reset-delays-us = <0 10000 1000000>;
diff --git a/arch/arm/mach-meson/Kconfig b/arch/arm/mach-meson/Kconfig
index 6cba2c40dda..bcb87ea243c 100644
--- a/arch/arm/mach-meson/Kconfig
+++ b/arch/arm/mach-meson/Kconfig
@@ -48,6 +48,7 @@ config MESON_AXG
 config MESON_G12A
 	bool "G12A"
 	select MESON64_COMMON
+	select BINMAN
 	help
 	  Select this if your SoC is an S905X/D2
 
diff --git a/doc/board/amlogic/odroid-c4.rst b/doc/board/amlogic/odroid-c4.rst
index f66d60a54d1..5eae1e66e3a 100644
--- a/doc/board/amlogic/odroid-c4.rst
+++ b/doc/board/amlogic/odroid-c4.rst
@@ -22,17 +22,8 @@ applies for HC4.
 
 Schematics are available on the manufacturer website.
 
-U-Boot compilation
-------------------
-
-.. code-block:: bash
-
-    $ export CROSS_COMPILE=aarch64-none-elf-
-    $ make odroid-c4_defconfig
-    $ make
-
-Image creation
---------------
+Setting up binary blobs
+-----------------------
 
 Amlogic doesn't provide sources for the firmware and for tools needed
 to create the bootloader image, so it is necessary to obtain them from
@@ -40,98 +31,50 @@ the git tree published by the board vendor:
 
 .. code-block:: bash
 
-    $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
-    $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
-    $ tar xvfJ gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
-    $ tar xvfJ gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
-    $ export PATH=$PWD/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux/bin:$PWD/gcc-linaro-arm-none-eabi-4.8-2013.11_linux/bin:$PATH
+    # This may be needed with this older U-Boot release
+    apt remove libfdt-dev
 
-    $ DIR=odroid-c4
-    $ git clone --depth 1 \
+    wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
+    wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
+    tar xvfJ gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
+    tar xvfJ gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
+    export PATH=$PWD/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux/bin:$PWD/gcc-linaro-arm-none-eabi-4.8-2013.11_linux/bin:$PATH
+
+    DIR=odroid-c4
+    git clone --depth 1 \
        https://github.com/hardkernel/u-boot.git -b odroidg12-v2015.01 \
        $DIR
 
-    $ cd odroid-c4
-    $ make odroidc4_defconfig
-    $ make
-    $ export UBOOTDIR=$PWD
+    cd odroid-c4
+    make odroidc4_defconfig
+    make
+    export UBOOTDIR=$PWD
+
+U-Boot compilation
+------------------
 
 Go back to mainline U-Boot source tree then :
 
 .. code-block:: bash
 
-    $ mkdir fip
-
-    $ wget https://github.com/BayLibre/u-boot/releases/download/v2017.11-libretech-cc/blx_fix_g12a.sh -O fip/blx_fix.sh
-    $ cp $UBOOTDIR/build/scp_task/bl301.bin fip/
-    $ cp $UBOOTDIR/build/board/hardkernel/odroidc4/firmware/acs.bin fip/
-    $ cp $UBOOTDIR/fip/g12a/bl2.bin fip/
-    $ cp $UBOOTDIR/fip/g12a/bl30.bin fip/
-    $ cp $UBOOTDIR/fip/g12a/bl31.img fip/
-    $ cp $UBOOTDIR/fip/g12a/ddr3_1d.fw fip/
-    $ cp $UBOOTDIR/fip/g12a/ddr4_1d.fw fip/
-    $ cp $UBOOTDIR/fip/g12a/ddr4_2d.fw fip/
-    $ cp $UBOOTDIR/fip/g12a/diag_lpddr4.fw fip/
-    $ cp $UBOOTDIR/fip/g12a/lpddr3_1d.fw fip/
-    $ cp $UBOOTDIR/fip/g12a/lpddr4_1d.fw fip/
-    $ cp $UBOOTDIR/fip/g12a/lpddr4_2d.fw fip/
-    $ cp $UBOOTDIR/fip/g12a/piei.fw fip/
-    $ cp $UBOOTDIR/fip/g12a/aml_ddr.fw fip/
-    $ cp u-boot.bin fip/bl33.bin
-
-    $ sh fip/blx_fix.sh \
-    	fip/bl30.bin \
-    	fip/zero_tmp \
-    	fip/bl30_zero.bin \
-    	fip/bl301.bin \
-    	fip/bl301_zero.bin \
-    	fip/bl30_new.bin \
-    	bl30
-
-    $ sh fip/blx_fix.sh \
-    	fip/bl2.bin \
-    	fip/zero_tmp \
-    	fip/bl2_zero.bin \
-    	fip/acs.bin \
-    	fip/bl21_zero.bin \
-    	fip/bl2_new.bin \
-    	bl2
-
-    $ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bl30sig --input fip/bl30_new.bin \
-    					--output fip/bl30_new.bin.g12a.enc \
-    					--level v3
-    $ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bl3sig --input fip/bl30_new.bin.g12a.enc \
-    					--output fip/bl30_new.bin.enc \
-    					--level v3 --type bl30
-    $ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bl3sig --input fip/bl31.img \
-    					--output fip/bl31.img.enc \
-    					--level v3 --type bl31
-    $ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bl3sig --input fip/bl33.bin --compress lz4 \
-    					--output fip/bl33.bin.enc \
-    					--level v3 --type bl33 --compress lz4
-    $ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bl2sig --input fip/bl2_new.bin \
-    					--output fip/bl2.n.bin.sig
-    $ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bootmk \
-    		--output fip/u-boot.bin \
-    		--bl2 fip/bl2.n.bin.sig \
-    		--bl30 fip/bl30_new.bin.enc \
-    		--bl31 fip/bl31.img.enc \
-    		--bl33 fip/bl33.bin.enc \
-    		--ddrfw1 fip/ddr4_1d.fw \
-    		--ddrfw2 fip/ddr4_2d.fw \
-    		--ddrfw3 fip/ddr3_1d.fw \
-    		--ddrfw4 fip/piei.fw \
-    		--ddrfw5 fip/lpddr4_1d.fw \
-    		--ddrfw6 fip/lpddr4_2d.fw \
-    		--ddrfw7 fip/diag_lpddr4.fw \
-    		--ddrfw8 fip/aml_ddr.fw \
-    		--ddrfw9 fip/lpddr3_1d.fw \
-    		--level v3
+    $ export CROSS_COMPILE=aarch64-none-elf-
+    $ make odroid-c4_defconfig
+    $ BINMAN_TOOLPATHS=$UBOOTDIR/odroid-c4/fip/g12a \
+      BINMAN_INDIRS="$UBOOTDIR/fip/g12a \
+      $UBOOTDIR/build/board/hardkernel/odroidc4/firmware \
+      $UBOOTDIR/build/scp_task" make
 
 and then write the image to SD with:
 
 .. code-block:: bash
 
-    $ DEV=/dev/your_sd_device
-    $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1
-    $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=444
+    DEV=/dev/your_sd_device
+    dd if=image.bin of=$DEV conv=fsync,notrunc
+
+If you copy the `$UBOOTDIR/odroid-c4/fip/g12a/aml_encrypt_g12a` tool somewhere
+in your path, you can omit the `BINMAN_TOOLPATHS` option. The `BINMAN_INDIRS`
+variable provides a space-seperated list of directories containing the various
+binary blobs needed by the build.
+
+To see these, look at the Binman image description in
+`arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi`.
diff --git a/scripts/pylint.base b/scripts/pylint.base
index 1b320e421e3..2331ecd51e4 100644
--- a/scripts/pylint.base
+++ b/scripts/pylint.base
@@ -1,4 +1,5 @@
 _testing 0.83
+aml_encrypt 2.71
 atf_bl31 -6.00
 atf_fip 0.44
 binman.cbfs_util 7.70
diff --git a/tools/binman/etype/aml_encrypt.py b/tools/binman/etype/aml_encrypt.py
new file mode 100644
index 00000000000..3f570702dc5
--- /dev/null
+++ b/tools/binman/etype/aml_encrypt.py
@@ -0,0 +1,124 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2016 Google, Inc
+# Written by Simon Glass <sjg@chromium.org>
+#
+# Entry-type module for producing an image using aml-encrypt-g12a
+#
+
+from collections import OrderedDict
+
+from binman.entry import Entry
+from binman.etype.section import Entry_section
+from binman.etype.blob_ext import Entry_blob_ext
+from binman.etype.blob_ext_list import Entry_blob_ext_list
+from dtoc import fdt_util
+from patman import tools
+from patman import tout
+
+DDR_FW_COUNT = 9
+
+class Entry_aml_encrypt(Entry_section):
+    def __init__(self, section, etype, node):
+        super().__init__(section, etype, node)
+        self._entries = OrderedDict()
+        self.align_default = None
+        self._aml_algo = None
+        self._aml_op = None
+        self._aml_level = None
+
+    def ReadNode(self):
+        super().ReadNode()
+        self._aml_algo = fdt_util.GetString(self._node, 'aml-algo')
+        self._aml_op = fdt_util.GetString(self._node, 'aml-op')
+        self._aml_level = fdt_util.GetString(self._node, 'aml-level')
+        self._aml_input = fdt_util.GetString(self._node, 'aml-input')
+        self._aml_compress = fdt_util.GetString(self._node, 'aml-compress')
+        self._aml_type = fdt_util.GetString(self._node, 'aml-type')
+        #self._aml_ddrfw = {}
+        #for i in range(1, DDR_FW_COUNT + 1):
+            #self._aml_ddrfw[i] = fdt_util.GetString(self._node, f'aml-ddrfw{i}')
+        self.ReadEntries()
+
+    def ReadEntries(self):
+        """Read the subnodes to find out what should go in this image"""
+        for node in self._node.subnodes:
+            etype = None
+            if node.name.startswith('aml-') and 'type' not in node.props:
+                etype = 'blob-ext'
+            entry = Entry.Create(self, node, etype)
+            entry.ReadNode()
+            self._entries[entry.name] = entry
+
+    def BuildSectionData(self, required):
+        uniq = self.GetUniqueName()
+        output_fname = tools.GetOutputFilename('aml-out.%s' % uniq)
+        args = [f'aml_encrypt_{self._aml_algo}',
+            f'--{self._aml_op}',
+            '--output', output_fname
+            ]
+        if self._aml_level:
+            args += ['--level', f'{self._aml_level}']
+        if self._aml_compress:
+            args += ['--compress', f'{self._aml_compress}']
+        if self._aml_type:
+            args += ['--type', f'{self._aml_type}']
+        if self._aml_input:
+            input_pathname = tools.GetInputFilename(
+                self._aml_input,
+                self.external and self.section.GetAllowMissing())
+            if not input_pathname:
+                missing = True
+            args += ['--input', f'{input_pathname}']
+
+        missing = False
+        for entry in self._entries.values():
+            # First get the input data and put it in a file. If not available,
+            # try later.
+            entry_data = entry.GetData(required)
+            if not required and entry_data is None:
+                return None
+            flag_name = entry.name.replace('aml-', '')  # Drop the aml- prefix
+            if isinstance(entry, Entry_blob_ext_list):
+                for i, pathname in enumerate(entry._pathnames):
+                    args += [f'--{flag_name}{i + 1}', pathname]
+            elif isinstance(entry, Entry_blob_ext):
+                pathname = entry._pathname
+                args += [f'--{flag_name}', pathname]
+            else:
+                data = self.GetPaddedDataForEntry(entry, entry_data)
+                fname = tools.GetOutputFilename('aml-in.%s' %
+                                                entry.GetUniqueName())
+                tools.WriteFile(fname, data)
+                args += [f'--{flag_name}', fname]
+            if entry.missing:
+                missing = True
+
+        if missing:
+            self.missing = True
+            return b''
+
+        tout.Debug(f"Node '{self._node.path}': running: %s" % ' '.join(args))
+        tools.Run(*args)
+
+        # If an input file (or subnode!) is providing the input, the tools
+        # writes to the requested output file. Otherwise it uses the output file
+        # as a template for three files that it writes, ending in '.sd.bin',
+        # 'usb.bl2' and 'usb.tpl'. We use the first one as the image output
+        if self._aml_input or self._node.FindNode('aml-input'):
+            real_outfile = output_fname
+        else:
+            real_outfile = f'{output_fname}.sd.bin'
+        data = tools.ReadFile(real_outfile)
+        return data
+
+    def SetAllowMissing(self, allow_missing):
+        self.allow_missing = allow_missing
+
+    def SetImagePos(self, image_pos):
+        Entry.SetImagePos(self, image_pos)
+
+    def SetCalculatedProperties(self):
+        Entry.SetCalculatedProperties(self)
+
+    def CheckEntries(self):
+        Entry.CheckEntries(self)
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index acbe107d6ae..b05ff10ee5a 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -4952,6 +4952,9 @@ fdt         fdtmap                Extract the devicetree blob from the fdtmap
         err = stderr.getvalue()
         self.assertRegex(err, "Image 'main-section'.*missing.*: blob-ext")
 
+    def testAmlEncrypt(self):
+        self._DoTestFile('213_aml_encrypt.dts', allow_missing=True)
+
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/tools/binman/missing-blob-help b/tools/binman/missing-blob-help
index dc2d9c98111..849004adc00 100644
--- a/tools/binman/missing-blob-help
+++ b/tools/binman/missing-blob-help
@@ -22,3 +22,9 @@ k3-rti-wdt-firmware:
 If CONFIG_WDT_K3_RTI_LOAD_FW is enabled, a firmware image is needed for
 the R5F core(s) to trigger the system reset. One possible source is
 https://github.com/siemens/k3-rti-wdt.
+
+aml-encrypt:
+Some AML messages
+
+aml-ddrfw
+Amlogic DDR firmware files are missing
diff --git a/tools/binman/test/213_aml_encrypt.dts b/tools/binman/test/213_aml_encrypt.dts
new file mode 100644
index 00000000000..513da65d500
--- /dev/null
+++ b/tools/binman/test/213_aml_encrypt.dts
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		aml-encrypt {
+			missing-msg = "aml-encrypt";
+			aml-algo = "g12a";
+			aml-op = "bootmk";
+			aml-level = "v3";
+
+			aml-bl2 {
+				filename = "bl2.n.bin.sig";
+			};
+			aml-bl30 {
+				filename = "bl30_new.bin.enc";
+			};
+			aml-bl31 {
+				filename = "bl31.img.enc";
+			};
+			aml-bl33 {
+				filename = "bl33.bin.enc";
+			};
+			aml-ddrfw {
+				missing-msg = "aml-ddrfw";
+				type = "blob-ext-list";
+				filenames = "ddr4_1d.fw", "ddr4_2d.fw",
+					"ddr3_1d.fw", "piei.fw",
+					"lpddr4_1d.fw", "lpddr4_2d.fw",
+					"diag_lpddr4.fw", "aml_ddr.fw",
+					"lpddr3_1d.fw";
+			};
+		};
+	};
+};
diff --git a/tools/binman/test/214_list_no_dtb.dts b/tools/binman/test/214_list_no_dtb.dts
new file mode 100644
index 00000000000..47ecd058644
--- /dev/null
+++ b/tools/binman/test/214_list_no_dtb.dts
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		size = <0x300>;
+		atf-bl31 {
+			filename = "bl31.bin";
+		};
+		scp {
+			filename = "scp.bin";
+		};
+		fdtmap {
+		};
+		image-header {
+			location = "end";
+		};
+	};
+};
-- 
2.34.0.rc2.393.gf8c9666880-goog


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 7/7] RFC: Move Odroid-C2 to use binman to produce the image
  2021-11-24  4:09 ` [PATCH 7/7] RFC: Move Odroid-C2 to use binman to produce the image Simon Glass
@ 2021-11-24 14:26   ` Neil Armstrong
  2021-11-25  0:12     ` Simon Glass
  0 siblings, 1 reply; 17+ messages in thread
From: Neil Armstrong @ 2021-11-24 14:26 UTC (permalink / raw)
  To: Simon Glass, U-Boot Mailing List
  Cc: Jaehoon Chung, Marek Szyprowski, u-boot-amlogic

Hi Simon,

On 24/11/2021 05:09, Simon Glass wrote:
> This shows how binman can be used to replace the long and complicated
> instructions with an automated build. It is still complicated to read
> but users don't have to worry about the details.

Thanks for demonstarting that !

I'm really not confident about using proprietary tools from mainline u-boot
source tree.

Will the binman step quietly fail if tools/bins aren't available ?

> It needs some tidying up and only supports Odroid-C2 at present.

--------------------------------------------------- C4

But i get the spirit !

Seems it should work as-is on allmost all boards except Odroid-C2 which has
only pre-signed binaries provided by HK.

The only work will be to replace acs_tool.py for pre-G12 SoCs.

> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
>  arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi | 107 ++++++++++++++++
>  arch/arm/mach-meson/Kconfig                  |   1 +
>  doc/board/amlogic/odroid-c4.rst              | 127 +++++--------------
>  scripts/pylint.base                          |   1 +
>  tools/binman/etype/aml_encrypt.py            | 124 ++++++++++++++++++
>  tools/binman/ftest.py                        |   3 +
>  tools/binman/missing-blob-help               |   6 +
>  tools/binman/test/213_aml_encrypt.dts        |  38 ++++++
>  tools/binman/test/214_list_no_dtb.dts        |  23 ++++
>  9 files changed, 338 insertions(+), 92 deletions(-)
>  create mode 100644 tools/binman/etype/aml_encrypt.py
>  create mode 100644 tools/binman/test/213_aml_encrypt.dts
>  create mode 100644 tools/binman/test/214_list_no_dtb.dts
> 
> diff --git a/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi b/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi
> index 963bf96b256..b221ce6920b 100644
> --- a/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi
> +++ b/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi
> @@ -6,6 +6,113 @@
>  
>  #include "meson-sm1-u-boot.dtsi"
>  
> +/{
> +	binman {
> +		/* run --bootmk on all the included inputs */
> +		aml-encrypt {
> +			missing-msg = "aml-encrypt";
> +			aml-algo = "g12a";
> +			aml-op = "bootmk";
> +			aml-level = "v3";
> +
> +			/* produce a bl2, containing signed bl2 binaries */
> +			bl2 {
> +				type = "aml-encrypt";
> +				aml-algo = "g12a";
> +				aml-op = "bl2sig";
> +
> +				/* sign the binary contaiing bl2 and acs */
> +				aml-input {
> +					type = "section";
> +					bl2 {
> +						type = "blob-ext";
> +						size = <0xe000>;
> +						filename = "bl2.bin";
> +					};
> +					acs {
> +						type = "blob-ext";
> +						size = <0x1000>;
> +						filename = "acs.bin";
> +					};
> +				};

This is nice way to get rid of blx_fix.sh !

> +			};
> +
> +			/* produce a bl30, containing signed bl30 binaries */
> +			bl30 {
> +				type = "aml-encrypt";
> +				aml-algo = "g12a";
> +				aml-op = "bl3sig";
> +				aml-level = "v3";
> +				aml-type = "bl30";
> +
> +				/* sign the binary contaiing bl30 and bl301 */
> +				aml-input {
> +					type = "aml-encrypt";
> +					aml-algo = "g12a";
> +					aml-op = "bl30sig";
> +					aml-level = "v3";
> +
> +					/*
> +					 * put bl30 and bl301 together, with
> +					 * the necessary paddiung
> +					 */
> +					aml-input {
> +						type = "section";
> +						bl30 {
> +							type = "blob-ext";
> +							size = <0xa000>;
> +							filename = "bl30.bin";
> +						};
> +						bl301 {
> +							type = "blob-ext";
> +							size = <0x3400>;
> +							filename = "bl301.bin";
> +						};
> +					};
> +				};
> +			};
> +
> +			/* sign the bl31 binary */
> +			bl31 {
> +				type = "aml-encrypt";
> +				aml-algo = "g12a";
> +				aml-op = "bl3sig";
> +				aml-input = "bl31.img";
> +				aml-level = "v3";
> +				aml-type = "bl31";
> +			};
> +
> +			/* sign the bl33 binary (which is U-Boot) */
> +			bl33 {
> +				type = "aml-encrypt";
> +				aml-algo = "g12a";
> +				aml-op = "bl3sig";
> +				aml-compress = "lz4";
> +				aml-level = "v3";
> +				aml-type = "bl33";
> +
> +				aml-input {
> +					type = "u-boot";
> +				};
> +			};
> +
> +			/* add the various DDR blobs */
> +			aml-ddrfw {
> +				missing-msg = "aml-ddrfw";
> +				type = "blob-ext-list";
> +				filenames = "ddr4_1d.fw", "ddr4_2d.fw",
> +					"ddr3_1d.fw", "piei.fw",
> +					"lpddr4_1d.fw", "lpddr4_2d.fw",
> +					"diag_lpddr4.fw", "aml_ddr.fw",
> +					"lpddr3_1d.fw";
> +			};
> +		};
> +
> +		fdtmap {
> +		};
> +	};
> +};
> +
>  &ethmac {
>  	snps,reset-gpio = <&gpio GPIOZ_15 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>;
>  	snps,reset-delays-us = <0 10000 1000000>;
> diff --git a/arch/arm/mach-meson/Kconfig b/arch/arm/mach-meson/Kconfig
> index 6cba2c40dda..bcb87ea243c 100644
> --- a/arch/arm/mach-meson/Kconfig
> +++ b/arch/arm/mach-meson/Kconfig
> @@ -48,6 +48,7 @@ config MESON_AXG
>  config MESON_G12A
>  	bool "G12A"
>  	select MESON64_COMMON
> +	select BINMAN
>  	help
>  	  Select this if your SoC is an S905X/D2
>  
> diff --git a/doc/board/amlogic/odroid-c4.rst b/doc/board/amlogic/odroid-c4.rst
> index f66d60a54d1..5eae1e66e3a 100644
> --- a/doc/board/amlogic/odroid-c4.rst
> +++ b/doc/board/amlogic/odroid-c4.rst
> @@ -22,17 +22,8 @@ applies for HC4.
>  
>  Schematics are available on the manufacturer website.
>  
> -U-Boot compilation
> -------------------
> -
> -.. code-block:: bash
> -
> -    $ export CROSS_COMPILE=aarch64-none-elf-
> -    $ make odroid-c4_defconfig
> -    $ make
> -
> -Image creation
> ---------------
> +Setting up binary blobs
> +-----------------------
>  
>  Amlogic doesn't provide sources for the firmware and for tools needed
>  to create the bootloader image, so it is necessary to obtain them from
> @@ -40,98 +31,50 @@ the git tree published by the board vendor:
>  
>  .. code-block:: bash
>  
> -    $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
> -    $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
> -    $ tar xvfJ gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
> -    $ tar xvfJ gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
> -    $ export PATH=$PWD/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux/bin:$PWD/gcc-linaro-arm-none-eabi-4.8-2013.11_linux/bin:$PATH
> +    # This may be needed with this older U-Boot release
> +    apt remove libfdt-dev
>  
> -    $ DIR=odroid-c4
> -    $ git clone --depth 1 \
> +    wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
> +    wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
> +    tar xvfJ gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
> +    tar xvfJ gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
> +    export PATH=$PWD/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux/bin:$PWD/gcc-linaro-arm-none-eabi-4.8-2013.11_linux/bin:$PATH
> +
> +    DIR=odroid-c4
> +    git clone --depth 1 \
>         https://github.com/hardkernel/u-boot.git -b odroidg12-v2015.01 \
>         $DIR
>  
> -    $ cd odroid-c4
> -    $ make odroidc4_defconfig
> -    $ make
> -    $ export UBOOTDIR=$PWD
> +    cd odroid-c4
> +    make odroidc4_defconfig
> +    make
> +    export UBOOTDIR=$PWD
> +
> +U-Boot compilation
> +------------------
>  
>  Go back to mainline U-Boot source tree then :
>  
>  .. code-block:: bash
>  
> -    $ mkdir fip
> -
> -    $ wget https://github.com/BayLibre/u-boot/releases/download/v2017.11-libretech-cc/blx_fix_g12a.sh -O fip/blx_fix.sh
> -    $ cp $UBOOTDIR/build/scp_task/bl301.bin fip/
> -    $ cp $UBOOTDIR/build/board/hardkernel/odroidc4/firmware/acs.bin fip/
> -    $ cp $UBOOTDIR/fip/g12a/bl2.bin fip/
> -    $ cp $UBOOTDIR/fip/g12a/bl30.bin fip/
> -    $ cp $UBOOTDIR/fip/g12a/bl31.img fip/
> -    $ cp $UBOOTDIR/fip/g12a/ddr3_1d.fw fip/
> -    $ cp $UBOOTDIR/fip/g12a/ddr4_1d.fw fip/
> -    $ cp $UBOOTDIR/fip/g12a/ddr4_2d.fw fip/
> -    $ cp $UBOOTDIR/fip/g12a/diag_lpddr4.fw fip/
> -    $ cp $UBOOTDIR/fip/g12a/lpddr3_1d.fw fip/
> -    $ cp $UBOOTDIR/fip/g12a/lpddr4_1d.fw fip/
> -    $ cp $UBOOTDIR/fip/g12a/lpddr4_2d.fw fip/
> -    $ cp $UBOOTDIR/fip/g12a/piei.fw fip/
> -    $ cp $UBOOTDIR/fip/g12a/aml_ddr.fw fip/
> -    $ cp u-boot.bin fip/bl33.bin
> -
> -    $ sh fip/blx_fix.sh \
> -    	fip/bl30.bin \
> -    	fip/zero_tmp \
> -    	fip/bl30_zero.bin \
> -    	fip/bl301.bin \
> -    	fip/bl301_zero.bin \
> -    	fip/bl30_new.bin \
> -    	bl30
> -
> -    $ sh fip/blx_fix.sh \
> -    	fip/bl2.bin \
> -    	fip/zero_tmp \
> -    	fip/bl2_zero.bin \
> -    	fip/acs.bin \
> -    	fip/bl21_zero.bin \
> -    	fip/bl2_new.bin \
> -    	bl2
> -
> -    $ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bl30sig --input fip/bl30_new.bin \
> -    					--output fip/bl30_new.bin.g12a.enc \
> -    					--level v3
> -    $ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bl3sig --input fip/bl30_new.bin.g12a.enc \
> -    					--output fip/bl30_new.bin.enc \
> -    					--level v3 --type bl30
> -    $ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bl3sig --input fip/bl31.img \
> -    					--output fip/bl31.img.enc \
> -    					--level v3 --type bl31
> -    $ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bl3sig --input fip/bl33.bin --compress lz4 \
> -    					--output fip/bl33.bin.enc \
> -    					--level v3 --type bl33 --compress lz4
> -    $ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bl2sig --input fip/bl2_new.bin \
> -    					--output fip/bl2.n.bin.sig
> -    $ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bootmk \
> -    		--output fip/u-boot.bin \
> -    		--bl2 fip/bl2.n.bin.sig \
> -    		--bl30 fip/bl30_new.bin.enc \
> -    		--bl31 fip/bl31.img.enc \
> -    		--bl33 fip/bl33.bin.enc \
> -    		--ddrfw1 fip/ddr4_1d.fw \
> -    		--ddrfw2 fip/ddr4_2d.fw \
> -    		--ddrfw3 fip/ddr3_1d.fw \
> -    		--ddrfw4 fip/piei.fw \
> -    		--ddrfw5 fip/lpddr4_1d.fw \
> -    		--ddrfw6 fip/lpddr4_2d.fw \
> -    		--ddrfw7 fip/diag_lpddr4.fw \
> -    		--ddrfw8 fip/aml_ddr.fw \
> -    		--ddrfw9 fip/lpddr3_1d.fw \
> -    		--level v3
> +    $ export CROSS_COMPILE=aarch64-none-elf-
> +    $ make odroid-c4_defconfig
> +    $ BINMAN_TOOLPATHS=$UBOOTDIR/odroid-c4/fip/g12a \
> +      BINMAN_INDIRS="$UBOOTDIR/fip/g12a \
> +      $UBOOTDIR/build/board/hardkernel/odroidc4/firmware \
> +      $UBOOTDIR/build/scp_task" make
>  
>  and then write the image to SD with:
>  
>  .. code-block:: bash
>  
> -    $ DEV=/dev/your_sd_device
> -    $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1
> -    $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=444
> +    DEV=/dev/your_sd_device
> +    dd if=image.bin of=$DEV conv=fsync,notrunc
> +
> +If you copy the `$UBOOTDIR/odroid-c4/fip/g12a/aml_encrypt_g12a` tool somewhere
> +in your path, you can omit the `BINMAN_TOOLPATHS` option. The `BINMAN_INDIRS`
> +variable provides a space-seperated list of directories containing the various
> +binary blobs needed by the build.
> +
> +To see these, look at the Binman image description in
> +`arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi`.
> diff --git a/scripts/pylint.base b/scripts/pylint.base
> index 1b320e421e3..2331ecd51e4 100644
> --- a/scripts/pylint.base
> +++ b/scripts/pylint.base
> @@ -1,4 +1,5 @@
>  _testing 0.83
> +aml_encrypt 2.71
>  atf_bl31 -6.00
>  atf_fip 0.44
>  binman.cbfs_util 7.70
> diff --git a/tools/binman/etype/aml_encrypt.py b/tools/binman/etype/aml_encrypt.py
> new file mode 100644
> index 00000000000..3f570702dc5
> --- /dev/null
> +++ b/tools/binman/etype/aml_encrypt.py
> @@ -0,0 +1,124 @@
> +# SPDX-License-Identifier: GPL-2.0+
> +# Copyright (c) 2016 Google, Inc
> +# Written by Simon Glass <sjg@chromium.org>
> +#
> +# Entry-type module for producing an image using aml-encrypt-g12a
> +#
> +
> +from collections import OrderedDict
> +
> +from binman.entry import Entry
> +from binman.etype.section import Entry_section
> +from binman.etype.blob_ext import Entry_blob_ext
> +from binman.etype.blob_ext_list import Entry_blob_ext_list
> +from dtoc import fdt_util
> +from patman import tools
> +from patman import tout
> +
> +DDR_FW_COUNT = 9
> +
> +class Entry_aml_encrypt(Entry_section):
> +    def __init__(self, section, etype, node):
> +        super().__init__(section, etype, node)
> +        self._entries = OrderedDict()
> +        self.align_default = None
> +        self._aml_algo = None
> +        self._aml_op = None
> +        self._aml_level = None
> +
> +    def ReadNode(self):
> +        super().ReadNode()
> +        self._aml_algo = fdt_util.GetString(self._node, 'aml-algo')
> +        self._aml_op = fdt_util.GetString(self._node, 'aml-op')
> +        self._aml_level = fdt_util.GetString(self._node, 'aml-level')
> +        self._aml_input = fdt_util.GetString(self._node, 'aml-input')
> +        self._aml_compress = fdt_util.GetString(self._node, 'aml-compress')
> +        self._aml_type = fdt_util.GetString(self._node, 'aml-type')
> +        #self._aml_ddrfw = {}
> +        #for i in range(1, DDR_FW_COUNT + 1):
> +            #self._aml_ddrfw[i] = fdt_util.GetString(self._node, f'aml-ddrfw{i}')
> +        self.ReadEntries()
> +
> +    def ReadEntries(self):
> +        """Read the subnodes to find out what should go in this image"""
> +        for node in self._node.subnodes:
> +            etype = None
> +            if node.name.startswith('aml-') and 'type' not in node.props:
> +                etype = 'blob-ext'
> +            entry = Entry.Create(self, node, etype)
> +            entry.ReadNode()
> +            self._entries[entry.name] = entry
> +
> +    def BuildSectionData(self, required):
> +        uniq = self.GetUniqueName()
> +        output_fname = tools.GetOutputFilename('aml-out.%s' % uniq)
> +        args = [f'aml_encrypt_{self._aml_algo}',
> +            f'--{self._aml_op}',
> +            '--output', output_fname
> +            ]
> +        if self._aml_level:
> +            args += ['--level', f'{self._aml_level}']
> +        if self._aml_compress:
> +            args += ['--compress', f'{self._aml_compress}']
> +        if self._aml_type:
> +            args += ['--type', f'{self._aml_type}']
> +        if self._aml_input:
> +            input_pathname = tools.GetInputFilename(
> +                self._aml_input,
> +                self.external and self.section.GetAllowMissing())
> +            if not input_pathname:
> +                missing = True
> +            args += ['--input', f'{input_pathname}']
> +
> +        missing = False
> +        for entry in self._entries.values():
> +            # First get the input data and put it in a file. If not available,
> +            # try later.
> +            entry_data = entry.GetData(required)
> +            if not required and entry_data is None:
> +                return None
> +            flag_name = entry.name.replace('aml-', '')  # Drop the aml- prefix
> +            if isinstance(entry, Entry_blob_ext_list):
> +                for i, pathname in enumerate(entry._pathnames):
> +                    args += [f'--{flag_name}{i + 1}', pathname]
> +            elif isinstance(entry, Entry_blob_ext):
> +                pathname = entry._pathname
> +                args += [f'--{flag_name}', pathname]
> +            else:
> +                data = self.GetPaddedDataForEntry(entry, entry_data)
> +                fname = tools.GetOutputFilename('aml-in.%s' %
> +                                                entry.GetUniqueName())
> +                tools.WriteFile(fname, data)
> +                args += [f'--{flag_name}', fname]
> +            if entry.missing:
> +                missing = True
> +
> +        if missing:
> +            self.missing = True
> +            return b''
> +
> +        tout.Debug(f"Node '{self._node.path}': running: %s" % ' '.join(args))
> +        tools.Run(*args)
> +
> +        # If an input file (or subnode!) is providing the input, the tools
> +        # writes to the requested output file. Otherwise it uses the output file
> +        # as a template for three files that it writes, ending in '.sd.bin',
> +        # 'usb.bl2' and 'usb.tpl'. We use the first one as the image output
> +        if self._aml_input or self._node.FindNode('aml-input'):
> +            real_outfile = output_fname
> +        else:
> +            real_outfile = f'{output_fname}.sd.bin'
> +        data = tools.ReadFile(real_outfile)
> +        return data
> +
> +    def SetAllowMissing(self, allow_missing):
> +        self.allow_missing = allow_missing
> +
> +    def SetImagePos(self, image_pos):
> +        Entry.SetImagePos(self, image_pos)
> +
> +    def SetCalculatedProperties(self):
> +        Entry.SetCalculatedProperties(self)
> +
> +    def CheckEntries(self):
> +        Entry.CheckEntries(self)
> diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
> index acbe107d6ae..b05ff10ee5a 100644
> --- a/tools/binman/ftest.py
> +++ b/tools/binman/ftest.py
> @@ -4952,6 +4952,9 @@ fdt         fdtmap                Extract the devicetree blob from the fdtmap
>          err = stderr.getvalue()
>          self.assertRegex(err, "Image 'main-section'.*missing.*: blob-ext")
>  
> +    def testAmlEncrypt(self):
> +        self._DoTestFile('213_aml_encrypt.dts', allow_missing=True)
> +
>  
>  if __name__ == "__main__":
>      unittest.main()
> diff --git a/tools/binman/missing-blob-help b/tools/binman/missing-blob-help
> index dc2d9c98111..849004adc00 100644
> --- a/tools/binman/missing-blob-help
> +++ b/tools/binman/missing-blob-help
> @@ -22,3 +22,9 @@ k3-rti-wdt-firmware:
>  If CONFIG_WDT_K3_RTI_LOAD_FW is enabled, a firmware image is needed for
>  the R5F core(s) to trigger the system reset. One possible source is
>  https://github.com/siemens/k3-rti-wdt.
> +
> +aml-encrypt:
> +Some AML messages
> +
> +aml-ddrfw
> +Amlogic DDR firmware files are missing
> diff --git a/tools/binman/test/213_aml_encrypt.dts b/tools/binman/test/213_aml_encrypt.dts
> new file mode 100644
> index 00000000000..513da65d500
> --- /dev/null
> +++ b/tools/binman/test/213_aml_encrypt.dts
> @@ -0,0 +1,38 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/dts-v1/;
> +
> +/ {
> +	#address-cells = <1>;
> +	#size-cells = <1>;
> +
> +	binman {
> +		aml-encrypt {
> +			missing-msg = "aml-encrypt";
> +			aml-algo = "g12a";
> +			aml-op = "bootmk";
> +			aml-level = "v3";
> +
> +			aml-bl2 {
> +				filename = "bl2.n.bin.sig";
> +			};
> +			aml-bl30 {
> +				filename = "bl30_new.bin.enc";
> +			};
> +			aml-bl31 {
> +				filename = "bl31.img.enc";
> +			};
> +			aml-bl33 {
> +				filename = "bl33.bin.enc";
> +			};
> +			aml-ddrfw {
> +				missing-msg = "aml-ddrfw";
> +				type = "blob-ext-list";
> +				filenames = "ddr4_1d.fw", "ddr4_2d.fw",
> +					"ddr3_1d.fw", "piei.fw",
> +					"lpddr4_1d.fw", "lpddr4_2d.fw",
> +					"diag_lpddr4.fw", "aml_ddr.fw",
> +					"lpddr3_1d.fw";
> +			};
> +		};
> +	};
> +};
> diff --git a/tools/binman/test/214_list_no_dtb.dts b/tools/binman/test/214_list_no_dtb.dts
> new file mode 100644
> index 00000000000..47ecd058644
> --- /dev/null
> +++ b/tools/binman/test/214_list_no_dtb.dts
> @@ -0,0 +1,23 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +
> +/dts-v1/;
> +
> +/ {
> +	#address-cells = <1>;
> +	#size-cells = <1>;
> +
> +	binman {
> +		size = <0x300>;
> +		atf-bl31 {
> +			filename = "bl31.bin";
> +		};
> +		scp {
> +			filename = "scp.bin";
> +		};
> +		fdtmap {
> +		};
> +		image-header {
> +			location = "end";
> +		};
> +	};
> +};
> 


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 7/7] RFC: Move Odroid-C2 to use binman to produce the image
  2021-11-24 14:26   ` Neil Armstrong
@ 2021-11-25  0:12     ` Simon Glass
  2021-11-25  8:31       ` Neil Armstrong
  0 siblings, 1 reply; 17+ messages in thread
From: Simon Glass @ 2021-11-25  0:12 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: U-Boot Mailing List, Jaehoon Chung, Marek Szyprowski, u-boot-amlogic

Hi Neil,

On Wed, 24 Nov 2021 at 07:26, Neil Armstrong <narmstrong@baylibre.com> wrote:
>
> Hi Simon,
>
> On 24/11/2021 05:09, Simon Glass wrote:
> > This shows how binman can be used to replace the long and complicated
> > instructions with an automated build. It is still complicated to read
> > but users don't have to worry about the details.
>
> Thanks for demonstarting that !

Thanks for looking at it.

>
> I'm really not confident about using proprietary tools from mainline u-boot
> source tree.

Arguably people already are doing this. At least this way it is in the
open. If people have the right tools installed it will just work, with
no extra steps.

>
> Will the binman step quietly fail if tools/bins aren't available ?

It handles the case where binaries are missing (that's the
--allow-missing) but not tools. I think we can do a similar thing,
where it just warns that the image won't work because of a missing
tool.

When a blob is missing there are instructions to tell the user how to
create it. For tools we could have instructions on where to download
the tool.

Is someone working on upstreaming the tools?

>
> > It needs some tidying up and only supports Odroid-C2 at present.
>
> --------------------------------------------------- C4
>
> But i get the spirit !
>
> Seems it should work as-is on allmost all boards except Odroid-C2 which has
> only pre-signed binaries provided by HK.

OK. There are a lot of instructions in doc/board/amlogic - are they
all mostly the same If so we can use a common binman description for
all boards.

>
> The only work will be to replace acs_tool.py for pre-G12 SoCs.
>
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> >  arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi | 107 ++++++++++++++++
> >  arch/arm/mach-meson/Kconfig                  |   1 +
> >  doc/board/amlogic/odroid-c4.rst              | 127 +++++--------------
> >  scripts/pylint.base                          |   1 +
> >  tools/binman/etype/aml_encrypt.py            | 124 ++++++++++++++++++
> >  tools/binman/ftest.py                        |   3 +
> >  tools/binman/missing-blob-help               |   6 +
> >  tools/binman/test/213_aml_encrypt.dts        |  38 ++++++
> >  tools/binman/test/214_list_no_dtb.dts        |  23 ++++
> >  9 files changed, 338 insertions(+), 92 deletions(-)
> >  create mode 100644 tools/binman/etype/aml_encrypt.py
> >  create mode 100644 tools/binman/test/213_aml_encrypt.dts
> >  create mode 100644 tools/binman/test/214_list_no_dtb.dts
> >
> > diff --git a/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi b/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi
> > index 963bf96b256..b221ce6920b 100644
> > --- a/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi
> > +++ b/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi
> > @@ -6,6 +6,113 @@
> >
> >  #include "meson-sm1-u-boot.dtsi"
> >
> > +/{
> > +     binman {
> > +             /* run --bootmk on all the included inputs */
> > +             aml-encrypt {
> > +                     missing-msg = "aml-encrypt";
> > +                     aml-algo = "g12a";
> > +                     aml-op = "bootmk";
> > +                     aml-level = "v3";
> > +
> > +                     /* produce a bl2, containing signed bl2 binaries */
> > +                     bl2 {
> > +                             type = "aml-encrypt";
> > +                             aml-algo = "g12a";
> > +                             aml-op = "bl2sig";
> > +
> > +                             /* sign the binary contaiing bl2 and acs */
> > +                             aml-input {
> > +                                     type = "section";
> > +                                     bl2 {
> > +                                             type = "blob-ext";
> > +                                             size = <0xe000>;
> > +                                             filename = "bl2.bin";
> > +                                     };
> > +                                     acs {
> > +                                             type = "blob-ext";
> > +                                             size = <0x1000>;
> > +                                             filename = "acs.bin";
> > +                                     };
> > +                             };
>
> This is nice way to get rid of blx_fix.sh !

Yes that sort of thing is easy with Binman.

>
> > +                     };
> > +
> > +                     /* produce a bl30, containing signed bl30 binaries */
> > +                     bl30 {
> > +                             type = "aml-encrypt";
> > +                             aml-algo = "g12a";
> > +                             aml-op = "bl3sig";
> > +                             aml-level = "v3";
> > +                             aml-type = "bl30";
> > +
> > +                             /* sign the binary contaiing bl30 and bl301 */
> > +                             aml-input {
> > +                                     type = "aml-encrypt";
> > +                                     aml-algo = "g12a";
> > +                                     aml-op = "bl30sig";
> > +                                     aml-level = "v3";
> > +
> > +                                     /*
> > +                                      * put bl30 and bl301 together, with
> > +                                      * the necessary paddiung
> > +                                      */
> > +                                     aml-input {
> > +                                             type = "section";
> > +                                             bl30 {
> > +                                                     type = "blob-ext";
> > +                                                     size = <0xa000>;
> > +                                                     filename = "bl30.bin";
> > +                                             };
> > +                                             bl301 {
> > +                                                     type = "blob-ext";
> > +                                                     size = <0x3400>;
> > +                                                     filename = "bl301.bin";
> > +                                             };
> > +                                     };
> > +                             };
> > +                     };
> > +
> > +                     /* sign the bl31 binary */
> > +                     bl31 {
> > +                             type = "aml-encrypt";
> > +                             aml-algo = "g12a";
> > +                             aml-op = "bl3sig";
> > +                             aml-input = "bl31.img";
> > +                             aml-level = "v3";
> > +                             aml-type = "bl31";
> > +                     };
> > +
> > +                     /* sign the bl33 binary (which is U-Boot) */
> > +                     bl33 {
> > +                             type = "aml-encrypt";
> > +                             aml-algo = "g12a";
> > +                             aml-op = "bl3sig";
> > +                             aml-compress = "lz4";
> > +                             aml-level = "v3";
> > +                             aml-type = "bl33";
> > +
> > +                             aml-input {
> > +                                     type = "u-boot";
> > +                             };
> > +                     };
> > +
> > +                     /* add the various DDR blobs */
> > +                     aml-ddrfw {
> > +                             missing-msg = "aml-ddrfw";
> > +                             type = "blob-ext-list";
> > +                             filenames = "ddr4_1d.fw", "ddr4_2d.fw",
> > +                                     "ddr3_1d.fw", "piei.fw",
> > +                                     "lpddr4_1d.fw", "lpddr4_2d.fw",
> > +                                     "diag_lpddr4.fw", "aml_ddr.fw",
> > +                                     "lpddr3_1d.fw";
> > +                     };
> > +             };
> > +
> > +             fdtmap {
> > +             };
> > +     };
> > +};
> > +
> >  &ethmac {
> >       snps,reset-gpio = <&gpio GPIOZ_15 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>;
> >       snps,reset-delays-us = <0 10000 1000000>;
> > diff --git a/arch/arm/mach-meson/Kconfig b/arch/arm/mach-meson/Kconfig
> > index 6cba2c40dda..bcb87ea243c 100644
> > --- a/arch/arm/mach-meson/Kconfig
> > +++ b/arch/arm/mach-meson/Kconfig
> > @@ -48,6 +48,7 @@ config MESON_AXG
> >  config MESON_G12A
> >       bool "G12A"
> >       select MESON64_COMMON
> > +     select BINMAN
> >       help
> >         Select this if your SoC is an S905X/D2
> >
> > diff --git a/doc/board/amlogic/odroid-c4.rst b/doc/board/amlogic/odroid-c4.rst
> > index f66d60a54d1..5eae1e66e3a 100644
> > --- a/doc/board/amlogic/odroid-c4.rst
> > +++ b/doc/board/amlogic/odroid-c4.rst
> > @@ -22,17 +22,8 @@ applies for HC4.
> >
> >  Schematics are available on the manufacturer website.
> >
> > -U-Boot compilation
> > -------------------
> > -
> > -.. code-block:: bash
> > -
> > -    $ export CROSS_COMPILE=aarch64-none-elf-
> > -    $ make odroid-c4_defconfig
> > -    $ make
> > -

[..]

Regards,
Simon

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 7/7] RFC: Move Odroid-C2 to use binman to produce the image
  2021-11-25  0:12     ` Simon Glass
@ 2021-11-25  8:31       ` Neil Armstrong
  0 siblings, 0 replies; 17+ messages in thread
From: Neil Armstrong @ 2021-11-25  8:31 UTC (permalink / raw)
  To: Simon Glass
  Cc: U-Boot Mailing List, Jaehoon Chung, Marek Szyprowski, u-boot-amlogic

On 25/11/2021 01:12, Simon Glass wrote:
> Hi Neil,
> 
> On Wed, 24 Nov 2021 at 07:26, Neil Armstrong <narmstrong@baylibre.com> wrote:
>>
>> Hi Simon,
>>
>> On 24/11/2021 05:09, Simon Glass wrote:
>>> This shows how binman can be used to replace the long and complicated
>>> instructions with an automated build. It is still complicated to read
>>> but users don't have to worry about the details.
>>
>> Thanks for demonstarting that !
> 
> Thanks for looking at it.
> 
>>
>> I'm really not confident about using proprietary tools from mainline u-boot
>> source tree.
> 
> Arguably people already are doing this. At least this way it is in the
> open. If people have the right tools installed it will just work, with
> no extra steps.

OK, no problem then

> 
>>
>> Will the binman step quietly fail if tools/bins aren't available ?
> 
> It handles the case where binaries are missing (that's the
> --allow-missing) but not tools. I think we can do a similar thing,
> where it just warns that the image won't work because of a missing
> tool.
> 
> When a blob is missing there are instructions to tell the user how to
> create it. For tools we could have instructions on where to download
> the tool.

Is there a easy way to bypass the binman step ? In case for example we
want to chainload the original u-boot binary, or wrap it using other
tools afterwards like for secure boot ?

> 
> Is someone working on upstreaming the tools?

There is some alternate open-source tools in C:

https://github.com/afaerber/meson-tools (GXBB, GXL & GXM only)
https://github.com/repk/gxlimg (GXBB, GXL, GXM & AXG only)
https://github.com/angerman/meson64-tools (developed for G12B, should work on G12A & SM1)

But no unified tool, all this should probably be rewritten in a binman plugin at some point.

> 
>>
>>> It needs some tidying up and only supports Odroid-C2 at present.
>>
>> --------------------------------------------------- C4
>>
>> But i get the spirit !
>>
>> Seems it should work as-is on allmost all boards except Odroid-C2 which has
>> only pre-signed binaries provided by HK.
> 
> OK. There are a lot of instructions in doc/board/amlogic - are they
> all mostly the same If so we can use a common binman description for
> all boards.
> 
>>
>> The only work will be to replace acs_tool.py for pre-G12 SoCs.
>>
>>>
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>> ---
>>>
>>>  arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi | 107 ++++++++++++++++
>>>  arch/arm/mach-meson/Kconfig                  |   1 +
>>>  doc/board/amlogic/odroid-c4.rst              | 127 +++++--------------
>>>  scripts/pylint.base                          |   1 +
>>>  tools/binman/etype/aml_encrypt.py            | 124 ++++++++++++++++++
>>>  tools/binman/ftest.py                        |   3 +
>>>  tools/binman/missing-blob-help               |   6 +
>>>  tools/binman/test/213_aml_encrypt.dts        |  38 ++++++
>>>  tools/binman/test/214_list_no_dtb.dts        |  23 ++++
>>>  9 files changed, 338 insertions(+), 92 deletions(-)
>>>  create mode 100644 tools/binman/etype/aml_encrypt.py
>>>  create mode 100644 tools/binman/test/213_aml_encrypt.dts
>>>  create mode 100644 tools/binman/test/214_list_no_dtb.dts
>>>
>>> diff --git a/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi b/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi
>>> index 963bf96b256..b221ce6920b 100644
>>> --- a/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi
>>> +++ b/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi
>>> @@ -6,6 +6,113 @@
>>>
>>>  #include "meson-sm1-u-boot.dtsi"
>>>
>>> +/{
>>> +     binman {
>>> +             /* run --bootmk on all the included inputs */
>>> +             aml-encrypt {
>>> +                     missing-msg = "aml-encrypt";
>>> +                     aml-algo = "g12a";
>>> +                     aml-op = "bootmk";
>>> +                     aml-level = "v3";
>>> +
>>> +                     /* produce a bl2, containing signed bl2 binaries */
>>> +                     bl2 {
>>> +                             type = "aml-encrypt";
>>> +                             aml-algo = "g12a";
>>> +                             aml-op = "bl2sig";
>>> +
>>> +                             /* sign the binary contaiing bl2 and acs */
>>> +                             aml-input {
>>> +                                     type = "section";
>>> +                                     bl2 {
>>> +                                             type = "blob-ext";
>>> +                                             size = <0xe000>;
>>> +                                             filename = "bl2.bin";
>>> +                                     };
>>> +                                     acs {
>>> +                                             type = "blob-ext";
>>> +                                             size = <0x1000>;
>>> +                                             filename = "acs.bin";
>>> +                                     };
>>> +                             };
>>
>> This is nice way to get rid of blx_fix.sh !
> 
> Yes that sort of thing is easy with Binman.
> 
>>
>>> +                     };
>>> +
>>> +                     /* produce a bl30, containing signed bl30 binaries */
>>> +                     bl30 {
>>> +                             type = "aml-encrypt";
>>> +                             aml-algo = "g12a";
>>> +                             aml-op = "bl3sig";
>>> +                             aml-level = "v3";
>>> +                             aml-type = "bl30";
>>> +
>>> +                             /* sign the binary contaiing bl30 and bl301 */
>>> +                             aml-input {
>>> +                                     type = "aml-encrypt";
>>> +                                     aml-algo = "g12a";
>>> +                                     aml-op = "bl30sig";
>>> +                                     aml-level = "v3";
>>> +
>>> +                                     /*
>>> +                                      * put bl30 and bl301 together, with
>>> +                                      * the necessary paddiung
>>> +                                      */
>>> +                                     aml-input {
>>> +                                             type = "section";
>>> +                                             bl30 {
>>> +                                                     type = "blob-ext";
>>> +                                                     size = <0xa000>;
>>> +                                                     filename = "bl30.bin";
>>> +                                             };
>>> +                                             bl301 {
>>> +                                                     type = "blob-ext";
>>> +                                                     size = <0x3400>;
>>> +                                                     filename = "bl301.bin";
>>> +                                             };
>>> +                                     };
>>> +                             };
>>> +                     };
>>> +
>>> +                     /* sign the bl31 binary */
>>> +                     bl31 {
>>> +                             type = "aml-encrypt";
>>> +                             aml-algo = "g12a";
>>> +                             aml-op = "bl3sig";
>>> +                             aml-input = "bl31.img";
>>> +                             aml-level = "v3";
>>> +                             aml-type = "bl31";
>>> +                     };
>>> +
>>> +                     /* sign the bl33 binary (which is U-Boot) */
>>> +                     bl33 {
>>> +                             type = "aml-encrypt";
>>> +                             aml-algo = "g12a";
>>> +                             aml-op = "bl3sig";
>>> +                             aml-compress = "lz4";
>>> +                             aml-level = "v3";
>>> +                             aml-type = "bl33";
>>> +
>>> +                             aml-input {
>>> +                                     type = "u-boot";
>>> +                             };
>>> +                     };
>>> +
>>> +                     /* add the various DDR blobs */
>>> +                     aml-ddrfw {
>>> +                             missing-msg = "aml-ddrfw";
>>> +                             type = "blob-ext-list";
>>> +                             filenames = "ddr4_1d.fw", "ddr4_2d.fw",
>>> +                                     "ddr3_1d.fw", "piei.fw",
>>> +                                     "lpddr4_1d.fw", "lpddr4_2d.fw",
>>> +                                     "diag_lpddr4.fw", "aml_ddr.fw",
>>> +                                     "lpddr3_1d.fw";
>>> +                     };
>>> +             };
>>> +
>>> +             fdtmap {
>>> +             };
>>> +     };
>>> +};
>>> +
>>>  &ethmac {
>>>       snps,reset-gpio = <&gpio GPIOZ_15 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>;
>>>       snps,reset-delays-us = <0 10000 1000000>;
>>> diff --git a/arch/arm/mach-meson/Kconfig b/arch/arm/mach-meson/Kconfig
>>> index 6cba2c40dda..bcb87ea243c 100644
>>> --- a/arch/arm/mach-meson/Kconfig
>>> +++ b/arch/arm/mach-meson/Kconfig
>>> @@ -48,6 +48,7 @@ config MESON_AXG
>>>  config MESON_G12A
>>>       bool "G12A"
>>>       select MESON64_COMMON
>>> +     select BINMAN
>>>       help
>>>         Select this if your SoC is an S905X/D2
>>>
>>> diff --git a/doc/board/amlogic/odroid-c4.rst b/doc/board/amlogic/odroid-c4.rst
>>> index f66d60a54d1..5eae1e66e3a 100644
>>> --- a/doc/board/amlogic/odroid-c4.rst
>>> +++ b/doc/board/amlogic/odroid-c4.rst
>>> @@ -22,17 +22,8 @@ applies for HC4.
>>>
>>>  Schematics are available on the manufacturer website.
>>>
>>> -U-Boot compilation
>>> -------------------
>>> -
>>> -.. code-block:: bash
>>> -
>>> -    $ export CROSS_COMPILE=aarch64-none-elf-
>>> -    $ make odroid-c4_defconfig
>>> -    $ make
>>> -
> 
> [..]
> 
> Regards,
> Simon
> 


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 5/7] binman: Support lists of external blobs
  2021-11-24  4:09 [PATCH 0/7] meson: Demonstration of using binman to produce the image Simon Glass
                   ` (7 preceding siblings ...)
  2021-12-05 19:46 ` [PATCH 6/7] binman: Rename _ReadSubnodes() to ReadEntries() Simon Glass
@ 2021-12-05 19:46 ` Simon Glass
  2021-12-05 19:46 ` [PATCH 4/7] dtoc: Add support for reading string-list properties Simon Glass
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Simon Glass @ 2021-12-05 19:46 UTC (permalink / raw)
  To: Simon Glass; +Cc: U-Boot Mailing List

Sometimes it is useful to have a list of related external blobs in a
single entry. An example is the DDR binaries used by meson. There are
9 files in total. Add support for this, so we don't have to have a
separate entry for each.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 scripts/pylint.base                           |  1 +
 tools/binman/entries.rst                      | 14 +++++
 tools/binman/etype/blob.py                    | 16 ++++-
 tools/binman/etype/blob_ext_list.py           | 58 +++++++++++++++++++
 tools/binman/ftest.py                         | 20 +++++++
 tools/binman/test/215_blob_ext_list.dts       | 14 +++++
 .../binman/test/216_blob_ext_list_missing.dts | 14 +++++
 7 files changed, 134 insertions(+), 3 deletions(-)
 create mode 100644 tools/binman/etype/blob_ext_list.py
 create mode 100644 tools/binman/test/215_blob_ext_list.dts
 create mode 100644 tools/binman/test/216_blob_ext_list_missing.dts

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 6/7] binman: Rename _ReadSubnodes() to ReadEntries()
  2021-11-24  4:09 [PATCH 0/7] meson: Demonstration of using binman to produce the image Simon Glass
                   ` (6 preceding siblings ...)
  2021-11-24  4:09 ` [PATCH 7/7] RFC: Move Odroid-C2 to use binman to produce the image Simon Glass
@ 2021-12-05 19:46 ` Simon Glass
  2021-12-05 19:46 ` [PATCH 5/7] binman: Support lists of external blobs Simon Glass
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Simon Glass @ 2021-12-05 19:46 UTC (permalink / raw)
  To: Simon Glass; +Cc: U-Boot Mailing List

This method name is more commonly used for this function. Use it
consistently.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/binman/etype/fit.py        | 4 ++--
 tools/binman/etype/intel_ifwi.py | 4 ++--
 tools/binman/etype/mkimage.py    | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/7] dtoc: Add support for reading string-list properties
  2021-11-24  4:09 [PATCH 0/7] meson: Demonstration of using binman to produce the image Simon Glass
                   ` (8 preceding siblings ...)
  2021-12-05 19:46 ` [PATCH 5/7] binman: Support lists of external blobs Simon Glass
@ 2021-12-05 19:46 ` Simon Glass
  2021-12-05 19:46 ` [PATCH 3/7] binman: Allow extracting a file in an alternative format Simon Glass
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Simon Glass @ 2021-12-05 19:46 UTC (permalink / raw)
  To: Simon Glass; +Cc: Walter Lozano, U-Boot Mailing List

Add a function to read a list of strings from the devicetree.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/dtoc/fdt_util.py | 21 +++++++++++++++++++++
 tools/dtoc/test_fdt.py |  9 +++++++++
 2 files changed, 30 insertions(+)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/7] binman: Allow extracting a file in an alternative format
  2021-11-24  4:09 [PATCH 0/7] meson: Demonstration of using binman to produce the image Simon Glass
                   ` (9 preceding siblings ...)
  2021-12-05 19:46 ` [PATCH 4/7] dtoc: Add support for reading string-list properties Simon Glass
@ 2021-12-05 19:46 ` Simon Glass
  2021-12-05 19:46 ` [PATCH 2/7] binman: Allow listing an image created by a newer version Simon Glass
  2021-12-05 19:46 ` [PATCH 1/7] binman: Allow providing tools and blob directories Simon Glass
  12 siblings, 0 replies; 17+ messages in thread
From: Simon Glass @ 2021-12-05 19:46 UTC (permalink / raw)
  To: Simon Glass; +Cc: U-Boot Mailing List

In some cases entries encapsulate other data and it is useful to access
the data within. An example is the fdtmap which consists of a 16-byte
header, followed by a devicetree.

Provide an option to specify an alternative format when extracting files.
In the case of fdtmap, this is 'fdt', which produces an FDT file which can
be viewed with fdtdump.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/binman/binman.rst                     | 29 ++++++++++++++++
 tools/binman/cmdline.py                     |  2 ++
 tools/binman/control.py                     | 28 +++++++++++++---
 tools/binman/entries.rst                    | 11 +++++-
 tools/binman/entry.py                       | 37 +++++++++++++++++----
 tools/binman/etype/atf_fip.py               | 16 ++++++++-
 tools/binman/etype/cbfs.py                  |  8 ++---
 tools/binman/etype/fdtmap.py                | 12 +++++++
 tools/binman/etype/section.py               | 23 ++++++++++---
 tools/binman/ftest.py                       | 34 +++++++++++++++++++
 tools/binman/image.py                       |  2 +-
 tools/binman/test/213_fdtmap_alt_format.dts | 15 +++++++++
 tools/binman/test/214_no_alt_format.dts     | 13 ++++++++
 13 files changed, 208 insertions(+), 22 deletions(-)
 create mode 100644 tools/binman/test/213_fdtmap_alt_format.dts
 create mode 100644 tools/binman/test/214_no_alt_format.dts

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/7] binman: Allow providing tools and blob directories
  2021-11-24  4:09 [PATCH 0/7] meson: Demonstration of using binman to produce the image Simon Glass
                   ` (11 preceding siblings ...)
  2021-12-05 19:46 ` [PATCH 2/7] binman: Allow listing an image created by a newer version Simon Glass
@ 2021-12-05 19:46 ` Simon Glass
  12 siblings, 0 replies; 17+ messages in thread
From: Simon Glass @ 2021-12-05 19:46 UTC (permalink / raw)
  To: Simon Glass; +Cc: Marek Behún, Pali Rohár, U-Boot Mailing List

At present it is necessary to symlink files containing external blobs into
the U-Boot tree in order for binman to find them. This is not very
convenient.

Add two new environment/Makefile variables to help with this. Add
documentation as well, fixing a related nit.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 Makefile                |  2 ++
 tools/binman/binman.rst | 31 ++++++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/7] binman: Allow listing an image created by a newer version
  2021-11-24  4:09 [PATCH 0/7] meson: Demonstration of using binman to produce the image Simon Glass
                   ` (10 preceding siblings ...)
  2021-12-05 19:46 ` [PATCH 3/7] binman: Allow extracting a file in an alternative format Simon Glass
@ 2021-12-05 19:46 ` Simon Glass
  2021-12-05 19:46 ` [PATCH 1/7] binman: Allow providing tools and blob directories Simon Glass
  12 siblings, 0 replies; 17+ messages in thread
From: Simon Glass @ 2021-12-05 19:46 UTC (permalink / raw)
  To: Simon Glass; +Cc: U-Boot Mailing List

If an older version of binman is used to list images created by a newer
one, it is possible that it will contain entry types that are not
supported. At present this produces an error.

Adjust binman to use a plain 'blob' entry type to cope with this, so the
image can at least be listed.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/binman/binman.rst       |  5 +++
 tools/binman/entry.py         | 65 +++++++++++++++++++++++++++--------
 tools/binman/entry_test.py    |  9 +++++
 tools/binman/etype/section.py |  3 +-
 tools/binman/image.py         | 10 ++++--
 5 files changed, 74 insertions(+), 18 deletions(-)

Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2021-12-05 19:48 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-24  4:09 [PATCH 0/7] meson: Demonstration of using binman to produce the image Simon Glass
2021-11-24  4:09 ` [PATCH 1/7] binman: Allow providing tools and blob directories Simon Glass
2021-11-24  4:09 ` [PATCH 2/7] binman: Allow listing an image created by a newer version Simon Glass
2021-11-24  4:09 ` [PATCH 3/7] binman: Allow extracting a file in an alternative format Simon Glass
2021-11-24  4:09 ` [PATCH 4/7] dtoc: Add support for reading string-list properties Simon Glass
2021-11-24  4:09 ` [PATCH 5/7] binman: Support lists of external blobs Simon Glass
2021-11-24  4:09 ` [PATCH 6/7] binman: Rename _ReadSubnodes() to ReadEntries() Simon Glass
2021-11-24  4:09 ` [PATCH 7/7] RFC: Move Odroid-C2 to use binman to produce the image Simon Glass
2021-11-24 14:26   ` Neil Armstrong
2021-11-25  0:12     ` Simon Glass
2021-11-25  8:31       ` Neil Armstrong
2021-12-05 19:46 ` [PATCH 6/7] binman: Rename _ReadSubnodes() to ReadEntries() Simon Glass
2021-12-05 19:46 ` [PATCH 5/7] binman: Support lists of external blobs Simon Glass
2021-12-05 19:46 ` [PATCH 4/7] dtoc: Add support for reading string-list properties Simon Glass
2021-12-05 19:46 ` [PATCH 3/7] binman: Allow extracting a file in an alternative format Simon Glass
2021-12-05 19:46 ` [PATCH 2/7] binman: Allow listing an image created by a newer version Simon Glass
2021-12-05 19:46 ` [PATCH 1/7] binman: Allow providing tools and blob directories Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.