Skip to content

Commit dcbc56c

Browse files
zagorstephanosio
authored andcommitted
ethernet: stm32h7: Move DMA buffers from sram3 to sram2
PR #30403 implemented nocache regions for ethernet DMA buffers in sram3 to fix issue #29915. Unfortunately, some STM32H7 variants do not have any sram3 so they still suffer from #29915. All H7 variants have sram2 though, so use that for targets without sram3. Signed-off-by: Björn Stenberg <[email protected]>
1 parent 774330f commit dcbc56c

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

drivers/ethernet/eth_stm32_hal.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
8080
DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_dtcm), okay)
8181
#define __eth_stm32_desc __dtcm_noinit_section
8282
#define __eth_stm32_buf __dtcm_noinit_section
83-
#elif defined(CONFIG_SOC_SERIES_STM32H7X) && \
84-
DT_NODE_HAS_STATUS(DT_NODELABEL(sram3), okay)
83+
#elif defined(CONFIG_SOC_SERIES_STM32H7X)
8584
#define __eth_stm32_desc __attribute__((section(".eth_stm32_desc")))
8685
#define __eth_stm32_buf __attribute__((section(".eth_stm32_buf")))
8786
#elif defined(CONFIG_NOCACHE_MEMORY)

soc/arm/st_stm32/stm32h7/mpu_regions.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,22 @@ static const struct arm_mpu_region mpu_regions[] = {
1313
REGION_FLASH_ATTR(REGION_FLASH_SIZE)),
1414
MPU_REGION_ENTRY("SRAM", CONFIG_SRAM_BASE_ADDRESS,
1515
REGION_RAM_ATTR(REGION_SRAM_SIZE)),
16-
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sram3), okay) && \
17-
DT_NODE_HAS_STATUS(DT_NODELABEL(mac), okay)
16+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(mac), okay)
17+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sram3), okay)
1818
MPU_REGION_ENTRY("SRAM3_ETH_BUF",
1919
DT_REG_ADDR(DT_NODELABEL(sram3)),
2020
REGION_RAM_NOCACHE_ATTR(REGION_16K)),
2121
MPU_REGION_ENTRY("SRAM3_ETH_DESC",
2222
DT_REG_ADDR(DT_NODELABEL(sram3)),
2323
REGION_PPB_ATTR(REGION_256B)),
24+
#else
25+
MPU_REGION_ENTRY("SRAM2_ETH_BUF",
26+
DT_REG_ADDR(DT_NODELABEL(sram2)),
27+
REGION_RAM_NOCACHE_ATTR(REGION_16K)),
28+
MPU_REGION_ENTRY("SRAM2_ETH_DESC",
29+
DT_REG_ADDR(DT_NODELABEL(sram2)),
30+
REGION_PPB_ATTR(REGION_256B)),
31+
#endif
2432
#endif
2533

2634
/* DT-defined regions */

soc/arm/st_stm32/stm32h7/sections.ld

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,24 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sram3), okay) && DT_NODE_HAS_STATUS(DT_NODELABEL(mac), okay)
7+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(mac), okay)
88

99
SECTION_DATA_PROLOGUE(eth_stm32,(NOLOAD),)
1010
{
11+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(sram3), okay)
1112
. = ABSOLUTE(DT_REG_ADDR(DT_NODELABEL(sram3)));
1213
*(.eth_stm32_desc)
1314
. = ABSOLUTE(DT_REG_ADDR(DT_NODELABEL(sram3))) + 256;
1415
*(.eth_stm32_buf)
1516
. = ABSOLUTE(DT_REG_ADDR(DT_NODELABEL(sram3))) + 16K;
1617
} GROUP_DATA_LINK_IN(LINKER_DT_NODE_REGION_NAME(DT_NODELABEL(sram3)), LINKER_DT_NODE_REGION_NAME(DT_NODELABEL(sram3)))
1718

19+
#else
20+
. = ABSOLUTE(DT_REG_ADDR(DT_NODELABEL(sram2)));
21+
*(.eth_stm32_desc)
22+
. = ABSOLUTE(DT_REG_ADDR(DT_NODELABEL(sram2))) + 256;
23+
*(.eth_stm32_buf)
24+
. = ABSOLUTE(DT_REG_ADDR(DT_NODELABEL(sram2))) + 16K;
25+
} GROUP_DATA_LINK_IN(LINKER_DT_NODE_REGION_NAME(DT_NODELABEL(sram2)), LINKER_DT_NODE_REGION_NAME(DT_NODELABEL(sram2)))
26+
#endif
1827
#endif

0 commit comments

Comments
 (0)