Maintenance notice: These forum archives are read-only, and will be removed shortly. Please visit our forums at their new location,

avrdude problem with MEGA2560

edited October 2015 in General
My son and I are trying to get the EvilMadScientist Peggy board working.  It's got an Arduino Mega2560 on it. We programmed it successfully a few months ago, and it's still running the program we put into it (e.g., the chip and the board all function just fine).  

Whenever we try to upload a new program (our Peggy program, blink, anything...) we get the message:
avrdude: stk500v2_getsync(): timeout communicating with programmer
This repeats a few times then it times out.

I have a Mac (OSX 10.10.5), my son has a PC with Windows 10.  But we've also tried this with a Mac with OSX 10.9.5.
We've also tried to upload a simple blink program to a Sainsmart Mega2560 board.  Same problem, same error message every time!

There are lots of solutions out there, including 
- Editing boards.txt to change the AVR (some say to change it to -wiring, some say to use -stk500v2). 
- Pressing the reset button just before trying to upload the program
- Unplugging the board, then plugging it in right before uploading.
- Using AVR ISP instead of AVRISP MKII
- Searching for and removing triple !!! in the code.

None of those worked for us.

We have the same problem with a Arduino Duemilanova.  But we are able to upload programs to an Arduino Nano and Arduino Uno with no problem.

Has anyone solved this?

Many thanks!  


  • edited October 2015
    It is not clear to me exactly what you are trying to do, nor exactly what the problem is.

    You have said that you are trying to get a Peggy board working, but that you're using an Arduino Mega2560 on it. The Peggy boards do not come with an Arduino Mega2560, nor a socket for one, nor any other obvious way to attach one to it. So, it is not whatsoever clear what your actual hardware setup is. 

     Some types of hardware setups *can* interfere with programming-- so you might consider disconnecting the Mega2560 from the Peggy, to see if this is actually Peggy related, or just an issue with programming with the '2560 board.

    You are having a problem with uploading code to the '2560 board. However, you have not said how you are trying to upload the code. The fact that you are mentioning the AVR ISP and AVRISP MKII leads me to guess that you are using an external programmer (perhaps an AVR ISP programmer of some sort?), rather than direct uploads via the more standard USB/bootloader interface, but you have not said. It is not clear what hardware you are using to connect the Mega2560 to your computer.

    The fact that you mention "boards.txt" suggests that you are trying to upload from within Arduino, rather than directly from the command line... but you have not said so directly. Assuming that you are trying to upload from within Arduino, then please follow the steps of the Arduino troubleshooting guide. I would also suggest starting over with a fresh copy of the Arduino IDE, one where you have _not_ edited the boards.txt file. If you are not using Arduino (and you are programming from the command line or another program), then you should ignore the boards.txt file.

    The fact that you can upload to both an Arduino Nano and Uno suggests that your computer and basic programming methods are sound. If you are using the USB interface to program these from within Arduino (guessing here-- again, you haven't really indicated what your hardware, programming, or software setups are!) then that does suggest that your USB drivers are working properly.

    If you find the same sort of behavior (these two boards always work, these two boards never work, etc) across multiple computers, that may indicate that the boards that the boards (or at least, the part of the hardware that allows them to be programmed) may be damaged.
  • Thanks Windell.

    You're right of course about the chip - the Peggy 2.1 uses the ATmega168-20PU chip.  But we have the same problem whether we're trying to upload to a Mega168, mega2560 or Duemilanova.  And we have the same problem when we use the Arduino IDE on a Mac or PC.

    In every case, we're using a USB cable to transfer the code from the PC/Mac to the Arduino board.  In every case, we can transfer the code successfully to an Uno or Nano board.  In every case, we get the "avrdude: stk500v2_getsync(): timeout communicating with programmer" error message when we try to upload to a 2560, 168, or Duemilanova Arduino.  
  • You are trying to debug many things at once, and that is a recipe for making things difficult. 

    Please use a single computer (I suggest one of the Macs-- generally a little more forgiving), and start with a fresh copy of the Arduino IDE.  Try to upload the "blink" example sketch to your Uno, and make sure that it works. 

    To make sure that it's actually uploading code successfully, try changing the "delay(1000);" lines to read "delay(250);".

    Then, with the _exact same setup_ -- same computer, same USB cable, same copy of Arduino and so forth -- try uploading to your duemilanove. The only thing that you should need to change is the selection in the Boards menu.
  • Thanks again Windell.  We're doing all the things you're asking, and doing them on both platforms.

    To be clear:  we're taking a Mac (OSX 10.10.5) and uploading blink onto an Arduino Uno using a USB cable.  Works fine.  When we change the delay from 1000 to 100, you can clearly see that the new blink program is uploading successfully onto the Uno.

    Then we do the same thing on the Arduino Micro.  Change the Arduino IDE settings, but same computer, same USB port, same result:  uploads fine.  Works fine.

    When we switch to the Peggy2, update the Arduino IDE settings but same USB port, same computer, same port, etc., we get the error "stk500v2_ReceiveMessage(): timeout".  Same with the SainSmart Mega2560 board.  Interestingly, when we try to upload the new blink program on the Duemilanove, it just hangs.  No error message.  

    All the above is true when we do the same tests on Windows 10.

    In both environments, we've uninstalled and reinstalled the Arduino IDE, we've installed the latest FTDI drivers, and we've tried with the original and the altered boards.txt file.

    Thanks in advance for any help you can provide.

  • Can you please the test that I suggested with the Uno and Duemilanove _with the same cable_ to see how that behaves?  If it still fails, do you have any reason to believe that the Duemilanove is still functional?

    For programming the Peggy 2, can you please say what your actual configuration is there? As you have described it so far, there isn't enough information about the hardware configuration to begin to guess what the actual problem might be.

    Have you ever reprogrammed any of these boards by a mechanism other than using the bootloader?

  • We did that.  It's a standard USB cable.  It still fails.  Not sure if the Duemilanove is still functional - it lights up, flashes, etc.  But we don't know any other way to talk to it.

    To program the Peggy2, we attach a small FTDI board to it, connect the FTDI board via USB cable to the PC, and upload the programs from the PC.

    We've never programmed any of these boards using any other mechanism other than a PC with a USB cable.  We weren't aware there was any other way!


  • It still sounds like you're trying to solve a number of unrelated problems here.

    For the case of the Peggy board, if you would like to send it and the programming interface to us, we could test them for you. Otherwise, you should try and establish _some_ baseline of either the programmer or the Peggy that is working. 
Sign In or Register to comment.