You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2021/12/16 09:56:49 UTC

[incubator-nuttx] branch master updated (5df041c -> 24c0e8b)

This is an automated email from the ASF dual-hosted git repository.

acassis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from 5df041c  ioe-rpmsg: bind server to diffent ept struture
     new 2dd5578  arch/arm/src/samv7/Kconfig: Define mem sizes
     new 463fbfe  boards/arm/samv7: Unify linker scripts
     new b5868ae  boards/arm/samv7: Introduce common folder
     new a6fc887  boards/arm/samv7: Move MCUboot to common folder
     new 24c0e8b  boards/arm/samv7/samv71-xult: Add MCUboot support

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 arch/arm/src/samv7/Kconfig                         |  71 +++++-
 boards/Kconfig                                     |   3 +
 boards/arm/samv7/common/.gitignore                 |   1 +
 boards/arm/samv7/common/Kconfig                    |  84 +++++++
 .../samv7/{same70-qmtech/src => common}/Makefile   |  60 +----
 .../arm/samv7/common/include/sam_progmem_common.h  |  62 +++++
 .../{samv71-xult => common}/scripts/Make.defs      |  24 +-
 .../scripts/flat-template.ld}                      |  36 ++-
 boards/arm/samv7/common/scripts/flat.memory        |  31 +++
 .../{samv71-xult => common}/scripts/gnu-elf.ld     |   2 +-
 .../scripts/kernel-space.ld                        |   2 +-
 .../{samv71-xult => common}/scripts/memory.ld      |   6 +-
 boards/arm/samv7/common/scripts/protected.memory   |  36 +++
 .../{samv71-xult => common}/scripts/user-space.ld  |   2 +-
 .../src/Makefile => common/src/Make.defs}          |  58 +----
 .../{same70-qmtech => common}/src/sam_boot_image.c |   2 +-
 .../src/sam_progmem_common.c}                      |  77 +++---
 .../tools/atmel-same70-qmtech.cfg}                 |   1 -
 .../tools/atmel-same70-xplained.cfg}               |   0
 .../tools/atmel-samv71-xult.cfg}                   |   6 +-
 .../samv7/{same70-qmtech => common}/tools/oocd.sh  |   5 +-
 boards/arm/samv7/same70-qmtech/Kconfig             |  61 -----
 boards/arm/samv7/same70-qmtech/README.txt          |   5 +-
 .../configs/mcuboot-confirm/defconfig              |   5 +-
 .../configs/mcuboot-confirm/defconfig_debug        |  85 -------
 .../same70-qmtech/configs/mcuboot-loader/defconfig |   6 +-
 .../arm/samv7/same70-qmtech/configs/nsh/defconfig  |   2 +
 boards/arm/samv7/same70-qmtech/kernel/Makefile     |   8 +-
 boards/arm/samv7/same70-qmtech/scripts/Make.defs   |  66 +----
 .../scripts/flash-dtcm-mcuboot-app.ld              | 117 ---------
 .../scripts/flash-dtcm-mcuboot-loader.ld           | 117 ---------
 .../arm/samv7/same70-qmtech/scripts/flash-dtcm.ld  | 117 ---------
 .../scripts/flash-sram-mcuboot-loader.ld           | 114 ---------
 .../arm/samv7/same70-qmtech/scripts/flash-sram.ld  | 114 ---------
 boards/arm/samv7/same70-qmtech/scripts/gnu-elf.ld  | 115 ---------
 .../samv7/same70-qmtech/scripts/kernel-space.ld    | 106 --------
 boards/arm/samv7/same70-qmtech/scripts/memory.ld   |  66 -----
 .../arm/samv7/same70-qmtech/scripts/user-space.ld  | 111 ---------
 .../same70-qmtech/src/{Makefile => Make.defs}      |  23 +-
 boards/arm/samv7/same70-qmtech/src/sam_bringup.c   |   3 +-
 boards/arm/samv7/same70-xplained/Kconfig           |  61 -----
 boards/arm/samv7/same70-xplained/README.txt        |  13 +-
 .../samv7/same70-xplained/configs/adc/defconfig    |   2 +
 .../configs/mcuboot-confirm/defconfig              |   7 +-
 .../configs/mcuboot-loader/defconfig               |   8 +-
 .../configs/mrf24j40-starhub/defconfig             |   2 +
 .../samv7/same70-xplained/configs/netnsh/defconfig |   2 +
 .../samv7/same70-xplained/configs/nsh/defconfig    |   2 +
 .../samv7/same70-xplained/configs/twm4nx/defconfig |   2 +
 boards/arm/samv7/same70-xplained/kernel/Makefile   |   8 +-
 boards/arm/samv7/same70-xplained/scripts/Make.defs |  66 +----
 .../scripts/flash-dtcm-mcuboot-app.ld              | 117 ---------
 .../scripts/flash-dtcm-mcuboot-loader.ld           | 117 ---------
 .../samv7/same70-xplained/scripts/flash-dtcm.ld    | 117 ---------
 .../scripts/flash-sram-mcuboot-app.ld              | 114 ---------
 .../scripts/flash-sram-mcuboot-loader.ld           | 114 ---------
 .../samv7/same70-xplained/scripts/flash-sram.ld    | 114 ---------
 .../arm/samv7/same70-xplained/scripts/gnu-elf.ld   | 115 ---------
 .../samv7/same70-xplained/scripts/kernel-space.ld  | 106 --------
 boards/arm/samv7/same70-xplained/scripts/memory.ld |  66 -----
 .../samv7/same70-xplained/scripts/user-space.ld    | 111 ---------
 .../same70-xplained/src/{Makefile => Make.defs}    |  23 +-
 .../arm/samv7/same70-xplained/src/sam_boot_image.c | 186 --------------
 boards/arm/samv7/same70-xplained/src/sam_bringup.c |   3 +-
 boards/arm/samv7/same70-xplained/src/sam_progmem.c | 268 ---------------------
 .../tools/atmel_same70_xplained.cfg                |  13 -
 boards/arm/samv7/same70-xplained/tools/oocd.sh     |  57 -----
 boards/arm/samv7/samv71-xult/.gitignore            |   1 +
 boards/arm/samv7/samv71-xult/README.txt            |  80 ++++++
 .../arm/samv7/samv71-xult/configs/knsh/Make.defs   |  55 +----
 .../arm/samv7/samv71-xult/configs/knsh/defconfig   |   2 +
 .../configs/{module => mcuboot-loader}/defconfig   |  24 +-
 .../configs/{module => mcuboot-nsh}/defconfig      |  23 +-
 .../arm/samv7/samv71-xult/configs/module/defconfig |   2 +
 .../samv71-xult/configs/mrf24j40-starhub/defconfig |   2 +
 .../samv7/samv71-xult/configs/mxtxplnd/defconfig   |   2 +
 .../arm/samv7/samv71-xult/configs/netnsh/defconfig |   2 +
 boards/arm/samv7/samv71-xult/configs/nsh/defconfig |   2 +
 .../arm/samv7/samv71-xult/configs/nxwm/defconfig   |   2 +
 boards/arm/samv7/samv71-xult/configs/vnc/defconfig |   2 +
 .../arm/samv7/samv71-xult/configs/vnxwm/defconfig  |   2 +
 boards/arm/samv7/samv71-xult/kernel/Makefile       |   8 +-
 boards/arm/samv7/samv71-xult/scripts/Make.defs     |  56 +----
 boards/arm/samv7/samv71-xult/scripts/flash-dtcm.ld | 117 ---------
 boards/arm/samv7/samv71-xult/scripts/flash-sram.ld | 114 ---------
 .../samv7/samv71-xult/src/{Makefile => Make.defs}  |  16 +-
 boards/arm/samv7/samv71-xult/src/sam_bringup.c     |  39 +--
 87 files changed, 613 insertions(+), 3562 deletions(-)
 create mode 100644 boards/arm/samv7/common/.gitignore
 create mode 100644 boards/arm/samv7/common/Kconfig
 copy boards/arm/samv7/{same70-qmtech/src => common}/Makefile (51%)
 create mode 100644 boards/arm/samv7/common/include/sam_progmem_common.h
 copy boards/arm/samv7/{samv71-xult => common}/scripts/Make.defs (85%)
 rename boards/arm/samv7/{same70-qmtech/scripts/flash-sram-mcuboot-app.ld => common/scripts/flat-template.ld} (74%)
 create mode 100644 boards/arm/samv7/common/scripts/flat.memory
 rename boards/arm/samv7/{samv71-xult => common}/scripts/gnu-elf.ld (98%)
 rename boards/arm/samv7/{samv71-xult => common}/scripts/kernel-space.ld (98%)
 rename boards/arm/samv7/{samv71-xult => common}/scripts/memory.ld (94%)
 create mode 100644 boards/arm/samv7/common/scripts/protected.memory
 rename boards/arm/samv7/{samv71-xult => common}/scripts/user-space.ld (98%)
 copy boards/arm/samv7/{same70-qmtech/src/Makefile => common/src/Make.defs} (55%)
 rename boards/arm/samv7/{same70-qmtech => common}/src/sam_boot_image.c (98%)
 rename boards/arm/samv7/{same70-qmtech/src/sam_progmem.c => common/src/sam_progmem_common.c} (76%)
 rename boards/arm/samv7/{same70-qmtech/tools/atmel_same70_qmtech.cfg => common/tools/atmel-same70-qmtech.cfg} (99%)
 rename boards/arm/samv7/{same70-xplained/scripts/atmel_same70_xplained.cfg => common/tools/atmel-same70-xplained.cfg} (100%)
 rename boards/arm/samv7/{same70-qmtech/scripts/atmel_same70_qmtech.cfg => common/tools/atmel-samv71-xult.cfg} (56%)
 rename boards/arm/samv7/{same70-qmtech => common}/tools/oocd.sh (88%)
 delete mode 100644 boards/arm/samv7/same70-qmtech/configs/mcuboot-confirm/defconfig_debug
 delete mode 100644 boards/arm/samv7/same70-qmtech/scripts/flash-dtcm-mcuboot-app.ld
 delete mode 100644 boards/arm/samv7/same70-qmtech/scripts/flash-dtcm-mcuboot-loader.ld
 delete mode 100644 boards/arm/samv7/same70-qmtech/scripts/flash-dtcm.ld
 delete mode 100644 boards/arm/samv7/same70-qmtech/scripts/flash-sram-mcuboot-loader.ld
 delete mode 100644 boards/arm/samv7/same70-qmtech/scripts/flash-sram.ld
 delete mode 100644 boards/arm/samv7/same70-qmtech/scripts/gnu-elf.ld
 delete mode 100644 boards/arm/samv7/same70-qmtech/scripts/kernel-space.ld
 delete mode 100644 boards/arm/samv7/same70-qmtech/scripts/memory.ld
 delete mode 100644 boards/arm/samv7/same70-qmtech/scripts/user-space.ld
 rename boards/arm/samv7/same70-qmtech/src/{Makefile => Make.defs} (75%)
 delete mode 100644 boards/arm/samv7/same70-xplained/scripts/flash-dtcm-mcuboot-app.ld
 delete mode 100644 boards/arm/samv7/same70-xplained/scripts/flash-dtcm-mcuboot-loader.ld
 delete mode 100644 boards/arm/samv7/same70-xplained/scripts/flash-dtcm.ld
 delete mode 100644 boards/arm/samv7/same70-xplained/scripts/flash-sram-mcuboot-app.ld
 delete mode 100644 boards/arm/samv7/same70-xplained/scripts/flash-sram-mcuboot-loader.ld
 delete mode 100644 boards/arm/samv7/same70-xplained/scripts/flash-sram.ld
 delete mode 100644 boards/arm/samv7/same70-xplained/scripts/gnu-elf.ld
 delete mode 100644 boards/arm/samv7/same70-xplained/scripts/kernel-space.ld
 delete mode 100644 boards/arm/samv7/same70-xplained/scripts/memory.ld
 delete mode 100644 boards/arm/samv7/same70-xplained/scripts/user-space.ld
 rename boards/arm/samv7/same70-xplained/src/{Makefile => Make.defs} (80%)
 delete mode 100644 boards/arm/samv7/same70-xplained/src/sam_boot_image.c
 delete mode 100644 boards/arm/samv7/same70-xplained/src/sam_progmem.c
 delete mode 100644 boards/arm/samv7/same70-xplained/tools/atmel_same70_xplained.cfg
 delete mode 100755 boards/arm/samv7/same70-xplained/tools/oocd.sh
 create mode 100644 boards/arm/samv7/samv71-xult/.gitignore
 copy boards/arm/samv7/samv71-xult/configs/{module => mcuboot-loader}/defconfig (79%)
 copy boards/arm/samv7/samv71-xult/configs/{module => mcuboot-nsh}/defconfig (81%)
 delete mode 100644 boards/arm/samv7/samv71-xult/scripts/flash-dtcm.ld
 delete mode 100644 boards/arm/samv7/samv71-xult/scripts/flash-sram.ld
 rename boards/arm/samv7/samv71-xult/src/{Makefile => Make.defs} (83%)

[incubator-nuttx] 04/05: boards/arm/samv7: Move MCUboot to common folder

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit a6fc88740c4c5b7f7c17c14cf966988af9e46670
Author: Gerson Fernando Budke <na...@gmail.com>
AuthorDate: Sat Dec 4 11:51:12 2021 -0300

    boards/arm/samv7: Move MCUboot to common folder
    
    Move MCUboot bootloader implementation to samv7 common folder. This drop
    all duplicated code and unify implementation.
    
    Signed-off-by: Gerson Fernando Budke <na...@gmail.com>
---
 .../arm/samv7/common/include/sam_progmem_common.h  |  62 +++++
 boards/arm/samv7/common/src/Make.defs              |  10 +
 .../{same70-qmtech => common}/src/sam_boot_image.c |   2 +-
 .../src/sam_progmem_common.c}                      |  55 ++---
 boards/arm/samv7/same70-qmtech/README.txt          |   2 +-
 boards/arm/samv7/same70-qmtech/src/Make.defs       |   7 +-
 boards/arm/samv7/same70-qmtech/src/sam_bringup.c   |   3 +-
 boards/arm/samv7/same70-xplained/README.txt        |   2 +-
 boards/arm/samv7/same70-xplained/src/Make.defs     |   7 +-
 .../arm/samv7/same70-xplained/src/sam_boot_image.c | 186 --------------
 boards/arm/samv7/same70-xplained/src/sam_bringup.c |   3 +-
 boards/arm/samv7/same70-xplained/src/sam_progmem.c | 268 ---------------------
 12 files changed, 104 insertions(+), 503 deletions(-)

diff --git a/boards/arm/samv7/common/include/sam_progmem_common.h b/boards/arm/samv7/common/include/sam_progmem_common.h
new file mode 100644
index 0000000..04eedb0
--- /dev/null
+++ b/boards/arm/samv7/common/include/sam_progmem_common.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+ * boards/arm/samv7/common/include/sam_progmem_common.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __BOARDS_ARM_SAMV7_COMMON_INCLUDE_SAM_PROGMEM_COMMON_H
+#define __BOARDS_ARM_SAMV7_COMMON_INCLUDE_SAM_PROGMEM_COMMON_H
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Public Functions Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sam_progmem_init
+ *
+ * Description:
+ *   Initialize the FLASH and register MTD devices.
+ ****************************************************************************/
+
+int sam_progmem_common_initialize(void);
+
+#undef EXTERN
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __ASSEMBLY__ */
+#endif /* __BOARDS_ARM_SAMV7_COMMON_INCLUDE_SAM_PROGMEM_COMMON_H */
diff --git a/boards/arm/samv7/common/src/Make.defs b/boards/arm/samv7/common/src/Make.defs
index ea09c16..b192adb 100644
--- a/boards/arm/samv7/common/src/Make.defs
+++ b/boards/arm/samv7/common/src/Make.defs
@@ -18,6 +18,16 @@
 #
 #############################################################################
 
+ifeq ($(CONFIG_BOARDCTL_BOOT_IMAGE),y)
+CSRCS += sam_boot_image.c
+endif
+
+ifeq ($(CONFIG_BOARDCTL),y)
+CSRCS += sam_progmem_common.c
+else ifeq ($(CONFIG_BOARD_LATE_INITIALIZE),y)
+CSRCS += sam_progmem_common.c
+endif
+
 DEPPATH += --dep-path src
 VPATH += :src
 CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src)
diff --git a/boards/arm/samv7/same70-qmtech/src/sam_boot_image.c b/boards/arm/samv7/common/src/sam_boot_image.c
similarity index 98%
rename from boards/arm/samv7/same70-qmtech/src/sam_boot_image.c
rename to boards/arm/samv7/common/src/sam_boot_image.c
index 5f61e80..cb94ac0 100644
--- a/boards/arm/samv7/same70-qmtech/src/sam_boot_image.c
+++ b/boards/arm/samv7/common/src/sam_boot_image.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * boards/arm/samv7/same70-qmtech/src/sam_boot_image.c
+ * boards/arm/samv7/common/src/sam_boot_image.c
  *
  * 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/same70-qmtech/src/sam_progmem.c b/boards/arm/samv7/common/src/sam_progmem_common.c
similarity index 84%
rename from boards/arm/samv7/same70-qmtech/src/sam_progmem.c
rename to boards/arm/samv7/common/src/sam_progmem_common.c
index 6ff222e..0f8e50a 100644
--- a/boards/arm/samv7/same70-qmtech/src/sam_progmem.c
+++ b/boards/arm/samv7/common/src/sam_progmem_common.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * boards/arm/samv7/same70-qmtech/src/sam_progmem.c
+ * boards/arm/samv7/common/src/sam_progmem_common.c
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -40,41 +40,26 @@
 #endif
 
 #include "sam_progmem.h"
-#include "same70-qmtech.h"
-
-#ifdef HAVE_PROGMEM_CHARDEV
+#include "sam_progmem_common.h"
 
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
 
 #define ARRAYSIZE(x)                (sizeof((x)) / sizeof((x)[0]))
+#define PROGMEM_MTD_MINOR           0
 
 /****************************************************************************
  * Private Types
  ****************************************************************************/
 
-#if defined(CONFIG_SAMV7_PROGMEM_OTA_PARTITION)
-
-struct ota_partition_s
+struct mcuboot_partition_s
 {
   uint32_t    offset;          /* Partition offset from the beginning of MTD */
   uint32_t    size;            /* Partition size in bytes */
   const char *devpath;         /* Partition device path */
 };
 
-#endif
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
-
-#if defined(CONFIG_SAMV7_PROGMEM_OTA_PARTITION)
-static struct mtd_dev_s *sam_progmem_alloc_mtdpart(uint32_t mtd_offset,
-                                                   uint32_t mtd_size);
-static int init_ota_partitions(void);
-#endif
-
 /****************************************************************************
  * Private Data
  ****************************************************************************/
@@ -82,7 +67,7 @@ static int init_ota_partitions(void);
 static FAR struct mtd_dev_s *g_samv7_progmem_mtd;
 
 #if defined(CONFIG_SAMV7_PROGMEM_OTA_PARTITION)
-static const struct ota_partition_s g_ota_partition_table[] =
+static const struct mcuboot_partition_s g_mcuboot_partition_table[] =
 {
   {
     .offset  = CONFIG_SAMV7_OTA_PRIMARY_SLOT_OFFSET,
@@ -100,14 +85,11 @@ static const struct ota_partition_s g_ota_partition_table[] =
     .devpath = CONFIG_SAMV7_OTA_SCRATCH_DEVPATH
   }
 };
-#endif
 
 /****************************************************************************
  * Private Functions
  ****************************************************************************/
 
-#if defined(CONFIG_SAMV7_PROGMEM_OTA_PARTITION)
-
 /****************************************************************************
  * Name: sam_progmem_alloc_mtdpart
  *
@@ -149,10 +131,10 @@ static struct mtd_dev_s *sam_progmem_alloc_mtdpart(uint32_t mtd_offset,
 }
 
 /****************************************************************************
- * Name: init_ota_partitions
+ * Name: init_mcuboot_partitions
  *
  * Description:
- *   Initialize partitions that are dedicated to firmware OTA update.
+ *   Initialize partitions that are dedicated to firmware MCUBOOT update.
  *
  * Input Parameters:
  *   None.
@@ -162,7 +144,7 @@ static struct mtd_dev_s *sam_progmem_alloc_mtdpart(uint32_t mtd_offset,
  *
  ****************************************************************************/
 
