Overview

AVR programmer & SPI interface

Introduction

This is documentation for a simple open-source USB AVR programmer and SPI interface. It is low cost, easy to make, works great with avrdude, is AVRStudio-compatible and tested under Windows, Linux and MacOS X. Perfect for students and beginners, or as a backup programmer.

The project is based off of the USBtiny code & design. The main improvements are: adjusting the code to allow it to act as a SpokePOV interface, adding lowlevel bitbang commands, and addition of a "USB good" LED. Other changes are new VID/PID (to make it official), removing some of the commands, and moving around the pins a bit.

You can build this design using the schematic and firmware, or buy a kit from the Adafruit webshop. Having a full kit available solves the "chicken & egg" problem of purchasing or building a USB programmer that then needs a programmer of some sort to 'kick start'. (See USBasp, AVRdoper, USBprog)

All the firmware code is distributed under the GPL, the hardware design layout files are CC 2.5 Attrib./Share-alike.

What's so great about it?

Easy to make

  • Ultra low cost: programmer is $16 in parts, less than half the price of the AVRISP v2 ! (Kits are $22 and available from the adafruit shop.)
  • Kit comes with both 6-pin and 10-pin AVR-standard connectors and cables. Almost no programmers that are not from Atmel have both! (Including the AVRISP v2)
  • Easy to build: All through-hole parts, all common and available from large distributors.

Easy to use

  • AVRdude compatible - support for usbtiny added in v5.5!
  • USB drivers available for Windows using libusb, no drivers needed for Mac OS X or Linux.
  • Durable off-the-shelf enclosure
  • High speed! Max clock rate is 400KHz. Write speed:1Kb/s, read speed: 2Kb/s. (Atmega8 takes 8s to write, 4s to read/verify)
  • 2 LEDs to indicate "USB/Power good" and "Busy"
  • I/O is buffered to allow programming of 2V-6V targets (v2)
  • Works with any AVR ISP chip with 64K of flash (or less) - does not work with Atmega1281/1280/2561/2560

Easy to power

  • Powered off of 5V USB bus at less than 100mA to allow it to be used with unpowered USB hubs
  • Easily accessable jumper to power target project off of USB (target must be 5V tolerant, of course)
  • Remove the jumper and it will self-power but buffer the I/O to match the target device. (v2)

Easy to extend

  • Easily interfaced with libusb
  • Existing firmware allows for fast SPI interfacing using USB
  • Bit-bang commands provide 8 bits of I/O control (including LED) for open-ended project ideas

F.A.Q.

Is this sold as an assembled programmer?

Not yet, it is only available as a kit.

How hard is it to assemble?

There are very clear instructions availble in the "Make it!" link. It's a simple kit and should be fairly easy for anyone with proper tools even if it's their first soldering project.

Does this work with linux?

Yes. We have tested it with linux (Ubuntu 7.04) and it didn't require anything strange so it should work with any distribution. If you're having problems make sure you are running as root to have permissions on the device.

Why is there no Serial/COM/port (or /dev/ttyXX device) ?

USBtiny is not a USB-Serial device, it is its own USB protocol which is understood by Avrdude. You will not see a COM port or Serial port created when you plug it in.

Can I send serial messages using the USBtiny as well as programming, like an Arduino?

No, the USBtiny does not create a serial port and cannot do that. It programs chips directly, using the ISP connection, not Serial. Arduinos are not AVR programmers, they are an AVR with a bootloader that runs over a serial port.

What chips can be programmed?

Any AVR that uses the ISP interface for programming and has 64K or less of flash can be programmed.

Chips such as the Atmega1280/1281 and Atmega2560/2561 have more than 64K and cannot be programmed.

Chips that use TPI interface, such as Attiny4/5/9/10 cannot be programmed.

Some very old chips such as the AT90S1200 and similar cannot be programmed

Can I program a bootloader (like an Arduino one) with USBtinyISP?

Yes, this is what an AVR programmer can do. We suggest using the 'built in' bootloader-burner in the IDE to do it.

How do I program a bootloader onto an Arduino?

  1. Put a fresh AVR chip (such as an Atmega328) into the Arduino in the correct orientation
  2. Remove the jumper from the USBtinyISP
  3. Plug in the USBtiny to USB
  4. Plug the Arduino into DC or USB so it is powered
  5. Plug the 6 pin cable from the USBtinyISP into the Arduino so that pin 1 mark is lined up with the red wire on the cable
  6. Start up Arduino IDE
  7. Select the chip/Arduino you are using in the Tools->Board menu
  8. Do not select a COM/Serial port
  9. Select Tools->Burn Bootloader->w/USBtinyISP
  10. The USBtinyISP red LED should light up. It will take a minute or two to program the chip
  11. When it is done, the IDE will tell you it has completed and the red LED will be off.

