Bootloader recompilation

Hi.

I want to create software-auto-reset function for Arduino Pro Mini. I do this because l want to upload the sketch via bluetooth without DTR signal. But there is a some problems in basic bootloader.

1)If you make a reset by watchdog, the processor is stuck somewhere in bootloader and main application never start. 2)Time window during which bootloader wait for connection is too short. Is difficult to hit right timing.

That's why I want recompile the bootloader. I use source code "atmel / ATmega BOOT_168.c". I made changes only on two lines. But new hex file is twice as large as the original. I used the same avr-gcc as in Arduino IDE directory. My OS is Ubuntu.

Why is new bootloader so big?

what flags did you pass to avr-gcc ?

I use still the same makefile as original bootloader.

override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS) override LDFLAGS = -Wl,$(LDSECTION)

atmega328: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>1' '-DNUM_LED_FLASHES=2' -DBAUD_RATE=57600

try to include -mint8 --frename-registers -O2 (that is "ooh", not zero) in CFLAGS

Also make sure that "-g" is not declared anywhere. -g adds debug code to the final binary, making it quite large.

Interesting reading:

http://www.atmel.com/webdoc/AVRLibcReferenceManual/using_tools_1using_avr_gcc.html

These parameters not helped. But I tried parameter -fno-inline-small-functions and that works.

But I do not understand why I have to edit the original makefile that is bundled with the Arduino IDE. How people working for Arduino company compiled their bootloaders?

If you have 1.5.x, then you have a different version of the compiler than was last used to compile the bootloaders. Inlining behavior and other compile optimization issues change pretty dramatically between versions. (se the optiboot repository history, for example.)