-static int init_ota_partitions(void)
+static int init_mcuboot_partitions(void)
 {
   FAR struct mtd_dev_s *mtd;
 #ifdef CONFIG_BCH
@@ -170,11 +152,17 @@ static int init_ota_partitions(void)
 #endif
   int ret = OK;
 
-  for (int i = 0; i < ARRAYSIZE(g_ota_partition_table); ++i)
+  for (int i = 0; i < ARRAYSIZE(g_mcuboot_partition_table); ++i)
     {
-      const struct ota_partition_s *part = &g_ota_partition_table[i];
+      const struct mcuboot_partition_s *part = &g_mcuboot_partition_table[i];
       mtd = sam_progmem_alloc_mtdpart(part->offset, part->size);
 
+      if (!mtd)
+        {
+          ferr("ERROR: create MTD OTA partition %s", part->devpath);
+          continue;
+        }
+
       ret = ftl_initialize(i, mtd);
       if (ret < 0)
         {
@@ -196,7 +184,7 @@ static int init_ota_partitions(void)
 
   return ret;
 }
-#endif
+#endif /* CONFIG_SAMV7_PROGMEM_OTA_PARTITION */
 
 /****************************************************************************
  * Public Functions
@@ -209,15 +197,15 @@ static int init_ota_partitions(void)
  *   Initialize the FLASH and register the MTD device.
  ****************************************************************************/
 
-int sam_progmem_init(void)
+int sam_progmem_common_initialize(void)
 {
   int ret = OK;
 
-  /* Initialize the SAME70 FLASH programming memory library */
+  /* Initialize the SAMV7 FLASH programming memory library */
 
   sam_progmem_initialize();
 
-  /* Create an instance of the SAME70 FLASH program memory device driver */
+  /* Create an instance of the SAMV7 FLASH program memory device driver */
 
   g_samv7_progmem_mtd = progmem_initialize();
   if (g_samv7_progmem_mtd == NULL)
@@ -226,7 +214,7 @@ int sam_progmem_init(void)
     }
 
 #if defined(CONFIG_SAMV7_PROGMEM_OTA_PARTITION)
-  ret = init_ota_partitions();
+  ret = init_mcuboot_partitions();
   if (ret < 0)
     {
       return ret;
@@ -265,4 +253,3 @@ int sam_progmem_init(void)
 
   return ret;
 }
-#endif /* HAVE_PROGMEM_CHARDEV */
diff --git a/boards/arm/samv7/same70-qmtech/README.txt b/boards/arm/samv7/same70-qmtech/README.txt
index 427078d..76b33cd 100644
--- a/boards/arm/samv7/same70-qmtech/README.txt
+++ b/boards/arm/samv7/same70-qmtech/README.txt
@@ -814,5 +814,5 @@ Configuration sub-directories
       CONFIG_BOOT_MCUBOOT=y
       CONFIG_MCUBOOT_SLOT_CONFIRM_EXAMPLE=y
 
-      CONFIG_SAME70QMTECH_FORMAT_MCUBOOT=y
+      CONFIG_SAMV7_FORMAT_MCUBOOT=y
       CONFIG_USER_ENTRYPOINT="mcuboot_confirm_main"
diff --git a/boards/arm/samv7/same70-qmtech/src/Make.defs b/boards/arm/samv7/same70-qmtech/src/Make.defs
index 567a1c4..ffdc077 100644
--- a/boards/arm/samv7/same70-qmtech/src/Make.defs
+++ b/boards/arm/samv7/same70-qmtech/src/Make.defs
@@ -23,15 +23,12 @@ include $(TOPDIR)/Make.defs
 CSRCS = sam_boot.c
 
 ifeq ($(CONFIG_BOARDCTL),y)
-CSRCS += sam_appinit.c sam_bringup.c sam_progmem.c
+CSRCS += sam_appinit.c sam_bringup.c
 ifeq ($(CONFIG_BOARDCTL_RESET),y)
 CSRCS += sam_reset.c
 endif
-ifeq ($(CONFIG_BOARDCTL_BOOT_IMAGE),y)
-CSRCS += sam_boot_image.c
-endif
 else ifeq ($(CONFIG_BOARD_LATE_INITIALIZE),y)
-CSRCS += sam_bringup.c sam_progmem.c
+CSRCS += sam_bringup.c
 endif
 
 ifeq ($(CONFIG_ARCH_LEDS),y)
diff --git a/boards/arm/samv7/same70-qmtech/src/sam_bringup.c b/boards/arm/samv7/same70-qmtech/src/sam_bringup.c
index a4791fd..373ecfd 100644
--- a/boards/arm/samv7/same70-qmtech/src/sam_bringup.c
+++ b/boards/arm/samv7/same70-qmtech/src/sam_bringup.c
@@ -39,6 +39,7 @@
 #include <nuttx/i2c/i2c_master.h>
 
 #include "sam_twihs.h"
+#include "sam_progmem_common.h"
 #include "same70-qmtech.h"
 
 #ifdef HAVE_ROMFS
@@ -151,7 +152,7 @@ int sam_bringup(void)
 #ifdef HAVE_PROGMEM_CHARDEV
   /* Initialize the SAME70 FLASH programming memory library */
 
-  ret = sam_progmem_init();
+  ret = sam_progmem_common_initialize();
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to initialize progmem: %d\n", ret);
diff --git a/boards/arm/samv7/same70-xplained/README.txt b/boards/arm/samv7/same70-xplained/README.txt
index b7c6d77..cfda0dc 100644
--- a/boards/arm/samv7/same70-xplained/README.txt
+++ b/boards/arm/samv7/same70-xplained/README.txt
@@ -1736,5 +1736,5 @@ Configuration sub-directories
       CONFIG_BOOT_MCUBOOT=y
       CONFIG_MCUBOOT_SLOT_CONFIRM_EXAMPLE=y
 
-      CONFIG_SAME70XPLAINED_FORMAT_MCUBOOT=y
+      CONFIG_SAMV7_FORMAT_MCUBOOT=y
       CONFIG_USER_ENTRYPOINT="mcuboot_confirm_main"
diff --git a/boards/arm/samv7/same70-xplained/src/Make.defs b/boards/arm/samv7/same70-xplained/src/Make.defs
index 4c88925..87a4526 100644
--- a/boards/arm/samv7/same70-xplained/src/Make.defs
+++ b/boards/arm/samv7/same70-xplained/src/Make.defs
@@ -27,15 +27,12 @@ CSRCS += sam_sdram.c
 endif
 
 ifeq ($(CONFIG_BOARDCTL),y)
-CSRCS += sam_appinit.c sam_bringup.c sam_progmem.c
+CSRCS += sam_appinit.c sam_bringup.c
 ifeq ($(CONFIG_BOARDCTL_RESET),y)
 CSRCS += sam_reset.c
 endif
-ifeq ($(CONFIG_BOARDCTL_BOOT_IMAGE),y)
-CSRCS += sam_boot_image.c
-endif
 else ifeq ($(CONFIG_BOARD_LATE_INITIALIZE),y)
-CSRCS += sam_bringup.c sam_progmem.c
+CSRCS += sam_bringup.c
 endif
 
 ifeq ($(CONFIG_ARCH_LEDS),y)
diff --git a/boards/arm/samv7/same70-xplained/src/sam_boot_image.c b/boards/arm/samv7/same70-xplained/src/sam_boot_image.c
deleted file mode 100644
index 48c5390..0000000
--- a/boards/arm/samv7/same70-xplained/src/sam_boot_image.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/same70-xplained/src/sam_boot_image.c
- *
- * 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.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <debug.h>
-#include <stdio.h>
-#include <fcntl.h>
-
-#include <sys/boardctl.h>
-#include <nuttx/irq.h>
-#include <nuttx/cache.h>
-
-#include "nvic.h"
-#include "arm_arch.h"
-#include "barriers.h"
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/* This structure represents the first two entries on NVIC vector table */
-
-struct arm_vector_table
-{
-  uint32_t spr;   /* Stack pointer on reset */
-  uint32_t reset; /* Pointer to reset exception handler */
-};
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
-
-static void cleanup_arm_nvic(void);
-#ifdef CONFIG_ARMV7M_SYSTICK
-static void systick_disable(void);
-#endif
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name:  cleanup_arm_nvic
- *
- * Description:
- *   Acknowledge and disable all interrupts in NVIC
- *
- * Input Parameters:
- *   None
- *
- *  Returned Value:
- *    None
- *
- ****************************************************************************/
-
-static void cleanup_arm_nvic(void)
-{
-  int i;
-
-  /* Allow any pending interrupts to be recognized */
-
-  ARM_ISB();
-  cpsid();
-
-  /* Disable all interrupts */
-
-  for (i = 0; i < SAM_IRQ_NIRQS; i += 32)
-    {
-      putreg32(0xffffffff, NVIC_IRQ_CLEAR(i));
-    }
-
-  /* Clear all pending interrupts */
-
-  for (i = 0; i < SAM_IRQ_NIRQS; i += 32)
-    {
-      putreg32(0xffffffff, NVIC_IRQ_CLRPEND(i));
-    }
-}
-
-#ifdef CONFIG_ARMV7M_SYSTICK
-/****************************************************************************
- * Name:  systick_disable
- *
- * Description:
- *   Disable the SysTick system timer
- *
- * Input Parameters:
- *   None
- *
- *  Returned Value:
- *    None
- *
- ****************************************************************************/
-
-static void systick_disable(void)
-{
-  putreg32(0, NVIC_SYSTICK_CTRL);
-  putreg32(NVIC_SYSTICK_RELOAD_MASK, NVIC_SYSTICK_RELOAD);
-  putreg32(0, NVIC_SYSTICK_CURRENT);
-}
-#endif
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: board_boot_image
- *
- * Description:
- *   This entry point is called by bootloader to jump to application image.
- *
- ****************************************************************************/
-
-int board_boot_image(FAR const char *path, uint32_t hdr_size)
-{
-  static struct arm_vector_table vt;
-  int fd;
-  ssize_t bytes;
-
-  fd = open(path, O_RDONLY | O_CLOEXEC);
-  if (fd < 0)
-    {
-      syslog(LOG_ERR, "Failed to open %s with: %d", path, fd);
-      return fd;
-    }
-
-  bytes = pread(fd, &vt, sizeof(vt), hdr_size);
-  if (bytes != sizeof(vt))
-    {
-      syslog(LOG_ERR, "Failed to read ARM vector table: %d", bytes);
-      return bytes < 0 ? bytes : -1;
-    }
-
-#ifdef CONFIG_ARMV7M_SYSTICK
-  systick_disable();
-#endif
-
-  cleanup_arm_nvic();
-
-#ifdef CONFIG_ARMV7M_DCACHE
-  up_disable_dcache();
-#endif
-#ifdef CONFIG_ARMV7M_ICACHE
-  up_disable_icache();
-#endif
-
-#ifdef CONFIG_ARM_MPU
-  mpu_control(false, false, false);
-#endif
-
-  /* Set main and process stack pointers */
-
-  __asm__ __volatile__("\tmsr msp, %0\n" : : "r" (vt.spr));
-  setcontrol(0x00);
-  ARM_ISB();
-  ((void (*)(void))vt.reset)();
-
-  return 0;
-}
diff --git a/boards/arm/samv7/same70-xplained/src/sam_bringup.c b/boards/arm/samv7/same70-xplained/src/sam_bringup.c
index 51d15fb..1316367 100644
--- a/boards/arm/samv7/same70-xplained/src/sam_bringup.c
+++ b/boards/arm/samv7/same70-xplained/src/sam_bringup.c
@@ -43,6 +43,7 @@
 #include <nuttx/i2c/i2c_master.h>
 
 #include "sam_twihs.h"
+#include "sam_progmem_common.h"
 #include "same70-xplained.h"
 
 #ifdef HAVE_ROMFS
@@ -240,7 +241,7 @@ int sam_bringup(void)
 #ifdef HAVE_PROGMEM_CHARDEV
   /* Initialize the SAME70 FLASH programming memory library */
 
-  ret = sam_progmem_init();
+  ret = sam_progmem_common_initialize();
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: Failed to initialize progmem: %d\n", ret);
diff --git a/boards/arm/samv7/same70-xplained/src/sam_progmem.c b/boards/arm/samv7/same70-xplained/src/sam_progmem.c
deleted file mode 100644
index 390868f..0000000
--- a/boards/arm/samv7/same70-xplained/src/sam_progmem.c
+++ /dev/null
@@ -1,268 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/same70-xplained/src/sam_progmem.c
- *
- * 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.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <sys/mount.h>
-
-#include <stdbool.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <assert.h>
-#include <errno.h>
-#include <debug.h>
-
-#include <nuttx/kmalloc.h>
-#include <nuttx/mtd/mtd.h>
-#ifdef CONFIG_BCH
-#include <nuttx/drivers/drivers.h>
-#endif
-
-#include "sam_progmem.h"
-#include "same70-xplained.h"
-
-#ifdef HAVE_PROGMEM_CHARDEV
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define ARRAYSIZE(x)                (sizeof((x)) / sizeof((x)[0]))
-
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-#if defined(CONFIG_SAMV7_PROGMEM_OTA_PARTITION)
-
-struct ota_partition_s
-{
-  uint32_t    offset;          /* Partition offset from the beginning of MTD */
-  uint32_t    size;            /* Partition size in bytes */
-  const char *devpath;         /* Partition device path */
-};
-
-#endif
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
-
-#if defined(CONFIG_SAMV7_PROGMEM_OTA_PARTITION)
-static struct mtd_dev_s *sam_progmem_alloc_mtdpart(uint32_t mtd_offset,
-                                                   uint32_t mtd_size);
-static int init_ota_partitions(void);
-#endif
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-static FAR struct mtd_dev_s *g_samv7_progmem_mtd;
-
-#if defined(CONFIG_SAMV7_PROGMEM_OTA_PARTITION)
-static const struct ota_partition_s g_ota_partition_table[] =
-{
-  {
-    .offset  = CONFIG_SAMV7_OTA_PRIMARY_SLOT_OFFSET,
-    .size    = CONFIG_SAMV7_OTA_SLOT_SIZE,
-    .devpath = CONFIG_SAMV7_OTA_PRIMARY_SLOT_DEVPATH
-  },
-  {
-    .offset  = CONFIG_SAMV7_OTA_SECONDARY_SLOT_OFFSET,
-    .size    = CONFIG_SAMV7_OTA_SLOT_SIZE,
-    .devpath = CONFIG_SAMV7_OTA_SECONDARY_SLOT_DEVPATH
-  },
-  {
-    .offset  = CONFIG_SAMV7_OTA_SCRATCH_OFFSET,
-    .size    = CONFIG_SAMV7_OTA_SCRATCH_SIZE,
-    .devpath = CONFIG_SAMV7_OTA_SCRATCH_DEVPATH
-  }
-};
-#endif
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-#if defined(CONFIG_SAMV7_PROGMEM_OTA_PARTITION)
-
-/****************************************************************************
- * Name: sam_progmem_alloc_mtdpart
- *
- * Description:
- *   Allocate an MTD partition from FLASH.
- *
- * Input Parameters:
- *   mtd_offset - MTD Partition offset from the base address in FLASH.
- *   mtd_size   - Size for the MTD partition.
- *
- * Returned Value:
- *   MTD partition data pointer on success, NULL on failure.
- *
- ****************************************************************************/
-
-static struct mtd_dev_s *sam_progmem_alloc_mtdpart(uint32_t mtd_offset,
-                                                   uint32_t mtd_size)
-{
-  uint32_t blocks;
-  uint32_t startblock;
-
-  ASSERT((mtd_offset + mtd_size) <= up_progmem_neraseblocks() *
-          up_progmem_pagesize(0));
-  ASSERT((mtd_offset % up_progmem_pagesize(0)) == 0);
-  ASSERT((mtd_size % up_progmem_pagesize(0)) == 0);
-
-  finfo("\tMTD offset = 0x%"PRIx32"\n", mtd_offset);
-  finfo("\tMTD size = 0x%"PRIx32"\n", mtd_size);
-
-  startblock = up_progmem_getpage(mtd_offset);
-  if (startblock < 0)
-    {
-      return NULL;
-    }
-
-  blocks = mtd_size / up_progmem_pagesize(0);
-
-  return mtd_partition(g_samv7_progmem_mtd, startblock, blocks);
-}
-
-/****************************************************************************
- * Name: init_ota_partitions
- *
- * Description:
- *   Initialize partitions that are dedicated to firmware OTA update.
- *
- * Input Parameters:
- *   None.
- *
- * Returned Value:
- *   Zero on success; a negated errno value on failure.
- *
- ****************************************************************************/
-
-static int init_ota_partitions(void)
-{
-  FAR struct mtd_dev_s *mtd;
-#ifdef CONFIG_BCH
-  char blockdev[18];
-#endif
-  int ret = OK;
-
-  for (int i = 0; i < ARRAYSIZE(g_ota_partition_table); ++i)
-    {
-      const struct ota_partition_s *part = &g_ota_partition_table[i];
-      mtd = sam_progmem_alloc_mtdpart(part->offset, part->size);
-
-      ret = ftl_initialize(i, mtd);
-      if (ret < 0)
-        {
-          ferr("ERROR: Failed to initialize the FTL layer: %d\n", ret);
-          return ret;
-        }
-
-#ifdef CONFIG_BCH
-      snprintf(blockdev, 18, "/dev/mtdblock%d", i);
-
-      ret = bchdev_register(blockdev, part->devpath, false);
-      if (ret < 0)
-        {
-          ferr("ERROR: bchdev_register %s failed: %d\n", part->devpath, ret);
-          return ret;
-        }
-#endif
-    }
-
-  return ret;
-}
-#endif
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: sam_progmem_init
- *
- * Description:
- *   Initialize the FLASH and register the MTD device.
- ****************************************************************************/
-
-int sam_progmem_init(void)
-{
-  int ret = OK;
-
-  /* Initialize the SAME70 FLASH programming memory library */
-
-  sam_progmem_initialize();
-
-  /* Create an instance of the SAME70 FLASH program memory device driver */
-
-  g_samv7_progmem_mtd = progmem_initialize();
-  if (g_samv7_progmem_mtd == NULL)
-    {
-      return -EFAULT;
-    }
-
-#if defined(CONFIG_SAMV7_PROGMEM_OTA_PARTITION)
-  ret = init_ota_partitions();
-  if (ret < 0)
-    {
-      return ret;
-    }
-#else
-  /* Use the FTL layer to wrap the MTD driver as a block driver */
-
-  ret = ftl_initialize(PROGMEM_MTD_MINOR, g_samv7_progmem_mtd);
-  if (ret < 0)
-    {
-      syslog(LOG_ERR, "ERROR: Failed to initialize the FTL layer: %d\n",
-             ret);
-      return ret;
-    }
-
-#ifdef CONFIG_BCH
-  char blockdev[18];
-  char chardev[12];
-
-  /* Use the minor number to create device paths */
-
-  snprintf(blockdev, 18, "/dev/mtdblock%d", PROGMEM_MTD_MINOR);
-  snprintf(chardev, 12, "/dev/mtd%d", PROGMEM_MTD_MINOR);
-
-  /* Now create a character device on the block device */
-
-  ret = bchdev_register(blockdev, chardev, false);
-  if (ret < 0)
-    {
-      syslog(LOG_ERR, "ERROR: bchdev_register %s failed: %d\n",
-             chardev, ret);
-      return ret;
-    }
-#endif /* CONFIG_BCH */
-#endif
-
-  return ret;
-}
-#endif /* HAVE_PROGMEM_CHARDEV */

[incubator-nuttx] 05/05: boards/arm/samv7/samv71-xult: Add MCUboot support

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 24c0e8bc75115344d075dd400c8f82a4ccccc769
Author: Gerson Fernando Budke <na...@gmail.com>
AuthorDate: Sat Dec 4 11:51:51 2021 -0300

    boards/arm/samv7/samv71-xult: Add MCUboot support
    
    Refactor to use common sam_progmem implementation and enable MCUboot
    support.
    
    Signed-off-by: Gerson Fernando Budke <na...@gmail.com>
---
 boards/arm/samv7/samv71-xult/README.txt            | 80 ++++++++++++++++++++++
 .../samv71-xult/configs/mcuboot-loader/defconfig   | 62 +++++++++++++++++
 .../samv71-xult/configs/mcuboot-nsh/defconfig      | 63 +++++++++++++++++
 boards/arm/samv7/samv71-xult/src/sam_bringup.c     | 39 ++---------
 4 files changed, 210 insertions(+), 34 deletions(-)

diff --git a/boards/arm/samv7/samv71-xult/README.txt b/boards/arm/samv7/samv71-xult/README.txt
index d56cee6..891c46e 100644
--- a/boards/arm/samv7/samv71-xult/README.txt
+++ b/boards/arm/samv7/samv71-xult/README.txt
@@ -2572,3 +2572,83 @@ Configuration sub-directories
          probably means some kind of memory corruption.
 
        2017-01-30: knsh configuration does not yet run correctly.
+
+  mcuboot-loader:
+    This configuration exercises the port of MCUboot loader to NuttX.
+
+    In this configuration both primary, secondary and scratch partitions are
+    mapped into the internal flash.
+    Relevant configuration settings:
+
+      CONFIG_BOARD_LATE_INITIALIZE=y
+
+      CONFIG_BOOT_MCUBOOT=y
+      CONFIG_MCUBOOT_BOOTLOADER=y
+
+      CONFIG_SAMV7_FORMAT_MCUBOOT=y
+      CONFIG_USER_ENTRYPOINT="mcuboot_loader_main"
+
+      Flash bootloader using embedded debugger:
+      openocd -f interface/cmsis-dap.cfg \
+              -c 'transport select swd' \
+	      -c 'set CHIPNAME atsamv71q21' \
+	      -f target/atsamv.cfg \
+	      -c 'reset_config srst_only' \
+	      -c init -c targets \
+	      -c 'reset halt' \
+	      -c 'program nuttx.bin 0x400000' \
+	      -c 'reset halt' \
+	      -c 'atsamv gpnvm set 1' \
+	      -c 'reset run' -c shutdown
+
+  mcuboot-nsh:
+    This configuration exercises the MCUboot compatible application slot
+    example. The application is NuttX nsh with some special commands.
+
+    Generate signed binaries for MCUboot compatible application:
+
+      ./apps/boot/mcuboot/mcuboot/scripts/imgtool.py sign \
+        --key apps/boot/mcuboot/mcuboot/root-rsa-2048.pem --align 8 \
+        --version 1.0.0 --header-size 0x200 --pad-header --slot-size 0xe0000 \
+        nuttx/nuttx.bin mcuboot_nuttx.app.nsh.confirmed-v1.bin
+
+      ./apps/boot/mcuboot/mcuboot/scripts/imgtool.py sign \
+        --key apps/boot/mcuboot/mcuboot/root-rsa-2048.pem --align 8 \
+        --version 2.0.0 --header-size 0x200 --pad-header --slot-size 0xe0000 \
+        nuttx/nuttx.bin mcuboot_nuttx.app.nsh.confirmed-v2.bin
+
+      Flash application version 1.0.0 at MCUboot Slot-0:
+
+      openocd -f interface/cmsis-dap.cfg \
+              -c 'transport select swd' \
+	      -c 'set CHIPNAME atsamv71q21' \
+	      -f target/atsamv.cfg \
+	      -c 'reset_config srst_only' \
+	      -c init -c targets \
+	      -c 'reset halt' \
+	      -c 'program mcuboot_nuttx.app.nsh.confirmed-v1.bin 0x420000' \
+	      -c 'reset halt' \
+	      -c 'atsamv gpnvm set 1' \
+	      -c 'reset run' -c shutdown
+
+      Flash version 2.0.0 at MCUboot Slot-1:
+
+      openocd -f interface/cmsis-dap.cfg \
+              -c 'transport select swd' \
+	      -c 'set CHIPNAME atsamv71q21' \
+	      -f target/atsamv.cfg \
+	      -c 'reset_config srst_only' \
+	      -c init -c targets \
+	      -c 'reset halt' \
+	      -c 'program mcuboot_nuttx.app.nsh.confirmed-v2.bin 0x500000' \
+	      -c 'reset halt' \
+	      -c 'atsamv gpnvm set 1' \
+	      -c 'reset run' -c shutdown
+
+    Relevant configuration settings:
+
+      CONFIG_BOOT_MCUBOOT=y
+      CONFIG_MCUBOOT_SLOT_CONFIRM_EXAMPLE=y
+
+      CONFIG_SAMV7_FORMAT_MCUBOOT=y
+      CONFIG_USER_ENTRYPOINT="nsh_main"
diff --git a/boards/arm/samv7/samv71-xult/configs/mcuboot-loader/defconfig b/boards/arm/samv7/samv71-xult/configs/mcuboot-loader/defconfig
new file mode 100644
index 0000000..a668ad8
--- /dev/null
+++ b/boards/arm/samv7/samv71-xult/configs/mcuboot-loader/defconfig
@@ -0,0 +1,62 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed .config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that includes your
+# modifications.
+#
+# CONFIG_SAMV7_UART0 is not set
+# CONFIG_SAMV7_UART2 is not set
+# CONFIG_SAMV7_UART4 is not set
+CONFIG_ARCH="arm"
+CONFIG_ARCH_BOARD="samv71-xult"
+CONFIG_ARCH_BOARD_SAMV71_XULT=y
+CONFIG_ARCH_BUTTONS=y
+CONFIG_ARCH_CHIP="samv7"
+CONFIG_ARCH_CHIP_SAMV71=y
+CONFIG_ARCH_CHIP_SAMV71Q21=y
+CONFIG_ARCH_CHIP_SAMV71Q=y
+CONFIG_ARCH_CHIP_SAMV7=y
+CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x200000
+CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x60000
+CONFIG_ARCH_INTERRUPTSTACK=2048
+CONFIG_ARCH_IRQBUTTONS=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_ARMV7M_DCACHE=y
+CONFIG_ARMV7M_ICACHE=y
+CONFIG_ARMV7M_LAZYFPU=y
+CONFIG_BOARDCTL_RESET=y
+CONFIG_BOARD_LATE_INITIALIZE=y
+CONFIG_BOARD_LOOPSPERMSEC=51262
+CONFIG_BOOT_MCUBOOT=y
+CONFIG_BUILTIN=y
+CONFIG_FS_PROCFS=y
+CONFIG_MCUBOOT_BOOTLOADER=y
+CONFIG_NSH_ARCHINIT=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_LINELEN=64
+CONFIG_NSH_READLINE=y
+CONFIG_PREALLOC_TIMERS=4
+CONFIG_RAM_SIZE=393216
+CONFIG_RAM_START=0x20400000
+CONFIG_RAW_BINARY=y
+CONFIG_RR_INTERVAL=200
+CONFIG_SAMV7_FORMAT_MCUBOOT=y
+CONFIG_SAMV7_GPIOA_IRQ=y
+CONFIG_SAMV7_GPIOB_IRQ=y
+CONFIG_SAMV7_GPIOD_IRQ=y
+CONFIG_SAMV7_GPIO_IRQ=y
+CONFIG_SAMV7_SYSTEMRESET=y
+CONFIG_SAMV7_USART1=y
+CONFIG_SAMV7_XDMAC=y
+CONFIG_SCHED_HPWORK=y
+CONFIG_SCHED_WAITPID=y
+CONFIG_SDCLONE_DISABLE=y
+CONFIG_START_DAY=10
+CONFIG_START_MONTH=3
+CONFIG_START_YEAR=2014
+CONFIG_SYSTEM_NSH=y
+CONFIG_SYSTEM_RAMTEST=y
+CONFIG_USART1_SERIAL_CONSOLE=y
+CONFIG_USER_ENTRYPOINT="mcuboot_loader_main"
diff --git a/boards/arm/samv7/samv71-xult/configs/mcuboot-nsh/defconfig b/boards/arm/samv7/samv71-xult/configs/mcuboot-nsh/defconfig
new file mode 100644
index 0000000..eff9b0d
--- /dev/null
+++ b/boards/arm/samv7/samv71-xult/configs/mcuboot-nsh/defconfig
@@ -0,0 +1,63 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed .config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that includes your
+# modifications.
+#
+# CONFIG_SAMV7_UART0 is not set
+# CONFIG_SAMV7_UART2 is not set
+# CONFIG_SAMV7_UART4 is not set
+CONFIG_ARCH="arm"
+CONFIG_ARCH_BOARD="samv71-xult"
+CONFIG_ARCH_BOARD_SAMV71_XULT=y
+CONFIG_ARCH_BUTTONS=y
+CONFIG_ARCH_CHIP="samv7"
+CONFIG_ARCH_CHIP_SAMV71=y
+CONFIG_ARCH_CHIP_SAMV71Q21=y
+CONFIG_ARCH_CHIP_SAMV71Q=y
+CONFIG_ARCH_CHIP_SAMV7=y
+CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x200000
+CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x60000
+CONFIG_ARCH_INTERRUPTSTACK=2048
+CONFIG_ARCH_IRQBUTTONS=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_ARMV7M_DCACHE=y
+CONFIG_ARMV7M_ICACHE=y
+CONFIG_ARMV7M_LAZYFPU=y
+CONFIG_BOARDCTL_RESET=y
+CONFIG_BOARD_LATE_INITIALIZE=y
+CONFIG_BOARD_LOOPSPERMSEC=51262
+CONFIG_BOOT_MCUBOOT=y
+CONFIG_BUILTIN=y
+CONFIG_FS_PROCFS=y
+CONFIG_MCUBOOT_SLOT_CONFIRM_EXAMPLE=y
+CONFIG_NSH_ARCHINIT=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_LINELEN=64
+CONFIG_NSH_READLINE=y
+CONFIG_PREALLOC_TIMERS=4
+CONFIG_PTABLE_PARTITION=y
+CONFIG_RAM_SIZE=393216
+CONFIG_RAM_START=0x20400000
+CONFIG_RAW_BINARY=y
+CONFIG_RR_INTERVAL=200
+CONFIG_SAMV7_FORMAT_MCUBOOT=y
+CONFIG_SAMV7_GPIOA_IRQ=y
+CONFIG_SAMV7_GPIOB_IRQ=y
+CONFIG_SAMV7_GPIOD_IRQ=y
+CONFIG_SAMV7_GPIO_IRQ=y
+CONFIG_SAMV7_SYSTEMRESET=y
+CONFIG_SAMV7_USART1=y
+CONFIG_SAMV7_XDMAC=y
+CONFIG_SCHED_HPWORK=y
+CONFIG_SCHED_WAITPID=y
+CONFIG_SDCLONE_DISABLE=y
+CONFIG_START_DAY=10
+CONFIG_START_MONTH=3
+CONFIG_START_YEAR=2014
+CONFIG_SYSTEM_NSH=y
+CONFIG_SYSTEM_RAMTEST=y
+CONFIG_USART1_SERIAL_CONSOLE=y
+CONFIG_USER_ENTRYPOINT="nsh_main"
diff --git a/boards/arm/samv7/samv71-xult/src/sam_bringup.c b/boards/arm/samv7/samv71-xult/src/sam_bringup.c
index c59a7f3..d922e7c 100644
--- a/boards/arm/samv7/samv71-xult/src/sam_bringup.c
+++ b/boards/arm/samv7/samv71-xult/src/sam_bringup.c
@@ -62,6 +62,7 @@
 
 #ifdef HAVE_PROGMEM_CHARDEV
 #  include "sam_progmem.h"
+#  include "sam_progmem_common.h"
 #endif
 
 #if defined(HAVE_RTC_DSXXXX) || defined(HAVE_RTC_PCF85263)
@@ -165,13 +166,13 @@ int sam_bringup(void)
 #ifdef HAVE_S25FL1
   FAR struct qspi_dev_s *qspi;
 #endif
-#if defined(HAVE_S25FL1) || defined(HAVE_PROGMEM_CHARDEV)
+#if defined(HAVE_S25FL1)
   FAR struct mtd_dev_s *mtd;
 #endif
 #if defined(HAVE_RTC_DSXXXX) || defined(HAVE_RTC_PCF85263)
   FAR struct i2c_master_s *i2c;
 #endif
-#if defined(HAVE_S25FL1_CHARDEV) || defined(HAVE_PROGMEM_CHARDEV)
+#if defined(HAVE_S25FL1_CHARDEV)
 #if defined(CONFIG_BCH)
   char blockdev[18];
   char chardev[12];
@@ -440,42 +441,12 @@ int sam_bringup(void)
 #ifdef HAVE_PROGMEM_CHARDEV
   /* Initialize the SAMV71 FLASH programming memory library */
 
-  sam_progmem_initialize();
-
-  /* Create an instance of the SAMV71 FLASH program memory device driver */
-
-  mtd = progmem_initialize();
-  if (!mtd)
-    {
-      syslog(LOG_ERR, "ERROR: progmem_initialize failed\n");
-    }
-
-  /* Use the FTL layer to wrap the MTD driver as a block driver */
-
-  ret = ftl_initialize(PROGMEM_MTD_MINOR, mtd);
-  if (ret < 0)
-    {
-      syslog(LOG_ERR, "ERROR: Failed to initialize the FTL layer: %d\n",
-             ret);
-      return ret;
-    }
-
-#if defined(CONFIG_BCH)
-  /* Use the minor number to create device paths */
-
-  snprintf(blockdev, 18, "/dev/mtdblock%d", PROGMEM_MTD_MINOR);
-  snprintf(chardev, 12, "/dev/mtd%d", PROGMEM_MTD_MINOR);
-
-  /* Now create a character device on the block device */
-
-  ret = bchdev_register(blockdev, chardev, false);
+  ret = sam_progmem_common_initialize();
   if (ret < 0)
     {
-      syslog(LOG_ERR, "ERROR: bchdev_register %s failed: %d\n",
-             chardev, ret);
+      syslog(LOG_ERR, "ERROR: Failed to initialize progmem: %d\n", ret);
       return ret;
     }
-#endif /* defined(CONFIG_BCH) */
 #endif
 
 #ifdef HAVE_USBHOST

[incubator-nuttx] 03/05: boards/arm/samv7: Introduce common folder

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit b5868aed6ff1ae285fadb6cb3dc5f61f3d1ef0c9
Author: Gerson Fernando Budke <na...@gmail.com>
AuthorDate: Sat Dec 11 20:51:31 2021 -0300

    boards/arm/samv7: Introduce common folder
    
    This introduce common folder structre and rework scripts & tools
    files. The linker scripts were reorganized to use best the current
    infrastructure which uses a template to create a final samv7.ld
    file based in the current SoC memories and bootloader definitions.
    
    Signed-off-by: Gerson Fernando Budke <na...@gmail.com>
---
 boards/Kconfig                                     |   3 +
 .../samv7/{same70-xplained => common}/.gitignore   |   0
 boards/arm/samv7/common/Kconfig                    |  84 +++++++++++++
 boards/arm/samv7/common/Makefile                   |  33 ++++++
 .../{samv71-xult => common}/scripts/Make.defs      |  21 ++--
 .../scripts/flat-template.ld}                      |  12 +-
 boards/arm/samv7/common/scripts/flat.memory        |  31 +++++
 .../{samv71-xult => common}/scripts/gnu-elf.ld     |   2 +-
 .../scripts/kernel-space.ld                        |   2 +-
 .../{samv71-xult => common}/scripts/memory.ld      |   6 +-
 boards/arm/samv7/common/scripts/protected.memory   |  36 ++++++
 .../{samv71-xult => common}/scripts/user-space.ld  |   2 +-
 boards/arm/samv7/common/src/Make.defs              |  23 ++++
 .../tools/atmel-same70-qmtech.cfg}                 |   1 -
 .../tools/atmel-same70-xplained.cfg}               |   0
 .../tools/atmel-samv71-xult.cfg}                   |   6 +-
 .../samv7/{same70-qmtech => common}/tools/oocd.sh  |   5 +-
 boards/arm/samv7/same70-qmtech/.gitignore          |   1 -
 boards/arm/samv7/same70-qmtech/Kconfig             |  61 ----------
 boards/arm/samv7/same70-qmtech/README.txt          |   3 +-
 .../configs/mcuboot-confirm/defconfig              |   3 +-
 .../same70-qmtech/configs/mcuboot-loader/defconfig |   4 +-
 boards/arm/samv7/same70-qmtech/kernel/Makefile     |   8 +-
 boards/arm/samv7/same70-qmtech/scripts/Make.defs   |  53 +--------
 boards/arm/samv7/same70-qmtech/scripts/gnu-elf.ld  | 115 ------------------
 .../samv7/same70-qmtech/scripts/kernel-space.ld    | 106 -----------------
 boards/arm/samv7/same70-qmtech/scripts/memory.ld   |  66 -----------
 .../arm/samv7/same70-qmtech/scripts/user-space.ld  | 111 ------------------
 .../same70-qmtech/src/{Makefile => Make.defs}      |   8 +-
 boards/arm/samv7/same70-qmtech/src/sam_progmem.c   |  28 ++---
 boards/arm/samv7/same70-xplained/Kconfig           |  61 ----------
 boards/arm/samv7/same70-xplained/README.txt        |  11 +-
 .../configs/mcuboot-confirm/defconfig              |   4 +-
 .../configs/mcuboot-loader/defconfig               |   5 +-
 boards/arm/samv7/same70-xplained/kernel/Makefile   |   8 +-
 boards/arm/samv7/same70-xplained/scripts/Make.defs |  53 +--------
 .../same70-xplained/scripts/flash.template.ld      | 130 ---------------------
 .../arm/samv7/same70-xplained/scripts/gnu-elf.ld   | 115 ------------------
 .../samv7/same70-xplained/scripts/kernel-space.ld  | 106 -----------------
 boards/arm/samv7/same70-xplained/scripts/memory.ld |  66 -----------
 .../samv7/same70-xplained/scripts/user-space.ld    | 111 ------------------
 .../same70-xplained/src/{Makefile => Make.defs}    |   8 +-
 boards/arm/samv7/same70-xplained/src/sam_progmem.c |  28 ++---
 .../tools/atmel_same70_xplained.cfg                |  13 ---
 boards/arm/samv7/same70-xplained/tools/oocd.sh     |  57 ---------
 .../arm/samv7/samv71-xult/configs/knsh/Make.defs   |  55 +--------
 boards/arm/samv7/samv71-xult/kernel/Makefile       |   8 +-
 boards/arm/samv7/samv71-xult/scripts/Make.defs     |  53 +--------
 .../samv7/samv71-xult/scripts/flash.template.ld    | 119 -------------------
 .../samv7/samv71-xult/src/{Makefile => Make.defs}  |   8 +-
 50 files changed, 306 insertions(+), 1547 deletions(-)

diff --git a/boards/Kconfig b/boards/Kconfig
index ec86157..a4b10ff 100644
--- a/boards/Kconfig
+++ b/boards/Kconfig
@@ -3326,6 +3326,9 @@ endif
 
 comment "Board-Common Options"
 
+if ARCH_CHIP_SAMV7
+source "boards/arm/samv7/common/Kconfig"
+endif
 if ARCH_CHIP_STM32
 source "boards/arm/stm32/common/Kconfig"
 endif
