Updating firmware on the pocket AVR programmer

The pocket AVR programmer from Sparkfun is very useful tool for uploading bootloaders via ISP to any custom boards that use Atmega microcontrollers. However, the firmware on these programmers is often stuck at whatever version was the latest at the time of board production. In my case, I had a Pocket AVR programmer from February 10, 2010 (back from when they dated the boards). I found that the programmer was somewhat flaky in OS X Mavericks and would often fail during bootloader uploads with verification errors. While I could have easily purchased a new programmer with a later firmware, it felt wasteful, considering that the hardware had not changed all that much. All it needed was a firmware update. Fortunately, the folks at Sparkfun have provided a SPI header on board for updating the firmware.

Sparkfun’s version of the firmware is based on Dick Streefland’s work and the latest version can be found on his site. In the package, there is a subdirectory called usbtinyisp that contains a modified version of the spi application used by both Sparkfun and Adafruit’s AVR programmers.

In order to compile the latest firmware, we need an AVR compiler suite since the programmer uses the ATtiny2313. Fortunately, most Arduino distributions come with the necessary compiler tools. They are typically located in the Arduino install directory under /hardware/tools/avr/bin. You simply have to add this location to your path. I used the latest 1.5 version of Arduino since it contains a recent version of the AVR tool chain. Once the AVR compiler tools are in your path, change to the usbtinyisp subdirectory in the downloaded usbtiny package and type make. This should produce a main.hex file that can be flashed to the programmer.

To flash the new firmware, we need to solder a 2×3 male PTH header in the header holes marked Not ISP. The location of the holes are circled in green in the image below.


Once the header is soldered, we can use another programmer to flash the firmware. In my case, I used another AVR programmer with a programming cable that attached to the header pins as shown below.


If another AVR programmer is not available, an Arduino programmed as an ISP can also be used. The pinout for the header is shown in the schematic below and the corresponding connections to the Arduino are shown in the associated table. As a reference, Pin 1 is marked with a small underscore on the PCB silkscreen (right by the P in ISP).


Arduino as ISP ISP Header
5V Pin 2
GND Pin 6
D11 (MOSI) Pin 4
D12 (MISO) Pin 1
D13 (SCK) Pin 3
D10 Pin 5

Once all the connections are made, issue the following commands from the directory where the firmware was previously built (usbtinyisp).

avrdude -C/path/to/avrdude.conf -v -v -v -v -pt2313 -cusbtiny -b9600 -B250 -Uflash:w:main.hex

avrdude -C/path/to/avrdude.conf -v -v -v -v -pt2313 -cusbtiny -Uhfuse:w:0xDF:m -Ulfuse:w:0xEF:m

The commands above utilize another pocket programmer to flash the target device. With the Arduino as ISP approach, you need to change the parameter -cusbtiny to -carduino and add -P COMPORT, where COMPORT is the port to which the Arduino is connected. This value shows up under Tools->Port in the Arduino IDE when your Arduino is connected. In the commands above, I have lowered the baud rate to 9600 and the bitclock (ISP clock) to 250 μs. These are fairly conservative values and results in a slow upload, but they are reliable across multiple platforms.

Note: If you are using another AVR programmer to flash the device, then make sure the programmer is set to power the target; this is often a switch on the programmer.