I adopted the network interface which you have provided a year ago. It worked on STM32H7 in normal cases, but when I plugged out the ethernet cable and plugged it in again after ca. 30 seconds, it was not able to receive any data again.
After a lot of debugging, I figured out, that I have to reinitialize the MAC after the PHY link got done (I check the PHY link state in a cycling thread and call there FreeRTOS_NetworkDown() if needed). I changed the code to the one below and now all is working as expected:
BaseType_t xNetworkInterfaceInitialise( void ) {
if (eth_input_task_handle == NULL) {
xTaskCreate(eth_input_task, "eth_input", 1024, NULL, 0, ð_input_task_handle);
}
// restart MAC if it was already started
if(HAL_ETH_GetState(&heth) & HAL_ETH_STATE_BUSY_RX) {
if(HAL_ETH_Stop_IT(&heth) != HAL_OK) {
return pdFAIL;
}
/* Disable global ethernet interrupt */
HAL_NVIC_DisableIRQ(ETH_IRQn);
if(HAL_ETH_DeInit(&heth) != HAL_OK) {
return pdFAIL;
}
}
/* Init MAC */
if(HAL_ETH_Init(&heth) != HAL_OK) {
return pdFAIL;
}
/* Set IRQ priority and enable global ethernet interrupt */
HAL_NVIC_SetPriority(ETH_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(ETH_IRQn);
// Assign memory buffers to DMA Rx descriptor
for(uint32_t idx = 0; idx < ETH_RX_DESC_CNT; idx ++)
{
if(HAL_ETH_DescAssignMemory(&heth, idx, (uint8_t*) ethRxBuffer[idx], NULL) != HAL_OK)
{
return pdFAIL;
}
}
/* Start MAC and DMA */
if (HAL_ETH_Start_IT(&heth) != HAL_OK) {
return pdFAIL;
}
/* check PHY status */
if(phy_isLinkUp()) {
return pdPASS;
}
else {
return pdFAIL;
}
}
Thank you very much for your template, that was a big help for me!