Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
OBJCOPY="arm-none-eabi-objcopy",
RANLIB="arm-none-eabi-gcc-ranlib",
SIZETOOL="arm-none-eabi-size",
SIZEPRINTCMD="$SIZETOOL -B -d $SOURCES"
SIZEPRINTCMD="$SIZETOOL -B -d $SOURCES",
TEENSYSECURE="teensy_secure"
)

env.Append(
Expand Down Expand Up @@ -127,6 +128,35 @@
)
)

if build_core == "teensy4":
# Get the key and default to an empty string
custom_secure_key = env.GetProjectOption("custom_secure_key", "")
if custom_secure_key:
encrypt_message = f"Encrypting $TARGET with key at {custom_secure_key}"
else:
encrypt_message = "Encrypting $TARGET with default key"

# Choose the correct board name for teensy_secure
if board_config.id == "teensymm":
board_name = "TEENSY_MICROMOD"
else:
board_name = board_config.id.upper()

env.Append(
BUILDERS=dict(
HexToEhex=Builder(
action=env.VerboseAction(" ".join([
"$TEENSYSECURE",
"encrypthex",
board_name,
"$SOURCES",
custom_secure_key
]), encrypt_message),
suffix=".ehex"
)
)
)

if not env.get("PIOFRAMEWORK"):
env.SConscript("frameworks/_bare_arm.py")

Expand Down Expand Up @@ -174,6 +204,8 @@ def teensy_check_upload_size(_, target, source, env):
else:
target_elf = env.BuildProgram()
target_firm = env.ElfToHex(join("$BUILD_DIR", "${PROGNAME}"), target_elf)
if build_core == "teensy4":
target_firm = env.HexToEhex(join("$BUILD_DIR", "${PROGNAME}"), target_firm)
env.Depends(target_firm, "checkprogsize")

AlwaysBuild(env.Alias("nobuild", target_firm))
Expand Down