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 FreeRTOSDemoWIN32-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 FreeRTOSSourceinclude & FreeRTOSSourceportableMSVC-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:
* 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
define configUSE_PREEMPTION 1
define configUSEPORTOPTIMISEDTASKSELECTION 1
define configUSEIDLEHOOK 0
define configUSETICKHOOK 0
define configTICKRATEHZ ( 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 configMINIMALSTACKSIZE ( ( 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 configTOTALHEAPSIZE ( ( size_t ) ( 35 * 1024 ) )
define configMAXTASKNAME_LEN ( 12 )
define configUSETRACEFACILITY 0
define configUSE16BIT_TICKS 0
define configIDLESHOULDYIELD 1
define configUSE_MUTEXES 1
define configCHECKFORSTACK_OVERFLOW 0
define configUSERECURSIVEMUTEXES 1
define configQUEUEREGISTRYSIZE 20
define configUSEMALLOCFAILED_HOOK 0
define configUSEAPPLICATIONTASK_TAG 1
define configUSECOUNTINGSEMAPHORES 0
define configUSEALTERNATIVEAPI 0
define configUSEQUEUESETS 1
define configUSETASKNOTIFICATIONS 1
/* Software timer related configuration options. */
define configUSE_TIMERS 0
define configTIMERTASKPRIORITY ( configMAX_PRIORITIES - 1 )
define configTIMERQUEUELENGTH 20
define configTIMERTASKSTACKDEPTH ( configMINIMALSTACK_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 configGENERATERUNTIME_STATS 0
define portCONFIGURETIMERFORRUNTIME_STATS() vConfigureTimerForRunTimeStats()
define portGETRUNTIMECOUNTERVALUE() ulGetRunTimeCounterValue()
/* Co-routine related configuration options. */
define configUSECOROUTINES 0
define configMAXCOROUTINE_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 configUSESTATSFORMATTING_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 TRACEENTERCRITICALSECTION() portENTERCRITICAL()
define TRACEEXITCRITICALSECTION() portEXITCRITICAL()
endif /* FREERTOSCONFIGH */
Unforunately it still won't build.
If I try to build it, I get the following errors:
C:Users...DesktopAtollic WorkspaceRTOSTestmineDebug/../src/port.c:183: undefined reference to
C:\Users\...\Desktop\Atollic Workspace\RTOS_Test_mine\Debug/../src/port.c:186: undefined reference totimeBeginPeriod@4'
srcport.o: In function
C:\Users\...\Desktop\Atollic Workspace\RTOS_Test_mine\Debug/../src/port.c:250: undefined reference totimeGetDevCaps@8'
C:Users...DesktopAtollic WorkspaceRTOSTestmineDebug/../src/port.c:254: undefined reference to
src\tasks.o: In functionvTaskStartScheduler':
C:Users...DesktopAtollic WorkspaceRTOSTestmineDebug/../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
configGENERATERUNTIME_STATS to "0".
The error would disappear if I comment the line portCONFIGURETIMERFORRUNTIME_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!
Hi Real Time Engineers ltd,
thank you very much for your answer.
It seems like you can build the project with Atollic.
I thougt the necessary Tools are there because the demo project works perfectly fine.
If the original demo wouldn't work I think I would have changed the IDE long ago, but the fact that it works made me think that I could make it somehow.
I searched for the winmm.lib but was not able to include it succesfully.
I just started downloading the Eclipse cdt IDE with MingW. Maybe I'll try the Visual Studio Demo too.
But I thougt it would be nice to get it to work with atollic because I have do go back to Atollic implementing the stuff on my STM32 :)
Unfortunately I'll be away over the weekend so I'll send a status report on Monday or Tuesday.
Thank you for your Help :)