[PATCH v2 12/49] binman: Add an etype for external binary blobs

Simon Glass sjg at chromium.org
Sun Jun 14 04:56:51 CEST 2020


It is useful to be able to distinguish between ordinary blobs such as
u-boot.bin and external blobs that cannot be build by the U-Boot build
system. If the external blobs are not available for some reason, then we
know that a value image cannot be built.

Introduce a new 'blob-ext' entry type for that.

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

(no changes since v1)

 tools/binman/README.entries                | 10 +++++++
 tools/binman/etype/blob_ext.py             | 31 ++++++++++++++++++++++
 tools/binman/ftest.py                      | 12 +++++++++
 tools/binman/test/157_blob_ext.dts         | 14 ++++++++++
 tools/binman/test/158_blob_ext_missing.dts | 16 +++++++++++
 5 files changed, 83 insertions(+)
 create mode 100644 tools/binman/etype/blob_ext.py
 create mode 100644 tools/binman/test/157_blob_ext.dts
 create mode 100644 tools/binman/test/158_blob_ext_missing.dts

diff --git a/tools/binman/README.entries b/tools/binman/README.entries
index d5b4b3af2b..ec0d47f8e3 100644
--- a/tools/binman/README.entries
+++ b/tools/binman/README.entries
@@ -42,6 +42,16 @@ obtained from the list of available device-tree files, managed by the
 
 
 
+Entry: blob-ext: Entry containing an externally built binary blob
+-----------------------------------------------------------------
+
+Note: This should not be used by itself. It is normally used as a parent
+class by other entry types.
+
+See 'blob' for Properties / Entry arguments.
+
+
+
 Entry: blob-named-by-arg: A blob entry which gets its filename property from its subclass
 -----------------------------------------------------------------------------------------
 
diff --git a/tools/binman/etype/blob_ext.py b/tools/binman/etype/blob_ext.py
new file mode 100644
index 0000000000..cc8d91bb59
--- /dev/null
+++ b/tools/binman/etype/blob_ext.py
@@ -0,0 +1,31 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2016 Google, Inc
+# Written by Simon Glass <sjg at chromium.org>
+#
+# Entry-type module for 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(Entry_blob):
+    """Entry containing an externally built binary blob
+
+    Note: This should not be used by itself. It is normally used as a parent
+    class by other entry types.
+
+    See 'blob' for Properties / Entry arguments.
+    """
+    def __init__(self, section, etype, node):
+        Entry_blob.__init__(self, section, etype, node)
+        self.external = True
+
+    def ObtainContents(self):
+        self._filename = self.GetDefaultFilename()
+        self._pathname = tools.GetInputFilename(self._filename)
+        self.ReadBlobContents()
+        return True
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 39e67b9042..f8d5191672 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -3364,6 +3364,18 @@ class TestFunctional(unittest.TestCase):
         # Just check that the data appears in the file somewhere
         self.assertIn(U_BOOT_SPL_DATA, data)
 
+    def testExtblob(self):
+        """Test an image with an external blob"""
+        data = self._DoReadFile('157_blob_ext.dts')
+        self.assertEqual(REFCODE_DATA, data)
+
+    def testExtblobMissing(self):
+        """Test an image with a missing external blob"""
+        with self.assertRaises(ValueError) as e:
+            self._DoReadFile('158_blob_ext_missing.dts')
+        self.assertIn("Filename 'missing-file' not found in input path",
+                      str(e.exception))
+
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/tools/binman/test/157_blob_ext.dts b/tools/binman/test/157_blob_ext.dts
new file mode 100644
index 0000000000..8afdd5339e
--- /dev/null
+++ b/tools/binman/test/157_blob_ext.dts
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		blob-ext {
+			filename = "refcode.bin";
+		};
+	};
+};
diff --git a/tools/binman/test/158_blob_ext_missing.dts b/tools/binman/test/158_blob_ext_missing.dts
new file mode 100644
index 0000000000..d315e5592e
--- /dev/null
+++ b/tools/binman/test/158_blob_ext_missing.dts
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		size = <0x80>;
+
+		blob-ext {
+			filename = "missing-file";
+		};
+	};
+};
-- 
2.27.0.290.gba653c62da-goog



More information about the U-Boot mailing list