Skip to content

Commit b480a4c

Browse files
committed
tests: drivers: spi loopback on stm32h7 SRAM2 memory
Configure the SRAM2 of the stm32h7x serie with NOCACHE attribute to run the tests/drivers/spi/spi_loopback Connect D11 to D12 to PASS the test Signed-off-by: Francois Ramu <[email protected]>
1 parent 6c03000 commit b480a4c

File tree

5 files changed

+59
-5
lines changed

5 files changed

+59
-5
lines changed

tests/drivers/spi/spi_loopback/boards/nucleo_h723zg.overlay

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
&sram2 {
8+
zephyr,memory-attr = "RAM_NOCACHE";
9+
};
10+
711
/* Set div-q to get test clk freq into acceptable SPI freq range */
812
&pll {
913
/delete-property/ div-q;

tests/drivers/spi/spi_loopback/boards/nucleo_h743zi.overlay

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
&sram2 {
8+
zephyr,memory-attr = "RAM_NOCACHE";
9+
};
10+
711
&spi1 {
812
dmas = <&dmamux1 0 38 (STM32_DMA_PERIPH_TX | STM32_DMA_PRIORITY_HIGH)
913
&dmamux1 1 37 (STM32_DMA_PERIPH_RX | STM32_DMA_PRIORITY_HIGH)>;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_NOCACHE_MEMORY=y
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2021 STMicroelectronics
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
&sram2 {
8+
zephyr,memory-attr = "RAM_NOCACHE";
9+
};
10+
11+
&spi1 {
12+
dmas = <&dmamux1 0 38 (STM32_DMA_PERIPH_TX | STM32_DMA_PRIORITY_HIGH)
13+
&dmamux1 1 37 (STM32_DMA_PERIPH_RX | STM32_DMA_PRIORITY_HIGH)>;
14+
dma-names = "tx", "rx";
15+
slow@0 {
16+
compatible = "test-spi-loopback-slow";
17+
reg = <0>;
18+
spi-max-frequency = <500000>;
19+
};
20+
fast@0 {
21+
compatible = "test-spi-loopback-fast";
22+
reg = <0>;
23+
spi-max-frequency = <16000000>;
24+
};
25+
};
26+
27+
&dma1 {
28+
status = "okay";
29+
};
30+
31+
&dma2 {
32+
status = "okay";
33+
};
34+
35+
&dmamux1 {
36+
status = "okay";
37+
};

tests/drivers/spi/spi_loopback/src/spi.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,20 @@ static struct spi_dt_spec spi_slow = SPI_DT_SPEC_GET(SPI_SLOW_DEV, SPI_OP, 0);
3838
#define BUF_SIZE 17
3939
#define BUF2_SIZE 36
4040

41-
#if CONFIG_NOCACHE_MEMORY
41+
#ifdef CONFIG_NOCACHE_MEMORY
42+
43+
#ifdef CONFIG_SOC_SERIES_STM32H7X
44+
#define CACHE_SECTION __attribute__((__section__("SRAM2")))
45+
#else
46+
#define CACHE_SECTION __attribute__((__section__(".nocache")))
47+
#endif /* CONFIG_SOC_SERIES_STM32H7X */
48+
4249
static const char tx_data[BUF_SIZE] = "0123456789abcdef\0";
43-
static __aligned(32) char buffer_tx[BUF_SIZE] __used __attribute__((__section__(".nocache")));
44-
static __aligned(32) char buffer_rx[BUF_SIZE] __used __attribute__((__section__(".nocache")));
50+
static __aligned(32) char buffer_tx[BUF_SIZE] __used CACHE_SECTION;
51+
static __aligned(32) char buffer_rx[BUF_SIZE] __used CACHE_SECTION;
4552
static const char tx2_data[BUF2_SIZE] = "Thequickbrownfoxjumpsoverthelazydog\0";
46-
static __aligned(32) char buffer2_tx[BUF2_SIZE] __used __attribute__((__section__(".nocache")));
47-
static __aligned(32) char buffer2_rx[BUF2_SIZE] __used __attribute__((__section__(".nocache")));
53+
static __aligned(32) char buffer2_tx[BUF2_SIZE] __used CACHE_SECTION;
54+
static __aligned(32) char buffer2_rx[BUF2_SIZE] __used CACHE_SECTION;
4855
#else
4956
/* this src memory shall be in RAM to support using as a DMA source pointer.*/
5057
static uint8_t buffer_tx[] = "0123456789abcdef\0";
@@ -598,6 +605,7 @@ static void *spi_loopback_setup(void)
598605
memset(buffer2_tx, 0, sizeof(buffer2_tx));
599606
memcpy(buffer2_tx, tx2_data, sizeof(tx2_data));
600607
#endif
608+
601609
return NULL;
602610
}
603611

0 commit comments

Comments
 (0)