diff --git a/boards/arm/samv7/same70-xplained/.gitignore b/boards/arm/samv7/common/.gitignore
similarity index 100%
rename from boards/arm/samv7/same70-xplained/.gitignore
rename to boards/arm/samv7/common/.gitignore
diff --git a/boards/arm/samv7/common/Kconfig b/boards/arm/samv7/common/Kconfig
new file mode 100644
index 0000000..fd23631
--- /dev/null
+++ b/boards/arm/samv7/common/Kconfig
@@ -0,0 +1,84 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfiglanguage.txt in the NuttX tools repository.
+#
+
+config BOARD_SAMV7_COMMON
+	bool "Board common logic"
+	default y
+	---help---
+		 Board common logic located in each board/common folder.
+
+if BOARD_SAMV7_COMMON
+
+config SAMV7_PROGMEM_OTA_PARTITION
+	bool
+	default n
+	select ARCH_RAMFUNCS
+	select BCH
+	select MTD
+	select MTD_BYTE_WRITE
+	select MTD_PARTITION
+	select MTD_PROGMEM
+	select MTD_PROGMEM_ERASESTATE
+	select SAMV7_PROGMEM
+	select SAMV7_PROGMEM_ERASESTATE
+
+config SAMV7_MCUBOOT_HEADER_SIZE
+	hex
+	default 0x200
+	depends on SAMV7_FORMAT_MCUBOOT
+
+menuconfig SAMV7_FORMAT_MCUBOOT
+	bool "MCUboot bootable format"
+	default n
+	select SAMV7_PROGMEM_OTA_PARTITION
+	---help---
+		 The MCUboot support of loading the firmware images.
+
+if SAMV7_FORMAT_MCUBOOT
+
+comment "MCUboot Application Image OTA Update support"
+
+config SAMV7_OTA_PRIMARY_SLOT_OFFSET
+	hex "MCUboot application image primary slot offset"
+	default 0x20000
+
+config SAMV7_OTA_PRIMARY_SLOT_DEVPATH
+	string "Application image primary slot device path"
+	default "/dev/ota0"
+
+config SAMV7_OTA_SECONDARY_SLOT_OFFSET
+	hex "MCUboot application image secondary slot offset"
+	default 0x48000  if SAMV7_MEM_FLASH_512
+	default 0x80000  if SAMV7_MEM_FLASH_1024
+	default 0x100000 if SAMV7_MEM_FLASH_2048
+
+config SAMV7_OTA_SECONDARY_SLOT_DEVPATH
+	string "Application image secondary slot device path"
+	default "/dev/ota1"
+
+config SAMV7_OTA_SLOT_SIZE
+	hex "MCUboot application image slot size (in bytes)"
+	default 0x28000  if SAMV7_MEM_FLASH_512
+	default 0x60000  if SAMV7_MEM_FLASH_1024
+	default 0xe0000  if SAMV7_MEM_FLASH_2048
+
+config SAMV7_OTA_SCRATCH_OFFSET
+	hex "MCUboot scratch partition offset"
+	default 0x70000  if SAMV7_MEM_FLASH_512
+	default 0xe0000  if SAMV7_MEM_FLASH_1024
+	default 0x1e0000 if SAMV7_MEM_FLASH_2048
+
+config SAMV7_OTA_SCRATCH_DEVPATH
+	string "Scratch partition device path"
+	default "/dev/otascratch"
+
+config SAMV7_OTA_SCRATCH_SIZE
+	hex "MCUboot scratch partition size (in bytes)"
+	default 0x10000  if SAMV7_MEM_FLASH_512
+	default 0x20000
+
+endif # SAMV7_FORMAT_MCUBOOT
+
+endif # BOARD_SAMV7_COMMON
diff --git a/boards/arm/samv7/common/Makefile b/boards/arm/samv7/common/Makefile
new file mode 100644
index 0000000..00ea9fc
--- /dev/null
+++ b/boards/arm/samv7/common/Makefile
@@ -0,0 +1,33 @@
+#############################################################################
+# boards/arm/samv7/common/Makefile
+#
+# 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)/Make.defs
+
+include board/Make.defs
+include src/Make.defs
+
+DEPPATH += --dep-path board
+DEPPATH += --dep-path src
+
+include $(TOPDIR)/boards/Board.mk
+
+ARCHSRCDIR = $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src
+BOARDDIR = $(ARCHSRCDIR)$(DELIM)board
+CFLAGS += $(shell $(INCDIR) "$(CC)" $(BOARDDIR)$(DELIM)include)
diff --git a/boards/arm/samv7/samv71-xult/scripts/Make.defs b/boards/arm/samv7/common/scripts/Make.defs
similarity index 85%
copy from boards/arm/samv7/samv71-xult/scripts/Make.defs
copy to boards/arm/samv7/common/scripts/Make.defs
index 2a008ad..f40b615 100644
--- a/boards/arm/samv7/samv71-xult/scripts/Make.defs
+++ b/boards/arm/samv7/common/scripts/Make.defs
@@ -1,5 +1,5 @@
 ############################################################################
-# boards/arm/samv7/samv71-xult/scripts/Make.defs
+# 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
@@ -18,17 +18,10 @@
 #
 ############################################################################
 
-include $(TOPDIR)/.config
-include $(TOPDIR)/tools/Config.mk
-include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs
-
-LDSCRIPT_TEMPLATE = $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash.template.ld
-LDSCRIPT = samv7.ld
-
-ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
-  ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
+ifneq ($(wildcard $(BOARD_DIR)$(DELIM)scripts$(DELIM)flat-template.ld),)
+  LDSCRIPT_TEMPLATE = $(BOARD_DIR)$(DELIM)scripts$(DELIM)flat-template.ld
 else
-  ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
+  LDSCRIPT_TEMPLATE = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)flat-template.ld
 endif
 
 ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
@@ -67,6 +60,12 @@ else
   LDMODULEFLAGS += -T $(TOPDIR)/libs/libc/modlib/gnu-elf.ld
 endif
 
+ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
+  LDFLAGS += -Map="${shell cygpath -w $(TOPDIR)/nuttx.map}" --cref
+else
+  LDFLAGS += -Map=$(TOPDIR)/nuttx.map --cref
+endif
+
 ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
   LDFLAGS += -g
 endif
diff --git a/boards/arm/samv7/same70-qmtech/scripts/flash.template.ld b/boards/arm/samv7/common/scripts/flat-template.ld
similarity index 89%
rename from boards/arm/samv7/same70-qmtech/scripts/flash.template.ld
rename to boards/arm/samv7/common/scripts/flat-template.ld
index f280071..40ae9b0 100644
--- a/boards/arm/samv7/same70-qmtech/scripts/flash.template.ld
+++ b/boards/arm/samv7/common/scripts/flat-template.ld
@@ -1,5 +1,5 @@
 /****************************************************************************
- * boards/arm/samv7/same70-qmtech/scripts/flash.template.ld
+ * boards/arm/samv7/common/scripts/flat-template.ld
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -28,14 +28,14 @@
 #  define SRAM_START_ADDR       0x20400000
 #endif
 
-#ifdef CONFIG_SAME70QMTECH_FORMAT_MCUBOOT
-#  define MCUBOOT_HEADER_SIZE   0x200
+#ifdef CONFIG_SAMV7_FORMAT_MCUBOOT
+#  define MCUBOOT_HEADER_SIZE   CONFIG_SAMV7_MCUBOOT_HEADER_SIZE
 #  ifdef CONFIG_BOARDCTL_BOOT_IMAGE
 #    define FLASH_OFFSET        0
-#    define FLASH_IMG_SIZE      CONFIG_SAME70QMTECH_OTA_PRIMARY_SLOT_OFFSET
+#    define FLASH_IMG_SIZE      CONFIG_SAMV7_OTA_PRIMARY_SLOT_OFFSET
 #  else
-#    define FLASH_OFFSET        (CONFIG_SAME70QMTECH_OTA_PRIMARY_SLOT_OFFSET + MCUBOOT_HEADER_SIZE)
-#    define FLASH_IMG_SIZE      (CONFIG_SAME70QMTECH_OTA_SLOT_SIZE - MCUBOOT_HEADER_SIZE)
+#    define FLASH_OFFSET        (CONFIG_SAMV7_OTA_PRIMARY_SLOT_OFFSET + MCUBOOT_HEADER_SIZE)
+#    define FLASH_IMG_SIZE      (CONFIG_SAMV7_OTA_SLOT_SIZE - MCUBOOT_HEADER_SIZE)
 #  endif
 #else
 #  define FLASH_OFFSET          0
diff --git a/boards/arm/samv7/common/scripts/flat.memory b/boards/arm/samv7/common/scripts/flat.memory
new file mode 100644
index 0000000..d3e428f
--- /dev/null
+++ b/boards/arm/samv7/common/scripts/flat.memory
@@ -0,0 +1,31 @@
+############################################################################
+# 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
+
+ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
+  ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)samv7.ld}"
+else
+  ARCHSCRIPT = -T$(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)samv7.ld
+endif
+
+include $(BOARD_COMMON_DIR)/scripts/Make.defs
diff --git a/boards/arm/samv7/samv71-xult/scripts/gnu-elf.ld b/boards/arm/samv7/common/scripts/gnu-elf.ld
similarity index 98%
rename from boards/arm/samv7/samv71-xult/scripts/gnu-elf.ld
rename to boards/arm/samv7/common/scripts/gnu-elf.ld
index d5ba8f5..bda1b92 100644
--- a/boards/arm/samv7/samv71-xult/scripts/gnu-elf.ld
+++ b/boards/arm/samv7/common/scripts/gnu-elf.ld
@@ -1,5 +1,5 @@
 /****************************************************************************
- * boards/arm/samv7/samv71-xult/scripts/gnu-elf.ld
+ * boards/arm/samv7/common/scripts/gnu-elf.ld
  *
  * 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/samv71-xult/scripts/kernel-space.ld b/boards/arm/samv7/common/scripts/kernel-space.ld
similarity index 98%
rename from boards/arm/samv7/samv71-xult/scripts/kernel-space.ld
rename to boards/arm/samv7/common/scripts/kernel-space.ld
index e5ffc00..03cea6d 100644
--- a/boards/arm/samv7/samv71-xult/scripts/kernel-space.ld
+++ b/boards/arm/samv7/common/scripts/kernel-space.ld
@@ -1,5 +1,5 @@
 /****************************************************************************
- * boards/arm/samv7/samv71-xult/scripts/kernel-space.ld
+ * boards/arm/samv7/common/scripts/kernel-space.ld
  *
  * 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/samv71-xult/scripts/memory.ld b/boards/arm/samv7/common/scripts/memory.ld
similarity index 94%
rename from boards/arm/samv7/samv71-xult/scripts/memory.ld
rename to boards/arm/samv7/common/scripts/memory.ld
index ae23b02..92da7ec 100644
--- a/boards/arm/samv7/samv71-xult/scripts/memory.ld
+++ b/boards/arm/samv7/common/scripts/memory.ld
@@ -1,5 +1,5 @@
 /****************************************************************************
- * boards/arm/samv7/samv71-xult/scripts/memory.ld
+ * boards/arm/samv7/common/scripts/memory.ld
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -18,8 +18,8 @@
  *
  ****************************************************************************/
 
-/* The SAMV71Q21 has 2048Kb of FLASH beginning at address 0x0040:0000 and
- * 384Kb of SRAM beginining at 0x2040:0000
+/* The SAMV7 can have up to 2048Kb of FLASH beginning at address 0x0040:0000
+ * and 384Kb of SRAM beginining at 0x2040: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
diff --git a/boards/arm/samv7/common/scripts/protected.memory b/boards/arm/samv7/common/scripts/protected.memory
new file mode 100644
index 0000000..4bc5df5
--- /dev/null
+++ b/boards/arm/samv7/common/scripts/protected.memory
@@ -0,0 +1,36 @@
+############################################################################
+# 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
+
+ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
+  ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT1)}"
+  ARCHSCRIPT += -T "${shell cygpath -w $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT2)}"
+else
+  ARCHSCRIPT = -T$(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT1)
+  ARCHSCRIPT += -T$(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT2)
+endif
+
+include $(BOARD_COMMON_DIR)/scripts/Make.defs
diff --git a/boards/arm/samv7/samv71-xult/scripts/user-space.ld b/boards/arm/samv7/common/scripts/user-space.ld
similarity index 98%
rename from boards/arm/samv7/samv71-xult/scripts/user-space.ld
rename to boards/arm/samv7/common/scripts/user-space.ld
index edd0150..55c737f 100644
--- a/boards/arm/samv7/samv71-xult/scripts/user-space.ld
+++ b/boards/arm/samv7/common/scripts/user-space.ld
@@ -1,5 +1,5 @@
 /****************************************************************************
- * boards/arm/samv7/samv71-xult/scripts/user-space.ld
+ * boards/arm/samv7/common/scripts/user-space.ld
  *
  * 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/src/Make.defs b/boards/arm/samv7/common/src/Make.defs
new file mode 100644
index 0000000..ea09c16
--- /dev/null
+++ b/boards/arm/samv7/common/src/Make.defs
@@ -0,0 +1,23 @@
+#############################################################################
+# boards/arm/samv7/common/src/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.
+#
+#############################################################################
+
+DEPPATH += --dep-path src
+VPATH += :src
+CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src)
diff --git a/boards/arm/samv7/same70-qmtech/tools/atmel_same70_qmtech.cfg b/boards/arm/samv7/common/tools/atmel-same70-qmtech.cfg
similarity index 99%
rename from boards/arm/samv7/same70-qmtech/tools/atmel_same70_qmtech.cfg
rename to boards/arm/samv7/common/tools/atmel-same70-qmtech.cfg
index db63edd..4c2cbfb 100644
--- a/boards/arm/samv7/same70-qmtech/tools/atmel_same70_qmtech.cfg
+++ b/boards/arm/samv7/common/tools/atmel-same70-qmtech.cfg
@@ -3,7 +3,6 @@
 # https://github.com/ChinaQMTECH/ATSAMS70_E70
 #
 # Connect using the EDBG chip on the dev kit over USB
-
 source [find interface/cmsis-dap.cfg]
 
 set CHIPNAME atsame70n19
diff --git a/boards/arm/samv7/same70-xplained/scripts/atmel_same70_xplained.cfg b/boards/arm/samv7/common/tools/atmel-same70-xplained.cfg
similarity index 100%
rename from boards/arm/samv7/same70-xplained/scripts/atmel_same70_xplained.cfg
rename to boards/arm/samv7/common/tools/atmel-same70-xplained.cfg
diff --git a/boards/arm/samv7/same70-qmtech/scripts/atmel_same70_qmtech.cfg b/boards/arm/samv7/common/tools/atmel-samv71-xult.cfg
similarity index 56%
rename from boards/arm/samv7/same70-qmtech/scripts/atmel_same70_qmtech.cfg
rename to boards/arm/samv7/common/tools/atmel-samv71-xult.cfg
index e986e6b..ca34007 100644
--- a/boards/arm/samv7/same70-qmtech/scripts/atmel_same70_qmtech.cfg
+++ b/boards/arm/samv7/common/tools/atmel-samv71-xult.cfg
@@ -1,11 +1,11 @@
 #
-# Atmel SAME70 QMTECH board.
-# https://github.com/ChinaQMTECH/ATSAMS70_E70
+# Atmel SAMV71 Xplained Ultra evaluation kit.
+# http://www.atmel.com/tools/ATSAMV71-XULT.aspx
 #
 # Connect using the EDBG chip on the dev kit over USB
 source [find interface/cmsis-dap.cfg]
 
-set CHIPNAME atsame70n19
+set CHIPNAME atsamv71q21
 
 source [find target/atsamv.cfg]
 
diff --git a/boards/arm/samv7/same70-qmtech/tools/oocd.sh b/boards/arm/samv7/common/tools/oocd.sh
similarity index 88%
rename from boards/arm/samv7/same70-qmtech/tools/oocd.sh
rename to boards/arm/samv7/common/tools/oocd.sh
index 6147ec9..1199cd5 100755
--- a/boards/arm/samv7/same70-qmtech/tools/oocd.sh
+++ b/boards/arm/samv7/common/tools/oocd.sh
@@ -1,7 +1,6 @@
 #!/usr/bin/env bash
 #
-# See boards/atmel_same70_qmtech.cfg/README.txt for information about
-# this file.
+# See boards README.txt for information about this file.
 
 TOPDIR=$1
 USAGE="$0 <TOPDIR> [-d]"
@@ -28,7 +27,7 @@ TARGET_PATH="/usr/local/share/openocd/scripts"
 #OPENOCD_EXE=openocd.exe
 OPENOCD_EXE=openocd
 
-OPENOCD_CFG="${TOPDIR}/boards/arm/samv7/same70-qmtech/tools/atmel_same70_qmtech.cfg"
+OPENOCD_CFG="${TOPDIR}/boards/arm/samv7/common/tools/atmel-${TARGET_BOARD}.cfg"
 OPENOCD_ARGS="-f ${OPENOCD_CFG} -s ${TARGET_PATH}"
 
 if [ "X$2" = "X-d" ]; then
diff --git a/boards/arm/samv7/same70-qmtech/.gitignore b/boards/arm/samv7/same70-qmtech/.gitignore
deleted file mode 100644
index a5638cb..0000000
--- a/boards/arm/samv7/same70-qmtech/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/scripts/samv7.ld
diff --git a/boards/arm/samv7/same70-qmtech/Kconfig b/boards/arm/samv7/same70-qmtech/Kconfig
index 0c665f6..039ea47 100644
--- a/boards/arm/samv7/same70-qmtech/Kconfig
+++ b/boards/arm/samv7/same70-qmtech/Kconfig
@@ -34,65 +34,4 @@ config SAME70QMTECH_HSMCI0_AUTOMOUNT_UDELAY
 
 endif # SAME70QMTECH_HSMCI0_AUTOMOUNT
 
-config SAME70QMTECH_PROGMEM_OTA_PARTITION
-	bool
-	default n
-	select MTD
-	select MTD_BYTE_WRITE
-	select MTD_PARTITION
-	select MTD_PROGMEM
-	select MTD_PROGMEM_ERASESTATE
-
-menuconfig SAME70QMTECH_FORMAT_MCUBOOT
-	bool "MCUboot-bootable format"
-	default n
-	select SAME70QMTECH_PROGMEM_OTA_PARTITION
-	---help---
-		The MCUboot support of loading the firmware images.
-
-if SAME70QMTECH_FORMAT_MCUBOOT
-
-config SAME70QMTECH_MCUBOOT_BOOTLOADER
-	bool "MCUboot bootloader application"
-	default n
-	---help---
-		This switch between linker scripts to allow an application be
-		built to another entry point address.
-
-comment "MCUboot Application Image OTA Update support"
-
-config SAME70QMTECH_OTA_PRIMARY_SLOT_OFFSET
-	hex "MCUboot application image primary slot offset"
-	default "0x20000"
-
-config SAME70QMTECH_OTA_PRIMARY_SLOT_DEVPATH
-	string "Application image primary slot device path"
-	default "/dev/ota0"
-
-config SAME70QMTECH_OTA_SECONDARY_SLOT_OFFSET
-	hex "MCUboot application image secondary slot offset"
-	default "0x48000"
-
-config SAME70QMTECH_OTA_SECONDARY_SLOT_DEVPATH
-	string "Application image secondary slot device path"
-	default "/dev/ota1"
-
-config SAME70QMTECH_OTA_SLOT_SIZE
-	hex "MCUboot application image slot size (in bytes)"
-	default "0x28000"
-
-config SAME70QMTECH_OTA_SCRATCH_OFFSET
-	hex "MCUboot scratch partition offset"
-	default "0x70000"
-
-config SAME70QMTECH_OTA_SCRATCH_DEVPATH
-	string "Scratch partition device path"
-	default "/dev/otascratch"
-
-config SAME70QMTECH_OTA_SCRATCH_SIZE
-	hex "MCUboot scratch partition size (in bytes)"
-	default "0x10000"
-
-endif # SAME70QMTECH_FORMAT_MCUBOOT
-
 endif # ARCH_BOARD_SAME70_QMTECH
diff --git a/boards/arm/samv7/same70-qmtech/README.txt b/boards/arm/samv7/same70-qmtech/README.txt
index 294f7ca..427078d 100644
--- a/boards/arm/samv7/same70-qmtech/README.txt
+++ b/boards/arm/samv7/same70-qmtech/README.txt
@@ -794,8 +794,7 @@ Configuration sub-directories
       CONFIG_MCUBOOT_BOOTLOADER=y
       CONFIG_MCUBOOT_ENABLE_LOGGING=y
 
-      CONFIG_SAME70QMTECH_FORMAT_MCUBOOT=y
-      CONFIG_SAME70QMTECH_MCUBOOT_BOOTLOADER=y
+      CONFIG_SAMV7_FORMAT_MCUBOOT=y
       CONFIG_USER_ENTRYPOINT="mcuboot_loader_main"
 
   mcuboot-confirm:
diff --git a/boards/arm/samv7/same70-qmtech/configs/mcuboot-confirm/defconfig b/boards/arm/samv7/same70-qmtech/configs/mcuboot-confirm/defconfig
index d27f7b5..0b848a6 100644
--- a/boards/arm/samv7/same70-qmtech/configs/mcuboot-confirm/defconfig
+++ b/boards/arm/samv7/same70-qmtech/configs/mcuboot-confirm/defconfig
@@ -45,12 +45,11 @@ CONFIG_RAM_SIZE=262144
 CONFIG_RAM_START=0x20400000
 CONFIG_RAW_BINARY=y
 CONFIG_RR_INTERVAL=200
-CONFIG_SAME70QMTECH_FORMAT_MCUBOOT=y
+CONFIG_SAMV7_FORMAT_MCUBOOT=y
 CONFIG_SAMV7_GPIOA_IRQ=y
 CONFIG_SAMV7_GPIOD_IRQ=y
 CONFIG_SAMV7_GPIO_IRQ=y
 CONFIG_SAMV7_HSMCI0=y
-CONFIG_SAMV7_PROGMEM=y
 CONFIG_SAMV7_USART1=y
 CONFIG_SAMV7_XDMAC=y
 CONFIG_SCHED_HPWORK=y
diff --git a/boards/arm/samv7/same70-qmtech/configs/mcuboot-loader/defconfig b/boards/arm/samv7/same70-qmtech/configs/mcuboot-loader/defconfig
index 9e15549..ec31b08 100644
--- a/boards/arm/samv7/same70-qmtech/configs/mcuboot-loader/defconfig
+++ b/boards/arm/samv7/same70-qmtech/configs/mcuboot-loader/defconfig
@@ -46,13 +46,11 @@ CONFIG_RAM_SIZE=262144
 CONFIG_RAM_START=0x20400000
 CONFIG_RAW_BINARY=y
 CONFIG_RR_INTERVAL=200
-CONFIG_SAME70QMTECH_FORMAT_MCUBOOT=y
-CONFIG_SAME70QMTECH_MCUBOOT_BOOTLOADER=y
+CONFIG_SAMV7_FORMAT_MCUBOOT=y
 CONFIG_SAMV7_GPIOA_IRQ=y
 CONFIG_SAMV7_GPIOD_IRQ=y
 CONFIG_SAMV7_GPIO_IRQ=y
 CONFIG_SAMV7_HSMCI0=y
-CONFIG_SAMV7_PROGMEM=y
 CONFIG_SAMV7_USART1=y
 CONFIG_SAMV7_XDMAC=y
 CONFIG_SCHED_HPWORK=y
diff --git a/boards/arm/samv7/same70-qmtech/kernel/Makefile b/boards/arm/samv7/same70-qmtech/kernel/Makefile
index 95f8c76..1cf8976 100644
--- a/boards/arm/samv7/same70-qmtech/kernel/Makefile
+++ b/boards/arm/samv7/same70-qmtech/kernel/Makefile
@@ -31,16 +31,16 @@ ENTRYPT = $(patsubst "%",%,$(CONFIG_USER_ENTRYPOINT))
 ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
   # Windows-native toolchains
   USER_LIBPATHS = ${shell for path in $(USERLIBS); do dir=`dirname $(TOPDIR)$(DELIM)$$path`;echo "-L\"`cygpath -w $$dir`\"";done}
-  USER_LDSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld}"
-  USER_LDSCRIPT += -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)user-space.ld}"
+  USER_LDSCRIPT = -T "${shell cygpath -w $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)memory.ld}"
+  USER_LDSCRIPT += -T "${shell cygpath -w $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)user-space.ld}"
   USER_HEXFILE += "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx_user.hex}"
   USER_SRECFILE += "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx_user.srec}"
   USER_BINFILE += "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx_user.bin}"
 else
   # Linux/Cygwin-native toolchain
   USER_LIBPATHS = $(addprefix -L$(TOPDIR)$(DELIM),$(dir $(USERLIBS)))
-  USER_LDSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld
-  USER_LDSCRIPT += -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)user-space.ld
+  USER_LDSCRIPT = -T$(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)memory.ld
+  USER_LDSCRIPT += -T$(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)user-space.ld
   USER_HEXFILE += "$(TOPDIR)$(DELIM)nuttx_user.hex"
   USER_SRECFILE += "$(TOPDIR)$(DELIM)nuttx_user.srec"
   USER_BINFILE += "$(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 8a764e6..888c23f 100644
--- a/boards/arm/samv7/same70-qmtech/scripts/Make.defs
+++ b/boards/arm/samv7/same70-qmtech/scripts/Make.defs
@@ -18,55 +18,4 @@
 #
 ############################################################################
 
-include $(TOPDIR)/.config
-include $(TOPDIR)/tools/Config.mk
-include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs
-
-LDSCRIPT_TEMPLATE = $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash.template.ld
-LDSCRIPT = samv7.ld
-
-ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
-  ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
-else
-  ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
-endif
-
-ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
-  ARCHOPTIMIZATION = -g
-endif
-
-ifneq ($(CONFIG_DEBUG_NOOPT),y)
-  ARCHOPTIMIZATION += $(MAXOPTIMIZATION)
-endif
-
-ARCHCFLAGS = -fno-builtin
-ARCHCXXFLAGS = -fno-builtin -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
-ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
-  LDMODULEFLAGS += -T "${shell cygpath -w $(TOPDIR)/libs/libc/modlib/gnu-elf.ld}"
-else
-  LDMODULEFLAGS += -T $(TOPDIR)/libs/libc/modlib/gnu-elf.ld
-endif
-
-ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
-  LDFLAGS += -g
-endif
+include $(TOPDIR)/boards/arm/samv7/common/scripts/flat.memory
diff --git a/boards/arm/samv7/same70-qmtech/scripts/gnu-elf.ld b/boards/arm/samv7/same70-qmtech/scripts/gnu-elf.ld
deleted file mode 100644
index a904824..0000000
--- a/boards/arm/samv7/same70-qmtech/scripts/gnu-elf.ld
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/same70-qmtech/scripts/gnu-elf.ld
- *
- * 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.
- *
- ****************************************************************************/
-
-SECTIONS
-{
-  .text 0x00000000 :
-    {
-      _stext = . ;
-      *(.text)
-      *(.text.*)
-      *(.gnu.warning)
-      *(.stub)
-      *(.glue_7)
-      *(.glue_7t)
-      *(.jcr)
-
-      /* C++ support:  The .init and .fini sections contain specific logic
-       * to manage static constructors and destructors.
-       */
-
-      *(.gnu.linkonce.t.*)
-      *(.init)             /* Old ABI */
-      *(.fini)             /* Old ABI */
-      _etext = . ;
-    }
-
-  .rodata :
-    {
-      _srodata = . ;
-      *(.rodata)
-      *(.rodata1)
-      *(.rodata.*)
-      *(.gnu.linkonce.r*)
-      _erodata = . ;
-    }
-
-  .data :
-    {
-      _sdata = . ;
-      *(.data)
-      *(.data1)
-      *(.data.*)
-      *(.gnu.linkonce.d*)
-      . = ALIGN(4);
-      _edata = . ;
-    }
-
-  /* C++ support. For each global and static local C++ object,
-   * GCC creates a small subroutine to construct the object. Pointers
-   * to these routines (not the routines themselves) are stored as
-   * simple, linear arrays in the .ctors section of the object file.
-   * Similarly, pointers to global/static destructor routines are
-   * stored in .dtors.
-   */
-
-  .ctors :
-    {
-      _sctors = . ;
-      *(.ctors)       /* Old ABI:  Unallocated */
-      *(.init_array)  /* New ABI:  Allocated */
-      _edtors = . ;
-    }
-
-  .dtors :
-    {
-      _sdtors = . ;
-      *(.dtors)       /* Old ABI:  Unallocated */
-      *(.fini_array)  /* New ABI:  Allocated */
-      _edtors = . ;
-    }
-
-  .bss :
-    {
-      _sbss = . ;
-      *(.bss)
-      *(.bss.*)
-      *(.sbss)
-      *(.sbss.*)
-      *(.gnu.linkonce.b*)
-      *(COMMON)
-      _ebss = . ;
-    }
-
-    /* Stabs debugging sections.    */
-
-    .stab 0 : { *(.stab) }
-    .stabstr 0 : { *(.stabstr) }
-    .stab.excl 0 : { *(.stab.excl) }
-    .stab.exclstr 0 : { *(.stab.exclstr) }
-    .stab.index 0 : { *(.stab.index) }
-    .stab.indexstr 0 : { *(.stab.indexstr) }
-    .comment 0 : { *(.comment) }
-    .debug_abbrev 0 : { *(.debug_abbrev) }
-    .debug_info 0 : { *(.debug_info) }
-    .debug_line 0 : { *(.debug_line) }
-    .debug_pubnames 0 : { *(.debug_pubnames) }
-    .debug_aranges 0 : { *(.debug_aranges) }
-}
diff --git a/boards/arm/samv7/same70-qmtech/scripts/kernel-space.ld b/boards/arm/samv7/same70-qmtech/scripts/kernel-space.ld
deleted file mode 100644
index 6362cd8..0000000
--- a/boards/arm/samv7/same70-qmtech/scripts/kernel-space.ld
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/same70-qmtech/scripts/kernel-space.ld
- *
- * 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.
- *
- ****************************************************************************/
-
-/* NOTE:  This depends on the memory.ld script having been included prior to
- * this script.
- */
-
-OUTPUT_ARCH(arm)
-EXTERN(_vectors)
-ENTRY(_stext)
-
-SECTIONS
-{
-    .text : {
-        _stext = ABSOLUTE(.);
-        *(.vectors)
-        *(.text .text.*)
-        *(.fixup)
-        *(.gnu.warning)
-        *(.rodata .rodata.*)
-        *(.gnu.linkonce.t.*)
-        *(.glue_7)
-        *(.glue_7t)
-        *(.got)
-        *(.gcc_except_table)
-        *(.gnu.linkonce.r.*)
-        _etext = ABSOLUTE(.);
-    } > kflash
-
-    .init_section : {
-        _sinit = ABSOLUTE(.);
-        *(.init_array .init_array.*)
-        _einit = ABSOLUTE(.);
-    } > kflash
-
-    .ARM.extab : {
-        *(.ARM.extab*)
-    } > kflash
-
-    __exidx_start = ABSOLUTE(.);
-    .ARM.exidx : {
-        *(.ARM.exidx*)
-    } > kflash
-
-    __exidx_end = ABSOLUTE(.);
-
-    _eronly = ABSOLUTE(.);
-
-    .data : {
-        _sdata = ABSOLUTE(.);
-        *(.data .data.*)
-        *(.gnu.linkonce.d.*)
-        CONSTRUCTORS
-        . = ALIGN(4);
-        _edata = ABSOLUTE(.);
-    } > ksram AT > kflash
-
-    .ramfunc ALIGN(4): {
-        _sramfuncs = ABSOLUTE(.);
-        *(.ramfunc  .ramfunc.*)
-        _eramfuncs = ABSOLUTE(.);
-    } > ksram AT > kflash
-
-    _framfuncs = LOADADDR(.ramfunc);
-
-    .bss : {
-        _sbss = ABSOLUTE(.);
-        *(.bss .bss.*)
-        *(.gnu.linkonce.b.*)
-        *(COMMON)
-        . = ALIGN(4);
-        _ebss = ABSOLUTE(.);
-    } > ksram
-
-    /* Stabs debugging sections */
-
-    .stab 0 : { *(.stab) }
-    .stabstr 0 : { *(.stabstr) }
-    .stab.excl 0 : { *(.stab.excl) }
-    .stab.exclstr 0 : { *(.stab.exclstr) }
-    .stab.index 0 : { *(.stab.index) }
-    .stab.indexstr 0 : { *(.stab.indexstr) }
-    .comment 0 : { *(.comment) }
-    .debug_abbrev 0 : { *(.debug_abbrev) }
-    .debug_info 0 : { *(.debug_info) }
-    .debug_line 0 : { *(.debug_line) }
-    .debug_pubnames 0 : { *(.debug_pubnames) }
-    .debug_aranges 0 : { *(.debug_aranges) }
-}
diff --git a/boards/arm/samv7/same70-qmtech/scripts/memory.ld b/boards/arm/samv7/same70-qmtech/scripts/memory.ld
deleted file mode 100644
index 9e33168..0000000
--- a/boards/arm/samv7/same70-qmtech/scripts/memory.ld
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/same70-qmtech/scripts/memory.ld
- *
- * 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.
- *
- ****************************************************************************/
-
-/* The SAME70N19 has 512Kb of FLASH beginning at address 0x0040:0000 and
- * 256Kb of SRAM beginining at 0x2040: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
- * the 0x0400:0000 address range.
- *
- * The user space partition will be spanned with a single region of size
- * 2**n bytes.  The alignment of the user-space region must be the same.
- * As a consequence, as the user-space increases in size, the alignment
- * requirement also increases.  The sizes below give the largest possible
- * user address spaces (but leave far too much for the OS).
- *
- * The solution to this wasted memory is to (1) use more than one region to
- * span the user spaces, or (2) poke holes in a larger region to trim it
- * to fit better.
- *
- * A detailed memory map for the 256KB SRAM region is as follows:
- *
- *   0x2040 0000:  Kernel .data region.  Typical size: 0.1KB
- *   ------ ----   Kernel .bss  region.  Typical size: 1.8KB
- *   0x2040 0800:  Kernel IDLE thread stack (approximate).  Size is
- *                 determined by CONFIG_IDLETHREAD_STACKSIZE and
- *                 adjustments for alignment.  Typical is 1KB.
- *   ------ ----   Padded to 4KB
- *   0x2041 0000:  User .data region.  Size is variable.
- *   ------- ----  User .bss region  Size is variable.
- *   0x2042 0000:  Beginning of kernel heap.  Size determined by
- *                 CONFIG_MM_KERNEL_HEAPSIZE.
- *   ------ ----   Beginning of user heap.  Can vary with other settings.
- *   0x2044 0000:  End+1 of mappable internal SRAM
- */
-
-MEMORY
-{
-  /* 512Kb of internal FLASH */
-
-  kflash (rx)      : ORIGIN = 0x00400000, LENGTH = 256K
-  uflash (rx)      : ORIGIN = 0x00440000, LENGTH = 256K
-
-  /* 256Kb of internal SRAM */
-
-  ksram (rwx)      : ORIGIN = 0x20400000, LENGTH = 64K
-  usram (rwx)      : ORIGIN = 0x20410000, LENGTH = 64K
-  xsram (rwx)      : ORIGIN = 0x20420000, LENGTH = 128K
-}
diff --git a/boards/arm/samv7/same70-qmtech/scripts/user-space.ld b/boards/arm/samv7/same70-qmtech/scripts/user-space.ld
deleted file mode 100644
index 8c08dfc..0000000
--- a/boards/arm/samv7/same70-qmtech/scripts/user-space.ld
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/same70-qmtech/scripts/user-space.ld
- *
- * 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.
- *
- ****************************************************************************/
-
-/* NOTE:  This depends on the memory.ld script having been included prior to
- * this script.
- */
-
-/* Make sure that the critical memory management functions are in user-space.
- * the user heap memory manager will reside in user-space but be usable both
- * by kernel- and user-space code
- */
-
-EXTERN(umm_initialize)
-EXTERN(umm_addregion)
-
-EXTERN(malloc)
-EXTERN(realloc)
-EXTERN(zalloc)
-EXTERN(free)
-
-OUTPUT_ARCH(arm)
-SECTIONS
-{
-    .userspace : {
-        *(.userspace)
-    } > uflash
-
-    .text : {
-        _stext = ABSOLUTE(.);
-        *(.text .text.*)
-        *(.fixup)
-        *(.gnu.warning)
-        *(.rodata .rodata.*)
-        *(.gnu.linkonce.t.*)
-        *(.glue_7)
-        *(.glue_7t)
-        *(.got)
-        *(.gcc_except_table)
-        *(.gnu.linkonce.r.*)
-        _etext = ABSOLUTE(.);
-    } > uflash
-
-    .init_section : {
-        _sinit = ABSOLUTE(.);
-        *(.init_array .init_array.*)
-        _einit = ABSOLUTE(.);
-    } > uflash
-
-    .ARM.extab : {
-        *(.ARM.extab*)
-    } > uflash
-
-    __exidx_start = ABSOLUTE(.);
-    .ARM.exidx : {
-        *(.ARM.exidx*)
-    } > uflash
-
-    __exidx_end = ABSOLUTE(.);
-
-    _eronly = ABSOLUTE(.);
-
-    .data : {
-        _sdata = ABSOLUTE(.);
-        *(.data .data.*)
-        *(.gnu.linkonce.d.*)
-        CONSTRUCTORS
-        . = ALIGN(4);
-        _edata = ABSOLUTE(.);
-    } > usram AT > uflash
-
-    .bss : {
-        _sbss = ABSOLUTE(.);
-        *(.bss .bss.*)
-        *(.gnu.linkonce.b.*)
-        *(COMMON)
-        . = ALIGN(4);
-        _ebss = ABSOLUTE(.);
-    } > usram
-
-    /* Stabs debugging sections */
-
-    .stab 0 : { *(.stab) }
-    .stabstr 0 : { *(.stabstr) }
-    .stab.excl 0 : { *(.stab.excl) }
-    .stab.exclstr 0 : { *(.stab.exclstr) }
-    .stab.index 0 : { *(.stab.index) }
-    .stab.indexstr 0 : { *(.stab.indexstr) }
-    .comment 0 : { *(.comment) }
-    .debug_abbrev 0 : { *(.debug_abbrev) }
-    .debug_info 0 : { *(.debug_info) }
-    .debug_line 0 : { *(.debug_line) }
-    .debug_pubnames 0 : { *(.debug_pubnames) }
-    .debug_aranges 0 : { *(.debug_aranges) }
-}
diff --git a/boards/arm/samv7/same70-qmtech/src/Makefile b/boards/arm/samv7/same70-qmtech/src/Make.defs
similarity index 85%
rename from boards/arm/samv7/same70-qmtech/src/Makefile
rename to boards/arm/samv7/same70-qmtech/src/Make.defs
index 8783c64..567a1c4 100644
--- a/boards/arm/samv7/same70-qmtech/src/Makefile
+++ b/boards/arm/samv7/same70-qmtech/src/Make.defs
@@ -68,16 +68,18 @@ ifneq (,$(findstring y,$(CONFIG_SAMV7_DAC0) $(CONFIG_SAMV7_DAC1)))
 CSRCS += sam_dac.c
 endif
 
