VUSBTiny AVR SPI Programmer

Intro: VUSBTiny AVR SPI Programmer



after making a usbtiny isp programmer and using it for 6 months, i was looking at making another one for carrying around. i like the simplicy of the usbtiny isp design but would like to make it even smaller and take less parts. one thing in the original design that i want to change is to eliminate the use of clock crystal. one solution i found is that v-usb drivers supports the 16.5Mhz internal oscillator on attiny25/45/85 devices. so i start out this project to have usbtiny isp employs v-usb for usb communication. the immediate benefits is that it saves space and have less component counts (no more crystals).


usbtiny

description from http://www.xs4all.nl/~dicks/avr/usbtiny/

USBtiny is a software implementation of the USB low-speed protocol for the Atmel ATtiny microcontrollers. Of course, it will also work on the ATmega series. The software is written for an AVR clocked at 12 MHz. At this frequency, each bit on the USB bus takes 8 clock cycles, and with a lot of trickery, it is possible to decode and encode the USB waveforms by software. The USB driver needs approximately 1250 to 1350 bytes of flash space (excluding the optional identification strings), depending on the configuration and compiler version, and 46 bytes RAM (excluding stack space). The C interface consists of 3 to 5 functions, depending on the configuration.


vusb

description from http://www.obdev.at/products/vusb/

V-USB is a software-only implementation of a low-speed USB device for Atmel's AVR microcontrollers, making it possible to build USB hardware with almost any AVR microcontroller, not requiring any additional chip.

video on construction and usage


Step 1: Features and Parts


* programming logic from usbtiny isp, mature avr-dude support
* small foot-print
* minimal components
* powers target device


note that the io lines to the target mcus are not protected. you can add 1k-2k resistors to SCK and MOSI and protect against possible wrong connections


references

based on the works found at

v-usb from framework http://www.obdev.at/vusb/
usbtiny isp http://www.xs4all.nl/~dicks/avr/usbtiny/

parts list

* attiny45/85 (85 is more easier to come by)
* 3.6v zener diodes (1n747,BZX79,..avoid 1W types)
* 68ohm resistor x 2
* 1.5K resistor
* mini breadboard 170 tiepoints
* usb cable (dollar shop usb printer cable is fine)
* 1k/2k resistors for io lines protection (optional)

tools required

