All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH v3 10/12] binman: Allow selecting default FIT configuration
Date: Tue,  1 Sep 2020 05:14:03 -0600	[thread overview]
Message-ID: <20200901051400.v3.10.Ie75709c8b68c270e911bba4dbd521706c966087f@changeid> (raw)
In-Reply-To: <20200901111405.358391-1-sjg@chromium.org>

Add a new entry argument to the fit entry which allows selection of the
default configuration to use. This is the 'default' property in the
'configurations' node.

Update the Makefile to pass in the value of DEVICE_TREE or
CONFIG_DEFAULT_DEVICE_TREE to provide this information.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Michal Simek <michal.simek@xilinx.com>
---

Changes in v3:
- Rebase on top of earlier binman series

Changes in v2:
- Add new patch to allow selecting default FIT configuration

 Makefile                                      |  2 +
 tools/binman/README.entries                   |  4 ++
 tools/binman/etype/fit.py                     | 22 ++++++++++
 tools/binman/ftest.py                         | 41 +++++++++++++++++--
 .../test/{170_fit_fdt.dts => 172_fit_fdt.dts} |  2 +-
 5 files changed, 67 insertions(+), 4 deletions(-)
 rename tools/binman/test/{170_fit_fdt.dts => 172_fit_fdt.dts} (95%)

diff --git a/Makefile b/Makefile
index 65024c74089..fcc559ce7fa 100644
--- a/Makefile
+++ b/Makefile
@@ -1321,6 +1321,7 @@ u-boot.ldr:	u-boot
 # binman
 # ---------------------------------------------------------------------------
 # Use 'make BINMAN_DEBUG=1' to enable debugging
+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) \
                 --toolpath $(objtree)/tools \
@@ -1329,6 +1330,7 @@ cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \
 		-I . -I $(srctree) -I $(srctree)/board/$(BOARDDIR) \
 		-I arch/$(ARCH)/dts -a of-list=$(CONFIG_OF_LIST) \
 		-a atf-bl31-path=${BL31} \
+		-a default-dt=$(default_dt) \
 		$(BINMAN_$(@F))
 
 OBJCOPYFLAGS_u-boot.ldr.hex := -I binary -O ihex
diff --git a/tools/binman/README.entries b/tools/binman/README.entries
index d2628dffd5d..c1d436563e8 100644
--- a/tools/binman/README.entries
+++ b/tools/binman/README.entries
@@ -402,6 +402,10 @@ Available substitutions for '@' nodes are:
 Note that if no devicetree files are provided (with '-a of-list' as above)
 then no nodes will be generated.
 
+The 'default' property, if present, will be automatically set to the name
+if of configuration whose devicetree matches the 'default-dt' entry
+argument, e.g. with '-a default-dt=sun50i-a64-pine64-lts'.
+
 
 Properties (in the 'fit' node itself):
     fit,external-offset: Indicates that the contents of the FIT are external
diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
index c291eb26bad..bf73bfb9a56 100644
--- a/tools/binman/etype/fit.py
+++ b/tools/binman/etype/fit.py
@@ -90,6 +90,10 @@ class Entry_fit(Entry):
     Note that if no devicetree files are provided (with '-a of-list' as above)
     then no nodes will be generated.
 
+    The 'default' property, if present, will be automatically set to the name
+    if of configuration whose devicetree matches the 'default-dt' entry
+    argument, e.g. with '-a default-dt=sun50i-a64-pine64-lts'.
+
 
     Properties (in the 'fit' node itself):
         fit,external-offset: Indicates that the contents of the FIT are external
@@ -121,6 +125,8 @@ class Entry_fit(Entry):
                 [EntryArg(self._fit_list_prop.value, str)])
             if fdts is not None:
                 self._fdts = fdts.split()
+        self._fit_default_dt = self.GetEntryArgsOrProps([EntryArg('default-dt',
+                                                                  str)])[0]
 
     def ReadNode(self):
         self._ReadSubnodes()
