ATTiny85-20SU Flashing

454 views
Skip to first unread message

Benjamin Blundell

unread,
Nov 9, 2016, 5:36:43 AM11/9/16
to london-h...@googlegroups.com
Hello LHS crew! I wondered if anyone could help me with a project I've been working on please? Im having problems flashing my ATTiny85 chip.

I have a circuit thats very simple, involving a screen and this surface mount chip. I've bought 100 of them brand new from RS, here in the UK. I've breadboarded the design using a through-hole version of the chip and that all works fine.

I'm using a buspirate v3 and avrdude under Arch linux to do the flashing, with avr-gcc.

Sadly, my surface mount version doesn't work. I've checked all the connections and even tried a second chip. No dice. Here is the output from avrdude


sudo avrdude -c buspirate -p t85 -P /dev/ttyUSB0 -U flash:w:invite.rom -Ulfuse:w:0x42:m -Uhfuse:w:0xdf:m -U efuse:w:0xff:m -F

Attempting to initiate BusPirate binary mode...
avrdude: Paged flash write enabled.
avrdude: initialization failed, rc=-2
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x489bd2
avrdude: Expected signature for ATtiny85 is 1E 93 0B
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.

avrdude done.  Thank you.

make: *** [Makefile:5: all] Error 1
[oni@motoko WeddingInvite]$ vim Makefile
[oni@motoko WeddingInvite]$ make
avr-gcc -I./include/ src/invite.c src/softspi.c src/smallfont.c -Os -o invite.elf -mmcu=attiny85
avr-objcopy -O ihex invite.elf invite.rom
sudo avrdude -c buspirate -p t85 -P /dev/ttyUSB0 -U flash:w:invite.rom -Ulfuse:w:0x62:m -Uhfuse:w:0xdf:m -U efuse:w:0xff:m -F -v

avrdude: Version 6.3, compiled on Feb 21 2016 at 13:33:25
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/root/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyUSB0
         Using Programmer              : buspirate
         AVR Part                      : ATtiny85
         Chip Erase delay              : 4500 us
         PAGEL                         : P00
         BS2                           : P00
         RESET disposition             : possible i/o
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     6     4    0 no        512    4      0  4000  4500 0xff 0xff
           flash         65     6    32    0 yes      8192   64    128  4500  4500 0xff 0xff
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00

         Programmer Type : BusPirate
         Description     : The Bus Pirate

Attempting to initiate BusPirate binary mode...
BusPirate binmode version: 1
BusPirate SPI version: 1
avrdude: Paged flash write enabled.
AVR Extended Commands not found.
avrdude: initialization failed, rc=-2
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x480bf3
avrdude: Expected signature for ATtiny85 is 1E 93 0B
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
BusPirate is back in the text mode

avrdude done.  Thank you.




What I'm seeing here is the signature is changing each time :/ This suggests some kind of clock issue right?

My design does not have an external clock - its very simple and I believe that ATTiny85-20SU are set to use a 1MHz internal oscillator by default, which is what I'd like. Can anyone see where I've gone wrong? Do I need to wire in some kind of crystal just for the first flashing?

Cheers

Ben

Adrian Godwin

unread,
Nov 9, 2016, 5:47:20 AM11/9/16
to london-hack-space
It didn't actually get the second signature from the device, did it ? I think it read junk.

I did use buspirate for programming some 328s but it was incredibly slow. There's some custom programming code that's faster but you have to reprogram the buspirate : maybe that 'avr extended commands' substitutes for it. Mostly, I use a Minimus programmed to be an avrusb programmer.

--
You received this message because you are subscribed to the Google Groups "London Hackspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to london-hack-space+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Benjamin Blundell

unread,
Nov 9, 2016, 5:49:50 AM11/9/16
to london-h...@googlegroups.com
I'm reluctant to change from the buspirate because it works on the through-hole ATTiny85 that I have with the same circuit, so it has to be something different with that chip or how it comes out of the factory. It may be it needs an external clock that isn't set correctly on the CLK line. But I wouldn't know where to begin with that.

Adrian Godwin

unread,
Nov 9, 2016, 5:51:44 AM11/9/16
to london-hack-space
I'm pretty sure the programming protocol doesn't need a crystal - it uses the SPI clock and the internal oscillator.

Benjamin Blundell

unread,
Nov 9, 2016, 5:53:59 AM11/9/16
to london-h...@googlegroups.com
Then I wonder if, some some reason the clocking is wrong for the surface mount chip vs the through-hole? Its likely the through-hole one has had something done to it. The datasheet doesnt really say too much about how the 20SU version differs from the stock ATTiny85. I wonder if this is something to do with it?

Adrian Godwin

unread,
Nov 9, 2016, 5:59:11 AM11/9/16
to london-hack-space
There are some 'fuses' that can prevent programming - you need to use high-voltage programming mode to change them. But I wouldn''t expect a fresh device to have those set.

http://www.instructables.com/id/AVR-Attiny-fusebit-doctor-HVSP/

Benjamin Blundell

unread,
Nov 9, 2016, 6:02:25 AM11/9/16
to london-h...@googlegroups.com
Yes, I saw some high voltage stuff. Not a road I can really go down - time and money constraints sadly. Also I agree, the default factory settings *should* be fine for this. I'm quite stumped.

Paddy Duncan

unread,
Nov 9, 2016, 6:08:49 AM11/9/16
to london-h...@googlegroups.com, pad...@padski.co.uk

Maybe not the case, but have the tried the –F option to force past the wrong signature?

--

To unsubscribe from this group and stop receiving emails from it, send an email to london-hack-sp...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

 

--

You received this message because you are subscribed to the Google Groups "London Hackspace" group.

To unsubscribe from this group and stop receiving emails from it, send an email to london-hack-sp...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "London Hackspace" group.

To unsubscribe from this group and stop receiving emails from it, send an email to london-hack-sp...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "London Hackspace" group.

To unsubscribe from this group and stop receiving emails from it, send an email to london-hack-sp...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "London Hackspace" group.

To unsubscribe from this group and stop receiving emails from it, send an email to london-hack-sp...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "London Hackspace" group.

To unsubscribe from this group and stop receiving emails from it, send an email to london-hack-sp...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "London Hackspace" group.

To unsubscribe from this group and stop receiving emails from it, send an email to london-hack-sp...@googlegroups.com.

Benjamin Blundell

unread,
Nov 9, 2016, 6:16:34 AM11/9/16
to london-h...@googlegroups.com
Yes, I use the force option to actually get the signature in the first place. AVR-DUDE is correct in that the datasheet says I should be able to read the signature.

--

To unsubscribe from this group and stop receiving emails from it, send an email to london-hack-space+unsubscribe@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

 

--

You received this message because you are subscribed to the Google Groups "London Hackspace" group.

To unsubscribe from this group and stop receiving emails from it, send an email to london-hack-space+unsubscribe@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "London Hackspace" group.

To unsubscribe from this group and stop receiving emails from it, send an email to london-hack-space+unsubscribe@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "London Hackspace" group.

To unsubscribe from this group and stop receiving emails from it, send an email to london-hack-space+unsubscribe@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "London Hackspace" group.

To unsubscribe from this group and stop receiving emails from it, send an email to london-hack-space+unsubscribe@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "London Hackspace" group.

To unsubscribe from this group and stop receiving emails from it, send an email to london-hack-space+unsubscribe@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "London Hackspace" group.

To unsubscribe from this group and stop receiving emails from it, send an email to london-hack-space+unsubscribe@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "London Hackspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to london-hack-space+unsubscribe@googlegroups.com.

Adrian Godwin

unread,
Nov 9, 2016, 6:19:10 AM11/9/16
to london-hack-space
I don't tend to trust the force option. It may be useful if you've accidentally changed the signature, but I tend to feel that if you have to ignore it, it's probably not communicating correctly and therefore won't do anything right.

Stephen Casey

unread,
Nov 9, 2016, 6:45:18 AM11/9/16
to London Hackspace
Hello,

Please forgive me for potentially stating the obvious, but it's worth checking that the power rail is good, and decoupled, and the ground (and signal) programming connections are sound, and not causing problems. I've seen issues like this with PIC programming when signal integrity wasn't great.

