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

undefined reference to 'ulRunTimeStatsC...

Posted by Rodrigo de la Vega on September 26, 2012
Hi, i am beginner with FreeRTOS.
I am trying to compile simple multitask program for test RTOSv7.2.0 on STM32F107VC + Eclipse CDT+ Code sourcery+ openOCD6, but compiler tells me some errors:

DescriptionResourcePathLocationType
more undefined references to `ulRunTimeStatsClock' followtasks.c/pokus107/srcline 1615C/C++ Problem
undefined reference to `ulRunTimeStatsClock'tasks.c/pokus107/srcline 1615C/C++ Problem
undefined reference to `ulRunTimeStatsClock'tasks.c/pokus107/srcline 1357C/C++ Problem
undefined reference to `ulRunTimeStatsClock'tasks.c/pokus107/srcline 1102C/C++ Problem
make: *** [pokus107.elf] Error 1 C/C++ Problem
undefined reference to `_sbrk'pokus107line 0C/C++ Problem

but in FreeRTOSConfig.h
is defined and declared:

extern unsigned long ulRunTimeStatsClock;
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() ulRunTimeStatsClock = 0
#define portGET_RUN_TIME_COUNTER_VALUE() ulRunTimeStatsClock

and in file tasks.c witch contain this errors is included FreeRTOS.h .

What is wrong? Thanks for reply.

RE: undefined reference to 'ulRunTimeStatsC...

Posted by Richard on September 26, 2012
FreeRTOSConfig.h is telling tasks.c that ulRunTimeStatsClock is defined somewhere else, and the compiler appears to be telling you that it isn't defined anywhere. Is it defined anywhere? I suspect not.

A quick way around this would be to start without any run time stats collection. Do that by setting configGENERATE_RUN_TIME_STATS to 0 in FreeRTOSConfig.h, then remove the definitions of portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE().

Regards.

RE: undefined reference to 'ulRunTimeStatsC...

Posted by Rodrigo de la Vega on September 26, 2012
Thanks, i havent defined tris variable anywhere.
So I was disabled configGENERATE_RUN_TIME_STATS, but i have still few errors:

DescriptionResourcePathLocationType
undefined reference to `_sbrk'pokus107line 0C/C++ Problem

my main.c is:


#include

#include "stm32f10x.h"
#include "stm32f10x_rcc.h"
#include "stm32f10x_gpio.h"

#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "semphr.h"

#define LED_PORT GPIOB
#define LED1 GPIO_Pin_13
#define LED2 GPIO_Pin_14
#define LED3 GPIO_Pin_15


void prvTaskA (void* pvParameters)
{
(void) pvParameters;
for (;;) {
GPIO_SetBits(LED_PORT,LED2);
vTaskDelay(1000);
//GPIO_ResetBits(LED_PORT,LED2);
vTaskDelay(1000);
}
}

void prvTaskB (void* pvParameters)
{
(void) pvParameters;
for (;;) {
GPIO_SetBits(LED_PORT,LED1);
vTaskDelay(1000);
//GPIO_ResetBits(LED_PORT,LED1);
vTaskDelay(1000);
}
}


void mojDelay()
{long int i;
i=0;
while(i < 2300000) //cca 0,5 sekundovy delay
{
i++;
}
}

int main(void)
{

GPIO_InitTypeDef GPIO_InitStructure;

SysTick_Config(1000);

SystemCoreClockUpdate();

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);



GPIO_InitStructure.GPIO_Pin = LED1 | LED2 | LED3;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(LED_PORT, &GPIO_InitStructure);




xTaskCreate( prvTaskA, ( signed char * ) "TaskA", configMINIMAL_STACK_SIZE , NULL,1 , NULL );
xTaskCreate( prvTaskB, ( signed char * ) "TaskB", configMINIMAL_STACK_SIZE , NULL,1 , NULL );

vTaskStartScheduler();

//sem by sme dojst nemali

while(1)
{
GPIO_SetBits(LED_PORT,LED1);
mojDelay();
GPIO_SetBits(LED_PORT,LED2);
mojDelay();
GPIO_SetBits(LED_PORT,LED3);
mojDelay();

GPIO_ResetBits(LED_PORT,LED1);
mojDelay();
GPIO_ResetBits(LED_PORT,LED2);
mojDelay();
GPIO_ResetBits(LED_PORT,LED3);
mojDelay();

}
return 0;
}

void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName )
{


( void ) pxTask;
( void ) pcTaskName;

for( ;; );
}

void vApplicationTickHook( void )
{

}



and my config file is:

#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H



#define configUSE_PREEMPTION1
#define configUSE_IDLE_HOOK0
#define configUSE_TICK_HOOK1
#define configCPU_CLOCK_HZ( ( unsigned long ) 72000000 )
#define configTICK_RATE_HZ( ( portTickType ) 1000 )
#define configMAX_PRIORITIES( ( unsigned portBASE_TYPE ) 5 )
#define configMINIMAL_STACK_SIZE( ( unsigned short ) 128 )
#define configTOTAL_HEAP_SIZE( ( size_t ) ( 30 * 1024 ) )
#define configMAX_TASK_NAME_LEN( 16 )
#define configUSE_TRACE_FACILITY1
#define configUSE_16_BIT_TICKS0
#define configIDLE_SHOULD_YIELD1

/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )

#define configUSE_MUTEXES1
#define configUSE_COUNTING_SEMAPHORES 0
#define configUSE_ALTERNATIVE_API 0
#define configCHECK_FOR_STACK_OVERFLOW2
#define configUSE_RECURSIVE_MUTEXES1
#define configQUEUE_REGISTRY_SIZE0
#define configGENERATE_RUN_TIME_STATS0



