0

ATmegaBOOT_xx8.c
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

ATmegaBOOT_xx8.c

by Algolosaur on Sat Apr 18, 2009 8:40 am

While waiting for Reality-As-We-Know-It to get its act together, I've been poking around ATmegaBOOT_xx8.c since I've seen comments that gcc 4 builds a file that is too big and gcc 3 won't build for 328P.

My thought was that I might be able to create an assembler source file for 168 and patch that for 328P.

Looking for what changes might be needed, I found this:
#if !defined(__AVR_ATmega168__) || !defined(__AVR_ATmega328P__)
#include <avr/eeprom.h>
#endif


That ~has~ to be wrong. The only time avr/eeprom is not included is when both 168 and 328P are defined.

-----

I'm using gcc 3.4.6 and 4.3.2 from CrossPack-AVR-20090415.dmg (I have a PPC Mac)
which I got from http://www.obdev.at/products/crosspack/download-de.html.

gcc 3 indeed does not build for 328P, but unless I'm misreading the hex files, gcc 4 will (barely) fit (can't actually try to burn it since my USBtinyISP is being held hostage by Fate and the USPS):
ATmegaBOOT_xx8_adaboot328-4.hex
~~~~~~
:107FD00085FFFCCFE1CF709307016093060180918C
:0C7FE000C00085FFFCCF17CEF894FFCF47
:027FEC00800013
:040000030000780081
:00000001FF

ATmegaBOOT_xx8_diecimilia-4.hex
~~~~~~~
:103FA0003296029709F0C7CF103011F00296E5CF94
:083FB00011244BCFF894FFCF60
:023FB800800087
:0400000300003800C1
:00000001FF


gcc 3 does build a smaller file for 168:

ATmegaBOOT_xx8_diecimilia-3.hex
~~~~~~~
:103E800005C0805DCF70CA30D4F7C05D0E949F1C12
:0C3E90008C2F0E949F1CCF910895FFCF43
:023E9C008000A4
:0400000300003800C1
:00000001FF
Veritas Vos Fugere Facet
Algolosaur
 
Posts: 67
Joined: Sun Apr 05, 2009 11:29 am
Location: Butler PA

Re: ATmegaBOOT_xx8.c

by ReSiStAnCe on Sat Apr 25, 2009 4:24 pm

#if !defined(__AVR_ATmega168__) || !defined(__AVR_ATmega328P__)
#include <avr/eeprom.h>
#endif


That ~has~ to be wrong. The only time avr/eeprom is not included is when both 168 and 328P are defined.


no it isn't actually..
the line says if NOT defined (__AVR_ATmega168__) OR NOT defined(__AVR_ATmega328P__)

probably saw over that one.. they use it all over the place for 168 and 328, only this time it was negated..
ReSiStAnCe
 
Posts: 1
Joined: Sat Apr 25, 2009 4:17 pm

Re: ATmegaBOOT_xx8.c

by Algolosaur on Mon Apr 27, 2009 6:05 am

the line says if NOT defined (__AVR_ATmega168__) OR NOT defined(__AVR_ATmega328P__)

probably saw over that one.. they use it all over the place for 168 and 328, only this time it was negated..


By deMorgan's Law, that negates as

if defined (__AVR_ATmega168__) AND defined (__AVR_ATmega328P__)

Since __AVR_ATmega168__ and __AVR_ATmega328P__ are processor type definitions, I do not believe that they would ever be defined at the same time.

If the negated version is common, there is either a serious problem with my understanding of the defines, or a serious problem with the code in general.
Veritas Vos Fugere Facet
Algolosaur
 
Posts: 67
Joined: Sun Apr 05, 2009 11:29 am
Location: Butler PA

Re: ATmegaBOOT_xx8.c

by westfw on Mon Apr 27, 2009 11:57 am

I thought someone had come up with a set of compiler switches that reduced the end-code-size to a reasonable number using gcc4 ? (But I don't see anything special in the makefile. Actually, I can't get the makefile to work very well...)

westfw
 
Posts: 1603
Joined: Fri Apr 27, 2007 1:01 pm
Location: SF Bay area

Re: ATmegaBOOT_xx8.c

by Algolosaur on Tue Apr 28, 2009 5:00 am

Well, at this point I can't do anything deeper than change
OPTIMIZE = -O2
to
OPTIMIZE = -Os
but that certainly makes a difference:
ATmegaBoot_xx8_adaboot328-Os.hex

~~~~~~~~~~
:107F2000C00085FFFCCFF092C600E2CD863709F491
:107F300045CE809103018F5F80930301853009F066
:107F4000D7CDE0910401F09105010995D1CDF894C8
:027F5000FFCF61
:027F52008000AD
:040000030000780081
:00000001FF


This file is 9 lines shorter than ATmegaBOOT_xx8_adaboot328-4.hex, which was built with the default -O2 and gcc 4.3.2

I have some vague recollection of seeing seeing a set of long-format options, but I think that had to do with building avr-libc.
Veritas Vos Fugere Facet
Algolosaur
 
Posts: 67
Joined: Sun Apr 05, 2009 11:29 am
Location: Butler PA

Please be positive and constructive with your questions and comments.