I’d like to report an issue I’ve found in the recent weeks.
Kinetis K64F (Cortex M4F), FreeRTOS-8.2.0, TCP-160112.
The K64F is the server. There’s a persistent connection between the K64F and PC. The PC regularly sends 100-200 bytes long requests, and the K64F replies with packets smaller than 1500 bytes.
An HTTP server is also running and can serve 3 parallel requests. The PC is executing many parallel wgets to get the homepage on K64F at the highest pace possible.
When everything is up and running (1 persistent TCP connection + 3 continuously connecting, downloading and disconnecting HTTP clients) the machine gets rebooted by the HW watchdog after a while (usually within 1-5 minutes). The watchdog has a dedicated reset task, with a priority lower than the IP task’s priority.
I’ve figured out that prvCalculateSleepTime(…) function sometimes calculates a 0 tick of sleep time, thus it doesn’t let lower priority tasks getting CPU time. Even worse, it appears that if prvCalculateSleepTime(…) once calculates a zero ms of sleep time, it will never recover and will calculate this bad value until eternity (or until the watchdog resets ;)).
I’ve applied a simple fix to the end of the function:
if (xMaximumSleepTime == 0) xMaximumSleepTime = pdMS_TO_TICKS(10);
And in my case this makes the trick, the system no longer gets starved.
I didn’t have time to dig into the code to find the real reasons of this; the fix above has been running for more than 10 days without a stop, so I hope it can’t be that bad…