-SCRIPTOUT = $(BOARD_DIR)$(DELIM)scripts$(DELIM)samv7.ld
+SCRIPTOUT = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)samv7.ld
 
 .PHONY = context distclean
 
 $(SCRIPTOUT): $(LDSCRIPT_TEMPLATE) $(CONFIGFILE)
-	$(Q) $(CC) -isystem $(TOPDIR)/include -I $(BOARD_DIR)$(DELIM)scripts -C -P -x c -E $(LDSCRIPT_TEMPLATE) -o $@
+	$(Q) $(CC) -isystem $(TOPDIR)/include -I $(BOARD_COMMON_DIR)$(DELIM)scripts -C -P -x c -E $(LDSCRIPT_TEMPLATE) -o $@
 
 context:: $(SCRIPTOUT)
 
 distclean::
 	$(call DELFILE, $(SCRIPTOUT))
 
-include $(TOPDIR)/boards/Board.mk
+DEPPATH += --dep-path board
+VPATH += :board
+CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)
diff --git a/boards/arm/samv7/same70-qmtech/src/sam_progmem.c b/boards/arm/samv7/same70-qmtech/src/sam_progmem.c
index e6d6a60..6ff222e 100644
--- a/boards/arm/samv7/same70-qmtech/src/sam_progmem.c
+++ b/boards/arm/samv7/same70-qmtech/src/sam_progmem.c
@@ -54,7 +54,7 @@
  * Private Types
  ****************************************************************************/
 
-#if defined(CONFIG_SAME70QMTECH_PROGMEM_OTA_PARTITION)
+#if defined(CONFIG_SAMV7_PROGMEM_OTA_PARTITION)
 
 struct ota_partition_s
 {
@@ -69,7 +69,7 @@ struct ota_partition_s
  * Private Function Prototypes
  ****************************************************************************/
 
-#if defined(CONFIG_SAME70QMTECH_PROGMEM_OTA_PARTITION)
+#if defined(CONFIG_SAMV7_PROGMEM_OTA_PARTITION)
 static struct mtd_dev_s *sam_progmem_alloc_mtdpart(uint32_t mtd_offset,
                                                    uint32_t mtd_size);
 static int init_ota_partitions(void);
@@ -81,23 +81,23 @@ static int init_ota_partitions(void);
 
 static FAR struct mtd_dev_s *g_samv7_progmem_mtd;
 
-#if defined(CONFIG_SAME70QMTECH_PROGMEM_OTA_PARTITION)
+#if defined(CONFIG_SAMV7_PROGMEM_OTA_PARTITION)
 static const struct ota_partition_s g_ota_partition_table[] =
 {
   {
-    .offset  = CONFIG_SAME70QMTECH_OTA_PRIMARY_SLOT_OFFSET,
-    .size    = CONFIG_SAME70QMTECH_OTA_SLOT_SIZE,
-    .devpath = CONFIG_SAME70QMTECH_OTA_PRIMARY_SLOT_DEVPATH
+    .offset  = CONFIG_SAMV7_OTA_PRIMARY_SLOT_OFFSET,
+    .size    = CONFIG_SAMV7_OTA_SLOT_SIZE,
+    .devpath = CONFIG_SAMV7_OTA_PRIMARY_SLOT_DEVPATH
   },
   {
-    .offset  = CONFIG_SAME70QMTECH_OTA_SECONDARY_SLOT_OFFSET,
-    .size    = CONFIG_SAME70QMTECH_OTA_SLOT_SIZE,
-    .devpath = CONFIG_SAME70QMTECH_OTA_SECONDARY_SLOT_DEVPATH
+    .offset  = CONFIG_SAMV7_OTA_SECONDARY_SLOT_OFFSET,
+    .size    = CONFIG_SAMV7_OTA_SLOT_SIZE,
+    .devpath = CONFIG_SAMV7_OTA_SECONDARY_SLOT_DEVPATH
   },
   {
-    .offset  = CONFIG_SAME70QMTECH_OTA_SCRATCH_OFFSET,
-    .size    = CONFIG_SAME70QMTECH_OTA_SCRATCH_SIZE,
-    .devpath = CONFIG_SAME70QMTECH_OTA_SCRATCH_DEVPATH
+    .offset  = CONFIG_SAMV7_OTA_SCRATCH_OFFSET,
+    .size    = CONFIG_SAMV7_OTA_SCRATCH_SIZE,
+    .devpath = CONFIG_SAMV7_OTA_SCRATCH_DEVPATH
   }
 };
 #endif
@@ -106,7 +106,7 @@ static const struct ota_partition_s g_ota_partition_table[] =
  * Private Functions
  ****************************************************************************/
 
-#if defined(CONFIG_SAME70QMTECH_PROGMEM_OTA_PARTITION)
+#if defined(CONFIG_SAMV7_PROGMEM_OTA_PARTITION)
 
 /****************************************************************************
  * Name: sam_progmem_alloc_mtdpart
@@ -225,7 +225,7 @@ int sam_progmem_init(void)
       return -EFAULT;
     }
 
-#if defined(CONFIG_SAME70QMTECH_PROGMEM_OTA_PARTITION)
+#if defined(CONFIG_SAMV7_PROGMEM_OTA_PARTITION)
   ret = init_ota_partitions();
   if (ret < 0)
     {
diff --git a/boards/arm/samv7/same70-xplained/Kconfig b/boards/arm/samv7/same70-xplained/Kconfig
index 78a74bb..dd3d2f0b 100644
--- a/boards/arm/samv7/same70-xplained/Kconfig
+++ b/boards/arm/samv7/same70-xplained/Kconfig
@@ -90,65 +90,4 @@ config SAME70XPLAINED_HSMCI0_AUTOMOUNT_UDELAY
 
 endif # SAME70XPLAINED_HSMCI0_AUTOMOUNT
 
-config SAME70XPLAINED_PROGMEM_OTA_PARTITION
-	bool
-	default n
-	select MTD
-	select MTD_BYTE_WRITE
-	select MTD_PARTITION
-	select MTD_PROGMEM
-	select MTD_PROGMEM_ERASESTATE
-
-menuconfig SAME70XPLAINED_FORMAT_MCUBOOT
-	bool "MCUboot-bootable format"
-	default n
-	select SAME70XPLAINED_PROGMEM_OTA_PARTITION
-	---help---
-		The MCUboot support of loading the firmware images.
-
-if SAME70XPLAINED_FORMAT_MCUBOOT
-
-config SAME70XPLAINED_MCUBOOT_BOOTLOADER
-	bool "MCUboot bootloader application"
-	default n
-	---help---
-		This switch between linker scripts to allow an application be
-		built to another entry point address.
-
-comment "MCUboot Application Image OTA Update support"
-
-config SAME70XPLAINED_OTA_PRIMARY_SLOT_OFFSET
-	hex "MCUboot application image primary slot offset"
-	default "0x20000"
-
-config SAME70XPLAINED_OTA_PRIMARY_SLOT_DEVPATH
-	string "Application image primary slot device path"
-	default "/dev/ota0"
-
-config SAME70XPLAINED_OTA_SECONDARY_SLOT_OFFSET
-	hex "MCUboot application image secondary slot offset"
-	default "0x100000"
-
-config SAME70XPLAINED_OTA_SECONDARY_SLOT_DEVPATH
-	string "Application image secondary slot device path"
-	default "/dev/ota1"
-
-config SAME70XPLAINED_OTA_SLOT_SIZE
-	hex "MCUboot application image slot size (in bytes)"
-	default "0xe0000"
-
-config SAME70XPLAINED_OTA_SCRATCH_OFFSET
-	hex "MCUboot scratch partition offset"
-	default "0x1e0000"
-
-config SAME70XPLAINED_OTA_SCRATCH_DEVPATH
-	string "Scratch partition device path"
-	default "/dev/otascratch"
-
-config SAME70XPLAINED_OTA_SCRATCH_SIZE
-	hex "MCUboot scratch partition size (in bytes)"
-	default "0x20000"
-
-endif # SAME70XPLAINED_FORMAT_MCUBOOT
-
 endif # ARCH_BOARD_SAME70_XPLAINED
diff --git a/boards/arm/samv7/same70-xplained/README.txt b/boards/arm/samv7/same70-xplained/README.txt
index 3c7ab65..b7c6d77 100644
--- a/boards/arm/samv7/same70-xplained/README.txt
+++ b/boards/arm/samv7/same70-xplained/README.txt
@@ -1159,7 +1159,7 @@ Using OpenOCD and GDB to flash via the EDBG chip
 
     OpenOCD requires a configuration file.  I keep the one I used last here:
 
-      boards/arm/samv7/same70-xplained/tools/atmel_same70_xplained.cfg
+      boards/arm/samv7/common/tools/atmel_same70_xplained.cfg
 
     However, the "correct" configuration script to use with OpenOCD may
     change as the features of OpenOCD evolve.  So you should at least
@@ -1175,15 +1175,15 @@ Using OpenOCD and GDB to flash via the EDBG chip
     the OpenOCD daemon on my system called oocd.sh.  That script will
     probably require some modifications to work in another environment:
 
-    - Possibly the value of OPENOCD_PATH and TARGET_PATH
+    - Possibly the value of OPENOCD_PATH, TARGET_PATH and TARGET_BOARD
     - It assumes that the correct script to use is the one at
-      boards/arm/samv7/same70-xplained/tools/atmel_same70_xplained.cfg
+      boards/arm/samv7/common/tools/atmel_${TARGET_BOARD}.cfg
 
   Starting OpenOCD
 
     Then you should be able to start the OpenOCD daemon like:
 
-      boards/arm/samv7/same70-xplained/tools/oocd.sh $PWD
+      boards/arm/samv7/common/tools/oocd.sh $PWD
 
   Connecting GDB
 
@@ -1716,8 +1716,7 @@ Configuration sub-directories
       CONFIG_MCUBOOT_BOOTLOADER=y
       CONFIG_MCUBOOT_ENABLE_LOGGING=y
 
-      CONFIG_SAME70XPLAINED_FORMAT_MCUBOOT=y
-      CONFIG_SAME70XPLAINED_MCUBOOT_BOOTLOADER=y
+      CONFIG_SAMV7_FORMAT_MCUBOOT=y
       CONFIG_USER_ENTRYPOINT="mcuboot_loader_main"
 
   mcuboot-confirm:
diff --git a/boards/arm/samv7/same70-xplained/configs/mcuboot-confirm/defconfig b/boards/arm/samv7/same70-xplained/configs/mcuboot-confirm/defconfig
index 931a4d5..4fbf4c2 100644
--- a/boards/arm/samv7/same70-xplained/configs/mcuboot-confirm/defconfig
+++ b/boards/arm/samv7/same70-xplained/configs/mcuboot-confirm/defconfig
@@ -46,7 +46,6 @@ CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
 CONFIG_MMCSD_SDIO=y
 CONFIG_MTD_AT24XX=y
 CONFIG_MTD_AT25=y
-CONFIG_MTD_CONFIG=y
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_BUILTIN_APPS=y
 CONFIG_NSH_FILEIOSIZE=512
@@ -57,12 +56,11 @@ CONFIG_RAM_SIZE=393216
 CONFIG_RAM_START=0x20400000
 CONFIG_RAW_BINARY=y
 CONFIG_RR_INTERVAL=200
-CONFIG_SAME70XPLAINED_FORMAT_MCUBOOT=y
+CONFIG_SAMV7_FORMAT_MCUBOOT=y
 CONFIG_SAMV7_GPIOA_IRQ=y
 CONFIG_SAMV7_GPIOC_IRQ=y
 CONFIG_SAMV7_GPIO_IRQ=y
 CONFIG_SAMV7_HSMCI0=y
-CONFIG_SAMV7_PROGMEM=y
 CONFIG_SAMV7_SDRAMC=y
 CONFIG_SAMV7_SDRAMSIZE=2097152
 CONFIG_SAMV7_TWIHS0=y
diff --git a/boards/arm/samv7/same70-xplained/configs/mcuboot-loader/defconfig b/boards/arm/samv7/same70-xplained/configs/mcuboot-loader/defconfig
index 86123ea..4ddd819 100644
--- a/boards/arm/samv7/same70-xplained/configs/mcuboot-loader/defconfig
+++ b/boards/arm/samv7/same70-xplained/configs/mcuboot-loader/defconfig
@@ -47,7 +47,6 @@ CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
 CONFIG_MMCSD_SDIO=y
 CONFIG_MTD_AT24XX=y
 CONFIG_MTD_AT25=y
-CONFIG_MTD_CONFIG=y
 CONFIG_NSH_ARCHINIT=y
 CONFIG_NSH_BUILTIN_APPS=y
 CONFIG_NSH_FILEIOSIZE=512
@@ -58,13 +57,11 @@ CONFIG_RAM_SIZE=393216
 CONFIG_RAM_START=0x20400000
 CONFIG_RAW_BINARY=y
 CONFIG_RR_INTERVAL=200
-CONFIG_SAME70XPLAINED_FORMAT_MCUBOOT=y
-CONFIG_SAME70XPLAINED_MCUBOOT_BOOTLOADER=y
+CONFIG_SAMV7_FORMAT_MCUBOOT=y
 CONFIG_SAMV7_GPIOA_IRQ=y
 CONFIG_SAMV7_GPIOC_IRQ=y
 CONFIG_SAMV7_GPIO_IRQ=y
 CONFIG_SAMV7_HSMCI0=y
-CONFIG_SAMV7_PROGMEM=y
 CONFIG_SAMV7_SDRAMC=y
 CONFIG_SAMV7_SDRAMSIZE=2097152
 CONFIG_SAMV7_TWIHS0=y
diff --git a/boards/arm/samv7/same70-xplained/kernel/Makefile b/boards/arm/samv7/same70-xplained/kernel/Makefile
index d7fe60f..e0b6632 100644
--- a/boards/arm/samv7/same70-xplained/kernel/Makefile
+++ b/boards/arm/samv7/same70-xplained/kernel/Makefile
@@ -31,16 +31,16 @@ ENTRYPT = $(patsubst "%",%,$(CONFIG_USER_ENTRYPOINT))
 ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
   # Windows-native toolchains
   USER_LIBPATHS = ${shell for path in $(USERLIBS); do dir=`dirname $(TOPDIR)$(DELIM)$$path`;echo "-L\"`cygpath -w $$dir`\"";done}
-  USER_LDSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld}"
-  USER_LDSCRIPT += -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)user-space.ld}"
+  USER_LDSCRIPT = -T "${shell cygpath -w $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)memory.ld}"
+  USER_LDSCRIPT += -T "${shell cygpath -w $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)user-space.ld}"
   USER_HEXFILE += "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx_user.hex}"
   USER_SRECFILE += "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx_user.srec}"
   USER_BINFILE += "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx_user.bin}"
 else
   # Linux/Cygwin-native toolchain
   USER_LIBPATHS = $(addprefix -L$(TOPDIR)$(DELIM),$(dir $(USERLIBS)))
-  USER_LDSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld
-  USER_LDSCRIPT += -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)user-space.ld
+  USER_LDSCRIPT = -T$(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)memory.ld
+  USER_LDSCRIPT += -T$(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)user-space.ld
   USER_HEXFILE += "$(TOPDIR)$(DELIM)nuttx_user.hex"
   USER_SRECFILE += "$(TOPDIR)$(DELIM)nuttx_user.srec"
   USER_BINFILE += "$(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 1c6279f..288f75d 100644
--- a/boards/arm/samv7/same70-xplained/scripts/Make.defs
+++ b/boards/arm/samv7/same70-xplained/scripts/Make.defs
@@ -18,55 +18,4 @@
 #
 ############################################################################
 
-include $(TOPDIR)/.config
-include $(TOPDIR)/tools/Config.mk
-include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs
-
-LDSCRIPT_TEMPLATE = $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash.template.ld
-LDSCRIPT = samv7.ld
-
-ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
-  ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
-else
-  ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
-endif
-
-ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
-  ARCHOPTIMIZATION = -g
-endif
-
-ifneq ($(CONFIG_DEBUG_NOOPT),y)
-  ARCHOPTIMIZATION += $(MAXOPTIMIZATION)
-endif
-
-ARCHCFLAGS = -fno-builtin
-ARCHCXXFLAGS = -fno-builtin -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
-ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
-  LDMODULEFLAGS += -T "${shell cygpath -w $(TOPDIR)/libs/libc/modlib/gnu-elf.ld}"
-else
-  LDMODULEFLAGS += -T $(TOPDIR)/libs/libc/modlib/gnu-elf.ld
-endif
-
-ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
-  LDFLAGS += -g
-endif
+include $(TOPDIR)/boards/arm/samv7/common/scripts/flat.memory
diff --git a/boards/arm/samv7/same70-xplained/scripts/flash.template.ld b/boards/arm/samv7/same70-xplained/scripts/flash.template.ld
deleted file mode 100644
index 4b984a8..0000000
--- a/boards/arm/samv7/same70-xplained/scripts/flash.template.ld
+++ /dev/null
@@ -1,130 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/same70-xplained/scripts/flash.template.ld
- *
- * 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 <nuttx/config.h>
-
-#define FLASH_START_ADDR        0x00400000
-
-#ifdef CONFIG_ARMV7M_DTCM
-#  define SRAM_START_ADDR       0x20000000
-#else
-#  define SRAM_START_ADDR       0x20400000
-#endif
-
-#ifdef CONFIG_SAME70XPLAINED_FORMAT_MCUBOOT
-#  define MCUBOOT_HEADER_SIZE   0x200
-#  ifdef CONFIG_BOARDCTL_BOOT_IMAGE
-#    define FLASH_OFFSET        0
-#    define FLASH_IMG_SIZE      CONFIG_SAME70XPLAINED_OTA_PRIMARY_SLOT_OFFSET
-#  else
-#    define FLASH_OFFSET        (CONFIG_SAME70XPLAINED_OTA_PRIMARY_SLOT_OFFSET + MCUBOOT_HEADER_SIZE)
-#    define FLASH_IMG_SIZE      (CONFIG_SAME70XPLAINED_OTA_SLOT_SIZE - MCUBOOT_HEADER_SIZE)
-#  endif
-#else
-#  define FLASH_OFFSET          0
-#  define FLASH_IMG_SIZE        CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH
-#endif
-
-MEMORY
-{
-  flash (rx) : ORIGIN = FLASH_START_ADDR + FLASH_OFFSET, LENGTH = FLASH_IMG_SIZE
-  sram (rwx) : ORIGIN = SRAM_START_ADDR, LENGTH = CONFIG_ARCH_CHIP_SAMV7_MEM_RAM
-}
-
-OUTPUT_ARCH(arm)
-EXTERN(_vectors)
-ENTRY(_stext)
-
-SECTIONS
-{
-    .text : {
-        _stext = ABSOLUTE(.);
-        *(.vectors)
-        *(.text .text.*)
-        *(.fixup)
-        *(.gnu.warning)
-        *(.rodata .rodata.*)
-        *(.gnu.linkonce.t.*)
-        *(.glue_7)
-        *(.glue_7t)
-        *(.got)
-        *(.gcc_except_table)
-        *(.gnu.linkonce.r.*)
-        _etext = ABSOLUTE(.);
-    } > flash
-
-    .init_section : {
-        _sinit = ABSOLUTE(.);
-        *(.init_array .init_array.*)
-        _einit = ABSOLUTE(.);
-    } > flash
-
-    .ARM.extab : {
-        *(.ARM.extab*)
-    } > flash
-
-    __exidx_start = ABSOLUTE(.);
-    .ARM.exidx : {
-        *(.ARM.exidx*)
-    } > flash
-    __exidx_end = ABSOLUTE(.);
-
-    _eronly = ABSOLUTE(.);
-
-    .data : {
-        _sdata = ABSOLUTE(.);
-        *(.data .data.*)
-        *(.gnu.linkonce.d.*)
-        CONSTRUCTORS
-        . = ALIGN(4);
-        _edata = ABSOLUTE(.);
-    } > sram AT > flash
-
-    .ramfunc ALIGN(4): {
-        _sramfuncs = ABSOLUTE(.);
-        *(.ramfunc  .ramfunc.*)
-        _eramfuncs = ABSOLUTE(.);
-    } > sram AT > flash
-
-    _framfuncs = LOADADDR(.ramfunc);
-
-    .bss : {
-        _sbss = ABSOLUTE(.);
-        *(.bss .bss.*)
-        *(.gnu.linkonce.b.*)
-        *(COMMON)
-        . = ALIGN(4);
-        _ebss = ABSOLUTE(.);
-    } > sram
-
-    /* Stabs debugging sections. */
-    .stab 0 : { *(.stab) }
-    .stabstr 0 : { *(.stabstr) }
-    .stab.excl 0 : { *(.stab.excl) }
-    .stab.exclstr 0 : { *(.stab.exclstr) }
-    .stab.index 0 : { *(.stab.index) }
-    .stab.indexstr 0 : { *(.stab.indexstr) }
-    .comment 0 : { *(.comment) }
-    .debug_abbrev 0 : { *(.debug_abbrev) }
-    .debug_info 0 : { *(.debug_info) }
-    .debug_line 0 : { *(.debug_line) }
-    .debug_pubnames 0 : { *(.debug_pubnames) }
-    .debug_aranges 0 : { *(.debug_aranges) }
-}
diff --git a/boards/arm/samv7/same70-xplained/scripts/gnu-elf.ld b/boards/arm/samv7/same70-xplained/scripts/gnu-elf.ld
deleted file mode 100644
index a141d7b..0000000
--- a/boards/arm/samv7/same70-xplained/scripts/gnu-elf.ld
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/same70-xplained/scripts/gnu-elf.ld
- *
- * 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.
- *
- ****************************************************************************/
-
-SECTIONS
-{
-  .text 0x00000000 :
-    {
-      _stext = . ;
-      *(.text)
-      *(.text.*)
-      *(.gnu.warning)
-      *(.stub)
-      *(.glue_7)
-      *(.glue_7t)
-      *(.jcr)
-
-      /* C++ support:  The .init and .fini sections contain specific logic
-       * to manage static constructors and destructors.
-       */
-
-      *(.gnu.linkonce.t.*)
-      *(.init)             /* Old ABI */
-      *(.fini)             /* Old ABI */
-      _etext = . ;
-    }
-
-  .rodata :
-    {
-      _srodata = . ;
-      *(.rodata)
-      *(.rodata1)
-      *(.rodata.*)
-      *(.gnu.linkonce.r*)
-      _erodata = . ;
-    }
-
-  .data :
-    {
-      _sdata = . ;
-      *(.data)
-      *(.data1)
-      *(.data.*)
-      *(.gnu.linkonce.d*)
-      . = ALIGN(4);
-      _edata = . ;
-    }
-
-  /* C++ support. For each global and static local C++ object,
-   * GCC creates a small subroutine to construct the object. Pointers
-   * to these routines (not the routines themselves) are stored as
-   * simple, linear arrays in the .ctors section of the object file.
-   * Similarly, pointers to global/static destructor routines are
-   * stored in .dtors.
-   */
-
-  .ctors :
-    {
-      _sctors = . ;
-      *(.ctors)       /* Old ABI:  Unallocated */
-      *(.init_array)  /* New ABI:  Allocated */
-      _edtors = . ;
-    }
-
-  .dtors :
-    {
-      _sdtors = . ;
-      *(.dtors)       /* Old ABI:  Unallocated */
-      *(.fini_array)  /* New ABI:  Allocated */
-      _edtors = . ;
-    }
-
-  .bss :
-    {
-      _sbss = . ;
-      *(.bss)
-      *(.bss.*)
-      *(.sbss)
-      *(.sbss.*)
-      *(.gnu.linkonce.b*)
-      *(COMMON)
-      _ebss = . ;
-    }
-
-    /* Stabs debugging sections.    */
-
-    .stab 0 : { *(.stab) }
-    .stabstr 0 : { *(.stabstr) }
-    .stab.excl 0 : { *(.stab.excl) }
-    .stab.exclstr 0 : { *(.stab.exclstr) }
-    .stab.index 0 : { *(.stab.index) }
-    .stab.indexstr 0 : { *(.stab.indexstr) }
-    .comment 0 : { *(.comment) }
-    .debug_abbrev 0 : { *(.debug_abbrev) }
-    .debug_info 0 : { *(.debug_info) }
-    .debug_line 0 : { *(.debug_line) }
-    .debug_pubnames 0 : { *(.debug_pubnames) }
-    .debug_aranges 0 : { *(.debug_aranges) }
-}
diff --git a/boards/arm/samv7/same70-xplained/scripts/kernel-space.ld b/boards/arm/samv7/same70-xplained/scripts/kernel-space.ld
deleted file mode 100644
index 7fce3ef..0000000
--- a/boards/arm/samv7/same70-xplained/scripts/kernel-space.ld
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/same70-xplained/scripts/kernel-space.ld
- *
- * 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.
- *
- ****************************************************************************/
-
-/* NOTE:  This depends on the memory.ld script having been included prior to
- * this script.
- */
-
-OUTPUT_ARCH(arm)
-EXTERN(_vectors)
-ENTRY(_stext)
-
-SECTIONS
-{
-    .text : {
-        _stext = ABSOLUTE(.);
-        *(.vectors)
-        *(.text .text.*)
-        *(.fixup)
-        *(.gnu.warning)
-        *(.rodata .rodata.*)
-        *(.gnu.linkonce.t.*)
-        *(.glue_7)
-        *(.glue_7t)
-        *(.got)
-        *(.gcc_except_table)
-        *(.gnu.linkonce.r.*)
-        _etext = ABSOLUTE(.);
-    } > kflash
-
-    .init_section : {
-        _sinit = ABSOLUTE(.);
-        *(.init_array .init_array.*)
-        _einit = ABSOLUTE(.);
-    } > kflash
-
-    .ARM.extab : {
-        *(.ARM.extab*)
-    } > kflash
-
-    __exidx_start = ABSOLUTE(.);
-    .ARM.exidx : {
-        *(.ARM.exidx*)
-    } > kflash
-
-    __exidx_end = ABSOLUTE(.);
-
-    _eronly = ABSOLUTE(.);
-
-    .data : {
-        _sdata = ABSOLUTE(.);
-        *(.data .data.*)
-        *(.gnu.linkonce.d.*)
-        CONSTRUCTORS
-        . = ALIGN(4);
-        _edata = ABSOLUTE(.);
-    } > ksram AT > kflash
-
-    .ramfunc ALIGN(4): {
-        _sramfuncs = ABSOLUTE(.);
-        *(.ramfunc  .ramfunc.*)
-        _eramfuncs = ABSOLUTE(.);
-    } > ksram AT > kflash
-
-    _framfuncs = LOADADDR(.ramfunc);
-
-    .bss : {
-        _sbss = ABSOLUTE(.);
-        *(.bss .bss.*)
-        *(.gnu.linkonce.b.*)
-        *(COMMON)
-        . = ALIGN(4);
-        _ebss = ABSOLUTE(.);
-    } > ksram
-
-    /* Stabs debugging sections */
-
-    .stab 0 : { *(.stab) }
-    .stabstr 0 : { *(.stabstr) }
-    .stab.excl 0 : { *(.stab.excl) }
-    .stab.exclstr 0 : { *(.stab.exclstr) }
-    .stab.index 0 : { *(.stab.index) }
-    .stab.indexstr 0 : { *(.stab.indexstr) }
-    .comment 0 : { *(.comment) }
-    .debug_abbrev 0 : { *(.debug_abbrev) }
-    .debug_info 0 : { *(.debug_info) }
-    .debug_line 0 : { *(.debug_line) }
-    .debug_pubnames 0 : { *(.debug_pubnames) }
-    .debug_aranges 0 : { *(.debug_aranges) }
-}
diff --git a/boards/arm/samv7/same70-xplained/scripts/memory.ld b/boards/arm/samv7/same70-xplained/scripts/memory.ld
deleted file mode 100644
index 8ba960c..0000000
--- a/boards/arm/samv7/same70-xplained/scripts/memory.ld
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/same70-xplained/scripts/memory.ld
- *
- * 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.
- *
- ****************************************************************************/
-
-/* The SAMe70Q21 has 2048Kb of FLASH beginning at address 0x0040:0000 and
- * 384Kb of SRAM beginining at 0x2040: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
- * the 0x0400:0000 address range.
- *
- * The user space partition will be spanned with a single region of size
- * 2**n bytes.  The alignment of the user-space region must be the same.
- * As a consequence, as the user-space increases in size, the alignment
- * requirement also increases.  The sizes below give the largest possible
- * user address spaces (but leave far too much for the OS).
- *
- * The solution to this wasted memory is to (1) use more than one region to
- * 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:
- *
- *   0x2040 0000:  Kernel .data region.  Typical size: 0.1KB
- *   ------ ----   Kernel .bss  region.  Typical size: 1.8KB
- *   0x2040 0800:  Kernel IDLE thread stack (approximate).  Size is
- *                 determined by CONFIG_IDLETHREAD_STACKSIZE and
- *                 adjustments for alignment.  Typical is 1KB.
- *   ------ ----   Padded to 4KB
- *   0x2042 0000:  User .data region.  Size is variable.
- *   ------- ----  User .bss region  Size is variable.
- *   0x2044 0000:  Beginning of kernel heap.  Size determined by
- *                 CONFIG_MM_KERNEL_HEAPSIZE.
- *   ------ ----   Beginning of user heap.  Can vary with other settings.
- *   0x2046 0000:  End+1 of mappable internal SRAM
- */
-
-MEMORY
-{
-  /* 2048KiB of internal FLASH */
-
-  kflash (rx)      : ORIGIN = 0x00400000, LENGTH = 1M
-  uflash (rx)      : ORIGIN = 0x00500000, LENGTH = 1M
-
-  /* 384Kb of internal SRAM */
-
-  ksram (rwx)      : ORIGIN = 0x20400000, LENGTH = 128K
-  usram (rwx)      : ORIGIN = 0x20420000, LENGTH = 128K
-  xsram (rwx)      : ORIGIN = 0x20440000, LENGTH = 128K
-}
diff --git a/boards/arm/samv7/same70-xplained/scripts/user-space.ld b/boards/arm/samv7/same70-xplained/scripts/user-space.ld
deleted file mode 100644
index bf32b45..0000000
--- a/boards/arm/samv7/same70-xplained/scripts/user-space.ld
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/same70-xplained/scripts/user-space.ld
- *
- * 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.
- *
- ****************************************************************************/
-
-/* NOTE:  This depends on the memory.ld script having been included prior to
- * this script.
- */
-
-/* Make sure that the critical memory management functions are in user-space.
- * the user heap memory manager will reside in user-space but be usable both
- * by kernel- and user-space code
- */
-
-EXTERN(umm_initialize)
-EXTERN(umm_addregion)
-
-EXTERN(malloc)
-EXTERN(realloc)
-EXTERN(zalloc)
-EXTERN(free)
-
-OUTPUT_ARCH(arm)
-SECTIONS
-{
-    .userspace : {
-        *(.userspace)
-    } > uflash
-
-    .text : {
-        _stext = ABSOLUTE(.);
-        *(.text .text.*)
-        *(.fixup)
-        *(.gnu.warning)
-        *(.rodata .rodata.*)
-        *(.gnu.linkonce.t.*)
-        *(.glue_7)
-        *(.glue_7t)
-        *(.got)
-        *(.gcc_except_table)
-        *(.gnu.linkonce.r.*)
-        _etext = ABSOLUTE(.);
-    } > uflash
-
-    .init_section : {
-        _sinit = ABSOLUTE(.);
-        *(.init_array .init_array.*)
-        _einit = ABSOLUTE(.);
-    } > uflash
-
-    .ARM.extab : {
-        *(.ARM.extab*)
-    } > uflash
-
-    __exidx_start = ABSOLUTE(.);
-    .ARM.exidx : {
-        *(.ARM.exidx*)
-    } > uflash
-
-    __exidx_end = ABSOLUTE(.);
-
-    _eronly = ABSOLUTE(.);
-
-    .data : {
-        _sdata = ABSOLUTE(.);
-        *(.data .data.*)
-        *(.gnu.linkonce.d.*)
-        CONSTRUCTORS
-        . = ALIGN(4);
-        _edata = ABSOLUTE(.);
-    } > usram AT > uflash
-
-    .bss : {
-        _sbss = ABSOLUTE(.);
-        *(.bss .bss.*)
-        *(.gnu.linkonce.b.*)
-        *(COMMON)
-        . = ALIGN(4);
-        _ebss = ABSOLUTE(.);
-    } > usram
-
-    /* Stabs debugging sections */
-
-    .stab 0 : { *(.stab) }
-    .stabstr 0 : { *(.stabstr) }
-    .stab.excl 0 : { *(.stab.excl) }
-    .stab.exclstr 0 : { *(.stab.exclstr) }
-    .stab.index 0 : { *(.stab.index) }
-    .stab.indexstr 0 : { *(.stab.indexstr) }
-    .comment 0 : { *(.comment) }
-    .debug_abbrev 0 : { *(.debug_abbrev) }
-    .debug_info 0 : { *(.debug_info) }
-    .debug_line 0 : { *(.debug_line) }
-    .debug_pubnames 0 : { *(.debug_pubnames) }
-    .debug_aranges 0 : { *(.debug_aranges) }
-}
diff --git a/boards/arm/samv7/same70-xplained/src/Makefile b/boards/arm/samv7/same70-xplained/src/Make.defs
similarity index 88%
rename from boards/arm/samv7/same70-xplained/src/Makefile
rename to boards/arm/samv7/same70-xplained/src/Make.defs
index 8bbea95..4c88925 100644
--- a/boards/arm/samv7/same70-xplained/src/Makefile
+++ b/boards/arm/samv7/same70-xplained/src/Make.defs
@@ -100,16 +100,18 @@ ifeq ($(CONFIG_IEEE802154_XBEE),y)
 CSRCS += sam_xbee.c
 endif
 
