cancel
Showing results for 
Search instead for 
Did you mean: 

Stack overflow in freeartos and ethernet

dorong
Associate II

Hi
I am using the evaluation board stm32743
And testing the firmware that include freeartos and ethernet
If enabled the "check_for_stack_overflow" in cubeMx freeartos this will result
in vApplicationStackOverflowhook to inhabit.

checking sp register when the firmware start(at main) shows that sp = 0x2407ffe8.
Once the start and reaches to the first task and the only one the stack pointer sp reigster = 0x24005af0
and on the next step vApplicationStackOverflowhook inhabit.
for some reason the stack uses a lot of memory right from the start of the first task

 

6 REPLIES 6
Bob S
Principal

Each task has its own stack - separate from the stack that is used for main().  If FreeRTOS is calling the stack overflow hook, then you need to increase the size of your stack for that task.  The CubeMX default task size is WAY too small for anything running Ethernet stacks.

dorong
Associate II

HI BOb thank you for your replay
I found the problem when I found that the semaphore handle, which is a part of freeartos
was erased by the stack overflow, so it is not a problem of defining the stack size of each task
it is a problem of freeartos

 

Doron

> so it is not a problem of defining the stack size of each task it is a problem of freeartos

No - it is absolutely a problem of defining stack sizes for each task.  It is not FreeRTOS's fault that the stack overflowed and corrupted data.  It is your fault for not giving tasks a big enough stack space, or not verifying that the CubeMX provided stack size was big enough.

Hi
what can cause stack pointer in firmware that include only freeartos
when just starting the StartDefaultTask the stack pointer goes from 0x2407ff98 to 0x240010a0
the default stack size for the StartDefaultTask is just 128 words

what can cause stack pointer in firmware that include only freeartos

Every task switch causes jumps of task stack pointer (PSP). LwIP creates its own tasks so you always have several of them. The default task stack size is too small, you need to increase it or specify larger sizes per task.

Thank for your replay
I have tested this on a new firmware which does not include any other task
Other then the freeartos ONLY