To program an AVR from the Pi you'll need to have 4 GPIO pins free on the Raspberry Pi.  These pins will connect to the AVR's ISP/ICSP MOSI, MISO, SCK, and RESET pins.  In addition you'll connect the Pi's 5 volt power and ground to the AVR to power it during programming.

If you're using an Arduino Uno you can access all the required pins from the small ICSP header on the far end of the board.

As an example using an Arduino Uno here's one possible way to connect it to a Raspberry Pi:

  • Arduino ICSP VCC to Raspberry Pi 3.3 volt pin. (You can also try 5V, which is riskier because there's 5V logic coming out of the Arduino to the Pi but its not a 'strong' 5V signal, so if you do just put a 1K resistor in series with the MISO output between AVR and Pi or you could use a level shifter)
  • Arduino ICSP GND to Raspberry Pi ground pin.
  • Arduino ICSP RESET to Raspberry Pi GPIO #12.
  • Arduino ICSP SCK to Raspberry Pi GPIO #24.
  • Arduino ICSP MOSI to Raspberry Pi GPIO #23.
  • Arduino ICSP MISO to Raspberry Pi GPIO #18.
Because the AVR Chip (which can operate as low as 1.8v) is only being powered by 3.3v from the Raspberry Pi, it will operate on 3.3v logic.


You'll need to create a custom avrdude configuration file to tell avrdude what GPIO pins to use for programming the AVR.  It's easiest to copy the default avrdude.conf file and make the necessary changes to it.

The avrdude.conf file will be in one of two spots depending on how you installed avrdude in the previous section.  If you did the easy install method to install through a package then avrdude.conf is in the /etc/avrdude.conf location.  However if you did the manual install method to compile the code and install it then avrdude.conf is in the /usr/local/etc/avrdude.conf location.

Copy the avrdude.conf configuration to a new file called avrdude_gpio.conf in your home directory, and then edit it with the nano text editor by running the commands below.  If you used the easy install method to install an avrdude package these commands are:

cp /etc/avrdude.conf ~/avrdude_gpio.conf
nano ~/avrdude_gpio.conf

However if you used the manual install method to compile the code then instead run these commands:

cp /usr/local/etc/avrdude.conf ~/avrdude_gpio.conf
nano ~/avrdude_gpio.conf

Once in the editor scroll all the way down to the very end of the file.  You'll need to add a new section that configures the GPIO pin programming.  Paste in the following section at the end of the file:

# Linux GPIO configuration for avrdude.
# Change the lines below to the GPIO pins connected to the AVR.
  id    = "pi_1";
  desc  = "Use the Linux sysfs interface to bitbang GPIO lines";
  type  = "linuxgpio";
  reset = 12;
  sck   = 24;
  mosi  = 23;
  miso  = 18;

This configuration will create a programmer with name 'pi_1' and assign the ICSP pins to the provided GPIO pin values.  If you've hooked up the ICSP pins to different GPIO pins make sure to modify the configuration to match your setup.

Also note that you can create mulitple programmer sections if you're programming multiple AVR chips from the same Raspberry Pi.  Each programmer section needs to have a unique name assigned with the id = "name" line.  In addition each AVR needs a distinct set of 4 GPIO pins configured for its ICSP pins.

Once you've modified the configuration file save it and quit nano by pressing Ctrl-O, enter, and then Ctrl-X.

Continue on to learn how to use avrdude with the custom GPIO programming configuration.

This guide was first published on Jun 01, 2015. It was last updated on Mar 08, 2024.

This page (Configuration) was last updated on Mar 08, 2024.

Text editor powered by tinymce.