I searched all over the internet for a solution for the Arduino Mega 2560, but never found a definitive answer. After much trail and error, I think I may have found a sure way to upload sketches to your Arduino Mega 2560 without a functioning USB chip. This problem is a lot more trivial for the other boards, but the ATmega2560 chip causes a lot of new problems due to its large memory size. The solutions that worked for the other boards don't apply to the Arduino Mega 2560 because its flash memory is larger than 128kb and therefore uses a different uploading protocol.
You might have wondered why I didn't include a video in the last blog post on motor drivers... probably not. Long story short, I fried the ATmel8U2 chip on my Arduino Mega board. The ATmel8U2 chip replaced the FTDI chip from the earlier Arduino models and controls the USB-to-serial communications. Without this chip you can't use the USB cable to upload sketches, but thankfully there is an alternative way to program your Arduino.
|This 6-pin header is where you'll connect your AVR programmer|
The Arduino Mega 2560 is the first Arduino to have more than 128kb of flash memory and has to use a different protocol for programming. You cannot just use any AVR Programmer, you have to make sure that it is compatible with the ATmega2560 chip. The USBtinyISP is a nice programmer you could probably build yourself that can program the ATmega328 and 168. But, it is unable to handle any chip with more than 128kb of memory. If you have a Arduino Mega 2560, make sure that the AVR programmer you buy is not a USBtiny clone.
You could buy the official ATmel AVRISP mkII programmer for $34 from their website, this is guaranteed to be compatible with the 2560. I purchased an AVRISP mkII clone from Pololu, the Pololu USB AVR Programmer for $19.95. It comes with a 6-pin ISP programming cable and a USB-mini cable.
Pololu has a User Guide to help you set-up your programmer and provides downloads for the drivers and AVR Programming software.
If you have any board other than the Mega 2560 (less than 128kb of flash memory), there is a way to set the Arduino IDE to use the ISP programmer instead of the USB by editing the boards.txt file and changing the upload method. The Arduino IDE uses avrdude behind the scenes to upload your sketch and has AVRISP compatibility. This method didn't work for my board and programmer, so I'm not going to go into details. Google is your friend.
After many wasted hours messing with avrdude, I found a way to upload sketches written in the Arduino IDE with the Pololu USB AVR programmer using AVR Studio 4.
Start a new file in AVR Studio for your Atmega 2560 chip. Plug in your AVR programmer and your Arduino Board. You will need to power both the programmer and the Arduino board separately, the programmer doesn't provide power for the Arduino. Connect the 6-pin ISP cable to your Arduino's ISP header.
Goto Tools>Program AVR>Connect...
Select AVRISP as your platform and whichever COM port your programmer is connected to. Auto may or may not work.
In the Main Tab, set your device to the ATmega2560 and your ISP frequency to 1.843 MHz (not sure if the freq change is necessary, but it works for me). If you click the Read Signature button, it will check the pin connections and make sure it's plugged in correctly.
If you look inside of the boards.txt file located in your Arduino directory, you can find the Fuse and Lock Bits settings for the ATmega2560. Double check the Fuse Tab to make sure that they match with the ones above, I didn't have to fix anything here. If not, change them and hit the program button.
Under the Lock Bits Tab, you will need to edit the values. The default value should be 0xFF, but the required value in the boards.txt file is 0x0F. If you try to type in 0x0F, it will change to 0xCF. I just left it at 0xCF and clicked the Program button. If it gives you a verification error, Uncheck the Verify after programming box and re-click the Program button.
Depending on what happened to your board, you may need to re-burn your bootloader onto your chip. Locate the hex file in your Arduino folder:
Load it into the Flash section of the Program Tab, but don't click the button just yet.
Goto the Auto Tab and check the following boxes and click the Start Button. If everything was set correctly, you should now have the bootloader freshly installed onto your Arduino board. If you cannot upload the bootloader onto your chip, try updating the firmware on the Pololu USB AVR Programmer. Check the User Guide for details. If it still won't program, check to see if anything beside the USB chip was fried. Your Arduino may be more damaged than you thought.
As of right now, there is no easy way to convert your sketches into .hex files. When you compile your sketches in the Arduino IDE, it creates a temporary hex file that you will need to locate in your computer's TEMP folder. I am using Windows 7 so this might not apply to you. KEEP THE ARDUINO IDE PROGRAM OPEN WHILE YOU LOCATE THE HEX FILE. Open up the sketch that you want to upload and compile it. Go to your temp folder(you will need to have hidden folders viewable):
There will be a folder called "build" followed by a large string of random numbers. Inside the folder will be your sketch's hex file. It's easier to find if you have file extensions viewable. I suggest moving this file to your desktop or another folder as it will be deleted once you close the IDE program.
Go to the Program Tab and now upload the sketch's hex file in the flash section.
Finally, go back to the Auto Tab and click the Start button. Huzzah! As long as there were no errors your sketch should now be uploaded to your Arduino Mega 2560.
Manly tears were shed
It may not look like much to you, but after trying everything to fix this board for the past week... reading every single forum post... clicking on every single Google link... Getting that LED to finally blink was quite the accomplishment.
After I get some well deserved rest, I'll be sure to get back to updating the blag regularly. We almost lost the Arduino there, but the blag must go on.