[PATCH 3/3] bsps/stm32h7: allow config and usage of QSPI memory on stm32h757i-eval BSP

Karel Gardas karel at functional.vision
Fri Jan 27 18:41:42 UTC 2023


The QSPI memory is initialized and used only when the BSP configure file
sets QSPI memory size to non-zero value. Currently QSPI is run in memory
mapped mode which allows future RTEMS binary linkage and upload into QSPI
memory.

Sponsored-By:	Precidata
---
 .../stm/stm32h757i-eval/stm32h7-bspstarthooks.c | 17 +++++++++++++++++
 bsps/arm/stm32h7/include/bsp.h                  |  1 +
 .../bsps/arm/stm32h7/bspstm32h757i-eval.yml     |  5 ++++-
 spec/build/bsps/arm/stm32h7/optmemquadspisz.yml |  5 +++++
 4 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/bsps/arm/stm32h7/boards/stm/stm32h757i-eval/stm32h7-bspstarthooks.c b/bsps/arm/stm32h7/boards/stm/stm32h757i-eval/stm32h7-bspstarthooks.c
index 8d34e357ee..1bb81e3b60 100644
--- a/bsps/arm/stm32h7/boards/stm/stm32h757i-eval/stm32h7-bspstarthooks.c
+++ b/bsps/arm/stm32h7/boards/stm/stm32h757i-eval/stm32h7-bspstarthooks.c
@@ -36,6 +36,22 @@
 
 #include <string.h>
 
+#include <stm32h747i_eval_qspi.h>
+static BSP_QSPI_Init_t QSPinit;
+
+void stm32h7_init_qspi(void)
+{
+#if defined(STM32H7_MEMORY_QUADSPI_SIZE) && STM32H7_MEMORY_QUADSPI_SIZE > 0
+    /* let's initialize Quad SPI memory here for memory mapped mode */
+    /* due to usage of static QSPinit variable please call this function
+       after bsp_start_clear_bss call since otherwise you would hit uninitialized
+       variable memory while accessing it and in addition the call to bsp_start_clear_bss
+       would wipe the variable content later after its initialization here. */
+    BSP_QSPI_Init(0, &QSPinit);
+    BSP_QSPI_EnableMemoryMappedMode(0);
+#endif
+}
+
 void bsp_start_hook_0(void)
 {
   if ((RCC->AHB3ENR & RCC_AHB3ENR_FMCEN) == 0) {
@@ -75,4 +91,5 @@ void bsp_start_hook_1(void)
   SCB_InvalidateICache();
 #endif
   bsp_start_clear_bss();
+  stm32h7_init_qspi();
 }
diff --git a/bsps/arm/stm32h7/include/bsp.h b/bsps/arm/stm32h7/include/bsp.h
index 08311bf51e..cd4d25c069 100644
--- a/bsps/arm/stm32h7/include/bsp.h
+++ b/bsps/arm/stm32h7/include/bsp.h
@@ -62,6 +62,7 @@ void stm32h7_init_power(void);
 void stm32h7_init_oscillator(void);
 void stm32h7_init_clocks(void);
 void stm32h7_init_peripheral_clocks(void);
+void stm32h7_init_qspi(void);
 
 /** @} */
 
diff --git a/spec/build/bsps/arm/stm32h7/bspstm32h757i-eval.yml b/spec/build/bsps/arm/stm32h7/bspstm32h757i-eval.yml
index 5d7ee1348d..7516e55a3f 100644
--- a/spec/build/bsps/arm/stm32h7/bspstm32h757i-eval.yml
+++ b/spec/build/bsps/arm/stm32h7/bspstm32h757i-eval.yml
@@ -8,7 +8,8 @@ copyrights:
 cppflags: []
 enabled-by: true
 family: stm32h7
-includes: []
+includes:
+- bsps/arm/stm32h7/boards/stm/stm32h757i-eval
 install: []
 links:
 - role: build-dependency
@@ -16,6 +17,8 @@ links:
 - role: build-dependency
   uid: tststm32h757i-eval
 source:
+- bsps/arm/stm32h7/boards/stm/Components/mt25tl01g/mt25tl01g.c
+- bsps/arm/stm32h7/boards/stm/stm32h757i-eval/stm32h747i_eval_qspi.c
 - bsps/arm/stm32h7/boards/stm/stm32h757i-eval/stm32h7-bspstarthooks.c
 - bsps/arm/stm32h7/boards/stm/stm32h757i-eval/stm32h7-config-clk.c
 - bsps/arm/stm32h7/boards/stm/stm32h757i-eval/stm32h7-config-osc.c
diff --git a/spec/build/bsps/arm/stm32h7/optmemquadspisz.yml b/spec/build/bsps/arm/stm32h7/optmemquadspisz.yml
index 82c48c7683..f4e39d979b 100644
--- a/spec/build/bsps/arm/stm32h7/optmemquadspisz.yml
+++ b/spec/build/bsps/arm/stm32h7/optmemquadspisz.yml
@@ -2,10 +2,15 @@ SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
 actions:
 - get-integer: null
 - env-assign: null
+- define-unquoted: null
 build-type: option
 copyrights:
 - Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
 default:
+- enabled-by:
+  - arm/stm32h757i-eval
+  - arm/stm32h757i-eval-m4
+  value: 0x08000000
 - enabled-by: true
   value: 0x00000000
 description: |
-- 
2.25.1



More information about the devel mailing list