nattynerdy
nattynerdy

Reputation: 421

avrdude: stk500v2_ReceiveMessage(): timeout

This is the main error that I get when I try to run my ARDUINO program. The full list of errors is as follows:

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

My code is as follows:

int led=13;
void setup()
{
    pinMode(13,OUTPUT);
}

void loop()
{
    digitalWrite(13,HIGH);
    delay(1000);
    digitalWrite(13,LOW);
    delay(1000);
}

I have tried updating the drivers (they are fully updated) and downloading some programs. I have Windows 7 and my arduino is a MEGA 2560. It shows up in the Device Manager and all of my connections are correct. The green PWR light is on and so is the flashing L light. The RX and TX lights flash when I update. I have tried almost everything on the web. What is the problem?

Upvotes: 39

Views: 226402

Answers (17)

Westy92
Westy92

Reputation: 21295

If your board has more than one processor option under Tools > Processor, make sure you select the correct one! I had ATmega2650 selected when I needed ATmega1280.

Upvotes: 0

dxk3355
dxk3355

Reputation: 158

I had this issue. The solution I found was I had to disconnect my LCD screen from the board.

Upvotes: 0

maratbn
maratbn

Reputation: 248

I had this problem when I had the Arduino connected thru nested USB hubs. Funny thing it was listed properly by 'lsusb' and if I clicked 'Tools' -> 'Get Board Info' I got the 'Board Info' dialog just fine. But still could not upload a sketch. Then unplugged from the nested hub and plugged directly into a USB port on the motherboard and problem went away.

Upvotes: 0

Foad S. Farimani
Foad S. Farimani

Reputation: 14016

To my humble understanding, this error arises in different scenarios:

  1. you have selected the wrong port or you haven't at all. go to tools > ports and select the com port with your Arduino connected to.

  2. you have selected the wrong board. go to tools > board and look for the right board.

  3. Do you have one of these Arduino replicas or you don't have the boot-loader installed on the microcontroller? I don't know the solution to this! if you know please edit my post and add the instructions.

  4. (windows only) you don't have the right drivers installed. you need to update them manually.

  5. sometimes when you have wires connected to the board this happens. you need to separate the board from any breadboard or wires you have installed and try uploading again. It seems pins 0 (RX) and 1 (TX), which can be used for serial communication, are problematic and better to be free while uploading the code.

  6. Sometimes it happens randomly for no specific reason!

There are all kinds of solutions all over the internet, but sometimes hard to tell the difference between magic! Maybe the Arduino team should think of better compiler errors to help users differentiate between these different causes.

The same problem happened to me and none of the solutions above worked. What happened was that I was using an Arduino UNO and everything was fine, but when I bought an Arduino Mega 2560, no matter what sketch I tried to upload I got the error:

avrdude: stk500v2_ReceiveMessage(): timeout

And it was just on one of my windows computers and the other one was just ok out of the box.

Solution:

What solved my problem was to go to tools > boards > Boards Manager... and then on the top left of the opened windows select updatable in the Type section. Then select the items in the list and press update on the right.

I'm not sure if this will solve everyone's problem, but it at least solved mine.

Upvotes: 9

bcdan
bcdan

Reputation: 1428

Something not yet mentioned is that this message also appears when the baudrate is not properly set... for Arduino, it is generally 115200.

Upvotes: 0

Rajeev Rathor
Rajeev Rathor

Reputation: 1922

I faced same problem. but Root cause of issue. Incorrect communication was set and thats why I occurred Communication timeout.

Solution: If you connected to laptop through USB port. Change Port as USB. Please follow steps

  1. Open Arduino-IDE
  2. Go to Menu "Tools --> Port" and Select option "USB" { for me its showing as /dev/ttyUSB0 }

It working fine for me.

Upvotes: 0

GlamSelva1297934
GlamSelva1297934

Reputation: 137

Open Terminal and type:

$ sudo usermod -a -G dialout 

(This command is optional)

$ **sudo chmod a+rw /dev/ttyACM0** 

(This command must succeed)

Upvotes: 1

Rafael Bartz
Rafael Bartz

Reputation: 328

I had the same problem, and in my case, the solution was updating the usb-serial driver using windows update on windows 10 device's manager. There was no need to download a especific driver, I just let windows update find a suitable driver.

