Programming an AVR chip with a Raspberry Pi

For a while now I’ve been programming AVR chips with the GPIOs on my Raspberry Pi. It’s very useful to me and I thought I’d documet it here as I will probably mention it in future blog posts too.

Wiring it up

RPi AVR programmer_bb

It’s not as complicated as it looks. Connect the RPi to the chip as in the following table. The pin numbers for the AVR chips refer to the PDIP package (the kind that goes in breadboard).

Raspberry Pi Pin (P1 Header) AVR Pin Name ATtiny25/V, ATtiny45/V, ATtiny85/V ATmega48, ATmega88, ATmega168, ATmega328 ATtiny2313, ATtiny4313
MOSI (19) MOSI 5 17 17
MISO (21) MISO 6 18 18
SCLK (23) SCLK 7 19 19
CE0 (24) RESET 1 1 1
Ground (6) Ground 4 8 & 22 10
3.3V (1) Vcc 8 7 & 20 20

Power the AVR chip up with a 3.3V supply, using 5V will probably damage your Raspberry Pi. You can use the 3.3V pin from the Raspberry Pi as shown in the table above but you will have to make sure you don’t exceed the 50mA current limit. If all that is connected is the chip you want to program, that is fine. If you have anything else running off the Pi’s 3.3V pin you may want to use a separate power supply instead.

RPi AVR programmer_schem

Installing the software

You will need to install a custom version of avrdude available at http://project-downloads.drogon.net/files/ . Install it with the commands

sudo dpkg -i avrdude_5.10-4_armhf.deb
sudo dpkg -i avrdude-doc_5.10-4_all.deb

There it is done. Use the programmer name gpio (-c switch to avrdude) in your projects.

2 thoughts on “Programming an AVR chip with a Raspberry Pi

  1. Benjamin Brinkman

    What did you use for the -P option in avrdude? I keep getting the following error:

    avrdude: AVR device not responding
    avrdude: initialization failed, rc=-1
    Double check connections and try again, or use -F to override
    this check.

    and I think it’s because I need to explicitly specify a port. Very helpful article, otherwise!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>