Go Down

Topic: atmega8 bootloader source code (Read 3345 times) previous topic - next topic

Guru

HEllo guys,

I've been trying to compile(using Win AVR)  the atmega8 bootloader source code that is located in the bootloader folder in the arduino hardware folder.But the code fails to fit into 1Kb ,it compiles to into anything more than 1088 bytes, and hence i'm unable to make it fit into 1Kb boot section of Atmega8.(i dont want to waste more than 1Kb on the boot code )

Plz Help.

mellis

What command line are you using (i.e. what parameters end up getting passed to gcc)?

Guru

Hey Mellis,

             C:\WinAVR-20070525/bin/avr-gcc -g -Wall -Os -mmcu=atmega8 -Datmega8 -DF_CPU=16000000 -DBAUD_RATE=9600   -c -o ATmegaBOOT.o ATmegaBOOT.c

              is what I see in the command line when I Make the project.

              My gcc version 4.1.2 (WinAVR 20070525).

Thanks. :)

mellis

Hmm, using the Makefile in that directory, I got the following output and a bootloader size of 1002 bytes:

/Applications/arduino-0010/hardware/tools/avr/bin/avr-gcc -g -Wall -Os -mmcu=atmega8 -Datmega8 -DF_CPU=16000000 -DBAUD_RATE=19200 -I/Applications/arduino-0010/hardware/tools/avr/include   -c -o ATmegaBOOT.o ATmegaBOOT.c
In file included from ATmegaBOOT.c:39:
/Applications/arduino-0010/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to <util/delay.h>."
/Applications/arduino-0010/hardware/tools/avr/bin/avr-gcc -g -Wall -Os -mmcu=atmega8 -Datmega8 -DF_CPU=16000000 -DBAUD_RATE=19200 -I/Applications/arduino-0010/hardware/tools/avr/include -Wl,-Map,ATmegaBOOT.map,--section-start=.text=0x1c00 -o ATmegaBOOT.elf ATmegaBOOT.o
/Applications/arduino-0010/hardware/tools/avr/bin/avr-objdump -h -S ATmegaBOOT.elf > ATmegaBOOT.lst
/Applications/arduino-0010/hardware/tools/avr/bin/avr-objcopy -j .text -j .data -O ihex ATmegaBOOT.elf ATmegaBOOT.hex
/Applications/arduino-0010/hardware/tools/avr/bin/avr-objcopy -j .text -j .data -O binary ATmegaBOOT.elf ATmegaBOOT.bin
/Applications/arduino-0010/hardware/tools/avr/bin/avr-objcopy -j .text -j .data -O srec ATmegaBOOT.elf ATmegaBOOT.srec
/Applications/arduino-0010/hardware/tools/avr/bin/avr-gcc -S -g -Wall -Os -mmcu=atmega8 -Datmega8 -DF_CPU=16000000 -DBAUD_RATE=19200 -I/Applications/arduino-0010/hardware/tools/avr/include -g1 ATmegaBOOT.c
In file included from ATmegaBOOT.c:39:
/Applications/arduino-0010/hardware/tools/avr/bin/../lib/gcc/avr/4.0.2/../../../../avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to <util/delay.h>."
/Applications/arduino-0010/hardware/tools/avr/bin/avr-size ATmegaBOOT.hex
  text         data          bss          dec          hex      filename
     0         1002            0         1002          3ea      ATmegaBOOT.hex

This was with avr-gcc 4.0.2.  How are you measuring the size of the bootloader?

mellis

Also, did you make any changes to the source code?

worapoht

#5
Dec 12, 2007, 06:32 pm Last Edit: Dec 12, 2007, 06:34 pm by worapoht Reason: 1
First things to do .. 8-) uninstall 2007xxxx WINAVR, and install old 20060421 and compile again..

compiled code from 20060421 is work well but weird result if compile on 2007xxxx.

I know this after lost time for weeks to find out the problem.

I think this problem cause from new 2007xxxx WINAVR internal optimization algorithm and boot library had changed .. then it's not work for arduino bootloader sourcecode.

Enjoy..

Guru

C:\WinAVR-20070525/bin/avr-gcc -g -Wall -Os -mmcu=atmega8 -Datmega8 -DF_CPU=16000000 -DBAUD_RATE=9600   -c -o ATmegaBOOT.o ATmegaBOOT.c
In file included from ATmegaBOOT.c:39: c:/winavr-20070525/bin/../avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to <util/delay.h>."
C:\WinAVR-20070525/bin/avr-gcc -g -Wall -Os -mmcu=atmega8 -Datmega8 -DF_CPU=16000000 -DBAUD_RATE=9600 -Wl,-Map,ATmegaBOOT.map,--section-start=.text=0x1800 -o AT
megaBOOT.elf ATmegaBOOT.o
C:\WinAVR-20070525/bin/avr-objdump -h -S ATmegaBOOT.elf > ATmegaBOOT.lst
C:\WinAVR-20070525/bin/avr-objcopy -j .text -j .data -O ihex ATmegaBOOT.elf ATmegaBOOT.hex
C:\WinAVR-20070525/bin/avr-objcopy -j .text -j .data -O binary ATmegaBOOT.elf ATmegaBOOT.bin
C:\WinAVR-20070525/bin/avr-objcopy -j .text -j .data -O srec ATmegaBOOT.elf ATmegaBOOT.srec
C:\WinAVR-20070525/bin/avr-gcc -S -g -Wall -Os -mmcu=atmega8 -Datmega8 -DF_CPU=16000000 -DBAUD_RATE=9600 -g1 ATmegaBOOT.c
In file included from ATmegaBOOT.c:39: c:/winavr-20070525/bin/../avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to <util/delay.h>."
C:\WinAVR-20070525/bin/avr-size ATmegaBOOT.hex
  text    data     bss     dec     hex filename
     0    1088       0    1088     440 ATmegaBOOT.hex

         Well, This is how I realized that the hex file was 1088 bytes.

          The only change I made was changing the start address from 1c00 to 1800 in the make file in order to get the bootloader compiled (with 1c00, it was giving a compilation error)

          @worapoht, Can you please point me to the right avr-gcc download on net. I'll try using it once.

