Go Down

Topic: ATmegaBOOT_168.c bootloader does not compile with newer AVR tools (Read 1 time) previous topic - next topic


The ATmegaBOOT_168.c module does not compile with an avr toolset that uses a av libC more recent than
July 5, 2009
(It can't currently be built on linux)

This relates to the use of the EEWE define which is no longer defined in eeprom.h

There is a discussion of this over in this thread:

There are a number ways to "fix" this but my recommendation would be:
(read additional details in the above thread)

- remove the ifdefs around the include for <avr/eeprom.h> (around line 79) since it is a NOP
and eeprom is always being included and eeprom.h is needed.

- Remove the ifdefs around the eeprom busy test while loops (around line 584)
and replace it with a single line of either:
or for compatibility with avr tools prior to Feb 26, 2004

This is not altering any code but merely using  macros available in eeprom.h to test the EEPROM busy
status that have been available for many years.
These eeprom.h macros will automatically use the proper EECR bit names.

--- bill


can you apply the suggested diffs, confirm that the produced binaries (hex files) are identical when running the same compiler, and provide a "patch" file in an issue submitted via http://code.google.com/p/arduino/issues/list ?  Ready-to-apply patches with easy proofs of correctness get into the code much faster than mere ideas that "should work."  (You seem up to the programming, and just need a bit of pushing in the direction of learning the "production" toolset...)


I'm trying to compile a 7.37MHz version for a 328p and both variants of the above fix show an error:

C:\arduino-0022\arduino-0022\hardware\arduino\bootloaders\atmega/ATmegaBOOT_168.c:588: undefined ref
erence to `eeprom_is_ready'
make: *** [ATmegaBOOT_168_atmega328_pro_7MHz.elf] Error 1

C:\arduino-0022\arduino-0022\hardware\arduino\bootloaders\atmega/ATmegaBOOT_168.c:588: undefined ref
erence to `eeprom_busy_wait'
make: *** [ATmegaBOOT_168_atmega328_pro_7MHz.elf] Error 1



I'm curious as to why this didn't work for you.

I have tried this on both the Windows version of 0022 and on linux with 0022 and it compiles
for all the originally defined targets in the Makefile.

And for westfw, yes the generated code (.hex file) is identical with the .c file changed for this bug-fix
when using the same toolset.
However, one very interesting thing worth noting is that the .hex file recreated for the m238p
from the "as is" bootloader files and toolset from the 0022 windows release and 0022 supplied
avr tools does not match the pre-compiled .hex file that comes with the windows 0022 release.
I haven't tried the other targets but this does seem concerning.
Like perhaps the distribution scripts/makefiles are not using the same windows compiler
that is shipped with the windows version of 0022 or maybe windows is not used
to create the windows releases.

My test enviroments:
Windows is using the 4.3.2 avr-gcc tools that come with arduino 0022
(there is no other arduino or avr toolset on the test machine).

Linux (Ubuntu 10.10) is using 4.3.3 avr-gcc from Bingos debian binary install package.

I've attached the Makefile and .c bootloader file I was using.
I did modify the Makefile so that the "all" target builds all the targets rather than do nothing.
--- bill


Bill, thanks for providing your ATmegaBOOT_168.c - I've found the issue with mine:
/* some includes */
#include <inttypes.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include <avr/wdt.h>
#include <util/delay.h>

#include <avr/eeprom.h>   <<<<<<<< this was missing in my source.

Now it compiles. P.

Go Up