I’m trying to integrate FreeRTOS with port GCC/ARM_CM4_MPU
in my project that was based on GCC/ARM_CM4F.
I use functions xTaskGetHandle and vTaskGetInfo to go get ulRunTimeCounter and calculate CPU usage.
I noticed 2 problems that are not present with the non MPU port.
Function xTaskGetHandle always return NULL when searching for idle task "IDLE" and timer task "Tmr Svc"
Function vTaskGetInfo do not return correct data for idle and timer tasks. For example the field xHandle of the returned task status is different from the given handle
xTaskGetHandle is no longer available to unprivileged tasks when using the MPU port which may be causing the problem you’re seeing.
Well the fields of taskStatus certainly look incorrect. Would you mind upgrading the task which is calling xTaskGetIdleTaskHandle and vTaskGetInfo to privileged and trying again. I would like to rule out the task access permissions/MPU settings being the source of the problem.
The above test has already been performed in a privileged task. Problem is present only for Idle and Timer tasks, for all other task vTaskGetInfo runs fine.
I think this check is failing because Idle and Timer tasks are created internally and therefore, do not have a corresponding external handle. Is it possible for you to step through the code and confirm that?
If stepping through the code is not possible, please try the following code snippet from a privileged task:
Yes i confirm that the check if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) will not pass in function MPU_vTaskGetInfoImpl.
But how to get the correct handle in “external index form” for Timer and Idle tasks? functions xTaskGetIdleTaskHandle and xTimerGetTimerDaemonTaskHandlewill not return a handle with value 1,2,3, .. like for other tasks.
There is no external handle associated with these 2 tasks currently and therefore, you cannot use get one. Can you try the code snippet I shared above?