Go Down

Topic: Programming ATtiny85 with UNO R3 as ISP (Read 1 time) previous topic - next topic

Marciokoko

Jul 01, 2017, 12:46 am Last Edit: Jul 01, 2017, 12:47 am by Marciokoko Reason: image
Ok, Ive reached the point where I have to shrink a project significantly that I need a tiny.  Its a simple flexiforce resistor strip project so I think itll be enough.

Ive read a couple of tutorials about programming an attiny85 from an R3 as an ISP:

Arduino as ISP

and after wiring everything I tried uploading the blink sketch with ledpin = 0 as explained, and I got this:

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

...down to 10 tries.  I checked my board and config settings in the tools menu:



and I googled some and ran into this:
post-about-error


where the guy at the end recognizes he didnt upload the ArduinoISP to the UNO before uploading the Blink to the tiny.

I know some of you will say "why didnt you try it instead of asking us here..."

Well because Im wandering into chip programming and mentions of bootloader which scare me and I dont want to 'brick' (if thats even possible) my only attiny.  So I wanted to make sure before trying it.

So here it is: do I need to upload the ArduinoISP sketch which I just found in the Sketchbook list onto the R3 and then upload the Blink?  Do I need to remove the attiny from its connections to the UNO R3 before uploading the ArduinoISP sketch to the UNO-R3, or can I leave those in place and just upload one sketch and then the other?

As Im writing im thinking that if anything, I would actually load the ArduinoISP onto the R3 (changing Tools menu config) and then upload the Blink to the tiny (changing Tools menu config again) huh?

kprims

#1
Jul 01, 2017, 03:08 am Last Edit: Jul 01, 2017, 03:14 am by kprims Reason: Added Link.
"As Im writing im thinking that if anything, I would actually load the ArduinoISP onto the R3 (changing Tools menu config) and then upload the Blink to the tiny (changing Tools menu config again) huh?"

That's the way I just did it. Selected burn bootloader first to set fuses for 8Mhz internal and then uploaded blink sketch using pin1. I am using:

https://github.com/SpenceKonde/ATTinyCore

Code: [Select]
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e930b (probably t85)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "/home/kprims/.arduino15/packages/ATTinyCore/hardware/avr/1.1.2/bootloaders/empty/empty_all.hex"
avrdude: writing flash (2 bytes):

Writing | ################################################## | 100% 0.09s

avrdude: 2 bytes of flash written
avrdude: verifying flash memory against /home/kprims/.arduino15/packages/ATTinyCore/hardware/avr/1.1.2/bootloaders/empty/empty_all.hex:
avrdude: load data flash data from input file /home/kprims/.arduino15/packages/ATTinyCore/hardware/avr/1.1.2/bootloaders/empty/empty_all.hex:
avrdude: input file /home/kprims/.arduino15/packages/ATTinyCore/hardware/avr/1.1.2/bootloaders/empty/empty_all.hex contains 2 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.05s

avrdude: verifying ...
avrdude: 2 bytes of flash verified

avrdude done.  Thank you.


I have had fun with these boards and attiny85's.

http://www.ebay.com/itm/1Pcs-For-Attiny13a-Attiny25-Attiny45-Attiny85-Development-Programmer-Board-Ic-L-/231982708227?hash=item36033f3603:g:5f8AAOSwcLxYHbCR

INTP

Are you intentionally trying to run it at 1MHz?

Marciokoko

#3
Jul 01, 2017, 03:55 am Last Edit: Jul 01, 2017, 04:03 am by Marciokoko
No INTP, I dont know what Im doing.  Ive never done this before.

kprims, so I have to:

1. Burn the bootloader.  
- Select 8MHz Internal
- Then select the burn bootloader option from the Tools menu  
2. Upload ArduinoISP sketch to UNO?
3. Upload Blink sketch to ATtiny85?

kprims

"kprims, so I have to:"

Upload ArduinoISP sketch to UNO
-select programmer/Arduino as ISP
-then select attiny85
- Select 8MHz Internal // if you want 8Mhz/// I have used this for simple projects and it works great.
- Then select the burn bootloader option from the Tools menu ///Doesn't actually have a bootloader, just sets the fuses for 8Mhz.
- Burn the bootloader.
-If you have good correct connections this should work
Upload Blink sketch to ATtiny85


Marciokoko

Ok a few doubts:

1. Upload ArduinoISP sketch to UNO (what should the Programmer be set to at this point, because I already changed it and I dont remember :-(  )
2. Select programmer > Arduino as ISP - check
3. Select the ATtiny85 - check
4. Select 8MHz internal - check
5. Select bootloader option from Tools menu (is this the same as Burn the bootloader step?)
6. Burn the bootloader

Q1. What should the programmer be set to before uploading ArduinoISP sketch to UNO?
Q2. Can I have the UNO connected to the attiny85 through the entire process or should I disconnect it when uploading the ArduinoISP sketch to the UNO?

Thanks

INTP

#6
Jul 01, 2017, 04:44 am Last Edit: Jul 01, 2017, 04:44 am by INTP
I don't know if it matters, but it doesn't hurt to unplug everything from the Uno before uploading the ArduinoISP sketch from the examples menu to the Uno. Programmer is usually AVRISP mkII.

Once sketch is uploaded, unpower Uno, hookup ATTiny85, remember the capacitor, power up Uno.
Open IDE, open whatever sketch is to be put on the ATTiny85, pick the correct ATTiny85 chip+settings (8MHz internal), pick the Uno for the port, pick 'Arduino as ISP' for programmer, pick Burn Bootloader, should take just a few seconds, then pick Upload sketch.

Marciokoko

Ok got it!  Now I should be able to disconnect all cables from the tiny and move it over to a 5V circuit and use its pin 0 for the blink program as modified in the sketch?

INTP

Yes, you could do that. Or keep using the Uno as a power source if you're still tinkering with the ATTiny85, as I imagine the blink isn't your end goal. (Unplug everything but the 5V and Gnd)

Marciokoko

Thx INTP, it is not my end goal.  I was actually wondering if I can power a tiny from a couple of CR2032s but Ive read their current output is as low as 190uA which would.

I would power a flex sensor and a piezo buzzer, im thinking a 3.7V lipo-(like for drones) might be better.

Jiggy-Ninja

Quote
1. Upload ArduinoISP sketch to UNO (what should the Programmer be set to at this point, because I already changed it and I dont remember :-(  )
Doesn't matter, because you don't have a programmer yet. Upload it using the normal way, with the Board set to Uno. Then, after you've set things up for the ATtiny85, use the "Upload with Programmer" option.


Quote
Q2. Can I have the UNO connected to the attiny85 through the entire process or should I disconnect it when uploading the ArduinoISP sketch to the UNO?
You can leave it connected.

Your worries about messing up fuses are overblown. A chip cannot change its own fuse bits, so your Uno is completely safe. It's the chip you're trying to program with it (ATtiny85) that you have the potential of messing up, which is fortunately much cheaper.

It's possible to recover a chip no matter what configuration you set it to, but certain ones are much more difficult to recover from. If you accidentally program it to use an external oscillator, you just need to add a crystal to the board to be able to change the fuses. If you accidentally program the RSTDISB bit, you need to use high-voltage serial programming to be able to program the chip again. That requires constructing a charge pump (easier than it sounds) to apply the needed ~12V to the reset pin, a different sketch, and slightly different connections to the target. More of a pain in the ass, but not impossible.

If you accidentally use the regular Upload option instead of Upload with Programmer, it will try to upload the sketch to your Uno instead of the ATtiny85. And it will probably fail because the chip IDs are different. Just make sure to use the Upload with Programmer option every time.

Go Up