Of Bootloaders and Nanos



Restoring a Nano to a default Nano


To use a Nano with default bootloader:
Select "Arduino Nano" in the Arduino IDE and click "Burn Bootloader" under Tools (I'm using the USBtiny ISP).

Alternatively use avrdude:
Write ATmegaBOOT_168_atmega328.hex (found in Arduino/hardware/arduino/avr/bootloaders/atmega) with an ISP, i.e.

avrdude -p m328p -c usbtiny -e -U flash:w:ATmegaBOOT_168_atmega328.hex

Optiboot bootloader with a Nano

To use the Optiboot which comes with the Arduino IDE (version 1.6.5)

Add this to the boards.txt file in Arduino/hardware/arduino/avr

##############################################################

atmega328o.name=[Optiboot] Arduino Duemilanove or Nano w/ ATmega328
atmega328o.upload.tool=avrdude
atmega328o.upload.protocol=arduino
atmega328o.upload.maximum_size=32256
atmega328o.upload.speed=115200
atmega328o.bootloader.tool=avrdude
atmega328o.bootloader.low_fuses=0xff
atmega328o.bootloader.high_fuses=0xde
atmega328o.bootloader.extended_fuses=0x05
atmega328o.bootloader.path=optiboot
atmega328o.bootloader.file=optiboot/optiboot_atmega328.hex
atmega328o.bootloader.unlock_bits=0x3F
atmega328o.bootloader.lock_bits=0x0F
atmega328o.build.mcu=atmega328p
atmega328o.build.f_cpu=16000000L
atmega328o.build.core=arduino:arduino
atmega328o.build.variant=arduino:standard

##############################################################


Now select "[Optiboot] Arduino Duemilanove or Nano w/ ATmega328" from the Board selection menu and click "Burn Bootloader" under Tools.

Alternatively use avrdude:
Write optiboot_atmega328.hex (found in Arduino/hardware/arduino/avr/bootloaders/optiboot) with an ISP, i.e.

avrdude -p m328p -c usbtiny -e -U flash:optiboot_atmega328.hex

Using the latest OptiBoot version
Download the latest Optiboot HEX file from here.  Name it "optiboot_atmega328_latest.hex" and place it within the Arduino/hardware/arduino/avr/bootloaders/optiboot directory.  Add the following to the boards.txt file:

##############################################################
atmega328opti.name=[Latest Optiboot] Arduino Duemilanove or Nano w/ ATmega328
atmega328opti.upload.protocol=arduino
atmega328opti.upload.maximum_size=32256
atmega328opti.upload.speed=115200
atmega328opti.upload.tool=avrdude
atmega328opti.bootloader.tool=avrdude
atmega328opti.bootloader.low_fuses=0xff
atmega328opti.bootloader.high_fuses=0xde
atmega328opti.bootloader.extended_fuses=0x05
atmega328opti.bootloader.path=optiboot
atmega328opti.bootloader.file=optiboot/optiboot_atmega328_latest.hex
atmega328opti.bootloader.unlock_bits=0x3F
atmega328opti.bootloader.lock_bits=0x0F
atmega328opti.build.mcu=atmega328p
atmega328opti.build.f_cpu=16000000L
atmega328opti.build.core=arduino:arduino
atmega328opti.build.variant=arduino:standard
##############################################################

Now select "[Latest Optiboot] Arduino Duemilanove or Nano w/ ATmega328" from the Arduino IDE (you will need to restart the program to register the board in the IDE).  Burn the boot loader within the software and upload your sketch as normal.

Alternatively use avrdude:
Write optiboot_atmega328_latest.hex with an ISP, i.e.

avrdude -p m328p -c usbtiny -e -U flash:w:optiboot_atmega328_latest.hex

Useful references:
https://bigdanzblog.wordpress.com/2014/10/23/installing-the-optiboot-loader-on-an-arudino-nano-to-fix-the-watch-dog-timer-wdt-issue/

Comments

Popular posts from this blog

Getting started with the Pro Micro Arduino Board

Arduino and Raspberry Pi serial communciation