Good luck.

Stephen.

Benjamin Blundell

unread,
Nov 9, 2016, 6:50:44 AM11/9/16
to london-h...@googlegroups.com
Hello Stephen.

That is interesting and I'm not too sure how I'd ensure that. I've soldered up two of the boards. One has all the parts (a cap, resistor, led and screen) and the other just has the chip. What I could do is link the board to my bench power-supply and go with that?

Its worth pointing out that this design runs off a battery. I've tried flashing with the battery both in and not.

Cheers

B

Adrian Godwin

unread,
Nov 9, 2016, 7:03:54 AM11/9/16
to london-hack-space
Are any of the components on the board sharing programming pins ? A cap on reset would be bad.

Benjamin Blundell

unread,
Nov 9, 2016, 7:10:55 AM11/9/16
to london-h...@googlegroups.com
Yes they are, which is why I tried just using a board with the chip and nothing else. A cap on reset you say? The only cap I believe comes off the screen component (Nokia 5110 screen) and down to ground.

Stephen Casey

unread,
Nov 9, 2016, 10:12:25 AM11/9/16
to London Hackspace
This is most peculiar. If you've correctly connected just the chip, and no other parts at all, and it still isn't working, then I think that those more experienced with the specifics of the ATTiny are more qualified to offer advice. I haven't done much at all with the AT devices, or the Bus Pirate, I'm afraid. I have had loads of experience with other in-circuit programming, and it can definitely cause headaches!

I am, however, intrigued to find out the solution. Good luck with it.

Stephen.

Evan Davey

unread,
Nov 9, 2016, 5:26:39 PM11/9/16
to London Hackspace
I've experienced this before and solved it with the brute force solution of holding an external crystal over the pins whilst programming the fuse bits to use the internal clock. From then on, normal programming worked.

Benjamin Blundell

unread,
Nov 9, 2016, 6:41:01 PM11/9/16
to london-h...@googlegroups.com
So the consensus on the arduino forums appears to be coupling caps. Whilst my EE friend says this would only result in intermittant and not outright refusal to work, I wonder if there is something in that? Here is the circuit and board I have





On 9 November 2016 at 22:26, Evan Davey <evan....@ekidna-engineering.com> wrote:
I've experienced this before and solved it with the brute force solution of holding an external crystal over the pins whilst programming the fuse bits to use the internal clock. From then on, normal programming worked.

Adrian Godwin

unread,
Nov 9, 2016, 6:44:07 PM11/9/16
to london-hack-space
I would certainly add a capacitor between Gnd and Vcc on the AVR. 100nF or so.
It's true that will probably only cause intermittent problems .. but it might be on 1 in 10 or 20 clock edges, not 1 in 10 or 20 programming attempts. Pretty much kills any chance of communication.

I don't see that it would be any better on a DIP package though.




On Wed, Nov 9, 2016 at 11:40 PM, Benjamin Blundell <onid...@gmail.com> wrote:
So the consensus on the arduino forums appears to be coupling caps. Whilst my EE friend says this would only result in intermittant and not outright refusal to work, I wonder if there is something in that? Here is the circuit and board I have




Adrian Godwin

unread,
Nov 9, 2016, 6:45:05 PM11/9/16
to london-hack-space
I'd probably give the Nokia screen a 10uF cap as well, especially if it has a backlight.

Benjamin Blundell

unread,
Nov 9, 2016, 6:45:16 PM11/9/16
to london-h...@googlegroups.com
Yeah thats the wierd thing isnt it? I've never needed a coupling cap on any of the AVRs I've worked on. Coupling caps are some kind of wierd voodoo :/

Benjamin Blundell

unread,
Nov 9, 2016, 6:45:38 PM11/9/16
to london-h...@googlegroups.com
Yeah it has no backlight but it is capped on it's vout line

Adrian Godwin

unread,
Nov 9, 2016, 6:53:36 PM11/9/16
to london-hack-space
It's not too bad a mod - scrape the soldermask off the Vcc trace near pin 5 of the AVR and bridge across to the ground via near pin 4 with a small capacitor.

Worth a try, anyway.

Spike

