This is a guide for restoring bootloader on Arduino boards via Atmel Studio, a free software which can be found here:
First, we make sure we have the appropiate bootloader hexadecimal (.hex file) for our Arduino, in this example, Arduino MEGA 2560. It must be located in the install directory of Arduino IDE:
\Program Files (x86)\Arduino\hardware\arduino\avr\bootloaders\stk500v2 (or similar path).
In this folder we can find this:
And that is our .hex file.
Start Atmel Studio and click the Device Programming icon on the top toolbar or select Tools → Device Programming from the top menu.
In the Device Programming dialog box, select the Tool (JTAGICE3 or similar), Device(ATmega2560) and Interface (ISP) then the click the Apply button. To test that Atmel Studio can communicate with the AVR on the Arduino board, click the Read button under the Device signature heading.
Click Memories in the left pane of the Device Programming dialog box. Click the […] button found at the right of the box under the Flash label to browse for the bootloader file mentioned before.
After finding it, click the Program button in the Device Programming dialog box to load the bootloader to the ATmega2560 AVR. Close the dialog box when done by clicking the Close button.
A few seconds later, we get our bootloader restored! You can test it with any simple .ino sketch, to make sure everything went correctly.