|
|||||||||||
Technical Support Support Resources
Product Information |
ARM: Example Ported from Keil RTX5 to FreeRTOS Does Not RunInformation in this knowledgebase article applies to:
SYMPTOMTo test, if we can use the CMSIS RTOS2 FreeRTOS implementation, I used an existing middleware example and switched in the RTE Run-Time manager the CMSIS RTOS2 implementation from Keil RTX5 to FreeRTOS. After that, the project builds without error, but it does not run. We thought, the actual RTOS2 implementation does not matter. So, what is the problem here? CAUSEThe FreeRTOS CMSIS RTOS2 implementation has unfortunately some limitations. One is, that threads can't be created, if the Attributes parameter of the osThreadNew() function only specifies custom stack memory. So, if the example starts e. g. the app_main thread like this: #define APP_MAIN_STK_SZ (1024U) uint64_t app_main_stk[APP_MAIN_STK_SZ / 8]; const osThreadAttr_t app_main_attr = { .stack_mem = &app_main_stk[0], .stack_size = sizeof(app_main_stk) }; int main( void ) { ... osThreadNew(app_main, NULL, &app_main_attr); ... }
the thread creation will fail with CMSIS-FreeRTOS. And so, the
application will not run. RESOLUTIONTo get the thread created, either remove the custom stack specification (default stack size needs to be sufficient) or add suitable values also for the control block structure as shown in the example: #include "FreeRTOS.h" #define APP_MAIN_STK_SZ (1024U) uint64_t app_main_stk[APP_MAIN_STK_SZ / 8]; StaticTask_t app_main_cb; const osThreadAttr_t app_main_attr = { .stack_mem = &app_main_stk[0], .stack_size = sizeof(app_main_stk), .cb_mem = &app_main_cb, .cb_size = sizeof(app_main_cb) }; With that the thread creation will work and also the example project should run. MORE INFORMATION
Last Reviewed: Friday, November 13, 2020 | ||||||||||
|
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.