I need help getting this working

Check the HELP! page.

Does this work with the 8051-core (AT89) series chips?

The USBtinyISP design as-is only works with the AVR core chips (ATtiny/ATmega/etc). However Lucas Chiesa and his peers have done an excellent job porting this version to support 8051-core chips.

What is "Self Program"?

The original USBtinyISP could be programmed by another programmer by jumpering a pin. This is not true anymore now that there is a buffer. You should ignore the jumper.

Also, you cannot program the usbtiny with itself.

Make It!

Make Make Make

Step-by-step

Making a USBtinyISP from kit is easy, just follow these steps:

  1. Preparation and tutorials
  2. Parts list check (v2.0) or if you have an older version, parts list for v1.0
  3. Solder it together! (v2.0) or if you have an older version, assembly for v1.0

Use It!

How to use it!

The USBtinyISP is pretty easy to use, but here are a couple hints:

Indicator LEDs

There are two LEDs, a green one near the USB port and a red one near the cables.

The green LED indicates that the USB connection was sucessful. If the green LED doesn't ever light and you're sure it's in right, there was a problem with enumeration. If you're using a Windows or Linux machine and the green LED does not light up when you plug it in, theres a problem. If you have a newer Mac OS machine, try sending it commands via avrdude - the LED should light up then (strange but true!)

The red LED indicates that the USBtinyISP is 'busy' programming. You probably don't want to unplug it or the device being programmed while it's lit. However, if there's a software crash the LED may remain on even though it's not doing anything.

Programming Cables

There are two cables for programming: a 10-pin ISP cable and a 6-pin ISP cable. They are the two prevailing standards for in-circuit AVR programming. This programmer doesn't do JTAG programming

Jumper JP3 (USB power to target)

There's a jumper sticking out near the cables, JP3. When the jumper is in place (connecting the two wires) then that means that the USBtinyISP is providing 5V power to the device being programmed. If you don't want to power the device then just take the jumper out or make sure it's only on one of the wires.

