Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

FreeRTOS run time stats.

Posted by Hurza on November 20, 2012
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:\CooCox\CoIDE\workspace\SuperSystem -Wl,--gc-sections -Wl,-TC:\CooCox\CoIDE\workspace\SuperSystem/arm-gcc-link.ld -g -o SuperSystem.elf ..\obj\stm32f10x_tim.o ..\obj\startup_stm32f10x_md_vl.o ..\obj\core_cm3.o ..\obj\system_stm32f10x.o ..\obj\DisplayController.o ..\obj\stm32f10x_gpio.o ..\obj\main.o ..\obj\adsf.o ..\obj\requiredMethodsFromMain.o ..\obj\timers.o ..\obj\stm32f10x_rcc.o ..\obj\MotorsController.o ..\obj\stm32f10x_exti.o ..\obj\tasks.o ..\obj\stm32f10x_adc.o ..\obj\alfanumDisplay.o ..\obj\list.o ..\obj\stm32f10x_flash.o ..\obj\stm32f10x_it.o ..\obj\MeasurementsController.o ..\obj\queue.o ..\obj\port.o ..\obj\SSBootstrapper.o ..\obj\misc.o ..\obj\heap_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-m\libg.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-m\libg.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-m\libg.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-m\libg.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.

RE: FreeRTOS run time stats.

Posted by Richard on November 20, 2012
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.

RE: FreeRTOS run time stats.

Posted by Hurza on November 20, 2012
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[0] is Task's name, array[1] is AbsTime and array[2] is %Time ?

Regards.

RE: FreeRTOS run time stats.

Posted by Hurza on November 21, 2012
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.

RE: FreeRTOS run time stats.

Posted by Richard on November 21, 2012
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.

RE: FreeRTOS run time stats.

Posted by Hurza on November 22, 2012
It's runs perfectly. Last problem was too small coutern, now with 32bit it's OK.

Regards.

RE: FreeRTOS run time stats.

Posted by Hurza on November 28, 2012
The last case which makes me trouble is that: What happens if 32bit counter overflow ? FreeRTOS detect it ? Or statistics are count again ?

Regards.

RE: FreeRTOS run time stats.

Posted by Dave on November 28, 2012
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.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists