My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mks_encrypt.py 1.1KB

1234567891011121314151617181920212223242526272829303132
  1. import os,sys
  2. Import("env")
  3. from SCons.Script import DefaultEnvironment
  4. board = DefaultEnvironment().BoardConfig()
  5. # Encrypt ${PROGNAME}.bin and save it as build.firmware ('Robin.bin')
  6. def encrypt(source, target, env):
  7. key = [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]
  8. firmware = open(target[0].path, "rb")
  9. robin = open(target[0].dir.path +'/'+ board.get("build.firmware"), "wb")
  10. length = os.path.getsize(target[0].path)
  11. position = 0
  12. try:
  13. while position < length:
  14. byte = firmware.read(1)
  15. if position >= 320 and position < 31040:
  16. byte = chr(ord(byte) ^ key[position & 31])
  17. if sys.version_info[0] > 2:
  18. byte = bytes(byte, 'latin1')
  19. robin.write(byte)
  20. position += 1
  21. finally:
  22. firmware.close()
  23. robin.close()
  24. if 'firmware' in board.get("build").keys():
  25. env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);
  26. else:
  27. print("You need to define output file via board_build.firmware = 'filename' parameter", file=sys.stderr)
  28. exit(1);