Bug in FreeRTOS??

Hi!!    I noticed a strange thing! When 3 tasks have been started without enough free stack system crashed! I didn’t return from last xTaskCreate! System crashed in prvAllocateTCBAndStack function – it didn’t come out from:     memset( pxNewTCB->pxStack, tskSTACK_FILL_BYTE, usStackDepth * sizeof( portSTACK_TYPE ) ); When I simply comment this line (it is useful only when debuging) system start working correctly! It means it returned an error code from xTaskCreate function insted of hang up in this function!! Is it a kind of bug?? Or maybe I made something wrong?? I use FreeRTOS on LPC2364 ARM7 microcontroller. Regards Konoppo

Bug in FreeRTOS??

Most likely your linker script is wrong, or the startup code is not correctly initializing variables.

Bug in FreeRTOS??

For what should I pay attention in linker script or in startup code?? In my opinion both are correct but maybe I missed something ;)…

Bug in FreeRTOS??

If there is not enough heap space to create a task then pvPortMalloc() will return NULL and xTaskCreate() will never call memset().  Do you mean without enough stack, or do you mean without enough heap?  (you say stack). Which heap implementation are you using, heap_1, heap_2 or heap_3? Which compiler are you using? Regards.

Bug in FreeRTOS??

OK, thanks for suggestion!! The USER_MODE stack size was only 2kB, when the total cheap size for freeRTOS was 4kB ;)… When I changed it everything is OK now :)…

Bug in FreeRTOS??

I use heap_2, and I should say "heap" instead of stack ;)… But problem Was in stack size, I think… When I increased it – everything is OK now. But I think it’s not good idea, that xTaskCreate() call memset in this situation and crash system (my uC went to address like 0xa5000000 and NOPs instruction)… Regards Konoppo

Bug in FreeRTOS??

Are you suggesting each line if FreeRTOS should check the user has not overflowed the stack before executing – even before the scheduler has been started? Regards.

Bug in FreeRTOS??

OK, you are right, my suggestion was a bit stupid ;)… For me it wasn’t obvious that freeRTOS uses a Supervisor Stack Size…

Bug in FreeRTOS??

OK, please, tell me – which memory is used by freeRTOS for "heap"?? It’s a free RAM (bss_section) or it’s stored in the stac region?? I thought that heap uses the stack region but now I think that it’s stored in BSS section (like any other variable)… I use GCC…