Skip to content

Commit d08c134

Browse files
committed
Adjusting bin2ota.py to support both MKR WIFI 1010 and Nano 33 IOT
1 parent 735899c commit d08c134

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

extras/tools/bin2ota.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,34 @@
33
import sys
44
import crccheck
55

6-
if len(sys.argv) != 3:
7-
print ("Usage: bin2ota.py sketch.bin sketch.ota")
6+
if len(sys.argv) != 4:
7+
print ("Usage: bin2ota.py BOARD sketch.bin sketch.ota")
8+
print (" BOARD = [MKR_WIFI_1010 | NANO_33_IOT]")
89
sys.exit()
910

10-
ifile = sys.argv[1]
11-
ofile = sys.argv[2]
11+
board = sys.argv[1]
12+
ifile = sys.argv[2]
13+
ofile = sys.argv[3]
1214

1315
# Read the binary file
1416
in_file = open(ifile, "rb")
1517
bin_data = bytearray(in_file.read())
1618
in_file.close()
1719

1820
# 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+
magic_number_mkr_wifi_1010 = bytearray([0x23, 0x41, 0x80, 0x54])
22+
magic_number_nano_33_iot = bytearray([0x23, 0x41, 0x80, 0x57])
23+
24+
if board == "MKR_WIFI_1010":
25+
magic_number = magic_number_mkr_wifi_1010
26+
elif board == "NANO_33_IOT":
27+
magic_number = magic_number_nano_33_iot
28+
else:
29+
print ("Error,", board, "is not a supported board type")
30+
sys.exit()
2131

2232
# Version field (byte array of size 8)
2333
version = bytearray(8)
24-
print(version)
2534

2635
# Prepend magic number and version field to payload
2736
bin_data_complete = magic_number + version + bin_data

0 commit comments

Comments
 (0)