Skip to content

Commit

Permalink
skip 'encrypt_mks'
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Jun 24, 2022
1 parent 84e1ac4 commit fc76629
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 39 deletions.
8 changes: 4 additions & 4 deletions buildroot/share/PlatformIO/scripts/lerdge.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def encrypt_file(input, output_file, file_length):
# Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt
def encrypt(source, target, env):
fwpath = target[0].path
enname = board.get("build.encrypt")
enname = board.get("build.crypt_lerdge")
print("Encrypting %s to %s" % (fwpath, enname))
fwfile = open(fwpath, "rb")
enfile = open(target[0].dir.path + "/" + enname, "wb")
Expand All @@ -41,9 +41,9 @@ def encrypt(source, target, env):
enfile.close()
os.remove(fwpath)

if 'encrypt' in board.get("build").keys():
if board.get("build.encrypt") != "":
if 'crypt_lerdge' in board.get("build").keys():
if board.get("build.crypt_lerdge") != "":
marlin.add_post_action(encrypt)
else:
print("LERDGE builds require output file via board_build.encrypt = 'filename' parameter")
print("LERDGE builds require output file via board_build.crypt_lerdge = 'filename' parameter")
exit(1)
16 changes: 9 additions & 7 deletions buildroot/share/PlatformIO/scripts/marlin.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,24 @@ def encrypt_mks(source, target, env, new_name):
mf = env["MARLIN_FEATURES"]
if "FIRMWARE_BIN" in mf: new_name = mf["FIRMWARE_BIN"]

firmware = open(target[0].path, "rb")
renamed = open(target[0].dir.path + "/" + new_name, "wb")
length = os.path.getsize(target[0].path)
fwpath = target[0].path
fwfile = open(fwpath, "rb")
enfile = open(target[0].dir.path + "/" + new_name, "wb")
length = os.path.getsize(fwpath)
position = 0
try:
while position < length:
byte = firmware.read(1)
byte = fwfile.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')
renamed.write(byte)
enfile.write(byte)
position += 1
finally:
firmware.close()
renamed.close()
fwfile.close()
enfile.close()
os.remove(fwpath)

def add_post_action(action):
env.AddPostAction(join("$BUILD_DIR", "${PROGNAME}.bin"), action);
56 changes: 28 additions & 28 deletions ini/stm32f4.ini
Original file line number Diff line number Diff line change
Expand Up @@ -302,24 +302,24 @@ build_flags = ${stm_flash_drive.build_flags}
# Lerdge base
#
[lerdge_common]
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 = ${stm32_variant.extra_scripts}
buildroot/share/PlatformIO/scripts/lerdge.py
extends = stm32_variant
board = marlin_STM32F407ZGT6
board_build.variant = MARLIN_LERDGE
board_build.crypt_lerdge = 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 = ${stm32_variant.extra_scripts}
buildroot/share/PlatformIO/scripts/lerdge.py

#
# Lerdge X (STM32F407VE)
#
[env:LERDGEX]
extends = lerdge_common
board_build.encrypt = Lerdge_X_firmware_force.bin
extends = lerdge_common
board_build.crypt_lerdge = Lerdge_X_firmware_force.bin

#
# Lerdge X with USB Flash Drive Support
Expand All @@ -333,8 +333,8 @@ build_flags = ${stm_flash_drive.build_flags} ${lerdge_common.build_flags}
# Lerdge S (STM32F407ZG)
#
[env:LERDGES]
extends = lerdge_common
board_build.encrypt = Lerdge_firmware_force.bin
extends = lerdge_common
board_build.crypt_lerdge = Lerdge_firmware_force.bin

#
# Lerdge S with USB Flash Drive Support
Expand All @@ -348,9 +348,9 @@ build_flags = ${stm_flash_drive.build_flags} ${lerdge_common.build_flags}
# Lerdge K (STM32F407ZG)
#
[env:LERDGEK]
extends = lerdge_common
board_build.encrypt = Lerdge_K_firmware_force.bin
build_flags = ${lerdge_common.build_flags} -DLERDGEK
extends = lerdge_common
board_build.crypt_lerdge = Lerdge_K_firmware_force.bin
build_flags = ${lerdge_common.build_flags} -DLERDGEK

#
# Lerdge K with USB Flash Drive Support
Expand Down Expand Up @@ -547,17 +547,17 @@ build_unflags = -DUSBD_USE_CDC
# TH3D EZBoard v2.0 (STM32F405RGT6 ARM Cortex-M4)
#
[env:TH3D_EZBoard_V2]
extends = stm32_variant
board = genericSTM32F405RG
board_build.variant = MARLIN_TH3D_EZBOARD_V2
board_build.encrypt = firmware.bin
board_build.offset = 0xC000
extends = stm32_variant
board = genericSTM32F405RG
board_build.variant = MARLIN_TH3D_EZBOARD_V2
board_build.encrypt = firmware.bin
board_build.offset = 0xC000
board_upload.offset_address = 0x0800C000
build_flags = ${stm32_variant.build_flags} -DHSE_VALUE=12000000U -O0
debug_tool = stlink
upload_protocol = stlink
extra_scripts = ${stm32_variant.extra_scripts}
buildroot/share/PlatformIO/scripts/openblt.py
build_flags = ${stm32_variant.build_flags} -DHSE_VALUE=12000000U -O0
debug_tool = stlink
upload_protocol = stlink
extra_scripts = ${stm32_variant.extra_scripts}
buildroot/share/PlatformIO/scripts/openblt.py

#
# BOARD_MKS_ROBIN_NANO_V1_3_F4
Expand Down

0 comments on commit fc76629

Please sign in to comment.