Summary

I document here my experience with using the ABRISP mkII programmer on my Mac OS X Intel computer.

Tools

You will need the following tools:

Installation

Warning: These notes were taken from my own experience. They might not apply to you.

Install binutils, gcc, avr-libc and uisp using Fink

fink install binutils gcc avr-libc uisp

Should do the job.

Install libusb and avrdude

At first I tried a precompiled package of all of these tools known as AvrMacPack. You will also find OSX-AVR which is an alternative. But none of these packages did it for me.

First problem: USB device not found

First time I ran avrdude I had the following issue:

avrdude -c avrisp2 -p t13 -v -P usb
avrdude: Version 5.5, compiled on Mar 18 2008 at 20:25:02
        Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

        System wide configuration file is "/usr/local/AVRMacPack-20080318/etc/avrdude.conf"
        User configuration file is "/Users/tats/.avrduderc"
        User configuration file does not exist or is not a regular file, skipping

        Using Port            : usb:xxx
        Using Programmer      : avrisp2
avrdude: usbdev_open(): did not find any (matching) USB device "usb"

The trick was to unplug and replug the USB cable, it then detected the programmer:

avrdude: Version 5.5, compiled on Mar 18 2008 at 20:25:02
...
        Using Port            : usb
        Using Programmer      : avrisp2
avrdude: usbdev_open(): Found AVRISP mkII, serno: 0000B0018274

Second problem: Nothing happening

But then it jammed, nothing was happening. Following this article which outlined a similar project, I needed to patch a file in avrdude and thus needed to compile it. Here is the patch that needs to be applied on the stk500v2.c file in the avrdude 5.5 repository:

--- stk500v2.c.orig     2008-04-04 23:41:31.000000000 -0400
+++ stk500v2.c  2008-04-04 23:41:33.000000000 -0400
@@ -480,7 +480,7 @@
 
   DEBUG("STK500V2: stk500v2_getsync()\n");
 
-  if (pgmtype == PGMTYPE_JTAGICE_MKII)
+  if (pgmtype == PGMTYPE_JTAGICE_MKII || pgmtype == PGMTYPE_AVRISP_MKII)
     return 0;
 
 retry:

I followed these instructions on how to compile libusb and avrdude (with usb support).

Third problem: Too slow

When trying to upload a program to the chip, the transfer would start but it would be way too long (I couldn't wait to see the end in fact).

I found the fix in this post on avrdude-dev. The reason was that

  1. The firmware was not up to date
  2. The ISP frequency (clock) was too small

Upgrade the firmware

The easiest way to do this that we found was to upgrade it under Windows. Just plug your AVRISP2 to a PC running Windows and it should upgrade the firmware to the latest available.

Increase the ISP frequency

You can use avrdude to set the ISP period using the interactive interface. You need to use the sck command to set the period. Of course, increasing the frequency means that you need to decrease the period. A value of 10 us usually works.

Example

# avrdude -c avrisp2    -p t13 -P usb -tuF

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0xffffff
avrdude> sck 10
>>> sck 10 
avrdude> parms
>>> parms 
Vtarget         : 5.1 V
SCK period      : 10.37 us
avrdude> quit
>>> quit 

avrdude done.  Thank you.

WARNING: If you set the ISP frequency to more than 1/4 the CPU frequency, it will fail. In that case just set it to a lower value.

Troubleshooting

"avrdude: initialization failed, rc=-1" type error

Always happens to me. The problem shows as:

avrdude: stk500v2_command(): command failed
avrdude: initialization failed, rc=-1
          Double check connections and try again, or use -F to override
          this check.

It usually has one of two sources:

  1. The ISP frequency is wrong (see up)
  2. The pin used by the ISP programmer (usually the first pin) is connected to something (like a LED or something)

That's it for now!

Other resources

Electronix/AvrIsp2OnOSX (last edited 2009-11-05 19:46:25 by localhost)