-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Description
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:
zephyr/soc/st/stm32/stm32h7rsx/mpu_regions.c
Lines 33 to 42 in 91b1b84
| #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:zephyr/dts/arm/st/h7rs/stm32h7rs.dtsi
Lines 67 to 77 in 91b1b84
| /* 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:
- Enabling
sram2in stm32h7s78_dk-common.dtsi and reducing thesram0by 16KB:
&sram0 {
reg = <0x24000000 DT_SIZE_K(440)>;
};
...
&sram2 {
status = "okay";
zephyr,memory-attr = <DT_MEM_ARM(ATTR_MPU_RAM)>;
};
- Replacing
sram2withsram1here (or creating a fallback, ifsram2is not available):
zephyr/soc/st/stm32/stm32h7rsx/mpu_regions.c
Lines 33 to 42 in 91b1b84
#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