How to change bootloader for different XTAL frequency

Hi, I am wanting to use Arduino with a lower crystal frequency but this seems to prevent the board uploading a sketch.

Can someone tell me where the source code is for an MEGA 1280 bootloader for Arduino - and post how to compile it for a different crystal frequency.


Look at boards.txt to see where the bootloader is:

mega.bootloader.path=atmega mega.bootloader.file=ATmegaBOOT_168_atmega1280.hex

Then look in hardware/bootloaders/atmega. You'll find the source file ATmegaBOOT_168.c and the make file Makefile.

In Makefile you will find:

mega: TARGET = atmega1280 mega: MCU_TARGET = atmega1280 mega: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=0' -DBAUD_RATE=57600 mega: AVR_FREQ = 16000000L mega: LDSECTION = --section-start=.text=0x1F000 mega: $(PROGRAM)_atmega1280.hex

mega_isp: mega mega_isp: TARGET = atmega1280 mega_isp: MCU_TARGET = atmega1280 mega_isp: HFUSE = DA mega_isp: LFUSE = FF mega_isp: EFUSE = F5 mega_isp: isp

Change AVR_FREQ and re-build.

NOTE: Only the values 16000000 and 8000000 are supported by the Arduino core. If you use any other values the timing functions (millis(), delay(), micros(), and delayMicroseconds()) will not be accurate... and different functions will be off by different amounts.

Have fun.

Thanks, found it after a bit of searching. I am yet to work out how to compile with the make file so if you have a simple way to do this and can let me know if would be much appreciated.

The comments on the crystal frequency are particularly useful although I only need to work at 8MHz for the moment so not a problem.


A quick work-around might be to create a new boards.txt entry to set the 8MHz clock rate and use half the upload baud rate. The bootloader is built for 57600 baud on a 16MHz clock. With an 8MHz clock it will run at half speed: 28800 baud.

[/quote] Mega (ATmega1280) at 8MHz

mega8M.upload.protocol=stk500 mega8M.upload.maximum_size=126976 mega8M.upload.speed=28800

mega8M.bootloader.low_fuses=0xFF mega8M.bootloader.high_fuses=0xDA mega8M.bootloader.extended_fuses=0xF5 mega8M.bootloader.path=atmega mega8M.bootloader.file=ATmegaBOOT_168_atmega1280.hex mega8M.bootloader.unlock_bits=0x3F mega8M.bootloader.lock_bits=0x0F [/quote]

Thanks John thats exactly the sort of quick fix I like to hear … much appreciated

Rob Aspey