Unable to upload programs to an Arduino Mega2560

Hey all... I've been getting really frustrated with a recent problem uploading programs to my Arduino Mega2560, and I'm really hoping somebody can help out here, cause I'm at my wit's end.

First, the essentials: OS: Ubuntu 10.10 x64 Arduino IDE: 0021 (straight from website, here: http://files.arduino.cc/downloads/arduino-0021-2.tgz) Arduino Board: brand new Mega2560

The Problem:

I've been recently trying to get an absolute encoder hooked up and talking to the Arduino for a project I'm working on, but I've been having some troubles getting THAT to work, so I've been changing out code on the 2560 frequently trying out new things (to be expected).

I was loading new simple sketches intermittently for the past few weeks, and everything was going fine until this past Wednesday night(1-26). I uploaded a sketch to the Mega, tested it (it didn't do what I wanted), so I made some changes then went to upload the new sketch, and I started getting a "comm_timeout" error. I didn't figure it was a big deal, so I disconnected the Arduino from my computer, closed the ArduinoIDE, re-plugged the board in, re-launched the IDE, and checked my settings before trying to upload again. This is where it gets wierd though... Whenever I clicked the 'Tools' menu with the my 2560 plugged in, the IDE just freezes. When it doens't freeze, (or occasionally it un-freezes) it doesn't show any available serial ports (although when I check, via "ls /dev/ttyACM*", I see "/dev/ttyACM0" listed). I've only gotten it th show the serial port and not freeze once since then, but when I tried to upload my sketch, I kept getting an error saying 'Serial port already in use...'

Also, the board does power up, and the "L" light blinks twice a bit when the board is first plugged in, but after that the TX light comes on and just stays lit until I unplug it.

Different things I've tried to fix this: * re-downloading the IDE from the link i listed above - didn't help * using different USB ports on the my computer - didnt help * tried uploading using my other computer (running Ubuntu 10.10, but otherwise same as far as Arduino is concerned) - same behavior as with the first computer * tried everything listed here: http://www.arduino.cc/en/Guide/Troubleshooting#toc1 except for re-burning the bootloader because I dont have / cant afford to buy an AVR-ISP at the moment...

Any suggestions on other things I can try/do to get this thing working again? I appreciate any and all input!

Thanks in advance, Andrew

I don't know... but can you list all of the options under the Serial Port Menu? Or maybe your computer's serial port is dead :(

You have uploaded a sketch that uses Serial comms??? The 8u2 firmware has a bug, and you need to reflash it. Once done, the 2560 is pretty reliable.

However, GOOD NEWS! You do not need an ISP,you need a piece of software called dfu-programmer, and two bits of wire. You reset the 8u2 to a different mode (different USB vendor/product) with the bits of wire, and then dfu-programmer lets you upload the bug-fixed firmware from v0022

Look on the old forum, where I describe how the 2560 process differs from the Uno process that others have described very well

Good luck - this is fix-able :)

Sounds like the firmware bug to me too. Here's the thread showing how to reflash the firmware:


Post 34 is how to reflash a Uno. Post 56 is how the process differs for a Mega 2560. It's worth skimming through the whole thread.

Thank you for the replies so far, I appreciate it!

As for how I'm programming the 2560, I'm using standard USB to program it (not an actual serial port), sorry for the confusion.

I'll give the firmware re-flash a try tomorrow or wednesday, and see if that helps.

Just an update:

My body decided that last week would be a great time to acquire an infection, so I've been too sick to try messing with my Arduino until today, so I decided to give the re-flash a try.

Unfortunately, I've hit a snag. All the posts in the thread posted earlier (this: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1286088093/30#34) point to another forum post for visual directions on how to put the Arduino into DFU mode to update the firmware.. this link, specifically: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1285962838/10#10

However, whenever I try to open that link for further direction, I just get an error: Error: You are not allowed to access this section.

Is there an alternate location for this information? I've tried searching the net, but every other piece of info I've found on putting the Arduino in DFU mode just links back to that same inaccessible forum post. I also found some info in the README on the Arduino firmware github page: https://github.com/arduino/Arduino/tree/master/hardware/arduino/firmwares/arduino-usbserial/ but it simply says: 4.a. assert and hold the 8U2's RESET line 4.b. assert and hold the 8U2's HWB line 4.c. release the 8U2's RESET line 4.d. release the 8U2's HWB line

I can figure out the reset part just fine, but as for HWB, I'm not as confident. I tried tracing lines from looking at the Mega's schematic: http://arduino.cc/en/uploads/Main/arduino-mega2560-schematic.pdf but I'm still not sure if I'm looking at it right, and I don't wanna accidentally fry my board....

Any further suggestions? thanks!


I just got it working. I found a supposed reproduction of the original image from the error-ing post i mentioned earlier here: http://www.scribd.com/doc/45913857/Arduino-UNO and, following some tips from the original thread in this reply: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1286088093/45#56 on how to modify the instructions for the 2560, i was successfully able to re-flash the firmware, and the IDE now works correctly. I was able to upload new sketches immediately, and all appears to be well. Thank you very much stimmer for posting the link to the thread, and thank you wombat42 and baum for your insights!

One final note to anybody stumbling across this in the future: my only fumbling point was that I was not immediately able to determine which capacitor to short to on the 2560 (since the guide was designed with the Uno in mind). To figure it out, just read comment 56 that I linked to immediately above, and keep the 2560 aligned in the same way as the Uno is on the scribd image (i.e. USB port to the left), and it should be obvious. hope that helps!

flyindragon1, if you have a moment could you please download the following image http://arduino.cc/en/uploads/Main/ArduinoMega2650Front.jpg and draw on it an arrow pointing to the place where the second wire should go. Then upload the image here (there's an attachment box under 'Additional Options' when you make a reply on this new board) If you do that I can add in the rest of the graphics similar to the other image.

OK - sorry I have no experience with the dfu program or with working with the chips and re-flashing. I can do programming and have been doing that for a couple of years.

So I don’t understand the dfu utility. I downloaded it and the hex file as in the instructions. But I don’t know how to get the dfu programming software to work!

My Mega 2560 will occasionally upload a sketch, but maybe once every 20 tries. I am guessing it’s the re-flash problem. I’ve read the old posts, but I can’t figure out how to get the dfu running so I can give the commands listed on the post.

This is very, very frustrating! I am using an old Mac running 10.4 and the newest IDE 22 and I just uploaded dfu-programmer 0.5.2


You run the commands in a shell / command prompt / terminal. Unfortunately I have absolutely no experience with Macs so can't be of much more help.

THANKS - I just found a link that steps you through installing the dfu program: https://alliance.seas.upenn.edu/~medesign/wiki/index.php/Guides/MaEvArM-starting-mac But it needs a much higher level of OSX than I can run on my old machine! I am still looking.....

We just put up a tutorial on upgrading the 8U2 firmware: http://arduino.cc/en/Hacking/DFUProgramming8U2

I have an old eMac running 10.5. I successfully got macports to install. In terminal I typed in your command and put in the password for sudo.

But now an error: Warning: no index(es) found. have you synced your source indexes? error: Port dfu-programmer not found.

Any words of wisdom?

OOPs - assuming I can get it working, is the 10K resistor necessary for the mega 2560?

Yes, you also need to connect HWB to ground on the Mega 2560. I also added instructions to the tutorial for a non-soldering version of the upgrade procedure.

On the other hand, if you're not having problems, you might want to just stick with the current firmware. It should work okay on the Mac. On Linux, it's much easier to install dfu-programmer.

I am having problems with the Mega 2560. It will sometimes let me upload programs several times, but usually I have to shut down the IDE, disconnect the board, reconnect it, start up the IDE and then get one good upload and do the whole thing all over again...and often I still can't get it to upload even then. I can get one successful upload out of maybe 15 or 20 tries.

Any ideas on the error code from terminal?

Thanks for the tutorial! It is great!!!!!!!!!!!!!!!

I have looked at a lot of posts, but don't see an image or description of where the location of the pin to short to ground is. It looks like the group of 6 pins near the usb port is the same as on the UNO, but I can't figure out where the two pins in the UNO illustration are on the MEGA.

It's the two pads near the 6-pins (for the 8U2) on the back of the Mega 2560.

Thanks - even the Arduino official site says that the solder pads are next to the map of Italy silkscreened on the back of the board. I really appreciate your clear and concise tutorial.


I'm totally new to Arduino (received this morning the UNO) and I have very few experience with microcontrollers. Here is my experience with the serial issue discussed in this post, in the end my question.

I have an ubuntu 9.10, Arduino UNO, arduino0022 (32bit even if my pc is 64 bit; I guess a Java compatibility issue without consequences for this post).

After 5 minutes of unpackaging I was able to run the blinking led example so I tried the "AnalogReadSerial" and got my board stacked with the TX led always on.

I (eventually) updated the firmware as described in several posts but the problems was still there.

I solved by connecting the board to a Windows PC and uploading a different sketch. I unlocked the /dev/ATM0 serial port on my Linux PC and then it worked again.

I do not know why but I'm not sure I correctly upgraded the firmware.

Now the question, how can I prompt the board to verify the uploaded firmware?

In case the firmware is not upgraded what is exactly the command to avoid until I upgrade the firmware correctly?

thanks in advance, g.

Unfortunately dfu-programmer doesn't seem to have a verify mode.

Enter the following in a terminal:

sudo lsusb -v -d 2341: | grep bcdDevice

The old firmware is 0.00, the new one is 0.01. If you get 0.00 you need to update the firmware again.

(This might be wrong though, maybe someone else can confirm it is right)