[PATCH rtems 5/6] bsps/imsrt: Make flash config more flexible

Christian Mauderer christian.mauderer at embedded-brains.de
Thu Jul 13 13:42:22 UTC 2023


The flash configuration is something very board specific. So move the
file to a board specific location. Beneath that, not all controllers and
configurations need the flash config right at the address 0 of the
flash. For example on the i.MXRT11xx, the config has an offset for some
flash types.
---
 .../evkbimxrt1050}/flash-flexspi-config.c     |  0
 bsps/arm/imxrt/include/imxrt/memory.h         |  4 ++++
 bsps/arm/imxrt/start/flash-boot-data.c        |  2 +-
 bsps/arm/imxrt/start/mpu-config.c             |  4 ++--
 spec/build/bsps/arm/imxrt/bspimxrt1052.yml    |  1 +
 spec/build/bsps/arm/imxrt/grp.yml             |  4 +++-
 spec/build/bsps/arm/imxrt/linkcmdsmemory.yml  | 15 ++++++++-----
 spec/build/bsps/arm/imxrt/obj.yml             |  1 -
 .../bsps/arm/imxrt/optmemflashcfgoffset.yml   | 21 +++++++++++++++++++
 .../build/bsps/arm/imxrt/optmemflashcfgsz.yml | 20 ------------------
 .../bsps/arm/imxrt/optmemflashivtoffset.yml   | 20 ++++++++++++++++++
 11 files changed, 62 insertions(+), 30 deletions(-)
 rename bsps/arm/imxrt/{start => boards/evkbimxrt1050}/flash-flexspi-config.c (100%)
 create mode 100644 spec/build/bsps/arm/imxrt/optmemflashcfgoffset.yml
 delete mode 100644 spec/build/bsps/arm/imxrt/optmemflashcfgsz.yml
 create mode 100644 spec/build/bsps/arm/imxrt/optmemflashivtoffset.yml

diff --git a/bsps/arm/imxrt/start/flash-flexspi-config.c b/bsps/arm/imxrt/boards/evkbimxrt1050/flash-flexspi-config.c
similarity index 100%
rename from bsps/arm/imxrt/start/flash-flexspi-config.c
rename to bsps/arm/imxrt/boards/evkbimxrt1050/flash-flexspi-config.c
diff --git a/bsps/arm/imxrt/include/imxrt/memory.h b/bsps/arm/imxrt/include/imxrt/memory.h
index 3fc8f0bbfa..52163d040f 100644
--- a/bsps/arm/imxrt/include/imxrt/memory.h
+++ b/bsps/arm/imxrt/include/imxrt/memory.h
@@ -56,6 +56,10 @@ extern char imxrt_memory_peripheral_begin[];
 extern char imxrt_memory_peripheral_end[];
 extern char imxrt_memory_peripheral_size[];
 
+extern char imxrt_memory_flash_raw_begin[];
+extern char imxrt_memory_flash_raw_end[];
+extern char imxrt_memory_flash_raw_size[];
+
 extern char imxrt_memory_flash_config_begin[];
 extern char imxrt_memory_flash_config_end[];
 extern char imxrt_memory_flash_config_size[];
