Thursday, February 14, 2013

Bootloading the ATMEGA 328-PU

Since I had my programmer out and breadboard setup for burning I also wanted to burn a bootloader to the ATmega328-PU chip I got today.
Note that it is not the same chip as ATmega328P-PU that is normally included with an Arduino.
I buy these since they are much cheaper and you can use them as the ATMEGA328P-PU chip. They lack the "pico-power" power saving mode but otherwise they are pretty much the same.

Select Arduino Uno board
But if you try to burn the bootloader directly to the 328-PU you will get the following error

avrdude: Device signature = 0x1e9514
avrdude: Expected signature for ATMEGA328P is 1E 95 0F
         Double check chip, or use -F to override this check.
avrdude done.  Thank you.


We have a ATMEGA328-PU and it is not a ATMEGA328P-PU!

To remedy this we trick the AVRDUDE into thinking it is working with a ATMEGA328P chip. This is done by modifying the file "avrdude.conf". You find it in the arduino folder under "hardware\tools\avr\etc".

We trick the Avrdude into thinking its dealing with another chip.
First take a backup of the file... 

Under the 
#------------------------------------------------------------
# ATmega328P
#------------------------------------------------------------
Replace the line 
signature = 0x1e 0x95 0x0F; 

With
#signature for 328P
#signature = 0x1e 0x95 0x0F;
#signature for 328-PU
signature = 0x1e 0x95 0x14;
Then you can burn the bootloader.

But when you are done, change back the signature to 0x1e 0x95 0x0F; otherwise you will get the following message when you try to upload sketches:
avrdude: Device signature = 0x1e950f
avrdude: Expected signature for ATMEGA328P is 1E 95 14
So after the bootloading with the replaced signature the bootloader identifies itself to the avrdude when programming the chip as a true ATMEGA328p!

So change the line avrdude.conf back to
#signature for 328P
signature = 0x1e 0x95 0x0F;
#signature for 328-PU
#signature = 0x1e 0x95 0x14; 
and you can program the chip as any other ATmega328p




No comments:

Post a Comment