It can be easily done using Linux. This procedure is for the 328p processor. It can easily be adapted for a 168 processor. You will need an ICSP. First, make sure that avrdude is installed. It can be installed by issuing the command:
sudo apt-get install avrdude
You will need to retrieve the bootloader. It can be found in the hardware/arduino/bootloaders/atmega directory in the 1.0.5 Arduino IDE download. It is named ATmegaBOOT_168_atmega328.hex.
- Put the chip on an Arduino board.
- Connect the ICSP to the Arduino board.
- Power the Arduino with an external source.
- Connect the ICSP to the computer. Find its serial port. Most of the time, it is listed in the system log. The command ‘dmesg’ can be used to find it out. Look at the last lines.
- Open a command line window.
- Issue the following commands. Replace /dev/ttyACM0 by the proper ICSP port.
/usr/bin/avrdude -c avrispv2 -p m328p -P /dev/ttyACM0 -e
/usr/bin/avrdude -c avrispv2 -p m328p -P /dev/ttyACM0 -U flash:w:ATmegaBOOT_168_atmega328.hex
- Unplug the ICSP and reset the Arduino board.