lowcost attiny tpi flasher - usb

Go To Last Post
41 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Discussion thread for this project:

http://www.avrfreaks.net/index.p...

It's a driverless generic USB bitbanger customized for TPI flashing based on ATTiny25.
Full src, HW and ATTiny10 sample project included.

Cheers,
PRosendahl

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

May i suggest that the schematic is also included in some eagle exportable graphics format , jpg,png or ...

Then non eagle users can see it

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@Bingo:
I will do that ASAP!

For now, I hope this info is enough:
it's a normal V-USB connection for VCC=5V operation (pullup D- with 1.5kR; D+ and D- with 3.6V Zdiodes to ground and connected via 68R to DBx of ATTiny25). Please check the src to find out where to connect D+ and D- (usbconfig.h). I think D+ has to go to PB2 because of INT0, and D- was connected to pin3 (PB3?).

Connect the ATTiny10 so that S_HIGH and S_LOW trigger the /RESET line.
D_HIGH and D_LOW shall drive the PB that is connected to TPIDATA. Data-PB must be connected via 1kR to TPIDATA.
Q_READ shall read the PB that is connected to TPIDATA.
C_HIGH and C_LOW must drive the PB connected to TPICLK.
VCC and GND of the ATTiny10 are directly connected to VCC and GND of the USB. So the CPU will be running as soon as you plug it in.

Don't forget to filter the VCC, eg put a 4.7uF between VCC and GND.

I wrote that from memory, but I'm sure that's how I constructed it.

FYI: the schematic was done using the free version of Eagle.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

uploaded the schematics as PNG
uploaded the USB flasher fuses

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you :-)

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

- updated .NET application to read signature and program fuses
- updated .NET application to handle RESET line as high/low active

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

- updated .NET application 1.2 (fix)
- uploaded another sample ATTiny10 application (PWM mode demo)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I tried it in Virtalbox with Win XP guest and Linux host. I can see the device in lsusb (Bus 004 Device 013: ID 16c0:05df VOTI) and I can connect it to Win guest in Virtualbox. But the programming application doesn't work, when trying to read it just prints "Opening USB device failed". I don't know if it's due to the extra layer which goes through Linux first or if I miss something on the Windows side. I'll try it in native Win XP at work later.

jnd

ASM programmer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Now I tried it under regular Win XP SP3 and it's same "Opening USB device failed". I reprogrammed the tiny25 in professional programmer just to be sure. I can see it in device manager but that's all.

jnd

ASM programmer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

do you haave VisualStudio? Then you can trace into the "connect()" function to check what's going wrong.
I'll upload a new version with faster programming/verifying this evening. I will add some error messages.

BTW: I am developing on a Mac via VMware Fusion.

Last Edited: Fri. Mar 19, 2010 - 07:14 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

- updated .NET application 1.3:
- "fast flash" (7 secs for entire chip)
- verification is faster (4 secs)
- more error messages

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't have VisualStudio so thanks for the update. Now I'm getting this:

Found the device on the USB bus
Too many IDLE bits (when I try more times, sometimes this line is missing)
Opening USB device failed

Hope it helps. Just some thought: couldn't be problem in timing since it uses only internal RC? Does it calibrate on the fly from USB timing?

jnd

ASM programmer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

the attiny10 isnt responding.

try clearing the checkmark from "reset is high active". does that help?
the next version that I will upload will have that checkmark off by default.

you might need to unplug/plug the programmer to reset it.

there is a free version of VS2008.

to answer the question:
the attiny25 calibrates itself to about 16.5MHz from some USB reset timing. The USB device it correctly discovered, so there are no probs.

there is a prob with the connection to the attiny10.

Last Edited: Fri. Mar 19, 2010 - 09:30 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

- updated .NET application 1.4 defaults to "reset line is low active" which is consistent with the published schematics

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm sorry I had one miswiring to the tiny25, missed it by 1 pin. It's always good to recheck the wiring :) So it works fine now, reading and programming, with the RESET high active unchecked.

When I saw the Opening USB device failed, I thought it means problem in communication with tiny25 since it is the USB device, not the tiny10 target. It would be nice if you can print something like Connecting to programmer... OK/Failed and Connecting to target... OK/Failed. With that I could see where is the problem.

Some other suggestions:
-It's not obvious if the verify was succesful, it prints the result only when it fails.
-Add flash read option and possibly read calibration byte, but that's not so important, it just adds to the completeness.
-When you're deselecting the device at the end, can you make it run the program? I tried also the check RESET high active and that leaves the target running so it looks like it's inverted or maybe you wanted keep it in reset? If yes you could add checkbox for disconnect state. I tried disconnecting the reset line from tiny25 and adding pull-up but it still needs to be reset by briefly inputing low.
-Does the tiny25 keep all lines hi-Z when not programming?

It's still impressive how simple and easy to make is this programmer. Before this I saw everywhere that minimal AVR for USB was tiny45. Now I could grab the tiny25 which I happened to already have and make good use of it. Thank you for the project!

jnd

ASM programmer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Don't worry about bad wiring - I havent been able to burn a chip even with 12V :) --- yet.

I changed the messages to reflect the connection stage (USB - programmer - target).

It's planned to implement all the tabs from the AVRdragon application. That includes a better fuse-selection dialog, reading/writing the calibration, etc. However calibration is not possible since we dont have a calibration-clock source.

The "RESET high active" option is for a different schematic: in my setup it drives a transistor that drives the 12V-reset voltage. So when I put high on the "S"-pin, it will apply 12V to the reset pin. This is needed because I programmed the RSTDBL fuse.

I had to heavily tweak the USB firmware (with OSCCAL self-calibration) in order to get it into 2048 bytes INCLUDING the bitbanger payload (it's 2044 bytes). That is why a lot of features are missing from the bitbanger side. The firmware was initially developed for flashing an AMIC A25L40P NOR flash - the class for that chip is included in the sources.

I think to truely restart the target, you need to cycle the power.
The "D"-pin is hardwired as output, there is always a signal on it. That is why it's connected via a resistor to the target.
I guess the "C"-pin should also be connected via resistor.
The state of the pins is simply the last value written to them.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What winavr version do you use? Which compiler and linker flags? I'm unable to build it with 2048 bytes (2050 right now), using winavr 20100110, linking libc and libm, and adding these compiler and linker options:

Compiler:
-fno-inline-small-functions
-ffunction-sections
-fdata-sections

Linker:
-Wl,--relax
-Wl,--gc-sections

Felipe Maimon

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The Makefile is included. But I dont know if AVR Studio is using directly, but it reflects what I have added under "Custom Compilation Options":

## General Flags
PROJECT = USB_hid_data
MCU = attiny25
TARGET = USB_hid_data.elf
CC = avr-gcc

CPP = avr-g++

## Options common to compile, link and assembly rules
COMMON = -mmcu=$(MCU)

## Compile options common for all C compilation units.
CFLAGS = $(COMMON)
CFLAGS += -Wall -gdwarf-2 -std=gnu99      -ffreestanding  -DF_CPU=16500000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d 

## Assembly specific flags
ASMFLAGS = $(COMMON)
ASMFLAGS += $(CFLAGS)
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2

## Linker flags
LDFLAGS = $(COMMON)
LDFLAGS += -nodefaultlibs  -nostdlib  -ffreestanding -Wl,-Map=USB_hid_data.map

You cd into the "default" directory and make it there. If the Makefile fails, delete the "dep" subdirectory - it needs to be rebuilt.

The avr-gcc tells me: gcc version 4.3.2 . I just d/l the WinAVR installer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So must be something different in WinAVR 20100110 that is producing a slightly larger code...

edit:

I've compiled it with 2040 bytes by changing main a little bit:

/*	Q_INPUT;
	C_OUTPUT;
	D_OUTPUT;
	S_OUTPUT;
	C_HIGH;
	D_HIGH;
	S_HIGH;
*/
	PORTB = (1<<PB5)|(1<<PB1)|(1<<PB0);
	DDRB = (1<<PB5)|(1<<PB1)|(1<<PB0);

Felipe Maimon

Last Edited: Sat. Mar 20, 2010 - 05:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I had to tweak the code a lot until I got 2044 bytes...

You can always edit USB_CFG_VENDOR_NAME and USB_CFG_DEVICE_NAME in usbconfig.h.

It wont affect the .NET application since it is only comparing the USB ID's.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

fmaimon wrote:
I've compiled it with 2040 bytes by changing main a little bit:

Thanks, I have changed the src accordingly. If we find more of these optimizations, then we can add the TPI protocol.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

PRosendahl wrote:

The "RESET high active" option is for a different schematic: in my setup it drives a transistor that drives the 12V-reset voltage. So when I put high on the "S"-pin, it will apply 12V to the reset pin. This is needed because I programmed the RSTDBL fuse.

can you add this transistor in the schematic as "optional"? Since the tiny10 only has 4 I/Os it might be nice to be able to use the RESET pin as an I/O pin with the option of being able to reprogram it.

great project by the way, keep up the good work!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

2010-03-28:
- schematics for 12V high voltage RESET option (Eagle and PNG)

Actually, the transistor drives the power supply for the 12V-circuit. I am using a "SIM1-0512" for this, but you can save about 1-2Euros by using the cheaper Maxim MAX662A as shown here:
http://www.avrfreaks.net/index.p...

Please note that the RESET pin is a "weak" output pin. The LED is very dim compared to the other pins.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

2010-04-30:
- .NET application: added support for I2C bus
- .NET application: added support for Microchip 24FC256 (I2C flash memory device)
- .NET application: lowlevel bit banger supports async read operations
- .NET application: bug fixes
- .NET application: added screenshots

Project is here:
http://www.avrfreaks.net/index.p...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

2010-10-01:
- .NET application: fixed writing of fuses (will erase chip to reset fuses if necessary)

Project is here:
http://www.avrfreaks.net/index.p...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This project seems nice :-), waiting for my attiny10 to arrive. I have changed the code to run on usbasp hardware instead (atmega8).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Got some questions:

1. Is the 12V programmer used to revive "dead" ATTINY micro-controllers. I have a bunch of ATTINY45s that I accidentally enabled the RSTDISBL bit, and they are no longer responsive. I see that the 12V output applies to the /RESET pin of the target micro-controller.

Can your programmer (via its 12V output) revive other 8-bit Atmel microcontrollers, e.g., ATMEGA8, etc.?

2. Your PWM sound examples look very interesting. Would you kindly describe the methods on how that is worked? And would I need to wire the output to some sort of amplifier IC to an 8ohm speaker for better audio?

Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

works nicely :D thanks (used tiny 25)

tested on -> XP sp3 / tiny 10

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does anyone know the fuse bits that need to be set on the ATtiny25/45/85? I'm guessing just PLL clock?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, I am using Tiny10. Does the programmer works for this type of microcontroller? Can it be programmed with AVR Studio 5?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Good day

Is it possible to port this project to Atmega328p? I've changed USB_CFG_IOPORTNAME, USB_CFG_DMINUS_BIT and USB_CFG_DPLUS_BIT accordingly.

I've set USB_CFG_CLOCK_KHZ to 20000 and soldered crystal on XTAL pins.

makefile was changed accordingly to frequency and mc.

What else should I change?

The device is read with errors and is unknow under Linux and under Win7.

Waiting for your help, if you are interested. Thx.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

:oops: never mind. Got your question wrong...

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
D- requires a pull-up of 1.5k to +3.5V (and the
device must be powered at 3.5V) to identify as low-speed USB device.

It's written in usbdrv.h. So my mega328p can't be used with 20MHz clock. Am I wrong?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think I've found my fault.

It's hardware problem, I think, because I've soldered diodes, but they are not zener 3.3V and it's important to use definitely this type.

But if you have any suggestions, plz tell me.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Okay, the device is working, but I get

"TPIIR reads back value 0 expected 128"

message. What does that mean and what should I do to fix that? I'm using attiny85 powered by 3,3V without zener diodes on usb lines.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AFIK, the TPI requires 5V for programming voltage.

The USB expects 3.3V on D- and D+ lines

The Tiny can operate between 1.8V and 5.5V.

So I suggest that you use 5V from the USB cable.
I guess that the logic signals will work fine during TPI programming whether they are 3.3V or 5V.

Regarding zeners on the D+ and D- lines. It is very important to use the correct part number. The nominal 3.3V zener is only 3.3V at typical currents. If you only send 1mA through the zener, a 400mW device will probably be 3.0V, a 1.5W device will probably be 2.5V.

You have to check the data sheets of your particular zener diode.

I can't help feeling that a $3.60 Chinese usbasp is the easiest (and cheapest) way to do TPI.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thx, David.

Ok, the device magically started to work, but there is a problem.

The device reads signature properly, but at the programming attempt it says "Too many IDLE bits. Target is not responding" and waits for my decision to continue programming. I'll try to verify whether it programmes properly.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I looked at the schematic and parts list.
They seem to use 1N5333 part.

Looking at the

Quote:
Figure 8. Zener Voltage versus Zener Current
VZ = 3.3 thru 10 Volts
in the Motorola data sheet. The 1N5333 seems to be a 5W part. As opposed to the specified 3.3V @ 380mA, it is 1.5V @ 1mA.

I also note that the D+ and D- lines have no series resistors. So your PC will attempt to pump as much current as it possibly can. i.e. probably 100mA or so. consequently 2.8V @ 100mA

If you want to use zeners, choose the 200mW or 400mW devices with a 68R series resistor in the D+, D- lines.

No, I have no idea about your "Too many IDLE bits. Target is not responding". However, I would get the USB electrical interface fixed first.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Project links posted in this thread appear dead.  If author is still here... can you update?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This thread is old enough to have started on the "legacy" site so maybe try searching there ?

 

EDIT: well I tried that with no luck. But here on the new Freaks I found:

https://community.atmel.com/proj...

 

Is that not what you require?

Last Edited: Wed. Mar 15, 2017 - 05:05 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hey, how about that?  Right on.  Thanks clawson.