AVRDUDE 5.8 with FTDI bitbang patch on Linux

2009 December 20
by David

Description: This is an adaptation of the work by Kimio Kosaka, Nate Phillips, and Massimo. It allows you to use AVRDUDE with an FTDI chip (like the one on the Arduino boards or SparkFun’s FTDI Basic Breakout). This can be useful if you manage to brick your Arduino and you have no programmer.

—————————

If you’re on Ubuntu or Debian, install the prerequisites with:

sudo apt-get install patch build-essential libreadline-dev libncurses-dev libusb-dev
sudo apt-get build-dep avrdude avrdude-doc

Start by grabbing a copy of AVRDUDE 5.8, untarring it in the directory, and switching to that directory:

wget http://download.savannah.gnu.org/releases-noredirect/avrdude/avrdude-5.8.tar.gz
tar xzf avrdude-5.8.tar.gz
cd avrdude-5.8

Now get a copy of the FTDI bitbang patch files:

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

Apply the patches:

for file in patch-*.diff; do patch -p0 < $file; done

Also get a copy of the FTDI driver. For 32-bit:

wget http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx0.4.16.tar.gz

For 64-bit:

wget http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx0.4.16_x86_64.tar.gz

Extract the FTDI driver and copy over the needed files:

tar xzf libftd2xx*.tar.gz
cp libftd2xx*/static_lib/* .
cp libftd2xx*/*.h .
cp libftd2xx*/*.cfg .

Generate your makefile:

./configure

Open Makefile in a text editor and perform the following operations:

  1. Find the line CFLAGS = -g -O2 and replace it with CFLAGS = -g -O2 -DHAVE_LIBUSB -DSUPPORT_FT245R.
  2. Find the line LIBS = -lreadline -lncurses -ltermcap and replace it with LIBS = -lreadline -lncurses -ltermcap ./libftd2xx.a.0.4.16 -lrt.

Now to actually compile it:

make

From here, you can follow the instructions at http://www.geocities.jp/arduino_diecimila/bootloader/index_old_en.html starting at step 5. Note that you’ll need to modify the commands a little bit. Instead of:

avrdude -c diecimila -P ft0 -p m168

you should write:

sudo ./avrdude -C avrdude.conf -c duemilanove -P ft0 -p m168

(Note: you can still use it on a Diecimila, just specify the programmer as `-c duemilanove` and it should work.)

If you’d like to use SparkFun’s FTDI Basic Breakout as a programmer, try these instructions.

7 Responses leave one →
  1. 2009 December 20

    This is great, David!

    I’ll have to give it a go when I get some free time after the holidays. Thanks for the update!

  2. 2009 December 21
    Tomek permalink

    Hi there. since a couple of days im trying to run stk500v2 with avrdude under ubuntu. its a disaster! could you tell me where can i find some instructions to follow that could help me?
    ive instaled nearly milion packages ;) with drivers software etc.

    after:

    $ avrdude -p 2313 -P /dev/ttyUSB3 -c stk500v2 -Uflash:w:a.hex

    goes:

    avrdude: stk500v2_command(): command failed
    avrdude: stk500v2_command(): unknown status 0xc9
    avrdude: stk500v2_program_enable(): cannot get connection status
    avrdude: initialization failed, rc=-1
    Double check connections and try again, or use -F to override
    this check.

    any idea whats wrong? cheers

    ps. dont want to come back to s@#% vista :(

  3. 2009 December 21
    Tomek permalink

    sorry but forgot to write:

    after sudo ./avrdude -C avrdude.conf -c duemilanove -P ft0 -p m168

    there comes the same thing

  4. 2009 December 21

    Hi Tomek,

    These directions are actually for the FT232R chip from FTDI. It’s not related to STK500v2.

    Anyway, it looks like the AVR isn’t responding to your programmer. What device are you trying to program? To AVRDUDE, `2313` means AT90S2313. Did you mean to program the ATtiny2313? If so, you should pass `t3213` to AVRDUDE instead.

    Failing that, the people at AVR Freaks might be able to help you if you ask nicely and include the “-vvv” (short for very, very verbose) flag in your AVRDUDE command.

    David

  5. 2009 December 22
    Tomek permalink

    thank you very much for respond. im pretty messed up all of that ;) stk500v2 uses FT232R am i wrong? ive installed any driver, anyone claimed that is necessary but i still think, the problem is lack of right communication between the computer and ft232r. thanks for answer, ill try to search avr freaks - its impossible im the first one who has such a problem ;)

    cheers

  6. 2010 February 26
    Mic permalink

    Great stuff, patched into avrdude 5.10 - works fine!
    I burned arduino 2009 with ATmega168.

Trackbacks & Pingbacks

  1. SparkFun’s FTDI Basic Breakout as an AVR programmer | Doswa

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS