2021-07-28 01:39 AM
For version 6.2.0 of cubemx software, select stm32l562vetx chip, use FreeRTOS CMOS V2, and fill in the stack size for the new task. In the generated armmdk code, the unit is not "words", but "bytes". But if I change to f429ze chip, the generated code will see stack_ size “* 4�?。
Solved! Go to Solution.
2021-07-28 04:21 AM
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.
2021-07-28 04:21 AM
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.
2021-07-28 07:01 AM
已�?�?�级到6.3.0,正确了。:ok_hand: