cancel
Showing results for 
Search instead for 
Did you mean: 

Howto create a custom Ethernet PHY driver, that integrates into CubeMX?

taraben
Senior

My board has ethernet PHY Micrel KSZ8721.

I use STM32F407, RMII, LWIP, noRTOS.

CubeMX 6.7, STM32Lib 1.27.1

Although this is no exotic PHY, it is not listed in the supported BSP PHY as LAN8742 and DP83848.

How can I write a mock driver so that custom calls to support the PHY are integrated into the auto-generated LWIP.c functions.

I see some potential problems in the current CubeMX setup:

1) PHY must be setup in Ethernet AND LwIP tab.

As the single responsibility theory says: one should setup only in 1(one) place.

2) If USER_PHY is selected , then USER_PHX calls should be generated, and not omitted as now.

3) USER_PHY creates warning, but it should be an accepted solution ...

Thanks, Adib.

4 REPLIES 4
AndrewFRC135
Associate

I'll second this; I'm running the CubeIDE 1.13.0 & FW_H7_1.11.1 on a custom board. ST only includes a driver for the LAN8742. It is very annoying that the only other option is Undefined and a custom BSP module can't be provided for Cube to be aware of.

AndrewFRC135_0-1692380812497.png

Not only does this produce a warning every time code is generated, but it also then just removes the HAL_ETH_MspInit and MspDeInit function from being generated for no reason. The GPIO configuration should have nothing to do with which PHY driver is selected.

AndrewFRC135_1-1692381191957.png

Obviously the current setup can be worked around (and is still preferred over the legacy version IMO), but it's just clunky. For anyone else, I generated code first with the LAN8742 driver, re-generated with it turned off, and ran a file difference between the two to ensure I filled in all the missing functionality.

 

Muhammed Güler
Senior III

If you create your project for LAN8742 and edit the ethernetif.c file according to the PHY you want to use, you can use the PHY you want. Only LAN8742 can be selected in the STM32H7 series.
Years ago I used DP83848 with STM32H723. I created the project with LAN8742 and rewrote the ethernetif.c file for DP83848. I wish you success in examining the datasheets in depth and making the necessary changes in the code.

priyazcs
Associate II

IDE : STM32CUBEIDE v 1.14.1

Hi, i am also facing a similar issue,when configuring ksz9893 ethernet switch in version 1.8.0 it works fine but in version 1.14.1 i am unable to configure the user phy.How can i make it work in the latest version.

If there are any articles or any useful documents please let me know.

Thank You

 

hello priyazcs,

I would be very grateful if you could share your project that use version 1.8.0!