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