🔨 Consolidate STM32 extra_scripts (#22365)

This commit is contained in:
Scott Lahteine
2021-07-14 19:44:51 -05:00
committed by Scott Lahteine
parent a5459a68a6
commit fef76a76a3
6 changed files with 50 additions and 104 deletions

View File

@ -10,7 +10,7 @@ Import("env")
env.AddPostAction(
join("$BUILD_DIR", "${PROGNAME}.elf"),
env.VerboseAction(" ".join([
"$OBJCOPY", "-O ihex", "$TARGET", # TARGET=.pio/build/fysetc_STM32F1/firmware.elf
"$OBJCOPY", "-O ihex", "$TARGET",
"\"" + join("$BUILD_DIR", "${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path
]), "Building $TARGET"))

View File

@ -1,29 +0,0 @@
#
# buildroot/share/PlatformIO/scripts/mks_encrypt.py
#
# Apply encryption and save as 'build.firmware' for these environments:
# - env:mks_robin
# - env:mks_robin_e3
# - env:flsun_hispeedv1
# - env:mks_robin_nano35
#
Import("env")
from SCons.Script import DefaultEnvironment
board = DefaultEnvironment().BoardConfig()
if 'encrypt' in board.get("build").keys():
import marlin
# Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt
def encrypt(source, target, env):
marlin.encrypt_mks(source, target, env, board.get("build.encrypt"))
marlin.add_post_action(encrypt);
else:
import sys
print("You need to define output file via board_build.encrypt = 'filename' parameter", file=sys.stderr)
env.Exit(1);

View File

@ -1,5 +1,5 @@
#
# stm32_bootloader.py
# offset_and_rename.py
#
# - If 'build.offset' is provided, either by JSON or by the environment...
# - Set linker flag LD_FLASH_OFFSET and relocate the VTAB based on 'build.offset'.
@ -36,6 +36,17 @@ if 'offset' in board_keys:
if "-Wl,--defsym=LD_MAX_DATA_SIZE" in flag:
env["LINKFLAGS"][i] = "-Wl,--defsym=LD_MAX_DATA_SIZE=" + str(maximum_ram_size - 40)
#
# For build.encrypt rename and encode the firmware file.
#
if 'encrypt' in board_keys:
# Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt
def encrypt(source, target, env):
marlin.encrypt_mks(source, target, env, board.get("build.encrypt"))
marlin.add_post_action(encrypt);
#
# For build.rename simply rename the firmware file.
#