Thanks :)

worapoht

#7
Dec 13, 2007, 08:05 pm Last Edit: Dec 13, 2007, 08:06 pm by worapoht Reason: 1
@Guru download WINAVR 20060421 from
http://sourceforge.net/project/showfiles.php?group_id=68108
expand
  • 20060421 and download file from selected mirror site..

Guru

Hi all,
Hi Mellis.. i did the exact same thing as u did..but this is what i see.

C:\exp\arduino-0010\hardware\bootloaders\atmega8>make
C:\exp\arduino-0010\hardware\tools\avr\bin\avr-gcc -g -Wall -Os -mmcu=atmega8 -D
atmega8 -DF_CPU=16000000 -DBAUD_RATE=19200 -IC:\exp\arduino-0010\hardware\tools\
avr\include   -c -o ATmegaBOOT.o ATmegaBOOT.c
In file included from ATmegaBOOT.c:39:
c:/exp/arduino-0010/hardware/tools/avr/bin/../avr/include/avr/delay.h:36:2: warn
ing: #warning "This file has been moved to <util/delay.h>."
C:\exp\arduino-0010\hardware\tools\avr\bin\avr-gcc -g -Wall -Os -mmcu=atmega8 -D
atmega8 -DF_CPU=16000000 -DBAUD_RATE=19200 -IC:\exp\arduino-0010\hardware\tools\
avr\include -Wl,-Map,ATmegaBOOT.map,--section-start=.text=0x1c00 -o ATmegaBOOT.e
lf ATmegaBOOT.o
c:\exp\arduino-0010\hardware\tools\avr\bin\..\lib\gcc\avr\4.1.2\..\..\..\..\avr\
bin\ld.exe: address 0x203e of ATmegaBOOT.elf section .text is not within region
text
make: *** [ATmegaBOOT.elf] Error 1

NOW ON CHANGING start address to 0x1800

C:\exp\arduino-0010\hardware\bootloaders\atmega8>make
C:\exp\arduino-0010\hardware\tools\avr\bin\avr-gcc -g -Wall -Os -mmcu=atmega8 -D
atmega8 -DF_CPU=16000000 -DBAUD_RATE=19200 -IC:\exp\arduino-0010\hardware\tools\
avr\include -Wl,-Map,ATmegaBOOT.map,--section-start=.text=0x1800 -o ATmegaBOOT.e
lf ATmegaBOOT.o
C:\exp\arduino-0010\hardware\tools\avr\bin\avr-objdump -h -S ATmegaBOOT.elf > AT
megaBOOT.lst
C:\exp\arduino-0010\hardware\tools\avr\bin\avr-objcopy -j .text -j .data -O ihex
ATmegaBOOT.elf ATmegaBOOT.hex
C:\exp\arduino-0010\hardware\tools\avr\bin\avr-objcopy -j .text -j .data -O bina
ry ATmegaBOOT.elf ATmegaBOOT.bin
C:\exp\arduino-0010\hardware\tools\avr\bin\avr-objcopy -j .text -j .data -O srec
ATmegaBOOT.elf ATmegaBOOT.srec
C:\exp\arduino-0010\hardware\tools\avr\bin\avr-gcc -S -g -Wall -Os -mmcu=atmega8
-Datmega8 -DF_CPU=16000000 -DBAUD_RATE=19200 -IC:\exp\arduino-0010\hardware\too
ls\avr\include -g1 ATmegaBOOT.c
In file included from ATmegaBOOT.c:39:
c:/exp/arduino-0010/hardware/tools/avr/bin/../avr/include/avr/delay.h:36:2: warn
ing: #warning "This file has been moved to <util/delay.h>."
C:\exp\arduino-0010\hardware\tools\avr\bin\avr-size ATmegaBOOT.hex
  text    data     bss     dec     hex filename
     0    1088       0    1088     440 ATmegaBOOT.hex

Thanks.

mellis

Huh.  Which version of gcc are you using?  Did you try the one that worapoht recommended?

Guru

:) ::) ;D

Used Gcc 3.4 Size =1024 bytes!!!!

Thanks guys!!


Go Up