# Upload sketches via USB Failed on 2560

**URL:** <https://forum.arduino.cc/t/upload-sketches-via-usb-failed-on-2560/1282040>\
**Category:** Programming\
**Created:** [July 16, 2024, 3:57am UTC](https://forum.arduino.cc/t/upload-sketches-via-usb-failed-on-2560/1282040 "2024-07-16T03:57:49Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![rleelaprasad](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@rleelaprasad](https://forum.arduino.cc/u/rleelaprasad)\
**Post date:** [July 16, 2024, 3:57am UTC](https://forum.arduino.cc/t/upload-sketches-via-usb-failed-on-2560/1282040/1 "2024-07-16T03:57:49Z")

</div>

We are working on cloned design of Arduino Mega 2560 Rev 3 Board for voltage monitoring application. We are able to flash the “Arduino-usbserial-mega.hex” on ATMega16U2 and able to detect as USB- Serial Adaptor. Also Burn Bootloader got successfully on Mega2560 using another Arduino Mega board as ISP.  
When we try to upload a sketch through the port linked to ATMega16U2, observed errors and upload got failed. Since this port is not working, we had to upload the sketch through ICSP Header using another Arduino Mega board as ISP and upload is completed without any errors. The communication between ATMEGA16U2 & Host Laptop and ATMega2560 & Laptop through FT232RNQ seems to be fine. Looks like communication between ATMega16U2 & ATMega2560 is having issue. Is there any option to enable USB in arduino2560 to upload sketches through it. Please suggest.

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [July 16, 2024, 4:28am UTC](https://forum.arduino.cc/t/upload-sketches-via-usb-failed-on-2560/1282040/2 "2024-07-16T04:28:56Z")

</div>

Welcome

> [@rleelaprasad](#):
>
> We are working on cloned design of Arduino Mega 2560 Rev 3 Board for voltage monitoring application.

Please provide the schematic.

> [@rleelaprasad](#):
>
> When we try to upload a sketch through the port linked to ATMega16U2, observed errors and upload got failed.

It would be useful if you could provide the complete error message. Please enable _verbose output during upload_ and disable _verbose output during compilation_, perform an upload and post the output here using code tags (see [How to get the best out of this forum](https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966)).

> [@rleelaprasad](#):
>
> The communication between ATMEGA16U2 & Host Laptop ... seems to be fine.

How did you come to that conclusion? Loopback test ([Loop-Back Test Instructions](https://forum.arduino.cc/t/loop-back-test-instructions/73046/1))?

> [@rleelaprasad](#):
>
> Looks like communication between ATMega16U2 & ATMega2560 is having issue.

Hook up a scope and check what is happening.

> [@rleelaprasad](#):
>
> Is there any option to enable USB in arduino2560 to upload sketches through it.

I'm not sure if I understand; the 2560 processor does not have USB functionality. If your FT232 provides a DTR output, you can use the FT232 instead of the 16U2; connect it to the Tx/Rx and reset pin of the 2560. Note that you need to have the current limiting resistors between the Tx/Rx of the 16U2 and the Rx/Tx of the 2560 in place (RN4A and RN4B in the reference design).

---

<div class="post-metadata">

**Author:** ![rleelaprasad](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@rleelaprasad](https://forum.arduino.cc/u/rleelaprasad)\
**Post date:** [July 16, 2024, 5:56am UTC](https://forum.arduino.cc/t/upload-sketches-via-usb-failed-on-2560/1282040/3 "2024-07-16T05:56:01Z")

</div>

Hi! Log is as Below.

Sketch uses 5194 bytes (2%) of program storage space. Maximum is 253952 bytes.  
Global variables use 441 bytes (5%) of dynamic memory, leaving 7751 bytes for local variables. Maximum is 8192 bytes.  
"C:\Users\leelaprasad.r\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\leelaprasad.r\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega2560 -cwiring "-PCOM9" -b115200 -D "-Uflash:w:C:\Users\leelaprasad.r\AppData\Local\Temp\arduino\sketches\4B110A3E1500358EAD3D713E1330BD6D/VMON\_Optimized\_Code.ino.hex:i"

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

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

     Using Port : COM9
     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

Schematics is same as Arduino Mega 2560 Rev3 Schematics.

ATMega16U2 USB Port is detecting on Host laptop as a COM Port.

we are able to get the data from 2560 Serial port (RXD1 & TXD1) when we upload our sketch through ICSP header.

Are there any fuse settings to be done to enable USB Sketch upload

---

<div class="post-metadata">

**Author:** ![bluejets](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/bluejets/32/1013044_2.png) [@bluejets](https://forum.arduino.cc/u/bluejets)\
**Post date:** [July 16, 2024, 7:57am UTC](https://forum.arduino.cc/t/upload-sketches-via-usb-failed-on-2560/1282040/4 "2024-07-16T07:57:11Z")

</div>

AS requested, copy the compile error messages to the clipboard and post as it is displayed in code tags.  
As it stands, no one knows where the error messages begin/end and your comments on whta you think is wrong, begin/end.

---

<div class="post-metadata">

**Author:** ![rleelaprasad](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@rleelaprasad](https://forum.arduino.cc/u/rleelaprasad)\
**Post date:** [July 16, 2024, 8:18am UTC](https://forum.arduino.cc/t/upload-sketches-via-usb-failed-on-2560/1282040/5 "2024-07-16T08:18:47Z")

</div>

Sketch uses 5194 bytes (2%) of program storage space. Maximum is 253952 bytes.  
Global variables use 441 bytes (5%) of dynamic memory, leaving 7751 bytes for local variables. Maximum is 8192 bytes.  
"C:\Users\leelaprasad.r\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\leelaprasad.r\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega2560 -cwiring "-PCOM9" -b115200 -D "-Uflash:w:C:\Users\leelaprasad.r\AppData\Local\Temp\arduino\sketches\4B110A3E1500358EAD3D713E1330BD6D/VMON\_Optimized\_Code.ino.hex:i"

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

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

     Using Port : COM9
     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

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [July 16, 2024, 8:33am UTC](https://forum.arduino.cc/t/upload-sketches-via-usb-failed-on-2560/1282040/6 "2024-07-16T08:33:33Z")

</div>

> [@rleelaprasad](#):
>
> ATMega16U2 USB Port is detecting on Host laptop as a COM Port.

Run the loopback test. If you burned the correct bootloader it should show as an "Arduino Mega" in windows device manager.

> [@rleelaprasad](#):
>
> “Arduino-usbserial-mega.hex”

Why did you pick that one? You might want to try another one, specifically one that has 16U2 in the name.

> [@rleelaprasad](#):
>
> we are able to get the data from 2560 Serial port (RXD1 & TXD1)

You did not mention that; that was probably through the FTDI adapter that you were talking about.

> [@rleelaprasad](#):
>
> Are there any fuse settings to be done to enable USB Sketch upload

The fuses are taken care of when you burn the bootloader.

* * *

And now please learn to use code tags.

---

<div class="post-metadata">

**Author:** ![rleelaprasad](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@rleelaprasad](https://forum.arduino.cc/u/rleelaprasad)\
**Post date:** [July 18, 2024, 7:05am UTC](https://forum.arduino.cc/t/upload-sketches-via-usb-failed-on-2560/1282040/7 "2024-07-18T07:05:43Z")

</div>

We will try loop back test once. And we have tried both "Arduino-usbserial-mega.hex " and "Arduino-usbserial-atmega16u2-Mega2560-Rev3.hex" but both are not working. Please share us the Hex file so that we can try that. Also It is not detecting as "Arduino Mega" in device manager. It is detecting as USB Serial Device.

Also could you please let us the know difference between "Arduino-usbserial-atmega16u2-Mega2560-Rev3.hex" and "Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex"  
as both are different in size.

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [July 18, 2024, 7:58am UTC](https://forum.arduino.cc/t/upload-sketches-via-usb-failed-on-2560/1282040/8 "2024-07-18T07:58:11Z")

</div>

This is getting outside the area of my knowledge, sorry. I can't answer those questions. You'll have to wait for somebody else to come along.

---

<div class="post-metadata">

**Author:** ![rleelaprasad](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@rleelaprasad](https://forum.arduino.cc/u/rleelaprasad)\
**Post date:** [July 18, 2024, 9:19am UTC](https://forum.arduino.cc/t/upload-sketches-via-usb-failed-on-2560/1282040/9 "2024-07-18T09:19:16Z")

</div>

Hi!

Please let us know what are the default hex files for Mega2560 & Mega16u2 and theirs versions that are factory programmed in Evaluation kits (Arduino Mega 2560 Rev3).

Thanks,  
Leela Prasad R

---

<div class="post-metadata">

**Author:** ![b707](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/b707/32/854321_2.png) [@b707](https://forum.arduino.cc/u/b707)\
**Post date:** [July 18, 2024, 9:33am UTC](https://forum.arduino.cc/t/upload-sketches-via-usb-failed-on-2560/1282040/10 "2024-07-18T09:33:12Z")

</div>

Could you explain your problem a just more clear?

---

<div class="post-metadata">

**Author:** ![kolaha](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/kolaha/32/966427_2.png) [@kolaha](https://forum.arduino.cc/u/kolaha)\
**Post date:** [July 18, 2024, 9:37am UTC](https://forum.arduino.cc/t/upload-sketches-via-usb-failed-on-2560/1282040/11 "2024-07-18T09:37:22Z")

</div>

[Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.zip](https://forum.arduino.cc/uploads/short-url/hU7WqU1SEAgYewgpDytWWJlXv8j.zip) (7.5 KB)

bootloader  
[stk500boot\_v2\_mega2560.zip](https://forum.arduino.cc/uploads/short-url/lEmIo6BIYZaJfxRAv4K9k0VcPG9.zip) (7.5 KB)

---

<div class="post-metadata">

**Author:** ![Dozie](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/dozie/32/239024_2.png) [@Dozie](https://forum.arduino.cc/u/Dozie)\
**Post date:** [July 18, 2024, 9:55am UTC](https://forum.arduino.cc/t/upload-sketches-via-usb-failed-on-2560/1282040/12 "2024-07-18T09:55:11Z")

</div>

If you meant " usb to serial firmware, it can be found in `firmwares/atmegaxxu2/arduino-usbserial` . Check [Flash USB-to-serial firmware in DFU mode](https://support.arduino.cc/hc/en-us/search/click?data=BAh7DjoHaWRsKwgSoyuGAgQ6D2FjY291bnRfaWRpA07KIDoJdHlwZUkiDGFydGljbGUGOgZFVDoIdXJsSSJoaHR0cHM6Ly9zdXBwb3J0LmFyZHVpbm8uY2MvaGMvZW4tdXMvYXJ0aWNsZXMvNDQwODg4NzQ1MjQzNC1GbGFzaC1VU0ItdG8tc2VyaWFsLWZpcm13YXJlLWluLURGVS1tb2RlBjsIVDoOc2VhcmNoX2lkSSIpMWEwODdmY2EtZGNlYi00MmQ4LWFmMTUtZTM4YTJhYjFhZWFlBjsIRjoJcmFua2kGOgtsb2NhbGVJIgplbi11cwY7CFQ6CnF1ZXJ5SSIOYXRtZWdhMTZ1BjsIVDoScmVzdWx0c19jb3VudGkL--f24195933a601d5dbf7a3b9ee4ec0edb8bfb607d)

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [July 18, 2024, 9:57am UTC](https://forum.arduino.cc/t/upload-sketches-via-usb-failed-on-2560/1282040/13 "2024-07-18T09:57:14Z")

</div>

@rleelaprasad, I've merged your two similar topics. As you can see, @b707 was already missing information that was available.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [January 14, 2025, 9:57am UTC](https://forum.arduino.cc/t/upload-sketches-via-usb-failed-on-2560/1282040/14 "2025-01-14T09:57:40Z")

</div>

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