Skip to content

Commit f24dfb6

Browse files
committed
boards: st: stm32h7s78_dk: add Ethernet support
Add Ethernet configuration for mac and mdio nodes. Define the SRAM region for Ethernet descriptor and buffer using memory-region = <...> in the mac node for this board and for nucleo_h7s3l8, since they both use the same mpu_regions.c and sections.ld files. Update mpu_regions.c and sections.ld to use the region defined in board's .dtsi file via phandle. Add a check to mpu_regions.c to make sure the memory-region node doesn't refer to the zephyr,sram region. Disable mac node in .overlay files for tests/drivers/memc/ram since ethernet drivers that get enabled by it consume sram1 node and thus fail the test. Update the yaml files to include Ethernet tag and update documentation to explain Ethernet usage. Signed-off-by: Benjamin Klaric <benjamin.klaric01@gmail.com>
1 parent 1814b90 commit f24dfb6

File tree

10 files changed

+82
-2
lines changed

10 files changed

+82
-2
lines changed

boards/st/nucleo_h7s3l8/nucleo_h7s3l8.dts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@
181181
pinctrl-names = "default";
182182
phy-connection-type = "rmii";
183183
phy-handle = <&eth_phy>;
184+
memory-region = <&sram1>;
184185
status = "okay";
185186
};
186187

boards/st/stm32h7s78_dk/doc/index.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ Default Zephyr Peripheral Mapping:
181181
- XSPI1 NCS/DQS0/DQS1/CLK/IO: PO0/PO2/PO3/PO4/PP0..15
182182
- I2C1 SCL/SDA: PB6/PB9
183183
- FDCAN1 RX/TX : PB8/PB9
184+
- ETH: PA2/PA7/PB0/PB1/PC1/PC4/PC5/PD7/PG11
184185

185186
System Clock
186187
------------
@@ -208,6 +209,12 @@ STM32H7S78-DK Discovery board has 2 FDCAN bus interfaces.
208209
FDCAN1 is configured but not enabled by default. To enable it, make sure
209210
that ``i2c1`` is disabled, since they share the PB9 pin.
210211

212+
Ethernet
213+
--------
214+
215+
In order to use Ethernet on STM32H7S78-DK, you need to set the ``JP6`` jumper
216+
to PC1 position on the back side of the board.
217+
211218
Programming and Debugging
212219
*************************
213220

boards/st/stm32h7s78_dk/stm32h7s78_dk-common.dtsi

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
#include "zephyr/dt-bindings/display/panel.h"
1212
#include <zephyr/dt-bindings/input/input-event-codes.h>
1313

14+
/*
15+
* WARNING:
16+
* JP6 must be in PC1 position when using Ethernet.
17+
*/
18+
1419
/ {
1520
chosen {
1621
zephyr,console = &uart4;
@@ -228,6 +233,32 @@
228233
status = "disabled";
229234
};
230235

236+
&mac {
237+
pinctrl-0 = <&eth_rmii_ref_clk_pd7
238+
&eth_rmii_crs_dv_pa7
239+
&eth_rmii_rxd0_pc4
240+
&eth_rmii_rxd1_pc5
241+
&eth_rmii_tx_en_pg11
242+
&eth_rmii_txd0_pb0
243+
&eth_rmii_txd1_pb1>;
244+
pinctrl-names = "default";
245+
phy-connection-type = "rmii";
246+
phy-handle = <&eth_phy>;
247+
memory-region = <&sram1>;
248+
status = "okay";
249+
};
250+
251+
&mdio {
252+
pinctrl-0 = <&eth_mdio_pa2 &eth_mdc_pc1>;
253+
pinctrl-names = "default";
254+
status = "okay";
255+
256+
eth_phy: ethernet-phy@0 {
257+
compatible = "ethernet-phy";
258+
reg = <0x00>;
259+
};
260+
};
261+
231262
&xspi1 {
232263
pinctrl-0 = <&xspim_p1_ncs1_po0 &xspim_p1_dqs0_po2
233264
&xspim_p1_dqs1_po3 &xspim_p1_clk_po4

boards/st/stm32h7s78_dk/stm32h7s78_dk.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ supported:
1616
- octospi
1717
- usbd
1818
- memc
19+
- netif:eth
1920
vendor: st

boards/st/stm32h7s78_dk/stm32h7s78_dk_stm32h7s7xx_ext_flash_app.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ supported:
1717
- octospi
1818
- usbd
1919
- memc
20+
- netif:eth
2021
vendor: st

dts/bindings/ethernet/st,stm32h7-ethernet.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,9 @@ description: |
1212
compatible: "st,stm32h7-ethernet"
1313

1414
include: st,stm32-ethernet-common.yaml
15+
16+
properties:
17+
memory-region:
18+
type: phandle
19+
description: |
20+
Reference to SRAM node used for Ethernet DMA buffer and descriptor.

soc/st/stm32/stm32h7rsx/mpu_regions.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ static const struct arm_mpu_region mpu_regions[] = {
3131
MPU_REGION_ENTRY("ID", 0x08FFF800, REGION_FLASH_ATTR(REGION_2K)),
3232

3333
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(mac))
34-
#define sram_eth_node DT_NODELABEL(sram2)
34+
#define sram_eth_node DT_PHANDLE(DT_NODELABEL(mac), memory_region)
35+
36+
#if DT_NODE_HAS_COMPAT(sram_eth_node, zephyr_sram)
37+
#error "Invalid Ethernet memory-region: cannot use zephyr,sram. \
38+
Use a SRAM region like sram1 or sram2 for Ethernet."
39+
#endif
40+
3541
#if DT_NODE_HAS_STATUS_OKAY(sram_eth_node)
3642
/* Region 5 - Ethernet DMA buffer RAM */
3743
MPU_REGION_ENTRY("SRAM_ETH_BUF", DT_REG_ADDR(sram_eth_node),

soc/st/stm32/stm32h7rsx/sections.ld

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
*/
66

77
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(mac))
8-
#define sram_eth_node DT_NODELABEL(sram2)
8+
#define sram_eth_node DT_PHANDLE(DT_NODELABEL(mac), memory_region)
9+
910
#if DT_NODE_HAS_STATUS_OKAY(sram_eth_node)
1011
SECTION_DATA_PROLOGUE(eth_stm32,(NOLOAD),)
1112
{

tests/drivers/memc/ram/boards/stm32h7s78_dk.overlay

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,11 @@
88
zephyr,memory-attr = <DT_MEM_ARM(ATTR_MPU_RAM)>;
99
status = "okay";
1010
};
11+
12+
&mac {
13+
/*
14+
* mac is disabled for this test since the ethernet driver that gets
15+
* enabled by this node consumes the sram1 node thus failing this test
16+
*/
17+
status = "disabled";
18+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) 2025 Benjamin Klaric <benjamin.klaric01@gmail.com>
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
&sram2 {
8+
zephyr,memory-attr = <DT_MEM_ARM(ATTR_MPU_RAM)>;
9+
status = "okay";
10+
};
11+
12+
&mac {
13+
/*
14+
* mac is disabled for this test since the ethernet driver that gets
15+
* enabled by this node consumes the sram1 node thus failing this test
16+
*/
17+
status = "disabled";
18+
};

0 commit comments

Comments
 (0)