Skip to content

Commit

Permalink
Merge pull request #9783 from bridadan/fix_unsigned_crc_header
Browse files Browse the repository at this point in the history
Ensure header CRC is written as unsigned int
  • Loading branch information
Cruz Monrreal committed Feb 21, 2019
2 parents 01aeb48 + 434d86b commit 091da53
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tools/build_api.py
Expand Up @@ -398,8 +398,9 @@ def _fill_header(region_list, current_region):
else:
ih = intelhex_offset(region_dict[data].filename, offset=region_dict[data].start)
if subtype.startswith("CRCITT32"):
fmt = {"CRCITT32be": ">l", "CRCITT32le": "<l"}[subtype]
header.puts(start, struct.pack(fmt, zlib.crc32(ih.tobinarray())))
fmt = {"CRCITT32be": ">L", "CRCITT32le": "<L"}[subtype]
crc_val = zlib.crc32(ih.tobinarray()) & 0xffffffff
header.puts(start, struct.pack(fmt, crc_val))
elif subtype.startswith("SHA"):
if subtype == "SHA256":
hash = hashlib.sha256()
Expand Down

0 comments on commit 091da53

Please sign in to comment.