Being able to program an ATtiny directly from Arduino can be a powerful tool to create low-cost embedded prototypes.
A few months ago, I wrote about programming an ATtiny84 from Arduino. While it was a great way to program the low-power and low-cost ATtiny from the easy-to-use Arduino IDE, it required you to connect 4 SPI lines every time you needed to reprogram the target (ATtiny). It also necessitated the use of another Arduino each time you wanted to program the ATtiny.
After a few days of digging through the micronucleus source code and Arduino IDE documentation, I achieved the holy grail for this project: emulating USB on the ATtiny in order to upload firmware directly from Arduino, removing the need for a separate programmer.
While this is not anything new (the Digispark from Digistump does the same thing), I needed a bootloader with virtual USB for the Atmel ATtiny84, as it offered more pins over the ATtiny85. This meant having to go through the process of loading the micronucleus bootloader onto the ATtiny84, changing some fuses, and writing a custom board definition in Arduino.
All that does not seem so bad, but it is a fairly lengthy process just to get a bootloader onto a single chip. The good news is that this process should work for other ATtiny microcontrollers that micronucleus supports, including the ATtiny85, ATtiny841 and ATtiny167. You'll just have to select the correct bootloader object (.hex) file, change which fuses you burn, and make a few changes to the boards.txt and platform.txt files in Arduino.
Once the bootloader and board definition files are in place, you can send compiled programs over USB directly to the ATtiny84. You'll need two pins on the ATtiny dedicated to emulating USB, but that's better than constantly having to hook up SPI lines, right? OK, I know that using a real programmer is much better in a lot of cases, but this is still an interesting way to reprogram small microcontrollers with cheap hardware.
If you are interested in trying out this process, you can follow this tutorial:
I know this seems like a rather long and involved process just to be able to program an ATtiny84 from Arduino, but it does promise for easy flashing of a microcontroller from an introductory IDE. Even without Arduino, have you used any of the ATtiny microcontrollers in the past? If so, for what kinds of projects?
These ATtiny parts are incredibly handy, thanks for the excellent tutorial!
Another option is to use the TinySafeBootloader.
Like a boss!