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?
2025-05-20 4:31 AM
@mbarg.1 here are the lwip source file
2025-05-20 4:37 AM
I do not see function lwip_init() in attached code (file lwip.c) !
2025-05-20 4:46 AM
My apologies, I have that part of the code named as Network_config in main.c. Something like this:
static void Netif_Config(void) {
ip_addr_t ipaddr;
ip_addr_t netmask;
ip_addr_t gw;
#if LWIP_DHCP
ip_addr_set_zero_ip4(&ipaddr);
ip_addr_set_zero_ip4(&netmask);
ip_addr_set_zero_ip4(&gw);
#else
/* IP address default setting */
IP4_ADDR(&ipaddr, IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3);
IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1 , NETMASK_ADDR2, NETMASK_ADDR3);
IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
#endif
/* add the network interface */
netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, ðernetif_init, ðernet_input);
/* Registers the default network interface */
netif_set_default(&gnetif);
ethernet_link_status_updated(&gnetif);
#if LWIP_NETIF_LINK_CALLBACK
netif_set_link_callback(&gnetif, ethernet_link_status_updated);
#endif
}
2025-05-20 7:07 AM
Are you using "pure HAL ETH", or did you modify it?
As you are using your own hardware, have you checked that all external clocks are available?
See NOTE in code:
/* SoftWare Reset */
/* set SWR bit: resets all MAC subsystem internal registers and logic
* NOTE: the SWR is not performed if the ETH_RX_CLK or the ETH_TX_CLK are
* not available -> check external PHY or IO configuration
*/
ETH->DMAMR |= ETH_DMAMR_SWR;
/* wait for software reset to reset... */
u32TickStart = HAL_GetTick();
while( ETH->DMAMR & ETH_DMAMR_SWR )
{
/* timeout ? */
if( (HAL_GetTick() - u32TickStart ) > ETH_TIMEOUT_SWRESET_MS )
{
#if DEBUG_ETHNETIF
uart_printf(SZC_TEXT_ERR "ETH_DMAMR_SWR software reset TO\n\r");
#endif /* DEBUG_ETHNETIF */
return HAL_TIMEOUT;
}
}
2025-05-20 7:24 AM
@LCE wrote:As you are using your own hardware, have you checked that all external clocks are available?
Indeed.
@jowakar122 and, in fact, have you verified all your external hardware?
Again, please post your schematics.
Have you got this working on an ST board (known-good hardware) before moving on to unknown hardware?