Instructables

Bootload an ATmega328

Picture of Bootload an ATmega328

This instructable adds to any of the Arduino on a Breadboard instructables. I wrote my own breadboard-Arduino tutorial, and then I found that I was struggling to program some of the boards I made. A lot of research and dead-ends got me understanding that:

1. You either need a microcontroller with a pre-loaded Bootloader, or must load your own
2. Not all ATmega328’s are equal

(A bootloader, very simply, is a programme that sits on the chip and manages the upload of your sketches onto the chip)

There are plenty of bootloading resources, but I couldn’t find a single one that pulled everything together in a way that made sense to me.

If this instructable helped you, please visit Crash Bang Prototyping, follow us on twitter, and join in with our prototyping resources and tools.

Here goes…

 
Remove these adsRemove these ads by Signing Up

Step 1: Parts

1 x Arduino on a Breadboard
1 x Arduino UNO
Connecting Wires
Arduino IDE installed on your PC

Step 2: The Approach

Picture of The Approach

We’re going to use the Arduino UNO to bootload the ATmega328 that is sitting on the Arduino-on-a-Breadboard. This is fairly straightforward if you have an ATmega328P-PU, but needs an extra step for an ATmega328-PU. I’ll tackle the differences later in the Instructable.

Step 3: Program your Arduino UNO as an ISP

Picture of Program your Arduino UNO as an ISP

We need to program the Arduino UNO to act as a an ISP (In-System Programmer), so that it can burn the bootloader onto the Breadboard chip.

  1. Open the Arduino IDE
  2. Open the ArduinoISP sketch (under File, Examples)
  3. If you’re using version 1.0 of the IDE:

search for void heartbeatand change the line that reads:

delay(40);

to

delay(20);

Connect your UNO to the PC, making sure it’s not connected to the Arduino on a Breadboard.

Ensure your UNO is selected under the Boards menu option, and upload the sketch.

bhutanidivye5 months ago

Thanks a lot

gewkwn5 months ago

thanks for info !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

kylebarker826 months ago

IT WORKED!!!

AndyTallack (author)  kylebarker826 months ago
Great stuff - thanks for letting me know! Would love it if you followed Crash-Bang on Twitter as a thanks :)
Thanks for this. Helped me save a wasted ATmega328
AndyTallack (author)  Antzy Carmasaic6 months ago
Excellent, pleased it helped! Thanks for letting me know.
raja_sekharan2 months ago

Thank you, for the clear instructable. Keep up the good work !

nandan31013 months ago

Hey I tried a lot but it's not working I don't know why I have exactly followed your steps as you said then also it is showing me error again and again

Yikes! Invalid device signature.

Double check connections and try again, or use -F to override

this check. PLEASE HELP ME THANKS

AndyTallack (author)  nandan31013 months ago

Hi. Can you check which ATmega chip you are using?

kylebarker826 months ago

Should we still use a 16MHz Crystal for pin 9 and 10???

AndyTallack (author)  kylebarker826 months ago
Yep, I use a 16MHz crystal. In the next few months I'll be working on an instructable for using other crystals - speed vs power and any complications like uploading sketches etc.
rohith9998 months ago
hiii andy i have successfully bootloaded atmegaP-PU chip using ur tutorial now i want to upload a blink sketch to test it later i want to reflash this chip using pulse sensor sketch using arduino uno tx and rx pins without using FTDI and after thant i want to remove tx and rx pins from arduino and i just want to power up using battery will the sketches run ?
all i want to know this because i am preparing beetband sleeve http://makezine.com/video/wear-your-heartbeat-with-a-pulse-sensor-and-weekend-projects/ from the make magzine could you please help me regarding this


thanks
AndyTallack (author) 1 year ago
Great, thanks for the link.  Why don't you put it into a full-blown instructable, so that everyone can search for it more easily?

A suggestion - I prefer the hardware files from :
http://code.google.com/p/arduino-tiny/

I haven't looked into it in detail, but this seems to offer greater language support - eg. Serial (which the GIThib  version doesn't support)...

