Skip to content

Commit 735899c

Browse files
committed
Tailor bin2ota script for MKR WiFi 1010 and new OTA header structure
1 parent 0b45114 commit 735899c

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

extras/tools/bin2ota.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,24 @@
1515
bin_data = bytearray(in_file.read())
1616
in_file.close()
1717

18+
# Magic number (VID/PID), hard coded for MKR VIDOR 4000 right now
19+
magic_number = bytearray([0x23, 0x41, 0x80, 0x54])
20+
print(magic_number)
21+
22+
# Version field (byte array of size 8)
23+
version = bytearray(8)
24+
print(version)
25+
26+
# Prepend magic number and version field to payload
27+
bin_data_complete = magic_number + version + bin_data
28+
1829
# Calculate length and CRC32
19-
bin_data_len = len(bin_data)
20-
bin_data_crc = crccheck.crc.Crc32.calc(bin_data)
30+
bin_data_len = len(bin_data_complete)
31+
bin_data_crc = crccheck.crc.Crc32.calc(bin_data_complete)
2132

2233
# Write to outfile
2334
out_file = open(ofile, "wb")
2435
out_file.write((bin_data_len).to_bytes(4,byteorder='little'))
2536
out_file.write((bin_data_crc).to_bytes(4,byteorder='little'))
26-
out_file.write(bin_data)
37+
out_file.write(bin_data_complete)
2738
out_file.close()

0 commit comments

Comments
 (0)