Arduino as an AVR ISP

Here’s some short notes for using an Arduino as programmer for SPI-based AVRs. Basically, the programmer example is uploaded to the Arduino and then using avrdude to upload a .hex file of your choice. My use was triggered by not having the DFU bootloader intact for an ATmega32u4-based project and having lost access to the regular ISP programmer.

The ClockController

There are plenty of resources to be found just by using your favorite search engine, so I’ll add another that tailors to my specific case. A sort of memory dump, if you will.

Prerequisites

Making this work in this configuration will require the following hardware:

  • An Arduino or compatible (I did it with an Arduino Uno)
  • An AVR target that accepts firmware download via SPI.
  • 5 wires to connect the programmer to the target, another one if you want to power the target as well

Software-wise, you’ll need:

  • Arduino IDE - Mostly for the examples and uploading
  • AVRDUDE - A command-line programmer utility for AVR microcontrollers

Just for reference, I’m using Windows 10 for this. Other platforms are probably similar, but with slightly different steps.

AVRDUDE

Download the latest version of AVRDUDE if you haven’t already got it, making sure it’s the correct one for your platform. At the time of writing, the windows-version is named avrdude-6.3-mingw32.zip.

Make sure you either know the exact path to the avrdude.exebinary or have it available on path, as you will need to call it when doing programming.

Electrical connections

The following listing is based on the instructions found in the ArduinoISP - How to wire your boards for the Arduino Uno, other variants may need different connections. Also, make sure that the I/O voltages match between the programmer and target.

Programmer pin (Arduino Uno) Target pin Comment
10 RESET  
11 MOSI  
12 MISO  
13 SCK  
GND GND  
5V 5V Optional, connect if you want to power your target.

Programmer setup

The programmer code that needs to be on the Arduino is available among the examples that come with the Arduino IDE. Arduino IDE - ISP example

Compile and upload to the Arduino.

Target programming

Finally, you just need to issue the appropriate AVRDUDE command-line to flash your code to the target. Look up the AVRDUDE documentation and/or help for further instructions, but it’s more or less on the format given below:

avrdude.exe -c avrisp -p <AVR MCU id> -P <serial port> -b 19200 -U flash:w:<your hex file>

which for my specific case becomes

avrdude.exe -c avrisp -p m32u4 -P COM3 -b 19200 -U flash:w:ClockController_LUFAex.hex

That’s it. Not particularly fast or elegant, but it did save me buying a programmer.