Endless loop in port.c "Sleep until something happens" Cortex M4F prtable

Hello community,

at the moment we have a port for the Cortex M4F wich stuck / endless loop in the port.c.
Exactly at line 587 in the if( xModifiableIdleTime > 0 ), sometimes its going in there and never goes out:

(we running a program that sometimes is running 2min and sometimes 6hrs before its stick in there)

/* Sleep until something happens. configPRE_SLEEP_PROCESSING() can
set its parameter to 0 to indicate that its implementation contains
its own wait for interrupt or wait for event instruction, and so wfi
should not be executed again. However, the original expected idle
time variable must remain unmodified, so a copy is taken. */
xModifiableIdleTime = xExpectedIdleTime;
configPRE_SLEEP_PROCESSING( xModifiableIdleTime );
if( xModifiableIdleTime > 0 )
{
__dsb( portSY_FULL_READ_WRITE );
__wfi();
__isb( portSY_FULL_READ_WRITE );
}

Can someone give us some hints what we can do?

Some ideas -

  • Make sure you’re using a recent version of FreeRTOS (10.x) and be sure configASSERT() is defined, stack overflow detection is enabled, and a malloc-failed hook is installed.
  • When it’s stuck, use the debugger to determine if it’s actually looping or if it’s sleeping in WFI. If FreeRTOS is working correctly, it will be looping, typically once per second(s). The period is set by the CPU clock rate and the limit of the 24-bit SysTick timer. If it’s not looping, check the value of BASEPRI.
  • Try disabling tickless idle temporarily. Make sure the application works as expected for many hours.
1 Like