Troube creating own Blinky example with Win32 simulation in Atollic Studio

evox402 wrote on Thursday, November 24, 2016:

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 \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:
http://www.freertos.org/rtos-run-time-stats.html
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 :slight_smile:

Thank you a lot!
Greetings evox402

rtel wrote on Thursday, November 24, 2016:

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.

evox402 wrote on Thursday, November 24, 2016:

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 :slight_smile:

Unfortunately I’ll be away over the weekend so I’ll send a status report on Monday or Tuesday.

Thank you for your Help :slight_smile:

evox402 wrote on Friday, November 25, 2016:

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

evox402 wrote on Friday, November 25, 2016:

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 :slight_smile:

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

rtel wrote on Friday, November 25, 2016:

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()?

evox402 wrote on Monday, November 28, 2016:

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 :slight_smile:

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 :slight_smile:

Anyhow, I thank you very much for your help it was really appreciated!

Have a nice day.
Greetings
evox402