You are here

FreeRTOS - the stack is in words!!!! | Cypress Semiconductor

FreeRTOS - the stack is in words!!!!

No fibbing here... last night I woke up around 4am thinking "they're words"!!!!! As in 32-bit words, not 8-bit bytes. Yesterday I wrote about increasing the FreeRTOS stack size "for the OS to do anything interesting". It turns out that the 1kB stacks I was using were actually 4kB. And the original 16kB allocation of SRAM to FreeRTOS is actually quite generous. Oops.

Once I got to work, I needed to check. Maybe there would be no falling-on-the-sword admission of stupidity after all. I opened the project in ModusToolbox IDE and, with judicious use of 'F3' and the search dialog, found this code in the xTaskCreate() function of task.c:

    pxStack = ( StackType_t * ) pvPortMalloc( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ) );

I knew things were looking bad by this point, but I looked up StackType_t in portmacro.h to reveal the confirmation.

#define portSTACK_TYPE uint32_t
typedef portSTACK_TYPE StackType_t;

 

Yup, they're words. It turns out I code better in my sleep than when I am awake! There is a moral here. You know when you think you know what you are doing, but there's a nagging doubt that you just ignore... DON'T. And especially don't write about it in public. Yesterday I did not really think about this and blithely assumed that our Apps team had under-resourced the RTOS configuration. I'm going to hear ALL about this from those guys...!

 

 

 

ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.