Skip to content

Commit c1a8c50

Browse files
committed
mimxrt: Make linker scripts configurable.
Can simply add LD_FILE_BOARD and/or LD_FILE_COMMON to a board's mpconfigboard.mk to change the linker scripts, such as to change the section sizes, or change the contents for each region. Example usage: LD_FILE_BOARD = $(BOARD_DIR)/my_board.ld LD_FILE_COMMON = $(BOARD_DIR)/my_common.ld Signed-off-by: Dryw Wade <[email protected]>
1 parent 4efc5e1 commit c1a8c50

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ports/mimxrt/Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ 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+
ifndef LD_FILE_COMMON
60+
LD_FILE_COMMON = boards/common.ld
61+
endif
62+
ifndef LD_FILE_BOARD
63+
LD_FILE_BOARD = boards/$(MCU_SERIES).ld
64+
endif
6065

6166
# Parameter configurations for generation
6267
AF_FILE = boards/$(MCU_SERIES)_af.csv
@@ -544,7 +549,7 @@ endif
544549
# aggregate output of preprocessor in a single linker script `link.ld`
545550
$(BUILD)/firmware.elf: $(OBJ)
546551
$(ECHO) "PREPROCESS LINK $@"
547-
$(Q)$(CC) -E -x c $(LDDEFINES) $(LD_FILES) | grep -v '^#' > $(BUILD)/link.ld
552+
$(Q)$(CC) -E -x c $(LDDEFINES) $(LD_FILE_BOARD) $(LD_FILE_COMMON) | grep -v '^#' > $(BUILD)/link.ld
548553
$(ECHO) "LINK $@"
549554
$(Q)$(LD) -T$(BUILD)/link.ld $(LDFLAGS) -o $@ $^ $(LIBS)
550555
$(Q)$(SIZE) $@
@@ -573,7 +578,7 @@ $(HEADER_BUILD)/qstrdefs.generated.h: $(BOARD_DIR)/mpconfigboard.h
573578
$(GEN_FLEXRAM_CONFIG_SRC): $(HEADER_BUILD)
574579
$(ECHO) "Create $@"
575580
$(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) > $@
581+
-f $(TOP)/$(MCU_DIR)/$(MCU_SERIES)$(MCU_CORE)_features.h -l $(LD_FILE_BOARD) -c $(MCU_SERIES) > $@
577582

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

0 commit comments

Comments
 (0)