2019-12-26 05:58 AM
When I use CMSIS RTOS I set a stack size of 128 words. Then the following code is generated:
/* Create the thread(s) */
/* definition and creation of cmdHandlerTask */
const osThreadAttr_t cmdHandlerTask_attributes = {
.name = "cmdHandlerTask",
.priority = (osPriority_t) osPriorityNormal,
.stack_size = 128
};
cmdHandlerTaskHandle = osThreadNew(CmdHandlerTask, NULL, &cmdHandlerTask_attributes);
When I read the documentation, the stack size in osThreadAttr_t is in bytes and the code seems to confirm this. Is this a bug or have I misunderstood it? (Im new to stm32 and this kind of low level programming so Im not too confident that I understood things right.)
Can someone confirm or disprove my suspicion?
Best,
Anders
2019-12-26 06:48 AM
The stack size seems to be in bytes: https://arm-software.github.io/CMSIS_5/RTOS2/html/group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t
Where did you get that it would be in words?
2019-12-26 06:56 AM
It is explicitly stated so in the CubeMX IDE that the stack size is in words. And the heap usage calculator seems to use that info.
2019-12-27 12:30 AM
Which one are you using? FreeRTOS (built on CMSIS-RTOS) or CMSIS-RTOS (alone)? FreeRTOS uses words for stack sizes.
There is also CMSIS-API for FreeRTOS. Don't get fooled.
2019-12-27 09:09 AM
Im using CMSIS API v2 which is using FreeRTOS as backend. But what seem to be the issue is the Cube code autogenerator.
2019-12-30 12:51 PM
I agree with topic starter. When selected CMSISv2 - then Cube "say Words", but code generated in bytes. As result stack overflow for default task mostly guaranteed.