How to reset Mega 2560 R3

I tried a program which was installed by entering the following line at a command prompt.

C:\arduino-1.0.3\hardware\tools\avr\bin\avrdude -patmega2560 -cwiring "-P\.\COM7" -b115200 -Uflash:w:apduinos-headless.hex:a "-CC:\arduino-1.0.3\hardware\tools\avr\etc\avrdude.conf"

Frankly, I don't quite understand what this does, but I want to get my Mega R3 back to factory/stock/default condition. I would appreciate any advice on how to do that.

If the processor has not had the Reset or Serial Programming fuses set to disabled you should be able to reset your Arduino to factory settings with your choice of ISP device. Just select the programmer (Tools->Programmers) the board type (Tools->Board->Arduino Mega 2560) and select Tools->Burn Bootloader.

You can buy a USBasp programmer for under $4 on eBay. Most come with only a 10-pin cable so you should either look for one that includes a 6-pin cable or get a 10-pin to 6-pin adapter for about $3 on eBay.

1 Like

Let's assume the OP has one of those, or he wouldn't have been able to replace the bootloader.

If you upload this .hex file (below) it should put the bootloader back.

(You probably need to go to that page, RH-click on the Raw button, and save the file appropriately).

You should also have the original bootloader on your disk in the "bootloaders" folder, named "stk500boot_v2_mega2560.hex". However the one that ships has a bug, I believe, with the way it handles watchdog timeouts.

However the one that ships has a bug, I believe, with the way it handles watchdog timeouts.

Correct, plus it barfs the upload if the flash contents has three !!! in a row.

Lefty

Thanks guys. I only have a USB cable (no ISP device). So I'm guessing the command prompt code I executed has not affected the bootloader, which would mean I am still in stock condition.

Yes, unless you had a second Arduino and connected them together in such a way that one programmed the other.