We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 15fbaff commit 666d3e9Copy full SHA for 666d3e9
extras/tools/bin2ota.py
@@ -0,0 +1,27 @@
1
+#!/usr/bin/python3
2
+
3
+import sys
4
+import crccheck
5
6
+if len(sys.argv) != 3:
7
+ print ("Usage: bin2ota.py sketch.bin sketch-ota.bin")
8
+ sys.exit()
9
10
+ifile = sys.argv[1]
11
+ofile = sys.argv[2]
12
13
+# Read the binary file
14
+in_file = open(ifile, "rb")
15
+bin_data = bytearray(in_file.read())
16
+in_file.close()
17
18
+# Calculate length and CRC32
19
+bin_data_len = len(bin_data)
20
+bin_data_crc = crccheck.crc.Crc32.calc(bin_data)
21
22
+# Write to outfile
23
+out_file = open(ofile, "wb")
24
+out_file.write((bin_data_len).to_bytes(4,byteorder='little'))
25
+out_file.write((bin_data_crc).to_bytes(4,byteorder='little'))
26
+out_file.write(bin_data)
27
+out_file.close()
0 commit comments