2026-01-26 6:49 AM
Hello fellow readers,
##Disclaimer##
I am using a Nucleo Board, the Nucleo H7S3L8, and HAL_ERROR ist laughing me since 2 days in my face#
I think you, dear reader, have heard about the SWR-Bit, which vanishes out as soon the software has restarted succesfully, everything seems perfect and you have finally the feeling you found the solution to world piece.
But I am currently at the brink of insanity, because this little ******* ***** ** **** wont clear itself after I forced the reset.
What do I mean specifically?
HAL_StatusTypeDef HAL_ETH_Init(ETH_HandleTypeDef *heth)
{
uint32_t tickstart;
if (heth == NULL)
{
return HAL_ERROR;
}
if (heth->gState == HAL_ETH_STATE_RESET)
{
heth->gState = HAL_ETH_STATE_BUSY;
#if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
ETH_InitCallbacksToDefault(heth);
if (heth->MspInitCallback == NULL)
{
heth->MspInitCallback = HAL_ETH_MspInit;
}
/* Init the low level hardware */
heth->MspInitCallback(heth);
#else
/* Init the low level hardware : GPIO, CLOCK, NVIC. */
HAL_ETH_MspInit(heth);
#endif /* (USE_HAL_ETH_REGISTER_CALLBACKS) */
}
__HAL_RCC_SBS_CLK_ENABLE();
if (heth->Init.MediaInterface == HAL_ETH_MII_MODE)
{
HAL_SBS_ConfigEthernetPHY(SBS_ETHERNET_PHY_GMII_OR_MII);
}
else
{
HAL_SBS_ConfigEthernetPHY(SBS_ETHERNET_PHY_RMII);
}
/* Dummy read to sync with ETH */
(void)SBS->PMCR;
/* 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;
}
}This section of code breaks me, and I know there have been a few posts before about it, but frankly they are either too old or my issue couldnt be solved by them.
But What have I checked so far? Many things. RCCs, the Ethernet control register and so on, but somehow i dont have a decent indicator why the SWR bit wont reset.
I also have modified my ethernetif.c and lwip.c according to the manual which is spooking around here, which is by the way behind a full driver update. As i am running my project not like a peasent only with Ethernet, instead like a meadiocre copy-pasta-champion with multible peripherals, the pin assignments arent the same as in the example or on Github.
So please, maybe one of you gods of embedded programming can help me free from my endless pain and torture to see HAL_ERROR every time again and wonder around in some driver files. I will append my ioc and my lwip folder, and hopefully you can point out simple and painfull easy error.
Thanks in advance!
I cant anymore