I am working on the IAR workbench, with AT91sam7s256 processor.
I have ported the freertos to this processor based on the relevant docs.
I have a problem with the freertos IDLE task.
When the IDLE task is created by the freertos vTaskStartSchedulervTaskStartScheduler function, its stack and TCB is being allocated, the problem is that it’s run over other tasks that created before by the user.
Then I get "stack overflow" (using freertos hook) on tasks that really not doing anything.
I saw that when the the IDLE stack is created its overrun others tasks.
I get overflow because the TCB of other tasks is overrun (by the IDLE task) and therefore the overflow-check function of freertos recognize it as stack overflow.
i don’t think that the problem is because of small stack of other tasks.
Idle task is created the same way as the other tasks are. First the memory for TCB and task stack is allocated on heap. Maybe there is a problem if allocate function returns wrong pointer. Please have a check if prvAllocateTCBAndStack function call in xTaskCreate works fine.
xTaskCreate calls prvAllocateTCBAndStack function and this returns the pointer to allocated memory. Suggest set the breakpoint there and check if pointers returned during TCB/stack allocation have values as expected.
P.S. A basic point. Almost all FreeRTOS features (queue/mutexes/semaphores etc.) use heap to allocate needed memory. I assume that you have commented out all of them and still there is an issue. If you haven’t I suggest to have a look in pvPortMalloc function which will be used for all this allocation - please check if pointer returned doesn’t show any unexpected behaviour.
xTaskCreate calls prvAllocateTCBAndStack function and this returns the pointer to allocated memory. Suggest set the breakpoint there and check if pointers returned during TCB/stack allocation have values as expected.
P.S. A basic point. Almost all FreeRTOS features (queue/mutexes/semaphores etc.) use heap to allocate needed memory. I assume that you have commented out all of them and still there is an issue. If you haven’t I suggest to have a look in pvPortMalloc function which will be used for all this allocation - please check if pointer returned doesn’t show any unexpected behaviour.