IntroductionI 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 use
avrdudeto actually program devices.
Software installationDownload the patched version of avrdude from http://project-downloads.drogon.net/files/. I also keep a copy in the
RPi_RFM12B_ISPrespository, 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 example
sudo 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
UsageSelecting the GPIO programmer is simply a matter of including "
-P gpio -c gpio" options; the
-Poption specifies that the GPIO port is used (as opposed to USB, serial or parallel interfaces) whilst the
-coption 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
CustomisationThe packages above define a single programmer called
gpiowhich uses the
gpiointerface on GPIO pins 8 to 11. Since the RFM12B shield for Raspberry Pi implements two independent programmers I prefer to use
gpio1. You can add these by creating a
.avrdudercfile 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; ;