[rtems commit] bsps/imxrt: Fix OCRAM, ITCM and DTCM sizes

Christian Mauderer christianm at rtems.org
Mon May 17 07:13:08 UTC 2021


Module:    rtems
Branch:    master
Commit:    691fec407a0faae379cab23679ec8456ace9fb06
Changeset: http://git.rtems.org/rtems/commit/?id=691fec407a0faae379cab23679ec8456ace9fb06

Author:    Christian Mauderer <christian.mauderer at embedded-brains.de>
Date:      Tue May 11 13:46:56 2021 +0200

bsps/imxrt: Fix OCRAM, ITCM and DTCM sizes

The sizes are configurable via fuses or per software via some registers.
At the moment the registers are not changed. Changing the registers
destroys data stored in the RAM areas (like application code or data).
So either the fuses or some bootloader should be used to set them before
the application starts.

This also adds an OCRAM only linker command file.

Update #4180

---

 bsps/arm/imxrt/include/imxrt/memory.h              |  4 ++++
 bsps/arm/imxrt/start/linkcmds.ocram                | 23 ++++++++++++++++++++++
 bsps/arm/imxrt/start/mpu-config.c                  |  6 ++++++
 spec/build/bsps/arm/imxrt/bspimxrt.yml             |  9 +++++++++
 spec/build/bsps/arm/imxrt/linkcmdsmemory.yml       | 11 ++++++++---
 spec/build/bsps/arm/imxrt/optlinkcmds.yml          |  3 ++-
 spec/build/bsps/arm/imxrt/optmemdtcmsz.yml         | 17 ++++++++++++++++
 spec/build/bsps/arm/imxrt/optmemitcmsz.yml         | 17 ++++++++++++++++
 spec/build/bsps/arm/imxrt/optmemocramnocachesz.yml | 16 +++++++++++++++
 spec/build/bsps/arm/imxrt/optmemocramsz.yml        | 17 ++++++++++++++++
 10 files changed, 119 insertions(+), 4 deletions(-)

diff --git a/bsps/arm/imxrt/include/imxrt/memory.h b/bsps/arm/imxrt/include/imxrt/memory.h
index 5a6b457..8185f71 100644
--- a/bsps/arm/imxrt/include/imxrt/memory.h
+++ b/bsps/arm/imxrt/include/imxrt/memory.h
@@ -48,6 +48,10 @@ extern char imxrt_memory_ocram_begin[];
 extern char imxrt_memory_ocram_end[];
 extern char imxrt_memory_ocram_size[];
 
+extern char imxrt_memory_ocram_nocache_begin[];
+extern char imxrt_memory_ocram_nocache_end[];
+extern char imxrt_memory_ocram_nocache_size[];
+
 extern char imxrt_memory_peripheral_begin[];
 extern char imxrt_memory_peripheral_end[];
 extern char imxrt_memory_peripheral_size[];
