AVR Programmer not working

I am trying to switch programmers from my old Sparkfun AVR Programmer with mini-USB to this nice looking Pololu V2.1.

I have a device in front of me (ATTiny841) that is easily programmed with the old one. Swapping to the Pololu, it does not work.’

avrdude: stk500v2_command(): command failed
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.

The first line is what concerns me. is stk500v2 the correct type to use with avrdude?

#!/bin/bash
PORT=`pavr2cmd --prog-port`
PROG=stk500v2
MCU=attiny841

avrdude -c $PROG -p $MCU -U lfuse:w:0xe2:m -P $PORT

pavr2gui/pavr2cmd run with no problems and I can set the device to provide 5V power.

Another note that I have 5V output enabled but it does not seem to power the target. My code has a beep upon startup that is not heard when using the Pololu programmer. It is heard when using the Sparkfun programmer.

A power cycle of the device and a single programming attempt gives as follows:


greg@grexps:~/megadesk_tindie$ PORT=`pavr2cmd --prog-port`
greg@grexps:~/megadesk_tindie$ PROG=stk500v2
greg@grexps:~/megadesk_tindie$ MCU=attiny841
greg@grexps:~/megadesk_tindie$ avrdude -c $PROG -p $MCU -V -Uflash:w:megadesk-v4.hex:i -P $PORT 
greg@grexps:~/megadesk_tindie$ pavr2cmd -s

Name:                                    Pololu USB AVR Programmer v2.1
Serial number:                           00309332
Firmware version:                        1.02
Programming port:                        /dev/ttyACM0
TTL port:                                /dev/ttyACM1

Settings:
  ISP frequency (kHz):                   1714
  Max ISP frequency (kHz):               1714
  Regulator mode:                        5 V
  VCC output:                            Enabled
  VCC output indicator:                  Blinking
  Line A function:                       None
  Line B function:                       DTR
  VCC/VDD maximum range (mV):            896
  VCC 3.3 V minimum (mV):                2720
  VCC 3.3 V maximum (mV):                3872
  VCC 5 V minimum (mV):                  4128
  VCC 5 V maximum (mV):                  5856
  STK500 hardware version:               F
  STK500 software version:               2.A

Results from last programming:
  Programming error:                     Initial SPI command failed.
  Target VCC measured minimum (mV):      4512
  Target VCC measured maximum (mV):      4832
  Programmer VDD measured minimum (mV):  4800
  Programmer VDD measured maximum (mV):  4832

Current status:
  Target VCC (mV):                       4768
  Programmer VDD (mV):                   4800
  VDD regulator set point:               5 V
  Last device reset:                     Power-on reset

Hello.

It looks like you are trying to program with a high ISP frequency, 1714 kHz. What frequency is your AVR running at? Can you try using the default ISP frequency of 114 kHz? You can set that up by running pavr2cmd --freq 114.

- Patrick

Perhaps closer. The device is running at 8MHz on the internal oscillator.


avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0xffffff (probably .avr8x_mega) (retrying)
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0xffffff (probably .avr8x_mega) (retrying)
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.
avrdude done.  Thank you.

reg@grexps:~/megadesk_tindie$ pavr2cmd -s
Name:                                    Pololu USB AVR Programmer v2.1
Serial number:                           00309332
Firmware version:                        1.02
Programming port:                        /dev/ttyACM0
TTL port:                                /dev/ttyACM1

Settings:
  ISP frequency (kHz):                   750
  Max ISP frequency (kHz):               750
  Regulator mode:                        5 V
  VCC output:                            Enabled
  VCC output indicator:                  Blinking
  Line A function:                       None
  Line B function:                       DTR
  VCC/VDD maximum range (mV):            896
  VCC 3.3 V minimum (mV):                2720
  VCC 3.3 V maximum (mV):                3872
  VCC 5 V minimum (mV):                  4128
  VCC 5 V maximum (mV):                  5856
  STK500 hardware version:               F
  STK500 software version:               2.A

Results from last programming:
  Programming error:                     No error.
  Target VCC measured minimum (mV):      4736
  Target VCC measured maximum (mV):      4768
  Programmer VDD measured minimum (mV):  4768
  Programmer VDD measured maximum (mV):  4800

Current status:
  Target VCC (mV):                       4768
  Programmer VDD (mV):                   4800
  VDD regulator set point:               5 V
  Last device reset:                     Power-on reset

Ah, there was a loose connection not being made properly. I think it’s working now! Let me verify a few things.

Yes, it is flashing now, and looks like I can flash at 1714KHz with -B 0.5, probably the fastest possible speed for an 8MHz clock.

2 Likes

I am glad to hear that you got it working! Thanks for letting us know.

- Patrick

I need to bring this back from the dead.

So, turns out my programmer cannot perform the 1st time flashing of the ATTiny841.

I can program it with my tinyusb programmer. After which, I can properly program it with the Pololu programmer. However, on a blank chip, the Pololu cannot program the chip the first time.

avrdude: stk500v2_command(): command failed
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

Can you try programming a blank ATTiny841, run pavr2cmd -s after it fails, and post the output here?

- Patrick

#!/bin/bash
PORT=`pavr2cmd --prog-port`
PROG=stk500v2
pavr2cmd --freq 114
MCU=attiny841

avrdude -c $PROG -p $MCU -U lfuse:w:0xe2:m -P $PORT
avrdude -c $PROG -p $MCU -U hfuse:w:0xd6:m -P $PORT
avrdude -c $PROG -p $MCU -U efuse:w:0xfe:m -P $PORT
greg@grexps:~/megadesk_tindie$ pavr2cmd -s
Name:                                    Pololu USB AVR Programmer v2.1
Serial number:                           00309332
Firmware version:                        1.02
Programming port:                        /dev/ttyACM0
TTL port:                                /dev/ttyACM1

Settings:
  ISP frequency (kHz):                   1714
  Max ISP frequency (kHz):               1714
  Regulator mode:                        5 V
  VCC output:                            Enabled
  VCC output indicator:                  Blinking
  Line A function:                       None
  Line B function:                       DTR
  VCC/VDD maximum range (mV):            896
  VCC 3.3 V minimum (mV):                2720
  VCC 3.3 V maximum (mV):                3872
  VCC 5 V minimum (mV):                  4128
  VCC 5 V maximum (mV):                  5856
  STK500 hardware version:               F
  STK500 software version:               2.A

Results from last programming:
  Programming error:                     Initial SPI command failed.
  Target VCC measured minimum (mV):      4544
  Target VCC measured maximum (mV):      4864
  Programmer VDD measured minimum (mV):  4800
  Programmer VDD measured maximum (mV):  4864

Current status:
  Target VCC (mV):                       4768
  Programmer VDD (mV):                   4800
  VDD regulator set point:               5 V
  Last device reset:                     Power-on reset

So I notice the freq is 1714 which is odd. In my batch file I am setting it to 114.

I’ve just tried a single line avrdude -c stk500v2 -p attiny841 -U lfuse:w:0xe2:m -P /dev/ttyACM0 after setting the speed to 114 again and confirming the speed was set properly, and it set the fuse sucessfully.

And of course now with a successful flash, programming at 1714 works OK as well.

Your bash script looks like it should succeed in setting the AVR programmer’s ISP frequency to 114 kHz, so I do not know why it ended up being 1714 kHz later. You might consider adding set -ue as the first command in your bash script (right after the #! line) to ensure that it stops after any errors.

I am glad you got everything working. Let me know if you have any more questions.

- Patrick