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

lerdge.py 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import os,sys
  2. Import("env")
  3. from SCons.Script import DefaultEnvironment
  4. board = DefaultEnvironment().BoardConfig()
  5. custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/lerdge.ld")
  6. for i, flag in enumerate(env["LINKFLAGS"]):
  7. if "-Wl,-T" in flag:
  8. env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script
  9. elif flag == "-T":
  10. env["LINKFLAGS"][i + 1] = custom_ld_script
  11. def encryptByte(byte):
  12. byte = 0xFF & ((byte << 6) | (byte >> 2))
  13. i = 0x58 + byte
  14. j = 0x05 + byte + (i >> 8)
  15. byte = (0xF8 & i) | (0x07 & j)
  16. return byte
  17. def encrypt_file(input, output_file, file_length):
  18. input_file = bytearray(input.read())
  19. for i in range(len(input_file)):
  20. result = encryptByte(input_file[i])
  21. input_file[i] = result
  22. output_file.write(input_file)
  23. return
  24. # Encrypt ${PROGNAME}.bin and save it as build.firmware
  25. def encrypt(source, target, env):
  26. print("Encrypting to:", board.get("build.firmware"))
  27. firmware = open(target[0].path, "rb")
  28. result = open(target[0].dir.path + "/" + board.get("build.firmware"), "wb")
  29. length = os.path.getsize(target[0].path)
  30. encrypt_file(firmware, result, length)
  31. firmware.close()
  32. result.close()
  33. if 'firmware' in board.get("build").keys():
  34. env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);
  35. else:
  36. print("You need to define output file via board_build.firmware = 'filename' parameter")
  37. exit(1);