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?

27 REPLIES 27
Andrew Neil
Super User

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

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.

@Andrew Neil In HAL_ETH_Init: From here HAL_ERROR is returned.

jowakar122_0-1747733023796.png

The ETH_DMAMR_SWR is always set.

To look at the problem, I need the .ioc file and eventually also the main. c and Middleware directory.

@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

jowakar122_0-1747733612088.png

 

I downloaded example Nx_WebServer for STM32H573IIKX; comparing 2 .ioc, I noted that Ethernet frequency in your project is very different from STM example:

mbarg1_0-1747734731239.png

Any reason for this difference?

Also other settings are different, please double check.

Mike

More:

 in main.c i do not see you calling MX_ETH_Init() - it is where you set all Eth params !

 

mbarg1_0-1747736275920.png

Attached my project.

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

 

Please see How to insert source code - not as screenshots!

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.
jowakar122
Senior

@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

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.