diff --git a/buildroot/share/PlatformIO/scripts/marlin.py b/buildroot/share/PlatformIO/scripts/marlin.py index 8ac36b7d59b5..72290fc47b22 100644 --- a/buildroot/share/PlatformIO/scripts/marlin.py +++ b/buildroot/share/PlatformIO/scripts/marlin.py @@ -52,24 +52,22 @@ def encrypt_mks(source, target, env, new_name): mf = env["MARLIN_FEATURES"] if "FIRMWARE_BIN" in mf: new_name = mf["FIRMWARE_BIN"] - fwpath = target[0].path - fwfile = open(fwpath, "rb") - enfile = open(target[0].dir.path + "/" + new_name, "wb") - length = os.path.getsize(fwpath) + firmware = open(target[0].path, "rb") + renamed = open(target[0].dir.path + "/" + new_name, "wb") + length = os.path.getsize(target[0].path) position = 0 try: while position < length: - byte = fwfile.read(1) + byte = firmware.read(1) if position >= 320 and position < 31040: byte = chr(ord(byte) ^ key[position & 31]) if sys.version_info[0] > 2: byte = bytes(byte, 'latin1') - enfile.write(byte) + renamed.write(byte) position += 1 finally: - fwfile.close() - enfile.close() - os.remove(fwpath) + firmware.close() + renamed.close() def add_post_action(action): env.AddPostAction(join("$BUILD_DIR", "${PROGNAME}.bin"), action); diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index 688cc1054736..a66eec407ed0 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -305,13 +305,13 @@ build_flags = ${stm_flash_drive.build_flags} extends = stm32_variant board = marlin_STM32F407ZGT6 board_build.variant = MARLIN_LERDGE +board_build.encrypt = firmware.bin board_build.offset = 0x10000 build_flags = ${stm32_variant.build_flags} -DSTM32F4 -DSTM32F4xx -DTARGET_STM32F4 -DDISABLE_GENERIC_SERIALUSB -DARDUINO_ARCH_STM32 -DLERDGE_TFT35 build_unflags = ${stm32_variant.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483 -extra_scripts = ${common_stm32.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py +extra_scripts = ${stm32_variant.extra_scripts} buildroot/share/PlatformIO/scripts/lerdge.py #