FreeRTOS run time stats.

Hi,
I would like to use vTaskGetRunTimeStats() function. I did 3 steps:
1. configGENERATE_RUN_TIME_STATS
2. portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
3. portGET_RUN_TIME_COUNTER_VALUE()
Then i wanted to use vTaskGetRunTimeStats() function. But compiler said me:
              [cc] Starting link
       [cc] arm-none-eabi-gcc -O0 -nostartfiles -Wl,-Map=SuperSystem.map -mcpu=cortex-m3 -mthumb -LC:CooCoxCoIDEworkspaceSuperSystem -Wl,--gc-sections -Wl,-TC:CooCoxCoIDEworkspaceSuperSystem/arm-gcc-link.ld -g -o SuperSystem.elf ..objstm32f10x_tim.o ..objstartup_stm32f10x_md_vl.o ..objcore_cm3.o ..objsystem_stm32f10x.o ..objDisplayController.o ..objstm32f10x_gpio.o ..objmain.o ..objadsf.o ..objrequiredMethodsFromMain.o ..objtimers.o ..objstm32f10x_rcc.o ..objMotorsController.o ..objstm32f10x_exti.o ..objtasks.o ..objstm32f10x_adc.o ..objalfanumDisplay.o ..objlist.o ..objstm32f10x_flash.o ..objstm32f10x_it.o ..objMeasurementsController.o ..objqueue.o ..objport.o ..objSSBootstrapper.o ..objmisc.o ..objheap_1.o
       [cc] sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib/armv7-mlibg.a(lib_a-sbrkr.o): In function `_sbrk_r':
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib/armv7-mlibg.a(lib_a-abort.o): In function `abort':
       [cc] abort.c:(.text.abort+0xa): undefined reference to `_exit'
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib/armv7-mlibg.a(lib_a-signalr.o): In function `_kill_r':
       [cc] signalr.c:(.text._kill_r+0xe): undefined reference to `_kill'
       [cc] c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib/armv7-mlibg.a(lib_a-signalr.o): In function `_getpid_r':
       [cc] signalr.c:(.text._getpid_r+0x0): undefined reference to `_getpid'
       [cc] collect2: ld returned 1 exit status
What is: _sbrk  ? How to fix it ?
This problem is only when i add function vTaskGetRunTimeStats(). If i delete it, it’s all right.
I use CooCox. Best Regards,
Horza.

FreeRTOS run time stats.

It looks like your implementation has used a printf() type function (maybe sprintf()) that has resulted in library functions being linked into your application, and that the library function requires you to define some target specific functions.  I would guess, from your output, that CooCox is using GCC with Newlib – Newlib is not ideal for small embedded systems. You have a few choices: 1) Provide stubs for the functions just to shut the linker up.  That is ok if the functions are never actually going to be used.  See the file newlib_stubs.c in one of the FreeRTOS/Demo subdirectories. 2) Provide real implementations for the functions.  See the syscalls.c files in a couple of sub-directories off of FreeRTOS/Demo for references. 3) Use a different library.  Try adding printf-stdarg.c to your project – you will find lots of copies in sub-directories off of FreeRTOS/Demo.  printf-stdarg.c implements a tiny sprintf() function that might prevent the Newlilb files being dragged into your build.  Be careful though, as snprintf() is not implemented properly in printf-stdarg.c. Regards.

FreeRTOS run time stats.

Aa so vTaskGetRunTimeStats function has sprintf. Can i remove this functions from tasks.c file ?, because i don’t need to print it on display, i want to send report about run time through SPI. I removed it, it’s compiled, but i don’t know if I have proper array with RunTimeStats.
I have additional question, how does this array looks after vTaskGetRunTimeStats() ? is that in each field is another data ? i mean: array is Task’s name, array is AbsTime and array is %Time ? Regards.

FreeRTOS run time stats.

I’ve added printf-stdarg.c and it works. But firstly in array from vTaskGetRunTimeStats() function percentage is ok i think, but in each next iteration i have studpid numbers. For example 2558% or more. Is that possible that my 16bit counter has overflow and then vTaskGetRunTimeStats() counts it wrong ? Or should I reset counter after vTaskGetRunTimeStats() ? Regards.

FreeRTOS run time stats.

The run time stats counter needs to have a resolution higher than the tick count, preferably at least 10 times higher.  Because of this, only 32 bit counters are practical. Regards.

FreeRTOS run time stats.

It’s runs perfectly. Last problem was too small coutern, now with 32bit it’s OK. Regards.

FreeRTOS run time stats.

The last case which makes me trouble is that: What happens if 32bit counter overflow ? FreeRTOS detect it ? Or statistics are count again ? Regards.

FreeRTOS run time stats.

Once the 32 bit counter overflows that is it. If you want to keep the run time stats going for ever then you could use a 64 bit counter but that is very inefficient. Or you could change the implementation. Normally the counter is only used for debugging and optimization though so not for more than a few hours at a time maximum.