Loading scripts/imgtool/image.py +4 −1 Changes for scripts/imgtool/image.py: 4 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ IMAGE_F = { 'ROM_FIXED': 0x0000100, 'COMPRESSED_LZMA1': 0x0000200, 'COMPRESSED_LZMA2': 0x0000400, 'COMPRESSED_ARM_THUMB': 0x0000800, } TLV_VALUES = { Loading Loading @@ -533,8 +534,10 @@ class Image: compression_flags = 0x0 if compression_tlvs is not None: if compression_type == "lzma2": if compression_type in ["lzma2", "lzma2armthumb"]: compression_flags = IMAGE_F['COMPRESSED_LZMA2'] if compression_type == "lzma2armthumb": compression_flags |= IMAGE_F['COMPRESSED_ARM_THUMB'] # This adds the header to the payload as well if encrypt_keylen == 256: self.add_header(enckey, protected_tlv_size, compression_flags, 256) Loading scripts/imgtool/main.py +4 −2 Changes for scripts/imgtool/main.py: 4 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -363,7 +363,7 @@ class BasedIntParamType(click.ParamType): 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.') Loading Loading @@ -513,7 +513,7 @@ def sign(key, public_key_format, align, version, pad_sig, header_size, 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), Loading @@ -527,6 +527,8 @@ def sign(key, public_key_format, align, version, pad_sig, header_size, "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()) Loading Loading
scripts/imgtool/image.py +4 −1 Changes for scripts/imgtool/image.py: 4 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ IMAGE_F = { 'ROM_FIXED': 0x0000100, 'COMPRESSED_LZMA1': 0x0000200, 'COMPRESSED_LZMA2': 0x0000400, 'COMPRESSED_ARM_THUMB': 0x0000800, } TLV_VALUES = { Loading Loading @@ -533,8 +534,10 @@ class Image: compression_flags = 0x0 if compression_tlvs is not None: if compression_type == "lzma2": if compression_type in ["lzma2", "lzma2armthumb"]: compression_flags = IMAGE_F['COMPRESSED_LZMA2'] if compression_type == "lzma2armthumb": compression_flags |= IMAGE_F['COMPRESSED_ARM_THUMB'] # This adds the header to the payload as well if encrypt_keylen == 256: self.add_header(enckey, protected_tlv_size, compression_flags, 256) Loading
scripts/imgtool/main.py +4 −2 Changes for scripts/imgtool/main.py: 4 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -363,7 +363,7 @@ class BasedIntParamType(click.ParamType): 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.') Loading Loading @@ -513,7 +513,7 @@ def sign(key, public_key_format, align, version, pad_sig, header_size, 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), Loading @@ -527,6 +527,8 @@ def sign(key, public_key_format, align, version, pad_sig, header_size, "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()) Loading