@@ -142,6 +148,22 @@ class Entry_fit(Entry):
             """
             for pname, prop in node.props.items():
                 if not pname.startswith('fit,'):
+                    if pname == 'default':
+                        val = prop.value
+                        # Handle the 'default' property
+                        if val.startswith('@'):
+                            if not self._fdts:
+                                continue
+                            if not self._fit_default_dt:
+                                self.Raise("Generated 'default' node requires default-dt entry argument")
+                            if self._fit_default_dt not in self._fdts:
+                                self.Raise("default-dt entry argument '%s' not found in fdt list: %s" %
+                                           (self._fit_default_dt,
+                                            ', '.join(self._fdts)))
+                            seq = self._fdts.index(self._fit_default_dt)
+                            val = val[1:].replace('DEFAULT-SEQ', str(seq + 1))
+                            fsw.property_string(pname, val)
+                            continue
                     fsw.property(pname, prop.bytes)
 
             rel_path = node.path[len(base_node.path):]
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 78d0e9c2b93..a269a7497cb 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -3602,7 +3602,7 @@ class TestFunctional(unittest.TestCase):
             """
             cnode = dtb.GetNode('/configurations')
             self.assertIn('default', cnode.props)
-            self.assertEqual('config-1', cnode.props['default'].value)
+            self.assertEqual('config-2', cnode.props['default'].value)
 
             name = 'config-%d' % seq
             fnode = dtb.GetNode('/configurations/%s' % name)
@@ -3615,9 +3615,10 @@ class TestFunctional(unittest.TestCase):
 
         entry_args = {
             'of-list': 'test-fdt1 test-fdt2',
+            'default-dt': 'test-fdt2',
         }
         data = self._DoReadFileDtb(
-            '170_fit_fdt.dts',
+            '172_fit_fdt.dts',
             entry_args=entry_args,
             extra_indirs=[os.path.join(self._indir, TEST_FDT_SUBDIR)])[0]
         self.assertEqual(U_BOOT_NODTB_DATA, data[-len(U_BOOT_NODTB_DATA):])
@@ -3639,7 +3640,7 @@ class TestFunctional(unittest.TestCase):
     def testFitFdtMissingList(self):
         """Test handling of a missing 'of-list' entry arg"""
         with self.assertRaises(ValueError) as e:
-            self._DoReadFile('170_fit_fdt.dts')
+            self._DoReadFile('172_fit_fdt.dts')
         self.assertIn("Generator node requires 'of-list' entry argument",
                       str(e.exception))
 
@@ -3657,5 +3658,39 @@ class TestFunctional(unittest.TestCase):
         self.assertIn("Generator node requires 'fit,fdt-list' property",
                       str(e.exception))
 
+    def testFitFdtEmptyList(self):
+        """Test handling of an empty 'of-list' entry arg"""
+        entry_args = {
+            'of-list': '',
+        }
+        data = self._DoReadFileDtb('172_fit_fdt.dts', entry_args=entry_args)[0]
+
+    def testFitFdtMissing(self):
+        """Test handling of a missing 'default-dt' entry arg"""
+        entry_args = {
+            'of-list': 'test-fdt1 test-fdt2',
+        }
+        with self.assertRaises(ValueError) as e:
+            self._DoReadFileDtb(
+                '172_fit_fdt.dts',
+                entry_args=entry_args,
+                extra_indirs=[os.path.join(self._indir, TEST_FDT_SUBDIR)])[0]
+        self.assertIn("Generated 'default' node requires default-dt entry argument",
+                      str(e.exception))
+
+    def testFitFdtNotInList(self):
+        """Test handling of a default-dt that is not in the of-list"""
+        entry_args = {
+            'of-list': 'test-fdt1 test-fdt2',
+            'default-dt': 'test-fdt3',
+        }
+        with self.assertRaises(ValueError) as e:
+            self._DoReadFileDtb(
+                '172_fit_fdt.dts',
+                entry_args=entry_args,
+                extra_indirs=[os.path.join(self._indir, TEST_FDT_SUBDIR)])[0]
+        self.assertIn("default-dt entry argument 'test-fdt3' not found in fdt list: test-fdt1, test-fdt2",
+                      str(e.exception))
+
 if __name__ == "__main__":
     unittest.main()
