From a0b9853154b1c40b69e4e3e40e67683aaf70a7a1 Mon Sep 17 00:00:00 2001 From: Jisheng Zhang Date: Wed, 19 Nov 2025 20:11:20 +0800 Subject: [PATCH 1/6] [PR 99799] boards: st: stm32h745i_disco: m7: Fix sdram available size WARNING: commit picked from P-R 99799. To be preferably reviewed from that P-R. According to UM2488 section 6.12[1], the available SDRAM size is only 8MB by hardware design, though 128Bit SDRAM is connected. Link: https://www.st.com/resource/en/user_manual/um2488-discovery-kits-with-stm32h745xi-and-stm32h750xb-mcus-stmicroelectronics.pdf [1] Signed-off-by: Jisheng Zhang --- boards/st/stm32h745i_disco/stm32h745i_disco_stm32h745xx_m7.dts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/boards/st/stm32h745i_disco/stm32h745i_disco_stm32h745xx_m7.dts b/boards/st/stm32h745i_disco/stm32h745i_disco_stm32h745xx_m7.dts index 66f7d4d4163f3..1a8c0a94d94e8 100644 --- a/boards/st/stm32h745i_disco/stm32h745i_disco_stm32h745xx_m7.dts +++ b/boards/st/stm32h745i_disco/stm32h745i_disco_stm32h745xx_m7.dts @@ -37,7 +37,8 @@ sdram2: sdram@d0000000 { compatible = "zephyr,memory-region", "mmio-sram"; device_type = "memory"; - reg = <0xd0000000 DT_SIZE_M(16)>; /* 128Mbit */ + /* 128Mbit, but only half is available by HW design */ + reg = <0xd0000000 DT_SIZE_M(8)>; zephyr,memory-region = "SDRAM2"; zephyr,memory-attr = ; }; From b823dbae60449e330b6d2761ae2c14cf4d862576 Mon Sep 17 00:00:00 2001 From: Jisheng Zhang Date: Thu, 20 Nov 2025 08:54:25 +0800 Subject: [PATCH 2/6] [PR 99799] boards: st: stm32h750b-dk: Fix sdram available size WARNING: commit picked from P-R 99799. To be preferably reviewed from that P-R. According to UM2488 section 6.12[1], the available SDRAM size is only 8MB by hardware design, though 128Bit SDRAM is connected. Link: https://www.st.com/resource/en/user_manual/um2488-discovery-kits-with-stm32h745xi-and-stm32h750xb-mcus-stmicroelectronics.pdf [1] Signed-off-by: Jisheng Zhang --- boards/st/stm32h750b_dk/stm32h750b_dk-common.dtsi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/boards/st/stm32h750b_dk/stm32h750b_dk-common.dtsi b/boards/st/stm32h750b_dk/stm32h750b_dk-common.dtsi index bfc806f3e7577..bb16bfba15669 100644 --- a/boards/st/stm32h750b_dk/stm32h750b_dk-common.dtsi +++ b/boards/st/stm32h750b_dk/stm32h750b_dk-common.dtsi @@ -20,7 +20,8 @@ sdram2: sdram@d0000000 { compatible = "zephyr,memory-region", "mmio-sram"; device_type = "memory"; - reg = <0xd0000000 DT_SIZE_M(16)>; /* 128Mbit */ + /* 128Mbit, but only half is available by HW design */ + reg = <0xd0000000 DT_SIZE_M(8)>; zephyr,memory-region = "SDRAM2"; zephyr,memory-attr = ; }; From 0539bfcf23cdeddc9e3eb7c1c2b61213194445ec Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Fri, 21 Nov 2025 15:59:12 +0100 Subject: [PATCH 3/6] tests: drivers: memc: fix minor inconsistencies in offsets Correct memc driver test application to allocated only the required size for the tests and print valid information instead of byte offset that was actually a 32bit cell pointer offset. Signed-off-by: Etienne Carriere --- tests/drivers/memc/ram/src/main.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/drivers/memc/ram/src/main.c b/tests/drivers/memc/ram/src/main.c index 36c0677df9995..446d208fbb4fe 100644 --- a/tests/drivers/memc/ram/src/main.c +++ b/tests/drivers/memc/ram/src/main.c @@ -15,7 +15,7 @@ #define BUF_SIZE_SDRAM 64U #define BUF_SIZE_SRAM 64U -#define BUF_DEF(label, size) static uint32_t buf_##label[size] \ +#define BUF_DEF(label, size) static uint32_t buf_##label[(size) / sizeof(uint32_t)] \ Z_GENERIC_SECTION(LINKER_DT_NODE_REGION_NAME(DT_NODELABEL(label))) /** @@ -23,16 +23,19 @@ * * @param mem RAM memory location to be tested. */ -static void test_ram_rw(uint32_t *mem, size_t size) +static void test_ram_rw(uint32_t *mem, size_t size_byte) { + size_t size_32b = size_byte / sizeof(uint32_t); + /* fill memory with number range (0, BUF_SIZE - 1) */ - for (size_t i = 0U; i < size / sizeof(uint32_t); i++) { + for (size_t i = 0U; i < size_32b; i++) { mem[i] = i; } /* check that memory contains written range */ - for (size_t i = 0U; i < size / sizeof(uint32_t); i++) { - zassert_equal(mem[i], i, "Unexpected content on byte %zd", i); + for (size_t i = 0U; i < size_32b; i++) { + zassert_equal(mem[i], i, "Unexpected content @%p: 0x%x != 0x%zx", + mem + i, mem[i], i); } } From dce13f53137ca3c85a42149f512d3129fc451f06 Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Fri, 21 Nov 2025 16:42:18 +0100 Subject: [PATCH 4/6] boards: st: stm32h745i_disco: increase FMC SDRAM clock period Testing full SDRAM access on stm32h745i_disco showed instabilities and corrupted accessed. Increasing the FMC SDRAM clock period fixes the issue. This change ensures stability of transactions with the SDRAM but may be sub-optimized regarding performances. An alternate correction would need further investigations in the FMC interface timings and clocks configuration. Signed-off-by: Etienne Carriere --- boards/st/stm32h745i_disco/stm32h745i_disco_stm32h745xx_m7.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards/st/stm32h745i_disco/stm32h745i_disco_stm32h745xx_m7.dts b/boards/st/stm32h745i_disco/stm32h745i_disco_stm32h745xx_m7.dts index 1a8c0a94d94e8..7bfc790aba5d1 100644 --- a/boards/st/stm32h745i_disco/stm32h745i_disco_stm32h745xx_m7.dts +++ b/boards/st/stm32h745i_disco/stm32h745i_disco_stm32h745xx_m7.dts @@ -275,7 +275,7 @@ STM32_FMC_SDRAM_MWID_16 STM32_FMC_SDRAM_NB_4 STM32_FMC_SDRAM_CAS_2 - STM32_FMC_SDRAM_SDCLK_PERIOD_2 + STM32_FMC_SDRAM_SDCLK_PERIOD_3 STM32_FMC_SDRAM_RBURST_ENABLE STM32_FMC_SDRAM_RPIPE_0>; st,sdram-timing = <2 7 4 7 2 2 2>; From 4cb632ac98d577856b1a655689b56f62f1e80c5a Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Fri, 21 Nov 2025 14:07:54 +0100 Subject: [PATCH 5/6] boards: st: stm32h750b_dk: increase FMC SDRAM clock period Testing full SDRAM access on stm32h750b_disco showed instabilities and corrupted accessed. Increasing the FMC SDRAM clock period fixes the issue. This change ensures stability of transactions with the SDRAM but may be sub-optimized regarding performances. An alternate correction would need further investigations in the FMC interface timings and clocks configuration. Signed-off-by: Etienne Carriere --- boards/st/stm32h750b_dk/stm32h750b_dk-common.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards/st/stm32h750b_dk/stm32h750b_dk-common.dtsi b/boards/st/stm32h750b_dk/stm32h750b_dk-common.dtsi index bb16bfba15669..546cc5c06baf4 100644 --- a/boards/st/stm32h750b_dk/stm32h750b_dk-common.dtsi +++ b/boards/st/stm32h750b_dk/stm32h750b_dk-common.dtsi @@ -237,7 +237,7 @@ STM32_FMC_SDRAM_MWID_16 STM32_FMC_SDRAM_NB_4 STM32_FMC_SDRAM_CAS_3 - STM32_FMC_SDRAM_SDCLK_PERIOD_2 + STM32_FMC_SDRAM_SDCLK_PERIOD_3 STM32_FMC_SDRAM_RBURST_ENABLE STM32_FMC_SDRAM_RPIPE_1>; st,sdram-timing = <2 7 4 7 2 2 2>; From e3bc8397f0a87fd780f15f5155f9967f4db446e8 Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Fri, 21 Nov 2025 16:26:32 +0100 Subject: [PATCH 6/6] tests: drivers: memc: test full SDRAM on a few stm32 boards Add an overlay for some STM32 boards that embed an SDRAM connected through FMC interface to better cover their accessibility. Despite each SDRAM is a few MByte large test are not too long lasting: - stm32f769i_disco (16MByte): 2s - stm32h747i_disco (32MByte): <0.6s - stm32h745i_disco (8Mbyte): <0.2s - stm32h750b_dk (8Mbyte): <0.2s Adding these test ensures non-regression on SDRAM support. Signed-off-by: Etienne Carriere --- .../memc/ram/boards/stm32f769i_disco.overlay | 13 +++++++++++++ .../boards/stm32h745i_disco_stm32h745xx_m7.overlay | 13 +++++++++++++ .../boards/stm32h747i_disco_stm32h747xx_m7.overlay | 13 +++++++++++++ tests/drivers/memc/ram/boards/stm32h750b_dk.overlay | 13 +++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 tests/drivers/memc/ram/boards/stm32f769i_disco.overlay create mode 100644 tests/drivers/memc/ram/boards/stm32h745i_disco_stm32h745xx_m7.overlay create mode 100644 tests/drivers/memc/ram/boards/stm32h747i_disco_stm32h747xx_m7.overlay create mode 100644 tests/drivers/memc/ram/boards/stm32h750b_dk.overlay diff --git a/tests/drivers/memc/ram/boards/stm32f769i_disco.overlay b/tests/drivers/memc/ram/boards/stm32f769i_disco.overlay new file mode 100644 index 0000000000000..1d6821ed8ab27 --- /dev/null +++ b/tests/drivers/memc/ram/boards/stm32f769i_disco.overlay @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2025 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* Test the full SDRAM accesses. Discable LTDC to prevent conflicts */ + +ram0: &sdram1 {}; + +<dc { + status = "disabled"; +}; diff --git a/tests/drivers/memc/ram/boards/stm32h745i_disco_stm32h745xx_m7.overlay b/tests/drivers/memc/ram/boards/stm32h745i_disco_stm32h745xx_m7.overlay new file mode 100644 index 0000000000000..b0cb816f9b100 --- /dev/null +++ b/tests/drivers/memc/ram/boards/stm32h745i_disco_stm32h745xx_m7.overlay @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2025 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* Test the full SDRAM accesses. Discable LTDC to prevent conflicts */ + +ram0: &sdram2 {}; + +<dc { + status = "disabled"; +}; diff --git a/tests/drivers/memc/ram/boards/stm32h747i_disco_stm32h747xx_m7.overlay b/tests/drivers/memc/ram/boards/stm32h747i_disco_stm32h747xx_m7.overlay new file mode 100644 index 0000000000000..b0cb816f9b100 --- /dev/null +++ b/tests/drivers/memc/ram/boards/stm32h747i_disco_stm32h747xx_m7.overlay @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2025 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* Test the full SDRAM accesses. Discable LTDC to prevent conflicts */ + +ram0: &sdram2 {}; + +<dc { + status = "disabled"; +}; diff --git a/tests/drivers/memc/ram/boards/stm32h750b_dk.overlay b/tests/drivers/memc/ram/boards/stm32h750b_dk.overlay new file mode 100644 index 0000000000000..b0cb816f9b100 --- /dev/null +++ b/tests/drivers/memc/ram/boards/stm32h750b_dk.overlay @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2025 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* Test the full SDRAM accesses. Discable LTDC to prevent conflicts */ + +ram0: &sdram2 {}; + +<dc { + status = "disabled"; +};