cancel
Showing results for 
Search instead for 
Did you mean: 

board restarts after one hour using FreeRtos and LWIP

Serge.ohmi
Associate II

I'm testing an UDP client/server using a NUCLEO-F429ZI (Ethernet).

Code is generated thanks to STM32CubeMx.

I'm using FreeRTOS and LWIP.

DHCP, ICMP and UDP are enabled. TCP is disabled.

IP stuff is done using socket API, one thread for receiving, one thread for sending.

The sender thread sends a message to a dedicated PC every second and write the same message to the uart.

Both threads are started by the default thread after MX_LWIP_Init();

All works fine except that after one hour the MCU restarts : DHCP is renewed and message count restarts at 1.

I did same kind of test (other LWIP API) whitout FreeRtos, same result

Any idea where this can come from ?

Any idea what I could try to understand the issue ?

code and MCU config are attached

8 REPLIES 8
Ozone
Lead

If your faulthandlers do not trigger a restart, I suspect a watchdog.

Didn't Cube enable a watchdog behind the user's back ?

Serge.ohmi
Associate II

I just found some fault handlers in stm32f4xx_it.c

So I launched the program with with the debugger after having set break points on each of these handlers.

I'll keep you posted.

Serge.ohmi
Associate II

But unsure this could be the cause as the default behaviour is a while(1) that should not result in a restart.

except if there is some kind of watchdog.

How can I check this ?

There is a "restart reason" flag somewhere in the system registers, check the reference manuals. Forgot the details, long time ago when I dealt with it ...

And I would check the Cube-generated code, if any watchdog gets enabled somewhere.

Can't give you more detailed pointers here, I don't use Cube. For good reasons...

> But unsure this could be the cause as the default behaviour is a while(1) that should not result in a restart.

Definitely true. Just trying to restart is not the method of choice I use to deal with.

Serge.ohmi
Associate II

this a code I found on the net (stackoverflow)

const char *reset_cause[]=
{
		"TBD",
		"LOW_POWER_RESET",
        "WINDOW_WATCHDOG_RESET",
        "INDEPENDENT_WATCHDOG_RESET",
        "SOFTWARE_RESET", // This reset is induced by calling the ARM CMSIS `NVIC_SystemReset()` function!
        "POWER-ON_RESET (POR) / POWER-DOWN_RESET (PDR)",
        "EXTERNAL_RESET_PIN_RESET",
        "BROWNOUT_RESET (BOR)",
        "UNKNOWN",
};
 
int cause=0;
 
int get_system_reset_cause()
{
	int cause;
 
    if (__HAL_RCC_GET_FLAG(RCC_FLAG_LPWRRST))
    {
        cause=1;
    }
    else if (__HAL_RCC_GET_FLAG(RCC_FLAG_WWDGRST))
    {
        cause=2;
    }
    else if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST))
    {
        cause=3;
    }
    else if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST))
    {
        cause=4;
    }
    else if (__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST))
    {
        cause=5;
    }
    else if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST))
    {
        cause=6;
    }
    // Needs to come *after* checking the `RCC_FLAG_PORRST` flag in order to ensure first that the reset cause is
    // NOT a POR/PDR reset. See note below.
    else if (__HAL_RCC_GET_FLAG(RCC_FLAG_BORRST))
    {
        cause=7;
    }
    else
    {
        cause=8;
    }
 
    // Clear all the reset flags or else they will remain set during future resets until system power is fully removed.
    __HAL_RCC_CLEAR_RESET_FLAGS();
 
    return cause;
}

I'll let you know the result, but previous tries gave External Reset Pin,which I'm sure I've not pressed!

I was searching the code for iwdg & wwdg, did not find anything suspect (to me) .

Any Idea if I could search for something else ?

Many thanks for the help.

> I'll let you know the result, but previous tries gave External Reset Pin,which I'm sure I've not pressed!

I can only guess (as I did ...).

But surely, very few devices have a hardware reset button at all.

What else I can imagine:

A power dropout (brownout/blackout). Not very plausible, but pssible.

A restart from within FreeRTOS. I'm don't have detailled knowledge about this OS. Perhaps it tries a restart on certain errors, like memory corruption / stack overflow. Calling th CMSIS function NVIC_SystemReset() ?

Serge.ohmi
Associate II

I always suspect my code or lake of knowledge of underneath system first.

Given this, As the code is quite simple, without dyn alloc, I've changed the delay time between 2 write (/4) so that if the restart is due to a memory error, it should happen 4 times faster.

Right ?

result last a bit more than 30 mins before restarting => software issue ?