More succinctly- It's the smallest, cheapest, and easiest way to build a simple Arduino project that doesn't require the larger Atmel microcontrollers.
After playing with my initial three Digisparks for a while, I started coming up with uses for the ATtiny85 that made even the Digispark overkill. For these simple circuits I didn't want (or need) the bootloader or the USB IO. I just wanted a way to flash my code onto the raw ATtiny85 and move on. Enter littlewire - a simple Atmel AVR programmer based on the ATtiny85 and it's ability to implement USB in firmware.
Littlewire uses the same IO pins as the Digispark, so you can actually just flash the existing littlewire firmware onto a digispark, and then immediately start using it as an AVR programmer to program raw Atmel chips!
Below (for my own recollection, honestly) are the steps I took to set this up and my notes about programming raw ATtiny chips with Arduino. Note: I'm doing this on a 64-bit Linux system. The steps should be similar for another OS, but YMMV.
Step 1. Set up & test the Digispark Arduino environment
I just used the pre-built Arduino package with the digispark binaries from digistump.com. The important part here is getting working micronucleus and avrdude binaries that can talk to the custom digispark bootloader.
Step 2. Push the littlewire firmware to the Digispark
After you have confirmed that you can program a digispark, you'll need to re-flash it with the littlewire firmware. The only file you really need is main.hex from the 'firmware' directory, currently located at https://github.com/kehribar/Little-Wire/tree/master/v1.1/firmware
The 'micronucleus' binary you got (or installed) with the Digispark Arduino package is the magic command to push a pre-compiled .hex file to a digispark. So, from a command prompt, simply run:
and then plug in the digispark you wish to re-flash. (Substitute the full path to main.hex if necessary.) NOTE: My laptop has some minor timing issues talking to the digispark, so it actually took three or four attempts to make micronucleus successfully upload the firmware.
Once this is successful, the Digispark will identify itself on the USB bus as a USBtiny after the initial Digispark bootloader 5 seconds is up.
Step 3. Install Arduino support for the ATtiny* family of AVRs
At the ATtiny AVR support to Arduino. I used the library available here: https://code.google.com/p/arduino-tiny/downloads/detail?name=arduino-tiny-0100-0016.zip
- create a hardware directory called 'attiny'
- extract the attiny support library into the attiny/ directory
- edit / create "boards.txt" under that directory with the entries from "Prospective Boards.txt"
Note: The MIT High Low Tech blog guys apparently have their own Arduino ATtiny library as well, which should also work. I haven't compared them. [Anyone used both? Let me know the difference!]
You should be all done! Verify you can complete the steps below:
Programming AVRs with your new programmer
Connect the Digispark-Littlewire to a chip to be programmed:
Naturally, you'll also have to supply +5V (pin 0) and GND (pin 4) to the target chip as well. You can safely leech these from the 5V and GND header pins of the Digispark to use the USB power.DigiSpark => ATtiny85 p0 => pin 5: PB 0 (MOSI) p1 => pin 6: PB 1 (MISO) p2 => pin 7: PB 2 (SCK) p5 => pin 1: PB 5 (RESET)
From within the Arduino interface:
- Select Tools -> Programmer -> USBtinyISP
- Select Tools -> Boards -> ATtiny85 (xxx) for the appropriate settings you want.
NOTE: If you select a new clock speed, you'll have to change the fuse bits on the processor to set them. The Arduino "Burn Bootloader" command will do this for you if you used the library I did. Otherwise, set the fuse bits yourself using avrdude from the command line.
- Upload! You're done!
One big advantage to using an AVR programmer in this configuration is that you can leave the AtTiny85 plugged in and re-program it at will, since the AVR programmer uses the pin 1 (RESET) pin to reset and reprogram the ATtiny85.
Conversely, the drawback is that you lose the use of pin 1 as an I/O pin (D5) unless you want to set the fuse bit to disable RESET - at which point you can no longer program it using the AVR programmer.
I want to use the attiny85 reset pin as I/OReplyDelete
What are the fuse settings ,I am using avrdude from terminal.
I have right now used
I saw somewhere else that the High fuse(DD) should be set to 5D to gain the use of that pin.
its also a nice tutorial worked for me...ReplyDelete
Is there a way to bring the Digispark back to its original firmware after you have configured it with the command line: micronucleus main.hex?ReplyDelete