* a working avr programmer (yes, it's a catch22, we need one to make one)
* working avr programming environment


Step 2: Breadboard Layout, Schematic, and Construction


construction

* follow breadboard layout, there ain't that may components, 3 resistors, 2 diodes, 1 cap, plus an 8 pin mcu.
* get a dollar shop usb printer cable cut off the printer end, there will be 4 exposed wire, secure and make them into a 4 pin male header, we will use it to connect to the breadboard. consult schematic for layout and pin assignment (J1).
* watch out for diode polarity.

building and flashing the project

the project was built in a linux ubuntu lucid box with avr-gcc toolchain. it is assumed you already have such an environment, or you can find out from the internet how to setup one up. source codes are gnu gpl v2 licensed from inheritence.

the source code follows a convention recommended by v-usb, you can download the source package vusbtiny.tgz and untarred in into a project directory. within your source directory, there is a main.c, which is my version of modified usbtiny programmer. and a usbdrv sub-directory, which contains the v-usb layer. please observe licensing term from the above two projects when building this. my source on the programmer logic is based on Dick Streefland version and not the ladyada version (although they are almost the same).

for those who do not have a build too-chain, you can use the following binary

click to download vusbtiny.hex

and use avrdude to flash firmware

avrdude -c usbtiny -p t45 -e -V -U flash:w:usbtiny.hex

(if your device is a tiny85, replace -p t45 w/ -p t85)


source can be download here
click to download vusbtiny.tgz

untar the source package into your working directory

tar -zxvf vusbtiny.tgz

* do cd vsubtiny, to change into vusbtiny working directory
* ajust makefile for target device according to the chip you will be using. i.e. PROGRAMMER_MCU=t45 or t85
* do a make
* attach your favorite ISP programmer
* modify makefile and change your avrdude parameters if needed. the stock one assumes USBTiny programmer. i.e. AVRDUDE_PROGRAMMERID=usbtiny
* flash firmware via make install

after flashing firmware, we need to properly set the fuse, we are using pin 1 reset as io in this project

* ppl clock used as required by v-usb layer for usb timing
* reset pin disabled as we need to use it as io

avrdude -c usbtiny -p t45 -V -U lfuse:w:0xe1:m -U hfuse:w:0x5d:m -U efuse:w:0xff:m

this setting disables further programming via 5V SPI as we need the RESET pin (pin1) for io. you will need access to a HVSP programmer to recover the fuse.


Step 3: Usage and Application


direct flashing on breadboard

if you are using vusbtiny to flash 8 pin AVR devices, you can just press your target device on top of the programmer device. the programmer had been designed so that the programming pins matches w/ targets. there is one trick though, you will need to isolate pin 2 and 3 on the programmer mcu, as they are the USB D+ and D- pins connecting to the PC. i use a cut of scotch tape to achieve this, you can see it on the photos. show below is a tiny13v "riding" on the tiny45, ready to receive firmware.

ISP flashing via jumper

to program a target circuit via ISP (in-system programming), you need an ISP cable. here i am not using the standard 2x3 or 2x5 pin headers. instead i am using a 1x6 jumper which is more breadboard friendly, you can make 2x3 or 2x5 pin header by mapping them to J2 as shown on the breadboard layout and schematics. the following photo shows an tiny2313 ready to get flashed via ISP.

troubleshooting

* cannot flash the firmware? check your original programmer, might need to adjust timing via -B flag in avrdude. try to read chip 1st, may be a bad fuse, may be your chip need an external clock signal. you may need to fix your chip back to default 1st.
* check connections
* if use different io pins, check code and connections
* you may substitute zener diodes w/ 500mw, 400mw types
* you may try reduce R3 value to 1.2K or less
* you are more likely to encounter avrdude timing problems, try -B flag of avrdude, have a shorter USB cable all helps

5 People Made This Project!

Recommendations

  • Tiny Home Contest

    Tiny Home Contest
  • Furniture Contest 2018

    Furniture Contest 2018
  • Fix It! Contest

    Fix It! Contest

71 Discussions

0
None
necko

5 years ago on Introduction

Need help on swapping PB3 and PB4.
Modified usbconfig.h as below and flash the attiny85.
#define USB_CFG_DMINUS_BIT 3
#define USB_CFG_DPLUS_BIT 4
I monitor reset line.
It stay high for a few seconds and then started pulsing.

I think I have to modified MCUR setting but do not know how.
Can you please help?
Thanks.

1 reply
0
None
marc_rivesnecko

Reply 9 months ago

That's why my cheap chinese development borad wasn't working!

I simply had to swap DMINUS and DPLUS lines (and change makefile settings).

It's working great now!

0
None
jessekey7

1 year ago

this worked avrdude -v -pt85 -cstk500v1 -b19200 -U flash:w:vusbtiny.hex

set com port of programer to 1

0
None
jessekey7

1 year ago

does it need drivers because i says that windoes does not recognise the usb device

0
None
PeterK138

2 years ago

Hi guys correct way to upload that using arduino:
HEX: avrdude -P com3 -b 19200 -c avrisp -p attiny85 -v -e -U flash:w:usbtiny.hex
FUSE:

avrdude -P com3 -b 19200 -c avrisp -p attiny85 -v -e -U lfuse:w:0xff:m -U hfuse:w:0xdf:m

0
None
stearmanmark

3 years ago on Introduction

Hello all,

Just finished assembling a USBtinyISP. As always I have double check my soldering and component placement. However when I connect the USB plug to my computer

I get a Power surge window. Reads as follows

Power Surge on Hub USB Port. device has exceeded the power limits.

This a large computer I am sure the little programmer does not exceed the limits.

Any hints ? Seen this before?

0
None
ANDREIS6

3 years ago on Introduction

I built this but it doesnt work.I got the same error as Badetise.

I used 100 ohms instead of 68.They are the probem?

As pull-up i used a 1,8kohm resistor.Also i added a led with a 1,8kohm resistor between Vcc and CND.I also used a 47microfarad electrolitic cap.If anybody can help?

Thanks.

1 reply
0
None
Badetise

3 years ago on Introduction

Hi, I just built this, but when I try to flash a program, it says "avrdude: Error: Could not find USBtiny device (0x1781/0xc9f)". I have double and quintuple checked all of my connections, I am completely stumped. Any help would be greatly appreciated, Thank you!

For more clear about how to load a hex file in microcontroller you can browse this video.
https://www.youtube.com/watch?v=4rHWzO7tqQc

0
None
pouic13

3 years ago on Introduction

Hello,

I realized the programmer with an attiny45 and it's work very well.

But now i want to try with a tiny85 and I can not compile the source.

i recieve this errors and many others:

usbdrv/usbdrv.h:455:6: error: variable ‘usbDescriptorDevice’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
char usbDescriptorDevice[];

Do you have the same results or i don't have the goods ressources?

0
None
spiess

6 years ago on Introduction

This is really a great little project! I built it on a little stripe of of prototype board and arranged it in such a way that one end of the prototype stripe also serves as a usb plug.

Every thing worked perfectly on the first try - so big congratulations for presenting such a useful project and making things so simple and the instructions so precise!

Thanks!!!

vusbtiny.jpg
1 reply
0
None
skootles

4 years ago on Introduction

Built one of these and it works great! Do you know if there are any limitations? For example, Adafruit's USBtinyISP kit can't program any AVRs that have over 64k of flash like the Atmega1281/1280/2561/2560. I don't have any of those AVRs on hand to test.

Also, I built one and it takes about 2 minutes to burn the Arduino bootloader to an ATmega328. Do you know what could be done to speed that process up, at all?

0
None
dan3008

4 years ago on Introduction

Wish there was a way of doing this without needing an avr programmer... Ah well, Teach me for looking for the easy way out

2 replies
0
None
dan3008dan3008

Reply 4 years ago on Introduction

Just a thourght, do you know if its possible to get the ATtiny45/85 preprogrammed with vusbtiny?

0
None
simpleavrdan3008

Reply 4 years ago on Introduction

Not from me. I have not do an AVR for more than one year. On MSP430 now. If you have friends that got a programmer, you can download the hex and have him flash one for you. Or try local avr forums. It might be wiser to get a programmer from ebay. They are about $3 shipped nowadays.

0
None
dzervas

4 years ago on Step 3

When I plug it in the USB i get in dmesg:

[257309.496223] usb 4-1.1: new full-speed USB device number 50 using ehci-pci
[257309.562747] usb 4-1.1: device descriptor read/64, error -32
[257309.732580] usb 4-1.1: device descriptor read/64, error -32
[257309.902371] usb 4-1.1: new full-speed USB device number 51 using ehci-pci
[257309.968926] usb 4-1.1: device descriptor read/64, error -32
[257310.138778] usb 4-1.1: device descriptor read/64, error -32
[257310.308634] usb 4-1.1: new full-speed USB device number 52 using ehci-pci
[257310.714804] usb 4-1.1: device not accepting address 52, error -32
[257313.126003] hub 4-1:1.0: connect-debounce failed, port 1 disabled

Any help appreciated...