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
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.
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.
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!
LikeLike
-P gpio
I probably should have mentioned that in the article.
LikeLike