I’m just getting started with FreeRTOS for a University Project.
Unfortunately, even though the examples are very well commented, I fail to build a simple blinky example where one tasks sends something to another task which prints a simple “Received” in the console.
In the future I have to use freeRTOS on an STM32F0 Controller. But to see if I understood the principle behind the tasks, queues and so on, I want to build a simple example where I can see via console output what happens if I do certain things.
First of all I need to say that I’m not very experienced when it comes down to stuff like includes and linking.
Before I started I simply could use the microcontroller.h maybe a stdlib and start right away in my projects.
I think thats the main problem I have right now because I just am not able to make my code work.
I already tried the \FreeRTOS\Demo\WIN32-MingW example code with Atollic Truestudio. I marked that I want to use the blinky_main in the main.c file, compiled it and everything works perfectly fine.
But I don’t want to use a Main-File where my real Main-File is called from with a lot of functions I don’t understand. I just want something like the blinky_main File to work on its own.
So i tried the Manual from the official homepage (http://www.freertos.org/Creating-a-new-FreeRTOS-project.html)
I put every file and folder mentioned in this manual in an extra folder called "NeededRTOSfiles.
I created a new PC Project with atollic.
Than added all the source files to the “src” folder. And included the FreeRTOS\Source\include & FreeRTOS\Source\portable\MSVC-MingW to the include path.
I added the FreeRTOSConfig.h (copied it from the working example) to my project and commented the Tracing_Facility aswell as the vAssertCalled stuff because it generated errors if I tried to build it.
Also I changed some define configUSE values to 0 as you can see below.
Here is my Workspace
and my Config File:
#ifndef FREERTOS_CONFIG_H #define FREERTOS_CONFIG_H /*----------------------------------------------------------- * Application specific definitions. * * These definitions should be adjusted for your particular hardware and * application requirements. * * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. See * http://www.freertos.org/a00110.html *----------------------------------------------------------*/ #define configUSE_PREEMPTION 1 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 #define configUSE_IDLE_HOOK 0 #define configUSE_TICK_HOOK 0 #define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */ #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 50 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the win32 thread. */ #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 35 * 1024 ) ) #define configMAX_TASK_NAME_LEN ( 12 ) #define configUSE_TRACE_FACILITY 0 #define configUSE_16_BIT_TICKS 0 #define configIDLE_SHOULD_YIELD 1 #define configUSE_MUTEXES 1 #define configCHECK_FOR_STACK_OVERFLOW 0 #define configUSE_RECURSIVE_MUTEXES 1 #define configQUEUE_REGISTRY_SIZE 20 #define configUSE_MALLOC_FAILED_HOOK 0 #define configUSE_APPLICATION_TASK_TAG 1 #define configUSE_COUNTING_SEMAPHORES 0 #define configUSE_ALTERNATIVE_API 0 #define configUSE_QUEUE_SETS 1 #define configUSE_TASK_NOTIFICATIONS 1 /* Software timer related configuration options. */ #define configUSE_TIMERS 0 #define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) #define configTIMER_QUEUE_LENGTH 20 #define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 ) #define configMAX_PRIORITIES ( 7 ) /* Run time stats gathering configuration options. */ unsigned long ulGetRunTimeCounterValue( void ); /* Prototype of function that returns run time counter. */ void vConfigureTimerForRunTimeStats( void ); /* Prototype of function that initialises the run time counter. */ #define configGENERATE_RUN_TIME_STATS 0 #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats() #define portGET_RUN_TIME_COUNTER_VALUE() ulGetRunTimeCounterValue() /* Co-routine related configuration options. */ #define configUSE_CO_ROUTINES 0 #define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) /* This demo makes use of one or more example stats formatting functions. These format the raw data provided by the uxTaskGetSystemState() function in to human readable ASCII form. See the notes in the implementation of vTaskList() within FreeRTOS/Source/tasks.c for limitations. */ #define configUSE_STATS_FORMATTING_FUNCTIONS 1 /* Set the following definitions to 1 to include the API function, or zero to exclude the API function. In most cases the linker will remove unused functions anyway. */ #define INCLUDE_vTaskPrioritySet 1 #define INCLUDE_uxTaskPriorityGet 1 #define INCLUDE_vTaskDelete 1 #define INCLUDE_vTaskCleanUpResources 0 #define INCLUDE_vTaskSuspend 1 #define INCLUDE_vTaskDelayUntil 1 #define INCLUDE_vTaskDelay 1 #define INCLUDE_uxTaskGetStackHighWaterMark 1 #define INCLUDE_xTaskGetSchedulerState 1 #define INCLUDE_xTimerGetTimerDaemonTaskHandle 1 #define INCLUDE_xTaskGetIdleTaskHandle 1 #define INCLUDE_eTaskGetState 1 #define INCLUDE_xSemaphoreGetMutexHolder 1 #define INCLUDE_xTimerPendFunctionCall 1 #define INCLUDE_xTaskAbortDelay 1 #define INCLUDE_xTaskGetHandle 1 /* It is a good idea to define configASSERT() while developing. configASSERT() uses the same semantics as the standard C assert() macro. */ //extern void vAssertCalled( unsigned long ulLine, const char * const pcFileName ); //#define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __LINE__, __FILE__ ) /* Include the FreeRTOS+Trace FreeRTOS trace macro definitions. #define TRACE_ENTER_CRITICAL_SECTION() portENTER_CRITICAL() #define TRACE_EXIT_CRITICAL_SECTION() portEXIT_CRITICAL() #include "trcKernelPort.h" */ #endif /* FREERTOS_CONFIG_H */
Unforunately it still won’t build.
If I try to build it, I get the following errors:
C:\Users\...\Desktop\Atollic Workspace\RTOS_Test_mine\Debug/../src/port.c:183: undefined reference to `timeGetDevCaps@8' C:\Users\...\Desktop\Atollic Workspace\RTOS_Test_mine\Debug/../src/port.c:186: undefined reference to `timeBeginPeriod@4' src\port.o: In function `prvEndProcess': C:\Users\...\Desktop\Atollic Workspace\RTOS_Test_mine\Debug/../src/port.c:250: undefined reference to `timeGetDevCaps@8' C:\Users\...\Desktop\Atollic Workspace\RTOS_Test_mine\Debug/../src/port.c:254: undefined reference to `timeEndPeriod@4' src\tasks.o: In function `vTaskStartScheduler': C:\Users\...\Desktop\Atollic Workspace\RTOS_Test_mine\Debug/../src/tasks.c:1905: undefined reference to `vConfigureTimerForRunTimeStats' collect2.exe: error: ld returned 1 exit status
I googled all these and could find the following site for the last one:
But I don’t know why this one shows up because I did set the
configGENERATE_RUN_TIME_STATS to “0”.
The error would disappear if I comment the line portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() in the Config FIle. But why is this still executed although I set it to 0.
Furthermore why do I have to comment the vAssertCalled Stuff? In the Manual is written that they highly recommend to use it. But how can I use it without producing errors?
For the last errors timeGetDevCaps@8 / timeEndPeriod@4 / timeBeginPeriod@4 I was not able to find a solution.
I did find that it could have something to do with a winmm.lib but I couldn’t learn where I find it and how I have to include it.
I could find the code line “#pragma comment(lib, “winmm.lib”)” in the port.c file but obviously it doesn’t seem to work…
So I really would appreciate if someone can help me out creating a very simple blinky example on my own.
I think I’m not the only one with this kind of problem (I already found a few with similiar problems) so maybe this could help other people who getting started to
Thank you a lot!