loading
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.

Step 4: Connect your ATmega328

Picture of Connect your ATmega328
ATMega328 Pins.JPG

Now connect your ATmega to your UNO as follows:

  • UNO 5v ---> ATmega pin 7 (VCC)
  • UNO GND ---> ATmega pin 8 (GND)
  • UNO pin 10 ---> ATmega pin 1 (RESET)
  • UNO pin 11 ---> ATmega pin 17 (MOSI)
  • UNO pin 12 ---> ATmega pin 18 (MISO)
  • UNO pin 13 ---> ATmega pin 19 (SCK)


Make sure that you don’t have anything else connected to the ATmega pins used above.

Step 5: Which ATmega328 are you using?

Picture of Which ATmega328 are you using?

I learnt the hard way that there is more than one type of ATmega328. The two variants that are of interest to us are the ATmega328-PU and the ATmega328P-PU.

The -PU suffix means that the chips are in a PDIP package, the format we need for our breadboard.

The 328P is a picoPower processor, designed for low power consumption, and is used on the Arduino boards. Given low power consumption this is first choice.

The 328 does not have picoPower technology, and is not used on the Arduino boards – and is not explicitly supported by the Arduino IDE.

What this means is that we can easily bootload the ATmega328P, but not the ATmega328. Unfortunately the websites that sell these chips don't always differentiate between them and forums are filled with people struggling to use the ATmega328-PU.

Luckily there is a workaround - take a look at my Crash Bang website.

Step 6: ATmega328-PU workaround

Picture of ATmega328-PU workaround

Each microprocessor has a signature – a unique code that identifies its model. When you bootload a chip (or even upload a sketch) the Arduino IDE checks that the chip selected matches the type it’s connected to. Even though the ATmega328-PU in essence functions in the same way as the ATmega328P-PU, it has a different signature, and one that isn’t recognised by the Arduino IDE.

(Behind the Scenes: The Arduino IDE actually uses AVRDUDE to programme the chips, so you’ll see error messages from avrdude)

If you try to bootload an ATmega328-PU, you’ll get a message something along the lines of:

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

You could also get a more colourful version:

avrdude: Yikes! Invalid device signature.


The way to work around this is to “trick” the IDE into believing your 328-PU is in fact a 328P-PU. Disclaimer: I have tested this myself and it works – no guarantees however that you won’t have unforeseen consequences.

Workaround:
In your Arduino folder, find the subfolder: ..\hardware\tools\avr\etc

  1. Make a backup copy of the file: avrdude.conf
  2. Open the file avrdude.conf in a text editor
  3. Search for: “0x1e 0x95 0x0F” (this is the ATmega328P signature)
  4. Replace it with: “0x1e 0x95 0x14” (this is the ATmega328 signature)
  5. Save the file
  6. Restart the Arduino IDE
  7. Continue with the rest of the steps in the instructable, and once bootloading is complete restore the backup copy you made.

Step 7: Bootload the ATmega328

Picture of Bootload the ATmega328
Burning Done.JPG

In the Arduino IDE, from the Tools menu:

  • under the Board option choose Arduino UNO
  • under the Serial Port option ensure the correct port is selected
  • under the Programmer option choose Arduino as ISP


To burn the Bootloader, choose Burn Bootloader from the Tools menu

You should see a message “Burning bootloader to I/O Board (this may take a minute)"

Once the bootloader has been burned, you’ll see a message confirming the success.
 

Congratulations: You're now ready to load sketches onto your Arduino on a breadboard!



Uploading Sketches

ATmega328P-PU: You can leave your setup as it is, and use the Arduino UNO to upload sketches to your newly bootloaded ATmega (File, Upload using Programmer).

ATmega328-PU: the IDE will notice that the signature isn’t valid – so you’ll have to either alter the avrdude.conf file again or use an FTDI board to upload. I prefer using an FTDI board anyway as it doesn’t take my UNO out of circulation and is quick to connect.

1-40 of 82Next »

Thanks a lot

gewkwn1 year ago

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

IT WORKED!!!

AndyTallack (author)  kylebarker821 year 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 Carmasaic1 year ago
Excellent, pleased it helped! Thanks for letting me know.
ksnanda1 month ago
Hi,

I have an atmega328p MLF package type that's mounted on a pcb with crystal (SMD Type) and other few components.

How to upload code to this ?
AndyTallack (author)  ksnanda1 month ago

Hi

It may have an ISP header? Can you send a link to the product you have?

Cheers

Andrew

bpatil652 months ago

my softwear are not working

subhro.j.bose2 months ago

I can't save F0. it is showing this error message. now what to do? please help........

Capture.JPG
AndyTallack (author)  subhro.j.bose2 months ago

Wow - that's an error I've never seen before. Can you give me more info on what you were doing when it happened? Looks like some kind of security rights issue.

actually I have done all the job but it is showing the same problem.Nothing new is showing. And inside the "etc" folder there already have “0x1e 0x95 0x14” sooooooo what to do now ?

mdeudon2 months ago

The bootload of my arduino has been corrupted. Through this tutorial I've fixed it, especially with the STEP6.

Thank you so much for sharing your experience

Michael

AndyTallack (author)  mdeudon2 months ago

