All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH v2 10/21] binman: Plumb expanded entries through fully
Date: Mon, 15 Mar 2021 20:26:15 +1300	[thread overview]
Message-ID: <20210315072627.2101110-11-sjg@chromium.org> (raw)
In-Reply-To: <20210315072627.2101110-1-sjg@chromium.org>

Add support for this feature in the control, image and section modules, so
that expanded entries will be selected by default. So far there are no
expanded entry types, so this is a nop.

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

(no changes since v1)

 tools/binman/control.py       | 24 ++++++++++++++++++------
 tools/binman/etype/section.py |  3 ++-
 tools/binman/image.py         | 17 ++++++++++++++++-
 3 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/tools/binman/control.py b/tools/binman/control.py
index 9c0cafeafc4..9709aa9a2b2 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -28,7 +28,7 @@ images = OrderedDict()
 #    value: Text for the help
 missing_blob_help = {}
 
-def _ReadImageDesc(binman_node):
+def _ReadImageDesc(binman_node, use_expanded):
     """Read the image descriptions from the /binman node
 
     This normally produces a single Image object called 'image'. But if
@@ -36,15 +36,17 @@ def _ReadImageDesc(binman_node):
 
     Args:
         binman_node: Node object of the /binman node
+        use_expanded: True if the FDT will be updated with the entry information
     Returns:
         OrderedDict of Image objects, each of which describes an image
     """
     images = OrderedDict()
     if 'multiple-images' in binman_node.props:
         for node in binman_node.subnodes:
-            images[node.name] = Image(node.name, node)
+            images[node.name] = Image(node.name, node,
+                                      use_expanded=use_expanded)
     else:
-        images['image'] = Image('image', binman_node)
+        images['image'] = Image('image', binman_node, use_expanded=use_expanded)
     return images
 
 def _FindBinmanNode(dtb):
@@ -399,7 +401,7 @@ def ReplaceEntries(image_fname, input_fname, indir, entry_paths,
     return image
 
 
-def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt):
+def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded):
     """Prepare the images to be processed and select the device tree
 
     This function:
@@ -413,6 +415,9 @@ def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt):
         dtb_fname: Filename of the device tree file to use (.dts or .dtb)
         selected_images: List of images to output, or None for all
         update_fdt: True to update the FDT wth entry offsets, etc.
+        use_expanded: True to use expanded versions of entries, if available.
+            So if 'u-boot' is called for, we use 'u-boot-expanded' instead. This
+            is needed if update_fdt is True (although tests may disable it)
 
     Returns:
         OrderedDict of images:
@@ -438,7 +443,7 @@ def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt):
         raise ValueError("Device tree '%s' does not have a 'binman' "
                             "node" % dtb_fname)
 
-    images = _ReadImageDesc(node)
+    images = _ReadImageDesc(node, use_expanded)
 
     if select_images:
         skip = []
@@ -611,6 +616,13 @@ def Binman(args):
         elf.debug = args.debug
         cbfs_util.VERBOSE = args.verbosity > 2
         state.use_fake_dtb = args.fake_dtb
+
+        # Normally we replace the 'u-boot' etype with 'u-boot-expanded', etc.
+        # When running tests this can be disabled using this flag. When not
+        # updating the FDT in image, it is not needed by binman, but we use it
+        # for consistency, so that the images look the same to U-Boot at
+        # runtime.
+        use_expanded = not args.no_expanded
         try:
             tools.SetInputDirs(args.indir)
             tools.PrepareOutputDir(args.outdir, args.preserve)
@@ -618,7 +630,7 @@ def Binman(args):
             state.SetEntryArgs(args.entry_arg)
 
             images = PrepareImagesAndDtbs(dtb_fname, args.image,
-                                          args.update_fdt)
+                                          args.update_fdt, use_expanded)
             missing = False
             for image in images.values():
                 missing |= ProcessImage(image, args.update_fdt, args.map,
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 2103919b0c3..2f862bddf0f 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -84,7 +84,8 @@ class Entry_section(Entry):
         for node in self._node.subnodes:
             if node.name.startswith('hash') or node.name.startswith('signature'):
                 continue
-            entry = Entry.Create(self, node)
+            entry = Entry.Create(self, node,
+                                 expanded=self.GetImage().use_expanded)
             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 e9494352413..10778f47fe9 100644
--- a/tools/binman/image.py
+++ b/tools/binman/image.py
@@ -47,9 +47,23 @@ class Image(section.Entry_section):
             exception). This should be used if the Image is being loaded from
             a file rather than generated. In that case we obviously don't need
             the entry arguments since the contents already exists.
+        use_expanded: True if we are updating the FDT wth entry offsets, etc.
+            and should use the expanded versions of the U-Boot entries.
+            Any entry type that includes a devicetree must put it in a
+            separate entry so that it will be updated. For example. 'u-boot'
+            normally just picks up 'u-boot.bin' which includes the
+            devicetree, but this is not updateable, since it comes into
+            binman as one piece and binman doesn't know that it is actually
+            an executable followed by a devicetree. Of course it could be
+            taught this, but then when reading an image (e.g. 'binman ls')
+            it may need to be able to split the devicetree out of the image
+            in order to determine the location of things. Instead we choose
+            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.
     """
     def __init__(self, name, node, copy_to_orig=True, test=False,
-                 ignore_missing=False):
+                 ignore_missing=False, use_expanded=False):
         super().__init__(None, 'section', node, test=test)
         self.copy_to_orig = copy_to_orig
         self.name = 'main-section'
