Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions boards/st/nucleo_h7s3l8/nucleo_h7s3l8.dts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
pinctrl-names = "default";
phy-connection-type = "rmii";
phy-handle = <&eth_phy>;
memory-regions = <&sram1>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use sram2 to preserve to previous configuration?
Otherwise, the commit message should tell that h7rs based device ethnet buffers are now in sram1 (AXI SRAM1) by default instead of sram2 (AXI SRAM2).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sram1 and sram2 are AHB, sram0 is AXI sram (called sram 1-4 in the datasheet/rm)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sram2 is disabled by default. That is why I opted to use sram1.
I can switch to using sram2 but that requires the node to be enabled by default. Otherwise an introduction of a fallback is needed (to sram1).
What should I do here?
I will update the commit message in any case. Thanks @TD-JBL for clarification.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the sram2 is disabled to have users enable it on purpose:

  1. Use as normal ram: enabled it in your board and set zephyr,memory-attr = <DT_MEM_ARM(ATTR_MPU_RAM)>
  2. Use it as dma buffer for ethernet, enable it in your board and let mpu_regions.c configure the mpu-region for it.
    I don't mind changing this behaviour, maybe have it already enabled... not sure whats be best way

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that preserving behavior is that important for a dev board

status = "okay";
};

Expand Down
7 changes: 7 additions & 0 deletions boards/st/stm32h7s78_dk/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ Default Zephyr Peripheral Mapping:
- XSPI1 NCS/DQS0/DQS1/CLK/IO: PO0/PO2/PO3/PO4/PP0..15
- I2C1 SCL/SDA: PB6/PB9
- FDCAN1 RX/TX : PB8/PB9
- ETH: PA2/PA7/PB0/PB1/PC1/PC4/PC5/PD7/PG11

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

Ethernet
--------

In order to use Ethernet on STM32H7S78-DK, you need to set the ``JP6`` jumper
to PC1 position on the back side of the board.

Programming and Debugging
*************************

Expand Down
31 changes: 31 additions & 0 deletions boards/st/stm32h7s78_dk/stm32h7s78_dk-common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
#include "zephyr/dt-bindings/display/panel.h"
#include <zephyr/dt-bindings/input/input-event-codes.h>

/*
* WARNING:
* JP6 must be in PC1 position when using Ethernet.
*/