Awesome - thanks for letting me know - really pleased it helped

JPS27 months ago

Perhaps a better, more permanent solution: if you buy a lot of these chips is to edit avrdude.conf and add the following below the part parent "m328" section:

part parent "m328" id = "m328pu"; desc = "ATmega328PU"; signature = 0x1e 0x95 0x14; ocdrev = 1;

This should permanently add the 328PU to your supported parts for avrdude.

pchretien JPS23 months ago

Hi JPS2 ... I would prefer this permanent solution but I have not been able to make it work. I get a "syntax error" at the line I have the "part parent" instruction. Any suggestion?

AndyTallack (author)  JPS26 months ago

Thanks for the suggestion. When I originally wrote this, the GCC toolchain didn't support the m328, so while AVRDude would upload ok, the sketch wouldn't compile. I understand this has changed with the latest releases of GCC - I need to test it out and amend the Instructable as soon as I have a chance.

Thanks for the post.

malvai4 months ago

thanks a lot!

Jonoi.Ramsay4 months ago

I have the ATmega328 with Arduino Bootloader (http://tinyurl.com/o4n9cxe). I do not have the 16MHz crystal and so im using the minimun circuit wiring setup to upload sketches (http://arduino.cc/en/Tutorial/ArduinoToBreadboard). but it does not work when i try to upload on a breadboard.

AndyTallack (author)  Jonoi.Ramsay4 months ago

It's likely that the ATmega you bought is configured to work with a crystal. ATmegas have "fuses" that can be set to configure where the system clock is sourced from. It's likely that the one you bought has the fuses set for an external 16MHz crystal, as that's what teh Arduino uses. If you have an Arduino UNO, try switching the new microcontroller out for the existing one.

kamalpancholi5 months ago

Hey thanks man... This is a great help to me. I had an ATMEGA 328-PU and I was in problem of burning bootloader. This is working. Thanks a lot....

AndyTallack (author)  kamalpancholi5 months ago

Excellent! Pleased it helped and salvaged your 328-PU chips!

kamalpancholi5 months ago
danis.dan.55 months ago

1) Uploading sketches in such a way (with the bootloading way) does mean that the bootloader will be erased after uploading a sketch, doesn't it? We just do that for fuses etc?? Could we upload a sketch without before burning the bootloader on our (breadboard) chip?

2) Using FTDI u mean w remove the chip from the Arduino Uno and programming via Rx and Tx pins, remaining/leaving the same "Arduino on a breadboard" circuit as it is?

gLorieul7 months ago

Hi,
@AndyTallack just to say that on linux, the "avrdude.conf" file is located in "/etc/avrdude.conf" (at least that is the case for linux mint 17 "Qiana"). You might want to add this information to your tutorial ; I am sure linux users would appreciate that.
Everything else works as expected.
Thanks for the tutorial !
Cheers,
G. Lorieul

AndyTallack (author)  gLorieul6 months ago

Great, thanks - will include when I get a gap.

Thanks for the info!

saikat198 months ago
It didn't worked fr me I''m using atmega 328-pu
AndyTallack (author)  saikat198 months ago
Sorry to hear that - can you give me more info?
saikat198 months ago
It didn't worked fr me I''m using atmega 328-pu
MarkF78 months ago

If swapping back and forth gets annoying then you can just copy the entire section to a new one, give it an id of "m328pu" and a description of "ATMEGA328PU" with the appropriate fuse values. You can then edit your Arduino IDE "boards.txt" file and create a new board based on the Uno one with the mcu set to "atmega328pu". You'll then be able to select that device in your IDE Board list in addition to the regular Uno board.

AndyTallack (author)  MarkF78 months ago
Thanks Mark. I had tried that originally, but the GCC toolchain (as I understood) didn't support it. What version of the IDE are you using? I believe the new GCC toolchain now supports but haven't had a chance to test yet.
mbose29 months ago

Plz help me Sir, I have modified the conf file. But now on hitting arduinoisp, it says 'Expected signature for ATMEGA328P is 1E 95 14'.

AndyTallack (author)  mbose29 months ago
Hi

Does it tell you what the actual signature is?

Are you sure it is an ATmega328?

Thank you so much for replying Sir. That was my mistake. I'm now using IDE1.0.1(1.0.6 previously). The error now is unrecognized character : "P"

3suresh9 months ago

i made iiiiiiiittttttttttttttttt

mbose2 3suresh9 months ago

I get error message saying expected signature for ATMEGA328P is 1E 95 14, even after modifying the conf file. Do you know the solution Sir?

novianwf9 months ago

thanks a lot i want to try this

ShajeehM9 months ago

i m getting this error avrdude: stk500_getsync(): not in sync: resp=0x00 while burning the bootloader to atmega 8L-8pu can any one tell me how to burn bootloader to this chip

AndyTallack (author)  ShajeehM9 months ago

Sorry I don't have an ATmega8 to test this on, but should work - see the comments below on possible way to do this.

ShajeehM9 months ago

i m getting this error avrdude: stk500_getsync(): not in sync: resp=0x00 while burning bootloader to atmega8L-8pu can some one tell me how to burn bootloader and upload sketch to this chip

1-40 of 82Next »