Arduino error while uploading the sketch

Hello guys!
I am having the following error as I am trying to upload my sketch on the Arduino Mega board:
Arduino: 1.8.10 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Sketch uses 2966 bytes (1%) of program storage space. Maximum is 253952 bytes.
Global variables use 220 bytes (2%) of dynamic memory, leaving 7972 bytes for local variables. Maximum is 8192 bytes.
An error occurred while uploading the sketch

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I have noticed that normally in the tools, the port name is something like COM3:Arduino Mega 2560 but this time it only says COM3. It might be some port issue but I cannot understand what the problem is as I have used this code several times before. Can anybody help me please? :slight_smile:

What does Windows device manager think about the board? It's either no longer recognised or it's now on another port?

Anything connected to pins 0 and 1 of the Mega? If so, remove it.

the device manager sees the board as being COM3. nothing at all connected to any pins

Thank you so much for replying haha.
Also tried a loopback test and it ain't working, arduino error window says the port is busy.

That would indicate that some application is using the port; it might be an upload in progress or a totally different application.

In a first attempt, I would restart the PC.

Next, in the IDE, file -> preferences: disable verbose output during compilation and enable verbose output during upload. Do an upload and post the resuts here if it fails.

I copied the error message, this is what is says

Arduino: 1.8.10 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Sketch uses 2966 bytes (1%) of program storage space. Maximum is 253952 bytes.
Global variables use 220 bytes (2%) of dynamic memory, leaving 7972 bytes for local variables. Maximum is 8192 bytes.
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega2560 -cwiring -PCOM3 -b115200 -D -Uflash:w:C:\Users\Andreea\AppData\Local\Temp\arduino_build_400302/flex_snesor_angle_measure.ino.hex:i

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:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

     Using Port                    : COM3
     Using Programmer              : wiring
     Overriding Baud Rate          : 115200

avrdude: ser_open(): can't open device "\.\COM3": Access is denied.

avrdude: ser_drain(): read error: The handle is invalid.

avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: The handle is invalid.

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: The handle is invalid.

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: The handle is invalid.

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
the selected serial port avrdude: stk500_send(): failed to send command to serial port
does not exist or your board is not connected
avrdude: ser_recv(): read error: The handle is invalid.

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: The handle is invalid.

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: The handle is invalid.

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

avrdude done. Thank you.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

also, I did the loopback test again and it did not show the message I had typed and then I could not close the window anymore

I had the same issue with the loopback test

well ahm, did you manage to find the problem for it?

No but i just got the same error:Arduino: 1.8.14 (Windows 10), Board: "Arduino Nano Every, None (ATMEGA4809)"

Sketch uses 1118 bytes (2%) of program storage space. Maximum is 49152 bytes.
An error occurred while uploading the sketch

I wrote now all what it said in the error window

isn't it great we're not alone in the world

1 Like

I turned on verbose output during upload and i got this now:Arduino: 1.8.14 (Windows 10), Board: "Arduino Nano Every, None (ATMEGA4809)"

Sketch uses 1118 bytes (2%) of program storage space. Maximum is 49152 bytes.

Global variables use 22 bytes (0%) of dynamic memory, leaving 6122 bytes for local variables. Maximum is 6144 bytes.

C:\Users\Pro\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\Pro\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega4809 -cjtag2updi -PCOM18 -b115200 -e -D -Uflash:w:C:\Users\Pro\AppData\Local\Temp\arduino_build_521319/Blink.ino.hex:i -Ufuse2:w:0x01:m -Ufuse5:w:0xC9:m -Ufuse8:w:0x00:m {upload.extra_files}

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\Pro\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"



     Using Port                    : COM18

     Using Programmer              : jtag2updi

     Overriding Baud Rate          : 115200

avrdude: ser_open(): can't open device "\.\COM18": The system cannot find the file specified.

avrdude done. Thank you.

Problem uploading to board. See Upload – Arduino Help Center for suggestions.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

yeah true

have you found a fix yet?

not really, I am still struggling but hopefully God will save me ... :frowning:

Please stick to your own thread. It will become highly confusing, also because you have a different board.

@smar321, thanks. Is that directly after a reboot?

If you originally did see Arduino Mega (COM3) and now only see COM3, I suspect that the 16U2 has lost its firmware or is damaged. You can try to restore the firmware using a programmer, but I have never done it so can't advise; there are a few articles on the web: uno 16u2 restore firmware - Google Search

I think I will trust this one and I think it will work although the author states that it's no longer maintained: https://www.instructables.com/How-to-Restore-the-Arduino-UNO-R3-ATmega16U2-Firmw/ . The firmware will be C:\Program Files (x86)\Arduino\hardware\arduino\avr\firmwares\atmegaxxu2, for me it will be trial-and-error to find the correct Mega hex file.

I have fixed the problem. I only had to attribute a different com number to the arduino board in the device manager and then it worked. I am only writing this in case someone else has the same issue haha
Thank you anyway for the advice :slight_smile:

1 Like

Thanks for the feedback.

It's my understandingthat that is not the proper solution as the COM ports should be enumerated automatically without issues. I however don't have another solution.

But at least you can continue.

If your issue is solved, you can click the solution checkbox under the most useful reply ( yours :wink: ) to let others know.