Troube creating own Blinky example with Win32 simulation in Atollic Studio

Hello, 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: ~~~

ifndef FREERTOSCONFIGH

define FREERTOSCONFIGH

/———————————————————– * 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 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()

include “trcKernelPort.h”

*/

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 timeGetDevCaps@8' C:Users...DesktopAtollic WorkspaceRTOS_Test_mineDebug/../src/port.c:186: undefined reference totimeBeginPeriod@4′ srcport.o: In function prvEndProcess': C:Users...DesktopAtollic WorkspaceRTOS_Test_mineDebug/../src/port.c:250: undefined reference totimeGetDevCaps@8′ C:Users...DesktopAtollic WorkspaceRTOSTestmineDebug/../src/port.c:254: undefined reference to timeEndPeriod@4' srctasks.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: http://www.freertos.org/rtos-run-time-stats.html 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! Greetings evox402

Troube creating own Blinky example with Win32 simulation in Atollic Studio

timeGetDevCaps is a Windows function that is used by the Win32 port layer. It does not come from FreeRTOS, but your Windows compiler libraries. I didn’t even know you could build the project in the Atollic tools. Did you have to install MingW manually, or do the Atollic tools come with MingW? Did you try following the instructions (http://www.freertos.org/FreeRTOS-Windows-Simulator-Emulator-for-Visual-Studio-and-Eclipse-MingW.html) using the standard Eclipse CDT (rather than the Atollic tools, which are really intended for cross compilation) https://eclipse.org/cdt/ ? Alternatively use the MSVC project, it is much easier.

Troube creating own Blinky example with Win32 simulation in Atollic Studio

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 🙂

Troube creating own Blinky example with Win32 simulation in Atollic Studio

Hello, I found some time to try the Eclipse cdt IDE with MingW. I took the same steps as with the Atollic IDE and used the same config file settings. Unfortunately I have the exact same error regarding the timeGetDevCaps and the Win32 Port layer. My new workspace Could you please tell me where can I find the winmm.lib and how do I include it in my project to make it work? I can’t seem to find how to solve this issue. Thank you a lot. Best Regards evox402

Troube creating own Blinky example with Win32 simulation in Atollic Studio

Small Update I think I fixed the issue with the method mentioned here: http://stackoverflow.com/posts/20105088/edit I’ll try to write a blinky demo and share my progress if everything works so maybe it would help some other people who are lost 🙂 But I would appreciate if someone could tell me how do I can make it work with the vAssertCalled stuff. It seems like it would be quite important to have it in your project. If I run in more trouble I’ll be back soon… Thanks so far, greetings evox402

Troube creating own Blinky example with Win32 simulation in Atollic Studio

Did you say why you had to comment out the configASSERT() macros? I think you just said you had to. The semantics are identical to the standard C library assert(). Take a look at the configASSERT() documentation http://www.freertos.org/a00110.html#configASSERT If you are defining it to call a function call vAssertCalled(), did you actually provide an implementation of vAssertCalled()?

Troube creating own Blinky example with Win32 simulation in Atollic Studio

Hello Real Time Engineers ltd. thank you for your answer. As I said I’m not very experienced when it comes down to pure C-Stuff. But I think the problem was, as you said, that there was no function vAssertCalled(). I took this Solution and now it works with the configAssert Macro 🙂 Also the example works with atollic too if you include the winmm.lib. Maybe this should be hinted on the “create a new FreeRTOS project” – site so that noobs like me know what to do 🙂 Anyhow, I thank you very much for your help it was really appreciated! Have a nice day. Greetings evox402