Sunday, March 24, 2013

Updating Firmware on ATmega16U2

Ok. I promised I'd tell how I updated the firmware on my ATmega16U2 on my Arduino Mega. Hopefully I will remember everything I did. Below are some of the websites I referenced to do this.
http://arduino.cc/en/Hacking/DFUProgramming8U2
http://andrewmemory.wordpress.com/2011/04/14/upgrading-the-arduino-uno-8u2-using-flip/
http://aphes.com/hardware/how-to-set-arduino-mega-2560-r3-into-dfu-mode/

Step 1. Download and install Flip programmer from Atmel.

Step 2. Make sure you have the latest version of the Arduino IDE. This will include the firmware you'll need.

Step 3. Plug in your Arduino and find it in the device manager. There are 6 male pins sticking up near the USB socket. Find the two nearest the socket and bridge them with some wire (as shown HERE and to the right). The Arduino should disappear from the device manager. Take the wire off. The Arduino should re-enter as an unknown device. It is now in DFU mode. If you unplug the USB, you will have to do this step again.

Step 4. Open the new device that is the ATmega16U2 in the device manager and load the driver for the flip programmer. On my install it was C:\Program Files (x86)\Atmel\Flip 3.4.7\usb. I just let it search that folder and it found it. Alternatively you could just say "have disk" and click on it. It should be similar to atmel_usb_dfu.inf.

Step 5. Open Flip. Click Load Hex File. You want "Arduino-usbserial-atmega16u2-Mega2560-Rev3.hex" (assuming you are using a Mega 2560 rev 3). It is in your Arduino folder. It can be found at this location. "arduino-1.0.4\hardware\arduino\firmwares\atmegaxxu2\arduino-usbserial". You should get a message something like "Hex file parsed" at the bottom.

Step 6. Click Select Target Device. Select ATmega16U2.

Step 7. Click Select Communication Medium. Select usb. Click open. This should bring up a new page with all sorts of interesting things to look at.

Step 8. Click Run. Assuming all goes well, you are done. Unplug your Arduino and plug it back in.

The most useful site I found was a blog HERE. Note that he was using an Uno. The Mega rev3 is easier to put into DFU mode. All you have to do is short the two pins I described above.

I hope this was helpful. If you find anything that I posted is wrong, let me know in a comment or by email. You can also email or comment if you have problems and can't get it to work. I will try to help as best I can.

Have fun in your endeavors!
Matthew

2 comments:

  1. hi matthew, a lot of thanks for this one.
    btw i'm planning to make an arduino mega2560 by myself (actually not, cause i got the schematic and board layout from arduino website).
    cause i want to make it by "myself", i'll need a new empty atmega2560 and an atmega16u2(the blank one too). in order to get an official-like arduino mega2560, i should have the firmware and the bootloader on them.
    the thing i want to ask to you, is it possible to do the method you've explained above on an empty atmega16u2? and what about uploading bootloader on an empty atmega2560? do you have any sollution for these?
    please feel free to email at danieltamp@gmail.com (or just reply my comment of course)
    i appreciate any respond from you.

    thanks before,
    Daniel

    ReplyDelete
    Replies
    1. Well I know for certain you can load the bootloader on the ATmega2560. It's fairly simple actually. Here's the link. http://arduino.cc/en/Hacking/Bootloader?from=Main.Bootloader

      As for the atmega16U2, I am not sure. It is certainly worth a try. If that doesn't work you would probably need to hook the programmer up to the ICSP header for the 16U2. Then you could program it directly.

      Delete