Compiling FreeRTOS with WinAVR and Eclipse

Hello, I am trying to compile Demo FreeRTOS application with WinAVR and eclipse IDE. These things have happened …. 1) First it was refusing to compile at all. 2) Then, I have included following definition at the command line .. -DGCC_MEGA_AVR So then finally it could compile all source files But …. It gave errors in the linking step, saying, almost all RTOS related functions are undefined !! What to do ? How to make it link ? -———————————————————————– This is the entire eclipseworkspace that I am using for compiling my code, you can download it for testing : http://rapidshare.com/files/148556548/EclipseWorkSpace.rar.html -———————————————————————– Here are the linker’s error messages : Building target: AVR_RTOS_TRY.elf Invoking: AVR C Linker avr-gcc -Wl,-Map,AVR_RTOS_TRY.map -s -mmcu=atmega32 -o"AVR_RTOS_TRY.elf"  ./main.o ./regtest.o  ./serial/serial.o  ./ParTest/ParTest.o  ./FreeRTOS/Source/croutine.o ./FreeRTOS/Source/list.o ./FreeRTOS/Source/queue.o ./FreeRTOS/Source/tasks.o  ./FreeRTOS/Source/portable/GCC/ATMega323/port.o  ./FreeRTOS/Demo/Common/Minimal/AltBlckQ.o ./FreeRTOS/Demo/Common/Minimal/AltBlock.o ./FreeRTOS/Demo/Common/Minimal/AltPollQ.o ./FreeRTOS/Demo/Common/Minimal/AltQTest.o ./FreeRTOS/Demo/Common/Minimal/BlockQ.o ./FreeRTOS/Demo/Common/Minimal/GenQTest.o ./FreeRTOS/Demo/Common/Minimal/PollQ.o ./FreeRTOS/Demo/Common/Minimal/QPeek.o ./FreeRTOS/Demo/Common/Minimal/blocktim.o ./FreeRTOS/Demo/Common/Minimal/comtest.o ./FreeRTOS/Demo/Common/Minimal/countsem.o ./FreeRTOS/Demo/Common/Minimal/crflash.o ./FreeRTOS/Demo/Common/Minimal/crhook.o ./FreeRTOS/Demo/Common/Minimal/death.o ./FreeRTOS/Demo/Common/Minimal/dynamic.o ./FreeRTOS/Demo/Common/Minimal/flash.o ./FreeRTOS/Demo/Common/Minimal/flop.o ./FreeRTOS/Demo/Common/Minimal/integer.o ./FreeRTOS/Demo/Common/Minimal/recmutex.o ./FreeRTOS/Demo/Common/Minimal/semtest.o   ./FreeRTOS/Source/croutine.o: In function `xCoRoutineCreate’: croutine.c:(.text+0x2ae): undefined reference to `pvPortMalloc’ ./FreeRTOS/Source/queue.o: In function `vQueueDelete’: queue.c:(.text+0x2fe): undefined reference to `vPortFree’ queue.c:(.text+0x304): undefined reference to `vPortFree’ ./FreeRTOS/Source/queue.o: In function `xQueueCreate’: …. and so on … lots of such errors. All errors of the type "undefined reference to xxx" -———————————————————————– Please help. Thanks.

Compiling FreeRTOS with WinAVR and Eclipse

It seems like you haven’t included the FreeRTOS source code into the build, but only the include files.. therefore, the FreeRTOS don’t get compiled and hence you have missing object files.. either use the "create /link folder" feature under "source location" and filter out all files not related to the port you are using, or copy the needed port+generic files into your project.. nb. i didn’t look at your workspace files.. cheers

Compiling FreeRTOS with WinAVR and Eclipse

Thank you for reply. Please have a look at workspace files. I have copied all necessary files to my trial project directly preserving the directory structure of RTOS. All RTOS’s core files, namely , croutine.c,list.c,task.c,queue.c and ".O" files are being generated for the same. If you look at linked command line posted in the earlier post … it clearly include all ".o" files. Still its not linking. Also I am getting many warnings like … ../FreeRTOS/Demo/Common/Minimal/AltBlckQ.c:300: warning: array subscript has type ‘char’ ../FreeRTOS/Source/croutine.c:316: warning: dereferencing type-punned pointer will break strict-aliasing rules What does it mean ?

Compiling FreeRTOS with WinAVR and Eclipse

hmm… maybe i misunderstood you when you said "lots of such errors".. are those errors all concerning the same 3 function names? because then it’s probably because you need to include one of the "heap_x.c" files from the "memmang" folder.. read this for more info: http://www.freertos.org/a00111.html cheers..

Compiling FreeRTOS with WinAVR and Eclipse

I GOT IT !!! However solution is problematic … This was the situation … - Demo was getting compiled but was not able to link. - It was giving errors … undefined reference to "xQueueAltGenericSend" undefined reference to "xQueueAltGenericReceive" undefined reference to "vTaskPrioritySet" undefined reference to "xQueueCreateMutex" undefined reference to "uxTaskPriorityGet" undefined reference to "xQueueTakeMutexRecursive" undefined reference to "xQueueGiveMutexRecursive" This is what I found … - Code got linked after adding/changing following DEFINITIONs in FreeRTOSconfig.h //Changed from ZERO to 1 #define INCLUDE_vTaskPrioritySet        1 #define INCLUDE_uxTaskPriorityGet    1 //Added these things … #define configUSE_MUTEXES                1 #define configUSE_COUNTING_SEMAPHORES    1 #define configUSE_RECURSIVE_MUTEXES        1 #define configUSE_ALTERNATIVE_API   1 - This means linker tries to put codes for all the functions which are declared in the RTOS header files, even though these functions are not used anywhere in the DEMO code, thereby making huge hex file, which runs out of the available flash memory. Thus, is there any command line switch to the linker, which will make linker skip all those functions which are not used in the demo files ?????

Compiling FreeRTOS with WinAVR and Eclipse

The linker does *not* include code just because you have the function prototypes included, but by setting all those "configXXX" to 1, you include all sorts of stuff you don’t need.. instead of just including everything with your head under your arm, you should think about what you are doing and only include the stuff you need.. For instance you don’t need to include the ALTernative API, if you only use the full API.. regarding having the linker exclude stuff you don’t need, you can make the compiler put each function in its own section and then have the linker ignore unreferenced sections, but this is only a solution to your symptoms, not the actual problem.. cheers..

Compiling FreeRTOS with WinAVR and Eclipse

Yes thats correct. Got it …. !! I have created new project in eclipse and included only those files in the compilation which were needed (I referred makefile provided with the demo). Though it is problematic process in eclipse to add only necessary files to workspace, as we have to create link to every required file(source files of RTOS) in the filesystem. After that it got compiled and linked successfully !!! Hurrryeee ! Is there any other automatic way to tell this to eclipse ? Like, say in VC, it is sufficient to include the file by writing #include and it gets compiled automatically.