Skip to content

Commit

Permalink
STM32F1 bootloader fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshLafleur committed Jan 31, 2025
1 parent 4aeabb4 commit 81447c1
Show file tree
Hide file tree
Showing 44 changed files with 219 additions and 503 deletions.
2 changes: 1 addition & 1 deletion components/bootloaders/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ from SCons.Script import Import, Return

Import("*")

artifacts = SConscript("STM/stm32f103/SConscript", exports=["CONFIG_IDS", "PLATFORM_ENV"])
artifacts = SConscript("STM/stm32f1/SConscript", exports=["CONFIG_IDS", "PLATFORM_ENV"])

Return('artifacts')
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ config:
defs:
can_debug:
erase_invalid_app:
flashable_bootloader:
5 changes: 5 additions & 0 deletions components/bootloaders/STM/stm32f1/FeatureSels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
featureDefs: "#/components/bootloaders/STM/stm32f1/FeatureDefs.yaml"
features:
feature_erase_invalid_app: false
feature_can_debug: false
mcu_stm32_use_hal: false
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ c_flags = [
"-Wshadow",
"-Wunused",
"-Wundef",
"-include", "BuildDefines.h", # Executed one after eachother
]

if not GetOption("release"):
Expand All @@ -81,6 +82,7 @@ link_flags = [
# "-Wl,--print-gc-sections",
"-Wl,--relax",
"-Wl,--print-memory-usage",
"-Icomponents/bootloaders/STM/stm32f1/include/HW/",
]

as_flags = [
Expand Down Expand Up @@ -126,7 +128,7 @@ env.Append(
ASFLAGS=as_flags,
CPPPATH=inc_paths,
CCFLAGS=c_flags,
LINKSCRIPT=File("STM32F103C8.ld"),
LINKSCRIPT=File("STM32F1.ld"),
LINKFLAGS=c_flags + link_flags,
)

Expand Down Expand Up @@ -195,9 +197,19 @@ for config_id, config in configs.items():
"_".join(config["description"].split(" ")) + f"_{config_id}"
)
generated_dir = variant_dir.Dir("generated")
config_env.Append(
LINKFLAGS=f"-I{generated_dir.abspath}",
)
makedirs(generated_dir.abspath, exist_ok=True)

features = {"features": config_env.GenerateFeatures(feature_selections_files, config["features"]["overrides"]) }
if features["features"]["defs"]["app_function_id"] == "function_id_bl":
try:
AddOption("--flashable-bootloader", dest="flashable-bootloader", action="store_true")
except Exception:
pass
if GetOption("flashable-bootloader"):
features["features"]["defs"]["feature_flashable_bootloader"] = True
generated_features = render_generated_files(features, renderers["featureDefs"], generated_dir)
generated = render_generated_files(config["options"], renderers["buildDefs"], generated_dir)

Expand All @@ -222,15 +234,6 @@ for config_id, config in configs.items():
for src in uds_srcs
]
)
if features["features"]["defs"]["app_function_id"] == "function_id_blu":
config_env["LINKSCRIPT"]=File("STM32F103C8-BLU.ld")
elif features["features"]["defs"]["app_function_id"] == "function_id_bl":
try:
AddOption("--flashable-bootloader", dest="flashable-bootloader", action="store_true")
except Exception:
pass
if GetOption("flashable-bootloader"):
config_env["LINKSCRIPT"]=File("STM32F103C8-BLFLASHABLE.ld")

# link all the compiled objects into an elf
elf, map = config_env.Program(
Expand Down
Loading

0 comments on commit 81447c1

Please sign in to comment.