Yet another Atmega bootloader burning giude. But this time i bet on the first attempt you will succeed!!
This is Nick Gammons bootloader burning tutorial for Arduino boards.
Step 1: A Few Words
The Atmega328P-PU microcontroller is one of the most popular Arduino chips that are used in a wide range all over the world. But most importantly the bare bones Atmega still does what the standard Uno R3 can do. The main reason why i love this microcontroller is the "Low Power" mode. I have written a some new sketches for a few sensors and i am testing them for a time now.
Back in a few years when i started to play with Arduino my first order was a Atmega328P-PU microcontroller. Later i realised that the ones i ordered from Aliexpress are blank chips. The chips are very cheap on Ali , you can buy them from 1.40$. But they have not contained the Uno Bootloader (Optiboot) and without it i could not upload any sketches. Tough break ha??!! It was a really cold shower for me .......So i was searching for a way to burn the bootloader into the chips. I have tried 5 or 6 methods, but no luck. After a week i found a topic on a website forum that mentioned Nick Gammon's bootloader burning tutorial. First attempt and SUCCESS!! :D Now i will show you how to burn the bootloader to blank Atmega328P-PU chips easily without messing up stuff in Arduino IDE.
Step 2: What Is the Bootloader? (Optiboot)
The bootloader is a small program (HEX file , 0.5Kbyte)that allows you to upload sketches to the flash memory directly from Arduino IDE. The HEX file always runs before the main program and that's why it is needed.
Whithout the bootloader :
-The microcontroller still CAN BE PROGRAMMED!(yes, it is possible), but you would need a dedicated AVR programmer to do that. And it is not cheap!
- It can not be programmed through the Arduino IDE.
Suported bootloaders of this method:
Atmega8 (1024 bytes)
Atmega168 Optiboot (512 bytes)
Atmega328 Optiboot (for Uno etc. at 16 MHz) (512 bytes)
Atmega328 (8 MHz) for Lilypad etc. (2048 bytes)
Atmega32U4 for Leonardo (4096 bytes) Atmega1280 Optiboot (1024 bytes)
Atmega1284 Optiboot (1024 bytes)
Atmega2560 with fixes for watchdog timer problem (8192 bytes)
Atmega16U2 - the bootloader on the USB interface chip of the Uno
Atmega256RFR2 - the bootloader on the Pinoccio Scout board
The code for the following bootloaders is incorporated in the sketch, and will be downloaded depending on which signature is detected.
So we have everything we need.
Step 3: Arduino Sketches Master
First of all you need the arduino library.
Download it from here: https://github.com/nickgammon/arduino_sketches
Or download it from here.
After you have downloaded extract it to Arduino libraries forlder and look for Board Programmer. Open it and run Board Programmer.ino.
Step 4: The Hardware Setup
There are 3 ways to wire up before programming:
- Use the AVR ISP shield
- Arduino A to Arduino B
- And the breadboard method
On the picture you can see how to wire up. On the breadboard the ceramic capacitors are not really needed, but the 16Mhz crystal must be added.
I am using my AVR ISP shield this time.
The goal of this method is, that the program is using the serial monitor to access the flash memory to write the Optiboot (bootloader)
Step 5: The Programming!
After the hardware setup is complete run Board Programmer.ino!
Compile and upload to your Arduino, but don't close the window!! You will need it :)
The upload will take a few seconds.
Step 6: Disconnect!
After you uploaded the sketch disconnent the Arduino from your PC and wire up everything if you planning to do this on the breadboard.
If you use the AVR shield put the Atmega chip in the ZIF socket and "lock" it down.
Very important: As long as the hardware is not set up, the processor must not get VCC!! That way you risk a damage!!
Step 7: Connect!
Ok! The hardware is set up and everything is in place we connect the Arduino to the PC.
Next open the Serial monitor and set the baud rate 115200 and you will see this.
In the serial monitor you can see that the Arduino has entered programming mode. Cool!! :)
Since we want to program Uno (Atmega328P-PU) type a "U" on the in the message prompt and hit enter.
Step 8: Programming State!
In the next window you will see this.
We won't quit or Verify, type a G and hit enter!
Step 9: The Fun Begins! :)
After hitting enter you will see this:
Erasing chip ...
Writing bootloader ...
Committing page starting at 0x7E00
Committing page starting at 0x7E80
Committing page starting at 0x7F00
Committing page starting at 0x7F80
No errors found.
Writing fuses ...
LFuse = 0xFF
HFuse = 0xDE
EFuse = 0xFD
Lock byte = 0xEF
Clock calibration = 0x9E
Programming mode off.
Type 'C' when ready to continue with another chip ...
And happy day!! :D Your Atmega328P-PU chip is now ready to upload sketches!
This was easy wasn't it? :)
Step 10: A New Chip!
If you want to program another chip disconnect Arduino from your PC, replace the chip with a blank one. Reconnect Arduino and do the steps again.
If the serial monitor does not respond after reconnecting the Arduino, don't panic just close it and open a new one.
Step 11: DISCLAIMER!!
I DO NOT OWN ANY OF THIS!! All the credit goes for Nick Gammon!!
I just showed this method in this Instructable.
Hope you will find this useful.
Have a nice day.
Step 12: When Weird Stuff Happen
Recently i received this Arduino Nano with Atmega328P-MU processor.
So i have tried uploading a sketch to it, but i could not. The processor not responded to anything with options Atmega328.
OK! So maybe the bootloader is corrupted and needs a rewriting. I wired it up with another arduino and done the bootloader burning. Still nothing......!!!!
Ok then, i need a brake (coffee and a cigarette)!! As a last chance i selected Arduino Uno again as a target. Upload complete :D
At this time i have a Nano that acts like a Arduino Uno. I don't know why this happened but i think this is because of the Processor signature. Anyway it really made my day and it is a bit funny :)
pavik_ made it!