Skip to content

Instantly share code, notes, and snippets.

@tjeastman
Last active February 15, 2016 05:35
Show Gist options
  • Save tjeastman/4c137c23a8bf74eb0166 to your computer and use it in GitHub Desktop.
Save tjeastman/4c137c23a8bf74eb0166 to your computer and use it in GitHub Desktop.
Flash an ATmega328P with the Arduino bootloader using a USBTinyISP AVR programmer

On a Debian-based system, install the avrdude and arduino-core packages and then run:

$ avrdude -p atmega328p -c usbtiny -U lock:w:0x3f:m -U lfuse:w:0xff:m -U hfuse:w:0xde:m -U efuse:w:0xfd:m
$ avrdude -p atmega328p -c usbtiny -U flash:w:/usr/share/arduino/hardware/arduino/bootloaders/optiboot/optiboot_atmega328.hex -U lock:w:0x0f:m

Fuse settings are from the file /usr/share/arduino/hardware/arduino/boards.txt for the Uno:

uno.name=Arduino Uno
uno.upload.protocol=arduino
uno.upload.maximum_size=32256
uno.upload.speed=115200
uno.bootloader.low_fuses=0xff
uno.bootloader.high_fuses=0xde
uno.bootloader.extended_fuses=0x05
uno.bootloader.path=optiboot
uno.bootloader.file=optiboot_atmega328.hex
uno.bootloader.unlock_bits=0x3F
uno.bootloader.lock_bits=0x0F
uno.build.mcu=atmega328p
uno.build.f_cpu=16000000L
uno.build.core=arduino
uno.build.variant=standard

Note that 0xfd is equivalent to 0x05 for the efuse setting since only the lowest 3 bits are used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment