aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/update_mks_robin.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2020-03-24 10:30:02 -0400
committerKevin O'Connor <kevin@koconnor.net>2020-03-24 10:30:02 -0400
commit302cd3821770ef2ba0261dc4d52019426a1a0262 (patch)
tree9dd1e4cd1cd5115f6dbe8e0385ded71bcf635b5c /scripts/update_mks_robin.py
parent91a27ef083966b59289b8bfb71a3fb3166b8615f (diff)
downloadkutter-302cd3821770ef2ba0261dc4d52019426a1a0262.tar.gz
kutter-302cd3821770ef2ba0261dc4d52019426a1a0262.tar.xz
kutter-302cd3821770ef2ba0261dc4d52019426a1a0262.zip
update_mks_robin: Add script to update firmware for MKS Robin bootloader
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'scripts/update_mks_robin.py')
-rwxr-xr-xscripts/update_mks_robin.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/update_mks_robin.py b/scripts/update_mks_robin.py
new file mode 100755
index 00000000..f54c05f8
--- /dev/null
+++ b/scripts/update_mks_robin.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python2
+# Script to update firmware for MKS Robin bootloader
+#
+# Copyright (C) 2020 Kevin O'Connor <kevin@koconnor.net>
+#
+# This file may be distributed under the terms of the GNU GPLv3 license.
+import os, optparse, sys
+
+XOR_PATTERN = [
+ 0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80,
+ 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33,
+ 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF,
+ 0xF7, 0x3E
+]
+
+def main():
+ # Parse command-line arguments
+ usage = "%prog <input_file> <output_file>"
+ opts = optparse.OptionParser(usage)
+ options, args = opts.parse_args()
+ if len(args) != 2:
+ opts.error("Incorrect number of arguments")
+ infilename, outfilename = args
+ # Read input
+ f = open(infilename, "rb")
+ srcfirmware = f.read()
+ f.close()
+ # Update
+ firmware = bytearray(srcfirmware)
+ for pos in range(320, min(31040, len(firmware))):
+ firmware[pos] ^= XOR_PATTERN[pos & 31]
+ # Write output
+ f = open(outfilename, "wb")
+ f.write(firmware)
+ f.close()
+
+if __name__ == '__main__':
+ main()