How to burn Optiboot for 28 pin 328p with ext 8MHz crystal

Hi,

I downloaded recent optiboot package from GitHub - Optiboot/optiboot: Small and Fast Bootloader for Arduino and other Atmel AVR chips, then I extracted the package into ~/Arduino/hardware and renamed boards-1.6.txt to boards.txt (Boards.txt file for Optiboot platforms, in format for Arduino 1.5.x and later.). I used IDE version 1.6.0.
I want to burn Optiboot bootloader for my atmega 328p in 28pin package.
Using the boards-1.6.txt which came with the optiboot package results in having boards:

optiboot28.name=Optiboot on 28-pin cpus
optiboot32.name=Optiboot on 32-pin cpus
optiboot1280.name=Optiboot on Mega1280
optiboot1284.name=Optiboot on (generic) Mega1284
optibootm32.name=Optiboot on Mega32
optiboott84.name=Optiboot on Tiny84

So I would assume if I have DIP28 atmega 328p and I want to run it using external 8MHz oscillator, then I have to chose "Optiboot on 28-pin cpus"
But then when I open "CPU speed" menu, there is 16MHz, 8MHz (INT) and 1MHz (INT). So I do not know what to chose or how to properly burn optiboot bootloader when I want to use 8MHz external crystal.

Any ideas or hints?

Try adding these three lines:

optiboot28.menu.mhz.16MHz=16MHz
optiboot28.menu.mhz.16MHz.upload.speed=115200
optiboot28.menu.mhz.8MHzC=8MHz (crystal)
optiboot28.menu.mhz.8MHzC.build.f_cpu=8000000L
optiboot28.menu.mhz.8MHzC.upload.speed=57600
optiboot28.menu.mhz.8MHz=8MHz (int)
optiboot28.menu.mhz.8MHz.build.f_cpu=8000000L
optiboot28.menu.mhz.8MHz.bootloader.low_fuses=0xE2
optiboot28.menu.mhz.8MHz.upload.speed=57600

Thanks! That worked fine.
In the meantime I found some useful information also in some other threads and found out the bootloader and also the fuse settings are the same either for 16MHz or 8MHz crystal, but the important thing are the parameters johnwasser posted here.

optiboot28.menu.mhz.8MHzC.build.f_cpu=8000000L --> will pass the actual frequency atmega will run on to IDE and it can compile the code properly

optiboot28.menu.mhz.8MHzC.upload.speed=57600 --> here I am not sure, but most likely the speed of sketch upload needs to be lower when use 8MHz crystal.

However I had problems burning the bootloader when I put the "optiboot" package into ~/Arduino/hardware. There was this error when tried to burn it:

Error while burning bootloader.
java.lang.NullPointerException
at cc.arduino.packages.uploaders.SerialUploader.burnBootloader(Unknown Source)
at processing.app.Editor$47.run(Editor.java:2563)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:312)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:738)
at java.awt.EventQueue.access$300(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:699)
at java.awt.EventQueue$3.run(EventQueue.java:697)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:708)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

Then I tried to append the content of the ~/Arduino/hardware/optiboot/optiboot/boards.txt to the directory where my IDE is stored: /opt/arduino-1.6.0/hardware/arduino/avr/boards.txt and also copied (overwritten) /opt/arduino-1.6.0/hardware/arduino/avr/bootloaders/optiboot with the one included in downloaded optiboot package. Also I removed ~/Arduino/hardware/optiboot. After this I successfully burned the optiboot bootloader with "8MHz (crystal)" parameters.

Although I successfully loaded the bootloader using the "append and replace" method above, I would like to know why the standard way with ~/Arduino/hardware/optiboot did not work. Any ideas?

fanofard:
optiboot28.menu.mhz.8MHzC.upload.speed=57600 --> here I am not sure, but most likely the speed of sketch upload needs to be lower when use 8MHz crystal.

Because the bootloader is shipped as a pre-compiled .hex file it can't take advantage of the F_CPU value to calculate the baud rate. It is compiled to do 115200 baud on a 16 MHz clock so on an 8 MHz clock you will get half the rate: 57600 baud.

fanofard:
Although I successfully loaded the bootloader using the "append and replace" method above, I would like to know why the standard way with ~/Arduino/hardware/optiboot did not work. Any ideas?

I noticed that when I switched from 1.0.x to 1.6.x I had to move all of the third-party boards.txt files down a level. Try: ~/Arduino/hardware/local/optiboot