Arduino mega 2560 changing quartz oscillator to 20MHz

Hi. If I want to overclock Arduino mega to 20MHz do I need to change anything else than boards.txt file to adjust "build.f_cpu" ?

Yes, the bootloader. Consider that ATmega2560 has the highest F_CPU 16MHz according the datasheet. Even it can run on 20MHz some functions can have a problem with overclocking. Maybe Krupski is an expert for 2560 overclocking.

Is there any tutorial about building custom bootloaders (I assume it's .hex file) ? I google it and cant find any interesting about building new ones. Everything is about uploading.

I don't about writing one, but MCUdude has this MegaCore add-in to the IDE that supports 2560 at 20 MHz: https://github.com/MCUdude/MegaCore

Thanks for replay. I also found some tutorials how to build bootloaders. It's not so complicated as i though it would be. I'll let you know if I succeeded.

If I want to overclock Arduino mega to 20MHz do I need to change anything else than boards.txt file to adjust "build.f_cpu" ?

You'll need a 20mhz crystal and some means of burning the new bootloader (USBASP, Dragon, JTAGICE3, etc)

somsom: If I want to overclock Arduino mega to 20MHz

Why? Why not just go for something significantly faster, like Due, esp8266, stm32, Teensy 3.x...

I upload my bootloader to arduino by avrdude with no errors. But when I'm uploading blink example over usb cable i have timeouts. Only Tx led blinks from time to time. I need to recalculate baudrate or something ?

My arduino/hardware/arduino/bootloaders/stk500v2/Makefile entry:

mega2560_20MHz: MCU = atmega2560 mega2560_20MHz: F_CPU = 20000000 mega2560_20MHz: BOOTLOADER_ADDRESS = 3E000 mega2560_20MHz: CFLAGS += -D_MEGA_BOARD_ mega2560_20MHz: begin gccversion sizebefore build sizeafter end mv $(TARGET).hex stk500boot_v2_mega2560_20MHz.hex

My arduino/hardware/arduino/boards.txt entry:

mega2560_20MHz.name=OC - Arduino Mega 2560 @ 20MHz

mega2560_20MHz.upload.protocol=wiring mega2560_20MHz.upload.maximum_size=258048 mega2560_20MHz.upload.speed=115200

mega2560_20MHz.bootloader.low_fuses=0xFF mega2560_20MHz.bootloader.high_fuses=0xD8 mega2560_20MHz.bootloader.extended_fuses=0xFD mega2560_20MHz.bootloader.path=stk500v2 mega2560_20MHz.bootloader.file=stk500boot_v2_mega2560_20MHz.hex mega2560_20MHz.bootloader.unlock_bits=0x3F mega2560_20MHz.bootloader.lock_bits=0x0F

mega2560_20MHz.build.mcu=atmega2560 mega2560_20MHz.build.f_cpu=20000000L mega2560_20MHz.build.core=arduino mega2560_20MHz.build.variant=mega

No, the baudrate is fixed, defined during bootloader build process. Described problem could be caused by HW issue, like bad clock oscillator or its settings, if the bootloader is uploaded correctly. Make sure the bootloader is present. Try to read out the memory from chip and compare with the HEX. Same with the fuses.

DID you change the hardware? You can't overclock an avr just by changing the build options.