@@ -59,6 +73,7 @@ class Image(section.Entry_section):
         self.fdtmap_data = None
         self.allow_repack = False
         self._ignore_missing = ignore_missing
+        self.use_expanded = use_expanded
         if not test:
             self.ReadNode()
 
-- 
2.31.0.rc2.261.g7f71774620-goog

  parent reply	other threads:[~2021-03-15  7:26 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15  7:26 [PATCH v2 00/21] binman: Support devicetree update in all entries Simon Glass
2021-03-15  7:26 ` [PATCH v2 01/21] binman: Allow extracting to current directory Simon Glass
2021-03-15  7:26 ` [PATCH v2 02/21] binman: Document ExpandEntries() in the base class Simon Glass
2021-03-15  7:26 ` [PATCH v2 03/21] binman: Update entry help for files-align Simon Glass
2021-03-15  7:26 ` [PATCH v2 04/21] binman: Tidy up underscores in entry documentation Simon Glass
2021-03-15  7:26 ` [PATCH v2 05/21] binman: Correct the documentation for u-boot-spl-bss-pad Simon Glass
2021-03-15  7:26 ` [PATCH v2 06/21] binman: Add support for u-boot-tpl-nodtb Simon Glass
2021-03-15  7:26 ` [PATCH v2 07/21] binman: Add support for u-boot-tpl-bss-bad Simon Glass
2021-03-15  7:26 ` [PATCH v2 08/21] binman: Allow using an an 'expanded' entry type Simon Glass
2021-03-15  7:26 ` [PATCH v2 09/21] binman: Allow a way to select expanded entries Simon Glass
2021-03-15  7:26 ` Simon Glass [this message]
2021-03-15  7:26 ` [PATCH v2 11/21] binman: Automatically expand phase binaries into sections Simon Glass
2021-03-15  7:26 ` [PATCH v2 12/21] Makefile: Pass new entry args to binman Simon Glass
2021-03-15  7:26 ` [PATCH v2 13/21] x86: Make use of binman expanded entries Simon Glass
2021-03-15  7:26 ` [PATCH v2 14/21] x86: dts: Drop unused CONFIG_SPL Simon Glass
2021-03-15  7:26 ` [PATCH v2 15/21] doc: Move UEFI under develop/ Simon Glass
2021-03-17  7:46   ` Heinrich Schuchardt
2021-03-18  6:36     ` Simon Glass
2021-03-15  7:26 ` [PATCH v2 16/21] doc: Move driver model docs " Simon Glass
2021-03-15  7:26 ` [PATCH v2 17/21] binman: doc: Add documentation to htmldocs Simon Glass
2021-03-15  7:26 ` [PATCH v2 18/21] binman: Rearrange documentation into headings Simon Glass
2021-03-15  7:26 ` [PATCH v2 19/21] binman: Incorporate entry documentation Simon Glass
2021-03-15  7:26 ` [PATCH v2 20/21] binman: Drop repetitive heading for each entry Simon Glass
2021-03-15  7:26 ` [PATCH v2 21/21] binman: Update various pieces of the documentation Simon Glass
2021-03-17  1:29 ` Simon Glass
2021-03-17  1:29 ` [PATCH v2 20/21] binman: Drop repetitive heading for each entry Simon Glass
2021-03-17  1:29 ` [PATCH v2 19/21] binman: Incorporate entry documentation Simon Glass
2021-03-17  1:29 ` [PATCH v2 18/21] binman: Rearrange documentation into headings Simon Glass
2021-03-17  1:29 ` [PATCH v2 17/21] binman: doc: Add documentation to htmldocs Simon Glass
2021-03-17  1:29 ` [PATCH v2 16/21] doc: Move driver model docs under develop/ Simon Glass
2021-03-17  1:29 ` [PATCH v2 15/21] doc: Move UEFI " Simon Glass
2021-03-17  1:29 ` [PATCH v2 14/21] x86: dts: Drop unused CONFIG_SPL Simon Glass
2021-03-17  1:29 ` [PATCH v2 13/21] x86: Make use of binman expanded entries Simon Glass
2021-03-17  1:29 ` [PATCH v2 12/21] Makefile: Pass new entry args to binman Simon Glass
2021-03-17  1:29 ` [PATCH v2 11/21] binman: Automatically expand phase binaries into sections Simon Glass
2021-03-17  1:29 ` [PATCH v2 10/21] binman: Plumb expanded entries through fully Simon Glass
2021-03-17  1:29 ` [PATCH v2 09/21] binman: Allow a way to select expanded entries Simon Glass
2021-03-17  1:29 ` [PATCH v2 08/21] binman: Allow using an an 'expanded' entry type Simon Glass
2021-03-17  1:30 ` [PATCH v2 07/21] binman: Add support for u-boot-tpl-bss-bad Simon Glass
2021-03-17  1:30 ` [PATCH v2 06/21] binman: Add support for u-boot-tpl-nodtb Simon Glass
2021-03-17  1:30 ` [PATCH v2 05/21] binman: Correct the documentation for u-boot-spl-bss-pad Simon Glass
2021-03-17  1:30 ` [PATCH v2 04/21] binman: Tidy up underscores in entry documentation Simon Glass
2021-03-17  1:30 ` [PATCH v2 03/21] binman: Update entry help for files-align Simon Glass
2021-03-17  1:30 ` [PATCH v2 02/21] binman: Document ExpandEntries() in the base class Simon Glass
2021-03-17  1:30 ` [PATCH v2 01/21] binman: Allow extracting to current directory Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210315072627.2101110-11-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.