Cheers
Andy
pctj1011 year ago
nugrahadi1 year ago
the resistor above the led, does it connect to the ground or 5V?
AndyTallack (author)  nugrahadi1 year ago
It connects to GND - sorry the diagram isn't very clear. If you trace the other leg of the LED you'll see it connects to pin 13 on the Arduino, which provides a +ve source.
Hi Andy,
I have tried your steps but I get an error message - "avrdude: stk500_getsync(): not in sync: resp=0x00"
I also have one more question for you, in the schematic, there is a capacitor connected to pin 1 but the other end of it is not connected to anything at all. What is the value of that cap and where should the other end of it be connected to?
Also I would like to ask you for another help. I have some 328 PU chips that came with preinstalled bootloader and the blink sketch uploaded. when I remove the stock 328P-PU from my Uno Rev3 and install the 328PU, I am not able to upload any sketch. All it does is blinks LED13. I get the signature error. I have tried changing the signature but still I cant get it to upload any new sketch. The IDE version is "arduino-1.0.2"
Please help
AndyTallack (author)  edifiedsprit1 year ago
Hi

I battled with the not in sync error, and if I recall correctly it was linked to that capacitor that isn't connected... although it shouldn't be needed for burning the bootloader, only when uploading the sketches. When are you getting this error, when burning or uploading?

The capacitor incidentally is a 0.1uF - I should have left it off the diagram as I only used it when connected an FTDI board to upload sketches.

On the 328-PU chips: I haven't actually tried them with a preinstalled bootloader, but once I'd burned the bootloader using the method in this instructable I was able to upload sketches without changing the signature. Did you try burning a new bootloader with one of these chips?

If you could send me a list of the steps you followed I may be able to help a little more.

Cheers
Andy
Info: The chips I bought from eBay are 328-PU. It came with Arduino Bootloader and blink sketch already uploaded. So if I remove the stock 328P-PU from my Uno-R3 and insert the 328-PU, I can see the blinking LED on Pin 13. The supplier did not mention what bootloader is installed.The link is here: http://www.ebay.com/itm/120994422530?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649#

Steps that I had followed to Burn a bootloader to the new 328PU chips:

Step 1: I setup a 328-PU on a breadboard as per your circuit diagram. I did not connect the 0.1uF capacitor to pin 1 on the target 328-PU.

Step 2: I connected wires from breadboard to Uno-R3.

Step 3: I edited the avrdude.config file and change the signature as instructed in your instructable, then saved the file and close the folder.

Step 4: I connected Uno-R3 to my laptop and open the IDE (version arduino-1.0.1)

Step 5: In the IDE I went to tools and ensured that the selected board is UNO, Then I went to "Programmer" and selected "Arduino as ISP".

Step 6: I clicked on Burn Bootloader.

Here I get stuck. and I am not able to go any further from here
-------------------------xxx-----------------xxx-----------------xxx----------
Issue 2:

Dear Andy,
My motive is to be able to program (upload new sketches to) the new 328PU chips that I had bought. The reason why I bought those chips is because they came with preinstalled Arduino bootloaders, hence I thought that I would be able to upload sketches onto them just by swapping them with the stock 328 P-PU on UNO-R3.
Sadly I am stuck even here. If I remove the stock 328P-PU from my UNO and insert this 328P-PU, I cant upload any sketches to them. I have tried to upload after changing the signature file, but still I get the same error.
-----------XXX-----------XXX-------------------XXX-----------

Request:
Please provide me with a solution to either issue 1 or issue 2. If I am not asking for too much, then provide solution to both the issues :-)

Thanks a ton in advance...


AndyTallack (author)  edifiedsprit1 year ago
Hi

Just checking - the chips on the link you provided were ATMEGA8 chips, not ATMEGA328. Can you confirm that they are ATMega328?

Secondly, perhaps you could send me the error that the IDE shows - do you have Verbose Output set (File, Preferences, Show Verbose Output during upload).

