cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H573: Ethernet - HAL_ETH_Init returns error.

jowakar122
Senior

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.

jowakar122_0-1747656677963.png

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?

24 REPLIES 24

@mbarg.1 here are the lwip source file

I do not see function lwip_init() in attached code (file lwip.c) !

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, &ethernetif_init, &ethernet_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
}
LCE
Principal II

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;
		}
	}

 


@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?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.