Flash atmega 8u2 on arduino mega with another arduino mega as ISP

arduinoatmegafirmware

[For a detailed post of my problem read here]

Long story short: My Arduino mega 2560 works fine (I plug it in, code runs flawlessly) except for the usb-serial converter which when connected to the PC (running w7 x64) won't be recongnized, not even on Device Manager.
After digging I came to the conclusion that I had to reprogram the ATmega 8u2 serving as the usb-serial converter.
Borrowed a friend's Mega ADK which works correctly with the same usb cable, OS and everything. Loaded it up with arduinoISP sketch so as to use it to program the 8u2 on my faulty mega. Everything connected and I tried this command on the CMD prompt:

avrdude.exe 
  -C [pathToArduinoFolder]\arduino-1.0.1\hardware\tools\avr\etc\avrdude.conf
  -c arduino -p at90usb82 -P [COM_Port_where_arduinoISP_is_connected] -F
  -U flash:w: [pathToArduinoFolder]\arduino-1.0.1\hardware\arduino\firmwares\arduino-usbserial\arduino-usbserial-mega.hex

when I hit enter the error led flashes, the heartbeat led turns off and nothing happens for a few seconds. After that, the programming led flashes a few times, the error led flashes once and finally the heartbeat keeps on glowing. On the CMD prompt I get this message

avrdude.exe: stk500_getsync(): not in sync: resp=0x00

which leads me to think that my mega is not responding to the programmer.

How can I beat through this error and get my mega to work again?

Best Answer

Here's a few things you might be doing wrong, or that you can try:

  1. Are you connecting to the 6-pin header that is adjacent to the 8u2? That's the ISP port for that device
  2. As described here, if you are using the arduino ISP sketch in the Arduino 1.0 or later environment, you have to modify the ArduinoISP sketch slightly; delay(20) instead of delay(40) in the heartbeat function.
  3. You could always break down and buy a real ISP programmer (I recommend the AVR ISP mkII), and then use AVR Studio to flash your 8u2 with the appropriate hex file.