Upvotes: 0

qwr
qwr

Reputation: 10929

Ensure the serial monitor is not running and nothing is reading/writing dev/tty/S0 (or whichever port you're using), which may cause uploading interference.

Upvotes: 0

Abu Bakar
Abu Bakar

Reputation: 185

My aurdino mega 2560 returned same error. It seems the problem exists in unofficial clones. The issue solved by pressing reset button just before uploading starts, as advertised in following video.

https://www.youtube.com/watch?v=tAzjO4v7oF4&list=LLDn5ewJDzz53IiwWmZTgQnQ&index=1

Upvotes: 0

PeterM
PeterM

Reputation: 1534

I've connected to USB port directly in my laptop and timeout issue has been resolved.

Previously tried by port replicator, but it did not even recognized arduino, thus I chosen wrong port - resulting in timeout message.

So make sure that it is visible by your OS.

Upvotes: 0

aaronsti
aaronsti

Reputation: 559

Another possible reason for this error for the Mega 2560 is if your code has three exclamation marks in a row. Perhaps in a recently added string.

3 bang marks in a row causes the Mega 2560 bootloader to go into Monitor mode from which it can not finish programming.

"!!!" <--- breaks Mega 2560 bootloader.

To fix, unplug the Arduino USB to reset the COM port and then recompile with only two exclamation points or with spaces between or whatever. Then reconnect the Arduino and program as usual.

Yes, this bit me yesterday and today I tracked down the culprit. Here is a link with more information: http://forum.arduino.cc/index.php?topic=132595.0

Upvotes: 25

hanoo
hanoo

Reputation: 4245

If you use the ino command line:

ino upload

it can be because you use the arduino software at the same time, try to kill it.

Upvotes: 0

Lokesh Tiwari
Lokesh Tiwari

Reputation: 10586

I was running this code from Arduino setup , got same error resolve after changing
serial port to COM13
GO TO Option
tool>> serial port>> COM132

Upvotes: 0

Nick T
Nick T

Reputation: 26717

The error message basically means that the programmer is unable to contact the bootloader on the device; the code you're trying to upload has no bearing on the problem.

What causes this can be numerous and varied, some possible issues:

  1. UART communications

    • Blinking is happening, so hopefully you aren't using the wrong port. It might be worth checking again though, sometimes USB COM devices install on strange port numbers.

    • Connect TX to RX (and disconnect them from the AVR if possible) then open a terminal on the COM port, you should see characters echoed if you type them. If you don't, something is wrong up-stream of the chip, it could be the communications chip (I think the Arduino 2560 uses a secondary AVR instead of an FTDI for some reason, so that could be broken, either its software or hardware)

  2. ATmega* bootloader

    • The AVR is not executing the bootloader for some reason. If the programmer is not resetting the micro before attempting to connect, this might be the reason. Try to reset the AVR (press and release the button) while the programmer is attempting to connect. Sometimes software that runs in a tight loop will prevent the bootloader from connecting.

    • Barring that, the fuses might have gotten messed up or the code erased. You would need to reflash the bootloader and proper fuses, again, see the appropriate info page for your device.

  3. Arduino Mega 2560 only: ATmega8U/16U software

    • Might not be working and would need reprogramming. See the Programming section on the info page, you will need the firmware and Atmel-compatible DFU (device firmware update) software on your computer to reflash the target.
  4. Hardware damage to the board, AVR(s), or FTDI chip

    • You're hosed; need a new chip.

Check this forum post for some more ideas.

Upvotes: 15

Michael F
Michael F

Reputation: 1409

I got this error because I didn't specify the correct programmer in the avrdude command line. You have to specify "-c arduino" if you are using an Arduino board.

This example command reads the status of the hfuse:

avrdude -c arduino -P /dev/ttyACM0 -p atmega328p -U hfuse:r:-:h

Upvotes: 7

anders
anders

Reputation: 4218

This isn't really a fixing solution but it may help others. Unlike Nick had said for me it was due to code in my program. I have the mega ADK model. The issue was tied to a switch statement for processing and parsing the returned byte[] from the usb connection to the Android. Its very strange because it would compile perfectly every time but would fail as the OP had stated. I commented it out and it worked fine.

Upvotes: 0

Related Questions