Optiboot compilation problem in ATmega328

Dear friends,
I have found one problem while compiling optiboot os in Atmel studio 6.2
here by i am attaching the image where i am getting error.
error is - F_CPU’ undeclared (first use in this function).

tools used- atmel studio version 6.2
bootloader used- optiboot( available in Arduino-1.0.5 installation folder)
OS version - windows 8

please reply if you have any idea
Thanks in advance.


I did not try to compile Optiboot with Atmel studio, but it compiles using the makefile at least on Linux. If you are using avr-gcc 4.8.1 (ubuntu 14.04), then I ran into a problem with the optimization flags, but it looks like this has been fixed: https://code.google.com/p/optiboot/issues/detail?id=101

spycatcher2k: Idea - define it at the top of your code with the CPU frequency you are building for

Yep. If OP finds the optiboot source folder and inspects Makefile, OP will find that F_CPU is a #define value entered at command prompt and takes the value of AVR_FREQ, which is defined elsewhere in the file, depending on which target dev board the compilation is intended. For atmega328, AVR_FREQ = 16000000L