Go Down

Topic: I would learn how to modify the bootloader (Read 2 times) previous topic - next topic

hexskrew

If you can get the proper headers set up in avrstudio, it gives an option for scaling the file down. I dunno how it does it though, as it may very well change variable names and etc. thus making the bootloader useless but it's worth a shot i guess.

leo72


davekw7x

#7
Feb 20, 2011, 05:54 pm Last Edit: Feb 20, 2011, 08:46 pm by davekw7x Reason: 1

...Linux.


Here's my experience using avr-gcc version 4.3.4, built from source, on my Centos 5.5 Linux workstation.  See Footnote.

When I executed "make atmega328" using arduino-0022/arduino/bootloaders/Makefile, the size of the object file was too large (532 bytes)

To get it below the 512 byte limit I did the following:

I changed line 61 of Makefile from the following
Code: [Select]

override LDFLAGS       = -Wl,$(LDSECTION) -Wl,--relax -nostartfiles


to the following
Code: [Select]

override LDFLAGS       = -Wl,$(LDSECTION) -Wl,--relax -nostartfiles -nostdlib


Now, with my compiler, that gets the object size down to 490 bytes.

Before going any further, there is a bug in that version of optiboot.c that has been documented elsewhere.  I really, really (really) recommend that you do the following, as I did:


I changed line 216 of optiboot.c from the following
Code: [Select]

 // asm volatile ("clr __zero_reg__");


to the following
Code: [Select]

 asm volatile ("clr __zero_reg__");


This must be the first executable statement in main().

This statement requires an avr header that was not previously needed, so I inserted the following after line 71 of optiboot.c
Code: [Select]

#include <avr/interrupt.h>

For me, that brought the object size to 492 bytes.

The code is very tightly written, and you won't have oodles and oodles of room to add any enhancements, but maybe this will give you a chance to start.


There have been other changes in optiboot since the last Arduino release.  If you really want to work with the latest, go to the Optiboot Home Page and follow the instructions to check out the latest optiboot source.  That code leaves less headroom than the code in arduino-0022, so you may have problems shoe-horning other stuff into it.


Bottom line: If you have a different version of avr-gcc, you may not see the exact same results.  Do I have to say it?  IWFMYMMV. (It works ror me, your mileage may vary.)

Regards,

Dave

Footnote:  Actually, I created a new working subdirectory under the optiboot directory and copied everything there.  That way, I could experiment to my little heart's content in the working directory and still have the originals with which to compare.



westfw

Quote
If you really want to work with the latest, go to the Optiboot Home Page and follow the instructions to check out the latest optiboot source.  That code leaves less headroom than the code in arduino-0022, so you may have problems shoe-horning other stuff into it.

Also be sure to check out the "issues" database from google code.  There are patches and discussion there that haven't made it into the source yet...

leo72


Go Up