Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

Bug in FreeRTOS??

Posted by Konoppo on March 23, 2009
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

RE: Bug in FreeRTOS??

Posted by Dave on March 23, 2009
Most likely your linker script is wrong, or the startup code is not correctly initializing variables.

RE: Bug in FreeRTOS??

Posted by Konoppo on March 23, 2009
For what should I pay attention in linker script or in startup code?? In my opinion both are correct but maybe I missed something ;)...

RE: Bug in FreeRTOS??

Posted by Richard on March 23, 2009
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.

RE: Bug in FreeRTOS??

Posted by Konoppo on March 23, 2009
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 :)...

RE: Bug in FreeRTOS??

Posted by Konoppo on March 23, 2009
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

RE: Bug in FreeRTOS??

Posted by Richard on March 23, 2009
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.

RE: Bug in FreeRTOS??

Posted by Konoppo on March 23, 2009
OK, you are right, my suggestion was a bit stupid ;)... For me it wasn't obvious that freeRTOS uses a Supervisor Stack Size...

RE: Bug in FreeRTOS??

Posted by Konoppo on March 23, 2009
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...


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS