ATtiny85 USB Boot Loader: Overview
Update 12/23/2012 - Jenna Fox aka Bluebie used the same mechanisms I developed here to make a much smaller footprint boot loader, available here. As her boot loader is more complete, thoroughly tested, and is being actively maintained, I suggest you use her micronucleus bootloader.
Update September 2013 - Adafruit released the Trinket and Gemma dev boards which use the ATtiny85 and the same boot loader mechanisms as I did. Their boot loader is not as space efficient as micronucleus, as their goal was to work with an unmodified AVRDUDE executable.
This is a USB boot loader for the ATtiny85, allowing for applications to be added through USB without an external programmer. An application can be loaded or updated on the ATtiny85 by using a slightly modified version of the AVRDUDE programming software. This is a modification to the USBaspLoader project by OBJECTIVE DEVELOPMENT Software GmbH.
The boot loader currently requires 2822 bytes of flash, leaving 5370 bytes for the application.
The boot loader is currently functional, though it has only limited testing and may contain significant bugs. If you burn the "External Reset Disable" fuse and the boot loader breaks, you will have to use a high voltage programmer to erase the chip, or replace the chip.
Release includes firmware source, AVRDUDE .patch, and precompiled binaries for the firmware and Windows version of AVRDUDE.
USBaspLoader-tiny85 on github
As of the 2012-05-13 release, applications can use any pins for USB, there is no longer a restriction to only using the INT0 pin for USB D+.
There are two hardware configurations supported with precompiled binaries. For an example of Hardware Configuration 1, see my Tiny AVR JTAG Programmer, or Sparkfun's AVR Stick for example schematics. For an example of Hardware Configuration 2, see Little Wire.
Regardless of which hardware configuration is used, the ATtiny85 needs to be powered by 4.5V minimum as the internal oscillator is running at 16.5 MHz.
Download the boot loader precompiled hex file or download the source and compile yourself. If you want to use one of the precompiled hex file, reference the fuse settings contained in the makefile and program the flash and fuses using your preferred tools.
Modify the makefile to correct use your preferred AVR programming tool.
Program the boot loader to the tiny85 flash using "make flash". Set the fuses appropriately: "make fuse" leaves the external reset functionality enabled.
Download the USBasp driver if you need it for Windows. See "drivers" on the USBasp homepage.
At this point AVRDUDE should be able to connect to the tiny85 as a USBasp programmer, try reading the signature:
avrdude -p attiny85 -c usbasp avrdude: warning: cannot set sck period. please check for usbasp firmware update avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.04s avrdude: Device signature = 0x1e930b avrdude: safemode: Fuses OK avrdude done. Thank you.
Download the modified version of AVRDUDE or download the source, apply the patch, and compile yourself.
Use the modified version of AVRDUDE to program an application on the tiny85, and make sure it verifies successfully. The boot loader code should jump to the application shortly after AVRDUDE disconnects.
To replace or update the application, disconnect and reconnect the USB cable (or otherwise reset the tiny85). The boot loader will connect to the PC as a USBasp programmer for 5 seconds before jumping to the application. If the application is invalid or erased, the boot loader will stay connected as a USBasp programmer until a new application is loaded successfully.
If you need an extra I/O line you can use "make disablereset" to disable external reset functionality, allowing reset to be used for I/O - only set this after you're sure the boot loader is working.