My Marlin configs for Fabrikator Mini and CTC i3 Pro B
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

mks_robin_lite.py 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import os
  2. Import("env")
  3. # Relocate firmware from 0x08000000 to 0x08005000
  4. for define in env['CPPDEFINES']:
  5. if define[0] == "VECT_TAB_ADDR":
  6. env['CPPDEFINES'].remove(define)
  7. env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08005000"))
  8. custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_lite.ld")
  9. for i, flag in enumerate(env["LINKFLAGS"]):
  10. if "-Wl,-T" in flag:
  11. env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script
  12. elif flag == "-T":
  13. env["LINKFLAGS"][i + 1] = custom_ld_script
  14. # Encrypt ${PROGNAME}.bin and save it as 'mksLite.bin'
  15. def encrypt(source, target, env):
  16. import sys
  17. 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]
  18. firmware = open(target[0].path, "rb")
  19. robin = open(target[0].dir.path +'/mksLite.bin', "wb")
  20. length = os.path.getsize(target[0].path)
  21. position = 0
  22. try:
  23. while position < length:
  24. byte = firmware.read(1)
  25. if position >= 320 and position < 31040:
  26. byte = chr(ord(byte) ^ key[position & 31])
  27. if sys.version_info[0] > 2:
  28. byte = bytes(byte, 'latin1')
  29. robin.write(byte)
  30. position += 1
  31. finally:
  32. firmware.close()
  33. robin.close()
  34. env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);