summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2021-01-07 11:26:54 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2021-01-07 11:26:54 +0100
commitcf79d8f57747cb41fa9756263fe14470197c5c86 (patch)
tree0cb86cbeb6399e0eea63c0f76a83aa5bbbc2c5aa
parentd4244f3d52f276337b44b0bab8c85094c985682f (diff)
build: Generate linker script.
-rw-r--r--SConscript3
-rw-r--r--build/scons_tools/tool_firmware.py2
-rw-r--r--build/scons_tools/tool_selectmcu.py4
-rw-r--r--ld_scripts/SConscript3
-rw-r--r--ld_scripts/generated.ld.j27
-rw-r--r--platforms/stm32/f4.yaml2
6 files changed, 17 insertions, 4 deletions
diff --git a/SConscript b/SConscript
index bc20764..8613407 100644
--- a/SConscript
+++ b/SConscript
@@ -1,6 +1,9 @@
# Don't call this file explicitly, it is called implicitly by the build rules.
Import('env')
+Export('env')
+
+env.SConscript('ld_scripts/SConscript')
env.Append(
LIB_SOURCES = Glob('*.cpp') + Glob('*/*.cpp'),
diff --git a/build/scons_tools/tool_firmware.py b/build/scons_tools/tool_firmware.py
index b1ead1f..c7e8f34 100644
--- a/build/scons_tools/tool_firmware.py
+++ b/build/scons_tools/tool_firmware.py
@@ -3,7 +3,7 @@ from SCons.Script import *
def Firmware(env, target, sources, **kwargs):
objects = [env.Object(f) for f in Flatten([sources, env['LIB_SOURCES']])]
firmware = env.Program(target, objects, **kwargs)
- #env.Depends(firmware, env['LINK_SCRIPT']) # TODO
+ env.Depends(firmware, '${LAKS_PATH}/ld_scripts/${LINK_SCRIPT}')
return firmware
def exists():
diff --git a/build/scons_tools/tool_selectmcu.py b/build/scons_tools/tool_selectmcu.py
index da4b38d..8d7029f 100644
--- a/build/scons_tools/tool_selectmcu.py
+++ b/build/scons_tools/tool_selectmcu.py
@@ -13,6 +13,8 @@ def SelectMCU(env, mcu, variant_dir = None):
)
env.Replace(
+ PLATFORM_SPEC = spec,
+
CC = '${TOOLCHAIN}gcc',
CXX = '${TOOLCHAIN}g++',
AS = '${TOOLCHAIN}gcc',
@@ -32,7 +34,7 @@ def SelectMCU(env, mcu, variant_dir = None):
)
env.Replace(
- LINK_SCRIPT = spec.get('ld_script'),
+ LINK_SCRIPT = 'generated.ld',
)
env.Append(
diff --git a/ld_scripts/SConscript b/ld_scripts/SConscript
new file mode 100644
index 0000000..da5c551
--- /dev/null
+++ b/ld_scripts/SConscript
@@ -0,0 +1,3 @@
+Import('env')
+
+env.Jinja2('generated.ld', 'generated.ld.j2', mem = env['PLATFORM_SPEC']['mem'])
diff --git a/ld_scripts/generated.ld.j2 b/ld_scripts/generated.ld.j2
new file mode 100644
index 0000000..40a198a
--- /dev/null
+++ b/ld_scripts/generated.ld.j2
@@ -0,0 +1,7 @@
+MEMORY {
+ {% for name, m in mem.items() %}
+ {{ name }} ({{ 'rx' if name == 'flash' else 'rwx' }}) : org = {{ m.origin }}, len = {{ m.size }}
+ {% endfor %}
+}
+
+INCLUDE "arm_flash_ram.ld"
diff --git a/platforms/stm32/f4.yaml b/platforms/stm32/f4.yaml
index 0d336ce..a2b28f7 100644
--- a/platforms/stm32/f4.yaml
+++ b/platforms/stm32/f4.yaml
@@ -4,7 +4,6 @@
flash:
origin: 0x08000000
size: 512k
- ld_script: stm32_f4_e.ld
- match:
mem: g
@@ -12,7 +11,6 @@
flash:
origin: 0x08000000
size: 1M
- ld_script: stm32_f4_g.ld
- mem:
ram: