# Programming IDUINO MEGA 2560

**URL:** <https://forum.core-electronics.com.au/t/programming-iduino-mega-2560/4563>\
**Category:** Uncategorized\
**Created:** [16 February 2019 09:27 UTC](https://forum.core-electronics.com.au/t/programming-iduino-mega-2560/4563 "2019-02-16T09:27:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Clem73666](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@Clem73666](https://forum.core-electronics.com.au/u/Clem73666)\
**Post date:** [16 February 2019 09:27 UTC](https://forum.core-electronics.com.au/t/programming-iduino-mega-2560/4563/1 "2019-02-16T09:27:00Z")

</div>

I have three MEGA boards , two identical. I have been working with one board developing code and able to program it successfully.

I just took another one out of the box and tried to program it with the same code and it refuses to program. I am using the USB interface to the MEGA

I get this message when I am connected to the one I have been programming all along:  
"  
Sketch uses 9026 bytes (3%) of program storage space. Maximum is 253952 bytes.  
Global variables use 754 bytes (9%) of dynamic memory, leaving 7438 bytes for local variables. Maximum is 8192 bytes.  
"

When I unplug the MEGA and plug the other MEGA in and try to program it identically I get this message:  
"

Sketch uses 9026 bytes (3%) of program storage space. Maximum is 253952 bytes.  
Global variables use 754 bytes (9%) of dynamic memory, leaving 7438 bytes for local variables. Maximum is 8192 bytes.  
avrdude: ser\_open(): can’t open device “\.\COM5”: The system cannot find the file specified.

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  
the selected serial port  
does not exist or your board is not connected  
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  
avrdude: ser\_recv(): read error: The handle is invalid.

avrdude: stk500v2\_ReceiveMessage(): timeout  
avrdude: stk500v2\_getsync(): timeout communicating with programmer  
"

When I plug a third MEGA in, it does not program either?

What is going on?

---

<div class="post-metadata">

**Author:** ![James46717](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@James46717](https://forum.core-electronics.com.au/u/James46717)\
**Post date:** [16 February 2019 22:53 UTC](https://forum.core-electronics.com.au/t/programming-iduino-mega-2560/4563/2 "2019-02-16T22:53:53Z")

</div>

Have not used a MEGA 2560, but assume it is similar to the UNO. Which I have used extensively with the ATMega328P micro.

To program via the USB interface the processor needs a boot loader.  
Possibly the second and third MEGA’s may not have boot loaders. Some ATMega328P chips I have bought had different boot loaders.

In the first error line “.\COM5”: is referenced, is this the port that shows up in the Arduino IDE when the MEGA is plugged in.

Harder to tell more without it being in front of me.

I have found the information Nick Gammon has put together, to be invaluable, maybe something there can help you.  
[https://www.gammon.com.au/forum/bbshowpost.php?bbtopic\_id=123](https://www.gammon.com.au/forum/bbshowpost.php?bbtopic_id=123)

---

<div class="post-metadata">

**Author:** ![Clem73666](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@Clem73666](https://forum.core-electronics.com.au/u/Clem73666)\
**Post date:** [17 February 2019 01:23 UTC](https://forum.core-electronics.com.au/t/programming-iduino-mega-2560/4563/3 "2019-02-17T01:23:44Z")

</div>

Hi James,

Yes com5 is the serial communication port.

Seems strange that the two identical boards received in the same order in the same package, one would have boot loader and one would not. Will look into this - thanks and regards

---

<div class="post-metadata">

**Author:** ![James46717](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@James46717](https://forum.core-electronics.com.au/u/James46717)\
**Post date:** [17 February 2019 04:37 UTC](https://forum.core-electronics.com.au/t/programming-iduino-mega-2560/4563/4 "2019-02-17T04:37:04Z")

</div>

Hi Clem,

You could try the ICSP programming port, but you need a ICSP programmer.

> **[Freetronics USBasp ICSP Programmer for AVR / Arduino](https://core-electronics.com.au/freetronics-usbasp-icsp-programmer-for-avr-arduino.html)**
>
> Program new bootloaders or firmware into a wide range of microcontrollers using this ICSP programmer with a USB interface. Compatible with the popular USBasp and .. read more

I was able to bring an ATMega328P back to life after I programmed the fuses wrongly.  
I followed the process Nick Gammon describes using a UNO as a programmer.

Beware though, it is possible to program the fuses so the micro does not respond to serial or ICSP programming. The only option then is to use a parallel programmer. An expensive one off purchase.

Of course the devices could just be faulty, but that doesn’t seem as likely; seeing 2 are behaving the same, but …

Hope you can solve it.  
Cheers  
Jim

---

<div class="post-metadata">

**Author:** ![Stephen](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/stephen/32/1599_2.png) [@Stephen](https://forum.core-electronics.com.au/u/Stephen)\
**Post date:** [17 February 2019 23:02 UTC](https://forum.core-electronics.com.au/t/programming-iduino-mega-2560/4563/5 "2019-02-17T23:02:47Z")

</div>

Hi Clem,

This is most likely a COM port issue, since it is unthinkably unlikely that two boards would have the same issue out of the box. When you connect a new MEGA, it may assign it a different COM port number (COM 6, or COM 7). I would expect you would need to change this in the IDE.

Alternatively, you may need to go into Device Manager on your PC and uninstall the COM 5 MEGA. The computer may not be able to recognize them as different devices and this is causing the issue.

I think its unlikely that there is a boot-loader issue with two at once.

Let me know how it goes!

---

<div class="post-metadata">

**Author:** ![Clem73666](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@Clem73666](https://forum.core-electronics.com.au/u/Clem73666)\
**Post date:** [18 February 2019 01:26 UTC](https://forum.core-electronics.com.au/t/programming-iduino-mega-2560/4563/6 "2019-02-18T01:26:32Z")

</div>

i was able to select different port (7) for one and (8) for the other and this mad all the difference - they now accept program download.

Regards
