1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-02 01:02:19 +02:00

binman: Support compressed entries

Add support for compressing blob entries. This can help reduce image sizes
for many types of data. It requires that the firmware be able to
decompress the data at run-time.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2018-09-14 04:57:26 -06:00
parent 04187a845c
commit 83d73c2f7c
6 changed files with 106 additions and 9 deletions

View File

@@ -54,6 +54,7 @@ CROS_EC_RW_DATA = 'ecrw'
GBB_DATA = 'gbbd'
BMPBLK_DATA = 'bmp'
VBLOCK_DATA = 'vblk'
COMPRESS_DATA = 'data to compress'
class TestFunctional(unittest.TestCase):
@@ -116,6 +117,8 @@ class TestFunctional(unittest.TestCase):
with open(self.TestFile('descriptor.bin')) as fd:
TestFunctional._MakeInputFile('descriptor.bin', fd.read())
TestFunctional._MakeInputFile('compress', COMPRESS_DATA)
@classmethod
def tearDownClass(self):
"""Remove the temporary input directory and its contents"""
@@ -1505,6 +1508,34 @@ class TestFunctional(unittest.TestCase):
finally:
self._ResetDtbs()
def _decompress(self, data):
out = os.path.join(self._indir, 'lz4.tmp')
with open(out, 'wb') as fd:
fd.write(data)
return tools.Run('lz4', '-dc', out)
'''
try:
orig = lz4.frame.decompress(data)
except AttributeError:
orig = lz4.decompress(data)
'''
def testCompress(self):
"""Test compression of blobs"""
data, _, _, out_dtb_fname = self._DoReadFileDtb('83_compress.dts',
use_real_dtb=True, update_dtb=True)
dtb = fdt.Fdt(out_dtb_fname)
dtb.Scan()
props = self._GetPropTree(dtb, ['size', 'uncomp-size'])
orig = self._decompress(data)
self.assertEquals(COMPRESS_DATA, orig)
expected = {
'blob:uncomp-size': len(COMPRESS_DATA),
'blob:size': len(data),
'size': len(data),
}
self.assertEqual(expected, props)
if __name__ == "__main__":
unittest.main()