Programming IDUINO MEGA 2560

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?

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

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

Hi Clem,

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

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

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!

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

2 Likes