[PATCH 14/20] binman: Allow entry types to override FDT contents

Simon Glass sjg at chromium.org
Sat Jul 20 12:49:44 CEST 2024


At present the contents of an FDT (for each phase) are fixed,
determined by the build and provided to Binman as input files.

Provide a means for entry types to provide their own FDT, so that it can
be processed, if needed.

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

 tools/binman/entry.py          | 12 ++++++++++++
 tools/binman/etype/blob_dtb.py |  4 ++--
 tools/binman/image.py          |  4 ++++
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 752c584c9a3..494b1b1278d 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -1386,3 +1386,15 @@ features to produce new behaviours.
 
     def UpdateSignatures(self, privatekey_fname, algo, input_fname):
         self.Raise('Updating signatures is not supported with this entry type')
+
+    def FdtContents(self, fdt_etype):
+        """Get the contents of an FDT for a particular phase
+
+        Args:
+            fdt_etype (str): Filename of the phase of the FDT to return, e.g.
+                'u-boot-tpl-dtb'
+
+        Returns:
+            bytes: Contents of requested FDT
+        """
+        return self.section.FdtContents(fdt_etype)
diff --git a/tools/binman/etype/blob_dtb.py b/tools/binman/etype/blob_dtb.py
index 1471ded2211..b234323d7cf 100644
--- a/tools/binman/etype/blob_dtb.py
+++ b/tools/binman/etype/blob_dtb.py
@@ -41,12 +41,12 @@ class Entry_blob_dtb(Entry_blob):
     def ObtainContents(self, fake_size=0):
         """Get the device-tree from the list held by the 'state' module"""
         self._filename = self.GetDefaultFilename()
-        self._pathname, _ = state.GetFdtContents(self.GetFdtEtype())
+        self._pathname, _ = self.FdtContents(self.GetFdtEtype())
         return super().ReadBlobContents()
 
     def ProcessContents(self):
         """Re-read the DTB contents so that we get any calculated properties"""
-        _, indata = state.GetFdtContents(self.GetFdtEtype())
+        _, indata = self.FdtContents(self.GetFdtEtype())
 
         if self.compress == 'zstd' and self.prepend != 'length':
             self.Raise('The zstd compression requires a length header')
diff --git a/tools/binman/image.py b/tools/binman/image.py
index 97443d3c0a7..c1be5cc23a2 100644
--- a/tools/binman/image.py
+++ b/tools/binman/image.py
@@ -425,3 +425,7 @@ class Image(section.Entry_section):
         super().AddBintools(bintools)
         self.bintools = bintools
         return bintools
+
+    def FdtContents(self, fdt_etype):
+        """This base-class implementation simply calls the state function"""
+        return state.GetFdtContents(fdt_etype)
-- 
2.34.1



More information about the U-Boot mailing list