Tiny AVR JTAG Programmer: Details


I wanted to release the SP Duo programmer, or at least the JTAG programming portion of it as open source software.  Inspired by the VUSBTiny project (actually this post where I learned about it), I decided to try to make a AVR JTAG programmer using an ATtiny85 and VUSB.



I found two projects I could use as a reference or base for my JTAG programmer:

  • VUSBTiny usbtiny / USBtinyISP
    • Based on VUSB
    • Used by adafruit
    • Tiny45 design
    • Source project is usbtiny which doesn’t seem like an actively developed project
    • Adafruit updates aren’t recent, and require outdated WinAVR version
  • USBasp
    • Based on VUSB
    • ATmega8 design – plenty of space and IO for initial development
    • Project has updates as of 2011
    • Developer also works on AVRDUDE

I decided to build the project as an addition to the USBasp programmer, adding the JTAG features and porting it to the tiny85.

I did all the JTAG development with an ATmega8 on an STK500 development board.  I changed all the ISP calls to use JTAG instead, using the JTAG module I created for the SP Duo programmer.

AVRDUDE sends some commands as ISP commands to the USBasp programmer, which are meant to be sent directly to the target AVR through the SPI interface without interpretation by the programmer.  As the JTAG commands are completely different from ISP, the JTAG module interprets the ISP commands to understand what information AVRDUDE was trying to program or read, and calls the appropriate JTAG function to program or read that information from the target.

I disabled the ISP and TPI modules to make the application small enough to fit into the tiny85 along with my ATtiny85 USB Boot Loader.

At the end when all the JTAG functionality was working, I made a few changes to make it easy to change the target hardware specifics used by the USBasp firmware.  It worked on the ATtiny85 without issues.


At the moment I just have a prototype circuit wired up on a protoboard.  It connects to USB just like the vusbtiny, and drives the JTAG lines through a level-shifting buffer.  The buffer allows for programming a  low-voltage target, so the TDI/TMS/TCK lines will not exceed the maximum input voltage of the target (usually Vtarget + 0.5V).

With only four pins available for JTAG and four signals required, I didn’t have an extra pin to drive the output enable on the buffer.  I realized that the TCK line was normally driven low during programming, with just short pulses high to cycle the JTAG clock.  I’m driving the output enable line using TCK through an open collector buffer with a very weak pullup, which will stay low (outputs enabled) during programming.

tinyJTAG prototype connected to AVR Butterfly

I’m putting the finishing touches on a PCB, and will post the finished design when I’m ready to order the first samples.

Eagle files are available here: tinyJTAG/circuit on github

Known Issues

The programmer is unable to program individual bytes in flash, as AVRDUDE doesn’t send a page write command after each byte.  The SP Duo has the same issue, as well as the STK500 when used with AVRDUDE.

Future Improvements

Speed improvements

  • Reading from flash is slow, with 25 seconds just to do the USB transfer of 128kB of data, and 40 seconds total when doing JTAG reads and the USB transfer.
  • Figure out how to speed up paged read/write

I’d like to release the JTAG module separately as something other programs can easily use

  • Among other things, I should clarify if the “length” and “address” variables refer to words or bytes

It would be nice to add an option for simultaneous JTAG and ISP support, so a mega8-based USBasp programmer can have the same functionality as the SP Duo.  The programmer could auto-detect which interface was connected to the programmer.

<< Back to Project Overview