Extra components needed:
- a 16 MHz crystal,
- a 10k resistor, and
- two 22 picofarad capacitors.
Program your Arduino Uno to be "Arduino as ISP":
- Connect Arduino Uno to PC with USB cable.
- Select Tools -> Port and your current connected Board (Arduino Uno).
- Select File -> Examples of ArduinoISP.
- Compile and upload to your Arduino Uno board.
- Once finished, your Arduino Uno is a "Arduino as ISP" now.
Burn bootloader to Atmega328, using your "Arduino as ISP":
- Select Tools -> Board, it is the board on which you want to burn the bootloader, not your current connect board. I will use Arduino Uno as target to verify my steps and setup later, so I keep using Arduino Uno.
- Select Tools -> Programmer of "Arduino as ISP".
- Select Tools -> Burn Bootloader
- Disconnect USB cable between Arduino Uno and yout PC.
- Replace the ATmega328 controller on your Arduino Uno with the new burnt ATmega328.
- Connect to PC again and try any example, it should be work as your original Arduino Uno.
I have one chance failed with the error:
Arduino: 1.5.7 (Linux), Board: "Arduino Uno"
avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
It is caused by bad contact, solved by slightly fixing the wires.
Mention in the tutorial "Using an Arduino as an AVR ISP (In-System Programmer)": Note for the Arduino Uno: you'll need to add a 10 uF capacitor between reset and ground.
In my trial experience, I have no this capacitor added.