[PATCH rtems 3/3] bsp/atsam: Allow to use custom SDRAM

Christian Mauderer christian.mauderer at embedded-brains.de
Fri Dec 9 09:20:18 UTC 2022


With the old build system in RTEMS 5 that was possible by just
overwriting BOARD_Sdram_Config and setting a custom
ATSAM_MEMORY_SDRAM_SIZE during building the BSP. In the new build system
that ATSAM_MEMORY_SDRAM_SIZE is set exclusively by the selected SDRAM
chip.

This patch adds the possibility to specify a "custom-0x100000" or
similar as SDRAM type where the number gives the SDRAM size.
---
 bsps/arm/atsam/start/sdram-config.c    |  7 +++++++
 spec/build/bsps/arm/atsam/optsdram.yml | 21 ++++++++++++++++-----
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/bsps/arm/atsam/start/sdram-config.c b/bsps/arm/atsam/start/sdram-config.c
index 87e52ebed0..85b009a9d5 100644
--- a/bsps/arm/atsam/start/sdram-config.c
+++ b/bsps/arm/atsam/start/sdram-config.c
@@ -148,6 +148,13 @@ const struct BOARD_Sdram_Config BOARD_Sdram_Config = {
 #error Please check SDRAM settings for this frequency.
 #endif
 
+#elif defined ATSAM_SDRAM_CUSTOM
+/*
+ * Custom SDRAM defined. Provide only a dummy BOARD_Sdram_Config. This config
+ * won't work and is only there so that test applications can link. The
+ * application has to overwrite this BOARD_Sdram_Config!
+ */
+const struct BOARD_Sdram_Config BOARD_Sdram_Config = {};
 #else
   #error SDRAM not supported.
 #endif
diff --git a/spec/build/bsps/arm/atsam/optsdram.yml b/spec/build/bsps/arm/atsam/optsdram.yml
index c07edd9ba5..0c3808ab2b 100644
--- a/spec/build/bsps/arm/atsam/optsdram.yml
+++ b/spec/build/bsps/arm/atsam/optsdram.yml
@@ -9,10 +9,18 @@ actions:
          "mt48lc16m16a2p-6a": ("ATSAM_SDRAM_MT48LC16M16A2P_6A", 0x02000000),
     }
     if value:
-        try:
-            s = sdram[value]
-        except:
-            conf.fatal("Unkown SDRAM variant '{}'".format(value))
+        if value.startswith("custom-"):
+            name = "ATSAM_SDRAM_CUSTOM"
+            try:
+                size = int(value[len("custom-"):], base=0)
+                s = (name, size)
+            except Exception as e:
+                conf.fatal("Invalid SDRAM size '{}': {}".format(value, e))
+        else:
+            try:
+                s = sdram[value]
+            except:
+                conf.fatal("Unkown SDRAM variant '{}'".format(value))
     conf.define_cond(s[0], True)
     conf.env["ATSAM_MEMORY_SDRAM_SIZE"] = s[1]
 build-type: option
@@ -21,7 +29,10 @@ copyrights:
 default: is42s16100e-7bli
 default-by-variant: []
 description: |
-  SDRAM variant
+  SDRAM variant. Known chips are "is42s16100e-7bli", "is42s16320f-7bl",
+  "mt48lc16m16a2p-6a". You can also set this to "custom-<RAM_SIZE>" (for example
+  "custom-0x1000000" for a 16MiB RAM). In that case the BOARD_Sdram_Config has
+  to be overwritten by the application to get working applications.
 enabled-by: true
 format: '{}'
 links: []
-- 
2.35.3



More information about the devel mailing list