scripts: imgtool: compression ARM thumb filter
Adds ARM thumb filter to imgtool's LZMA2 compression.
Signed-off-by: Mateusz Michalek <mateusz.michalek@nordicsemi.no>
diff --git a/scripts/imgtool/main.py b/scripts/imgtool/main.py
index 03bb565..94952a8 100755
--- a/scripts/imgtool/main.py
+++ b/scripts/imgtool/main.py
@@ -363,7 +363,7 @@
help='When encrypting the image using AES, select a 128 bit or '
'256 bit key len.')
@click.option('--compression', default='disabled',
- type=click.Choice(['disabled', 'lzma2']),
+ type=click.Choice(['disabled', 'lzma2', 'lzma2armthumb']),
help='Enable image compression using specified type. '
'Will fall back without image compression automatically '
'if the compression increases the image size.')
@@ -513,7 +513,7 @@
custom_tlvs, compression_tlvs, int(encrypt_keylen), clear,
baked_signature, pub_key, vector_to_sign, user_sha)
- if compression == "lzma2":
+ if compression in ["lzma2", "lzma2armthumb"]:
compressed_img = image.Image(version=decode_version(version),
header_size=header_size, pad_header=pad_header,
pad=pad, confirm=confirm, align=int(align),
@@ -527,6 +527,8 @@
"dict_size": comp_default_dictsize, "lp": comp_default_lp,
"lc": comp_default_lc}
]
+ if compression == "lzma2armthumb":
+ compression_filters.insert(0, {"id":lzma.FILTER_ARMTHUMB})
compressed_data = lzma.compress(img.get_infile_data(),filters=compression_filters,
format=lzma.FORMAT_RAW)
uncompressed_size = len(img.get_infile_data())