After my most recent post about my Shinewave protoype, a lot of people were asking how to do it themselves. In particular, how to upload my firmware to the ATtiny. In this post, I'm going to show how to upload my firmware to the microprocessor, and in the next post I'll give an overview of how it works.
Keep in mind that these instructions apply to the latest prototype of this project(Aug 2, 2015) and does not necessarily apply to future versions of Shinewave. In fact, I have some pretty ambitious plans for improving this process!
You'll need two parts and some software for this step.
One of the easiest ways to program an ATtiny is with Sparkfun's Tiny AVR Programmer. Designed specifically for programming the ATtiny, it has a drop in socket so no wiring is required. In the future, if you'd like to program other AVR chips, it breaks out the 6-pin ISP header.
In order to use the device on Windows, you'll need to install its drivers. The ones that I used are listed on the product page on Sparkfun. Just scroll down to "USBTinyISP Driver" and download the right version for your copy of Windows. Then, plug in your device, unzip and run the installer.
Now, just insert your chip into the socket so that the chip's corner dot is on the same side as the socket's round divot. These markings denote which orientation the chip needs to be placed in.
Image from Sparkfun's hookup guide
avrdude is the program that communicates with the ISP programmer and the chip. We can use to to set the chip's configuration fuses and upload programs. If you have the Arduino environment set up, you'll already have it in your
Arduino/tools/bin folder. Otherwise, I've packaged a compiled version of avrdude and a default configuration here. You can unzip it wherever you'd like, but for this example, I'm just using my desktop.
Because avrdude is a command line program, we'll need to open a command prompt in order to interact with it. Hold down the Windows key and press
r(Win+r) to open up the Run dialog, then type in
cmd.exe and hit OK.
Next, we'll use the
cd command to change directories to the folder that we unzipped avrdude to. If the folder has any spaces in the full path, you'll need to enclose it in quotes.
Now, typing in
avrdude should give you a basic rundown on what avrdude is capable of. We'll be using the
-p parameter to specify our part, the
-c parameter to specify our programmer, and the
-U command to modify the chip. For now, just run
avrdude -p t85 -c usbtiny to confirm that everything is working.
Setting the fuses
Most AVR parts handle vital configuration in three fuse bytes. These bytes can only be set while programming and control things like clock speed and whether the chip can be reprogrammed. We'll need to set the fuses to enable the chip's internal RC oscillator and configure it to run at 16MHz. To do this, tun the following command:
avrdude -p t85 -c usbtiny -U efuse:w:0xFF:m -U hfuse:w:0xDF:m -U lfuse:w:0xD1:m
You'll see the command line scroll through some output as it writes and verifies each byte.
You'll only need to preform this step once per chip, even if you're reprogramming it with a new firmware.
Writing the firmware
Finally, we get to write the Shinewave firmware to the chip. Download the
shinewave.hex file from my Github repository and place it directly in your avrdude folder. If someone else compiles a version of my program with their own animations, you'd download their
.hex file at this point instead.
avrdude -p t85 -c usbtiny -U flash:w:shinewave.hex
Just like when setting the fuses, you'll see some text scroll by as the program is written. Congratulations! You're done setting up the firmware and are ready to perform the rest of the mod.
If you're having trouble with any of the above steps, I'd recommend looking through some of the below links. They're all very useful, and what I used to learn this process.
If you're having trouble past what those links can help with, feel free to ask questions in the comments section below!