/ {
chosen {
zephyr,console = &uart4;
Expand Down Expand Up @@ -228,6 +233,32 @@
status = "disabled";
};

&mac {
pinctrl-0 = <&eth_rmii_ref_clk_pd7
&eth_rmii_crs_dv_pa7
&eth_rmii_rxd0_pc4
&eth_rmii_rxd1_pc5
&eth_rmii_tx_en_pg11
&eth_rmii_txd0_pb0
&eth_rmii_txd1_pb1>;
pinctrl-names = "default";
phy-connection-type = "rmii";
phy-handle = <&eth_phy>;
memory-regions = <&sram1>;
status = "okay";
};

&mdio {
pinctrl-0 = <&eth_mdio_pa2 &eth_mdc_pc1>;
pinctrl-names = "default";
status = "okay";

eth_phy: ethernet-phy@0 {
compatible = "ethernet-phy";
reg = <0x00>;
};
};

&xspi1 {
pinctrl-0 = <&xspim_p1_ncs1_po0 &xspim_p1_dqs0_po2
&xspim_p1_dqs1_po3 &xspim_p1_clk_po4
Expand Down
1 change: 1 addition & 0 deletions boards/st/stm32h7s78_dk/stm32h7s78_dk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ supported:
- octospi
- usbd
- memc
- netif:eth
vendor: st
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ supported:
- octospi
- usbd
- memc
- netif:eth
vendor: st
3 changes: 3 additions & 0 deletions dts/arm/st/h7rs/stm32h7rs.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@
reg = <0x24000000 DT_SIZE_K(456)>;
compatible = "zephyr,memory-region", "mmio-sram";
zephyr,memory-region = "SRAM0";
#memory-region-cells = <0>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be removed. We don't expect one to reference &sram0 as a memory-region phandle.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

};

/* System data RAM accessible over AHB bus: SRAM1 in D2 domain */
sram1: memory@30000000 {
reg = <0x30000000 DT_SIZE_K(16)>;
compatible = "zephyr,memory-region", "mmio-sram";
zephyr,memory-region = "SRAM1";
#memory-region-cells = <0>;
zephyr,memory-attr = <DT_MEM_ARM(ATTR_MPU_RAM)>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the change made in #97731, won't sram1 MPU attributes here now conflicts with the one defined by mpu_regions.c?

Copy link
Contributor Author

@bklaric1 bklaric1 Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is partially what I was discussing with @TD-JBL in #99164.
I can only confirm that I get no errors during build process and Ethernet works as expected with either sram1 or sram2.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the change made in #97731, won't sram1 MPU attributes here now conflicts with the one defined by mpu_regions.c?

Yes it will create 2 overlaying mpu regions for sram1 and the one from zephyr,memory-attr has the higher priority and should cause problems with caching on the dma region, but for whatever reason it seems to work.

};

Expand All @@ -69,6 +71,7 @@
compatible = "zephyr,memory-region", "mmio-sram";
reg = <0x30004000 DT_SIZE_K(16)>;
zephyr,memory-region = "SRAM2";
#memory-region-cells = <0>;
/* Disable SRAM2 by default to avoid unintended access.
* To enable it, explicitly define zephyr,memory-attr
* to configure MPU attributes.
Expand Down
9 changes: 8 additions & 1 deletion dts/bindings/ethernet/st,stm32h7-ethernet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,11 @@ description: |
compatible: "st,stm32h7-ethernet"

include: st,stm32-ethernet-common.yaml
include:
- "st,stm32-ethernet-common.yaml"
- "memory-region.yaml"

properties:
memory-regions:
description: |
Reference to SRAM node used for Ethernet DMA buffer and descriptor.
12 changes: 10 additions & 2 deletions soc/st/stm32/stm32h7rsx/mpu_regions.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ static const struct arm_mpu_region mpu_regions[] = {
/* Region 4 - Ready only flash with unique device id */
MPU_REGION_ENTRY("ID", 0x08FFF800, REGION_FLASH_ATTR(REGION_2K)),

#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(mac))
#define sram_eth_node DT_NODELABEL(sram2)
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(mac)) && \
DT_NODE_HAS_PROP(DT_NODELABEL(mac), memory_regions)
#define sram_eth_node DT_PHANDLE(DT_NODELABEL(mac), memory_regions)

#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),
Expand All @@ -42,6 +44,12 @@ static const struct arm_mpu_region mpu_regions[] = {
#endif
};

#ifdef sram_eth_node
BUILD_ASSERT(!DT_SAME_NODE(sram_eth_node, DT_CHOSEN(zephyr_sram)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation

Suggested change
BUILD_ASSERT(!DT_SAME_NODE(sram_eth_node, DT_CHOSEN(zephyr_sram)),
BUILD_ASSERT(!DT_SAME_NODE(sram_eth_node, DT_CHOSEN(zephyr_sram)),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

"Remove property memory-regions from 'mac' node "
"to locate ethernet buffers in system RAM.");
#endif

const struct arm_mpu_config mpu_config = {
.num_regions = ARRAY_SIZE(mpu_regions),
.mpu_regions = mpu_regions,
Expand Down
6 changes: 4 additions & 2 deletions soc/st/stm32/stm32h7rsx/sections.ld
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(mac))
#define sram_eth_node DT_NODELABEL(sram2)
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(mac)) && \
DT_NODE_HAS_PROP(DT_NODELABEL(mac), memory_regions)
#define sram_eth_node DT_PHANDLE(DT_NODELABEL(mac), memory_regions)

#if DT_NODE_HAS_STATUS_OKAY(sram_eth_node)
SECTION_DATA_PROLOGUE(eth_stm32,(NOLOAD),)
{
Expand Down
8 changes: 8 additions & 0 deletions tests/drivers/memc/ram/boards/stm32h7s78_dk.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@
zephyr,memory-attr = <DT_MEM_ARM(ATTR_MPU_RAM)>;
status = "okay";
};

&mac {
/*
* mac is disabled for this test since the ethernet driver that gets
* enabled by this node consumes the sram1 node thus failing this test
*/
status = "disabled";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2025 Benjamin Klaric <benjamin.klaric01@gmail.com>
*
* SPDX-License-Identifier: Apache-2.0
*/

&sram2 {
zephyr,memory-attr = <DT_MEM_ARM(ATTR_MPU_RAM)>;
status = "okay";
};

&mac {
/*
* mac is disabled for this test since the ethernet driver that gets
* enabled by this node consumes the sram1 node thus failing this test
*/
status = "disabled";
};