2025-05-19 5:13 AM - last edited on 2025-05-20 1:58 AM by Andrew Neil
I am using STM32H573 and trying to enable ethernet. I have used the below article for it:
https://community.st.com/t5/stm32-mcus/how-to-use-the-lwip-ethernet-middleware-on-the-stm32h5-series/ta-p/691100
But ethernet is not being initialized. The HAL_ETH_Init is returning error which is resulting in error handler.
This is the condition being checked in MX_ETH_Init function. As even after using the steps mentioned in the article mentioned above the ethernet is not working.
- Do we have to add RX and TX descriptors specific addresses in the linker file?
Solved! Go to Solution.
2025-05-20 2:02 AM
@jowakar122 wrote:The HAL_ETH_Init is returning error
So what error, exactly, is it returning ?
Have you stepped into HAL_ETH_Init to see where and why it is failing ?
@jowakar122 wrote:I am using my own board design
Then please post schematics:
How to write your question to maximize your chances to find a solution.
Have you tried on an ST board?
2025-05-20 2:24 AM
2025-05-20 2:28 AM
To look at the problem, I need the .ioc file and eventually also the main. c and Middleware directory.
2025-05-20 2:34 AM
@mbarg.1 I have attached the .ioc and main.c file. About Middleware I have taken src and systems from
stm32h5-classic-coremw-apps/Projects/STM32H573I-DK/Applications/LwIP at main · STMicroelectronics/stm32h5-classic-coremw-apps
2025-05-20 2:54 AM
I downloaded example Nx_WebServer for STM32H573IIKX; comparing 2 .ioc, I noted that Ethernet frequency in your project is very different from STM example:
Any reason for this difference?
Also other settings are different, please double check.
Mike
2025-05-20 3:20 AM
2025-05-20 3:39 AM - edited 2025-05-20 3:49 AM
MX_ETH_Init is being called in low_level_init
static void low_level_init(struct netif *netif)
{
MX_ETH_Init();
heth.Instance = ETH;
/* set MAC hardware address length */
netif->hwaddr_len = ETH_HWADDR_LEN;
netif->hwaddr[0] = heth.Init.MACAddr[0];
netif->hwaddr[1] = heth.Init.MACAddr[1];
netif->hwaddr[2] = heth.Init.MACAddr[2];
netif->hwaddr[3] = heth.Init.MACAddr[3];
netif->hwaddr[4] = heth.Init.MACAddr[4];
netif->hwaddr[5] = heth.Init.MACAddr[5];
/* maximum transfer unit */
netif->mtu = ETH_MAX_PAYLOAD;
/* device capabilities */
/* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
/* Initialize the RX POOL */
LWIP_MEMPOOL_INIT(RX_POOL);
/* Set PHY IO functions */
LAN8742_RegisterBusIO(&LAN8742, &LAN8742_IOCtx);
/* Initialize the LAN8742 ETH PHY */
if(LAN8742_Init(&LAN8742) != LAN8742_STATUS_OK)
{
netif_set_link_down(netif);
netif_set_down(netif);
return;
}
ethernet_link_check_state(netif);
}
2025-05-20 3:46 AM
Please see How to insert source code - not as screenshots!
2025-05-20 3:59 AM
@mbarg.1 I tried after changing the Ethernet clock frequency as per the example and also initialized ethernet before calling Network_config. Yet same result
2025-05-20 4:24 AM
First: something MUST be the problem, never forget this; many people run this device without problems.
Next step is to see differences between your code and exampe I did attach to previous post.
Or add code of lwip_init() and let me try to understand what happens.