-SCRIPTOUT = $(BOARD_DIR)$(DELIM)scripts$(DELIM)samv7.ld
+SCRIPTOUT = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)samv7.ld
 
 .PHONY = context distclean
 
 $(SCRIPTOUT): $(LDSCRIPT_TEMPLATE) $(CONFIGFILE)
-	$(Q) $(CC) -isystem $(TOPDIR)/include -I $(BOARD_DIR)$(DELIM)scripts -C -P -x c -E $(LDSCRIPT_TEMPLATE) -o $@
+	$(Q) $(CC) -isystem $(TOPDIR)/include -I $(BOARD_COMMON_DIR)$(DELIM)scripts -C -P -x c -E $(LDSCRIPT_TEMPLATE) -o $@
 
 context:: $(SCRIPTOUT)
 
 distclean::
 	$(call DELFILE, $(SCRIPTOUT))
 
-include $(TOPDIR)/boards/Board.mk
+DEPPATH += --dep-path board
+VPATH += :board
+CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)
diff --git a/boards/arm/samv7/same70-xplained/src/sam_progmem.c b/boards/arm/samv7/same70-xplained/src/sam_progmem.c
index 5dfe73e..390868f 100644
--- a/boards/arm/samv7/same70-xplained/src/sam_progmem.c
+++ b/boards/arm/samv7/same70-xplained/src/sam_progmem.c
@@ -54,7 +54,7 @@
  * Private Types
  ****************************************************************************/
 
-#if defined(CONFIG_SAME70XPLAINED_PROGMEM_OTA_PARTITION)
+#if defined(CONFIG_SAMV7_PROGMEM_OTA_PARTITION)
 
 struct ota_partition_s
 {
@@ -69,7 +69,7 @@ struct ota_partition_s
  * Private Function Prototypes
  ****************************************************************************/
 
-#if defined(CONFIG_SAME70XPLAINED_PROGMEM_OTA_PARTITION)
+#if defined(CONFIG_SAMV7_PROGMEM_OTA_PARTITION)
 static struct mtd_dev_s *sam_progmem_alloc_mtdpart(uint32_t mtd_offset,
                                                    uint32_t mtd_size);
 static int init_ota_partitions(void);
@@ -81,23 +81,23 @@ static int init_ota_partitions(void);
 
 static FAR struct mtd_dev_s *g_samv7_progmem_mtd;
 
-#if defined(CONFIG_SAME70XPLAINED_PROGMEM_OTA_PARTITION)
+#if defined(CONFIG_SAMV7_PROGMEM_OTA_PARTITION)
 static const struct ota_partition_s g_ota_partition_table[] =
 {
   {
-    .offset  = CONFIG_SAME70XPLAINED_OTA_PRIMARY_SLOT_OFFSET,
-    .size    = CONFIG_SAME70XPLAINED_OTA_SLOT_SIZE,
-    .devpath = CONFIG_SAME70XPLAINED_OTA_PRIMARY_SLOT_DEVPATH
+    .offset  = CONFIG_SAMV7_OTA_PRIMARY_SLOT_OFFSET,
+    .size    = CONFIG_SAMV7_OTA_SLOT_SIZE,
+    .devpath = CONFIG_SAMV7_OTA_PRIMARY_SLOT_DEVPATH
   },
   {
-    .offset  = CONFIG_SAME70XPLAINED_OTA_SECONDARY_SLOT_OFFSET,
-    .size    = CONFIG_SAME70XPLAINED_OTA_SLOT_SIZE,
-    .devpath = CONFIG_SAME70XPLAINED_OTA_SECONDARY_SLOT_DEVPATH
+    .offset  = CONFIG_SAMV7_OTA_SECONDARY_SLOT_OFFSET,
+    .size    = CONFIG_SAMV7_OTA_SLOT_SIZE,
+    .devpath = CONFIG_SAMV7_OTA_SECONDARY_SLOT_DEVPATH
   },
   {
-    .offset  = CONFIG_SAME70XPLAINED_OTA_SCRATCH_OFFSET,
-    .size    = CONFIG_SAME70XPLAINED_OTA_SCRATCH_SIZE,
-    .devpath = CONFIG_SAME70XPLAINED_OTA_SCRATCH_DEVPATH
+    .offset  = CONFIG_SAMV7_OTA_SCRATCH_OFFSET,
+    .size    = CONFIG_SAMV7_OTA_SCRATCH_SIZE,
+    .devpath = CONFIG_SAMV7_OTA_SCRATCH_DEVPATH
   }
 };
 #endif
@@ -106,7 +106,7 @@ static const struct ota_partition_s g_ota_partition_table[] =
  * Private Functions
  ****************************************************************************/
 
-#if defined(CONFIG_SAME70XPLAINED_PROGMEM_OTA_PARTITION)
+#if defined(CONFIG_SAMV7_PROGMEM_OTA_PARTITION)
 
 /****************************************************************************
  * Name: sam_progmem_alloc_mtdpart
@@ -225,7 +225,7 @@ int sam_progmem_init(void)
       return -EFAULT;
     }
 
-#if defined(CONFIG_SAME70XPLAINED_PROGMEM_OTA_PARTITION)
+#if defined(CONFIG_SAMV7_PROGMEM_OTA_PARTITION)
   ret = init_ota_partitions();
   if (ret < 0)
     {
diff --git a/boards/arm/samv7/same70-xplained/tools/atmel_same70_xplained.cfg b/boards/arm/samv7/same70-xplained/tools/atmel_same70_xplained.cfg
deleted file mode 100644
index 068d6c2..0000000
--- a/boards/arm/samv7/same70-xplained/tools/atmel_same70_xplained.cfg
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# Atmel SAME70 Xplained evaluation kit.
-# http://www.atmel.com/tools/ATSAME70-XPLD.aspx
-#
-# Connect using the EDBG chip on the dev kit over USB
-
-source [find interface/cmsis-dap.cfg]
-
-set CHIPNAME atsame70q21
-
-source [find target/atsamv.cfg]
-
-reset_config srst_only
diff --git a/boards/arm/samv7/same70-xplained/tools/oocd.sh b/boards/arm/samv7/same70-xplained/tools/oocd.sh
deleted file mode 100755
index 8ed4a9d..0000000
--- a/boards/arm/samv7/same70-xplained/tools/oocd.sh
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/usr/bin/env bash
-#
-# See boards/atmel_same70_xplained.cfg/README.txt for information about
-# this file.
-
-TOPDIR=$1
-USAGE="$0 <TOPDIR> [-d]"
-if [ -z "${TOPDIR}" ]; then
-	echo "Missing argument"
-	echo $USAGE
-	exit 1
-fi
-
-# Assume that OpenOCD was installed and at /usr/local/bin.  Uncomment
-# the following to run directly from the build directory
-
-# OPENOCD_PATH="/home/OpenOCD/openocd/src"
-# OPENOCD_PATH="/usr/bin"
-OPENOCD_PATH="/usr/local/bin"
-
-# TARGET_PATH="/home/OpenOCD/openocd/tcl"
-# TARGET_PATH="/usr/share/openocd/scripts"
-TARGET_PATH="/usr/local/share/openocd/scripts"
-
-# Assume a Unix development environment.  Uncomment to use a Windows
-# like environment
-
-#OPENOCD_EXE=openocd.exe
-OPENOCD_EXE=openocd
-
-OPENOCD_CFG="${TOPDIR}/boards/arm/samv7/same70-xplained/tools/atmel_same70_xplained.cfg"
-OPENOCD_ARGS="-f ${OPENOCD_CFG} -s ${TARGET_PATH}"
-
-if [ "X$2" = "X-d" ]; then
-	OPENOCD_ARGS=$OPENOCD_ARGS" -d3"
-	set -x
-fi
-
-if [ ! -d ${OPENOCD_PATH} ]; then
-	echo "OpenOCD path does not exist: ${OPENOCD_PATH}"
-	exit 1
-fi
-if [ ! -x ${OPENOCD_PATH}/${OPENOCD_EXE} ]; then
-	echo "OpenOCD does not exist: ${OPENOCD_PATH}/${OPENOCD_EXE}"
-	exit 1
-fi
-if [ ! -f ${OPENOCD_CFG} ]; then
-	echo "OpenOCD config file does not exist: ${OPENOCD_CFG}"
-	exit 1
-fi
-
-echo "Starting OpenOCD"
-cd ${OPENOCD_PATH} || { echo "Failed to CD to ${OPENOCD_PATH}"; exit 1; }
-${OPENOCD_EXE} ${OPENOCD_ARGS} &
-echo "OpenOCD daemon started"
-ps -ef | grep openocd
-echo "In GDB: target remote localhost:3333"
diff --git a/boards/arm/samv7/samv71-xult/configs/knsh/Make.defs b/boards/arm/samv7/samv71-xult/configs/knsh/Make.defs
index 5edaf3c..615897d 100644
--- a/boards/arm/samv7/samv71-xult/configs/knsh/Make.defs
+++ b/boards/arm/samv7/samv71-xult/configs/knsh/Make.defs
@@ -18,57 +18,4 @@
 #
 ############################################################################
 
-include $(TOPDIR)/.config
-include $(TOPDIR)/tools/Config.mk
-include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs
-
-LDSCRIPT1 = memory.ld
-LDSCRIPT2 = kernel-space.ld
-
-ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
-  ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT1)}"
-  ARCHSCRIPT += -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT2)}"
-else
-  ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT1)
-  ARCHSCRIPT += -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT2)
-endif
-
-ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
-  ARCHOPTIMIZATION = -g
-endif
-
-ifneq ($(CONFIG_DEBUG_NOOPT),y)
-  ARCHOPTIMIZATION += $(MAXOPTIMIZATION)
-endif
-
-ARCHCFLAGS = -fno-builtin
-ARCHCXXFLAGS = -fno-builtin -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
-ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
-  LDMODULEFLAGS += -T "${shell cygpath -w $(TOPDIR)/libs/libc/modlib/gnu-elf.ld}"
-else
-  LDMODULEFLAGS += -T $(TOPDIR)/libs/libc/modlib/gnu-elf.ld
-endif
-
-ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
-  LDFLAGS += -g
-endif
+include $(TOPDIR)/boards/arm/samv7/common/scripts/protected.memory
diff --git a/boards/arm/samv7/samv71-xult/kernel/Makefile b/boards/arm/samv7/samv71-xult/kernel/Makefile
index bda98a6..721e861 100644
--- a/boards/arm/samv7/samv71-xult/kernel/Makefile
+++ b/boards/arm/samv7/samv71-xult/kernel/Makefile
@@ -31,16 +31,16 @@ ENTRYPT = $(patsubst "%",%,$(CONFIG_USER_ENTRYPOINT))
 ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
   # Windows-native toolchains
   USER_LIBPATHS = ${shell for path in $(USERLIBS); do dir=`dirname $(TOPDIR)$(DELIM)$$path`;echo "-L\"`cygpath -w $$dir`\"";done}
-  USER_LDSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld}"
-  USER_LDSCRIPT += -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)user-space.ld}"
+  USER_LDSCRIPT = -T "${shell cygpath -w $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)memory.ld}"
+  USER_LDSCRIPT += -T "${shell cygpath -w $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)user-space.ld}"
   USER_HEXFILE += "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx_user.hex}"
   USER_SRECFILE += "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx_user.srec}"
   USER_BINFILE += "${shell cygpath -w $(TOPDIR)$(DELIM)nuttx_user.bin}"
 else
   # Linux/Cygwin-native toolchain
   USER_LIBPATHS = $(addprefix -L$(TOPDIR)$(DELIM),$(dir $(USERLIBS)))
-  USER_LDSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld
-  USER_LDSCRIPT += -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)user-space.ld
+  USER_LDSCRIPT = -T$(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)memory.ld
+  USER_LDSCRIPT += -T$(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)user-space.ld
   USER_HEXFILE += "$(TOPDIR)$(DELIM)nuttx_user.hex"
   USER_SRECFILE += "$(TOPDIR)$(DELIM)nuttx_user.srec"
   USER_BINFILE += "$(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 2a008ad..81ea817 100644
--- a/boards/arm/samv7/samv71-xult/scripts/Make.defs
+++ b/boards/arm/samv7/samv71-xult/scripts/Make.defs
@@ -18,55 +18,4 @@
 #
 ############################################################################
 
-include $(TOPDIR)/.config
-include $(TOPDIR)/tools/Config.mk
-include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs
-
-LDSCRIPT_TEMPLATE = $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash.template.ld
-LDSCRIPT = samv7.ld
-
-ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
-  ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
-else
-  ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
-endif
-
-ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
-  ARCHOPTIMIZATION = -g
-endif
-
-ifneq ($(CONFIG_DEBUG_NOOPT),y)
-  ARCHOPTIMIZATION += $(MAXOPTIMIZATION)
-endif
-
-ARCHCFLAGS = -fno-builtin
-ARCHCXXFLAGS = -fno-builtin -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
-ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
-  LDMODULEFLAGS += -T "${shell cygpath -w $(TOPDIR)/libs/libc/modlib/gnu-elf.ld}"
-else
-  LDMODULEFLAGS += -T $(TOPDIR)/libs/libc/modlib/gnu-elf.ld
-endif
-
-ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
-  LDFLAGS += -g
-endif
+include $(TOPDIR)/boards/arm/samv7/common/scripts/flat.memory
diff --git a/boards/arm/samv7/samv71-xult/scripts/flash.template.ld b/boards/arm/samv7/samv71-xult/scripts/flash.template.ld
deleted file mode 100644
index 478fb82..0000000
--- a/boards/arm/samv7/samv71-xult/scripts/flash.template.ld
+++ /dev/null
@@ -1,119 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/samv71-xult/scripts/flash.template.ld
- *
- * 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 <nuttx/config.h>
-
-#define FLASH_START_ADDR        0x00400000
-
-#ifdef CONFIG_ARMV7M_DTCM
-#  define SRAM_START_ADDR       0x20000000
-#else
-#  define SRAM_START_ADDR       0x20400000
-#endif
-
-#define FLASH_OFFSET            0
-#define FLASH_IMG_SIZE          CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH
-
-MEMORY
-{
-  flash (rx) : ORIGIN = FLASH_START_ADDR + FLASH_OFFSET, LENGTH = FLASH_IMG_SIZE
-  sram (rwx) : ORIGIN = SRAM_START_ADDR, LENGTH = CONFIG_ARCH_CHIP_SAMV7_MEM_RAM
-}
-
-OUTPUT_ARCH(arm)
-EXTERN(_vectors)
-ENTRY(_stext)
-
-SECTIONS
-{
-    .text : {
-        _stext = ABSOLUTE(.);
-        *(.vectors)
-        *(.text .text.*)
-        *(.fixup)
-        *(.gnu.warning)
-        *(.rodata .rodata.*)
-        *(.gnu.linkonce.t.*)
-        *(.glue_7)
-        *(.glue_7t)
-        *(.got)
-        *(.gcc_except_table)
-        *(.gnu.linkonce.r.*)
-        _etext = ABSOLUTE(.);
-    } > flash
-
-    .init_section : {
-        _sinit = ABSOLUTE(.);
-        *(.init_array .init_array.*)
-        _einit = ABSOLUTE(.);
-    } > flash
-
-    .ARM.extab : {
-        *(.ARM.extab*)
-    } > flash
-
-    __exidx_start = ABSOLUTE(.);
-    .ARM.exidx : {
-        *(.ARM.exidx*)
-    } > flash
-    __exidx_end = ABSOLUTE(.);
-
-    _eronly = ABSOLUTE(.);
-
-    .data : {
-        _sdata = ABSOLUTE(.);
-        *(.data .data.*)
-        *(.gnu.linkonce.d.*)
-        CONSTRUCTORS
-        . = ALIGN(4);
-        _edata = ABSOLUTE(.);
-    } > sram AT > flash
-
-    .ramfunc ALIGN(4): {
-        _sramfuncs = ABSOLUTE(.);
-        *(.ramfunc  .ramfunc.*)
-        _eramfuncs = ABSOLUTE(.);
-    } > sram AT > flash
-
-    _framfuncs = LOADADDR(.ramfunc);
-
-    .bss : {
-        _sbss = ABSOLUTE(.);
-        *(.bss .bss.*)
-        *(.gnu.linkonce.b.*)
-        *(COMMON)
-        . = ALIGN(4);
-        _ebss = ABSOLUTE(.);
-    } > sram
-
-    /* Stabs debugging sections. */
-    .stab 0 : { *(.stab) }
-    .stabstr 0 : { *(.stabstr) }
-    .stab.excl 0 : { *(.stab.excl) }
-    .stab.exclstr 0 : { *(.stab.exclstr) }
-    .stab.index 0 : { *(.stab.index) }
-    .stab.indexstr 0 : { *(.stab.indexstr) }
-    .comment 0 : { *(.comment) }
-    .debug_abbrev 0 : { *(.debug_abbrev) }
-    .debug_info 0 : { *(.debug_info) }
-    .debug_line 0 : { *(.debug_line) }
-    .debug_pubnames 0 : { *(.debug_pubnames) }
-    .debug_aranges 0 : { *(.debug_aranges) }
-}
diff --git a/boards/arm/samv7/samv71-xult/src/Makefile b/boards/arm/samv7/samv71-xult/src/Make.defs
similarity index 88%
rename from boards/arm/samv7/samv71-xult/src/Makefile
rename to boards/arm/samv7/samv71-xult/src/Make.defs
index 7e23f3b..d273b77 100644
--- a/boards/arm/samv7/samv71-xult/src/Makefile
+++ b/boards/arm/samv7/samv71-xult/src/Make.defs
@@ -114,16 +114,18 @@ ifeq ($(CONFIG_LCD_ST7789),y)
 CSRCS += sam_st7789.c
 endif
 
-SCRIPTOUT = $(BOARD_DIR)$(DELIM)scripts$(DELIM)samv7.ld
+SCRIPTOUT = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)samv7.ld
 
 .PHONY = context distclean
 
 $(SCRIPTOUT): $(LDSCRIPT_TEMPLATE) $(CONFIGFILE)
-	$(Q) $(CC) -isystem $(TOPDIR)/include -I $(BOARD_DIR)$(DELIM)scripts -C -P -x c -E $(LDSCRIPT_TEMPLATE) -o $@
+	$(Q) $(CC) -isystem $(TOPDIR)/include -I $(BOARD_COMMON_DIR)$(DELIM)scripts -C -P -x c -E $(LDSCRIPT_TEMPLATE) -o $@
 
 context:: $(SCRIPTOUT)
 
 distclean::
 	$(call DELFILE, $(SCRIPTOUT))
 
