boards/xtensa/esp32: Make board level linker script take precedence over

the common scripts.
This allows having a more costumized linker script per board.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
This commit is contained in:
Abdelatif Guettouche 2021-07-14 21:07:30 +02:00 committed by Alan Carvalho de Assis
parent 0aa35850fc
commit a6632f969a
6 changed files with 94 additions and 31 deletions

View File

@ -23,16 +23,38 @@ include $(TOPDIR)/tools/Config.mk
include $(TOPDIR)/tools/esp32/Config.mk include $(TOPDIR)/tools/esp32/Config.mk
include $(TOPDIR)/arch/xtensa/src/lx6/Toolchain.defs include $(TOPDIR)/arch/xtensa/src/lx6/Toolchain.defs
LDSCRIPT1 = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_out.ld # Pick the linker scripts from the board level if they exist, if not
LDSCRIPT2 = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32.ld # pick the common linker scripts.
LDSCRIPT3 = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32_rom.ld
ifneq ($(wildcard $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_rom.ld),)
LDSCRIPT_ROM = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_rom.ld
else
LDSCRIPT_ROM = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32_rom.ld
endif
ifneq ($(wildcard $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32.ld),)
LDSCRIPT_SECT = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32.ld
else
LDSCRIPT_SECT = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32.ld
endif
ifneq ($(wildcard $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32.template.ld),)
LDSCRIPT_TEMPLATE = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32.template.ld
else
LDSCRIPT_TEMPLATE = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32.template.ld
endif
# This is the generated memory layout linker script. It will always be
# generated at the board level.
LDSCRIPT_MEMORY = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_out.ld
ifeq ($(CONFIG_CYGWIN_WINTOOL),y) ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
ARCHSCRIPT = -T "${shell cygpath -w $(LDSCRIPT1)}" ARCHSCRIPT = -T "${shell cygpath -w $(LDSCRIPT_MEMORY)}"
ARCHSCRIPT += -T "${shell cygpath -w $(LDSCRIPT2)}" ARCHSCRIPT += -T "${shell cygpath -w $(LDSCRIPT_SECT)}"
ARCHSCRIPT += -T "${shell cygpath -w $(LDSCRIPT3)}" ARCHSCRIPT += -T "${shell cygpath -w $(LDSCRIPT_ROM)}"
else else
ARCHSCRIPT = -T$(LDSCRIPT1) -T$(LDSCRIPT2) -T$(LDSCRIPT3) ARCHSCRIPT = -T$(LDSCRIPT_MEMORY) -T$(LDSCRIPT_SECT) -T$(LDSCRIPT_ROM)
endif endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y) ifeq ($(CONFIG_DEBUG_SYMBOLS),y)

View File

@ -51,13 +51,12 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y)
CSRCS += esp32_buttons.c CSRCS += esp32_buttons.c
endif endif
SCRIPTIN = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32.template.ld
SCRIPTOUT = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_out.ld SCRIPTOUT = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_out.ld
.PHONY = context distclean .PHONY = context distclean
$(SCRIPTOUT): $(SCRIPTIN) $(CONFIGFILE) $(SCRIPTOUT): $(LDSCRIPT_TEMPLATE) $(CONFIGFILE)
$(Q) $(CC) -isystem $(TOPDIR)/include -C -P -x c -E $(SCRIPTIN) -o $@ $(Q) $(CC) -isystem $(TOPDIR)/include -C -P -x c -E $(LDSCRIPT_TEMPLATE) -o $@
context:: $(SCRIPTOUT) context:: $(SCRIPTOUT)

View File

@ -23,16 +23,38 @@ include $(TOPDIR)/tools/Config.mk
include $(TOPDIR)/tools/esp32/Config.mk include $(TOPDIR)/tools/esp32/Config.mk
include $(TOPDIR)/arch/xtensa/src/lx6/Toolchain.defs include $(TOPDIR)/arch/xtensa/src/lx6/Toolchain.defs
LDSCRIPT1 = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_out.ld # Pick the linker scripts from the board level if they exist, if not
LDSCRIPT2 = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32.ld # pick the common linker scripts.
LDSCRIPT3 = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32_rom.ld
ifneq ($(wildcard $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_rom.ld),)
LDSCRIPT_ROM = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_rom.ld
else
LDSCRIPT_ROM = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32_rom.ld
endif
ifneq ($(wildcard $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32.ld),)
LDSCRIPT_SECT = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32.ld
else
LDSCRIPT_SECT = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32.ld
endif
ifneq ($(wildcard $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32.template.ld),)
LDSCRIPT_TEMPLATE = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32.template.ld
else
LDSCRIPT_TEMPLATE = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32.template.ld
endif
# This is the generated memory layout linker script. It will always be
# generated at the board level.
LDSCRIPT_MEMORY = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_out.ld
ifeq ($(CONFIG_CYGWIN_WINTOOL),y) ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
ARCHSCRIPT = -T "${shell cygpath -w $(LDSCRIPT1)}" ARCHSCRIPT = -T "${shell cygpath -w $(LDSCRIPT_MEMORY)}"
ARCHSCRIPT += -T "${shell cygpath -w $(LDSCRIPT2)}" ARCHSCRIPT += -T "${shell cygpath -w $(LDSCRIPT_SECT)}"
ARCHSCRIPT += -T "${shell cygpath -w $(LDSCRIPT3)}" ARCHSCRIPT += -T "${shell cygpath -w $(LDSCRIPT_ROM)}"
else else
ARCHSCRIPT = -T$(LDSCRIPT1) -T$(LDSCRIPT2) -T$(LDSCRIPT3) ARCHSCRIPT = -T$(LDSCRIPT_MEMORY) -T$(LDSCRIPT_SECT) -T$(LDSCRIPT_ROM)
endif endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y) ifeq ($(CONFIG_DEBUG_SYMBOLS),y)

