|
@@ -4,7 +4,9 @@
|
4
|
4
|
#
|
5
|
5
|
import pioutil
|
6
|
6
|
if pioutil.is_pio_build():
|
7
|
|
- import struct,uuid
|
|
7
|
+ import struct,uuid,marlin
|
|
8
|
+
|
|
9
|
+ board = marlin.env.BoardConfig()
|
8
|
10
|
|
9
|
11
|
def calculate_crc(contents, seed):
|
10
|
12
|
accumulating_xor_value = seed;
|
|
@@ -104,12 +106,21 @@ if pioutil.is_pio_build():
|
104
|
106
|
# Encrypt ${PROGNAME}.bin and save it as 'update.cbd'
|
105
|
107
|
def encrypt(source, target, env):
|
106
|
108
|
from pathlib import Path
|
|
109
|
+
|
107
|
110
|
fwpath = Path(target[0].path)
|
108
|
111
|
fwsize = fwpath.stat().st_size
|
|
112
|
+
|
|
113
|
+ enname = board.get("build.crypt_chitu")
|
|
114
|
+ enpath = Path(target[0].dir.path)
|
|
115
|
+
|
109
|
116
|
fwfile = fwpath.open("rb")
|
110
|
|
- upfile = Path(target[0].dir.path, 'update.cbd').open("wb")
|
111
|
|
- encrypt_file(fwfile, upfile, fwsize)
|
|
117
|
+ enfile = (enpath / enname).open("wb")
|
|
118
|
+
|
|
119
|
+ print(f"Encrypting {fwpath} to {enname}")
|
|
120
|
+ encrypt_file(fwfile, enfile, fwsize)
|
|
121
|
+ fwfile.close()
|
|
122
|
+ enfile.close()
|
|
123
|
+ fwpath.unlink()
|
112
|
124
|
|
113
|
|
- import marlin
|
114
|
125
|
marlin.relocate_firmware("0x08008800")
|
115
|
126
|
marlin.add_post_action(encrypt);
|