binman: Support reading from CBFS entries
authorSimon Glass <sjg@chromium.org>
Mon, 8 Jul 2019 20:25:51 +0000 (14:25 -0600)
committerSimon Glass <sjg@chromium.org>
Wed, 24 Jul 2019 19:54:08 +0000 (12:54 -0700)
CBFS is a bit like a section but with a custom format. Provide the list of
entries and the compression type to binman so that it can extract the data
from the CBFS, just like any other part of the image.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/binman/cbfs_util.py
tools/binman/etype/cbfs.py

index 4691be4aee22e9498e408f7cef7f90e8984b8797..45e16da0aaa7e9ac78f89de55dd07ccdf1e62e20 100644 (file)
@@ -142,6 +142,20 @@ def find_compress(find_name):
             return compress
     return None
 
+def compress_name(compress):
+    """Look up the name of a compression algorithm
+
+    Args:
+        compress: Compression algorithm number to find (COMPRESS_...)
+
+    Returns:
+        Compression algorithm name (string)
+
+    Raises:
+        KeyError if the algorithm number is invalid
+    """
+    return COMPRESS_NAMES[compress]
+
 def align_int(val, align):
     """Align a value up to the given alignment
 
index 953d6f4868da6c6bacfe0f7cf7af69ce5e8af54d..edf2189fd26cb47ec868e314ec451f1c37c11662 100644 (file)
@@ -238,6 +238,10 @@ class Entry_cbfs(Entry):
             entry.AddMissingProperties()
             if entry._cbfs_compress:
                 state.AddZeroProp(entry._node, 'uncomp-size')
+                # Store the 'compress' property, since we don't look at
+                # 'cbfs-compress' in Entry.ReadData()
+                state.AddString(entry._node, 'compress',
+                                cbfs_util.compress_name(entry._cbfs_compress))
 
     def SetCalculatedProperties(self):
         """Set the value of device-tree properties calculated by binman"""
@@ -254,3 +258,6 @@ class Entry_cbfs(Entry):
         Entry.ListEntries(self, entries, indent)
         for entry in self._cbfs_entries.values():
             entry.ListEntries(entries, indent + 1)
+
+    def GetEntries(self):
+        return self._cbfs_entries