2015-05-06 09:48 AM
Hi,
I would like to known if I don't understand something or if there is a bug in cmsis_os.c (STMCube for STM32F429) 1) In osThreadCreate() stacksize in bytes is directly passed to xTaskCreate() but the definition for the usStackDepth argument isusStackDepth
The size of the task stack specified as the number of variables the stack can hold - not the number of bytes.
typedef struct os_thread_def { char *name; ///< Thread name os_pthread pthread; ///< start address of thread function osPriority tpriority; ///< initial thread priority uint32_t instances; ///< maximum number of instances of that thread function uint32_t stacksize; ///< stack size requirements in bytes; 0 is default stack size } osThreadDef_t; osThreadId osThreadCreate (const osThreadDef_t *thread_def, void *argument) { TaskHandle_t handle; if (xTaskCreate((TaskFunction_t)thread_def->pthread,(const portCHAR *)thread_def->name, thread_def->stacksize, argument, makeFreeRtosPriority(thread_def->tpriority), &handle) != pdPASS) { return NULL; } return handle; } I think the definition of stacksize in os_thread_def must be changed or the code of osThreadCreate() must be corrected.2015-06-02 09:03 AM
Looks like a bug in either the comments or the code to me. It appears that thread_def->stacksize is only used in this one place. IF that's really the case, then the fix could be as simple as fixing the comments associated with osThreadCreate() stacksize. In the mean time, it appears the impact is just that you are allocating a size four times larger than intended. (now if I could only figure out why my code quits starting the task when the stack size is set as big as I need...)
2017-05-26 12:15 PM
Another inconsistency: stackSize = 0 should mean DEFAULT stack size; instead it allocates zero stack.