diff --git a/bsps/arm/imxrt/start/flash-boot-data.c b/bsps/arm/imxrt/start/flash-boot-data.c
index 485f91c8ec..2186fc08bf 100644
--- a/bsps/arm/imxrt/start/flash-boot-data.c
+++ b/bsps/arm/imxrt/start/flash-boot-data.c
@@ -30,7 +30,7 @@
 #include <bspopts.h>
 
 const BOOT_DATA_T imxrt_boot_data = {
-  .start = (uint32_t) imxrt_memory_flash_config_begin,
+  .start = (uint32_t) imxrt_memory_flash_raw_begin,
   .size = IMXRT_MEMORY_FLASH_SIZE,
   .plugin = PLUGIN_FLAG,
   .placeholder = 0xFFFFFFFF,
diff --git a/bsps/arm/imxrt/start/mpu-config.c b/bsps/arm/imxrt/start/mpu-config.c
index 8928980445..a8f98f1c81 100644
--- a/bsps/arm/imxrt/start/mpu-config.c
+++ b/bsps/arm/imxrt/start/mpu-config.c
@@ -44,8 +44,8 @@ BSP_START_DATA_SECTION const ARMV7M_MPU_Region_config
         | ARMV7M_MPU_RASR_TEX(0x1) | ARMV7M_MPU_RASR_C | ARMV7M_MPU_RASR_B
         | ARMV7M_MPU_RASR_ENABLE,
     }, {
-      .begin = imxrt_memory_flash_config_begin,
-      .end = imxrt_memory_flash_end,
+      .begin = imxrt_memory_flash_raw_begin,
+      .end = imxrt_memory_flash_raw_end,
       .rasr = ARMV7M_MPU_RASR_AP(0x3)
         | ARMV7M_MPU_RASR_TEX(0x1) | ARMV7M_MPU_RASR_C | ARMV7M_MPU_RASR_B
         | ARMV7M_MPU_RASR_ENABLE,
diff --git a/spec/build/bsps/arm/imxrt/bspimxrt1052.yml b/spec/build/bsps/arm/imxrt/bspimxrt1052.yml
index d2bd43d84d..8413b4bef1 100644
--- a/spec/build/bsps/arm/imxrt/bspimxrt1052.yml
+++ b/spec/build/bsps/arm/imxrt/bspimxrt1052.yml
@@ -25,6 +25,7 @@ links:
 source:
 - bsps/arm/imxrt/boards/evkbimxrt1050/clock_config.c
 - bsps/arm/imxrt/boards/evkbimxrt1050/flash-dcd.c
+- bsps/arm/imxrt/boards/evkbimxrt1050/flash-flexspi-config.c
 - bsps/arm/imxrt/boards/evkbimxrt1050/pin_mux.c
 - bsps/arm/imxrt/boards/evkbimxrt1050/clock-arm-pll-config.c
 - bsps/arm/imxrt/dts/imxrt1050-evkb.c
diff --git a/spec/build/bsps/arm/imxrt/grp.yml b/spec/build/bsps/arm/imxrt/grp.yml
index c8128ef10d..6191823899 100644
--- a/spec/build/bsps/arm/imxrt/grp.yml
+++ b/spec/build/bsps/arm/imxrt/grp.yml
@@ -33,7 +33,9 @@ links:
 - role: build-dependency
   uid: optmemextramsz
 - role: build-dependency
-  uid: optmemflashcfgsz
+  uid: optmemflashcfgoffset
+- role: build-dependency
+  uid: optmemflashivtoffset
 - role: build-dependency
   uid: optmemflashivtsz
 - role: build-dependency
diff --git a/spec/build/bsps/arm/imxrt/linkcmdsmemory.yml b/spec/build/bsps/arm/imxrt/linkcmdsmemory.yml
index d50d2c814b..967423ed6b 100644
--- a/spec/build/bsps/arm/imxrt/linkcmdsmemory.yml
+++ b/spec/build/bsps/arm/imxrt/linkcmdsmemory.yml
@@ -5,12 +5,13 @@ content: |
     NULL           : ORIGIN = 0x00000000, LENGTH = ${IMXRT_MEMORY_NULL_SIZE:#010x}
     ITCM           : ORIGIN = ${IMXRT_MEMORY_NULL_SIZE:#010x}, LENGTH = ${IMXRT_MEMORY_ITCM_SIZE:#010x}
     DTCM           : ORIGIN = 0x20000000, LENGTH = ${IMXRT_MEMORY_DTCM_SIZE:#010x}
-    OCRAM          : ORIGIN = ${IMXRT_MEMORY_OCRAM_ORIGIN}, LENGTH = ${IMXRT_MEMORY_OCRAM_SIZE:#010x} - ${IMXRT_MEMORY_OCRAM_NOCACHE_SIZE:#010x}
-    OCRAM_NOCACHE  : ORIGIN = ${IMXRT_MEMORY_OCRAM_ORIGIN} + ${IMXRT_MEMORY_OCRAM_SIZE:#010x} - ${IMXRT_MEMORY_OCRAM_NOCACHE_SIZE:#010x}, LENGTH = ${IMXRT_MEMORY_OCRAM_NOCACHE_SIZE:#010x}
+    OCRAM          : ORIGIN = ${IMXRT_MEMORY_OCRAM_ORIGIN:#010x}, LENGTH = ${IMXRT_MEMORY_OCRAM_SIZE:#010x} - ${IMXRT_MEMORY_OCRAM_NOCACHE_SIZE:#010x}
+    OCRAM_NOCACHE  : ORIGIN = ${IMXRT_MEMORY_OCRAM_ORIGIN:#010x} + ${IMXRT_MEMORY_OCRAM_SIZE:#010x} - ${IMXRT_MEMORY_OCRAM_NOCACHE_SIZE:#010x}, LENGTH = ${IMXRT_MEMORY_OCRAM_NOCACHE_SIZE:#010x}
     PERIPHERAL     : ORIGIN = 0x40000000, LENGTH = 0x20000000
-    FLASH_CONFIG   : ORIGIN = ${IMXRT_MEMORY_FLASH_ORIGIN:#010x}, LENGTH = ${IMXRT_MEMORY_FLASH_CFG_SIZE:#010x}
-    FLASH_IVT      : ORIGIN = ${IMXRT_MEMORY_FLASH_ORIGIN:#010x} + ${IMXRT_MEMORY_FLASH_CFG_SIZE:#010x}, LENGTH = ${IMXRT_MEMORY_FLASH_IVT_SIZE:#010x}
-    FLASH          : ORIGIN = ${IMXRT_MEMORY_FLASH_ORIGIN:#010x} + ${IMXRT_MEMORY_FLASH_CFG_SIZE:#010x} + ${IMXRT_MEMORY_FLASH_IVT_SIZE:#010x}, LENGTH = ${IMXRT_MEMORY_FLASH_SIZE:#010x} - ${IMXRT_MEMORY_FLASH_CFG_SIZE:#010x} - ${IMXRT_MEMORY_FLASH_IVT_SIZE:#010x}
+    FLASH_RAW      : ORIGIN = ${IMXRT_MEMORY_FLASH_ORIGIN:#010x}, LENGTH = ${IMXRT_MEMORY_FLASH_SIZE:#010x}
+    FLASH_CONFIG   : ORIGIN = ${IMXRT_MEMORY_FLASH_ORIGIN:#010x} + ${IMXRT_MEMORY_FLASH_CFG_OFFSET:#010x}, LENGTH = ${IMXRT_MEMORY_FLASH_IVT_OFFSET:#010x} - ${IMXRT_MEMORY_FLASH_CFG_OFFSET:#010x}
+    FLASH_IVT      : ORIGIN = ${IMXRT_MEMORY_FLASH_ORIGIN:#010x} + ${IMXRT_MEMORY_FLASH_IVT_OFFSET:#010x}, LENGTH = ${IMXRT_MEMORY_FLASH_IVT_SIZE:#010x}
+    FLASH          : ORIGIN = ${IMXRT_MEMORY_FLASH_ORIGIN:#010x} + ${IMXRT_MEMORY_FLASH_IVT_OFFSET:#010x} + ${IMXRT_MEMORY_FLASH_IVT_SIZE:#010x}, LENGTH = ${IMXRT_MEMORY_FLASH_SIZE:#010x} - ${IMXRT_MEMORY_FLASH_IVT_OFFSET:#010x} - ${IMXRT_MEMORY_FLASH_IVT_SIZE:#010x}
     EXTRAM         : ORIGIN = ${IMXRT_MEMORY_EXTRAM_ORIGIN:#010x}, LENGTH = ${IMXRT_MEMORY_EXTRAM_SIZE:#010x} - ${IMXRT_MEMORY_EXTRAM_NOCACHE_SIZE:#010x}
     EXTRAM_NOCACHE : ORIGIN = ${IMXRT_MEMORY_EXTRAM_ORIGIN:#010x} + ${IMXRT_MEMORY_EXTRAM_SIZE:#010x} - ${IMXRT_MEMORY_EXTRAM_NOCACHE_SIZE:#010x}, LENGTH = ${IMXRT_MEMORY_EXTRAM_NOCACHE_SIZE:#010x}
   }
@@ -39,6 +40,10 @@ content: |
   imxrt_memory_peripheral_end = ORIGIN (PERIPHERAL) + LENGTH (PERIPHERAL);
   imxrt_memory_peripheral_size = LENGTH (PERIPHERAL);
 
+  imxrt_memory_flash_raw_begin = ORIGIN (FLASH_RAW);
+  imxrt_memory_flash_raw_end = ORIGIN (FLASH_RAW) + LENGTH (FLASH_RAW);
+  imxrt_memory_flash_raw_size = LENGTH (FLASH_RAW);
+
   imxrt_memory_flash_config_begin = ORIGIN (FLASH_CONFIG);
   imxrt_memory_flash_config_end = ORIGIN (FLASH_CONFIG) + LENGTH (FLASH_CONFIG);
   imxrt_memory_flash_config_size = LENGTH (FLASH_CONFIG);
diff --git a/spec/build/bsps/arm/imxrt/obj.yml b/spec/build/bsps/arm/imxrt/obj.yml
index 29e234a747..ca1b07beca 100644
--- a/spec/build/bsps/arm/imxrt/obj.yml
+++ b/spec/build/bsps/arm/imxrt/obj.yml
@@ -41,7 +41,6 @@ source:
 - bsps/arm/imxrt/start/bspstart.c
 - bsps/arm/imxrt/start/bspstarthooks.c
 - bsps/arm/imxrt/start/flash-boot-data.c
-- bsps/arm/imxrt/start/flash-flexspi-config.c
 - bsps/arm/imxrt/start/flash-ivt.c
 - bsps/arm/imxrt/start/imxrt-ffec-init.c
 - bsps/arm/imxrt/start/mpu-config.c
diff --git a/spec/build/bsps/arm/imxrt/optmemflashcfgoffset.yml b/spec/build/bsps/arm/imxrt/optmemflashcfgoffset.yml
new file mode 100644
index 0000000000..269dcdb4e1
--- /dev/null
+++ b/spec/build/bsps/arm/imxrt/optmemflashcfgoffset.yml
@@ -0,0 +1,21 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+actions:
+- get-integer: null
+- env-assign: null
+build-type: option
+copyrights:
+- Copyright (C) 2023 embedded brains GmbH (http://www.embedded-brains.de)
+default:
+- enabled-by: arm/imxrt1166-cm7-saltshaker
+  value: 0x00000400
+- enabled-by: true
+  value: 0x00000000
+description: |
+  Ofset of the flash configuration area from the start of the FlexSPI / SEMC
+  flash in bytes. The example link files for the i.MX RT1050 set that to 0. On
+  the i.MX RT1166, it's 0x400.
+enabled-by: true
+format: '{:#010x}'
+links: []
+name: IMXRT_MEMORY_FLASH_CFG_OFFSET
+type: build
diff --git a/spec/build/bsps/arm/imxrt/optmemflashcfgsz.yml b/spec/build/bsps/arm/imxrt/optmemflashcfgsz.yml
deleted file mode 100644
index d724059956..0000000000
--- a/spec/build/bsps/arm/imxrt/optmemflashcfgsz.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
-actions:
-- get-integer: null
-- env-assign: null
-build-type: option
-copyrights:
-- Copyright (C) 2020 embedded brains GmbH & Co. KG
-default:
-- enabled-by: true
-  value: 0x00001000
-description: |
-  Size of the flash configuration area at the start of the FlexSPI / SEMC flash
-  in bytes. Either 4 KByte for FlexSPI NOR / SEMC NOR or 1 Kbyte for most other.
-  Take a look at the i.MX RT1050 Processor Reference Manual chapter 9.7 "Program
-  image" for details.
-enabled-by: true
-format: '{:#010x}'
-links: []
-name: IMXRT_MEMORY_FLASH_CFG_SIZE
-type: build
diff --git a/spec/build/bsps/arm/imxrt/optmemflashivtoffset.yml b/spec/build/bsps/arm/imxrt/optmemflashivtoffset.yml
new file mode 100644
index 0000000000..4d3bd5556e
--- /dev/null
+++ b/spec/build/bsps/arm/imxrt/optmemflashivtoffset.yml
@@ -0,0 +1,20 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+actions:
+- get-integer: null
+- env-assign: null
+build-type: option
+copyrights:
+- Copyright (C) 2023 embedded brains GmbH (http://www.embedded-brains.de)
+default:
+- enabled-by: true
+  value: 0x00001000
+description: |
+  Offset of the image vector table in flash in bytes. Either 4 KByte for FlexSPI
+  NOR / SEMC NOR or 1 KByte for most others (on i.MXRT1050). Take a look at the
+  i.MXRT1050 / i.MXRT1166 Processor Reference Manual chapter "System Boot" /
+  "Program image" for details.
+enabled-by: true
+format: '{:#010x}'
+links: []
+name: IMXRT_MEMORY_FLASH_IVT_OFFSET
+type: build
-- 
2.35.3



More information about the devel mailing list