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