Skip to content

Commit a3dc540

Browse files
committed
mimxrt: Make linker scripts configurable.
Can simply add LD_FILES to a board's mpconfigboard.mk to change the linkerscripts, such as to change the section sizes, or change the contents for each region. Example usage: LD_FILES = $(BOARD_DIR)/my_board.ld boards/common.ld Signed-off-by: Dryw Wade <dryw.wade@sparkfun.com>
1 parent 4efc5e1 commit a3dc540

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

‎ports/mimxrt/Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ MCUX_SDK_DIR = lib/nxp_driver/sdk
5656
MCU_DIR = $(MCUX_SDK_DIR)/devices/$(MCU_SERIES)
5757

5858
# Select linker scripts based on MCU_SERIES
59-
LD_FILES = boards/$(MCU_SERIES).ld boards/common.ld
59+
LD_FILES ?= boards/$(MCU_SERIES).ld boards/common.ld
6060

6161
# Parameter configurations for generation
6262
AF_FILE = boards/$(MCU_SERIES)_af.csv
@@ -573,7 +573,7 @@ $(HEADER_BUILD)/qstrdefs.generated.h: $(BOARD_DIR)/mpconfigboard.h
573573
$(GEN_FLEXRAM_CONFIG_SRC): $(HEADER_BUILD)
574574
$(ECHO) "Create $@"
575575
$(Q)$(PYTHON) $(MAKE_FLEXRAM_LD) -d $(TOP)/$(MCU_DIR)/$(MCU_SERIES)$(MCU_CORE).h \
576-
-f $(TOP)/$(MCU_DIR)/$(MCU_SERIES)$(MCU_CORE)_features.h -l boards/$(MCU_SERIES).ld -c $(MCU_SERIES) > $@
576+
-f $(TOP)/$(MCU_DIR)/$(MCU_SERIES)$(MCU_CORE)_features.h $(addprefix -l,$(LD_FILES)) -c $(MCU_SERIES) > $@
577577

578578
# Use a pattern rule here so that make will only call make-pins.py once to make
579579
# both pins_gen.c and pins.h

‎ports/mimxrt/boards/make-flexram-config.py‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,14 @@
5555

5656

5757
# Value parser
58-
def mimxrt_default_parser(defines_file, features_file, ld_script):
59-
with open(ld_script, "r") as input_file:
60-
input_str = input_file.read()
58+
def mimxrt_default_parser(defines_file, features_file, ld_scripts):
59+
input_str = ""
60+
if ld_scripts is None:
61+
# Default linker script
62+
ld_scripts = ["boards/MIMXRT1021.ld"]
63+
for ld_script in ld_scripts:
64+
with open(ld_script, "r") as input_file:
65+
input_str += input_file.read()
6166
#
6267
ocram_match = re.search(ocram_regex, input_str, re.MULTILINE)
6368
dtcm_match = re.search(dtcm_regex, input_str, re.MULTILINE)
@@ -249,7 +254,9 @@ def main(defines_file, features_file, ld_script, controller):
249254
"--ld_file",
250255
dest="linker_file",
251256
help="Path to the aggregated linker-script",
252-
default="MIMXRT1021.ld",
257+
action="append",
258+
# Can't specify default here when using 'append' action, see
259+
# https://github.com/python/cpython/issues/60603
253260
)
254261
parser.add_argument(
255262
"-c", "--controller", dest="controller", help="Controller name", default="MIMXRT1021"

0 commit comments

Comments
 (0)