diff --git a/bsps/arm/imxrt/start/linkcmds.ocram b/bsps/arm/imxrt/start/linkcmds.ocram
new file mode 100644
index 0000000..6df3c91
--- /dev/null
+++ b/bsps/arm/imxrt/start/linkcmds.ocram
@@ -0,0 +1,23 @@
+INCLUDE linkcmds.memory
+
+REGION_ALIAS ("REGION_START", OCRAM);
+REGION_ALIAS ("REGION_VECTOR", OCRAM);
+REGION_ALIAS ("REGION_TEXT", OCRAM);
+REGION_ALIAS ("REGION_TEXT_LOAD", OCRAM);
+REGION_ALIAS ("REGION_RODATA", OCRAM);
+REGION_ALIAS ("REGION_RODATA_LOAD", OCRAM);
+REGION_ALIAS ("REGION_DATA", OCRAM);
+REGION_ALIAS ("REGION_DATA_LOAD", OCRAM);
+REGION_ALIAS ("REGION_FAST_TEXT", OCRAM);
+REGION_ALIAS ("REGION_FAST_TEXT_LOAD", OCRAM);
+REGION_ALIAS ("REGION_FAST_DATA", OCRAM);
+REGION_ALIAS ("REGION_FAST_DATA_LOAD", OCRAM);
+REGION_ALIAS ("REGION_BSS", OCRAM);
+REGION_ALIAS ("REGION_WORK", OCRAM);
+REGION_ALIAS ("REGION_STACK", OCRAM);
+REGION_ALIAS ("REGION_NOCACHE", OCRAM_NOCACHE);
+REGION_ALIAS ("REGION_NOCACHE_LOAD", OCRAM);
+
+bsp_vector_table_in_start_section = 1;
+
+INCLUDE linkcmds.armv7m
diff --git a/bsps/arm/imxrt/start/mpu-config.c b/bsps/arm/imxrt/start/mpu-config.c
index 31c39bc..683b26d 100644
--- a/bsps/arm/imxrt/start/mpu-config.c
+++ b/bsps/arm/imxrt/start/mpu-config.c
@@ -56,6 +56,12 @@ BSP_START_DATA_SECTION const ARMV7M_MPU_Region_config
         | ARMV7M_MPU_RASR_TEX(0x2)
         | ARMV7M_MPU_RASR_ENABLE,
     }, {
+      .begin = imxrt_memory_ocram_nocache_begin,
+      .end = imxrt_memory_ocram_nocache_end,
+      .rasr = ARMV7M_MPU_RASR_AP(0x3)
+        | ARMV7M_MPU_RASR_TEX(0x2)
+        | ARMV7M_MPU_RASR_ENABLE,
+    }, {
       .begin = imxrt_memory_peripheral_begin,
       .end = imxrt_memory_peripheral_end,
       .rasr = ARMV7M_MPU_RASR_XN
diff --git a/spec/build/bsps/arm/imxrt/bspimxrt.yml b/spec/build/bsps/arm/imxrt/bspimxrt.yml
index 07f6bce..f543a14 100644
--- a/spec/build/bsps/arm/imxrt/bspimxrt.yml
+++ b/spec/build/bsps/arm/imxrt/bspimxrt.yml
@@ -109,6 +109,7 @@ install:
 - destination: ${BSP_LIBDIR}
   source:
   - bsps/arm/imxrt/start/linkcmds.flexspi
+  - bsps/arm/imxrt/start/linkcmds.ocram
   - bsps/arm/imxrt/start/linkcmds.sdram
 links:
 - role: build-dependency
@@ -124,14 +125,22 @@ links:
 - role: build-dependency
   uid: optlinkcmds
 - role: build-dependency
+  uid: optmemdtcmsz
+- role: build-dependency
   uid: optmemflashcfgsz
 - role: build-dependency
   uid: optmemflashivtsz
 - role: build-dependency
   uid: optmemflexspisz
 - role: build-dependency
+  uid: optmemitcmsz
+- role: build-dependency
   uid: optmemnullsz
 - role: build-dependency
+  uid: optmemocramsz
+- role: build-dependency
+  uid: optmemocramnocachesz
+- role: build-dependency
   uid: optmemsdrambase
 - role: build-dependency
   uid: optmemsdramsz
diff --git a/spec/build/bsps/arm/imxrt/linkcmdsmemory.yml b/spec/build/bsps/arm/imxrt/linkcmdsmemory.yml
index 86dc37c..3f7885c 100644
--- a/spec/build/bsps/arm/imxrt/linkcmdsmemory.yml
+++ b/spec/build/bsps/arm/imxrt/linkcmdsmemory.yml
@@ -2,9 +2,10 @@ build-type: config-file
 content: |
   MEMORY {
     NULL           : ORIGIN = 0x00000000, LENGTH = ${IMXRT_MEMORY_NULL_SIZE:#010x}
-    ITCM           : ORIGIN = ${IMXRT_MEMORY_NULL_SIZE:#010x}, LENGTH = 512k - ${IMXRT_MEMORY_NULL_SIZE:#010x}
-    DTCM           : ORIGIN = 0x20000000, LENGTH = 512k
-    OCRAM          : ORIGIN = 0x20200000, LENGTH = 512k
+    ITCM           : ORIGIN = ${IMXRT_MEMORY_NULL_SIZE:#010x}, LENGTH = ${IMXRT_MEMORY_ITCM_SIZE:#010x} - ${IMXRT_MEMORY_NULL_SIZE:#010x}
+    DTCM           : ORIGIN = 0x20000000, LENGTH = ${IMXRT_MEMORY_DTCM_SIZE:#010x}
+    OCRAM          : ORIGIN = 0x20200000, LENGTH = ${IMXRT_MEMORY_OCRAM_SIZE:#010x} - ${IMXRT_MEMORY_OCRAM_NOCACHE_SIZE:#010x}
+    OCRAM_NOCACHE  : ORIGIN = 0x20200000 + ${IMXRT_MEMORY_OCRAM_SIZE:#010x} - ${IMXRT_MEMORY_OCRAM_NOCACHE_SIZE:#010x}, LENGTH = ${IMXRT_MEMORY_OCRAM_NOCACHE_SIZE:#010x}
     PERIPHERAL     : ORIGIN = 0x40000000, LENGTH = 0x20000000
     FLEXSPI_CONFIG : ORIGIN = 0x60000000, LENGTH = ${IMXRT_MEMORY_FLASH_CFG_SIZE:#010x}
     FLEXSPI_IVT    : ORIGIN = 0x60000000 + ${IMXRT_MEMORY_FLASH_CFG_SIZE:#010x}, LENGTH = ${IMXRT_MEMORY_FLASH_IVT_SIZE:#010x}
@@ -30,6 +31,10 @@ content: |
   imxrt_memory_ocram_end = ORIGIN (OCRAM) + LENGTH (OCRAM);
   imxrt_memory_ocram_size = LENGTH (OCRAM);
 
+  imxrt_memory_ocram_nocache_begin = ORIGIN (OCRAM_NOCACHE);
+  imxrt_memory_ocram_nocache_end = ORIGIN (OCRAM_NOCACHE) + LENGTH (OCRAM_NOCACHE);
+  imxrt_memory_ocram_nocache_size = LENGTH (OCRAM_NOCACHE);
+
   imxrt_memory_peripheral_begin = ORIGIN (PERIPHERAL);
   imxrt_memory_peripheral_end = ORIGIN (PERIPHERAL) + LENGTH (PERIPHERAL);
   imxrt_memory_peripheral_size = LENGTH (PERIPHERAL);
diff --git a/spec/build/bsps/arm/imxrt/optlinkcmds.yml b/spec/build/bsps/arm/imxrt/optlinkcmds.yml
index ba20c38..4349ad3 100644
--- a/spec/build/bsps/arm/imxrt/optlinkcmds.yml
+++ b/spec/build/bsps/arm/imxrt/optlinkcmds.yml
@@ -9,7 +9,8 @@ format: '{}'
 links: []
 name: IMXRT_DEFAULT_LINKCMDS
 description: |
-  The default linker command file.  Must be linkcmds.sdram or linkcmds.flexspi.
+  The default linker command file.  Must be linkcmds.sdram, linkcmds.ocram or
+  linkcmds.flexspi.
 type: build
 SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
 copyrights:
diff --git a/spec/build/bsps/arm/imxrt/optmemdtcmsz.yml b/spec/build/bsps/arm/imxrt/optmemdtcmsz.yml
new file mode 100644
index 0000000..1bd57fa
--- /dev/null
+++ b/spec/build/bsps/arm/imxrt/optmemdtcmsz.yml
@@ -0,0 +1,17 @@
+actions:
+- get-integer: null
+- env-assign: null
+build-type: option
+default: 0x20000
+default-by-variant: []
+enabled-by: true
+format: '{:#010x}'
+links: []
+name: IMXRT_MEMORY_DTCM_SIZE
+description: |
+  Size of the DTCM in bytes. Note that these sizes depend on fuses or software
+  settings done by a bootloader (together with ITCM and OCRAM).
+type: build
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
diff --git a/spec/build/bsps/arm/imxrt/optmemitcmsz.yml b/spec/build/bsps/arm/imxrt/optmemitcmsz.yml
new file mode 100644
index 0000000..195d519
--- /dev/null
+++ b/spec/build/bsps/arm/imxrt/optmemitcmsz.yml
@@ -0,0 +1,17 @@
+actions:
+- get-integer: null
+- env-assign: null
+build-type: option
+default: 0x20000
+default-by-variant: []
+enabled-by: true
+format: '{:#010x}'
+links: []
+name: IMXRT_MEMORY_ITCM_SIZE
+description: |
+  Size of the ITCM in bytes. Note that these sizes depend on fuses or software
+  settings done by a bootloader (together with DTCM and OCRAM).
+type: build
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
diff --git a/spec/build/bsps/arm/imxrt/optmemocramnocachesz.yml b/spec/build/bsps/arm/imxrt/optmemocramnocachesz.yml
new file mode 100644
index 0000000..8e68a08
--- /dev/null
+++ b/spec/build/bsps/arm/imxrt/optmemocramnocachesz.yml
@@ -0,0 +1,16 @@
+actions:
+- get-integer: null
+- env-assign: null
+build-type: option
+default: 0
+default-by-variant: []
+enabled-by: true
+format: '{:#010x}'
+links: []
+name: IMXRT_MEMORY_OCRAM_NOCACHE_SIZE
+description: |
+  Size of the nocache area at the end of the OCRAM in bytes.
+type: build
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
diff --git a/spec/build/bsps/arm/imxrt/optmemocramsz.yml b/spec/build/bsps/arm/imxrt/optmemocramsz.yml
new file mode 100644
index 0000000..4498435
--- /dev/null
+++ b/spec/build/bsps/arm/imxrt/optmemocramsz.yml
@@ -0,0 +1,17 @@
+actions:
+- get-integer: null
+- env-assign: null
+build-type: option
+default: 0x40000
+default-by-variant: []
+enabled-by: true
+format: '{:#010x}'
+links: []
+name: IMXRT_MEMORY_OCRAM_SIZE
+description: |
+  Size of the OCRAM in bytes. Note that these sizes depend on fuses or software
+  settings done by a bootloader (together with ITCM and DTCM).
+type: build
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)



More information about the vc mailing list