Unable to upload code to Mega2560

Hi,
i am using a Mega2560 and i am unable to upload the most simplest code.
Here is the error message.

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\vishe\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM14
         Using Programmer              : wiring
         Overriding Baud Rate          : 115200
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

avrdude done.  Thank you.

Failed uploading: uploading error: exit status 1

Can you all help me?

what have you tried?

i tried the blink project

Which version of the IDE are you using?
Do you have other boards (Uno, other Mega, ...) to test?
Which Windows version?
What does Windows device manager think of your board? Any yellow triangles?
Is COM 14 indeed the Mega? If you disconnect, does it disappear from IDE and device manager?
What is the TTL-to-USB converter on your board? Possible options are 16U2 for original or faithful clone, CH340, FTDI, .. for clones?

what have you tried to solve the problem? nothing? not googling?

i am using Arduino IDE. I tried uploading the code to WeMos D1 and it works. there is some problem with them mega. Yes, the mega is attached to COM 14.

I could have guessed that :wink: But the question was which version? Anything connected to pins 0 and 1 of the Mega.

There were more questions in my previous reply; please answer them.

it is the latest version of Arduino 2.1.1
there is nothing connected to any pin of the Mega.


This is how Windows discovers the mega.

I don't understand the other questions. Sorry.

Your board is on COM11 if I have to believe your screenshot, not COM14 as you mentioned in an earlier post. Please post a screenshot of the ports section in device manager.

Your post #8 answered the other questions.

It doesn't work in COM 11 as well

Does COM11 disappear when you disconnect the board?

If yes

  1. Please enable verbose output during upload and disable verbose output during compilation (both under file → preferences).
  2. Perform an upload and post the results here.

Did it ever work in the past? Or is it a new board? If it worked in the past, what is the last project that you managed to upload. Wjat was all connected for that project?

this is a new board. Yes, the COM 11 option disappears when I disconnect it.

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\vishe\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM11
         Using Programmer              : wiring
         Overriding Baud Rate          : 115200
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

avrdude done.  Thank you.

An error occurred while uploading the sketch

above is the error I receive when uploading

Unfortunately I can't help you further with that :frowning:

Hi @headless_knight. There is a program named a "bootloader" that is stored in a special area of the memory in the primary microcontroller of your Arduino board. This program receives the data sent by the computer when you upload a sketch to the board.

Beyond the more common causes already covered by the other helpers here, one additional possible cause of this error could be that the bootloader is not running when it should be activated. This could have either of the following causes:

  • The memory in the microcontroller where the bootloader was stored has somehow been erased or corrupted.
  • There is physical damage to the microcontroller or its support circuitry.

If the cause is a missing bootloader, the board might be recoverable by a "Burn Bootloader" operation.

Prepare ISP programmer

You will need an ISP programmer. If you don't have a programmer, you can use a spare Arduino board as an "Arduino as ISP" programmer.

Arduino as ISP

The following instructions are for using an Arduino board as an "Arduino as ISP" programmer. If you have a dedicated programmer, you can skip to the next set of instructions.

Although the "Arduino as ISP" only works for programming targets of the AVR architecture, you can also use boards of a variety of architectures (e.g., "AVR", "SAMD", "megaAVR") as an "Arduino as ISP" programmer.

I will refer to the board which will used as an "Arduino as ISP" as the "programmer board" from here on. The board you are burning the bootloader to will be referred to as the "target board".

  1. Disconnect the USB cable of the Arduino boards from your computer.
  2. Make the following connections between the "programmer board" and the "target board".
    Refer to the "Connections" table on the SPI library reference page to determine the pin numbers.
    Programmer Target
    CIPO (AKA "MISO") CIPO
    VCC 5V (VCC on 3.3 V boards)
    SCK SCK
    COPI (AKA "MOSI") COPI
    10 RESET
    GND GND
  3. Connect the "programmer board" to your computer with a USB cable.
  4. Select File > Examples > 11.ArduinoISP > Arduino ISP from the Arduino IDE menus.
  5. Select your "programmer board" from Arduino IDE's Tools > Board menu.
  6. Select the port of your "programmer board" from Arduino IDE's Tools > Port menu.
  7. Select Sketch > Upload from the Arduino IDE menus.
  8. Wait for the upload to finish.

You are now ready to burn the bootloader using your "Arduino as ISP" programmer.

Burn Bootloader

Instructions for burning the bootloader:

  1. Connect an ISP programmer to your Arduino board.
    If you are using an "Arduino as ISP", then you have already connected it according to the previous instructions.
  2. Select the target board from the Tools > Board menu and any other custom Tools menus (e.g., Tools > Processor).
  3. Select the appropriate programmer from the Tools > Programmer menu.
  4. Tools > Burn Bootloader
  5. Wait for the process to finish successfully.
  6. Disconnect the USB cable of the programmer from your computer.
  7. Disconnect the programmer from the "target board".

Now connect the "target board" to your computer with a USB cable, select its port from the Tools > Port menu, and try uploading a sketch as usual.

Conclusion

Now connect the "target board" to your computer with a USB cable and try uploading again. Does the upload succeed now?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.