AVR323_WinAVR demo compilation with AVR Studi

grosiles wrote on Sunday, March 28, 2010:

I used to be able to compile the FreeRTOS demo for the Atmega32 (using the Atmega323 demo)  with AVR Studio. I downloaded the newer version of FreeRTOS and get the following errors:
C:\WinAVR\FreeRTOS\Demo\AVR_ATMega323_WinAVR\rtosdemo\default/…/…/main.c:269: undefined reference to `eeprom_read_block’

C:\WinAVR\FreeRTOS\Demo\AVR_ATMega323_WinAVR\rtosdemo\default/…/…/main.c:271: undefined reference to `eeprom_write_byte’

I know this looks more like an AVR studio or WinAVR question, but since it is related to the FreeRTOS demos I would like to see if someone has encountered this problem. It would seem that the compiler does not know were to locate the eeprom library, but  if I make the program directly on a command window I don’t get this problem.

Thanks.

grosiles wrote on Sunday, March 28, 2010:

Ok, I found the culcript, which I do not know who to blame :). The main.c code for the demo has the following lines:

#ifdef GCC_MEGA_AVR
/* EEPROM routines used only with the WinAVR compiler. */
#include <avr/eeprom.h>
#endif

It seems that GCC_MEGA_AVR is not defined. I assume FreeRTOS is expected this to be defined somewhere in the compiler, but it is not being detected at compilation time. As I said, if I “make” directly on a command line there is no problem. Hence, somehow AVR Studio is not providing this definition at compile time. I do not think I need to add the file into the project since this is suppose to be part of the compiler standard definitions (?).

In any case, this did not happen with the older versions on the WinAVR and AVRStudio tools.

Regards.

grosiles wrote on Sunday, March 28, 2010:

Forgot to mention, commenting out the pre-processor lines fixes the problem.

grosiles wrote on Sunday, March 28, 2010:

I meant to say:
// #ifdef GCC_MEGA_AVR
/* EEPROM routines used only with the WinAVR compiler. */
#include <avr/eeprom.h>
// #endif

Sorry for so much blurb.

rtel wrote on Sunday, March 28, 2010:

Its been a while since I updated my WinAVR, but have just tried the very latest WinAVR against the very latest FreeRTOS and found it compiled without any problems (I got the “…/…/Source/tasks.c:420: warning: cast from pointer to integer of different size” warning which has been discussed here before), although I have not tried actually running the code.

The GCC_MEGA_AVR definition should be set on the GCC command line, using the -D option.  Take a look at the makefile that comes in the FreeRTOS WinAVR example project.

Regards

gerardo_rosiles wrote on Wednesday, April 28, 2010:

Thanks, that fixed the problem.