🔨 [2.0.9.7] Use older chitu_crypt.py

This commit is contained in:
Scott Lahteine
2023-07-04 00:19:45 -05:00
parent 5ac0c72bac
commit 743d3100fa
5 changed files with 15 additions and 24 deletions

View File

@@ -4,9 +4,9 @@
#
import pioutil
if pioutil.is_pio_build():
import struct,uuid,marlin
board = marlin.env.BoardConfig()
import os,random,struct,uuid,marlin
# Relocate firmware from 0x08000000 to 0x08008800
marlin.relocate_firmware("0x08008800")
def calculate_crc(contents, seed):
accumulating_xor_value = seed;
@@ -105,22 +105,13 @@ if pioutil.is_pio_build():
# Encrypt ${PROGNAME}.bin and save it as 'update.cbd'
def encrypt(source, target, env):
from pathlib import Path
firmware = open(target[0].path, "rb")
update = open(target[0].dir.path + '/update.cbd', "wb")
length = os.path.getsize(target[0].path)
fwpath = Path(target[0].path)
fwsize = fwpath.stat().st_size
encrypt_file(firmware, update, length)
enname = board.get("build.crypt_chitu")
enpath = Path(target[0].dir.path)
firmware.close()
update.close()
fwfile = fwpath.open("rb")
enfile = (enpath / enname).open("wb")
print(f"Encrypting {fwpath} to {enname}")
encrypt_file(fwfile, enfile, fwsize)
fwfile.close()
enfile.close()
fwpath.unlink()
marlin.relocate_firmware("0x08008800")
marlin.add_post_action(encrypt);