Hello @MShao.1 ,
Thanks for your feedback.
Actually you're right, I was able to reproduce the issue with the previous STM32CubeMX version 6.2.0 and STM32L562 MCU:
In CMSIS-RTOS v2 implementation (cmsis_os2.c file > osThreadNew function), the argument from CubeMX is divided by sizeof(StackType_t) (== 4):
if (attr->stack_size > 0U) {
/* In FreeRTOS stack is not in bytes, but in sizeof(StackType_t) which is 4 on ARM ports. */
/* Stack size should be therefore 4 byte aligned in order to avoid division caused side effects */
stack = attr->stack_size / sizeof(StackType_t);
}
Thus, the issue would be fixed by generating:
osThreadId_t defaultTaskHandle;
const osThreadAttr_t defaultTask_attributes = {
.name = "defaultTask",
.priority = (osPriority_t) osPriorityNormal,
.stack_size = 128 * 4
};
The issue is no longer reproduced with the latest STM32CubeMX version 6.3.0 and the stack size used for CMSIS-RTOS v2 tasks dynamically allocated will be correctly generated.
Could you please confirm from your side ?
Khouloud.