So the bootloader on my arduino got corrupted somehow, lets try and fix it! This method will work with any ‘blank’ atmega328p.
- USBtinyISP from Adafruit
- Arduino dev board
- WinAVR aka avrdude; Dowload, Setup
- Arduino IDE
First make sure you have all the software/drivers setup for the above. Connect the programer to the ICSP port on the arduino make sure you get the right port and get it the right way round!
You need to power up both the dev board and the programmer. Now test that AVR dude can communicate with the board be running the following by reading the fuses of the chip
-B 25 specifies the speed -c usbtiny specifies the device we are using (USBtinyISP) and -p indicates the target chip is a atmel atmega328p.
You should see this result:
lets setup the fuses. First its worth checking them so lets reconnect but this time in terminal mode.
You will recive the same output as before but end up with an “avrdude>” prompt. There are 3 fuses we are intrested in hfuse, lfuse and efuse. To check fuse values you can use the dump command.
For our the arduino bootloader the defualts are hfuse:0xDA lfuse:0xFF and efuse:0x05
to exit terminal mode type “quit”
If any of our fuses where incorrect we can set them using the commands below
You can find the bootloader in the place you installed the arduino IDE. The path should be somthing like:
The file we want to burn is “ATmegaBOOT_168_atmega328.hex” so to burn we run:
This will take a little bit of time the output should look somthing like:
Thats it! Its a good idea at this point to verify the bootloader installed ok by loading a small program onto the chip, happy programming.