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 hers.
Introduction
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.
Application Compatibility
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+.
Hardware
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.
Usage Instructions
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.

Hey, thanks for the great work!
A few questions however:
I’ve tried both your precompiled as well as compiled my own hex, either way when I conenct it to a usb port the computer just shows a message saying that a device malfunctioned.
I assume that the problem is on my breadboard; is there a schematic to show what my breadboard should look like?
Cheers!
The PC side doesn’t give very useful errors, usually it either it works or it gives the same error. It could be you have the wrong pins wired up, no zeners on the data lines, wrong fuses or binary on the avr.
Try my Tiny JTAG AVR Programmer schematic of the Sparkfun AVR Stick for examples of the hardware. I’ll try to make the hardware details more clear this evening.
Louis
I updated the page. Post back and let me know if you are able to get the circuit to work. My first time breadboarding the circuit I didn’t have the zeners at the time, and found they were required, it didn’t work until I added them.
Still having issues; I’ve tried with the zener diodes but still says the same thing, I think I might do a little more research (If I solve it I’ll b e sure to post my solution!)
Try using another V-USB based program, this one comes with a precompiled binary which worked on my circuit:
http://www.frank-zhao.com/cache/usbbusinesscard_details.php
The programmer shares the same pins as USB, did you remove it after programming? I never had an issue, but your programmer might be doing something different.
Is anything pulling the reset line low? I’m pretty sure you’ll get the same “USB malfunction” message just from having the pullup resistor on the D- line, it doesn’t mean there was any communication with the PC at all.
Good luck!
I made a new release of the bootloader, and while updating this page found I had reversed the description of where the D- and D+ lines connect to on the tiny85. Could that explain why you’re having trouble running the bootloader? If you followed the schematic for AVR Stick or tinyJTAG there’s no issue.
Hi, Louis.
Great work, very interesting reading.
I’ve got one issue. Using the schematic of SFE AVR Stick,
and compiling the code myself, I’m having troubles with PC recognizing a unknown device, even though the USBasp is not inserted at the same time.
I’ve tried multiple configs, but this won’t work.
One thing I noticed: In the bootloaderconfig.h, you could comment out both or one of the preconfigured hardware options.
This doesn’t change anything for my device.
So now the question is, how to get on from here?
Thanks in advance.
Lerche
Have you run any other V-USB projects successfully on your hardware? I used this project which comes with a precompiled binary to test out my hardware:
http://www.frank-zhao.com/cache/usbbusinesscard_details.php
AVR Stick uses LEDs instead of zener diodes, which parts are you using in your circuit? I haven’t tried using LEDs, I did use zener diodes, these ones in particular:
http://search.digikey.com/us/en/products/1N5227B-TP/1N5227B-TPCT-ND/950673
I’ve tried both zeners and LEDs, no change. Maybe my compile isn’t right. I’m having failure on trying to program lock bits to the tiny. I’ll investigate. Thanks
Wow, funny thing. I’ve tried one of your precompiled HEX files. This goes right up and recognizes it as USBasp.
Now I’ve got to figure out how to throw a Arduino compiled program down to it
The AVRDUDE you include in the software folder, is it patched? If not, how can I do so?
Thanks
Yes, the included .exe is patched.
Let me know if you figure out why compiling the bootloader yourself doesn’t work. You do need to change one definition in bootloaderconfig.h to support your hardware:
change
#define HARDWARE_CONFIG TINY85_HARDWARE_CONFIG_2
to
#define HARDWARE_CONFIG TINY85_HARDWARE_CONFIG_1
I haven’t tried it myself, but you should be able to replace the avrdude.exe in your ardunio directory with my patched version, and program the tiny85 through the arduino environment. I’ll post instructions if I try that myself, but that won’t be anytime soon.
What you is amazing
I managed to program your bootloader into my AVR Stick and right next an USBasp was identified and installed.
I’m now trying to integrate this with the Arduino IDE using these libs. Then i appended this board configuration to the boards.txt of the attinys:
attiny85-16.name=AVR Stick (USBasp)
attiny85-16.bootloader.low_fuses=0xe1
attiny85-16.bootloader.high_fuses=0xdd
attiny85-16.bootloader.extended_fuses=0xfe
attiny85-16.upload.protocol=usbasp
attiny85-16.upload.maximum_size=5370
attiny85-16.build.mcu=attiny85
attiny85-16.build.f_cpu=16500000L
attiny85-16.build.core=arduino:arduino
attiny85-16.build.variant=tiny8
But, when trying to upload a simple blink sketch to the AVR Stick, the Arduino IDE throws this:
Binary sketch size: 806 bytes (of a 5.370 byte maximum)
java.lang.NullPointerException
at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:88)
at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:67)
at processing.app.Sketch.upload(Sketch.java:1706)
at processing.app.Sketch.exportApplet(Sketch.java:1662)
at processing.app.Sketch.exportApplet(Sketch.java:1634)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2346)
at java.lang.Thread.run(Unknown Source)
I’m relatively new to this, but i’m looking into it. Also, i’m looking forward to know any updates on this, if you try it yourself
Cheers from Portugal.
after reading this post i figured out what was wrong. In Arduino 1.0, if using a programmer we should upload using “File->Upload Using Programmmer”
but there’s still a problem after uploading:
Binary sketch size: 808 bytes (of a 5.370 byte maximum)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: error: usbasp_transmit: usb_control_msg: sending control message failed, win error: A device connected to the system is not working.
avrdude: error: usbasp_transmit: usb_control_msg: sending control message failed, win error: A device connected to the system is not working.
avrdude: error: wrong count at writing ffffffff
avrdude: error: usbasp_transmit: usb_control_msg: sending control message failed, win error: A device connected to the system is not working
avrdude: error: wrong responds size
avrdude: error: usbasp_transmit: usb_control_msg: sending control message failed, win error: A device connected to the system is not working.
avrdude: error: wrong responds size
avrdude: verification error, first mismatch at byte 0×0040
0×00 != 0xff
avrdude: verification error; content mismatch
I suspect this has someting to do with the bootloader disconnecting from the system as soon as it is used, but it reconnects has a USBasp, so the program upload wasn’t successful.
I think you just need to replace the avrdude.exe in arduino with the modified version I included in the bootloader release. Please try that and let me know if it works.
Hi, i had switched arduino’s avrdude with yours before those errors occured.
I tried using another computer and it was flawless. I have all the resources shared between computers so the conditions were the same, thus i suspect it was something usb-related with the first computer i used.
I already managed to make all the AVR Stick LEDs blink
this is awesome work, i can’t put to words how awesome this is.
The world should know about it
cheers.
Hi Tiago,
Thanks for the kind words. If you have any blogs you read that might be interested in the bootloader maybe you can send them a link. I haven’t really tried to get the word out yet.
You may have another avrdude.exe in your path, try renaming the exe in the arduino folder and see if it’s still able to run avrdude.
Hi, thanks to Louis for this great project! Like Tiago, I’m seeing write failures even after applying the avrdude patch successfully, but mine look a little different. I’m on Linux.
Binary sketch size: 806 bytes (of a 5,370 byte maximum)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: error: usbasp_transmit: Broken pipe
avrdude: error: usbasp_transmit: Broken pipe
avrdude: error: wrong count at writing ffffffff
avrdude: error: usbasp_transmit: Broken pipe
avrdude: error: wrong responds size
avrdude: error: usbasp_transmit: Broken pipe
avrdude: error: wrong responds size
avrdude: error: usbasp_transmit: Broken pipe
avrdude: error: wrong responds size
avrdude: error: usbasp_transmit: Broken pipe
avrdude: error: wrong responds size
avrdude: error: usbasp_transmit: Broken pipe
avrdude: error: wrong responds size
avrdude: error: usbasp_transmit: Broken pipe
avrdude: error: wrong responds size
avrdude: verification error, first mismatch at byte 0×0036
0×01 != 0xff
avrdude: verification error; content mismatch
Any ideas? I’ve tried making the usleep() longer,thinking that maybe the amount of sleep required is system-dependent, but that didn’t help. Thanks!
Hi Chris,
I’ve never seen that error message myself, and I’m not running Linux, so I can’t try it myself unfortunately. Can you try programming with AVRDUDE from the commandline with parameters “-v -v” for more verbose debug output? If we can figure out where it’s failing that might help track it down.
Another thing you might try is connecting AVRDUDE to a USBasp programmer, or another programmer using USB to see if it might be a generic USB or libusb problem, not anything specific to the tiny85 bootloader. Do you have a USBasp programmer, or could you put my USB JTAG programmer firmware on your tiny85?
It’s interesting to see you are at OLPC, one of the ideas I had as a use for this bootloader was to make an extremely inexpensive Arduino-compatible board that could open up microcontroller development to classrooms that wouldn’t have a budget for a full Arduino board for each student. I specifically looked at the OLPC to see if the Arduino and Minibloq IDEs were compatible. I’m not working on that idea right now, but if I pick it up again, I’ll be in touch.
Hi! Great work!
The bootloader is working well, but I have issues with avrdude.
I recompiled avrdude after applying your patch, and writing failed every time.
After some improvement, I’ve got a pseudo-working version:
When I’m trying upload a new program (via the bootloader) it fails at the verification. And at the second try it’s always working.
Are you used the published patch when compiled your avrdude? It looks a little broken to me (patching with patch command is fails; what is “int i” stands for, it never used). Although it’s possible that I’m wrong at something…Any ideas? Thanks
Hmm, I’m not sure, and won’t have access to a computer for a couple days. I’ll take a look when I can.
The “int i” was just left over from some previous code I later deleted. It’s unnecessary and I’ll remove it before the next release.
I did test the patch before publishing it. I tested it again and it worked for me, I ran the patch program from a MinGW shell in Windows:
patch -i avrdude.patch usbasp-orig.c -o usbasp-patched.c(usbasp-orig.c is the original usbasp.c file from AVRDUDE 5.11.1)
Thanks, I will test it again in Linux.
Hey, impressive work, thanks for sharing!
How hard will it be to adapt the code for Attiny84?
It should be fairly easy. I would start by getting one of the other example V-USB projects to work on your hardware, then make a few changes to the Boot Loader code to match the settings on your working example. You’ll need to add an external crystal and change the clock to 16 or 12MHz as the Attiny84 doesn’t have an internal PLL clock like the Attiny85. There are probably a few other minor changes. If you get it to work, please post back!
I’m attempting to make this work with an ATTiny84 clocked at 12MHz with an external crystal. I’ve gotten other V-USB things working with the hardware. I’m currently scratching my head in usbdrvasm{12,165}.inc, pondering a blind copy of the
#ifdef TINY85MODEsection. While I want a USBasp-compatible bootloader, perhaps I’ll look at Micronucleus to see if it supports 12MHz already.It’s probably that simple (copy/paste), but I can’t take a look at the code right now.
I suggest looking at Micronucleus, I don’t plan to maintain this boot loader in the future.
A few people pointed out problems using the modified AVRDUDE to program a chip through the boot loader, it appears to be related to timing, specifically AVRDUDE not waiting long enough before polling the chip after the boot loader does a write to flash (while the boot loader is unresponsive). I don’t see this issue on my Windows system used to do development on this project. I do see it on my recently purchased Mac system, in OSX and in Parallels running Windows 7.
I added a 100ms delay after the second ‘usbasp_transmit()’ call in ‘usbasp_spi_paged_write()’ and that seemed to improve things, but I haven’t done much testing. I’ll pick this up when I have more time, not sure when that will be.
See this issue thread in github for more details:
https://github.com/embedded-creations/USBaspLoader-tiny85/issues/1
Any reasons that PB3(USB-) and PB5(USB+) could be used for the USB line? Would one just need to change the USB_CFG_DPLUS_BIT in bootloaderconfig.h to 5 and then upload it and then changes the fuses to disable reset?
Hi Jimmy, the GPIO drivers on PB5 has some unique characteristics because of the special reset behavior on that pin that prevent it from driving the outputs very hard. It might work but I doubt it, and you’ll need a high-voltage programmer to bring the fuses back to normal if you disable reset. Take a look at the datasheet for more details on the GPIO pin.
Aside from that, it should be as simple as changing the #define for the D+ pin.
Thanks for putting this together. I see that it has a lot of potential. I spent a few hours on this today and got pretty close to it working. The goal is to integrate my ATtiny85 board into the Arduino IDE without the programmer requirement. The challenge for me is that my board operates on 3.3V. Is there any way to get this to work with a 3.3V system? I have gotten EasyLogger working to test V-USB, so I know that works at least. I did swap out the avrdude.exe with the pre-compiled and patched version that comes in the zip file, but still not working properly. I ended up compiling the bootloader hex file myself since I use different pins for the USB D+ and D-.
More information on my hardware is here: http://candleplus.blogspot.com/
When trying to upload, I got similar messages that others received:
…
avrdude: auto set sck period (because given equals null)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e930b
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: auto set sck period (because given equals null)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file “C:\Users\John\AppData\Local\Temp\build7826448490907735431.tmp\candle.cpp.hex”
avrdude: writing flash (1882 bytes):
Writing | #avrdude: error: usbasp_transmit: usb_control_msg: sending control message failed, win error: A device attached to the system is not functioning.
avrdude: error: usbasp_transmit: usb_control_msg: sending control message failed, win error: A device attached to the system is not functioning.
avrdude: error: wrong count at writing ffffffff
################################################# | 100% 2.24s
avrdude: 1882 bytes of flash written
avrdude: verifying flash memory against C:\Users\John\AppData\Local\Temp\build7826448490907735431.tmp\candle.cpp.hex:
avrdude: load data flash data from input file C:\Users\John\AppData\Local\Temp\build7826448490907735431.tmp\candle.cpp.hex:
avrdude: input file C:\Users\John\AppData\Local\Temp\build7826448490907735431.tmp\candle.cpp.hex contains 1882 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.16s
avrdude: verifying …
avrdude: verification error, first mismatch at byte 0×0040
0×00 != 0xff
avrdude: verification error; content mismatch
avrdude done. Thank you.
I tried running a simple V-USB app at 3.3V early on, before trying to take on the bootloader, and I couldn’t even get a simple app to run. I think trying to run the tiny85 at 16.5MHz at 3.3V is pushing it, maybe you have a chip on your board that will handle it, but I wouldn’t depend on it working.
It looks like the issue you’re seeing “a device attached to the system is not functioning” might be fixed by something I found last week but haven’t had time to commit yet to git, take a look at the issue here:
https://github.com/embedded-creations/USBaspLoader-tiny85/issues/1
I keep stumbling across references that V-USB can operate at 12MHz or 12.8MHz, which would drop the clock down to be within spec for 3.3V. Is this not suitable for this application or is this possibly outdated information?
A couple of examples:
http://vusb.wikidot.com/hardware
http://forums.obdev.at/viewtopic.php?f=8&t=3274
Thanks again.
-John
http://vusb.wikidot.com/hardware
see the section labeled “Which clock rate should I choose?”
You could run at 12MHz, but you’d need an external crystal, taking up two valuable pins on the tiny85.