Well I compiled it with this command
make atmega328 AVR_FREQ=20000000
in the optiboot (mercurial clone) directory
Output:
BAUD RATE CHECK: Desired: 115200, Real: 113636, UBRRL = 21, Error=1.3%
avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls -mmcu=atmega328p -DF_CPU=20000000 -DBAUD_RATE=115200 -DLED_START_FLASHES=3 -c -o optiboot.o optiboot.c
avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls -mmcu=atmega328p -DF_CPU=20000000 -DBAUD_RATE=115200 -DLED_START_FLASHES=3 -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe -Wl,--relax -Wl,--gc-sections -nostartfiles -nostdlib -o optiboot_atmega328.elf optiboot.o
avr-size optiboot_atmega328.elf
text data bss dec hex filename
482 0 0 482 1e2 optiboot_atmega328.elf
avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex optiboot_atmega328.elf optiboot_atmega328.hex
avr-objdump -h -S optiboot_atmega328.elf > optiboot_atmega328.lst
rm optiboot.o optiboot_atmega328.elf
Then burn it with:
make atmega328_isp
The bootloader flashes the 'L' led on reset so the burn worked but upload always fails.
also, boards.txt:
##############################################################
atmega328_20.name=atmega328p @ 20MHz
atmega328_20.upload.protocol=arduino
atmega328_20.upload.maximum_size=32256
atmega328_20.upload.speed=115200
atmega328_20.bootloader.low_fuses=0xff
atmega328_20.bootloader.high_fuses=0xde
atmega328_20.bootloader.extended_fuses=0x05
atmega328_20.bootloader.path=optiboot
atmega328_20.bootloader.file=optiboot_atmega328_20MHz.hex
atmega328_20.bootloader.unlock_bits=0x3F
atmega328_20.bootloader.lock_bits=0x0F
atmega328_20.build.mcu=atmega328p
atmega328_20.build.f_cpu=20000000L
atmega328_20.build.core=arduino
atmega328_20.build.variant=standard
##############################################################