For the past couple of days I've been having a problem with my arduino mega 2560 R2. It's my fault ("it's the man my friend, not the machine" I firmly believe that) but I'm stomped as to what to do to unbrick the device, if anything possible. Here is what happened. I had a sketch I was working on, on arduino IDE 1.0.5, and as soon as I clicked on "upload" I realized I had forgotten to plug up the board to the usb. Instead of doing the right thing, waiting for it to fail and then connect and reupload, I connected the usb while it was compiling. Something went horribly wrong (I am guessing the atmega8u2 is totally confused) and since then the board is completely undiscoverable. I tried reloading the bootloader using an Uno with no luck. As soon as I connect the usb the L led blinks twice every second and that's it. I also tried to follow this http://arduino.cc/en/Hacking/DFUProgramming8U2 to reprogram the chip but it does not show up at all at the device manager.
Is there anything I could do to salvage the board? Any ideas at all?
Thanks in advance...
If you are not familiar with avrdude (the program the IDE uses to upload sketches) you can generate the boards.txt file, bootladers directory, etc to allow the Arduino Burn Bootloader process to do the work.
In your Arduino/hardware folder create a folder named 'atmegaxxu2'. In there you put a custom boards.txt file and a bootloaders folder. The boards.txt file will tell the Arduino IDE where to find the bootlader and which processor you are uploading to.
John, first of all thanks for your prompt replies.
See my problem right now is that when I plug the mega board in my usb it is not recognized by the computer at all. I tried what you said but got:
avrdude: usbdev_open(): did not find any USB device "usb"
You mentioned programming it using an Uno through ICSP. I think if there is any hope for that board that's it. Is it possible? Is there anything you might have seen around from someone that has attempted it?
To use the "Burn Bootloader" process (programmer connected to ICSP) you need the appropriate data files installed. I made a quick pass at it and attached the files. Expand the .zip in Arduino/hardware to create:
After you install and re-start the IDE you should see "ATmega16u2 on Arduino Mega 2560 Rev3", and "ATmega16u2 on Arduino MegaADK Rev3" in the Tools->Boards menu.
Connect your UNO.
Select Tools->Boards->"Arduino UNO"
Select Tools->Serial-> (the serial port for your UNO)
Upload the "ArduinoISP" example.
Disable auto-reset on your UNO.
Connect pins 10-13 of your UNO to the ICSP header for the 16u2 on your Mega 2560 board.
Connect power and ground to the ICSP header, too.
Select Tools->Boards->"ATmega16u2 on Arduino Mega 2560 Rev3"
Select Tools->Programmers->Arduino as ISP
Select Tools->Burn Bootloader
Thank you for your time and elaborate explanation. Unfortunately I was not able to reprogram the chip. I kept getting an error from avrdude (through Arduino IDE) about the board ID being 000000 and expected a different value. It might be because I have Mega R2 (with 8u2 chip) and I had to download a different bootloader appropriate for my chip and modify your example a little to accommodate for that. I might have made a mistake during that process. In any case I have started giving up on that chip, I have already ordered a new one and I know what not to do next time
Thanks again for your time and patience in the matter.
Arduino: 1.0.6 (Mac OS X), Board: "ATmega16u2 on Arduino MegaADK Rev3"
avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check.