aboutsummaryrefslogtreecommitdiff
path: root/circuitpython/tools/join_bins.py
diff options
context:
space:
mode:
Diffstat (limited to 'circuitpython/tools/join_bins.py')
-rw-r--r--circuitpython/tools/join_bins.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/circuitpython/tools/join_bins.py b/circuitpython/tools/join_bins.py
new file mode 100644
index 0000000..a370f86
--- /dev/null
+++ b/circuitpython/tools/join_bins.py
@@ -0,0 +1,24 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
+import sys
+
+output_filename = sys.argv[1]
+input_filenames = {}
+i = 2
+while i < len(sys.argv):
+ offset = int(sys.argv[i], 16)
+ filename = sys.argv[i + 1]
+ input_filenames[offset] = filename
+ i += 2
+
+with open(output_filename, "wb") as output_file:
+ offsets = sorted(input_filenames.keys())
+ for offset in offsets:
+ input_filename = input_filenames[offset]
+ # Fill with ones to save NOR flash.
+ while output_file.tell() < offset:
+ output_file.write(b"\xff")
+ with open(input_filename, "rb") as input_file:
+ output_file.write(input_file.read())