diff --git a/tools/binman/test/170_fit_fdt.dts b/tools/binman/test/172_fit_fdt.dts
similarity index 95%
rename from tools/binman/test/170_fit_fdt.dts
rename to tools/binman/test/172_fit_fdt.dts
index 89142e91017..99d710c57e9 100644
--- a/tools/binman/test/170_fit_fdt.dts
+++ b/tools/binman/test/172_fit_fdt.dts
@@ -40,7 +40,7 @@
 			};
 
 			configurations {
-				default = "config-1";
+				default = "@config-DEFAULT-SEQ";
 				@config-SEQ {
 					description = "conf-NAME.dtb";
 					firmware = "uboot";
-- 
2.28.0.402.g5ffc5be6b7-goog

  parent reply	other threads:[~2020-09-01 11:14 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-01 11:13 [PATCH v3 00/12] binman: Add support for generating more complex FITs Simon Glass
2020-09-01 11:13 ` [PATCH v3 01/12] binman: Allow entry args to be required Simon Glass
2020-09-01 11:13 ` [PATCH v3 02/12] binman: Fix up a few missing comments Simon Glass
2020-09-01 11:13 ` [PATCH v3 03/12] libfdt: Detected out-of-space with fdt_finish() Simon Glass
2020-09-01 11:13 ` [PATCH v3 04/12] binman: Move 'external' support into base class Simon Glass
2020-09-01 11:13 ` [PATCH v3 05/12] binman: Add support for ATF BL31 Simon Glass
2020-09-05 22:57   ` Samuel Holland
2020-09-06  0:17     ` Simon Glass
2020-09-01 11:13 ` [PATCH v3 06/12] binman: Support generating FITs with multiple dtbs Simon Glass
2020-09-05 22:41   ` Samuel Holland
2020-09-05 23:19     ` Samuel Holland
2020-09-06  0:17       ` Simon Glass
2020-09-06  0:18     ` Simon Glass
2020-09-01 11:14 ` [PATCH v3 07/12] Makefile: Support missing external blobs always Simon Glass
2020-09-01 11:14 ` [PATCH v3 08/12] sunxi: Convert 64-bit boards to use binman Simon Glass
2020-09-05 23:10   ` Samuel Holland
2020-09-05 23:42     ` Samuel Holland
2020-09-06  0:17       ` Simon Glass
2020-09-06  0:18     ` Simon Glass
2020-09-06  1:49       ` Samuel Holland
2020-09-06  2:22         ` Simon Glass
2020-09-07 13:01       ` Michal Simek
2020-09-07 13:57         ` Simon Glass
2020-09-01 11:14 ` [PATCH v3 09/12] sunxi: Drop the FIT-generator script Simon Glass
2020-09-01 11:14 ` Simon Glass [this message]
2020-09-01 11:14 ` [PATCH v3 11/12] binman: Support help messages for missing blobs Simon Glass
2020-09-01 11:14 ` [PATCH v3 12/12] binman: sunxi: Add help message for missing sunxi ATF BL31 Simon Glass
2020-09-02 10:26 ` [PATCH v3 00/12] binman: Add support for generating more complex FITs Michal Simek
2020-09-02 17:07   ` Simon Glass
2020-09-03 13:31     ` Michal Simek
2020-09-05 21:10 ` [PATCH v3 07/12] Makefile: Support missing external blobs always Simon Glass
2020-09-05 21:10 ` [PATCH v3 06/12] binman: Support generating FITs with multiple dtbs Simon Glass
2020-09-05 21:10 ` [PATCH v3 05/12] binman: Add support for ATF BL31 Simon Glass
2020-09-05 21:10 ` [PATCH v3 04/12] binman: Move 'external' support into base class Simon Glass
2020-09-05 21:10 ` [PATCH v3 03/12] libfdt: Detected out-of-space with fdt_finish() Simon Glass
2020-09-05 21:10 ` [PATCH v3 02/12] binman: Fix up a few missing comments Simon Glass
2020-09-05 21:10 ` [PATCH v3 01/12] binman: Allow entry args to be required Simon Glass
2020-09-07  6:31   ` Michal Simek
2020-09-07 13:57     ` 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=20200901051400.v3.10.Ie75709c8b68c270e911bba4dbd521706c966087f@changeid \
    --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.