The USBtinyISP can only provide 5V, up to about 100mA to the device. If you need more power then you should remove the jumper and power the device seperately. (Alternately, if you're feeling adventurous you can reprogram the USBtinyISP to requires 500mA from the USB port instead of 100mA but if you don't know how to do this I'd suggest not.)

Version 1.0 of USBtinyISP sends data to the device at 5V level no matter whether it's powering the device or not so make sure it's 5V compliant! (Note that there are 2 1.5K resistors in series with the data lines for protection)

Version 2.0 which is almost certainly what you've got, uses a level shifter so that if the jumper is not in place, it will use whatever the target voltage is, a lot better for your low-voltage devices!

So, if you have a device that needs to run at 3.3V, don't have the jumper in place!

Using it as an SPI interface

USBtinyISP can be used as a 'generic' SPI device. The best place to look for examples of how to use this is download the avrdude source code and read usbtiny.c

Here is a submitted example of using it under Linux, in c++. Thanks Matt D!

Download

Windows Drivers


For windows, we use a modified LibUSB driver. You can download it here:

For historic reasons, we have a:

  • Windows USBtinyISP driver built with libusb v1.10. Use this for older WinAVR's. Don't use this unless you have to interface with old versions of software that are bound to libusb v1.1

AVRDUDE

AVRDUDE is the recommended software to use if you want to program/flash an AVR microcontroller.

Hardware/Firmware Files for v2.0

The latest!

Please note this firmware contains the Adafruit VID/PID, while the firmware is open source the VID/PID is not. To use in your own products, replace those values in usbtiny.h You can purchase a USB VID for yourself at http://www.usb.org/developers/vendor/

Hardware/Firmware Files for v1.0

The board design is not single sided, but it's close: you will need to solder in the 5 wires that would go on the top. I have successfully toner-transfer etched this design.


v1.04 is a possible hotfix for some flakiness, you can try either one.

USBtiny500 compatibility bridge for AVR Studio

Download the latest installer
And source code


HELP!!!

Frequently Asked Questions

I'm running avrdude and I get "Initialization failed, rc=1"

This response from avrdude means that it can talk to the programmer but the programmer can't talk to the chip.

Check:

  • Are your 10 and 6 pin cables correct? compare with the pictures in the manual.
  • Are you either providing power to the chip (have the jumper in place) or are providing power to the programmer through the VCC header pin? If the jumper is not in place, the buffer chip (74ahc125) will require at least 2.5V from the target.
  • If you programmed your chip to have a very slow clockspeed use the -B flag, as shown here to slow down the chip. "-B 32" should do the job most of the time, but you can go as slowly as "-B 250"
  • Is the chip powered? AVCC, VCC, and all GND pins must be connected.
  • Does it have a clock or crystal (if necessary?)
  • Is anything keeping the MISO/MOSI/SCK/Reset pins from switching? (ie are the loaded down)
  • Does the target chip need a crystal? is the crystal oscillating?
  • Are you sure its wired up correctly? Use an oscilloscope to watch the reset line on the chip, it should flicker up and down. Watch the SCK pin and make sure you see a 8-pulse clock train. Check that you didnt get MISO/MOSI swapped. etc.
  • Do you need to 'jumper' the output 1.5K resistors? If you are not using the USBtinyISP for SpokePOV communication, this is recommended, especially with target chips that have something connected to the MISO/MOSI/SCK lines. Check the end of the soldering instructions for how to do this

Most of the time, your programmer is working fine, check your cables and pins and that the target device is properly wired up.

We have never encountered a USBtinyISP that got to this point where it talks to the computer but not a chip and it is the kit that is defective. It is ALWAYS a bad chip or a wiring, clocking, bit-speed, powering or output-resistor problem.

It doesn't work with a USB 3 port

We've noticed that USB 3 ports are sometimes a little more sensitive than USB 2. In this case you can try changing the cable (see this article) or placing an every-day USB hub between the USBtinyISP and your computer.

I'm running avrdude and I get "error: usbtiny_transmit: initialization failed, rc=-1"

This response means that it found the USBtiny, but could not communicate with it. The likely reason is that you found a version of avrdude that was not from WinAVR.
Differences in new versions of avrdude mean that it doesn't work with the libusb-win32 USBtinyISP driver.
For more information, see https://github.com/adafruit/Adafruit_Windows_Drivers/issues/22

It's not working!

Check:

  • Are all the parts in correctly?
  • Are there any cold-solder joints or bridges?
  • Are the cables attached properly?
  • Are the cables in backwards? (The red wire should be at the #1 spot)
  • Is the green light on, indicating USB enumeration was successful? (note with some Macs it appears the green light only turns on after Avrdude talks to the programmer, weird!)
  • Is the driver installed (windows)?
  • Is the device plugged into a target board? (I.e. is it connected to a chip)
  • Is the target chip powered?
  • Does the target chip need a crystal? is the crystal oscillating?
  • Are you trying to provide 5V USB power to a device that is already powered?

before posting to the forums!

I'm running avrdude and I get "USB read error: expected 4, got -1" (or something similar)

There's a priv's problem, check the usbtinyisp avrdude linux instructions for more info.

My 64 bit computer doesn't seem to work!

Some very old kits have this problem,thanks to intrepid assistants, a patch has been submitted to avrdude project, if you want to fix it yourself, simply replace the lines in usbtiny.c in avrdude that have
sizeof(res)
with
4

This was fixed in 2010 or so

I'm having trouble compiling/burning the chip for this project...

Use the precompiled .hex file and Makefiles as newer avr-gcc compilers may not be able to squeeze the code down to fit in the chip. Modify the Makefile in spi as needed and, in the spi folder, type in "make fuse flash" Beyond that, you're on your own!

I'm running avrdude and I get "Could not find USB device 0x1781/0xc9f"

This response means it could not find the programmer. There are many possible reasons:

  1. If you are using the latest WinAVR (which was built with an old version of the libusb driver library) you must use the v1.10 driver. Uninstall the driver you have and make sure you get the right one installed.
  2. Try unplugging and re-plugging it in
  3. Make sure the driver (windows only) is installed.
  4. Make sure the green LED is lit (which means its powered and has performed USB enumeration).
  5. Make sure you have libusb installed and that it is the correct version. (linux/mac)
  6. Make sure you have replaced the old version of libusb0.dll with the one from the download page.
  7. Make sure you are not providing power to the target through USB when it already has power. Check the jumper in the end of the device and remove it, if so.
  8. If you programmed the usbtinyisp chip, make sure the fuses are set properly.

I'm having trouble building this project from scratch...

Beyond the advice, here if you can't get this project working on your own I suggest buying a kit. It's not a simple project to debug!

I'm running avrdude and I get "error at avrdude.conf:370 unrecognized character: 'u'"

This means you properly replaced avrdude.conf but did not replace avrdude.exe (or under mac/linux, just avrdude) do a search on your computer and verify that you have replaced any copy of avrdude.conf with the patched version from the download page.

I'm running avrdude and I get 'avrdude: Can't find programmer id "usbtiny"

This means you did not replace avrdude.exe (or under mac/linux, just avrdude) with the patched version. Do a search on your computer foravrdude.exe and verify that you have replaced any copy of avrdude with the patched version from the download page.
This guide was first published on Jun 10, 2013. It was last updated on Jun 10, 2013.