Skip to content

Conversation

TD-JBL
Copy link
Contributor

@TD-JBL TD-JBL commented Oct 10, 2025

This PR adds ethernet support for STM32H7RS series microcontrollers.
It's almost a 1:1 copy of h7x ethernet configuration. Only register addresses, clock sources and interrupt numbers changed in device tree and the used RAM for DMA buffer.

Changes:

  • Add ethernet node with mac and mdio subnodes to dts similar to h7-family.
  • Add SOC_SERIES_STM32H7RSX where appicable next to SOC_SERIES_STM32H7X.
  • Add ethernet DMA buffer/descriptor region (sram2) and read only flash region (0x08FFF800) with unique device ID registers to MPU region list.
  • Ethernet DMA buffer/descriptor memory section is added to soc linker script.
  • Enable support for ethernet on nucleo_h7s3l8 board.

Used DMA memory

As all h7rs variants have the same memory configuration, there is no need to support multiple memories as DMA buffer. sram1 and sram2 (AHB SRAM1 and AHB SRAM2) are identical, so I hardcoded the DMA buffer into sram2.

At first I tried not defining any special memory and let the driver use the NOCACHE memory, but after reading #29915 and #30403 I decided to keep it as near as possible to the h7x implementation.

Edit: Is it possible or useful to add a Kconfig option or dts property to select the used sram node?

0x08FFF800 read only flash region with unique device ID registers

The controller memfaults without this region in the MPU list while trying to read the uniqe device ID registers. The PR #94019 introduced a different way of preventing speculative access in entire memory space than the one used for h7x:
MPU_REGION_ENTRY("UNMAPPED", 0, {REGION_4G | MPU_RASR_XN_Msk | P_NA_U_NA_Msk}),
Every accessed memory must get a MPU region after blocking access to the complete memory space with this entry.

The unique device ID is used to create a random mac address by the ethernet driver in some conditions.

Testing Status:

  • It responds to ping ;)
  • Tested on NUCLEO-H7S3L8 with custom bootloader/app. As I'm not familiar with mcuboot, I didn't run tests with samples like echo_server, they are too big to fit into internal flash and need XiP.

Maybe someone more familiar with running mcuboot+samples on this board can run some tests?

Add ethernet node with mac and mdio subnodes to dts similar to h7-family.

Signed-off-by: Thomas Decker <[email protected]>
@decsny decsny removed their request for review October 10, 2025 16:09
@TD-JBL TD-JBL changed the title stm32h7rs ethernet support STM32: add ethernet support to stm32h7rs Oct 13, 2025
@erwango erwango added this to the v4.3.0 milestone Oct 13, 2025
Copy link

@juickar juickar left a comment

Choose a reason for hiding this comment

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

Hello @TD-JBL , thanks for the contribution. Could you add the pin layout used for the Ethernet in the index.rst of the board in the last commit?

zephyr/boards/st/nucleo_h7s3l8/doc/index.rst :

In the Default Zephyr Peripheral Mapping part :

+ -ETH : PA2, PA7, PB6, PG4, PG5, PG6, PG11, PG12, PG13

Otherwise it looks goods to me

@TD-JBL
Copy link
Contributor Author

TD-JBL commented Oct 14, 2025

Hello @TD-JBL , thanks for the contribution. Could you add the pin layout used for the Ethernet in the index.rst of the board in the last commit?

Sure, added the documentation. I also fixed a wrong heading format in this file (I added with FDCAN documentation). Is it ok to add this in a extra commit to this PR?

@TD-JBL TD-JBL requested a review from juickar October 14, 2025 13:47
etienne-lms
etienne-lms previously approved these changes Oct 16, 2025
Copy link
Contributor

@etienne-lms etienne-lms left a comment

Choose a reason for hiding this comment

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

LGTM with minor issues fixed or not.

I also fixed a wrong heading format in this file (I added with FDCAN documentation). Is it ok to add this in a extra commit to this PR?

Yes, fine with me.

Add SOC_SERIES_STM32H7RSX to applicable Kconfig parameters and enable
use of .eth_stm32_desc and .eth_stm32_buf linker sections for ethernet
dma.

Signed-off-by: Thomas Decker <[email protected]>
Add ethernet DMA buffer/descriptor region (sram2) and read only
flash region 0x08FFF800 with unique device ID registers to MPU region
list. The unique device ID is used to create a random mac address by
the ethernet driver. Ethernet DMA buffer/descriptor memory section is
also added to linker script.

Signed-off-by: Thomas Decker <[email protected]>
Enable support for ethernet on nucleo_h7s3l8 board.

Signed-off-by: Thomas Decker <[email protected]>
Fix wrong heading type in index.rst introduced with PR zephyrproject-rtos#95388

Signed-off-by: Thomas Decker <[email protected]>
@erwango
Copy link
Member

erwango commented Oct 16, 2025

@juickar PTAL

Copy link

@erwango erwango requested a review from etienne-lms October 16, 2025 14:40
@@ -26,6 +26,20 @@ static const struct arm_mpu_region mpu_regions[] = {

/* Region 3 */
MPU_REGION_ENTRY("SRAM_0", CONFIG_SRAM_BASE_ADDRESS, REGION_RAM_ATTR(REGION_SRAM_SIZE)),

/* Region 4 - Ready only flash with unique device id */
MPU_REGION_ENTRY("ID", 0x08FFF800, REGION_FLASH_ATTR(REGION_2K)),
Copy link
Member

Choose a reason for hiding this comment

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

@djiatsaf-st Can you confirm this is ok with you wrt #97731 ?
I guess name could be either but size may be adapted ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I confirm that it works well

Copy link
Contributor Author

@TD-JBL TD-JBL Oct 17, 2025

Choose a reason for hiding this comment

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

Please also read my comment on PR #97731 about MPU configuration issues between this two PRs

Copy link
Member

Choose a reason for hiding this comment

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

@TD-JBL Comment is not visible.

Copy link
Contributor Author

@TD-JBL TD-JBL Oct 17, 2025

Choose a reason for hiding this comment

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

My comment has a pending note next to it. Not sure for what it is waiting for. I'm not yet very familiar with the GitHub user interface....

I quote my comment from the other PR:

My PR #97364 most likely gets a problem with adding the memory attribute to sram2, because the order of MPU region initialization (see arm_mpu.c):

  1. elements from mpu_regions.c
  2. entries from the device tree with zephyr,memory-attr property
  3. entries resulting from CONFIG_USERSPACE, CONFIG_NOCACHE_MEMORY etc
  4. dynamic entries

As later defined regions overlapping earlier ones have a higher priority (called region overlay), the ATTR_MPU_RAM from dt will overlay the REGION_RAM_NOCACHE_ATTR / REGION_PPB_ATTR from my PR's mpu_regions.c. Never tried to overlay a smaller region with a bigger one, so maybe this is even illegal? Anyway, I need to figure a way to define my DMA memory regions after it is configured as standard memory.

I see the point of this change (and use it in my custom boards dts for other mem nodes), but how can I solve this?

Copy link
Member

Choose a reason for hiding this comment

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

Not sure for what it is waiting for.

You need to submit your review (green button in the upper right)

@jhedberg jhedberg merged commit 18f1d33 into zephyrproject-rtos:main Oct 17, 2025
28 checks passed
@TD-JBL TD-JBL deleted the zephyr/h7rs_eth branch October 20, 2025 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants