cancel
Showing results for 
Search instead for 
Did you mean: 

STM32MP135 - ETH SWRESET fails, ETH_DMAMR_SWR stays set and then timeout

SteMMo
Senior

Hello everyone,

i'm working on a custom SOC based on ST32MP135 and LAN8710 ethernet phy chip.

When the HAL_ETH_Init() code runs and sends the module reset by setting the ETH_DMAMR_SWR bit, the loop exits with the HAL_ETH_ERROR_TIMEOUT.

The current interface is set to SYSCFG_ETH1_RMII value and the clock source is set by the following code:

HAL_RCCEx_PeriphCLKConfig(&(RCC_PeriphCLKInitTypeDef){
	.PeriphClockSelection = RCC_PERIPHCLK_ETH1,
	.Eth1ClockSelection = RCC_ETH1CLKSOURCE_PLL4
});

  The HAL_ETH_MspInit() function sets the GPIOs and enables the clocks:

		/* Enable GPIOs clocks */
		__HAL_RCC_GPIOA_CLK_ENABLE();
		__HAL_RCC_GPIOB_CLK_ENABLE();
		__HAL_RCC_GPIOC_CLK_ENABLE();
		__HAL_RCC_GPIOG_CLK_ENABLE();

		/* Ethernet MSP init:
		REF_CLK  -------------> PA11
		TXD0    --------------> PG13
		TXD1    --------------> PG14
		RXD0    --------------> PC4
		RXD1    --------------> PC5
		TX_EN   --------------> PB11
		CRS_DV  --------------> PC1
		MDC     --------------> PG2
		MDIO    --------------> PA2
		*/

		/* Configure PA11 = ETH1_CLK */
		GPIO_InitStructure.Pin =  GPIO_PIN_11;
		GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_MEDIUM;
		GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
		GPIO_InitStructure.Pull = GPIO_NOPULL;
		GPIO_InitStructure.Alternate = GPIO_AF11_ETH;
		HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);

		/* Configure PA2 = ETH1_MDIO */
		GPIO_InitStructure.Pin =  GPIO_PIN_2;
		GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW;
		GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
		GPIO_InitStructure.Pull = GPIO_NOPULL;
		GPIO_InitStructure.Alternate = GPIO_AF11_ETH;
		HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);

		/* Configure PB11 = ETH1_TX_EN */
		GPIO_InitStructure.Pin = GPIO_PIN_11;
		GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_MEDIUM;
		HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);

		/* Configure PC1 = ETH1_CRS_DV */
		GPIO_InitStructure.Pin = GPIO_PIN_1;
		GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
		GPIO_InitStructure.Pull = GPIO_NOPULL;
		GPIO_InitStructure.Alternate = GPIO_AF10_ETH;
		HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);

		/* Configure PC4 = ETH1_RXD0 and PC5 = ETH1_RXD1 */
		GPIO_InitStructure.Pin = GPIO_PIN_4 | GPIO_PIN_5;
		GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
		GPIO_InitStructure.Pull = GPIO_NOPULL;
		GPIO_InitStructure.Alternate = GPIO_AF11_ETH;
		HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);

		/* Configure PG2 = ETH1_MDC, PG13 = ETH1_TXD0 and PG14 = ETH1_TXD1 */
		GPIO_InitStructure.Pin = GPIO_PIN_2 | GPIO_PIN_13 | GPIO_PIN_14;
		GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
		GPIO_InitStructure.Pull = GPIO_NOPULL;
		GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_MEDIUM;
		GPIO_InitStructure.Alternate = GPIO_AF11_ETH;
		HAL_GPIO_Init(GPIOG, &GPIO_InitStructure);

		/* Enable Ethernet clocks */
		__HAL_RCC_ETH1CK_CLK_ENABLE();
		__HAL_RCC_ETH1MAC_CLK_ENABLE();
		__HAL_RCC_ETH1TX_CLK_ENABLE();
		__HAL_RCC_ETH1RX_CLK_ENABLE();

		/* Configure IRQ */
		IRQ_SetPriority(ETH1_IRQn, 7);
		IRQ_Enable(ETH1_IRQn);

 Touching the pin 5 (CLKIN) of the PHY I see a 50MHz clock.

Any idea about the timeout?

Regards

2 REPLIES 2

Hi @SteMMo 

this kind of error usually come from lack of clock going to ETH IP (eth_mii_tx_clk and eth_mii_rx_clk).
Apart settings in RCC, please have a look to this figure from RM0475 and set SYSCFG according to your HW board setup to ensure correct clock paths are selected.
AN5474 could also help.

PatrickF_0-1758900917008.png

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.
Tip of the day: Try Sidekick STM32 AI agent, see here