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:
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?
"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:
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.
Upload ArduinoISP sketch to UNO (what should the Programmer be set to at this point, because I already changed it and I dont remember )
Select programmer > Arduino as ISP - check
Select the ATtiny85 - check
Select 8MHz internal - check
Select bootloader option from Tools menu (is this the same as Burn the bootloader step?)
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?
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.
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?
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)
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.
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.
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.