Avrdude error when programming 3pi robot atmega328 on Linux


I have been working for about a month with a Pololu 3pi atmega328 robot. I have been programming my 3pi on Linux using the USB AVR programmer (pololu.com/product/1300). Today, I am trying to program the 3pi as usual running the following command:

sudo make program

and I am getting the following error:

avrdude -p m328p -c avrisp2 -P /dev/ttyACM0 -U flash:w:test.hex
avrdude: stk500v2_command(): command failed
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.
avrdude done.  Thank you.
make: *** [program] Error 1

Batteries are fully charged and the robot is on when I attempt to program it. I am using a voltmeter on the VCC pin and I see about 5 V. Both blue LEDs are on and steady. The USB AVR programmer has the green LED on and the yellow LED blinking before programming. After the fail attempt to program the 3pi, the red LED turns on. I have a second USB AVR programmer and the same error appears. I also have a second 3pi robot and I can program it correctly using the same USB AVR and computer.

According to this, the problem seems to be on the 3pi. I do not see any sign of board damage or burned circuits. How can I be sure the problem is on the 3pi? Where could the problem be? I measured the voltage level on the USB AVR programmer pins on the 3pi board, using my second and functional 3pi as reference, voltage levels look normal.

Is there anything else I could do to diagnose the problem?

Thank you for your help.

Running the avrdude command in verbose mode instead of using the Makefile gives me a bit more information. In Ubuntu, I am getting:

avrdude: stk500v2_getsync(): found STK500 programmer
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         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                 :
avrdude: stk500v2_command(): command failed
avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x58d46d
avrdude: Expected signature for ATmega328P is 1E 95 0F

In CentOS I see a similar error message:

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
avrdude: Expected signature for ATMEGA328P is 1E 95 0F

On http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=133673&view=previous forum, I see
"The lack of a valid ID often means that there is no functioning oscillator in the micro. Even though you have a crystal connected, that does not mean it is oscillating."
Could this be the case? How could this be fixed?


I am sorry you are having issues programming your 3pi. Were you able to program your 3pi before the issue happened? If so, has anything in your setup changed since then? The issue does seem to have to do with your 3pi, but I am not specifically sure what the problem might be.

You could try using the configuration utility of the AVR Programmer to output a better error message then post it here, which would require you to set up on a Windows computer since the feature is only available for that operating system. You can follow the installation steps in our AVR Programming Quick Start Guide.

It is possible that the oscillator has failed. If you have an oscilloscope, you could try probing the AVR’s XTAL2 pin, which can be found in the schematic diagram under the “Pictures” tab of the 3pi product page.

- Amanda

Hi Amanda:

Thank you for your help. I tried using the AVR programming tool on Windows and I am getting the following message when trying to program the 3pi:

[quote]Failed to launch program.
Error: Failed to start programming session before chip erase with eeprom overwrite: Failed to enter programming mode. ispEnterProgMode: Error status received: Got 0xc0, expected 0x00 (Command has failed to execute on the tool)

What could that message mean?

I see the XTAL2/TOSC2 (PB7) pin on the diagram like you indicated, but I am unable to find it on the board. Is PB7 labeled on the board?

Could you let me know what software are you using that is giving the error message? What version of Windows are you using? Once again, were you able to program that 3pi before? Has anything changed since then?

The error message implies there was a problem when putting your AVR into programming mode, but running the Pololu USB AVR Programmer Configuration Utility will give a more detailed error message. The utility comes with the drivers during the installation. Please run the configuration utility after receiving an error from the software you are using and post a screenshot of it here.

The XTAL2 pin can be directly measured on the AVR chip. You can find out which pin it is on the chip by looking at the AVR’s pin configuration diagram in Figure 1-1 of its datasheet on the Atmel website.

- Amanda

I had been able to program this 3pi before in Linux, nothing has changed since. Same computer, same system, same environment. I have been working with this 3pi for the last month with the same settings, one day I walked in the lab, tried to program it as usual, and it failed.

I used AtmelStudio 6 and the Pololu USB AVR Programmer Configuration Utility on a Windows 7 machine. I followed the steps at https://www.pololu.com/docs/0J36/3.b. When I got to step 8 and clicked the Read button next to the Device Signature box, I got the error shown in the following screenshot:

The upper left window shows the error message I get when clicking the Read button next to the Device Signature box on AtmelStudio from the Device Programming dialog. The bottom right window is the Pololu USB AVR Programmer Configuration Utility, after getting the error on AtmelStudio, I clicked the Refresh button next to the Measurements From Last Programming text.
According to https://www.pololu.com/docs/0J36/3.e, the Pololu 3pi can be programmed at most at 2000 kHz. I also tried reducing this to 1500 kHz and the same error occurs.

I was able to find the XTAL2 pin, following the diagrams you provided. See a picture of the back of the 3pi robot on:
A red circle indicates what I believe is the oscillator. Is this correct? I used an oscilloscope to measure the signals on the pins on the oscillator. No signal was observed on any of the pins. As reference, I also measured the same pins on my second 3pi robot that is operating normally and I was able to see an oscillating signal shown below:

The absence of this oscillating signal on the 3pi that gives me the programming error seems to indicate the oscillator is not functioning. Does this make sense? Is it possible to replace the oscillator on the 3pi?

Thank you for looking into this in such detail. It certainly seems like the oscillator circuit is not functioning, but this is not necessarily an indication of a problem with the resonator. I think it is more likely that the microcontroller has been damaged. Please email us directly with your order information, and we will see if we can help you out with a replacement 3pi.

- Amanda