Burn bootloader for Arduino Duemilanove w/ Atmega328 using avrdude 5.10
This is using a new Arduino Duemilanove board with a regular Atmega328p, with no bootloader. I wanted to do the BitBang mode, since I didn't want to get or make anything else, and the ArduinoISP, I didn't have access to another Arduino. So I pieced together 3 different guides, I finally got it working.
This assumes you have a Duemilanove with Atmega328p. Running Ubuntu 9.10, though really any distro will work, though how you get the dependencies will vary. Also, you have the Arduino IDE installed to /usr/share/arduino, which if you install using the deb source method, it will be.
First, setup the Arduino as shown here. I used the first wiring guide, but either should work.
Next, setup avrdude on Ubuntu. I followed this guide, but used avrdude 5.10, instead of 5.8. The commands remain the same, except instead of downloading 5.8, you download 5.10.
Here's what I ran:
wget http://download.savannah.gnu.org/releases-noredirect/avrdude/avrdude-5.10.tar.gz tar xfvz avrdude-5.10.tar.gz cd avrdude-5.10/ for i in 8 7 6 5 4 3 2 1 0; do wget -O patch-$i.diff http://savannah.nongnu.org/patch/download.php?file_id=1851$i; done for file in patch-*.diff; do patch -p0 < $file; done wget http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx0.4.16.tar.gz tar xzf libftd2xx*.tar.gz cp libftd2xx*/static_lib/* . cp libftd2xx*/*.h . cp libftd2xx*/*.cfg . ./configure cp /usr/share/arduino/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex . |
Then you edit the file, Makefile:
CFLAGS = -g -O2 -> CFLAGS = -g -O2 -DHAVE_LIBUSB -DSUPPORT_FT245R
LIBS = -lreadline -lncurses -ltermcap -> LIBS = -lreadline -lncurses -ltermcap ./libftd2xx.a.0.4.16 -lrt
Then just run make.
Third, run:
sudo ./avrdude -C avrdude.conf -c duemilanove -P ft0 -p m328p -t -B 4800 |
And in that:
erase w efuse 0 0x05 w hfuse 0 0xda w lfuse 0 0xff q |
This sets up the efuse, hfuse, and ifuse values. This has to be run at a lower baud rate.
Fourth, run:
sudo ./avrdude -C avrdude.conf -c duemilanove -P ft0 -p m328p -U flash:w:ATmegaBOOT_168_atmega328.hex |
The bootloader has been flashed. Lock it by running:
sudo ./avrdude -C avrdude.conf -c duemilanove -P ft0 -p m328p -t |
And enter:
w lock 0 0x0f q |
Now, your Atmega328 should be ready to use. You can try it by uploading the example Blink from the IDE.