From a958e7f58e52d5d68e54194d636388a886c684d7 Mon Sep 17 00:00:00 2001 From: Petro Karashchenko Date: Thu, 10 Mar 2022 15:34:48 +0100 Subject: [PATCH] boards/arm/samv7: rework linker script usage logic to allow custom linker scripts Signed-off-by: Petro Karashchenko --- boards/arm/samv7/common/.gitignore | 1 - boards/arm/samv7/common/scripts/Make.defs | 62 ------------------- .../{flat-template.ld => flash.ld.template} | 2 +- boards/arm/samv7/common/scripts/flat.memory | 27 -------- .../arm/samv7/common/scripts/kernel-space.ld | 4 +- .../scripts/{memory.ld => memory.ld.template} | 49 ++++++++++++--- .../arm/samv7/common/scripts/protected.memory | 31 ---------- boards/arm/samv7/common/scripts/user-space.ld | 4 +- boards/arm/samv7/same70-qmtech/.gitignore | 2 + .../arm/samv7/same70-qmtech/kernel/Makefile | 8 ++- .../arm/samv7/same70-qmtech/scripts/Make.defs | 54 +++++++++++++++- boards/arm/samv7/same70-qmtech/src/Make.defs | 4 +- boards/arm/samv7/same70-xplained/.gitignore | 2 + .../arm/samv7/same70-xplained/kernel/Makefile | 8 ++- .../samv7/same70-xplained/scripts/Make.defs | 55 +++++++++++++++- .../arm/samv7/same70-xplained/src/Make.defs | 4 +- boards/arm/samv7/samv71-xult/.gitignore | 3 +- .../samv7/samv71-xult/configs/knsh/Make.defs | 60 +++++++++++++++++- boards/arm/samv7/samv71-xult/kernel/Makefile | 8 ++- .../arm/samv7/samv71-xult/scripts/Make.defs | 55 +++++++++++++++- boards/arm/samv7/samv71-xult/src/Make.defs | 4 +- 21 files changed, 291 insertions(+), 156 deletions(-) delete mode 100644 boards/arm/samv7/common/.gitignore delete mode 100644 boards/arm/samv7/common/scripts/Make.defs rename boards/arm/samv7/common/scripts/{flat-template.ld => flash.ld.template} (98%) delete mode 100644 boards/arm/samv7/common/scripts/flat.memory rename boards/arm/samv7/common/scripts/{memory.ld => memory.ld.template} (60%) delete mode 100644 boards/arm/samv7/common/scripts/protected.memory create mode 100644 boards/arm/samv7/same70-qmtech/.gitignore create mode 100644 boards/arm/samv7/same70-xplained/.gitignore diff --git a/boards/arm/samv7/common/.gitignore b/boards/arm/samv7/common/.gitignore deleted file mode 100644 index a5638cbefc..0000000000 --- a/boards/arm/samv7/common/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/scripts/samv7.ld diff --git a/boards/arm/samv7/common/scripts/Make.defs b/boards/arm/samv7/common/scripts/Make.defs deleted file mode 100644 index 6d9afc7628..0000000000 --- a/boards/arm/samv7/common/scripts/Make.defs +++ /dev/null @@ -1,62 +0,0 @@ -############################################################################ -# boards/arm/samv7/common/scripts/Make.defs -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. The -# ASF licenses this file to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance with the -# License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -############################################################################ - -ifneq ($(wildcard $(BOARD_DIR)$(DELIM)scripts$(DELIM)flat-template.ld),) - LDSCRIPT_TEMPLATE = $(BOARD_DIR)$(DELIM)scripts$(DELIM)flat-template.ld -else - LDSCRIPT_TEMPLATE = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)flat-template.ld -endif - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti -ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing -ARCHWARNINGSXX = -Wall -Wshadow -Wundef -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - -CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe -CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) -CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe -CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) -CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -AFLAGS := $(CFLAGS) -D__ASSEMBLY__ - -NXFLATLDFLAGS1 = -r -d -warn-common -NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections -LDNXFLATFLAGS = -e main -s 2048 - -# Loadable module definitions - -CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs - -LDMODULEFLAGS = -r -e module_initialize -LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) - -LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/samv7/common/scripts/flat-template.ld b/boards/arm/samv7/common/scripts/flash.ld.template similarity index 98% rename from boards/arm/samv7/common/scripts/flat-template.ld rename to boards/arm/samv7/common/scripts/flash.ld.template index 40ae9b041d..3f9fc22b72 100644 --- a/boards/arm/samv7/common/scripts/flat-template.ld +++ b/boards/arm/samv7/common/scripts/flash.ld.template @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/samv7/common/scripts/flat-template.ld + * boards/arm/samv7/common/scripts/flash.ld.template * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/boards/arm/samv7/common/scripts/flat.memory b/boards/arm/samv7/common/scripts/flat.memory deleted file mode 100644 index c11060875c..0000000000 --- a/boards/arm/samv7/common/scripts/flat.memory +++ /dev/null @@ -1,27 +0,0 @@ -############################################################################ -# boards/arm/samv7/common/scripts/flat.memory -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. The -# ASF licenses this file to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance with the -# License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -############################################################################ - -include $(TOPDIR)/.config -include $(TOPDIR)/tools/Config.mk -include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs - -ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)samv7.ld - -include $(BOARD_COMMON_DIR)/scripts/Make.defs diff --git a/boards/arm/samv7/common/scripts/kernel-space.ld b/boards/arm/samv7/common/scripts/kernel-space.ld index 03cea6dc81..6830bd512a 100644 --- a/boards/arm/samv7/common/scripts/kernel-space.ld +++ b/boards/arm/samv7/common/scripts/kernel-space.ld @@ -18,8 +18,8 @@ * ****************************************************************************/ -/* NOTE: This depends on the memory.ld script having been included prior to - * this script. +/* NOTE: This depends on the memory.ld.template script having been included + * prior to this script. */ OUTPUT_ARCH(arm) diff --git a/boards/arm/samv7/common/scripts/memory.ld b/boards/arm/samv7/common/scripts/memory.ld.template similarity index 60% rename from boards/arm/samv7/common/scripts/memory.ld rename to boards/arm/samv7/common/scripts/memory.ld.template index 92da7ecf0a..24c439aa3b 100644 --- a/boards/arm/samv7/common/scripts/memory.ld +++ b/boards/arm/samv7/common/scripts/memory.ld.template @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/samv7/common/scripts/memory.ld + * boards/arm/samv7/common/scripts/memory.ld.template * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -18,8 +18,37 @@ * ****************************************************************************/ +#include + +#define FLASH_START_ADDR 0x00400000 + +#ifdef CONFIG_ARMV7M_DTCM +# define SRAM_START_ADDR 0x20000000 +#else +# define SRAM_START_ADDR 0x20400000 +#endif + +#define KFLASH_START_ADDR FLASH_START_ADDR +#define KFLASH_SIZE (CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH / 2) + +#define UFLASH_START_ADDR (KFLASH_START_ADDR + KFLASH_SIZE) +#define UFLASH_SIZE (CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH - KFLASH_SIZE) + +#define KSRAM_START_ADDR SRAM_START_ADDR +#ifdef CONFIG_SAMV7_MEM_RAM_384 +# define KSRAM_SIZE (CONFIG_ARCH_CHIP_SAMV7_MEM_RAM / 3) +#else +# define KSRAM_SIZE (CONFIG_ARCH_CHIP_SAMV7_MEM_RAM / 2) +#endif + +#define USRAM_START_ADDR (KSRAM_START_ADDR + KSRAM_SIZE) +#define USRAM_SIZE ((CONFIG_ARCH_CHIP_SAMV7_MEM_RAM - KSRAM_SIZE) / 2) + +#define XSRAM_START_ADDR (USRAM_START_ADDR + USRAM_SIZE) +#define XSRAM_SIZE (CONFIG_ARCH_CHIP_SAMV7_MEM_RAM - KSRAM_SIZE - USRAM_SIZE) + /* The SAMV7 can have up to 2048Kb of FLASH beginning at address 0x0040:0000 - * and 384Kb of SRAM beginining at 0x2040:0000 + * and up to 384Kb of SRAM beginining at 0x2040:0000 or 0x2000:0000 * * When booting from FLASH, FLASH memory is aliased to address 0x0000:0000 * where the code expects to begin execution by jumping to the entry point in @@ -35,7 +64,7 @@ * span the user spaces, or (2) poke holes in a larger region to trim it * to fit better. * - * A detailed memory map for the 384KB SRAM region is as follows: + * A detailed memory map example for the 384KB SRAM region is as follows: * * 0x2040 0000: Kernel .data region. Typical size: 0.1KB * ------ ---- Kernel .bss region. Typical size: 1.8KB @@ -53,14 +82,14 @@ MEMORY { - /* 2048KiB of internal FLASH */ + /* Internal FLASH */ - kflash (rx) : ORIGIN = 0x00400000, LENGTH = 1M - uflash (rx) : ORIGIN = 0x00500000, LENGTH = 1M + kflash (rx) : ORIGIN = KFLASH_START_ADDR, LENGTH = KFLASH_SIZE + uflash (rx) : ORIGIN = UFLASH_START_ADDR, LENGTH = UFLASH_SIZE - /* 384Kb of internal SRAM */ + /* Internal SRAM */ - ksram (rwx) : ORIGIN = 0x20400000, LENGTH = 128K - usram (rwx) : ORIGIN = 0x20420000, LENGTH = 128K - xsram (rwx) : ORIGIN = 0x20440000, LENGTH = 128K + ksram (rwx) : ORIGIN = KSRAM_START_ADDR, LENGTH = KSRAM_SIZE + usram (rwx) : ORIGIN = USRAM_START_ADDR, LENGTH = USRAM_SIZE + xsram (rwx) : ORIGIN = XSRAM_START_ADDR, LENGTH = XSRAM_SIZE } diff --git a/boards/arm/samv7/common/scripts/protected.memory b/boards/arm/samv7/common/scripts/protected.memory deleted file mode 100644 index 33423ce419..0000000000 --- a/boards/arm/samv7/common/scripts/protected.memory +++ /dev/null @@ -1,31 +0,0 @@ -############################################################################ -# boards/arm/samv7/common/scripts/protected.memory -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. The -# ASF licenses this file to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance with the -# License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -############################################################################ - -include $(TOPDIR)/.config -include $(TOPDIR)/tools/Config.mk -include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs - -LDSCRIPT1 = memory.ld -LDSCRIPT2 = kernel-space.ld - -ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT1) -ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT2) - -include $(BOARD_COMMON_DIR)/scripts/Make.defs diff --git a/boards/arm/samv7/common/scripts/user-space.ld b/boards/arm/samv7/common/scripts/user-space.ld index 55c737f93d..f172c34b03 100644 --- a/boards/arm/samv7/common/scripts/user-space.ld +++ b/boards/arm/samv7/common/scripts/user-space.ld @@ -18,8 +18,8 @@ * ****************************************************************************/ -/* NOTE: This depends on the memory.ld script having been included prior to - * this script. +/* NOTE: This depends on the memory.ld.template script having been included + * prior to this script. */ /* Make sure that the critical memory management functions are in user-space. diff --git a/boards/arm/samv7/same70-qmtech/.gitignore b/boards/arm/samv7/same70-qmtech/.gitignore new file mode 100644 index 0000000000..3253984d7b --- /dev/null +++ b/boards/arm/samv7/same70-qmtech/.gitignore @@ -0,0 +1,2 @@ +/scripts/flash.ld +/scripts/memory.ld diff --git a/boards/arm/samv7/same70-qmtech/kernel/Makefile b/boards/arm/samv7/same70-qmtech/kernel/Makefile index d1811c380c..20e38f6714 100644 --- a/boards/arm/samv7/same70-qmtech/kernel/Makefile +++ b/boards/arm/samv7/same70-qmtech/kernel/Makefile @@ -29,8 +29,12 @@ ENTRYPT = $(patsubst "%",%,$(CONFIG_INIT_ENTRYPOINT)) # is appropriate for the host OS USER_LIBPATHS = $(addprefix -L,$(call CONVERT_PATH,$(addprefix $(TOPDIR)$(DELIM),$(dir $(USERLIBS))))) -USER_LDSCRIPT = -T $(call CONVERT_PATH,$(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)memory.ld) -USER_LDSCRIPT += -T $(call CONVERT_PATH,$(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)user-space.ld) +USER_LDSCRIPT = -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld) +ifneq ($(wildcard $(BOARD_DIR)$(DELIM)scripts$(DELIM)user-space.ld),) + USER_LDSCRIPT += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)user-space.ld) +else + USER_LDSCRIPT += -T $(call CONVERT_PATH,$(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)user-space.ld) +endif USER_HEXFILE += $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx_user.hex) USER_SRECFILE += $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx_user.srec) USER_BINFILE += $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx_user.bin) diff --git a/boards/arm/samv7/same70-qmtech/scripts/Make.defs b/boards/arm/samv7/same70-qmtech/scripts/Make.defs index 888c23f1de..6ad009013e 100644 --- a/boards/arm/samv7/same70-qmtech/scripts/Make.defs +++ b/boards/arm/samv7/same70-qmtech/scripts/Make.defs @@ -18,4 +18,56 @@ # ############################################################################ -include $(TOPDIR)/boards/arm/samv7/common/scripts/flat.memory +include $(TOPDIR)/.config +include $(TOPDIR)/tools/Config.mk +include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs + +SCRIPTOUT = $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash.ld + +ARCHSCRIPT += $(SCRIPTOUT) + +# Pick the linker scripts from the board level if they exist, if not +# pick the common linker scripts. + +ifneq ($(wildcard $(SCRIPTOUT).template),) + LDSCRIPT_TEMPLATE = $(SCRIPTOUT).template +else + LDSCRIPT_TEMPLATE = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)$(notdir $(SCRIPTOUT).template) +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + ARCHOPTIMIZATION = -g +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += $(MAXOPTIMIZATION) +endif + +ARCHCFLAGS = -fno-common +ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGSXX = -Wall -Wshadow -Wundef +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +AFLAGS := $(CFLAGS) -D__ASSEMBLY__ + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + +# Loadable module definitions + +CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs + +LDMODULEFLAGS = -r -e module_initialize +LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) + +LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g +endif diff --git a/boards/arm/samv7/same70-qmtech/src/Make.defs b/boards/arm/samv7/same70-qmtech/src/Make.defs index c232177830..ab266c088a 100644 --- a/boards/arm/samv7/same70-qmtech/src/Make.defs +++ b/boards/arm/samv7/same70-qmtech/src/Make.defs @@ -54,12 +54,10 @@ ifneq (,$(findstring y,$(CONFIG_SAMV7_DAC0) $(CONFIG_SAMV7_DAC1))) CSRCS += sam_dac.c endif -SCRIPTOUT = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)samv7.ld - .PHONY = context distclean $(SCRIPTOUT): $(LDSCRIPT_TEMPLATE) $(CONFIGFILE) - $(Q) $(CC) -isystem $(TOPDIR)/include -I $(BOARD_COMMON_DIR)$(DELIM)scripts -C -P -x c -E $(LDSCRIPT_TEMPLATE) -o $@ + $(Q) $(CC) -isystem $(TOPDIR)/include -I $(dir $(LDSCRIPT_TEMPLATE)) -C -P -x c -E $(LDSCRIPT_TEMPLATE) -o $@ context:: $(SCRIPTOUT) diff --git a/boards/arm/samv7/same70-xplained/.gitignore b/boards/arm/samv7/same70-xplained/.gitignore new file mode 100644 index 0000000000..3253984d7b --- /dev/null +++ b/boards/arm/samv7/same70-xplained/.gitignore @@ -0,0 +1,2 @@ +/scripts/flash.ld +/scripts/memory.ld diff --git a/boards/arm/samv7/same70-xplained/kernel/Makefile b/boards/arm/samv7/same70-xplained/kernel/Makefile index b372a18a8f..2f3cc45639 100644 --- a/boards/arm/samv7/same70-xplained/kernel/Makefile +++ b/boards/arm/samv7/same70-xplained/kernel/Makefile @@ -29,8 +29,12 @@ ENTRYPT = $(patsubst "%",%,$(CONFIG_INIT_ENTRYPOINT)) # is appropriate for the host OS USER_LIBPATHS = $(addprefix -L,$(call CONVERT_PATH,$(addprefix $(TOPDIR)$(DELIM),$(dir $(USERLIBS))))) -USER_LDSCRIPT = -T $(call CONVERT_PATH,$(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)memory.ld) -USER_LDSCRIPT += -T $(call CONVERT_PATH,$(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)user-space.ld) +USER_LDSCRIPT = -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld) +ifneq ($(wildcard $(BOARD_DIR)$(DELIM)scripts$(DELIM)user-space.ld),) + USER_LDSCRIPT += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)user-space.ld) +else + USER_LDSCRIPT += -T $(call CONVERT_PATH,$(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)user-space.ld) +endif USER_HEXFILE += $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx_user.hex) USER_SRECFILE += $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx_user.srec) USER_BINFILE += $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx_user.bin) diff --git a/boards/arm/samv7/same70-xplained/scripts/Make.defs b/boards/arm/samv7/same70-xplained/scripts/Make.defs index 288f75d23e..72768d7c3c 100644 --- a/boards/arm/samv7/same70-xplained/scripts/Make.defs +++ b/boards/arm/samv7/same70-xplained/scripts/Make.defs @@ -18,4 +18,57 @@ # ############################################################################ -include $(TOPDIR)/boards/arm/samv7/common/scripts/flat.memory +include $(TOPDIR)/.config +include $(TOPDIR)/tools/Config.mk +include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs + +SCRIPTOUT = $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash.ld + +ARCHSCRIPT += $(SCRIPTOUT) + +# Pick the linker scripts from the board level if they exist, if not +# pick the common linker scripts. + +ifneq ($(wildcard $(SCRIPTOUT).template),) + LDSCRIPT_TEMPLATE = $(SCRIPTOUT).template +else + LDSCRIPT_TEMPLATE = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)$(notdir $(SCRIPTOUT).template) +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + ARCHOPTIMIZATION = -g +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += $(MAXOPTIMIZATION) +endif + +ARCHCFLAGS = -fno-common +ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGSXX = -Wall -Wshadow -Wundef +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +AFLAGS := $(CFLAGS) -D__ASSEMBLY__ + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + +# Loadable module definitions + +CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs + +LDMODULEFLAGS = -r -e module_initialize +LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) + +LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g +endif + diff --git a/boards/arm/samv7/same70-xplained/src/Make.defs b/boards/arm/samv7/same70-xplained/src/Make.defs index c8005df261..5b086a1f16 100644 --- a/boards/arm/samv7/same70-xplained/src/Make.defs +++ b/boards/arm/samv7/same70-xplained/src/Make.defs @@ -90,12 +90,10 @@ ifeq ($(CONFIG_IEEE802154_XBEE),y) CSRCS += sam_xbee.c endif -SCRIPTOUT = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)samv7.ld - .PHONY = context distclean $(SCRIPTOUT): $(LDSCRIPT_TEMPLATE) $(CONFIGFILE) - $(Q) $(CC) -isystem $(TOPDIR)/include -I $(BOARD_COMMON_DIR)$(DELIM)scripts -C -P -x c -E $(LDSCRIPT_TEMPLATE) -o $@ + $(Q) $(CC) -isystem $(TOPDIR)/include -I $(dir $(LDSCRIPT_TEMPLATE)) -C -P -x c -E $(LDSCRIPT_TEMPLATE) -o $@ context:: $(SCRIPTOUT) diff --git a/boards/arm/samv7/samv71-xult/.gitignore b/boards/arm/samv7/samv71-xult/.gitignore index a5638cbefc..3253984d7b 100644 --- a/boards/arm/samv7/samv71-xult/.gitignore +++ b/boards/arm/samv7/samv71-xult/.gitignore @@ -1 +1,2 @@ -/scripts/samv7.ld +/scripts/flash.ld +/scripts/memory.ld diff --git a/boards/arm/samv7/samv71-xult/configs/knsh/Make.defs b/boards/arm/samv7/samv71-xult/configs/knsh/Make.defs index 615897da63..1a0ab92abb 100644 --- a/boards/arm/samv7/samv71-xult/configs/knsh/Make.defs +++ b/boards/arm/samv7/samv71-xult/configs/knsh/Make.defs @@ -18,4 +18,62 @@ # ############################################################################ -include $(TOPDIR)/boards/arm/samv7/common/scripts/protected.memory +include $(TOPDIR)/.config +include $(TOPDIR)/tools/Config.mk +include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs + +SCRIPTOUT = $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld + +ARCHSCRIPT += $(SCRIPTOUT) + +# Pick the linker scripts from the board level if they exist, if not +# pick the common linker scripts. + +ifneq ($(wildcard $(SCRIPTOUT).template),) + LDSCRIPT_TEMPLATE = $(SCRIPTOUT).template +else + LDSCRIPT_TEMPLATE = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)$(notdir $(SCRIPTOUT).template) +endif + +ifneq ($(wildcard $(BOARD_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld),) + ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld +else + ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + ARCHOPTIMIZATION = -g +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += $(MAXOPTIMIZATION) +endif + +ARCHCFLAGS = -fno-common +ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGSXX = -Wall -Wshadow -Wundef +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +AFLAGS := $(CFLAGS) -D__ASSEMBLY__ + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + +# Loadable module definitions + +CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs + +LDMODULEFLAGS = -r -e module_initialize +LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) + +LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g +endif diff --git a/boards/arm/samv7/samv71-xult/kernel/Makefile b/boards/arm/samv7/samv71-xult/kernel/Makefile index 5bb8394a5d..ef735c249f 100644 --- a/boards/arm/samv7/samv71-xult/kernel/Makefile +++ b/boards/arm/samv7/samv71-xult/kernel/Makefile @@ -29,8 +29,12 @@ ENTRYPT = $(patsubst "%",%,$(CONFIG_INIT_ENTRYPOINT)) # is appropriate for the host OS USER_LIBPATHS = $(addprefix -L,$(call CONVERT_PATH,$(addprefix $(TOPDIR)$(DELIM),$(dir $(USERLIBS))))) -USER_LDSCRIPT = -T $(call CONVERT_PATH,$(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)memory.ld) -USER_LDSCRIPT += -T $(call CONVERT_PATH,$(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)user-space.ld) +USER_LDSCRIPT = -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld) +ifneq ($(wildcard $(BOARD_DIR)$(DELIM)scripts$(DELIM)user-space.ld),) + USER_LDSCRIPT += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)user-space.ld) +else + USER_LDSCRIPT += -T $(call CONVERT_PATH,$(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)user-space.ld) +endif USER_HEXFILE += $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx_user.hex) USER_SRECFILE += $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx_user.srec) USER_BINFILE += $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx_user.bin) diff --git a/boards/arm/samv7/samv71-xult/scripts/Make.defs b/boards/arm/samv7/samv71-xult/scripts/Make.defs index 81ea817614..b3afb2060d 100644 --- a/boards/arm/samv7/samv71-xult/scripts/Make.defs +++ b/boards/arm/samv7/samv71-xult/scripts/Make.defs @@ -18,4 +18,57 @@ # ############################################################################ -include $(TOPDIR)/boards/arm/samv7/common/scripts/flat.memory +include $(TOPDIR)/.config +include $(TOPDIR)/tools/Config.mk +include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs + +SCRIPTOUT = $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash.ld + +ARCHSCRIPT += $(SCRIPTOUT) + +# Pick the linker scripts from the board level if they exist, if not +# pick the common linker scripts. + +ifneq ($(wildcard $(SCRIPTOUT).template),) + LDSCRIPT_TEMPLATE = $(SCRIPTOUT).template +else + LDSCRIPT_TEMPLATE = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)$(notdir $(SCRIPTOUT).template) +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + ARCHOPTIMIZATION = -g +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += $(MAXOPTIMIZATION) +endif + +ARCHCFLAGS = -fno-common +ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGSXX = -Wall -Wshadow -Wundef +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +AFLAGS := $(CFLAGS) -D__ASSEMBLY__ + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + +# Loadable module definitions + +CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs + +LDMODULEFLAGS = -r -e module_initialize +LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) + +LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g +endif + diff --git a/boards/arm/samv7/samv71-xult/src/Make.defs b/boards/arm/samv7/samv71-xult/src/Make.defs index f85b390e3a..7a790b000e 100644 --- a/boards/arm/samv7/samv71-xult/src/Make.defs +++ b/boards/arm/samv7/samv71-xult/src/Make.defs @@ -103,12 +103,10 @@ ifeq ($(CONFIG_LCD_ST7789),y) CSRCS += sam_st7789.c endif -SCRIPTOUT = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)samv7.ld - .PHONY = context distclean $(SCRIPTOUT): $(LDSCRIPT_TEMPLATE) $(CONFIGFILE) - $(Q) $(CC) -isystem $(TOPDIR)/include -I $(BOARD_COMMON_DIR)$(DELIM)scripts -C -P -x c -E $(LDSCRIPT_TEMPLATE) -o $@ + $(Q) $(CC) -isystem $(TOPDIR)/include -I $(dir $(LDSCRIPT_TEMPLATE)) -C -P -x c -E $(LDSCRIPT_TEMPLATE) -o $@ context:: $(SCRIPTOUT)