Introduction
I previously showed an implementation of a AVR ISP programmer using the Raspberry Pi GPIO port which can be used to program Atmel's AVR range of microcontrollers with avrdude. An ISP programmer based on this design was incorporated into a shield to interface to the RFM12B radio module. This post explains how to useavrdude
to actually program devices.Software installation
Download the patched version of avrdude from http://project-downloads.drogon.net/files/. I also keep a copy in theRPi_RFM12B_ISP
respository, https://github.com/stevemarple/RPi_RFM12B_ISP/tree/master/software/avrdude. You will probably want the armhf (hardware floating-point) version. Download the documentation package for avrdude too. Install the packages using "dpkg -i". For examplesudo dpkg -i avrdude_5.10-4_armhf.deb sudo dpkg -i avrdude-doc_5.10-4_all.deb
Using avrdude over the GPIO interface is problematic for users other than root. The easiest solution is to give the avrdude binary setgroup permission:
sudo chmod g+s /usr/bin/avrdude
Usage
Selecting the GPIO programmer is simply a matter of including "-P gpio -c gpio
" options; the -P
option specifies that the GPIO port is used (as opposed to USB, serial or parallel interfaces) whilst the -c
option selects the correct programmer type on that port.For example, to check the signature on an ATmega328P execute the command
avrdude -P gpio -c gpio -p atmega328p
To read the fuses execute the command
avrdude -P gpio -c gpio -p atmega328 -U lfuse:r:-:h -U hfuse:r:-:h -U efuse:r:-:h
Customisation
The packages above define a single programmer calledgpio
which uses the gpio
interface on GPIO pins 8 to 11. Since the RFM12B shield for Raspberry Pi implements two independent programmers I prefer to use gpio0
and gpio1
. You can add these by creating a .avrduderc
file in your home directory. The file should contain:programmer id = "gpio0"; desc = "Use sysfs interface to bitbang GPIO lines"; type = gpio; reset = 8; sck = 11; mosi = 10; miso = 9; ; programmer id = "gpio1"; desc = "Use sysfs interface to bitbang GPIO lines"; type = gpio; reset = 7; sck = 11; mosi = 10; miso = 9; ;