-include $(TOPDIR)/boards/Board.mk
+DEPPATH += --dep-path board
+VPATH += :board
+CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)

[incubator-nuttx] 01/05: arch/arm/src/samv7/Kconfig: Define mem sizes

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 2dd5578d50b7c1f8f68e8655fbf061d285fde9e9
Author: Gerson Fernando Budke <na...@gmail.com>
AuthorDate: Sat Dec 4 10:34:39 2021 -0300

    arch/arm/src/samv7/Kconfig: Define mem sizes
    
    Current samv7 platform does not define SoC memories sizes. This define
    both internal flash and sram memories sizes and update all defconfig
    files.
    
    Signed-off-by: Gerson Fernando Budke <na...@gmail.com>
---
 arch/arm/src/samv7/Kconfig                         | 71 +++++++++++++++++-
 .../configs/mcuboot-confirm/defconfig              |  2 +
 .../configs/mcuboot-confirm/defconfig_debug        | 85 ----------------------
 .../same70-qmtech/configs/mcuboot-loader/defconfig |  2 +
 .../arm/samv7/same70-qmtech/configs/nsh/defconfig  |  2 +
 .../samv7/same70-xplained/configs/adc/defconfig    |  2 +
 .../configs/mcuboot-confirm/defconfig              |  3 +-
 .../configs/mcuboot-loader/defconfig               |  3 +-
 .../configs/mrf24j40-starhub/defconfig             |  2 +
 .../samv7/same70-xplained/configs/netnsh/defconfig |  2 +
 .../samv7/same70-xplained/configs/nsh/defconfig    |  2 +
 .../samv7/same70-xplained/configs/twm4nx/defconfig |  2 +
 .../arm/samv7/samv71-xult/configs/knsh/defconfig   |  2 +
 .../arm/samv7/samv71-xult/configs/module/defconfig |  2 +
 .../samv71-xult/configs/mrf24j40-starhub/defconfig |  2 +
 .../samv7/samv71-xult/configs/mxtxplnd/defconfig   |  2 +
 .../arm/samv7/samv71-xult/configs/netnsh/defconfig |  2 +
 boards/arm/samv7/samv71-xult/configs/nsh/defconfig |  2 +
 .../arm/samv7/samv71-xult/configs/nxwm/defconfig   |  2 +
 boards/arm/samv7/samv71-xult/configs/vnc/defconfig |  2 +
 .../arm/samv7/samv71-xult/configs/vnxwm/defconfig  |  2 +
 21 files changed, 108 insertions(+), 88 deletions(-)

diff --git a/arch/arm/src/samv7/Kconfig b/arch/arm/src/samv7/Kconfig
index 2f82223..4d57aa5 100644
--- a/arch/arm/src/samv7/Kconfig
+++ b/arch/arm/src/samv7/Kconfig
@@ -16,74 +16,110 @@ choice
 config ARCH_CHIP_SAME70Q19
 	bool "SAME70Q19"
 	select ARCH_CHIP_SAME70Q
+	select SAMV7_MEM_FLASH_512
+	select SAMV7_MEM_RAM_256
 
 config ARCH_CHIP_SAME70Q20
 	bool "SAME70Q20"
 	select ARCH_CHIP_SAME70Q
+	select SAMV7_MEM_FLASH_1024
+	select SAMV7_MEM_RAM_384
 
 config ARCH_CHIP_SAME70Q21
 	bool "SAME70Q21"
 	select ARCH_CHIP_SAME70Q
+	select SAMV7_MEM_FLASH_2048
+	select SAMV7_MEM_RAM_384
 
 config ARCH_CHIP_SAME70N19
 	bool "SAME70N19"
 	select ARCH_CHIP_SAME70N
+	select SAMV7_MEM_FLASH_512
+	select SAMV7_MEM_RAM_256
 
 config ARCH_CHIP_SAME70N20
 	bool "SAME70N20"
 	select ARCH_CHIP_SAME70N
+	select SAMV7_MEM_FLASH_1024
+	select SAMV7_MEM_RAM_384
 
 config ARCH_CHIP_SAME70N21
 	bool "SAME70N21"
 	select ARCH_CHIP_SAME70N
+	select SAMV7_MEM_FLASH_2048
+	select SAMV7_MEM_RAM_384
 
 config ARCH_CHIP_SAME70J19
 	bool "SAME70J10"
 	select ARCH_CHIP_SAME70J
+	select SAMV7_MEM_FLASH_512
+	select SAMV7_MEM_RAM_256
 
 config ARCH_CHIP_SAME70J20
 	bool "SAME70J20"
 	select ARCH_CHIP_SAME70J
+	select SAMV7_MEM_FLASH_1024
+	select SAMV7_MEM_RAM_384
 
 config ARCH_CHIP_SAME70J21
 	bool "SAME70J21"
 	select ARCH_CHIP_SAME70J
+	select SAMV7_MEM_FLASH_2048
+	select SAMV7_MEM_RAM_384
 
 config ARCH_CHIP_SAMV71Q19
 	bool "SAMV71Q19"
 	select ARCH_CHIP_SAMV71Q
+	select SAMV7_MEM_FLASH_512
+	select SAMV7_MEM_RAM_256
 
 config ARCH_CHIP_SAMV71Q20
 	bool "SAMV71Q20"
 	select ARCH_CHIP_SAMV71Q
+	select SAMV7_MEM_FLASH_1024
+	select SAMV7_MEM_RAM_384
 
 config ARCH_CHIP_SAMV71Q21
 	bool "SAMV71Q21"
 	select ARCH_CHIP_SAMV71Q
+	select SAMV7_MEM_FLASH_2048
+	select SAMV7_MEM_RAM_384
 
 config ARCH_CHIP_SAMV71N19
 	bool "SAMV71N19"
 	select ARCH_CHIP_SAMV71N
+	select SAMV7_MEM_FLASH_512
+	select SAMV7_MEM_RAM_256
 
 config ARCH_CHIP_SAMV71N20
 	bool "SAMV71N20"
 	select ARCH_CHIP_SAMV71N
+	select SAMV7_MEM_FLASH_1024
+	select SAMV7_MEM_RAM_384
 
 config ARCH_CHIP_SAMV71N21
 	bool "SAMV71N21"
 	select ARCH_CHIP_SAMV71N
+	select SAMV7_MEM_FLASH_2048
+	select SAMV7_MEM_RAM_384
 
 config ARCH_CHIP_SAMV71J19
 	bool "SAMV71J19"
 	select ARCH_CHIP_SAMV71J
+	select SAMV7_MEM_FLASH_512
+	select SAMV7_MEM_RAM_256
 
 config ARCH_CHIP_SAMV71J20
 	bool "SAMV71J20"
 	select ARCH_CHIP_SAMV71J
+	select SAMV7_MEM_FLASH_1024
+	select SAMV7_MEM_RAM_384
 
 config ARCH_CHIP_SAMV71J21
 	bool "SAMV71J21"
 	select ARCH_CHIP_SAMV71J
+	select SAMV7_MEM_FLASH_2048
+	select SAMV7_MEM_RAM_384
 
 endchoice # Atmel SAMV7 Chip Selection
 
@@ -188,6 +224,37 @@ config ARCH_CHIP_SAMV71J
 
 # Chip Capabilities
 
+config SAMV7_MEM_FLASH_512
+	bool
+	default n
+
+config SAMV7_MEM_FLASH_1024
+	bool
+	default n
+
+config SAMV7_MEM_FLASH_2048
+	bool
+	default n
+
+config ARCH_CHIP_SAMV7_MEM_FLASH
+	hex
+	default 0x80000  if SAMV7_MEM_FLASH_512
+	default 0x100000 if SAMV7_MEM_FLASH_1024
+	default 0x200000 if SAMV7_MEM_FLASH_2048
+
+config SAMV7_MEM_RAM_256
+	bool
+	default n
+
+config SAMV7_MEM_RAM_384
+	bool
+	default n
+
+config ARCH_CHIP_SAMV7_MEM_RAM
+	hex
+	default 0x40000 if SAMV7_MEM_RAM_256
+	default 0x60000 if SAMV7_MEM_RAM_384
+
 config SAMV7_MCAN
 	bool
 	default n
@@ -919,7 +986,9 @@ if SAMV7_PROGMEM
 
 config SAMV7_PROGMEM_NSECTORS
 	int "Number of 128KB sectors"
-	default 4
+	default 4  if SAMV7_MEM_FLASH_512
+	default 8  if SAMV7_MEM_FLASH_1024
+	default 16 if SAMV7_MEM_FLASH_2048
 	range 1 16
 	---help---
 		This is the number of 128KB FLASH sectors at the end of the program
diff --git a/boards/arm/samv7/same70-qmtech/configs/mcuboot-confirm/defconfig b/boards/arm/samv7/same70-qmtech/configs/mcuboot-confirm/defconfig
index 70187e8..d27f7b5 100644
--- a/boards/arm/samv7/same70-qmtech/configs/mcuboot-confirm/defconfig
+++ b/boards/arm/samv7/same70-qmtech/configs/mcuboot-confirm/defconfig
@@ -17,6 +17,8 @@ CONFIG_ARCH_CHIP_SAME70=y
 CONFIG_ARCH_CHIP_SAME70N19=y
 CONFIG_ARCH_CHIP_SAME70N=y
 CONFIG_ARCH_CHIP_SAMV7=y
+CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x80000
+CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x40000
 CONFIG_ARCH_INTERRUPTSTACK=2048
 CONFIG_ARCH_STACKDUMP=y
 CONFIG_ARMV7M_DCACHE=y
diff --git a/boards/arm/samv7/same70-qmtech/configs/mcuboot-confirm/defconfig_debug b/boards/arm/samv7/same70-qmtech/configs/mcuboot-confirm/defconfig_debug
deleted file mode 100644
index 2ca694e..0000000
--- a/boards/arm/samv7/same70-qmtech/configs/mcuboot-confirm/defconfig_debug
+++ /dev/null
@@ -1,85 +0,0 @@
-#
-# This file is autogenerated: PLEASE DO NOT EDIT IT.
-#
-# You can use "make menuconfig" to make any modifications to the installed .config file.
-# You can then do "make savedefconfig" to generate a new defconfig file that includes your
-# modifications.
-#
-# CONFIG_MMCSD_MMCSUPPORT is not set
-# CONFIG_MMCSD_SPI is not set
-# CONFIG_SAMV7_UART0 is not set
-# CONFIG_SAMV7_UART2 is not set
-# CONFIG_SAMV7_UART4 is not set
-CONFIG_ARCH="arm"
-CONFIG_ARCH_BOARD_CUSTOM=y
-CONFIG_ARCH_BOARD_CUSTOM_DIR="../autococo2-board"
-CONFIG_ARCH_BOARD_CUSTOM_DIR_RELPATH=y
-CONFIG_ARCH_BOARD_CUSTOM_NAME="ARCH_BOARD_AUTOCOCO2_BOARD"
-CONFIG_ARCH_CHIP="samv7"
-CONFIG_ARCH_CHIP_SAME70=y
-CONFIG_ARCH_CHIP_SAME70Q21=y
-CONFIG_ARCH_CHIP_SAME70Q=y
-CONFIG_ARCH_CHIP_SAMV7=y
-CONFIG_ARCH_INTERRUPTSTACK=2048
-CONFIG_ARCH_STACKDUMP=y
-CONFIG_ARMV7M_DCACHE=y
-CONFIG_ARMV7M_ICACHE=y
-CONFIG_ARMV7M_LAZYFPU=y
-CONFIG_AT24XX_ADDR=0x57
-CONFIG_AT24XX_EXTENDED=y
-CONFIG_AT24XX_EXTSIZE=160
-CONFIG_AT24XX_SIZE=2
-CONFIG_BOARD_LATE_INITIALIZE=y
-CONFIG_BOARD_LOOPSPERMSEC=51262
-CONFIG_BOOT_MCUBOOT=y
-CONFIG_BUILTIN=y
-CONFIG_DEBUG_FULLOPT=y
-CONFIG_DEBUG_SYMBOLS=y
-CONFIG_FAT_LCNAMES=y
-CONFIG_FAT_LFN=y
-CONFIG_FS_FAT=y
-CONFIG_FS_PROCFS=y
-CONFIG_I2CTOOL_MAXBUS=0
-CONFIG_INTELHEX_BINARY=y
-CONFIG_MCUBOOT_SLOT_CONFIRM_EXAMPLE=y
-CONFIG_MCUBOOT_VERSION="1a9c6d8495e4dbe7d02edf14bb8a9fa1d4e955c0"
-CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
-CONFIG_MMCSD_SDIO=y
-CONFIG_MTD=y
-CONFIG_MTD_AT24XX=y
-CONFIG_MTD_AT25=y
-CONFIG_MTD_BYTE_WRITE=y
-CONFIG_MTD_CONFIG=y
-CONFIG_MTD_PARTITION=y
-CONFIG_MTD_PROGMEM=y
-CONFIG_NSH_ARCHINIT=y
-CONFIG_NSH_BUILTIN_APPS=y
-CONFIG_NSH_FILEIOSIZE=512
-CONFIG_NSH_LINELEN=64
-CONFIG_NSH_READLINE=y
-CONFIG_PREALLOC_TIMERS=4
-CONFIG_RAM_SIZE=393216
-CONFIG_RAM_START=0x20400000
-CONFIG_RAW_BINARY=y
-CONFIG_RR_INTERVAL=200
-CONFIG_SAMV7_APP_FORMAT_MCUBOOT=y
-CONFIG_SAMV7_GPIOA_IRQ=y
-CONFIG_SAMV7_GPIOC_IRQ=y
-CONFIG_SAMV7_GPIO_IRQ=y
-CONFIG_SAMV7_HSMCI0=y
-CONFIG_SAMV7_PROGMEM=y
-CONFIG_SAMV7_PROGMEM_NSECTORS=16
-CONFIG_SAMV7_UART3=y
-CONFIG_SAMV7_XDMAC=y
-CONFIG_SCHED_HPWORK=y
-CONFIG_SCHED_WAITPID=y
-CONFIG_SDCLONE_DISABLE=y
-CONFIG_SDIO_BLOCKSETUP=y
-CONFIG_START_DAY=10
-CONFIG_START_MONTH=3
-CONFIG_START_YEAR=2014
-CONFIG_SYSTEM_I2CTOOL=y
-CONFIG_SYSTEM_NSH=y
-CONFIG_SYSTEM_RAMTEST=y
-CONFIG_UART3_SERIAL_CONSOLE=y
-CONFIG_USER_ENTRYPOINT="mcuboot_confirm_main"
diff --git a/boards/arm/samv7/same70-qmtech/configs/mcuboot-loader/defconfig b/boards/arm/samv7/same70-qmtech/configs/mcuboot-loader/defconfig
index b26ff05..9e15549 100644
--- a/boards/arm/samv7/same70-qmtech/configs/mcuboot-loader/defconfig
+++ b/boards/arm/samv7/same70-qmtech/configs/mcuboot-loader/defconfig
@@ -17,6 +17,8 @@ CONFIG_ARCH_CHIP_SAME70=y
 CONFIG_ARCH_CHIP_SAME70N19=y
 CONFIG_ARCH_CHIP_SAME70N=y
 CONFIG_ARCH_CHIP_SAMV7=y
+CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x80000
+CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x40000
 CONFIG_ARCH_INTERRUPTSTACK=2048
 CONFIG_ARCH_STACKDUMP=y
 CONFIG_ARMV7M_DCACHE=y
diff --git a/boards/arm/samv7/same70-qmtech/configs/nsh/defconfig b/boards/arm/samv7/same70-qmtech/configs/nsh/defconfig
index 626f378..bdc32fd 100644
--- a/boards/arm/samv7/same70-qmtech/configs/nsh/defconfig
+++ b/boards/arm/samv7/same70-qmtech/configs/nsh/defconfig
@@ -19,6 +19,8 @@ CONFIG_ARCH_CHIP_SAME70=y
 CONFIG_ARCH_CHIP_SAME70N19=y
 CONFIG_ARCH_CHIP_SAME70N=y
 CONFIG_ARCH_CHIP_SAMV7=y
+CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x80000
+CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x40000
 CONFIG_ARCH_INTERRUPTSTACK=2048
 CONFIG_ARCH_IRQBUTTONS=y
 CONFIG_ARCH_STACKDUMP=y
diff --git a/boards/arm/samv7/same70-xplained/configs/adc/defconfig b/boards/arm/samv7/same70-xplained/configs/adc/defconfig
index ac9934f..2a923d2 100644
--- a/boards/arm/samv7/same70-xplained/configs/adc/defconfig
+++ b/boards/arm/samv7/same70-xplained/configs/adc/defconfig
@@ -23,6 +23,8 @@ CONFIG_ARCH_CHIP_SAME70=y
 CONFIG_ARCH_CHIP_SAME70Q21=y
 CONFIG_ARCH_CHIP_SAME70Q=y
 CONFIG_ARCH_CHIP_SAMV7=y
+CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x200000
+CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x60000
 CONFIG_ARCH_INTERRUPTSTACK=2048
 CONFIG_ARCH_IRQBUTTONS=y
 CONFIG_ARCH_STACKDUMP=y
diff --git a/boards/arm/samv7/same70-xplained/configs/mcuboot-confirm/defconfig b/boards/arm/samv7/same70-xplained/configs/mcuboot-confirm/defconfig
index ff3ac8f..931a4d5 100644
--- a/boards/arm/samv7/same70-xplained/configs/mcuboot-confirm/defconfig
+++ b/boards/arm/samv7/same70-xplained/configs/mcuboot-confirm/defconfig
@@ -20,6 +20,8 @@ CONFIG_ARCH_CHIP_SAME70=y
 CONFIG_ARCH_CHIP_SAME70Q21=y
 CONFIG_ARCH_CHIP_SAME70Q=y
 CONFIG_ARCH_CHIP_SAMV7=y
+CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x200000
+CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x60000
 CONFIG_ARCH_INTERRUPTSTACK=2048
 CONFIG_ARCH_IRQBUTTONS=y
 CONFIG_ARCH_STACKDUMP=y
@@ -61,7 +63,6 @@ CONFIG_SAMV7_GPIOC_IRQ=y
 CONFIG_SAMV7_GPIO_IRQ=y
 CONFIG_SAMV7_HSMCI0=y
 CONFIG_SAMV7_PROGMEM=y
-CONFIG_SAMV7_PROGMEM_NSECTORS=16
 CONFIG_SAMV7_SDRAMC=y
 CONFIG_SAMV7_SDRAMSIZE=2097152
 CONFIG_SAMV7_TWIHS0=y
diff --git a/boards/arm/samv7/same70-xplained/configs/mcuboot-loader/defconfig b/boards/arm/samv7/same70-xplained/configs/mcuboot-loader/defconfig
index 1c332f6..86123ea 100644
--- a/boards/arm/samv7/same70-xplained/configs/mcuboot-loader/defconfig
+++ b/boards/arm/samv7/same70-xplained/configs/mcuboot-loader/defconfig
@@ -20,6 +20,8 @@ CONFIG_ARCH_CHIP_SAME70=y
 CONFIG_ARCH_CHIP_SAME70Q21=y
 CONFIG_ARCH_CHIP_SAME70Q=y
 CONFIG_ARCH_CHIP_SAMV7=y
+CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x200000
+CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x60000
 CONFIG_ARCH_INTERRUPTSTACK=2048
 CONFIG_ARCH_IRQBUTTONS=y
 CONFIG_ARCH_STACKDUMP=y
@@ -63,7 +65,6 @@ CONFIG_SAMV7_GPIOC_IRQ=y
 CONFIG_SAMV7_GPIO_IRQ=y
 CONFIG_SAMV7_HSMCI0=y
 CONFIG_SAMV7_PROGMEM=y
-CONFIG_SAMV7_PROGMEM_NSECTORS=16
 CONFIG_SAMV7_SDRAMC=y
 CONFIG_SAMV7_SDRAMSIZE=2097152
 CONFIG_SAMV7_TWIHS0=y
diff --git a/boards/arm/samv7/same70-xplained/configs/mrf24j40-starhub/defconfig b/boards/arm/samv7/same70-xplained/configs/mrf24j40-starhub/defconfig
index 758f15c..4c78cbd 100644
--- a/boards/arm/samv7/same70-xplained/configs/mrf24j40-starhub/defconfig
+++ b/boards/arm/samv7/same70-xplained/configs/mrf24j40-starhub/defconfig
@@ -19,6 +19,8 @@ CONFIG_ARCH_CHIP_SAME70=y
 CONFIG_ARCH_CHIP_SAME70Q21=y
 CONFIG_ARCH_CHIP_SAME70Q=y
 CONFIG_ARCH_CHIP_SAMV7=y
+CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x200000
+CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x60000
 CONFIG_ARCH_INTERRUPTSTACK=2048
 CONFIG_ARCH_IRQBUTTONS=y
 CONFIG_ARCH_STACKDUMP=y
diff --git a/boards/arm/samv7/same70-xplained/configs/netnsh/defconfig b/boards/arm/samv7/same70-xplained/configs/netnsh/defconfig
index cb39fac..6a32f32 100644
--- a/boards/arm/samv7/same70-xplained/configs/netnsh/defconfig
+++ b/boards/arm/samv7/same70-xplained/configs/netnsh/defconfig
@@ -20,6 +20,8 @@ CONFIG_ARCH_CHIP_SAME70=y
 CONFIG_ARCH_CHIP_SAME70Q21=y
 CONFIG_ARCH_CHIP_SAME70Q=y
 CONFIG_ARCH_CHIP_SAMV7=y
+CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x200000
+CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x60000
 CONFIG_ARCH_INTERRUPTSTACK=2048
 CONFIG_ARCH_IRQBUTTONS=y
 CONFIG_ARCH_STACKDUMP=y
diff --git a/boards/arm/samv7/same70-xplained/configs/nsh/defconfig b/boards/arm/samv7/same70-xplained/configs/nsh/defconfig
index 9c0c439..d4398b2 100644
--- a/boards/arm/samv7/same70-xplained/configs/nsh/defconfig
+++ b/boards/arm/samv7/same70-xplained/configs/nsh/defconfig
@@ -21,6 +21,8 @@ CONFIG_ARCH_CHIP_SAME70=y
 CONFIG_ARCH_CHIP_SAME70Q21=y
 CONFIG_ARCH_CHIP_SAME70Q=y
 CONFIG_ARCH_CHIP_SAMV7=y
+CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x200000
+CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x60000
 CONFIG_ARCH_INTERRUPTSTACK=2048
 CONFIG_ARCH_IRQBUTTONS=y
 CONFIG_ARCH_STACKDUMP=y
diff --git a/boards/arm/samv7/same70-xplained/configs/twm4nx/defconfig b/boards/arm/samv7/same70-xplained/configs/twm4nx/defconfig
index 207d192..1a232b2 100644
--- a/boards/arm/samv7/same70-xplained/configs/twm4nx/defconfig
+++ b/boards/arm/samv7/same70-xplained/configs/twm4nx/defconfig
@@ -21,6 +21,8 @@ CONFIG_ARCH_CHIP_SAME70=y
 CONFIG_ARCH_CHIP_SAME70Q21=y
 CONFIG_ARCH_CHIP_SAME70Q=y
 CONFIG_ARCH_CHIP_SAMV7=y
+CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x200000
+CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x60000
 CONFIG_ARCH_INTERRUPTSTACK=2048
 CONFIG_ARCH_IRQBUTTONS=y
 CONFIG_ARCH_STACKDUMP=y
diff --git a/boards/arm/samv7/samv71-xult/configs/knsh/defconfig b/boards/arm/samv7/samv71-xult/configs/knsh/defconfig
index 653afd7..3853923 100644
--- a/boards/arm/samv7/samv71-xult/configs/knsh/defconfig
+++ b/boards/arm/samv7/samv71-xult/configs/knsh/defconfig
@@ -21,6 +21,8 @@ CONFIG_ARCH_CHIP_SAMV71=y
 CONFIG_ARCH_CHIP_SAMV71Q21=y
 CONFIG_ARCH_CHIP_SAMV71Q=y
 CONFIG_ARCH_CHIP_SAMV7=y
+CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x200000
+CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x60000
 CONFIG_ARCH_INTERRUPTSTACK=2048
 CONFIG_ARCH_IRQBUTTONS=y
 CONFIG_ARCH_STACKDUMP=y
diff --git a/boards/arm/samv7/samv71-xult/configs/module/defconfig b/boards/arm/samv7/samv71-xult/configs/module/defconfig
index e63f537..062164c 100644
--- a/boards/arm/samv7/samv71-xult/configs/module/defconfig
+++ b/boards/arm/samv7/samv71-xult/configs/module/defconfig
@@ -18,6 +18,8 @@ CONFIG_ARCH_CHIP_SAMV71=y
 CONFIG_ARCH_CHIP_SAMV71Q21=y
 CONFIG_ARCH_CHIP_SAMV71Q=y
 CONFIG_ARCH_CHIP_SAMV7=y
+CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x200000
+CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x60000
 CONFIG_ARCH_INTERRUPTSTACK=2048
 CONFIG_ARCH_IRQBUTTONS=y
 CONFIG_ARCH_STACKDUMP=y
diff --git a/boards/arm/samv7/samv71-xult/configs/mrf24j40-starhub/defconfig b/boards/arm/samv7/samv71-xult/configs/mrf24j40-starhub/defconfig
index f57ca06..fe5eaf3 100644
--- a/boards/arm/samv7/samv71-xult/configs/mrf24j40-starhub/defconfig
+++ b/boards/arm/samv7/samv71-xult/configs/mrf24j40-starhub/defconfig
@@ -19,6 +19,8 @@ CONFIG_ARCH_CHIP_SAMV71=y
 CONFIG_ARCH_CHIP_SAMV71Q21=y
 CONFIG_ARCH_CHIP_SAMV71Q=y
 CONFIG_ARCH_CHIP_SAMV7=y
+CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x200000
+CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x60000
 CONFIG_ARCH_INTERRUPTSTACK=2048
 CONFIG_ARCH_IRQBUTTONS=y
 CONFIG_ARCH_STACKDUMP=y
diff --git a/boards/arm/samv7/samv71-xult/configs/mxtxplnd/defconfig b/boards/arm/samv7/samv71-xult/configs/mxtxplnd/defconfig
index dcef1cf..ef651b4 100644
--- a/boards/arm/samv7/samv71-xult/configs/mxtxplnd/defconfig
+++ b/boards/arm/samv7/samv71-xult/configs/mxtxplnd/defconfig
@@ -22,6 +22,8 @@ CONFIG_ARCH_CHIP_SAMV71=y
 CONFIG_ARCH_CHIP_SAMV71Q21=y
 CONFIG_ARCH_CHIP_SAMV71Q=y
 CONFIG_ARCH_CHIP_SAMV7=y
+CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x200000
+CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x60000
 CONFIG_ARCH_INTERRUPTSTACK=2048
 CONFIG_ARCH_IRQBUTTONS=y
 CONFIG_ARCH_STACKDUMP=y
diff --git a/boards/arm/samv7/samv71-xult/configs/netnsh/defconfig b/boards/arm/samv7/samv71-xult/configs/netnsh/defconfig
index f68c494..9436164 100644
--- a/boards/arm/samv7/samv71-xult/configs/netnsh/defconfig
+++ b/boards/arm/samv7/samv71-xult/configs/netnsh/defconfig
@@ -20,6 +20,8 @@ CONFIG_ARCH_CHIP_SAMV71=y
 CONFIG_ARCH_CHIP_SAMV71Q21=y
 CONFIG_ARCH_CHIP_SAMV71Q=y
 CONFIG_ARCH_CHIP_SAMV7=y
+CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x200000
+CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x60000
 CONFIG_ARCH_INTERRUPTSTACK=2048
 CONFIG_ARCH_IRQBUTTONS=y
 CONFIG_ARCH_STACKDUMP=y
diff --git a/boards/arm/samv7/samv71-xult/configs/nsh/defconfig b/boards/arm/samv7/samv71-xult/configs/nsh/defconfig
index 7245a07..b9fd9fd 100644
--- a/boards/arm/samv7/samv71-xult/configs/nsh/defconfig
+++ b/boards/arm/samv7/samv71-xult/configs/nsh/defconfig
@@ -21,6 +21,8 @@ CONFIG_ARCH_CHIP_SAMV71=y
 CONFIG_ARCH_CHIP_SAMV71Q21=y
 CONFIG_ARCH_CHIP_SAMV71Q=y
 CONFIG_ARCH_CHIP_SAMV7=y
+CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x200000
+CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x60000
 CONFIG_ARCH_INTERRUPTSTACK=2048
 CONFIG_ARCH_IRQBUTTONS=y
 CONFIG_ARCH_STACKDUMP=y
diff --git a/boards/arm/samv7/samv71-xult/configs/nxwm/defconfig b/boards/arm/samv7/samv71-xult/configs/nxwm/defconfig
index bd556b0..a471e49 100644
--- a/boards/arm/samv7/samv71-xult/configs/nxwm/defconfig
+++ b/boards/arm/samv7/samv71-xult/configs/nxwm/defconfig
@@ -24,6 +24,8 @@ CONFIG_ARCH_CHIP_SAMV71=y
 CONFIG_ARCH_CHIP_SAMV71Q21=y
 CONFIG_ARCH_CHIP_SAMV71Q=y
 CONFIG_ARCH_CHIP_SAMV7=y
+CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x200000
+CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x60000
 CONFIG_ARCH_INTERRUPTSTACK=2048
 CONFIG_ARCH_IRQBUTTONS=y
 CONFIG_ARCH_STACKDUMP=y
diff --git a/boards/arm/samv7/samv71-xult/configs/vnc/defconfig b/boards/arm/samv7/samv71-xult/configs/vnc/defconfig
index 29df32c..51b4128 100644
--- a/boards/arm/samv7/samv71-xult/configs/vnc/defconfig
+++ b/boards/arm/samv7/samv71-xult/configs/vnc/defconfig
@@ -21,6 +21,8 @@ CONFIG_ARCH_CHIP_SAMV71=y
 CONFIG_ARCH_CHIP_SAMV71Q21=y
 CONFIG_ARCH_CHIP_SAMV71Q=y
 CONFIG_ARCH_CHIP_SAMV7=y
+CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x200000
+CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x60000
 CONFIG_ARCH_INTERRUPTSTACK=2048
 CONFIG_ARCH_IRQBUTTONS=y
 CONFIG_ARCH_STACKDUMP=y
diff --git a/boards/arm/samv7/samv71-xult/configs/vnxwm/defconfig b/boards/arm/samv7/samv71-xult/configs/vnxwm/defconfig
index 695ccc9..b5daa79 100644
--- a/boards/arm/samv7/samv71-xult/configs/vnxwm/defconfig
+++ b/boards/arm/samv7/samv71-xult/configs/vnxwm/defconfig
@@ -21,6 +21,8 @@ CONFIG_ARCH_CHIP_SAMV71=y
 CONFIG_ARCH_CHIP_SAMV71Q21=y
 CONFIG_ARCH_CHIP_SAMV71Q=y
 CONFIG_ARCH_CHIP_SAMV7=y
+CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH=0x200000
+CONFIG_ARCH_CHIP_SAMV7_MEM_RAM=0x60000
 CONFIG_ARCH_INTERRUPTSTACK=2048
 CONFIG_ARCH_IRQBUTTONS=y
 CONFIG_ARCH_STACKDUMP=y

[incubator-nuttx] 02/05: boards/arm/samv7: Unify linker scripts

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 463fbfe975180e284108dd3adcca982d10b46dfe
Author: Gerson Fernando Budke <na...@gmail.com>
AuthorDate: Sat Dec 11 19:52:39 2021 -0300

    boards/arm/samv7: Unify linker scripts
    
    After define memory sizes for samv7 it is possible unify linker scripts.
    This add necessary changes to perform such operation.
    
    Signed-off-by: Gerson Fernando Budke <na...@gmail.com>
---
 boards/arm/samv7/same70-qmtech/.gitignore          |   1 +
 boards/arm/samv7/same70-qmtech/scripts/Make.defs   |  17 +--
 .../scripts/flash-dtcm-mcuboot-loader.ld           | 117 ---------------------
 .../arm/samv7/same70-qmtech/scripts/flash-dtcm.ld  | 117 ---------------------
 .../scripts/flash-sram-mcuboot-loader.ld           | 114 --------------------
 .../arm/samv7/same70-qmtech/scripts/flash-sram.ld  | 114 --------------------
 ...flash-sram-mcuboot-app.ld => flash.template.ld} |  36 +++++--
 boards/arm/samv7/same70-qmtech/src/Makefile        |  12 +++
 boards/arm/samv7/same70-xplained/.gitignore        |   1 +
 boards/arm/samv7/same70-xplained/scripts/Make.defs |  17 +--
 .../scripts/flash-dtcm-mcuboot-app.ld              | 117 ---------------------
 .../scripts/flash-dtcm-mcuboot-loader.ld           | 117 ---------------------
 .../samv7/same70-xplained/scripts/flash-dtcm.ld    | 117 ---------------------
 .../scripts/flash-sram-mcuboot-app.ld              | 114 --------------------
 .../scripts/flash-sram-mcuboot-loader.ld           | 114 --------------------
 .../scripts/flash.template.ld}                     |  39 ++++---
 boards/arm/samv7/same70-xplained/src/Makefile      |  12 +++
 boards/arm/samv7/samv71-xult/.gitignore            |   1 +
 boards/arm/samv7/samv71-xult/scripts/Make.defs     |   7 +-
 boards/arm/samv7/samv71-xult/scripts/flash-dtcm.ld | 117 ---------------------
 boards/arm/samv7/samv71-xult/scripts/flash-sram.ld | 114 --------------------
 .../scripts/flash.template.ld}                     |  25 +++--
 boards/arm/samv7/samv71-xult/src/Makefile          |  12 +++
 23 files changed, 112 insertions(+), 1340 deletions(-)

diff --git a/boards/arm/samv7/same70-qmtech/.gitignore b/boards/arm/samv7/same70-qmtech/.gitignore
new file mode 100644
index 0000000..a5638cb
--- /dev/null
+++ b/boards/arm/samv7/same70-qmtech/.gitignore
@@ -0,0 +1 @@
+/scripts/samv7.ld
diff --git a/boards/arm/samv7/same70-qmtech/scripts/Make.defs b/boards/arm/samv7/same70-qmtech/scripts/Make.defs
index 2927cfc..8a764e6 100644
--- a/boards/arm/samv7/same70-qmtech/scripts/Make.defs
+++ b/boards/arm/samv7/same70-qmtech/scripts/Make.defs
@@ -22,21 +22,8 @@ include $(TOPDIR)/.config
 include $(TOPDIR)/tools/Config.mk
 include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs
 
-ifeq ($(CONFIG_ARMV7M_DTCM),y)
-LDSCRIPT_PREFIX = flash-dtcm
-else
-LDSCRIPT_PREFIX = flash-sram
-endif
-
-ifeq ($(CONFIG_SAME70QMTECH_FORMAT_MCUBOOT),y)
-  ifeq ($(CONFIG_SAME70QMTECH_MCUBOOT_BOOTLOADER),y)
-    LDSCRIPT = $(LDSCRIPT_PREFIX)-mcuboot-loader.ld
-  else
-    LDSCRIPT = $(LDSCRIPT_PREFIX)-mcuboot-app.ld
-  endif
-else
-  LDSCRIPT = $(LDSCRIPT_PREFIX).ld
-endif
+LDSCRIPT_TEMPLATE = $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash.template.ld
+LDSCRIPT = samv7.ld
 
 ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
   ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
diff --git a/boards/arm/samv7/same70-qmtech/scripts/flash-dtcm-mcuboot-loader.ld b/boards/arm/samv7/same70-qmtech/scripts/flash-dtcm-mcuboot-loader.ld
deleted file mode 100644
index 542e879..0000000
--- a/boards/arm/samv7/same70-qmtech/scripts/flash-dtcm-mcuboot-loader.ld
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/same70-qmtech/scripts/flash-dtcm-mcuboot-loader.ld
- *
- * 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.
- *
- ****************************************************************************/
-
-/* The SAME70N19 has 512Kb of FLASH beginning at address 0x0040:0000 and
- * 256Kb of SRAM beginining at 0x2040: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
- * the 0x0400:0000 address range (Assuming that ITCM is not enable).
- *
- * NOTE: that the DTCM address of 0x2000:0000 is used for SRAM.  If DTCM is
- * disabled, then the accesses will actually occur on the AHB bus.
- */
-
-MEMORY
-{
-  flash (rx) : ORIGIN = 0x00400000, LENGTH = 128K
-  sram (rwx) : ORIGIN = 0x20000000, LENGTH = 256K
-}
-
-OUTPUT_ARCH(arm)
-EXTERN(_vectors)
-ENTRY(_stext)
-
-SECTIONS
-{
-    .text : {
-        _stext = ABSOLUTE(.);
-        *(.vectors)
-        *(.text .text.*)
-        *(.fixup)
-        *(.gnu.warning)
-        *(.rodata .rodata.*)
-        *(.gnu.linkonce.t.*)
-        *(.glue_7)
-        *(.glue_7t)
-        *(.got)
-        *(.gcc_except_table)
-        *(.gnu.linkonce.r.*)
-        _etext = ABSOLUTE(.);
-    } > flash
-
-    .init_section : {
-        _sinit = ABSOLUTE(.);
-        *(.init_array .init_array.*)
-        _einit = ABSOLUTE(.);
-    } > flash
-
-    .ARM.extab : {
-        *(.ARM.extab*)
-    } > flash
-
-    __exidx_start = ABSOLUTE(.);
-    .ARM.exidx : {
-        *(.ARM.exidx*)
-    } > flash
-    __exidx_end = ABSOLUTE(.);
-
-    _eronly = ABSOLUTE(.);
-
-    .data : {
-        _sdata = ABSOLUTE(.);
-        *(.data .data.*)
-        *(.gnu.linkonce.d.*)
-        CONSTRUCTORS
-        . = ALIGN(4);
-        _edata = ABSOLUTE(.);
-    } > sram AT > flash
-
-    .ramfunc ALIGN(4): {
-        _sramfuncs = ABSOLUTE(.);
-        *(.ramfunc  .ramfunc.*)
-        _eramfuncs = ABSOLUTE(.);
-    } > sram AT > flash
-
-    _framfuncs = LOADADDR(.ramfunc);
-
-    .bss : {
-        _sbss = ABSOLUTE(.);
-        *(.bss .bss.*)
-        *(.gnu.linkonce.b.*)
-        *(COMMON)
-        . = ALIGN(4);
-        _ebss = ABSOLUTE(.);
-    } > sram
-
-    /* Stabs debugging sections. */
-    .stab 0 : { *(.stab) }
-    .stabstr 0 : { *(.stabstr) }
-    .stab.excl 0 : { *(.stab.excl) }
-    .stab.exclstr 0 : { *(.stab.exclstr) }
-    .stab.index 0 : { *(.stab.index) }
-    .stab.indexstr 0 : { *(.stab.indexstr) }
-    .comment 0 : { *(.comment) }
-    .debug_abbrev 0 : { *(.debug_abbrev) }
-    .debug_info 0 : { *(.debug_info) }
-    .debug_line 0 : { *(.debug_line) }
-    .debug_pubnames 0 : { *(.debug_pubnames) }
-    .debug_aranges 0 : { *(.debug_aranges) }
-}
diff --git a/boards/arm/samv7/same70-qmtech/scripts/flash-dtcm.ld b/boards/arm/samv7/same70-qmtech/scripts/flash-dtcm.ld
deleted file mode 100644
index b163a36..0000000
--- a/boards/arm/samv7/same70-qmtech/scripts/flash-dtcm.ld
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/same70-qmtech/scripts/flash-dtcm.ld
- *
- * 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.
- *
- ****************************************************************************/
-
-/* The SAME70N19 has 512Kb of FLASH beginning at address 0x0040:0000 and
- * 256Kb of SRAM beginining at 0x2040: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
- * the 0x0400:0000 address range (Assuming that ITCM is not enable).
- *
- * NOTE: that the DTCM address of 0x2000:0000 is used for SRAM.  If DTCM is
- * disabled, then the accesses will actually occur on the AHB bus.
- */
-
-MEMORY
-{
-  flash (rx) : ORIGIN = 0x00400000, LENGTH = 512K
-  sram (rwx) : ORIGIN = 0x20000000, LENGTH = 256K
-}
-
-OUTPUT_ARCH(arm)
-EXTERN(_vectors)
-ENTRY(_stext)
-
-SECTIONS
-{
-    .text : {
-        _stext = ABSOLUTE(.);
-        *(.vectors)
-        *(.text .text.*)
-        *(.fixup)
-        *(.gnu.warning)
-        *(.rodata .rodata.*)
-        *(.gnu.linkonce.t.*)
-        *(.glue_7)
-        *(.glue_7t)
-        *(.got)
-        *(.gcc_except_table)
-        *(.gnu.linkonce.r.*)
-        _etext = ABSOLUTE(.);
-    } > flash
-
-    .init_section : {
-        _sinit = ABSOLUTE(.);
-        *(.init_array .init_array.*)
-        _einit = ABSOLUTE(.);
-    } > flash
-
-    .ARM.extab : {
-        *(.ARM.extab*)
-    } > flash
-
-    __exidx_start = ABSOLUTE(.);
-    .ARM.exidx : {
-        *(.ARM.exidx*)
-    } > flash
-    __exidx_end = ABSOLUTE(.);
-
-    _eronly = ABSOLUTE(.);
-
-    .data : {
-        _sdata = ABSOLUTE(.);
-        *(.data .data.*)
-        *(.gnu.linkonce.d.*)
-        CONSTRUCTORS
-        . = ALIGN(4);
-        _edata = ABSOLUTE(.);
-    } > sram AT > flash
-
-    .ramfunc ALIGN(4): {
-        _sramfuncs = ABSOLUTE(.);
-        *(.ramfunc  .ramfunc.*)
-        _eramfuncs = ABSOLUTE(.);
-    } > sram AT > flash
-
-    _framfuncs = LOADADDR(.ramfunc);
-
-    .bss : {
-        _sbss = ABSOLUTE(.);
-        *(.bss .bss.*)
-        *(.gnu.linkonce.b.*)
-        *(COMMON)
-        . = ALIGN(4);
-        _ebss = ABSOLUTE(.);
-    } > sram
-
-    /* Stabs debugging sections. */
-    .stab 0 : { *(.stab) }
-    .stabstr 0 : { *(.stabstr) }
-    .stab.excl 0 : { *(.stab.excl) }
-    .stab.exclstr 0 : { *(.stab.exclstr) }
-    .stab.index 0 : { *(.stab.index) }
-    .stab.indexstr 0 : { *(.stab.indexstr) }
-    .comment 0 : { *(.comment) }
-    .debug_abbrev 0 : { *(.debug_abbrev) }
-    .debug_info 0 : { *(.debug_info) }
-    .debug_line 0 : { *(.debug_line) }
-    .debug_pubnames 0 : { *(.debug_pubnames) }
-    .debug_aranges 0 : { *(.debug_aranges) }
-}
diff --git a/boards/arm/samv7/same70-qmtech/scripts/flash-sram-mcuboot-loader.ld b/boards/arm/samv7/same70-qmtech/scripts/flash-sram-mcuboot-loader.ld
deleted file mode 100644
index 1f2dca3..0000000
--- a/boards/arm/samv7/same70-qmtech/scripts/flash-sram-mcuboot-loader.ld
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/same70-qmtech/scripts/flash-sram-mcuboot-loader.ld
- *
- * 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.
- *
- ****************************************************************************/
-
-/* The SAME70N19 has 512Kb of FLASH beginning at address 0x0040:0000 and
- * 256Kb of SRAM beginining at 0x2040: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
- * the 0x0400:0000 address range (Assuming that ITCM is not enable).
- */
-
-MEMORY
-{
-  flash (rx) : ORIGIN = 0x00400000, LENGTH = 128K
-  sram (rwx) : ORIGIN = 0x20400000, LENGTH = 256K
-}
-
-OUTPUT_ARCH(arm)
-EXTERN(_vectors)
-ENTRY(_stext)
-
-SECTIONS
-{
-    .text : {
-        _stext = ABSOLUTE(.);
-        *(.vectors)
-        *(.text .text.*)
-        *(.fixup)
-        *(.gnu.warning)
-        *(.rodata .rodata.*)
-        *(.gnu.linkonce.t.*)
-        *(.glue_7)
-        *(.glue_7t)
-        *(.got)
-        *(.gcc_except_table)
-        *(.gnu.linkonce.r.*)
-        _etext = ABSOLUTE(.);
-    } > flash
-
-    .init_section : {
-        _sinit = ABSOLUTE(.);
-        *(.init_array .init_array.*)
-        _einit = ABSOLUTE(.);
-    } > flash
-
-    .ARM.extab : {
-        *(.ARM.extab*)
-    } > flash
-
-    __exidx_start = ABSOLUTE(.);
-    .ARM.exidx : {
-        *(.ARM.exidx*)
-    } > flash
-    __exidx_end = ABSOLUTE(.);
-
-    _eronly = ABSOLUTE(.);
-
-    .data : {
-        _sdata = ABSOLUTE(.);
-        *(.data .data.*)
-        *(.gnu.linkonce.d.*)
-        CONSTRUCTORS
-        . = ALIGN(4);
-        _edata = ABSOLUTE(.);
-    } > sram AT > flash
-
-    .ramfunc ALIGN(4): {
-        _sramfuncs = ABSOLUTE(.);
-        *(.ramfunc  .ramfunc.*)
-        _eramfuncs = ABSOLUTE(.);
-    } > sram AT > flash
-
-    _framfuncs = LOADADDR(.ramfunc);
-
-    .bss : {
-        _sbss = ABSOLUTE(.);
-        *(.bss .bss.*)
-        *(.gnu.linkonce.b.*)
-        *(COMMON)
-        . = ALIGN(4);
-        _ebss = ABSOLUTE(.);
-    } > sram
-
-    /* Stabs debugging sections. */
-    .stab 0 : { *(.stab) }
-    .stabstr 0 : { *(.stabstr) }
-    .stab.excl 0 : { *(.stab.excl) }
-    .stab.exclstr 0 : { *(.stab.exclstr) }
-    .stab.index 0 : { *(.stab.index) }
-    .stab.indexstr 0 : { *(.stab.indexstr) }
-    .comment 0 : { *(.comment) }
-    .debug_abbrev 0 : { *(.debug_abbrev) }
-    .debug_info 0 : { *(.debug_info) }
-    .debug_line 0 : { *(.debug_line) }
-    .debug_pubnames 0 : { *(.debug_pubnames) }
-    .debug_aranges 0 : { *(.debug_aranges) }
-}
diff --git a/boards/arm/samv7/same70-qmtech/scripts/flash-sram.ld b/boards/arm/samv7/same70-qmtech/scripts/flash-sram.ld
deleted file mode 100644
index 3404912..0000000
--- a/boards/arm/samv7/same70-qmtech/scripts/flash-sram.ld
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/same70-qmtech/scripts/flash-sram.ld
- *
- * 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.
- *
- ****************************************************************************/
-
-/* The SAME70N19 has 512Kb of FLASH beginning at address 0x0040:0000 and
- * 256Kb of SRAM beginining at 0x2040: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
- * the 0x0400:0000 address range (Assuming that ITCM is not enable).
- */
-
-MEMORY
-{
-  flash (rx) : ORIGIN = 0x00400000, LENGTH = 512K
-  sram (rwx) : ORIGIN = 0x20400000, LENGTH = 256K
-}
-
-OUTPUT_ARCH(arm)
-EXTERN(_vectors)
-ENTRY(_stext)
-
-SECTIONS
-{
-    .text : {
-        _stext = ABSOLUTE(.);
-        *(.vectors)
-        *(.text .text.*)
-        *(.fixup)
-        *(.gnu.warning)
-        *(.rodata .rodata.*)
-        *(.gnu.linkonce.t.*)
-        *(.glue_7)
-        *(.glue_7t)
-        *(.got)
-        *(.gcc_except_table)
-        *(.gnu.linkonce.r.*)
-        _etext = ABSOLUTE(.);
-    } > flash
-
-    .init_section : {
-        _sinit = ABSOLUTE(.);
-        *(.init_array .init_array.*)
-        _einit = ABSOLUTE(.);
-    } > flash
-
-    .ARM.extab : {
-        *(.ARM.extab*)
-    } > flash
-
-    __exidx_start = ABSOLUTE(.);
-    .ARM.exidx : {
-        *(.ARM.exidx*)
-    } > flash
-    __exidx_end = ABSOLUTE(.);
-
-    _eronly = ABSOLUTE(.);
-
-    .data : {
-        _sdata = ABSOLUTE(.);
-        *(.data .data.*)
-        *(.gnu.linkonce.d.*)
-        CONSTRUCTORS
-        . = ALIGN(4);
-        _edata = ABSOLUTE(.);
-    } > sram AT > flash
-
-    .ramfunc ALIGN(4): {
-        _sramfuncs = ABSOLUTE(.);
-        *(.ramfunc  .ramfunc.*)
-        _eramfuncs = ABSOLUTE(.);
-    } > sram AT > flash
-
-    _framfuncs = LOADADDR(.ramfunc);
-
-    .bss : {
-        _sbss = ABSOLUTE(.);
-        *(.bss .bss.*)
-        *(.gnu.linkonce.b.*)
-        *(COMMON)
-        . = ALIGN(4);
-        _ebss = ABSOLUTE(.);
-    } > sram
-
-    /* Stabs debugging sections. */
-    .stab 0 : { *(.stab) }
-    .stabstr 0 : { *(.stabstr) }
-    .stab.excl 0 : { *(.stab.excl) }
-    .stab.exclstr 0 : { *(.stab.exclstr) }
-    .stab.index 0 : { *(.stab.index) }
-    .stab.indexstr 0 : { *(.stab.indexstr) }
-    .comment 0 : { *(.comment) }
-    .debug_abbrev 0 : { *(.debug_abbrev) }
-    .debug_info 0 : { *(.debug_info) }
-    .debug_line 0 : { *(.debug_line) }
-    .debug_pubnames 0 : { *(.debug_pubnames) }
-    .debug_aranges 0 : { *(.debug_aranges) }
-}
diff --git a/boards/arm/samv7/same70-qmtech/scripts/flash-sram-mcuboot-app.ld b/boards/arm/samv7/same70-qmtech/scripts/flash.template.ld
similarity index 74%
rename from boards/arm/samv7/same70-qmtech/scripts/flash-sram-mcuboot-app.ld
rename to boards/arm/samv7/same70-qmtech/scripts/flash.template.ld
index 3449899..f280071 100644
--- a/boards/arm/samv7/same70-qmtech/scripts/flash-sram-mcuboot-app.ld
+++ b/boards/arm/samv7/same70-qmtech/scripts/flash.template.ld
@@ -1,5 +1,5 @@
 /****************************************************************************
- * boards/arm/samv7/same70-qmtech/scripts/flash-sram-mcuboot-app.ld
+ * boards/arm/samv7/same70-qmtech/scripts/flash.template.ld
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -18,18 +18,34 @@
  *
  ****************************************************************************/
 
-/* The SAME70N19 has 512Kb of FLASH beginning at address 0x0040:0000 and
- * 256Kb of SRAM beginining at 0x2040: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
- * the 0x0400:0000 address range (Assuming that ITCM is not enable).
- */
+#include <nuttx/config.h>
+
+#define FLASH_START_ADDR        0x00400000
+
+#ifdef CONFIG_ARMV7M_DTCM
+#  define SRAM_START_ADDR       0x20000000
+#else
+#  define SRAM_START_ADDR       0x20400000
+#endif
+
+#ifdef CONFIG_SAME70QMTECH_FORMAT_MCUBOOT
+#  define MCUBOOT_HEADER_SIZE   0x200
+#  ifdef CONFIG_BOARDCTL_BOOT_IMAGE
+#    define FLASH_OFFSET        0
+#    define FLASH_IMG_SIZE      CONFIG_SAME70QMTECH_OTA_PRIMARY_SLOT_OFFSET
+#  else
+#    define FLASH_OFFSET        (CONFIG_SAME70QMTECH_OTA_PRIMARY_SLOT_OFFSET + MCUBOOT_HEADER_SIZE)
+#    define FLASH_IMG_SIZE      (CONFIG_SAME70QMTECH_OTA_SLOT_SIZE - MCUBOOT_HEADER_SIZE)
+#  endif
+#else
+#  define FLASH_OFFSET          0
+#  define FLASH_IMG_SIZE        CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH
+#endif
 
 MEMORY
 {
-  flash (rx) : ORIGIN = 0x00420200, LENGTH = 160K - 0x200
-  sram (rwx) : ORIGIN = 0x20400000, LENGTH = 256K
+  flash (rx) : ORIGIN = FLASH_START_ADDR + FLASH_OFFSET, LENGTH = FLASH_IMG_SIZE
+  sram (rwx) : ORIGIN = SRAM_START_ADDR, LENGTH = CONFIG_ARCH_CHIP_SAMV7_MEM_RAM
 }
 
 OUTPUT_ARCH(arm)
diff --git a/boards/arm/samv7/same70-qmtech/src/Makefile b/boards/arm/samv7/same70-qmtech/src/Makefile
index 94b43b7..8783c64 100644
--- a/boards/arm/samv7/same70-qmtech/src/Makefile
+++ b/boards/arm/samv7/same70-qmtech/src/Makefile
@@ -68,4 +68,16 @@ ifneq (,$(findstring y,$(CONFIG_SAMV7_DAC0) $(CONFIG_SAMV7_DAC1)))
 CSRCS += sam_dac.c
 endif
 
+SCRIPTOUT = $(BOARD_DIR)$(DELIM)scripts$(DELIM)samv7.ld
+
+.PHONY = context distclean
+
+$(SCRIPTOUT): $(LDSCRIPT_TEMPLATE) $(CONFIGFILE)
+	$(Q) $(CC) -isystem $(TOPDIR)/include -I $(BOARD_DIR)$(DELIM)scripts -C -P -x c -E $(LDSCRIPT_TEMPLATE) -o $@
+
+context:: $(SCRIPTOUT)
+
+distclean::
+	$(call DELFILE, $(SCRIPTOUT))
+
 include $(TOPDIR)/boards/Board.mk
diff --git a/boards/arm/samv7/same70-xplained/.gitignore b/boards/arm/samv7/same70-xplained/.gitignore
new file mode 100644
index 0000000..a5638cb
--- /dev/null
+++ b/boards/arm/samv7/same70-xplained/.gitignore
@@ -0,0 +1 @@
+/scripts/samv7.ld
diff --git a/boards/arm/samv7/same70-xplained/scripts/Make.defs b/boards/arm/samv7/same70-xplained/scripts/Make.defs
index 7957c99..1c6279f 100644
--- a/boards/arm/samv7/same70-xplained/scripts/Make.defs
+++ b/boards/arm/samv7/same70-xplained/scripts/Make.defs
@@ -22,21 +22,8 @@ include $(TOPDIR)/.config
 include $(TOPDIR)/tools/Config.mk
 include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs
 
-ifeq ($(CONFIG_ARMV7M_DTCM),y)
-LDSCRIPT_PREFIX = flash-dtcm
-else
-LDSCRIPT_PREFIX = flash-sram
-endif
-
-ifeq ($(CONFIG_SAME70XPLAINED_FORMAT_MCUBOOT),y)
-  ifeq ($(CONFIG_SAME70XPLAINED_MCUBOOT_BOOTLOADER),y)
-    LDSCRIPT = $(LDSCRIPT_PREFIX)-mcuboot-loader.ld
-  else
-    LDSCRIPT = $(LDSCRIPT_PREFIX)-mcuboot-app.ld
-  endif
-else
-  LDSCRIPT = $(LDSCRIPT_PREFIX).ld
-endif
+LDSCRIPT_TEMPLATE = $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash.template.ld
+LDSCRIPT = samv7.ld
 
 ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
   ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
