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.
The FTDI breakout board is very handy, as it provides 5V 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.
Update 9-Sep-2017: The second part to this series, written some 7 years later, is now here. It covers writing code for the ATtiny10 as well as other programming options.
Hello from russia)
Can i use simply com port to programm Tiny10?
What software me need to use for programm Attiny10, and where to place avrdude-tpi-bb.patch
you cannot use the com port directly as the voltages are too high for the attiny10. to use the com port, you need a “dumb” serial port programmer, for example the DASA programmer here: http://www.adafruit.com/index.php?main_page=product_info&cPath=16&products_id=26
to program the attiny10, i used a modified version of avrdude. you need to download the source for avrdude 5.10, then apply the patch to the source code with a command like “patch -p1 < avrdude-tpi-bb.patch". you then need to compile the patched avrdude.
ladyada has very nice tutorials on how to compile avrdude for linux/unix and mac os x here: http://www.ladyada.net/learn/avr/setup-unix.html
this whole setup is not an easy way to program the attiny10, but it is the cheapest way without buying extra hardware (other than the Sparkfun breakout board).
Thanks for answer! But i win user only.. can you help me?
unfortunately not. this process can be done on Windows but it is quite troublesome and personally i’m using a Mac, which is more convenient for compiling such software.
you can either setup the whole compilation environment for Windows to patch and compile avrdude, or you can wait until the patch is accepted into the main avrdude tree (not anytime soon i think) and they will release Windows binaries.
I have done an USB-based TPI-programmer for the ATTiny10 family here:
It is based on VUSB-firmware and an ATTiny25.
actually i did see your programmer when i was looking around for a way to program my ATtiny10, but i guess writing the bitbang code would be simpler in terms of hardware and easier to debug too.
it was actually quite a bit of work to get the firmware into that little chip ( = messy ), plus avr-gcc-bugs, plus no debugging with v-usb firmware.
This tutorial was a fantastic discovery, especially since ATTiny10 programming material is so sparse. However, could you please update the FT232RL pins shown above to reflect what is used in the software distributed on avrfreaks.net? My discovery was:
ATTiny10 Pin = FT232RL Pin
1) RESET = Tx
2) TPICLK = RTS
3) TPIDATA = RI (And pulled up to DTR)
I was able to program the device using the software provided. Being a Linux user, I will try and port it to Python (The D2XX drivers work, from previous experience).
Thank you once again.
The TinyProg software hangs while reading / writing flash at a byte count of around 632. Is it possible that this is a bug in the FT232RL driver? I am using a FT232RL driver that is one version older.
bitbang methods are not the most reliable.
i personally have not encountered any errors, but you may want to try slowing down the speed by passing the -i (ISP clock delay) flag to avrdude, or lower the baud rate using the -b flag.
[…] Darrel Tan’s Programming the ATTiny10 instructions and a SOT-23 breakout board by Raphael, I was able to flash one of these very small MCU chips. […]
Just a note in case you weren’t aware, avrdude 5.11 Windows binary is now available in the arduino 1.0 release.
great! thanks for letting me know. wonder what happened to WinAVR releases.
can you share your avrdude command line? I’m using avrdude 5.11:
./bin/avrdude -p attiny10 -c dasaftdi -P /dev/ttyUSB0 -U flash:w:test.hex -v -v -F
isn’t giving me what I expect on a scope. Am I missing something?
The command line is pretty standard, similar to what you have. The part id should be “t10” though, unless you modified your avrdude.conf. Also, it’s not good to ignore the device signature.
If you still can’t get it to work, please let me know. I’d like to see this work for as many people as possible.
I’ve now got lots of data visible on the mosi/miso line, a regular clock, but avrdude fails with avr device not responding…
Hmmm interesting… where does it fail? Do you mind sharing your log with all the bitbang_cmd_tpi debug output?
You are using 5V right? That is the programming voltage required.
Does this programmer use the HVP method and apply 12v or the RST pin, so it will erase the
RSTDISBL fuse in the attiny chip inf PB3 is used fo I/O and the reset function has to be disabled?
Hi Steve, this method uses 5V from the FTDI for the programming voltage. You could however add a transistor on the RTS line (in this case) to control a 12V supply to the RESET line instead for HV programming – the TPI protocol is the same. As you’ve mentioned, it is only necessary when the RSTDISBL fuse has been programmed.
have you tried this?, do i need to use any special commands in avrdude for this?
i read somewhere the timing of the programming algorithm is a little different
if you use hvp and put 12v on the rest pin.
I have not tried this but there is no (significant) difference in the timing. Refer to the ATtiny4/5/9/10 datasheet, section 14.3.1. You require 5V on Vcc, and either 12V on the RESET pin or pull RESET low after tTOUT. avrdude has no problems doing the latter, so 12V shouldn’t be a problem.
2 years later, and TPI info is still light. I am not very experienced with Attiny10 parts and TPI or HVP in general.
So how would we do HVP using a buspirate (and a 12V supply) to clear the reset fuse? With a chip this tiny, the reset pin is quite usefull.
Maybe an updated blog post, using avrdude, a BP and normal + HV programming?
Thanks for this in any case!
Thanks for taking the time to post these instructions… they worked perfectly for me, and saved me a lot of headache!
my question is, did you used the ‘SparkFun FT232RL breakout board’ as an AVRISP to programm the ATtiny10? But how could that work with TPI?
Yes that’s correct. Bit-bang type programmers have been around since the DOS days with parallel and serial port programmers. The FT232RL acts like a serial port. I just wrote the software part into avrdude to communicate using the TPI protocol.
Hope that answers your question.
Thanks for your answer but how does the avrdude software part looks like? If its ok.
Hi Murn, avrdude is open-source so you can download the source code to take a look. If you are interested only in the part specific to TPI, I have also linked to the patch tracker where you can find the patch. Everything is linked in the article above.
To program an ATtiny9 using avrdude and either the linuxgpio driver (e.g., on Raspberry Pi) or the usbtiny programmer (aka Sparkfun AVR Pocket Programmer), the following patches can be used:
– linuxgpio bug fix: https://savannah.nongnu.org/patch/?8922
– linuxgpio TPI support: https://savannah.nongnu.org/patch/?8923
– usbtiny TPI support: https://savannah.nongnu.org/patch/?8924
[…] artículos donde hablan de cómo desarrollar software para él, o donde han creado un tipo de firmware para un adaptador USB-TTL, y lo que mejor pinta tenía: un sketch de arduino que simulaba la interfaz TPI para el […]