summaryrefslogtreecommitdiff
path: root/tools/binman/etype
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-07-09 18:39:38 -0600
committerSimon Glass <sjg@chromium.org>2020-07-20 11:37:47 -0600
commit5f850fb9a62659edaa81167a4acc879c0ea104fc (patch)
tree0bb5362a5c9286d4eba4832c185ffb692f98105b /tools/binman/etype
parent894f63575574e153ac813b7a1d20bf5d251af2ac (diff)
binman: Allow external binaries to be missing
Sometimes it is useful to build an image even though external binaries are not present. This allows the build system to continue to function without these files, albeit not producing valid images. U-Boot does with with ATF (ARM Trusted Firmware) today. Add a new flag to binman to request this behaviour. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'tools/binman/etype')
-rw-r--r--tools/binman/etype/blob_ext.py13
-rw-r--r--tools/binman/etype/section.py24
2 files changed, 34 insertions, 3 deletions
diff --git a/tools/binman/etype/blob_ext.py b/tools/binman/etype/blob_ext.py
index cc8d91bb59..51779c88c9 100644
--- a/tools/binman/etype/blob_ext.py
+++ b/tools/binman/etype/blob_ext.py
@@ -18,6 +18,9 @@ class Entry_blob_ext(Entry_blob):
Note: This should not be used by itself. It is normally used as a parent
class by other entry types.
+ If the file providing this blob is missing, binman can optionally ignore it
+ and produce a broken image with a warning.
+
See 'blob' for Properties / Entry arguments.
"""
def __init__(self, section, etype, node):
@@ -26,6 +29,10 @@ class Entry_blob_ext(Entry_blob):
def ObtainContents(self):
self._filename = self.GetDefaultFilename()
- self._pathname = tools.GetInputFilename(self._filename)
- self.ReadBlobContents()
- return True
+ self._pathname = tools.GetInputFilename(self._filename,
+ self.section.GetAllowMissing())
+ # Allow the file to be missing
+ if not self._pathname:
+ self.SetContents(b'')
+ return True
+ return super().ObtainContents()
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index f108121c3a..9b718f1fa7 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -34,6 +34,11 @@ class Entry_section(Entry):
name-prefix: Adds a prefix to the name of every entry in the section
when writing out the map
+ Properties:
+ _allow_missing: True if this section permits external blobs to be
+ missing their contents. The second will produce an image but of
+ course it will not work.
+
Since a section is also an entry, it inherits all the properies of entries
too.
@@ -49,6 +54,7 @@ class Entry_section(Entry):
self._sort = False
self._skip_at_start = None
self._end_4gb = False
+ self._allow_missing = False
def ReadNode(self):
"""Read properties from the image node"""
@@ -535,3 +541,21 @@ class Entry_section(Entry):
def WriteChildData(self, child):
return True
+
+ def SetAllowMissing(self, allow_missing):
+ """Set whether a section allows missing external blobs
+
+ Args:
+ allow_missing: True if allowed, False if not allowed
+ """
+ self._allow_missing = allow_missing
+ for entry in self._entries.values():
+ entry.SetAllowMissing(allow_missing)
+
+ def GetAllowMissing(self):
+ """Get whether a section allows missing external blobs
+
+ Returns:
+ True if allowed, False if not allowed
+ """
+ return self._allow_missing