cancel
Showing results for 
Search instead for 
Did you mean: 

Ethernet Initialization on Nucleo-H723ZG (HAL_ETH_Init returns HAL_ERROR)

cbsim
Associate

I am currently working on initializing the Ethernet peripheral on the Nucleo-H723ZG using the following environment:

  • CubeIDE Version: 1.17.0 (MacOS)
  • STM32Cube Firmware Version: H7 V1.12.1

While calling the MX_ETH_Init() function, I encountered an issue where HAL_ETH_Init(&heth) returns HAL_ERROR. Upon debugging, I found that the problem is related to the software reset step in the initialization process.

Here is the relevant portion of the code from stm32h7xx_hal_eth.c:

 

 

/* Ethernet Software reset */
  /* Set the SWR bit: resets all MAC subsystem internal registers and logic */
  /* After reset all the registers holds their respective reset values */
  SET_BIT(heth->Instance->DMAMR, ETH_DMAMR_SWR);

  /* Get tick */
  tickstart = HAL_GetTick();

  /* Wait for software reset */
  while (READ_BIT(heth->Instance->DMAMR, ETH_DMAMR_SWR) > 0U)
  {
    if (((HAL_GetTick() - tickstart) > ETH_SWRESET_TIMEOUT))
    {
      /* Set Error Code */
      heth->ErrorCode = HAL_ETH_ERROR_TIMEOUT;
      /* Set State as Error */
      heth->gState = HAL_ETH_STATE_ERROR;
      /* Return Error */
      return HAL_ERROR;
    }
  }

 

Issue:
The software reset (SWR bit in ETH_DMAMR) is not being cleared, causing the function to timeout and return HAL_ERROR.

3 REPLIES 3
Pavel A.
Evangelist III

Timeout in this place usually means a problem with initialization of the PHY.

Please start with one of available ETH sample projects in the H7 Cube package or here. Do not change anything until the project "works" (at least the board responds to ping). Use isolated network segment for testing.

 

 

@Pavel A. 

Thank you for your response.

I conducted tests using the source code available at the following path:
https://github.com/stm32-hotspot/STM32H7-LwIP-Examples/tree/main/STM32H723_Nucleo_ETH
However, I was unable to verify proper operation.

In the source file
https://github.com/stm32-hotspot/STM32H7-LwIP-Examples/blob/main/STM32H723_Nucleo_ETH/LWIP/Target/ethernetif.c,
the `low_level_init` function leads to Error_Handler.

The issue seems to be with the following statement:

hal_eth_init_status = HAL_ETH_Init(&heth);


The `hal_eth_init_status` is returned as 1.

The testing environment is as follows:

  • Nucleo-H723ZG
  • CubeIDE Version: 1.17.0 (MacOS)
  • STM32Cube Firmware Version: H7 V1.12.1

Hello @cbsim ,

the example that you are trying to implement was developed for an older version of tools and an old version of Cube Firmware and migrating it may make you encounter some issues.

my recommendation is to try, and examples installed with Cube Firmware version 1.17.2, and which will insure us that no hardware related issues are found. 
try this example and let me know if you face any issues STM32CubeH7/Projects/NUCLEO-H723ZG/Applications/LwIP/LwIP_UDP_Echo_Server at master · STMicroelectronics/STM32CubeH7 · GitHub

Regards

 

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.