Arduino upload error

avrdude: stk500v2_getsync(): timeout communicating with programmer

The Mega 2560 uses a different upload protocol from the Uno, called stk500v2. This message is the Mega version of "not in sync".

  • Upload error
  • 4 common causes
The message

What the Arduino IDE prints

Output window
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
Failed uploading: uploading error: exit status 1

The sketch compiled. The board did not answer the upload request.

Causes

The 4 usual causes in order

1The board setting says Uno, not Mega

The Uno and the Mega use different protocols and speeds. A wrong board setting gets no answer.

  1. In Tools, Board, choose Arduino Mega or Mega 2560.
  2. In Tools, Processor, choose ATmega2560 (Mega 2560).

2The port is wrong or taken

avrdude talks to the port you chose.

  1. Unplug the board, check the list in Tools, Port, plug it in, and pick the new entry.
  2. Close the Serial Monitor and other programs that hold the port.

3Something is connected to pins 0 and 1

Pins 0 and 1 (RX0 and TX0) are the serial port the upload uses. A module there blocks it.

  1. Unplug whatever is on pins 0 and 1, upload, then plug it back in.

4A clone with no driver, or a bad cable

Mega clones often use a CH340 USB chip that needs a driver on Windows.

  1. Install the CH340 driver and try another data cable.
On a real board

What to do at the bench

Mokxi's Upload to board writes to a Mega 2560 from Chrome or Edge, and meets the same causes. It tells you when it finds no board.

Run the sketch in Mokxi before you blame the board. If it builds and runs there, the code is fine and the problem is the connection to the real board.

Test the sketch in Mokxi first

Run the sketch here before you blame the board. If it builds and runs in Mokxi, the code is fine and the fault is the connection to the real board. Mokxi never uploads in a simulation, so it cannot raise this error itself.

A sketch to try first
void setup() {
  Serial.begin(9600);
  pinMode(13, OUTPUT);
  Serial.println("blink ready");
}

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

Run it in Mokxi

FAQ

Questions and answers

How is this different from the Uno error?

The Mega talks stk500v2, so the message says stk500v2 and timeout. The causes are nearly the same: port, board setting, pins 0 and 1, cable.

What does timeout communicating with programmer mean?

The tool waited for an answer from the bootloader and none came.

Could the code cause it?

Not usually. A sketch that crashes right at start can keep the bootloader from running, but the board setting and the cable come first.