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.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #
  2. # 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 pioutil
  9. if pioutil.is_pio_build():
  10. import os,marlin
  11. Import("env")
  12. from SCons.Script import DefaultEnvironment
  13. board = DefaultEnvironment().BoardConfig()
  14. def encryptByte(byte):
  15. byte = 0xFF & ((byte << 6) | (byte >> 2))
  16. i = 0x58 + byte
  17. j = 0x05 + byte + (i >> 8)
  18. byte = (0xF8 & i) | (0x07 & j)
  19. return byte
  20. def encrypt_file(input, output_file, file_length):
  21. input_file = bytearray(input.read())
  22. for i in range(len(input_file)):
  23. input_file[i] = encryptByte(input_file[i])
  24. output_file.write(input_file)
  25. # Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt
  26. def encrypt(source, target, env):
  27. fwpath = target[0].path
  28. enname = board.get("build.encrypt")
  29. print("Encrypting %s to %s" % (fwpath, enname))
  30. fwfile = open(fwpath, "rb")
  31. enfile = open(target[0].dir.path + "/" + enname, "wb")
  32. length = os.path.getsize(fwpath)
  33. encrypt_file(fwfile, enfile, length)
  34. fwfile.close()
  35. enfile.close()
  36. os.remove(fwpath)
  37. if 'encrypt' in board.get("build").keys():
  38. if board.get("build.encrypt") != "":
  39. marlin.add_post_action(encrypt)
  40. else:
  41. print("LERDGE builds require output file via board_build.encrypt = 'filename' parameter")
  42. exit(1)