Programming an ATmega168 using SparkFun's FTDI Basic Breakout. This guide works for other FT232R-based devices as well.
First, install the dependencies. On Ubuntu 10.04, this should take care of all of them:
sudo apt-get install patch build-essential libreadline-dev libncurses-dev libusb-dev libftdi-dev automake autoconf bison flex sudo apt-get build-dep avrdude avrdude-doc
Next, create a working directory for the build and cd into it:
mkdir avrdude cd avrdude
Now download the D2xx driver from FTDI. Only download the one that corresponds to your OS (either 64 bit or 32 bit).
# For 64-bit: wget http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx0.4.16_x86_64.tar.gz # For 32-bit: wget http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx0.4.16.tar.gz
Download AVRDUDE and the FTDI bitbang patches:
wget http://download.savannah.gnu.org/releases-noredirect/avrdude/avrdude-5.10.tar.gz 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
Extract everything, put the drivers into place, and apply the patches:
tar xzf avrdude-5.10.tar.gz tar xzf libftd2xx*.tar.gz cd avrdude-5.10 for file in ../patch-*.diff; do patch -p0 < $file; done cp ../libftd2xx*/static_lib/* . cp ../libftd2xx*/*.h . cp ../libftd2xx*/*.cfg .
Configure and compile AVRDUDE.
./configure CFLAGS="-g -O2 -DSUPPORT_FT245R" LIBS="./libftd2xx.a.0.4.16 -lpthread -ldl -lrt" make
If you're using SparkFun's FTDI Basic Breakout board, you can use the following to update your AVRDUDE configuration. If you're using some other FTDI breakout board, you'll need to modify the miso, sck, mosi, and reset options. FTDI has a listing of which bits correspond to which pins on page 1 of the bit-bang mode datasheet.
echo ' programmer id = "ftdi"; desc = "SparkFun FTDI Basic Breakout"; type = "ft245r"; miso = 1; # RXD sck = 3; # CTS mosi = 0; # TXD reset = 4; # DTR ;' >> avrdude.conf;
If you're using SparkFun's FTDI Basic Breakout, you can make your connections as follows. Otherwise, make your connections according to the pins you chose in the previous step (more details in my previous post on the subject.
FTDI -> MCU (ATmega168 PDIP pin) -------------------------------- DTR -> RESET (1) RXI -> MISO (18) TXO -> MOSI (17) 5V -> VCC (7 & 20) CTS -> SCK (19) GND -> GND (8 & 22)
Now try it out to make sure everything worked. On Ubuntu, sudo is required because of the default permissions applied to USB devices. The
-B 1 option sets the programming speed to the lowest possible. You can omit that option if your AVR is clocked higher than 8MHz. If this runs successfully, your AVR's high fuse byte should be printed to the terminal in hexadecimal.
sudo ./avrdude -C avrdude.conf -c ftdi -p m168 -P ft0 -U hfuse:r:-:h -B 1
If everything worked well, you can now install AVRDUDE.
# If you're using Ubuntu, you can use checkinstall to build a .deb package and install it: sudo checkinstall # Otherwise, just use `make install`: sudo make install
You should now be able to use AVRDUDE without specifying a configuration file:
sudo avrdude -c ftdi -p m168 -P ft0 -U hfuse:r:-:h -B 1