2023-12-13 03:59 AM
Hi all
I'm pretty sure this was already a topic, but i haven't found a solution yet. Since i'm a beginner i definitely need some help here.
I'm sending UDP data with LWIP and FreeRTOS. It works, but after some (random) time the code gets stuck at
2023-12-13 05:50 AM - edited 2023-12-13 05:50 AM
A stack overflow might cause this kind of internal data corruption. Did you enable stack checking ? See https://www.freertos.org/Stacks-and-stack-overflow-checking.html
2023-12-13 07:01 AM - edited 2023-12-13 07:34 AM
Thank you for your reply.
Yes, i did. My ioc file has following FreeRTOS settings (maybe this helps)
FREERTOS.FootprintOK=true
FREERTOS.IPParameters=Tasks01,configMINIMAL_STACK_SIZE,configUSE_NEWLIB_REENTRANT,copyHeapFile,FootprintOK,configENABLE_FPU,configCHECK_FOR_STACK_OVERFLOW,configQUEUE_REGISTRY_SIZE
FREERTOS.Tasks01=defaultTask,24,256,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL;
FREERTOS.configCHECK_FOR_STACK_OVERFLOW=1
FREERTOS.configENABLE_FPU=1
FREERTOS.configMINIMAL_STACK_SIZE=256
FREERTOS.configQUEUE_REGISTRY_SIZE=0
FREERTOS.configUSE_NEWLIB_REENTRANT=0
FREERTOS.copyHeapFile=1
Cheers
2023-12-13 07:38 AM
This might be a buffer overrun resulting in the memory at pxQueue being stomped. I'd suggest looking at what's in memory prior to pxQueue for clues.
2023-12-13 12:41 PM
Also try FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 and ensure that you have configASSERT defined. (sorry, I’m not familiar with cube)
BTW what’s the stack size(s) you’re using for your task(s) ?
2023-12-14 12:30 AM
Thank you both for your replies. I try to test both, not sure if I do it correctly ;-).
@David Littell : "I'd suggest looking at what's in memory prior to pxQueue for clues". Does this help somehow:
Stack size for the taks is, if I'm correct 256 (words).
Cheers
2023-12-14 07:27 AM
It does look like the queue structure in memory is being stomped by something. As a quick test you could try 4x all the stacks. You can also convert the uxMessagesWaiting value to hex and see if that's a memory address you can examine.
Issues like this force you to dig around and work to really understand what's being allocated versus statically defined in memory - simple IDE debugger snippets aren't usually enough.