Skip to content

STM32H7S78-DK Ethernet support #99164

@bklaric1

Description

@bklaric1

Is your feature request related to a problem? Please describe.

I wanted to implement Ethernet support for the STM32H7S78-DK board, which under Zephyr at the moment doesn't officially support Ethernet.

I based my work on the STM32H7S3L8 board (with adapted pins) and successfully tested Ethernet using the dumb_http_server sample.

Before opening a PR, I’d like feedback on one implementation detail.

The setup for Ethernet DMA in mpu_regions.c depends on sram2:

#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(mac))
#define sram_eth_node DT_NODELABEL(sram2)
#if DT_NODE_HAS_STATUS_OKAY(sram_eth_node)
/* Region 5 - Ethernet DMA buffer RAM */
MPU_REGION_ENTRY("SRAM_ETH_BUF", DT_REG_ADDR(sram_eth_node),
REGION_RAM_NOCACHE_ATTR(REGION_16K)),
/* Region 6 - Ethernet DMA descriptor RAM (overlays the first 256B of SRAM_ETH_BUF)*/
MPU_REGION_ENTRY("SRAM_ETH_DESC", DT_REG_ADDR(sram_eth_node), REGION_PPB_ATTR(REGION_256B)),
#endif
#endif

But sram2 is currently disabled, so the MPU regions are not created unless the user manually enables it:
/* System data RAM accessible over AHB bus: SRAM2 in D2 domain */
sram2: memory@30004000 {
compatible = "zephyr,memory-region", "mmio-sram";
reg = <0x30004000 DT_SIZE_K(16)>;
zephyr,memory-region = "SRAM2";
/* Disable SRAM2 by default to avoid unintended access.
* To enable it, explicitly define zephyr,memory-attr
* to configure MPU attributes.
*/
status = "disabled";
};

Describe the solution you'd like

There are two different ways of solving this, at least known to me at this moment:

  1. Enabling sram2 in stm32h7s78_dk-common.dtsi and reducing the sram0 by 16KB:
&sram0 {
	reg = <0x24000000 DT_SIZE_K(440)>;
};

...

&sram2 {
	status = "okay";
	zephyr,memory-attr = <DT_MEM_ARM(ATTR_MPU_RAM)>;
};
  1. Replacing sram2 with sram1 here (or creating a fallback, if sram2 is not available):
    #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(mac))
    #define sram_eth_node DT_NODELABEL(sram2)
    #if DT_NODE_HAS_STATUS_OKAY(sram_eth_node)
    /* Region 5 - Ethernet DMA buffer RAM */
    MPU_REGION_ENTRY("SRAM_ETH_BUF", DT_REG_ADDR(sram_eth_node),
    REGION_RAM_NOCACHE_ATTR(REGION_16K)),
    /* Region 6 - Ethernet DMA descriptor RAM (overlays the first 256B of SRAM_ETH_BUF)*/
    MPU_REGION_ENTRY("SRAM_ETH_DESC", DT_REG_ADDR(sram_eth_node), REGION_PPB_ATTR(REGION_256B)),
    #endif
    #endif

I think this ties, at least partially, to this issue: #98866, since I needed to enable CONFIG_SPEED_OPTIMIZATIONS=y in order to avoid MPU FAULT.

If this is a good way to implement Ethernet support for this board, I will gladly open a PR with these and other needed changes to enable Ethernet.

Thanks in advance.

Describe alternatives you've considered

No response

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions