Skip to content

Conversation

arnopo
Copy link
Contributor

@arnopo arnopo commented Sep 17, 2025

This Pull reuest enable the support of the ethernet 1 instance

Hardware details:

  • the PHY is a LAN8742A with an Hardware reset based on a GPIO.
  • the clock reference is an externl crystal running at 25 Mhz
  • 16K of non cacheable memory in the SYSRAM is used to store ethernet DMA Buffers and descriptors

Samples tested:

  • samples/net/ipv4_autoconf
  • samples/net/dhcpv4_client

Known current limitation:

  • Ethernet2 instance not implemented
  • sample/net/zperf not build

Copy link

github-actions bot commented Sep 17, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
hal_stm32 zephyrproject-rtos/hal_stm32@d768bcb zephyrproject-rtos/hal_stm32@b6f03b6 (main) zephyrproject-rtos/[email protected]

Additional metadata changed:

Name URL Submodules West cmds module.yml Blobs
hal_stm32 2x ✏

DNM label due to: 1 project with metadata changes and 2 blob changes

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@github-actions github-actions bot added manifest manifest-hal_stm32 DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Sep 17, 2025
Comment on lines 18 to 19
# Zephyr Kernel Configuration
CONFIG_KERNEL_DIRECT_MAP=y
Copy link
Member

Choose a reason for hiding this comment

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

Should this really be part of the board _defconfig?
Doesn't it apply to the series in general ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, as we use MMU_REGION_FLAT_ENTRY in https://github.com/zephyrproject-rtos/zephyr/blob/main/soc/st/stm32/stm32mp13x/soc.c we need is at Soc level

# UART console (overrides remote proc console)
CONFIG_UART_CONSOLE=y

# Enable I2C support
Copy link
Member

@erwango erwango Sep 17, 2025

Choose a reason for hiding this comment

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

Suggested change
# Enable I2C support
# Enable I2C support (for mcp23017 GPIO expander)

Alternatively, could be enabled depending on expander compatible status in .defconfig file.

Copy link
Member

Choose a reason for hiding this comment

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

GPIO_MCP230XX should select I2C, instead of depending on it. see https://docs.zephyrproject.org/latest/build/kconfig/tips.html#select-recommendations

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@maass-hamburg
Seems we are facing "egg or chicken" dilemma between I2C and GPIO_MCP230XX should I replace depends on I2C

menuconfig GPIO_MCP230XX
	bool "MCP230XX I2C-based GPIO chip"
	default y
	depends on DT_HAS_MICROCHIP_MCP23008_ENABLED || \
	           DT_HAS_MICROCHIP_MCP23009_ENABLED || \
	           DT_HAS_MICROCHIP_MCP23016_ENABLED || \
	           DT_HAS_MICROCHIP_MCP23017_ENABLED || \
	           DT_HAS_MICROCHIP_MCP23018_ENABLED
-	depends on I2C
+	select I2C
	select GPIO_MCP23XXX
	help
	  Enable driver for MCP230XX I2C-based GPIO chip.

Copy link
Member

Choose a reason for hiding this comment

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

yes

&rcc {
clock-frequency = <DT_FREQ_M(1000)>;
clocks = <&pll>;
clocks = <&pll &pll4>;
Copy link
Member

Choose a reason for hiding this comment

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

clocks here is the main clock tree input. Only one entry is supported.

@erwango
Copy link
Member

erwango commented Sep 17, 2025

FYI, it'll have to be rebased on top of #96095

Comment on lines 29 to 32
reset-gpios:
type: phandle-array
description: |
This reset gpio can be used for PHY with hardware reset.
Copy link
Member

Choose a reason for hiding this comment

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

the ethernet-phy driver is meant to be generic and only implement features, that are defined in the ethernet standard IEEE 802.3. It doesn't specify a reset pin, only the register, which should be enought. If you want a reset pin, you have to create a specific phy driver.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have created a LAN8742 inspired from ethernet_phy

(clock_control_subsys_t)&cfg->pclken_tx);
ret |= clock_control_on(DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE),
(clock_control_subsys_t)&cfg->pclken_rx);
#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32mp13_ethernet)
Copy link
Member

Choose a reason for hiding this comment

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

Can't you check DT_INST_CLOCKS_HAS_NAME(0, mac_clk) instead ?

struct eth_stm32_hal_dev_data *dev_data = dev->data;
const struct eth_stm32_hal_dev_cfg *cfg = dev->config;
ETH_HandleTypeDef *heth = &dev_data->heth;
uint8_t *desc_uncached_addr;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
uint8_t *desc_uncached_addr;
__maybe_unused uint8_t *desc_uncached_addr;


#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32mp13_ethernet)
/* APO test : TBD */
heth->Init.ClockSelection = cfg->ClockSelection;
Copy link
Member

Choose a reason for hiding this comment

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

Ideally please use clock_control_configure()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would prefer not use it. The concerning register is a SYSCFG register that is updated by HAL_ETH_Init() function.
If I set it before calling HAL_ETH_Init() it will overwritte it
Else if set it after HAL_ETH_Init() it could generate side effect.

@arnopo arnopo force-pushed the mp13_eth branch 4 times, most recently from 5ed3b84 to 86f88cc Compare September 22, 2025 15:23
@arnopo
Copy link
Contributor Author

arnopo commented Sep 25, 2025

To be able to run Zperf we need #96575

arnopo added 9 commits October 6, 2025 11:12
Add new flags to allow to select normal and strong ordered attributes
for non-cacheable memory. This is needed for armV7 to be able to configure
all non cacheable memories with another attribute than "device" attribute.

Signed-off-by: Arnaud Pouliquen <[email protected]>
Selecting MT_DEVICE for non cache-able memory does no work in all use
cases.
For instance for net samples a non-cacheable memory can be used for
descriptors and buffers exchanged between the lib and the hardware.
In such context, the net lib can perform some non word aligned memory
this lead to an alignment data abort if the attribute is MT_DEVICE.
Memories attribute should be MT_NORMAL, allowing non aligned transfer

Signed-off-by: Arnaud Pouliquen <[email protected]>arch: arm: mmu: allow selecting memory type for non-cacheable memory
New hal_stm32 revision contains pincontrol for the etherent support.

Signed-off-by: Arnaud Pouliquen <[email protected]>
Introduce stm32mp13 bindings to support the ethernet peripherals.
The "memory-regions" property is used to reference non cacheable memory
for the ETH DMA.
The  "st,ext-phyclk" property aligned Linux binding is used to specify
the PHY clock for RMII.

Signed-off-by: Arnaud Pouliquen <[email protected]>
Add basic support of the LAN8742 RMII phy. The driver is inspired
from the phy_mii generic driver, with the support of a GPIO reset.

Signed-off-by: Arnaud Pouliquen <[email protected]>
The GPIO_MCP230XX config currently depends on the I2C config. This means
that the board/SoC must enable the I2C config to support MCP23xxx devices.
Inverting this dependency allows declaring GPIO_MCP230XX directly in the
board/SoC defconfig without explicitly enabling I2C.

Signed-off-by: Arnaud Pouliquen <[email protected]>
Suggested-by Fin Maaß <[email protected]>
Enable dynamic configuration of region mapping with a 1:1
virtual-to-physical address mapping.
This configuration is aligned with the static declaration of the
MMU table using MMU_REGION_FLAT_ENTRY macro.

Signed-off-by: Arnaud Pouliquen <[email protected]>
Add the Ethernet 0 MAC and MDIO nodes in the device tree.

Signed-off-by: Arnaud Pouliquen <[email protected]>
Signed-off-by: Arif Balik <[email protected]>
The typedef ETH_TxPacketConfigTypeDef is used consistently in the driver.
However, some instances of ETH_TxPacketConfig have not yet been replaced.
On the STM32MP13 series, the ETH_TxPacketConfig typedef is no longer
defined. This cleanup ensures compatibility and consistency.

Signed-off-by: Arnaud Pouliquen <[email protected]>
arnopo added 2 commits October 6, 2025 11:14
Add the support of the stm32mp13 ethernet:
- Adapt to HAL API
- Add support of a memory region in DT for descriptor and buffers
- Add support of  PHY with/without crystal 50MHz

Signed-off-by: Arnaud Pouliquen <[email protected]>
Signed-off-by: Arif Balik <[email protected]>
The STM32MP135F-DK board embeds 2 ethernets. Enable the ethernet1
in RMII mode with associated PHY.

Signed-off-by: Arnaud Pouliquen <[email protected]>
Signed-off-by: Arif Balik <[email protected]>
Copy link

sonarqubecloud bot commented Oct 6, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Binary Blobs Modified DNM (manifest) This PR should not be merged (controlled by action-manifest) manifest manifest-hal_stm32
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants