summaryrefslogtreecommitdiff
path: root/tools/binman/cbfs_util.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-10-14 14:40:26 -0600
committerTom Rini <trini@konsulko.com>2023-11-02 22:37:50 -0400
commitbd13255a91af04ab431972ab145e665147802c30 (patch)
tree2534d79cd0fce227d731094bdac27b40c29268e5 /tools/binman/cbfs_util.py
parent823f5c3a02276067c583b2f31144095f2b3b41fc (diff)
binman: Don't add compression attribute for uncompressed files
cbfsutil changed to skip adding a compression attribute if there is no compression. Adjust the binman implementation to do the same. This mirrors commit 105cdf5625 in coreboot. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Neha Malcom Francis <n-francis@ti.com>
Diffstat (limited to 'tools/binman/cbfs_util.py')
-rw-r--r--tools/binman/cbfs_util.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/tools/binman/cbfs_util.py b/tools/binman/cbfs_util.py
index fc56b40b753..92d2add2514 100644
--- a/tools/binman/cbfs_util.py
+++ b/tools/binman/cbfs_util.py
@@ -333,7 +333,8 @@ class CbfsFile(object):
if self.ftype == TYPE_STAGE:
pass
elif self.ftype == TYPE_RAW:
- hdr_len += ATTR_COMPRESSION_LEN
+ if self.compress:
+ hdr_len += ATTR_COMPRESSION_LEN
elif self.ftype == TYPE_EMPTY:
pass
else:
@@ -369,9 +370,11 @@ class CbfsFile(object):
data = self.comp_bintool.compress(orig_data)
self.memlen = len(orig_data)
self.data_len = len(data)
- attr = struct.pack(ATTR_COMPRESSION_FORMAT,
- FILE_ATTR_TAG_COMPRESSION, ATTR_COMPRESSION_LEN,
- self.compress, self.memlen)
+ if self.compress:
+ attr = struct.pack(ATTR_COMPRESSION_FORMAT,
+ FILE_ATTR_TAG_COMPRESSION,
+ ATTR_COMPRESSION_LEN, self.compress,
+ self.memlen)
elif self.ftype == TYPE_EMPTY:
data = tools.get_bytes(self.erase_byte, self.size)
else:
@@ -405,7 +408,7 @@ class CbfsFile(object):
if expected_len != actual_len: # pragma: no cover
# Test coverage of this is not available since this should never
# happen. It probably indicates that get_header_len() is broken.
- raise ValueError("Internal error: CBFS file '%s': Expected headers of %#x bytes, got %#d" %
+ raise ValueError("Internal error: CBFS file '%s': Expected headers of %#x bytes, got %#x" %
(self.name, expected_len, actual_len))
return hdr + name + attr + pad + content + data, hdr_len