My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

lerdge.py 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #
  2. # buildroot/share/PlatformIO/scripts/lerdge.py
  3. # Customizations for Lerdge build environments:
  4. # env:LERDGEX env:LERDGEX_usb_flash_drive
  5. # env:LERDGES env:LERDGES_usb_flash_drive
  6. # env:LERDGEK env:LERDGEK_usb_flash_drive
  7. #
  8. import os,marlin
  9. Import("env")
  10. from SCons.Script import DefaultEnvironment
  11. board = DefaultEnvironment().BoardConfig()
  12. def encryptByte(byte):
  13. byte = 0xFF & ((byte << 6) | (byte >> 2))
  14. i = 0x58 + byte
  15. j = 0x05 + byte + (i >> 8)
  16. byte = (0xF8 & i) | (0x07 & j)
  17. return byte
  18. def encrypt_file(input, output_file, file_length):
  19. input_file = bytearray(input.read())
  20. for i in range(len(input_file)):
  21. result = encryptByte(input_file[i])
  22. input_file[i] = result
  23. output_file.write(input_file)
  24. return
  25. # Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt
  26. def encrypt(source, target, env):
  27. fwname = board.get("build.encrypt")
  28. print("Encrypting %s to %s" % (target[0].path, fwname))
  29. firmware = open(target[0].path, "rb")
  30. renamed = open(target[0].dir.path + "/" + fwname, "wb")
  31. length = os.path.getsize(target[0].path)
  32. encrypt_file(firmware, renamed, length)
  33. firmware.close()
  34. renamed.close()
  35. if 'encrypt' in board.get("build").keys():
  36. marlin.add_post_action(encrypt);
  37. else:
  38. print("LERDGE builds require output file via board_build.encrypt = 'filename' parameter")
  39. exit(1);