[tools] Move functions to utilities, add universal CRC16 class

This commit is contained in:
Kuba Szczodrzyński
2022-06-10 11:02:49 +02:00
parent bbf8e0b6b6
commit c3f2ce57f0
6 changed files with 303 additions and 43 deletions

View File

@@ -10,7 +10,7 @@ from binascii import crc32
from os import makedirs
from os.path import basename, dirname, join
from tools.util.crypto import crc16
from tools.util.crc16 import CRC16
from tools.util.platform import get_board_manifest
if __name__ == "__main__":
@@ -61,7 +61,7 @@ if __name__ == "__main__":
cs = crc32(part)
cs = cs.to_bytes(length=4, byteorder="big")
else:
cs = crc16(part)
cs = CRC16.ARC.calc(part)
cs = cs.to_bytes(length=2, byteorder="big")
filename = f"{offset}_{name}_{cs.hex().upper()}.bin"
print(f"Writing {filename}")