diff --git a/src/modm/platform/core/stm32/idtcm.ld.in b/src/modm/platform/core/stm32/idtcm.ld.in index 8a8a9152c0..b133457e05 100644 --- a/src/modm/platform/core/stm32/idtcm.ld.in +++ b/src/modm/platform/core/stm32/idtcm.ld.in @@ -31,7 +31,11 @@ SECTIONS %% set dtcm_section = "DTCM" %% endif +%% if stack_in_dtcm {{ linker.section_stack(dtcm_section) }} +%% else +{{ linker.section_stack(cont_ram.cont_name|upper) }} +%% endif %% if "dtcm" in cont_ram.cont_name {{ linker.section_ram(cont_ram.cont_name|upper, "FLASH", table_copy, table_zero, diff --git a/src/modm/platform/core/stm32/module.lb b/src/modm/platform/core/stm32/module.lb index 93b376ffa6..8e0141b5c4 100644 --- a/src/modm/platform/core/stm32/module.lb +++ b/src/modm/platform/core/stm32/module.lb @@ -30,6 +30,15 @@ def prepare(module, options): default="rom") ) + if options[":target"].identifier.family == "h7": + module.add_option( + EnumerationOption( + name="main_stack_location", + description="SRAM (default) or DTCM (faster, but not DMA-capable)", + enumeration=["sram", "dtcm"], + default="sram") + ) + module.depends(":platform:cortex-m") return True @@ -100,5 +109,6 @@ def post_build(env): linkerscript = "dccm.ld.in" elif memory["name"] == "dtcm": # Executable ITCM and DTCM (Tightly-Coupled Memory) + env.substitutions["stack_in_dtcm"] = env.get(":platform:core:main_stack_location", "dtcm") == "dtcm" linkerscript = "idtcm.ld.in" env.template(linkerscript, "linkerscript.ld")