tools: hex2c: Add crc32s for each segment
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
This commit is contained in:
parent
ccaf12750b
commit
0678128c26
1 changed files with 5 additions and 1 deletions
|
@ -3,6 +3,7 @@
|
|||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
# Copyright (C) 2020 Daniel Thompson
|
||||
|
||||
import binascii
|
||||
import intelhex
|
||||
import sys
|
||||
|
||||
|
@ -14,6 +15,7 @@ def generate_c(ihex):
|
|||
print('struct segment {')
|
||||
print(' uint32_t start;');
|
||||
print(' uint32_t end;');
|
||||
print(' uint32_t crc32;')
|
||||
print(' const uint8_t *data;')
|
||||
print('};')
|
||||
print()
|
||||
|
@ -29,7 +31,9 @@ def generate_c(ihex):
|
|||
print('\n};\n')
|
||||
print(f'const struct segment segments[] = {{')
|
||||
for i, segment in enumerate(ihex.segments()):
|
||||
print(f' 0x{segment[0]:08x}, 0x{segment[1]:08x}, segment{i},')
|
||||
sg = ihex.tobinarray(start=segment[0], end=segment[1]-1)
|
||||
crc = binascii.crc32(sg)
|
||||
print(f' 0x{segment[0]:08x}, 0x{segment[1]:08x}, 0x{crc:08x}, segment{i},')
|
||||
print('};')
|
||||
|
||||
ihex = intelhex.IntelHex()
|
||||
|
|
Loading…
Reference in a new issue