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_robin.py 1.1KB

123456789101112131415161718192021222324252627282930
  1. Import("env")
  2. # Relocate firmware from 0x08000000 to 0x08007000
  3. for define in env['CPPDEFINES']:
  4. if define[0] == "VECT_TAB_ADDR":
  5. env['CPPDEFINES'].remove(define)
  6. env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
  7. env.Replace(LDSCRIPT_PATH="buildroot/share/PlatformIO/ldscripts/mks_robin.ld")
  8. # Encrypt ${PROGNAME}.bin and save it as 'Robin.bin'
  9. def encrypt(source, target, env):
  10. import os
  11. 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]
  12. firmware = open(target[0].path, "rb")
  13. robin = open(target[0].dir.path +'/Robin.bin', "wb")
  14. length = os.path.getsize(target[0].path)
  15. position = 0
  16. try:
  17. while position < length:
  18. byte = firmware.read(1)
  19. if position >= 320 and position < 31040:
  20. byte = chr(ord(byte) ^ key[position & 31])
  21. robin.write(byte)
  22. position += 1
  23. finally:
  24. firmware.close()
  25. robin.close()
  26. env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);