View File

@ -43,13 +43,12 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y)
CSRCS += esp32_buttons.c CSRCS += esp32_buttons.c
endif endif
SCRIPTIN = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32.template.ld
SCRIPTOUT = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_out.ld SCRIPTOUT = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_out.ld
.PHONY = context distclean .PHONY = context distclean
$(SCRIPTOUT): $(SCRIPTIN) $(CONFIGFILE) $(SCRIPTOUT): $(LDSCRIPT_TEMPLATE) $(CONFIGFILE)
$(Q) $(CC) -isystem $(TOPDIR)/include -C -P -x c -E $(SCRIPTIN) -o $@ $(Q) $(CC) -isystem $(TOPDIR)/include -C -P -x c -E $(LDSCRIPT_TEMPLATE) -o $@
context:: $(SCRIPTOUT) context:: $(SCRIPTOUT)

View File

@ -23,16 +23,38 @@ include $(TOPDIR)/tools/Config.mk
include $(TOPDIR)/tools/esp32/Config.mk include $(TOPDIR)/tools/esp32/Config.mk
include $(TOPDIR)/arch/xtensa/src/lx6/Toolchain.defs include $(TOPDIR)/arch/xtensa/src/lx6/Toolchain.defs
LDSCRIPT1 = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_out.ld # Pick the linker scripts from the board level if they exist, if not
LDSCRIPT2 = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32.ld # pick the common linker scripts.
LDSCRIPT3 = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32_rom.ld
ifneq ($(wildcard $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_rom.ld),)
LDSCRIPT_ROM = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_rom.ld
else
LDSCRIPT_ROM = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32_rom.ld
endif
ifneq ($(wildcard $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32.ld),)
LDSCRIPT_SECT = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32.ld
else
LDSCRIPT_SECT = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32.ld
endif
ifneq ($(wildcard $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32.template.ld),)
LDSCRIPT_TEMPLATE = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32.template.ld
else
LDSCRIPT_TEMPLATE = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32.template.ld
endif
# This is the generated memory layout linker script. It will always be
# generated at the board level.
LDSCRIPT_MEMORY = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_out.ld
ifeq ($(CONFIG_CYGWIN_WINTOOL),y) ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
ARCHSCRIPT = -T "${shell cygpath -w $(LDSCRIPT1)}" ARCHSCRIPT = -T "${shell cygpath -w $(LDSCRIPT_MEMORY)}"
ARCHSCRIPT += -T "${shell cygpath -w $(LDSCRIPT2)}" ARCHSCRIPT += -T "${shell cygpath -w $(LDSCRIPT_SECT)}"
ARCHSCRIPT += -T "${shell cygpath -w $(LDSCRIPT3)}" ARCHSCRIPT += -T "${shell cygpath -w $(LDSCRIPT_ROM)}"
else else
ARCHSCRIPT = -T$(LDSCRIPT1) -T$(LDSCRIPT2) -T$(LDSCRIPT3) ARCHSCRIPT = -T$(LDSCRIPT_MEMORY) -T$(LDSCRIPT_SECT) -T$(LDSCRIPT_ROM)
endif endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y) ifeq ($(CONFIG_DEBUG_SYMBOLS),y)

View File

@ -53,13 +53,12 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y)
CSRCS += esp32_buttons.c CSRCS += esp32_buttons.c
endif endif
SCRIPTIN = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32.template.ld SCRIPTOUT = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_out.ld
SCRIPTOUT = $(BOARD_DIR)$(DELIM)script$(DELIM)esp32_out.ld
.PHONY = context distclean .PHONY = context distclean
$(SCRIPTOUT): $(SCRIPTIN) $(CONFIGFILE) $(SCRIPTOUT): $(LDSCRIPT_TEMPLATE) $(CONFIGFILE)
$(Q) $(CC) -isystem $(TOPDIR)/include -C -P -x c -E $(SCRIPTIN) -o $@ $(Q) $(CC) -isystem $(TOPDIR)/include -C -P -x c -E $(LDSCRIPT_TEMPLATE) -o $@
context:: $(SCRIPTOUT) context:: $(SCRIPTOUT)