Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years ago.
Change main thread stack size
Hi all,
Running my program causes stack underflow. How can I change stack size of main thread? And, what is the upper limit of stack size? I am using MBED OS 5 with NUCLEO-F767ZI.
Thank you.
1 Answer
7 years ago.
I'm using 5.4.2 offline in System Workbench. All I have to do is throw a #define in main file to increase stack size. I have no idea if this works in the online compiler or not.
#define OS_MAINSTKSIZE 256
It's in this file:
targets\TARGET_STM\mbed_rtx.h
The 256 is the default for your F767ZI board.
I can't answer this question, as it already has an accepted answer. But the prefered way of doing this (which works everywhere, also in online compiler), is to spin up a new thread with the required task size and letting the old thread die. E.g.
In Mbed OS 5.7 and up you can configure the main stack size in mbed_app.json. See https://os.mbed.com/docs/v5.7/reference/configuration.html
posted by Jan Jongboom 12 Mar 2018