#define INCLUDE_vTaskPrioritySet1
#define INCLUDE_uxTaskPriorityGet1
#define INCLUDE_vTaskDelete1
#define INCLUDE_vTaskCleanUpResources0
#define INCLUDE_vTaskSuspend1
#define INCLUDE_vTaskDelayUntil1
#define INCLUDE_vTaskDelay1


#define configKERNEL_INTERRUPT_PRIORITY 255

#define configMAX_SYSCALL_INTERRUPT_PRIORITY 191 /* equivalent to 0xb0, or priority 11. */

#define configLIBRARY_KERNEL_INTERRUPT_PRIORITY15


#endif /* FREERTOS_CONFIG_H */



without FreeRTOS includes and tasks is this compiled and functionaly in last endless loop with LED's with no errors

RE: undefined reference to 'ulRunTimeStatsC...

Posted by Rodrigo de la Vega on September 26, 2012
Where i can fix the _sbrk error?

RE: undefined reference to 'ulRunTimeStatsC...

Posted by Richard on September 26, 2012
It sounds like your compiler is trying to use newlilb. You will have to either change to a different library more suited to deeply embedded systems, or provide some of the library functions yourself, or provide a null implementation of _sbrk().

To define your own library functions you can simply include printf-stdarg.c in your project. You will find lots of copies of printf-stdarg.c in the FreeRTOS/Demo sub-directories.

To define your own sbrk() function add something like:

char * sbrk( size_t x )
{
/* Just to remove compiler warning. */
( void ) x;
return NULL;
}


to main.c. Just make sure the function never gets called (it shouldn't, unless you call malloc() in your application code.

Which heap implementation are you using? If you are using heap_3.c (that is, if heap_3.c is being built with your project), switch to heap_1, heap_2 or heap_4. That will prevent some library functions being pulled in and prevent malloc being called by the kernel.

Regards.

RE: undefined reference to 'ulRunTimeStatsC...

Posted by Rodrigo de la Vega on September 26, 2012
Thanks,
I defined my own _sbrk according to your example, and errors was cleared.... now is compiling without errors:)

But no LED in my application is lighting. :/ What can be cause of not running tasks?
Must I enable some interrupts or samwhat other in startup initialization of MCU? I have STM32F107VC and i've read in datasheet that internal oscilator is running on 72Mhz.... are the settings in my main.c and config.h ok?

Sorry for my endless questions.

RE: undefined reference to 'ulRunTimeStatsC...

Posted by Rodrigo de la Vega on September 26, 2012
Oh, sorry, i forgot to tell that i am using heap_4.c

RE: undefined reference to 'ulRunTimeStatsC...

Posted by Dave on September 26, 2012
Chip initialilzation, set up and IO is outside of the scope of topics discussed here. You need to get these things working in a basic blinky application before adding in the RTOS code. If you need help working out how to configure the chip, or create a working project (without FreeRTOS) then I recommend asking questions on the ST forum because that is where the ST experts are. Once you have your basic application working you can add in the FreeRTOS code.

RE: undefined reference to 'ulRunTimeStatsC...

Posted by Rodrigo de la Vega on September 26, 2012
My LED basic application is working without RTOS... but i am trying implement led lighting of my basic application to RTOS Task.... compilation is without faults, but my basic code as task not working. So I asked , if I have not something wrong set, or if i havent done something basic FreeRTOS settings for basic FreeRTOS Functionality. In debugging i cam see that program is still in endless loop xPortStartScheduler, prvSetupTimerInterrupt();,prvPortStartFirstTask();, but nothing is happend with my LEDs.

RE: undefined reference to 'ulRunTimeStatsC...

Posted by Richard on September 26, 2012
My next guess is that you have not installed the FreeRTOS interrupt handlers. See

http://www.freertos.org/FreeRTOS_Support_Forum_Archive/September_2011/freertos_FreeRTOS_on_Atmel_SAM3U_in_CrossStudio_4694403.html

or numerous other posts.

It is always recommended to start your application using one of the many pre-configured examples. That way you start with a project that has the correct files installed, and the correct project configuration.

Regards.

RE: undefined reference to 'ulRunTimeStatsC...

Posted by Rodrigo de la Vega on September 26, 2012
Is possible that is RTOS using SVC Handler from stm32f10_it.c? because from function

static void prvPortStartFirstTask( void )
{
__asm volatile(
" ldr r0, =0xE000ED08 \n" /* Use the NVIC offset register to locate the stack. */
" ldr r0, [r0] \n"
" ldr r0, [r0] \n"
" msr msp, r0\n" /* Set the msp back to the start of the stack. */
" cpsie i\n" /* Globally enable interrupts. */
" svc 0\n" /* System call to start first task. */
" nop\n"
);
}


is program jumping always to :

void SVC_Handler(void)
{
}
witch is located in stm32f10x_it.c
FreeRTOS have own handlers, or is ok, that is using this?
Configuration file i have from Demo maked for STM32f107_GCC_Rowley simple two tasks was written myself an other files i had left from working configuration with MCU without FreeRTOS.

RE: undefined reference to 'ulRunTimeStatsC...

Posted by Richard on September 26, 2012
This post assumes you have used the #define method to install the exception handlers, as per my previous post.

The program is jumping to the default handler. It must use the FreeRTOS handler, otherwise the application will never even start.

The default handler should be defined weak, so the FreeRTOS handler takes its place. If the default handler is not defined weak, just delete it.

Regards.

RE: undefined reference to 'ulRunTimeStatsC...

Posted by Rodrigo de la Vega on September 27, 2012
Thank you for help,
problem was caused by using incorrect interrupt handlers. After correct redefining vectors and removing stm32f10x_it.c , **it.h is my application running with FreeROTS:)


[ 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