unread,
Nov 9, 2016, 7:37:40 PM11/9/16
to london-h...@googlegroups.com
On 09/11/2016 23:45, Benjamin Blundell wrote:
Yeah thats the wierd thing isnt it? I've never needed a coupling cap on any of the AVRs I've worked on. Coupling caps are some kind of wierd voodoo :/

To be picky about this - what you are talking about (a capacitor between a supply line and ground) is a decoupling capacitor .

Spike

Benjamin Blundell

unread,
Nov 10, 2016, 4:26:09 AM11/10/16
to london-h...@googlegroups.com
decoupling yes. The only options I can see are:

1) All the chips so far are broken
2) A decoupling cap is needed
3) An external clock is needed for the first flash

Once it's programmed, if it works,  I don't care about flashing it again. It might be possible to do what Adrian describes but it will be really tricky. For now, I'll nip to the space, get the caps I need and try it. If it works great, otherwise its crystal time. If that fails, I'm out of ideas  :/

Cheers
B


--

Liam Lynch

unread,
Nov 11, 2016, 8:46:01 AM11/11/16
to London Hackspace, o...@section9.co.uk
Hi,

You do know it is possible to upload code to a tiny 85 using the arduino and a programmer.

I've done it a number of times and its worked a treat for me.

I wrote quite a long post on it in one of the arduino forums. Look for posts by VideoLiam.

Liam
To unsubscribe from this group and stop receiving emails from it, send an email to london-hack-sp...@googlegroups.com.

Benjamin Blundell

unread,
Nov 11, 2016, 8:57:11 AM11/11/16
to london-h...@googlegroups.com
Thanks Liam. The buspirate I find easier to use because I can avoid all the nonsense that Arduino puts in the way. A single makefile and AVRDUDE is all you need. Besides the buspirate works fine with the through-hole version so although I did look at this, it seemed more complicated and didnt work :(

I tried the decoupling capacitor and that didn't work either.

One thing that I think did help is pulling the RESET pin 8 on the chip to high (3V).

What did appear to work is soldering header pins into the board and reconnecting the buspirate. I have a suspicion the connection to the board was not perfect all the time and although I tested it throughly with the meter, the buspirate connects or the board connects had shifted once I removed the probes (or I was holding it wrong). Soldering seems to have worked.

Sadly, although AVRDUDE reports that the flashing has worked, the screen is blank. My next step is to try and do the classic hello-world-LED-blink test to make sure basic code is executing,

Learning things! :)

Cheers
B


To unsubscribe from this group and stop receiving emails from it, send an email to london-hack-space+unsubscribe@googlegroups.com.

Spike

unread,
Nov 11, 2016, 9:29:01 AM11/11/16
to london-h...@googlegroups.com
There *was* an AVRISP (http://www.atmel.com/tools/AVRISPMKII.aspx) on
loan in the old space Ben - no idea if it is still around.

I found that worked very well for programming AVR devices.

Spike

Benjamin Blundell

unread,
Nov 11, 2016, 11:14:27 AM11/11/16
to london-h...@googlegroups.com
Yeah, I found a random programmer in my drawer that I *believe* is for AVR that I bought off ebay.

Thing is, I briefly saw flickers of life on the screen once in about 50 tries so I think something is still loose and so I just need to sanity check everything, as the buspirate works fine for my through hole ATTiny85

I did think about internal pull-up resistors. My design does not include them because ATTiny85 has internal ones but I dont know if these are activated by default. It is entirely possible that I did *something* many moons ago to my through hole chip that I haven't done to the new ones.

Cheers
B

Adrian Godwin

unread,
Nov 11, 2016, 11:58:55 AM11/11/16
to london-hack-space
They're activated if you set the pin to be an input yet write a '1' to its output register. It's a code option, not a fuse option. Some pins don't have it available (eg the higher numbered analog pins on the a328).

Benjamin Blundell

unread,
Nov 11, 2016, 12:01:49 PM11/11/16
to london-h...@googlegroups.com
Thanks Adrian. I'll double check the code again as I suspect I've set it but worth a look just in case.

Cheers
B
Reply all
Reply to author
Forward
0 new messages