Cheers
Well, I am really sorry for wasting your time here..:-(. Yes I was wrong. The chip is a ATMega8-16PU.

What can I do with this?? Can I still upload sketches on them by any method?? :-P

AndyTallack (author)  edifiedsprit1 year ago
No worries. Sorry I don't know much about the ATmega8 - it is in fact an older chip used on the early versions of the Arduino - it has less memory, less PWM pins etc. than the ATmega328. To upload sketches, I suggest you try the "Arduino NG or older w/ ATmega8" option from the "Tools/Board" menu in the IDE.

Good luck!
Dear Andy,
I just found that I had to update the boards.txt file with this
" ##############################################################
opti8.name=Arduino Optiboot-Atmega8-16
opti8.upload.protocol=arduino
opti8.upload.maximum_size=7680
opti8.upload.speed=115200
opti8.bootloader.low_fuses=0xbf
opti8.bootloader.high_fuses=0xcc
opti8.bootloader.path=optiboot
opti8.bootloader.file=optiboot_atmega8-16.hex
opti8.bootloader.unlock_bits=0x3F
opti8.bootloader.lock_bits=0x0F
opti8.build.mcu=atmega8
opti8.build.f_cpu=16000000L
opti8.build.core=arduino
opti8.build.variant=standard
##############################################################
"
I am now able to upload sketches once I change the selected board as created by this code.
mspinks1 year ago
hmm. I just ordered some chips and realized I confused the 328-PU for the 328P-PU. What about the "use -F to override this check" Shouldn't there be a way to just put the -F flag in the command automatically? Or I suppose I could do it from the command line every time.
AndyTallack (author)  mspinks1 year ago
Yes, you could do it from the command line but the command line involves a host of parameters and if I recall binary files that you need to specify. For the more technically challenged I must admit I was a little lazy and went with a bit of a "cheat" solution. Let me know if you win with the command line...
gordonpt1 year ago
it works for me! I used Uno r2 IDE 1.01!
Thank you
Can you just copy lines 7261-7447 (ATmega328P description), paste them right underneath and change the code to the ATmega328 signature?
I tried it and I wasn't able to get it to work, even by adding a new board. It ultimately didn't matter though because once you bootload the 328 once, the computer seems to recognize it as an Arduino Uno. I found that you could just change the avrdude.conf file back to normal and still be able to upload to the 328 chip.
AndyTallack (author)  lozervillesuks1 year ago
Hi

I don't think that would work, as when we bootload we are telling the Arduino IDE that we're bootloading an Arduino UNO, which comes with a 328P. You'd probably need to create a new board to appear in the IDE and then link that to the definition for the 328.
Sorry I'm traveling so not able to go through all the steps. Did you try it? Any luck?

Cheers
A
manu081 year ago
Now I got the following

avrdude: Expected signature for ATMEGA328P is 1E 95 14
Double check chip, or use -F to override this check. xD
AndyTallack (author)  manu081 year ago
Hi Are you sure that the chip you're bootloading is a ATMEGA328? The ones that I've worked with have a signature of 1E 95 14.

Do you get a message like this, which will tell you what your device signature is? I've highlighted it in bold
avrdude: Device signature = 0x1e9514
avrdude: Expected signature for ATMEGA328P is 1E 95 0F Double check chip, or use -F to override this check.


If so, try using this signature as the replacement in the avrdude.conf file?  Just make sure that you do have an ATMEGA328, as I don't know what will happen if you try to upload the wrong bootloader... potential toast?

If you don't see a message like the one above, try turning on detailed messages. In the Arduino IDE click on:
- File
- Preferences
- "Show Verbose Output during Upload"

Hope the above helps?

Cheers
A
I tried with Atmega6-16PU. Tried to optiboot. But got this error "avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check."

please help..
Can you upload set by step for boot loading Atmega8 .. Using uno board..

As the error says, you can use the F key to upload to the chip anyway. The problem is that the returned signature is probably all zeros, but whatever it is, the Arduino IDE doesn't like it.
AndyTallack (author)  ajdragornlord2 years ago
Hi

Sorry, I don't have an Atmega8 to try out - and not sure of the variants that there are... so not sure how the Arduino IDE supports this. If the IDE doesn't support it, then you'll likely need to start using the command-line version of AVRDUDE, or even give in and buy Atmel's programmer.

Start with the below tutorial, and try to take it from there.:
http://www.sparkfun.com/tutorials/247

If no joy then suggest you google yourself to death to try to piece it all together.

CHeers
ringai2 years ago
Very nice. This is exactly what I was looking for.

I do have a question, though... Can you uypload a parts list for the breadboarded portion? I'm very new to Arduino. Thanks.
AndyTallack (author)  ringai2 years ago
Great, pleased it worked for you.

You can try the following links:
http://www.instructables.com/id/BaW-Bot-Part-1-Build-an-Arduino-on-a-Board/

or

http://arduino.cc/en/Main/Standalone

There are loads of others, but these work for me.

Cheers