Programming with ArduinoISP from Arduino IDE

I downloaded ArduinoISP to my Uno so I could program an attiny44 from the Arduino IDE (version 1.8.9). After trying just about every sensible Programmer, I switched to using avrdude (Version 6.3-20171130) from the command line.

I found that I had to use -c stk500v1 and -b19200 (or -c avrisp and -b19200) to get ArduinoISP to successfully communicate with the attiny44.

There were no Programmers in the Arduino IDE that used those particular settings for avrdude. So, what Programmer should be selected in the IDE when using ArduinoISP as a programmer? Is there a baud rate setting missing in the programmers.txt file for ArudinoISP?

Thanks,

Ag Primatic

agprimatic:
So, what Programmer should be selected in the IDE when using ArduinoISP as a programmer?

Tools > Programmer > Arduino as ISP

It's quite confusing that the sketch name is ArduinoISP and there is a Tools > Programmer > ArduinoISP as well as a Tools > Programmer > ArduinoISP.org, neither of which has anything to do with the ArduinoISP sketch. Luckily, there are a ton of tutorials available all over the Internet on this topic.

agprimatic:
There were no Programmers in the Arduino IDE that used those particular settings for avrdude.

Arduino recently changed the Arduino as ISP programmer to use the arduino protocol instead of stk500v1. The reason for that change is to allow native USB boards like the Leonardo and Micro to be used as Arduino as ISP programmers. The side effect of that change was that it made it more likely that non-native USB boards like your Uno would require a 10 uF capacitor to be connected between the reset and ground pins in order to work as an Arduino as ISP. This may be the explanation why you had difficulty using your Arduino as ISP via the Arduino IDE.

That protocol change has since been reverted and a new "Arduino as ISP (ATmega32U4)" programmer added to avoid this inconvenience but there has not been a new release of Arduino AVR Boards since that time.

OK, I tried using "Arduino as ISP", and this is what was output during the attempted programming:

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -pattiny44 -carduino -P/dev/cu.usbmodem4421 -b19200 -Uflash:w:/var/folders/hn/jd02xm_s5h38hf_f_j8fyzgm0000gp/T/arduino_build_59602/chipi5x8test.ino.hex:i 

avrdude: Version 6.3-20171130
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/ag/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/cu.usbmodem4421
         Using Programmer              : arduino
         Overriding Baud Rate          : 19200
         AVR Part                      : ATtiny44
         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        256    4      0  4000  4500 0xff 0xff
           flash         65     6    32    0 yes      4096   64     64  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 : Arduino
         Description     : Arduino

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x14

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x02

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x10
         Hardware Version: 425479
         Firmware Version: 8420868.-1451118764
         Topcard         : STK502
         Vtarget         : 1.8 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: stk500_initialize(): (b) protocol error, expect=0x10, resp=0x01
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x10

avrdude done.  Thank you.

the selected serial port 
 does not exist or your board is not connected

The Arduino ISP is using -c arduino and -b 19200, but I had to use -c avrisp -b 19200 on the avrdude command line.

I checked the ArduinoISP code from Examples in the IDE, and it matches what is in GitHub.

Thanks,

Ag

Did you connect a 10 uF capacitor between the reset and ground pins on your Uno?

Thank you. The 10uF capacitor between reset and ground worked.

But, I'm still curious as to why -c avrisp worked without the 10uF capacitor and -c arduino did not. Maybe it's worth providing a way to set the programmer baud rate from the IDE without modifying programmers.txt?

It would be nice if we didn't have to add any components to the Uno just to get it to act like a programmer.

Thanks again for your help.

Ag

agprimatic:
Thank you. The 10uF capacitor between reset and ground worked.

You're welcome. I'm glad to hear it's working now.

agprimatic:
I'm still curious as to why -c avrisp worked without the 10uF capacitor and -c arduino did not.

The DTR pin of the USB to TTL serial adapter chip on your Uno is connected to the reset pin of the ATmega328P via a 0.1 uF capacitor. When the DTR pin is asserted, this circuit causes the ATmega328P to reset. That reset is needed to activate the bootloader on the ATmega328P so that you can upload a sketch. The old Arduino boards didn't have this auto reset circuit and so you needed to manually press the reset button at just the right time during every upload. The arduino protocol is designed for this auto reset behavior.

When using an Uno as an Arduino as ISP, if the auto reset circuit causes the Uno to reset this will make it not work properly because the bootloader will be running instead of the ArduinoISP program. The solution is to disable the auto reset circuit with the 10 uF capacitor.

agprimatic:
Maybe it's worth providing a way to set the programmer baud rate from the IDE without modifying programmers.txt?

This has absolutely nothing to do with baud rate. The baud rate is 19200. If you added a programmer baud rate menu to the Arduino IDE it would just cause a ton of problems.

agprimatic:
It would be nice if we didn't have to add any components to the Uno just to get it to act like a programmer.

As I already said, the change that required you to use the 10 uF capacitor has already been reverted for the next release of Arduino AVR Boards:

Some people have actually reported needing the capacitor even with the stk500v1 protocol. Some don't need it even with the arduino protocol. So it's a bit of a complicated situation. It never hurts to use the capacitor (though you have to remember to remove it before trying to upload a sketch to the programmer board again), but on the other hand many Arduino users are not going to happen to have a 10 uF capacitor on hand so it is nice to be able to do without. I think the Arduino as ISP documentation could be improved to explain the capacitor better.