diff --git a/boards/arm/samv7/same70-xplained/scripts/flash-dtcm-mcuboot-app.ld b/boards/arm/samv7/same70-xplained/scripts/flash-dtcm-mcuboot-app.ld
deleted file mode 100644
index d38c7ff..0000000
--- a/boards/arm/samv7/same70-xplained/scripts/flash-dtcm-mcuboot-app.ld
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/same70-xplained/scripts/flash-dtcm-mcuboot-app.ld
- *
- * 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.
- *
- ****************************************************************************/
-
-/* The SAME70Q21 has 2048Kb of FLASH beginning at address 0x0040:0000 and
- * 384Kb of SRAM beginining at 0x2040: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
- * the 0x0400:0000 address range (Assuming that ITCM is not enable).
- *
- * NOTE: that the DTCM address of 0x2000:0000 is used for SRAM.  If DTCM is
- * disabled, then the accesses will actually occur on the AHB bus.
- */
-
-MEMORY
-{
-  flash (rx) : ORIGIN = 0x00420200, LENGTH = 896K - 0x200
-  sram (rwx) : ORIGIN = 0x20000000, LENGTH = 384K
-}
-
-OUTPUT_ARCH(arm)
-EXTERN(_vectors)
-ENTRY(_stext)
-
-SECTIONS
-{
-    .text : {
-        _stext = ABSOLUTE(.);
-        *(.vectors)
-        *(.text .text.*)
-        *(.fixup)
-        *(.gnu.warning)
-        *(.rodata .rodata.*)
-        *(.gnu.linkonce.t.*)
-        *(.glue_7)
-        *(.glue_7t)
-        *(.got)
-        *(.gcc_except_table)
-        *(.gnu.linkonce.r.*)
-        _etext = ABSOLUTE(.);
-    } > flash
-
-    .init_section : {
-        _sinit = ABSOLUTE(.);
-        *(.init_array .init_array.*)
-        _einit = ABSOLUTE(.);
-    } > flash
-
-    .ARM.extab : {
-        *(.ARM.extab*)
-    } > flash
-
-    __exidx_start = ABSOLUTE(.);
-    .ARM.exidx : {
-        *(.ARM.exidx*)
-    } > flash
-    __exidx_end = ABSOLUTE(.);
-
-    _eronly = ABSOLUTE(.);
-
-    .data : {
-        _sdata = ABSOLUTE(.);
-        *(.data .data.*)
-        *(.gnu.linkonce.d.*)
-        CONSTRUCTORS
-        . = ALIGN(4);
-        _edata = ABSOLUTE(.);
-    } > sram AT > flash
-
-    .ramfunc ALIGN(4): {
-        _sramfuncs = ABSOLUTE(.);
-        *(.ramfunc  .ramfunc.*)
-        _eramfuncs = ABSOLUTE(.);
-    } > sram AT > flash
-
-    _framfuncs = LOADADDR(.ramfunc);
-
-    .bss : {
-        _sbss = ABSOLUTE(.);
-        *(.bss .bss.*)
-        *(.gnu.linkonce.b.*)
-        *(COMMON)
-        . = ALIGN(4);
-        _ebss = ABSOLUTE(.);
-    } > sram
-
-    /* Stabs debugging sections. */
-    .stab 0 : { *(.stab) }
-    .stabstr 0 : { *(.stabstr) }
-    .stab.excl 0 : { *(.stab.excl) }
-    .stab.exclstr 0 : { *(.stab.exclstr) }
-    .stab.index 0 : { *(.stab.index) }
-    .stab.indexstr 0 : { *(.stab.indexstr) }
-    .comment 0 : { *(.comment) }
-    .debug_abbrev 0 : { *(.debug_abbrev) }
-    .debug_info 0 : { *(.debug_info) }
-    .debug_line 0 : { *(.debug_line) }
-    .debug_pubnames 0 : { *(.debug_pubnames) }
-    .debug_aranges 0 : { *(.debug_aranges) }
-}
diff --git a/boards/arm/samv7/same70-xplained/scripts/flash-dtcm-mcuboot-loader.ld b/boards/arm/samv7/same70-xplained/scripts/flash-dtcm-mcuboot-loader.ld
deleted file mode 100644
index 15c29ce..0000000
--- a/boards/arm/samv7/same70-xplained/scripts/flash-dtcm-mcuboot-loader.ld
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/same70-xplained/scripts/flash-dtcm-mcuboot-loader.ld
- *
- * 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.
- *
- ****************************************************************************/
-
-/* The SAME70Q21 has 2048Kb of FLASH beginning at address 0x0040:0000 and
- * 384Kb of SRAM beginining at 0x2040: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
- * the 0x0400:0000 address range (Assuming that ITCM is not enable).
- *
- * NOTE: that the DTCM address of 0x2000:0000 is used for SRAM.  If DTCM is
- * disabled, then the accesses will actually occur on the AHB bus.
- */
-
-MEMORY
-{
-  flash (rx) : ORIGIN = 0x00400000, LENGTH = 128K
-  sram (rwx) : ORIGIN = 0x20000000, LENGTH = 384K
-}
-
-OUTPUT_ARCH(arm)
-EXTERN(_vectors)
-ENTRY(_stext)
-
-SECTIONS
-{
-    .text : {
-        _stext = ABSOLUTE(.);
-        *(.vectors)
-        *(.text .text.*)
-        *(.fixup)
-        *(.gnu.warning)
-        *(.rodata .rodata.*)
-        *(.gnu.linkonce.t.*)
-        *(.glue_7)
-        *(.glue_7t)
-        *(.got)
-        *(.gcc_except_table)
-        *(.gnu.linkonce.r.*)
-        _etext = ABSOLUTE(.);
-    } > flash
-
-    .init_section : {
-        _sinit = ABSOLUTE(.);
-        *(.init_array .init_array.*)
-        _einit = ABSOLUTE(.);
-    } > flash
-
-    .ARM.extab : {
-        *(.ARM.extab*)
-    } > flash
-
-    __exidx_start = ABSOLUTE(.);
-    .ARM.exidx : {
-        *(.ARM.exidx*)
-    } > flash
-    __exidx_end = ABSOLUTE(.);
-
-    _eronly = ABSOLUTE(.);
-
-    .data : {
-        _sdata = ABSOLUTE(.);
-        *(.data .data.*)
-        *(.gnu.linkonce.d.*)
-        CONSTRUCTORS
-        . = ALIGN(4);
-        _edata = ABSOLUTE(.);
-    } > sram AT > flash
-
-    .ramfunc ALIGN(4): {
-        _sramfuncs = ABSOLUTE(.);
-        *(.ramfunc  .ramfunc.*)
-        _eramfuncs = ABSOLUTE(.);
-    } > sram AT > flash
-
-    _framfuncs = LOADADDR(.ramfunc);
-
-    .bss : {
-        _sbss = ABSOLUTE(.);
-        *(.bss .bss.*)
-        *(.gnu.linkonce.b.*)
-        *(COMMON)
-        . = ALIGN(4);
-        _ebss = ABSOLUTE(.);
-    } > sram
-
-    /* Stabs debugging sections. */
-    .stab 0 : { *(.stab) }
-    .stabstr 0 : { *(.stabstr) }
-    .stab.excl 0 : { *(.stab.excl) }
-    .stab.exclstr 0 : { *(.stab.exclstr) }
-    .stab.index 0 : { *(.stab.index) }
-    .stab.indexstr 0 : { *(.stab.indexstr) }
-    .comment 0 : { *(.comment) }
-    .debug_abbrev 0 : { *(.debug_abbrev) }
-    .debug_info 0 : { *(.debug_info) }
-    .debug_line 0 : { *(.debug_line) }
-    .debug_pubnames 0 : { *(.debug_pubnames) }
-    .debug_aranges 0 : { *(.debug_aranges) }
-}
diff --git a/boards/arm/samv7/same70-xplained/scripts/flash-dtcm.ld b/boards/arm/samv7/same70-xplained/scripts/flash-dtcm.ld
deleted file mode 100644
index 0fad41b..0000000
--- a/boards/arm/samv7/same70-xplained/scripts/flash-dtcm.ld
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/same70-xplained/scripts/flash-dtcm.ld
- *
- * 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.
- *
- ****************************************************************************/
-
-/* The SAME70Q21 has 2048Kb of FLASH beginning at address 0x0040:0000 and
- * 384Kb of SRAM beginining at 0x2040: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
- * the 0x0400:0000 address range (Assuming that ITCM is not enable).
- *
- * NOTE: that the DTCM address of 0x2000:0000 is used for SRAM.  If DTCM is
- * disabled, then the accesses will actually occur on the AHB bus.
- */
-
-MEMORY
-{
-  flash (rx) : ORIGIN = 0x00400000, LENGTH = 2048K
-  sram (rwx) : ORIGIN = 0x20000000, LENGTH = 384K
-}
-
-OUTPUT_ARCH(arm)
-EXTERN(_vectors)
-ENTRY(_stext)
-
-SECTIONS
-{
-    .text : {
-        _stext = ABSOLUTE(.);
-        *(.vectors)
-        *(.text .text.*)
-        *(.fixup)
-        *(.gnu.warning)
-        *(.rodata .rodata.*)
-        *(.gnu.linkonce.t.*)
-        *(.glue_7)
-        *(.glue_7t)
-        *(.got)
-        *(.gcc_except_table)
-        *(.gnu.linkonce.r.*)
-        _etext = ABSOLUTE(.);
-    } > flash
-
-    .init_section : {
-        _sinit = ABSOLUTE(.);
-        *(.init_array .init_array.*)
-        _einit = ABSOLUTE(.);
-    } > flash
-
-    .ARM.extab : {
-        *(.ARM.extab*)
-    } > flash
-
-    __exidx_start = ABSOLUTE(.);
-    .ARM.exidx : {
-        *(.ARM.exidx*)
-    } > flash
-    __exidx_end = ABSOLUTE(.);
-
-    _eronly = ABSOLUTE(.);
-
-    .data : {
-        _sdata = ABSOLUTE(.);
-        *(.data .data.*)
-        *(.gnu.linkonce.d.*)
-        CONSTRUCTORS
-        . = ALIGN(4);
-        _edata = ABSOLUTE(.);
-    } > sram AT > flash
-
-    .ramfunc ALIGN(4): {
-        _sramfuncs = ABSOLUTE(.);
-        *(.ramfunc  .ramfunc.*)
-        _eramfuncs = ABSOLUTE(.);
-    } > sram AT > flash
-
-    _framfuncs = LOADADDR(.ramfunc);
-
-    .bss : {
-        _sbss = ABSOLUTE(.);
-        *(.bss .bss.*)
-        *(.gnu.linkonce.b.*)
-        *(COMMON)
-        . = ALIGN(4);
-        _ebss = ABSOLUTE(.);
-    } > sram
-
-    /* Stabs debugging sections. */
-    .stab 0 : { *(.stab) }
-    .stabstr 0 : { *(.stabstr) }
-    .stab.excl 0 : { *(.stab.excl) }
-    .stab.exclstr 0 : { *(.stab.exclstr) }
-    .stab.index 0 : { *(.stab.index) }
-    .stab.indexstr 0 : { *(.stab.indexstr) }
-    .comment 0 : { *(.comment) }
-    .debug_abbrev 0 : { *(.debug_abbrev) }
-    .debug_info 0 : { *(.debug_info) }
-    .debug_line 0 : { *(.debug_line) }
-    .debug_pubnames 0 : { *(.debug_pubnames) }
-    .debug_aranges 0 : { *(.debug_aranges) }
-}
diff --git a/boards/arm/samv7/same70-xplained/scripts/flash-sram-mcuboot-app.ld b/boards/arm/samv7/same70-xplained/scripts/flash-sram-mcuboot-app.ld
deleted file mode 100644
index 34a0c82..0000000
--- a/boards/arm/samv7/same70-xplained/scripts/flash-sram-mcuboot-app.ld
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/same70-xplained/scripts/flash-sram-mcuboot-app.ld
- *
- * 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.
- *
- ****************************************************************************/
-
-/* The SAME70Q21 has 2048Kb of FLASH beginning at address 0x0040:0000 and
- * 384Kb of SRAM beginining at 0x2040: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
- * the 0x0400:0000 address range (Assuming that ITCM is not enable).
- */
-
-MEMORY
-{
-  flash (rx) : ORIGIN = 0x00420200, LENGTH = 896K - 0x200
-  sram (rwx) : ORIGIN = 0x20400000, LENGTH = 384K
-}
-
-OUTPUT_ARCH(arm)
-EXTERN(_vectors)
-ENTRY(_stext)
-
-SECTIONS
-{
-    .text : {
-        _stext = ABSOLUTE(.);
-        *(.vectors)
-        *(.text .text.*)
-        *(.fixup)
-        *(.gnu.warning)
-        *(.rodata .rodata.*)
-        *(.gnu.linkonce.t.*)
-        *(.glue_7)
-        *(.glue_7t)
-        *(.got)
-        *(.gcc_except_table)
-        *(.gnu.linkonce.r.*)
-        _etext = ABSOLUTE(.);
-    } > flash
-
-    .init_section : {
-        _sinit = ABSOLUTE(.);
-        *(.init_array .init_array.*)
-        _einit = ABSOLUTE(.);
-    } > flash
-
-    .ARM.extab : {
-        *(.ARM.extab*)
-    } > flash
-
-    __exidx_start = ABSOLUTE(.);
-    .ARM.exidx : {
-        *(.ARM.exidx*)
-    } > flash
-    __exidx_end = ABSOLUTE(.);
-
-    _eronly = ABSOLUTE(.);
-
-    .data : {
-        _sdata = ABSOLUTE(.);
-        *(.data .data.*)
-        *(.gnu.linkonce.d.*)
-        CONSTRUCTORS
-        . = ALIGN(4);
-        _edata = ABSOLUTE(.);
-    } > sram AT > flash
-
-    .ramfunc ALIGN(4): {
-        _sramfuncs = ABSOLUTE(.);
-        *(.ramfunc  .ramfunc.*)
-        _eramfuncs = ABSOLUTE(.);
-    } > sram AT > flash
-
-    _framfuncs = LOADADDR(.ramfunc);
-
-    .bss : {
-        _sbss = ABSOLUTE(.);
-        *(.bss .bss.*)
-        *(.gnu.linkonce.b.*)
-        *(COMMON)
-        . = ALIGN(4);
-        _ebss = ABSOLUTE(.);
-    } > sram
-
-    /* Stabs debugging sections. */
-    .stab 0 : { *(.stab) }
-    .stabstr 0 : { *(.stabstr) }
-    .stab.excl 0 : { *(.stab.excl) }
-    .stab.exclstr 0 : { *(.stab.exclstr) }
-    .stab.index 0 : { *(.stab.index) }
-    .stab.indexstr 0 : { *(.stab.indexstr) }
-    .comment 0 : { *(.comment) }
-    .debug_abbrev 0 : { *(.debug_abbrev) }
-    .debug_info 0 : { *(.debug_info) }
-    .debug_line 0 : { *(.debug_line) }
-    .debug_pubnames 0 : { *(.debug_pubnames) }
-    .debug_aranges 0 : { *(.debug_aranges) }
-}
diff --git a/boards/arm/samv7/same70-xplained/scripts/flash-sram-mcuboot-loader.ld b/boards/arm/samv7/same70-xplained/scripts/flash-sram-mcuboot-loader.ld
deleted file mode 100644
index d9b6ee8..0000000
--- a/boards/arm/samv7/same70-xplained/scripts/flash-sram-mcuboot-loader.ld
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/same70-xplained/scripts/flash-sram-mcuboot-loader.ld
- *
- * 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.
- *
- ****************************************************************************/
-
-/* The SAME70Q21 has 2048Kb of FLASH beginning at address 0x0040:0000 and
- * 384Kb of SRAM beginining at 0x2040: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
- * the 0x0400:0000 address range (Assuming that ITCM is not enable).
- */
-
-MEMORY
-{
-  flash (rx) : ORIGIN = 0x00400000, LENGTH = 128K
-  sram (rwx) : ORIGIN = 0x20400000, LENGTH = 384K
-}
-
-OUTPUT_ARCH(arm)
-EXTERN(_vectors)
-ENTRY(_stext)
-
-SECTIONS
-{
-    .text : {
-        _stext = ABSOLUTE(.);
-        *(.vectors)
-        *(.text .text.*)
-        *(.fixup)
-        *(.gnu.warning)
-        *(.rodata .rodata.*)
-        *(.gnu.linkonce.t.*)
-        *(.glue_7)
-        *(.glue_7t)
-        *(.got)
-        *(.gcc_except_table)
-        *(.gnu.linkonce.r.*)
-        _etext = ABSOLUTE(.);
-    } > flash
-
-    .init_section : {
-        _sinit = ABSOLUTE(.);
-        *(.init_array .init_array.*)
-        _einit = ABSOLUTE(.);
-    } > flash
-
-    .ARM.extab : {
-        *(.ARM.extab*)
-    } > flash
-
-    __exidx_start = ABSOLUTE(.);
-    .ARM.exidx : {
-        *(.ARM.exidx*)
-    } > flash
-    __exidx_end = ABSOLUTE(.);
-
-    _eronly = ABSOLUTE(.);
-
-    .data : {
-        _sdata = ABSOLUTE(.);
-        *(.data .data.*)
-        *(.gnu.linkonce.d.*)
-        CONSTRUCTORS
-        . = ALIGN(4);
-        _edata = ABSOLUTE(.);
-    } > sram AT > flash
-
-    .ramfunc ALIGN(4): {
-        _sramfuncs = ABSOLUTE(.);
-        *(.ramfunc  .ramfunc.*)
-        _eramfuncs = ABSOLUTE(.);
-    } > sram AT > flash
-
-    _framfuncs = LOADADDR(.ramfunc);
-
-    .bss : {
-        _sbss = ABSOLUTE(.);
-        *(.bss .bss.*)
-        *(.gnu.linkonce.b.*)
-        *(COMMON)
-        . = ALIGN(4);
-        _ebss = ABSOLUTE(.);
-    } > sram
-
-    /* Stabs debugging sections. */
-    .stab 0 : { *(.stab) }
-    .stabstr 0 : { *(.stabstr) }
-    .stab.excl 0 : { *(.stab.excl) }
-    .stab.exclstr 0 : { *(.stab.exclstr) }
-    .stab.index 0 : { *(.stab.index) }
-    .stab.indexstr 0 : { *(.stab.indexstr) }
-    .comment 0 : { *(.comment) }
-    .debug_abbrev 0 : { *(.debug_abbrev) }
-    .debug_info 0 : { *(.debug_info) }
-    .debug_line 0 : { *(.debug_line) }
-    .debug_pubnames 0 : { *(.debug_pubnames) }
-    .debug_aranges 0 : { *(.debug_aranges) }
-}
diff --git a/boards/arm/samv7/same70-qmtech/scripts/flash-dtcm-mcuboot-app.ld b/boards/arm/samv7/same70-xplained/scripts/flash.template.ld
similarity index 74%
rename from boards/arm/samv7/same70-qmtech/scripts/flash-dtcm-mcuboot-app.ld
rename to boards/arm/samv7/same70-xplained/scripts/flash.template.ld
index 4b071b9..4b984a8 100644
--- a/boards/arm/samv7/same70-qmtech/scripts/flash-dtcm-mcuboot-app.ld
+++ b/boards/arm/samv7/same70-xplained/scripts/flash.template.ld
@@ -1,5 +1,5 @@
 /****************************************************************************
- * boards/arm/samv7/same70-qmtech/scripts/flash-dtcm-mcuboot-app.ld
+ * boards/arm/samv7/same70-xplained/scripts/flash.template.ld
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -18,21 +18,34 @@
  *
  ****************************************************************************/
 
-/* The SAME70N19 has 512Kb of FLASH beginning at address 0x0040:0000 and
- * 256Kb of SRAM beginining at 0x2040: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
- * the 0x0400:0000 address range (Assuming that ITCM is not enable).
- *
- * NOTE: that the DTCM address of 0x2000:0000 is used for SRAM.  If DTCM is
- * disabled, then the accesses will actually occur on the AHB bus.
- */
+#include <nuttx/config.h>
+
+#define FLASH_START_ADDR        0x00400000
+
+#ifdef CONFIG_ARMV7M_DTCM
+#  define SRAM_START_ADDR       0x20000000
+#else
+#  define SRAM_START_ADDR       0x20400000
+#endif
+
+#ifdef CONFIG_SAME70XPLAINED_FORMAT_MCUBOOT
+#  define MCUBOOT_HEADER_SIZE   0x200
+#  ifdef CONFIG_BOARDCTL_BOOT_IMAGE
+#    define FLASH_OFFSET        0
+#    define FLASH_IMG_SIZE      CONFIG_SAME70XPLAINED_OTA_PRIMARY_SLOT_OFFSET
+#  else
+#    define FLASH_OFFSET        (CONFIG_SAME70XPLAINED_OTA_PRIMARY_SLOT_OFFSET + MCUBOOT_HEADER_SIZE)
+#    define FLASH_IMG_SIZE      (CONFIG_SAME70XPLAINED_OTA_SLOT_SIZE - MCUBOOT_HEADER_SIZE)
+#  endif
+#else
+#  define FLASH_OFFSET          0
+#  define FLASH_IMG_SIZE        CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH
+#endif
 
 MEMORY
 {
-  flash (rx) : ORIGIN = 0x00420200, LENGTH = 160K - 0x200
-  sram (rwx) : ORIGIN = 0x20000000, LENGTH = 256K
+  flash (rx) : ORIGIN = FLASH_START_ADDR + FLASH_OFFSET, LENGTH = FLASH_IMG_SIZE
+  sram (rwx) : ORIGIN = SRAM_START_ADDR, LENGTH = CONFIG_ARCH_CHIP_SAMV7_MEM_RAM
 }
 
 OUTPUT_ARCH(arm)
diff --git a/boards/arm/samv7/same70-xplained/src/Makefile b/boards/arm/samv7/same70-xplained/src/Makefile
index b78b8b0..8bbea95 100644
--- a/boards/arm/samv7/same70-xplained/src/Makefile
+++ b/boards/arm/samv7/same70-xplained/src/Makefile
@@ -100,4 +100,16 @@ ifeq ($(CONFIG_IEEE802154_XBEE),y)
 CSRCS += sam_xbee.c
 endif
 
+SCRIPTOUT = $(BOARD_DIR)$(DELIM)scripts$(DELIM)samv7.ld
+
+.PHONY = context distclean
+
+$(SCRIPTOUT): $(LDSCRIPT_TEMPLATE) $(CONFIGFILE)
+	$(Q) $(CC) -isystem $(TOPDIR)/include -I $(BOARD_DIR)$(DELIM)scripts -C -P -x c -E $(LDSCRIPT_TEMPLATE) -o $@
+
+context:: $(SCRIPTOUT)
+
+distclean::
+	$(call DELFILE, $(SCRIPTOUT))
+
 include $(TOPDIR)/boards/Board.mk
diff --git a/boards/arm/samv7/samv71-xult/.gitignore b/boards/arm/samv7/samv71-xult/.gitignore
new file mode 100644
index 0000000..a5638cb
--- /dev/null
+++ b/boards/arm/samv7/samv71-xult/.gitignore
@@ -0,0 +1 @@
+/scripts/samv7.ld
diff --git a/boards/arm/samv7/samv71-xult/scripts/Make.defs b/boards/arm/samv7/samv71-xult/scripts/Make.defs
index 0aa116e..2a008ad 100644
--- a/boards/arm/samv7/samv71-xult/scripts/Make.defs
+++ b/boards/arm/samv7/samv71-xult/scripts/Make.defs
@@ -22,11 +22,8 @@ include $(TOPDIR)/.config
 include $(TOPDIR)/tools/Config.mk
 include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs
 
-ifeq ($(CONFIG_ARMV7M_DTCM),y)
-  LDSCRIPT = flash-dtcm.ld
-else
-  LDSCRIPT = flash-sram.ld
-endif
+LDSCRIPT_TEMPLATE = $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash.template.ld
+LDSCRIPT = samv7.ld
 
 ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
   ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
diff --git a/boards/arm/samv7/samv71-xult/scripts/flash-dtcm.ld b/boards/arm/samv7/samv71-xult/scripts/flash-dtcm.ld
deleted file mode 100644
index e729f75..0000000
--- a/boards/arm/samv7/samv71-xult/scripts/flash-dtcm.ld
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/samv71-xult/scripts/flash-dtcm.ld
- *
- * 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.
- *
- ****************************************************************************/
-
-/* The SAMV71Q21 has 2048Kb of FLASH beginning at address 0x0040:0000 and
- * 384Kb of SRAM beginining at 0x2040: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
- * the 0x0400:0000 address range (Assuming that ITCM is not enable).
- *
- * NOTE: that the DTCM address of 0x2000:0000 is used for SRAM.  If DTCM is
- * disabled, then the accesses will actually occur on the AHB bus.
- */
-
-MEMORY
-{
-  flash (rx) : ORIGIN = 0x00400000, LENGTH = 2048K
-  sram (rwx) : ORIGIN = 0x20000000, LENGTH = 384K
-}
-
-OUTPUT_ARCH(arm)
-EXTERN(_vectors)
-ENTRY(_stext)
-
-SECTIONS
-{
-    .text : {
-        _stext = ABSOLUTE(.);
-        *(.vectors)
-        *(.text .text.*)
-        *(.fixup)
-        *(.gnu.warning)
-        *(.rodata .rodata.*)
-        *(.gnu.linkonce.t.*)
-        *(.glue_7)
-        *(.glue_7t)
-        *(.got)
-        *(.gcc_except_table)
-        *(.gnu.linkonce.r.*)
-        _etext = ABSOLUTE(.);
-    } > flash
-
-    .init_section : {
-        _sinit = ABSOLUTE(.);
-        *(.init_array .init_array.*)
-        _einit = ABSOLUTE(.);
-    } > flash
-
-    .ARM.extab : {
-        *(.ARM.extab*)
-    } > flash
-
-    __exidx_start = ABSOLUTE(.);
-    .ARM.exidx : {
-        *(.ARM.exidx*)
-    } > flash
-    __exidx_end = ABSOLUTE(.);
-
-    _eronly = ABSOLUTE(.);
-
-    .data : {
-        _sdata = ABSOLUTE(.);
-        *(.data .data.*)
-        *(.gnu.linkonce.d.*)
-        CONSTRUCTORS
-        . = ALIGN(4);
-        _edata = ABSOLUTE(.);
-    } > sram AT > flash
-
-    .ramfunc ALIGN(4): {
-        _sramfuncs = ABSOLUTE(.);
-        *(.ramfunc  .ramfunc.*)
-        _eramfuncs = ABSOLUTE(.);
-    } > sram AT > flash
-
-    _framfuncs = LOADADDR(.ramfunc);
-
-    .bss : {
-        _sbss = ABSOLUTE(.);
-        *(.bss .bss.*)
-        *(.gnu.linkonce.b.*)
-        *(COMMON)
-        . = ALIGN(4);
-        _ebss = ABSOLUTE(.);
-    } > sram
-
-    /* Stabs debugging sections. */
-    .stab 0 : { *(.stab) }
-    .stabstr 0 : { *(.stabstr) }
-    .stab.excl 0 : { *(.stab.excl) }
-    .stab.exclstr 0 : { *(.stab.exclstr) }
-    .stab.index 0 : { *(.stab.index) }
-    .stab.indexstr 0 : { *(.stab.indexstr) }
-    .comment 0 : { *(.comment) }
-    .debug_abbrev 0 : { *(.debug_abbrev) }
-    .debug_info 0 : { *(.debug_info) }
-    .debug_line 0 : { *(.debug_line) }
-    .debug_pubnames 0 : { *(.debug_pubnames) }
-    .debug_aranges 0 : { *(.debug_aranges) }
-}
diff --git a/boards/arm/samv7/samv71-xult/scripts/flash-sram.ld b/boards/arm/samv7/samv71-xult/scripts/flash-sram.ld
deleted file mode 100644
index 633f9b0..0000000
--- a/boards/arm/samv7/samv71-xult/scripts/flash-sram.ld
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
- * boards/arm/samv7/samv71-xult/scripts/flash-sram.ld
- *
- * 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.
- *
- ****************************************************************************/
-
-/* The SAMV71Q21 has 2048Kb of FLASH beginning at address 0x0040:0000 and
- * 384Kb of SRAM beginining at 0x2040: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
- * the 0x0400:0000 address range (Assuming that ITCM is not enable).
- */
-
-MEMORY
-{
-  flash (rx) : ORIGIN = 0x00400000, LENGTH = 2048K
-  sram (rwx) : ORIGIN = 0x20400000, LENGTH = 384K
-}
-
-OUTPUT_ARCH(arm)
-EXTERN(_vectors)
-ENTRY(_stext)
-
-SECTIONS
-{
-    .text : {
-        _stext = ABSOLUTE(.);
-        *(.vectors)
-        *(.text .text.*)
-        *(.fixup)
-        *(.gnu.warning)
-        *(.rodata .rodata.*)
-        *(.gnu.linkonce.t.*)
-        *(.glue_7)
-        *(.glue_7t)
-        *(.got)
-        *(.gcc_except_table)
-        *(.gnu.linkonce.r.*)
-        _etext = ABSOLUTE(.);
-    } > flash
-
-    .init_section : {
-        _sinit = ABSOLUTE(.);
-        *(.init_array .init_array.*)
-        _einit = ABSOLUTE(.);
-    } > flash
-
-    .ARM.extab : {
-        *(.ARM.extab*)
-    } > flash
-
-    __exidx_start = ABSOLUTE(.);
-    .ARM.exidx : {
-        *(.ARM.exidx*)
-    } > flash
-    __exidx_end = ABSOLUTE(.);
-
-    _eronly = ABSOLUTE(.);
-
-    .data : {
-        _sdata = ABSOLUTE(.);
-        *(.data .data.*)
-        *(.gnu.linkonce.d.*)
-        CONSTRUCTORS
-        . = ALIGN(4);
-        _edata = ABSOLUTE(.);
-    } > sram AT > flash
-
-    .ramfunc ALIGN(4): {
-        _sramfuncs = ABSOLUTE(.);
-        *(.ramfunc  .ramfunc.*)
-        _eramfuncs = ABSOLUTE(.);
-    } > sram AT > flash
-
-    _framfuncs = LOADADDR(.ramfunc);
-
-    .bss : {
-        _sbss = ABSOLUTE(.);
-        *(.bss .bss.*)
-        *(.gnu.linkonce.b.*)
-        *(COMMON)
-        . = ALIGN(4);
-        _ebss = ABSOLUTE(.);
-    } > sram
-
-    /* Stabs debugging sections. */
-    .stab 0 : { *(.stab) }
-    .stabstr 0 : { *(.stabstr) }
-    .stab.excl 0 : { *(.stab.excl) }
-    .stab.exclstr 0 : { *(.stab.exclstr) }
-    .stab.index 0 : { *(.stab.index) }
-    .stab.indexstr 0 : { *(.stab.indexstr) }
-    .comment 0 : { *(.comment) }
-    .debug_abbrev 0 : { *(.debug_abbrev) }
-    .debug_info 0 : { *(.debug_info) }
-    .debug_line 0 : { *(.debug_line) }
-    .debug_pubnames 0 : { *(.debug_pubnames) }
-    .debug_aranges 0 : { *(.debug_aranges) }
-}
diff --git a/boards/arm/samv7/same70-xplained/scripts/flash-sram.ld b/boards/arm/samv7/samv71-xult/scripts/flash.template.ld
similarity index 84%
rename from boards/arm/samv7/same70-xplained/scripts/flash-sram.ld
rename to boards/arm/samv7/samv71-xult/scripts/flash.template.ld
index 3b32adc..478fb82 100644
--- a/boards/arm/samv7/same70-xplained/scripts/flash-sram.ld
+++ b/boards/arm/samv7/samv71-xult/scripts/flash.template.ld
@@ -1,5 +1,5 @@
 /****************************************************************************
- * boards/arm/samv7/same70-xplained/scripts/flash-sram.ld
+ * boards/arm/samv7/samv71-xult/scripts/flash.template.ld
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -18,18 +18,23 @@
  *
  ****************************************************************************/
 
-/* The SAME70Q21 has 2048Kb of FLASH beginning at address 0x0040:0000 and
- * 384Kb of SRAM beginining at 0x2040: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
- * the 0x0400:0000 address range (Assuming that ITCM is not enable).
- */
+#include <nuttx/config.h>
+
+#define FLASH_START_ADDR        0x00400000
+
+#ifdef CONFIG_ARMV7M_DTCM
+#  define SRAM_START_ADDR       0x20000000
+#else
+#  define SRAM_START_ADDR       0x20400000
+#endif
+
+#define FLASH_OFFSET            0
+#define FLASH_IMG_SIZE          CONFIG_ARCH_CHIP_SAMV7_MEM_FLASH
 
 MEMORY
 {
-  flash (rx) : ORIGIN = 0x00400000, LENGTH = 2048K
-  sram (rwx) : ORIGIN = 0x20400000, LENGTH = 384K
+  flash (rx) : ORIGIN = FLASH_START_ADDR + FLASH_OFFSET, LENGTH = FLASH_IMG_SIZE
+  sram (rwx) : ORIGIN = SRAM_START_ADDR, LENGTH = CONFIG_ARCH_CHIP_SAMV7_MEM_RAM
 }
 
 OUTPUT_ARCH(arm)
diff --git a/boards/arm/samv7/samv71-xult/src/Makefile b/boards/arm/samv7/samv71-xult/src/Makefile
index fa452cd..7e23f3b 100644
--- a/boards/arm/samv7/samv71-xult/src/Makefile
+++ b/boards/arm/samv7/samv71-xult/src/Makefile
@@ -114,4 +114,16 @@ ifeq ($(CONFIG_LCD_ST7789),y)
 CSRCS += sam_st7789.c
 endif
 
+SCRIPTOUT = $(BOARD_DIR)$(DELIM)scripts$(DELIM)samv7.ld
+
+.PHONY = context distclean
+
+$(SCRIPTOUT): $(LDSCRIPT_TEMPLATE) $(CONFIGFILE)
+	$(Q) $(CC) -isystem $(TOPDIR)/include -I $(BOARD_DIR)$(DELIM)scripts -C -P -x c -E $(LDSCRIPT_TEMPLATE) -o $@
+
+context:: $(SCRIPTOUT)
+
+distclean::
+	$(call DELFILE, $(SCRIPTOUT))
+
 include $(TOPDIR)/boards/Board.mk