Skip to content

Instantly share code, notes, and snippets.

@nedos
Created June 23, 2011 14:05
Show Gist options
  • Save nedos/1042593 to your computer and use it in GitHub Desktop.
Save nedos/1042593 to your computer and use it in GitHub Desktop.
Flash a 'virgin' ATMEGA328PU with the Arduino Bootloader. On MacOS simply brew install avrdude --with-usb
#!/bin/sh
OPTS="-p m328p -c avrisp2 -P usb"
PWD="$(pwd)"
# Unlock the chip
avrdude $OPTS -U lock:w:0x3f:m
# Set the Fuses
avrdude $OPTS -e -U lfuse:w:0xff:m -U hfuse:w:0xda:m -U efuse:w:0x05:m
cd ~/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/bootloaders/atmega
pwd
# Write the Bootloader
avrdude $OPTS -e -U flash:w:ATmegaBOOT_168_atmega328.hex:i
# Lock the chip
avrdude $OPTS -e -U lock:w:0x0f:m
cd $PWD
pwd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment