diff mbox series

[U-Boot,v2,29/31] binman: Support reading from CBFS entries

Message ID 20190708202553.225715-30-sjg@chromium.org
State Accepted
Commit 3a9c252583785c3aabce834e8f9a54fa94685ee8
Delegated to: Simon Glass
Headers show
Series binman: Allow reading of images to list contents | expand

Commit Message

Simon Glass July 8, 2019, 8:25 p.m. UTC
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>
---

Changes in v2: None

 tools/binman/cbfs_util.py  | 14 ++++++++++++++
 tools/binman/etype/cbfs.py |  7 +++++++
 2 files changed, 21 insertions(+)

Comments

Simon Glass July 18, 2019, 1:58 a.m. UTC | #1
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>
---

Changes in v2: None

 tools/binman/cbfs_util.py  | 14 ++++++++++++++
 tools/binman/etype/cbfs.py |  7 +++++++
 2 files changed, 21 insertions(+)

Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/tools/binman/cbfs_util.py b/tools/binman/cbfs_util.py
index 4691be4aee2..45e16da0aaa 100644
--- a/tools/binman/cbfs_util.py
+++ b/tools/binman/cbfs_util.py
@@ -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
 
diff --git a/tools/binman/etype/cbfs.py b/tools/binman/etype/cbfs.py
index 953d6f4868d..edf2189fd26 100644
--- a/tools/binman/etype/cbfs.py
+++ b/tools/binman/etype/cbfs.py
@@ -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