summaryrefslogtreecommitdiff
path: root/tools/binman/etype/blob.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2016-11-26 03:15:52 (GMT)
committerSimon Glass <sjg@chromium.org>2016-12-19 19:09:55 (GMT)
commit4f44304b0bd881f79252c7b7d2fb796e31ca3b0a (patch)
tree50c4140da8f12dd9a145707b3b186d8a39a471e8 /tools/binman/etype/blob.py
parentbf7fd50b3ba56b53dc13a681d19c845be903c3e0 (diff)
downloadu-boot-4f44304b0bd881f79252c7b7d2fb796e31ca3b0a.tar.xz
binman: Add basic entry types for U-Boot
Add entries to support some standard U-Boot binaries, such as u-boot.bin, u-boot.dtb, etc. Also add some tests for these. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'tools/binman/etype/blob.py')
-rw-r--r--tools/binman/etype/blob.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py
new file mode 100644
index 0000000..def2164
--- /dev/null
+++ b/tools/binman/etype/blob.py
@@ -0,0 +1,37 @@
+# Copyright (c) 2016 Google, Inc
+# Written by Simon Glass <sjg@chromium.org>
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Entry-type module for blobs, which are binary objects read from files
+#
+
+from entry import Entry
+import fdt_util
+import tools
+
+class Entry_blob(Entry):
+ def __init__(self, image, etype, node):
+ Entry.__init__(self, image, etype, node)
+ self._filename = fdt_util.GetString(self._node, "filename", self.etype)
+
+ def ObtainContents(self):
+ self._filename = self.GetDefaultFilename()
+ self._pathname = tools.GetInputFilename(self._filename)
+ self.ReadContents()
+ return True
+
+ def ReadContents(self):
+ with open(self._pathname) as fd:
+ # We assume the data is small enough to fit into memory. If this
+ # is used for large filesystem image that might not be true.
+ # In that case, Image.BuildImage() could be adjusted to use a
+ # 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.
+ self.data = fd.read()
+ self.contents_size = len(self.data)
+ return True
+
+ def GetDefaultFilename(self):
+ return self._filename