Pages: [1]   Go Down
Author Topic: atmega8 bootloader source code  (Read 3039 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Bangkok, Thailand
Offline Offline
Newbie
*
Karma: 0
Posts: 47
Arduino POP!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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..
« Last Edit: December 12, 2007, 12:34:47 pm by worapoht » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
Logged

Bangkok, Thailand
Offline Offline
Newbie
*
Karma: 0
Posts: 47
Arduino POP!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@Guru download WINAVR 20060421 from
http://sourceforge.net/project/showfiles.php?group_id=68108
expand
  • 20060421 and download file from selected mirror site..
« Last Edit: December 13, 2007, 02:06:57 pm by worapoht » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 smiley :smiley ;D

Used Gcc 3.4 Size =1024 bytes!!!!

Thanks guys!!

Logged

Pages: [1]   Go Up
Jump to: