Errors when configuring run time counter on xilinx microblaze port

Hello,

I have an application using freeRTOS xilinx microblaze port. I just tried to enable run time stats but I am getting errors about defining portGET_RUN_TIME_COUNTER_VALUE & portCONFIGURE_TIMER_FOR_RUN_TIME_STATS even though I DO have them defined in my main file as shown below

extern XTmrCtr xTickTimerInstance;
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() dummy()
#define portGET_RUN_TIME_COUNTER_VALUE() XTmrCtr_GetValue(&xTickTimerInstance, 1UL)

I have had this feature working on other ports and I am doing the same exact thing. I am not sure why I am getting these errors. Any thoughts?

BTW I have a dumy function for portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() because the run timer counter in this port is setup in vApplicationSetupTimerInterrupt when the tick counter is initialized so I believe no additional setup is needed.

So I was able to get rid off these specific errors by including the definition section mentioned above in FreeRTOSConfig.h config file instead of main.

However, now I get an error saying undefined reference to `vTaskGetRunTimeStats’. I thought once I make those definitions as well as defining configUSE_STATS_FORMATTING_FUNCTIONS to 1, then I will be able to use this function. Not sure what I am missing. Please keep in mind that function vTaskList() works fine.

I also noticed that the #if ( configGENERATE_RUN_TIME_STATS == 1 ) conditional section defined within vTaskSwitchContext( void ) in task.h is still highlighted grey even though I have configGENERATE_RUN_TIME_STATS defined as 1. Not sure why.

Do you also have configSUPPORT_DYNAMIC_ALLOCATION set to 1? See https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/master/tasks.c#L4478

Hi. I’m trying to do the same thing, trying to access the functionality provided by defining configGENERATE_RUN_TIME_STATS. Trying to follow the info here: https://www.freertos.org/rtos-run-time-stats.html. Found your question and it looks like your solution is exactly what I was looking for. However, How did you get FreeRTOSConfig.h to recognize XTmrCtr type? I tried including xtmrctr.h but that just resulted in a bazillion errors. I’m guessing it messed up the include structure?

Not sure if you already solved this but just saw it. The way I was able to get it to work is to declare a function in main that handle XTmrCtr and then reference it in FreeRTOSConfig.h. I did not even need to add an extern deceleration in FreeRTOSConfig.h. Not sure how the linker resolve it but it works. Here is more details.

in main.c:

#include "xtmrctr.h"
extern XTmrCtr xTickTimerInstance;
unsigned int getRunTimeCount(){
    return XTmrCtr_GetValue(&xTickTimerInstance,1UL);
}

in FreeRTOSConfig.h:

#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
#define portGET_RUN_TIME_COUNTER_VALUE()     getRunTimeCount()

Hope that helps!