Skip to content

Commit 091da53

Browse files
author
Cruz Monrreal
authored
Merge pull request #9783 from bridadan/fix_unsigned_crc_header
Ensure header CRC is written as unsigned int
2 parents 01aeb48 + 434d86b commit 091da53

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tools/build_api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,9 @@ def _fill_header(region_list, current_region):
398398
else:
399399
ih = intelhex_offset(region_dict[data].filename, offset=region_dict[data].start)
400400
if subtype.startswith("CRCITT32"):
401-
fmt = {"CRCITT32be": ">l", "CRCITT32le": "<l"}[subtype]
402-
header.puts(start, struct.pack(fmt, zlib.crc32(ih.tobinarray())))
401+
fmt = {"CRCITT32be": ">L", "CRCITT32le": "<L"}[subtype]
402+
crc_val = zlib.crc32(ih.tobinarray()) & 0xffffffff
403+
header.puts(start, struct.pack(fmt, crc_val))
403404
elif subtype.startswith("SHA"):
404405
if subtype == "SHA256":
405406
hash = hashlib.sha256()

0 commit comments

Comments
 (0)