Programming the ATtiny10

Recently I wanted to use a really tiny, low pin-count microcontroller for a project, so I decided to buy a few Atmel ATtiny10 to experiment with.

To get it working, I would need a compiler and a programmer. I like working with Atmel chips because they have cross-platform development tools. The Arduino IDE that I’ve been using comes with avr-gcc and avrdude, both of which are really awesome open source tools for compiling and uploading code to the microcontrollers. If you just want the tools without the Arduino IDE, you can get the WinAVR package.

However both of these tools do not work with the ATtiny10 yet. I do not expect a C compiler, but even the GNU assembler that comes with avr-gcc still doesn’t support this chip. avrdude recently added support for uploading to the ATtiny10, but only through the STK or AVRISP programmer, which I didn’t want to fork out money to buy.

The compiler problem was solved by downloading AVR Studio 4.18 SP2 (download is free but requires registration), which comes with a command-line assembler that supports the ATtiny10. I decided to solve the avrdude problem by writing the bitbang code myself. (Update: this is now included in the avrdude 5.11 release)

I spent a couple of hours reading the existing avrdude code, and thinking how I can properly integrate the code that talks the TPI protocol instead of the usual serial downloading protocols used by the more common ATmega’s.

I made my own breakout board for the microcontroller, which I then hooked up to the SparkFun FT232RL breakout board.

My ATtiny10 bitbang programmer setup

Schematic of the ATtiny10 bitbang setup

The FTDI breakout board is very handy, as it provides 5 V power, as well as all the signals required to program the chip. I’m using the board with the VCCIO pin tied to the 3V3OUT pin and it works fine.

I decided to use the same connections as a “dasa” programmer, which is documented in the avrdude.conf file. One very important thing to take note when using the FTDI chip is that the pins are all inverted, so my avrdude programmer definition looks like this:

programmer
  id    = "dasaftdi";
  desc  = "FTDI serial port banging, reset=rts sck=dtr mosi=txd miso=cts";
  type  = serbb;
  reset = ~7;
  sck   = ~4;
  mosi  = ~3;
  miso  = ~8;
;

You can see that all the pin numbers have a tilde character in front of them, to indicate that the polarity is inverted. I spent several days of head scratching after I wrote the initial code to enable the TPI interface and it didn’t work at all.

After implementing the TPI protocol that uses the serial bit-bang programer for avrdude, I finally got a simple program uploaded and working.

I will see if I can get the TPI bit-bang code integrated into the main avrdude tree so that other people may benefit from it.

Update: if you need to program an ATtiny4/5/9/10 right now, you can use the patch (against avrdude 5.10) that I’ve submitted on the project patch tracker.

Update 1-Sep-2011: Good news everyone! After about a year (from this post), avrdude 5.11 has been released and it now has, among other things, the TPI bitbang implementation included. Now we just need to wait until WinAVR releases Windows binaries for Windows users.