diff options
author | Tom Rini <trini@konsulko.com> | 2022-08-22 12:41:07 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-08-22 12:41:07 -0400 |
commit | 850ac7ceb75d2f86f0feae48ee77ee663dcd29d5 (patch) | |
tree | 5d70681ddd31ad0cb69ad7900a9956aaae8aba51 /tools/binman/cbfs_util.py | |
parent | 61e887fb9cbb6e1d64c2383a865f79ed3570bcf8 (diff) | |
parent | cd15b640b0b8d5a7ba5f1c0587e4f9c767e2d8fb (diff) |
Merge tag 'dm-pull-20aug22' of https://source.denx.de/u-boot/custodians/u-boot-dm
binman fixes for various things
binman clean-up of compression and addition of utilities
Diffstat (limited to 'tools/binman/cbfs_util.py')
-rw-r--r-- | tools/binman/cbfs_util.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/tools/binman/cbfs_util.py b/tools/binman/cbfs_util.py index 9cad03886f7..7bd3d897981 100644 --- a/tools/binman/cbfs_util.py +++ b/tools/binman/cbfs_util.py @@ -20,7 +20,7 @@ import io import struct import sys -from binman import comp_util +from binman import bintool from binman import elf from patman import command from patman import tools @@ -236,14 +236,18 @@ class CbfsFile(object): self.data_len = len(data) self.erase_byte = None self.size = None + if self.compress == COMPRESS_LZ4: + self.comp_bintool = bintool.Bintool.create('lz4') + elif self.compress == COMPRESS_LZMA: + self.comp_bintool = bintool.Bintool.create('lzma_alone') + else: + self.comp_bintool = None def decompress(self): """Handle decompressing data if necessary""" indata = self.data - if self.compress == COMPRESS_LZ4: - data = comp_util.decompress(indata, 'lz4', with_header=False) - elif self.compress == COMPRESS_LZMA: - data = comp_util.decompress(indata, 'lzma', with_header=False) + if self.comp_bintool: + data = self.comp_bintool.decompress(indata) else: data = indata self.memlen = len(data) @@ -361,10 +365,8 @@ class CbfsFile(object): data = elf_data.data elif self.ftype == TYPE_RAW: orig_data = data - if self.compress == COMPRESS_LZ4: - data = comp_util.compress(orig_data, 'lz4', with_header=False) - elif self.compress == COMPRESS_LZMA: - data = comp_util.compress(orig_data, 'lzma', with_header=False) + if self.comp_bintool: + data = self.comp_bintool.compress(orig_data) self.memlen = len(orig_data) self.data_len = len(data) attr = struct.pack(ATTR_COMPRESSION_FORMAT, |