diff --git a/config/printer-tronxy-x5sa-v6-2019.cfg b/config/printer-tronxy-x5sa-v6-2019.cfg index 2a6ccba3..ad822beb 100644 --- a/config/printer-tronxy-x5sa-v6-2019.cfg +++ b/config/printer-tronxy-x5sa-v6-2019.cfg @@ -7,7 +7,7 @@ # at 0x8008800 (Chitu v6 Bootloader). Uncheck USB, and leave default # serial settings. # -# Use "./chitu_crypt.py out/klipper.bin" to generate update.cbz. +# Use "./update_chitu.py out/klipper.bin update.cbz" to generate update.cbz. # Put `update.cbz` onto SD card, and reboot the printer. # It will be automatically installed, and you will be able to update it this way. diff --git a/scripts/chitu_crypt.py b/scripts/update_chitu.py similarity index 78% rename from scripts/chitu_crypt.py rename to scripts/update_chitu.py index 080b9f47..2da78276 100755 --- a/scripts/chitu_crypt.py +++ b/scripts/update_chitu.py @@ -1,5 +1,5 @@ #!/usr/bin/env python2 -# Encrypts STM32 firmwares to be flashable from SD card by Chitu motherboards. +# Encodes STM32 firmwares to be flashable from SD card by Chitu motherboards. # Relocate firmware to 0x08008800! # Copied from Marlin and modified. @@ -64,7 +64,7 @@ def xor_block(r0, r1, block_number, block_size, file_key): loop_counter = loop_counter + 1 -def encrypt_file(input, output_file, file_length): +def encode_file(input, output_file, file_length): input_file = bytearray(input.read()) block_size = 0x800 key_length = 0x18 @@ -81,7 +81,7 @@ def encrypt_file(input, output_file, file_length): # write the file header output_file.write(struct.pack(">I", 0x443D2D3F)) - # encrypt the contents using a known file header key + # encode the contents using a known file header key # write the file_key output_file.write(struct.pack(" ") + exit(1) -fw = sys.argv[-1] + fw, output = sys.argv[1:] -if not os.path.isfile(fw): - print("Usage: chitu_crypt [firmware.bin]") - print("Firmware file", fw, "does not exist") - exit(1) + if not os.path.isfile(fw): + print("Usage: update_chitu ") + print("Firmware file", fw, "does not exist") + exit(1) -firmware = open(fw, "rb") -update = open('./update.cbd', "wb") -length = os.path.getsize(fw) + firmware = open(fw, "rb") + update = open(output, "wb") + length = os.path.getsize(fw) -encrypt_file(firmware, update, length) + encode_file(firmware, update, length) -firmware.close() -update.close() + firmware.close() + update.close() -print("Encryption complete. Firmware is written to update.cbd.") + print("Encoding complete.") + +if __name__ == '__main__': + main()