The Atmega328 microcontroller is at the heart of many Arduino boards and DIY electronics projects. One of the essential steps in working with Atmega328 chips is burning the bootloader onto the chip. The bootloader is a small piece of code that allows you to program the microcontroller over a serial connection, making it easier to upload sketches and update firmware. In this blog post, we will walk you through the process of burning the bootloader onto an Atmega328 IC using an Arduino board as a programmer.
What You’ll Need: To successfully burn the bootloader onto the Atmega328 IC, you’ll need the following components and tools:
- Arduino board (e.g., Arduino Uno or Arduino Nano)
- Atmega328 IC (with or without the Arduino bootloader)
- Breadboard and jumper wires
- 16MHz crystal oscillator (for standalone setups)
- Two 22pF capacitors (for standalone setups)
- 10kΩ resistor (for standalone setups)
- USB cable to connect Arduino to your computer
- Arduino IDE installed on your computer
- Patience and attention to detail
Step 1: Install Arduino IDE If you haven’t installed the Arduino IDE on your computer, head over to the official Arduino website and download the latest version. Install the IDE following the provided instructions.
Step 2: Wiring the Circuit For burning the bootloader, you will use an Arduino board as an ISP (In-System Programmer) to program the Atmega328 IC.
At a certain juncture, I found myself questioning the accuracy of the schematics created for the custom board. To help illustrate the correct way schematics should be drawn for custom boards, I have provided a snapshot of my own schematics below for your reference.
How to program the custom board with Arduino UNO?
Note that the RST pin of the custom board must be connected to D10 pin on the Arduino UNO (Slave select line). Now, open Arduino IDE .
File -> Example -> ArduinoISP -> ArduinoISP sketch
After opening this go to Tools -> Boards -> Arduino UNO. Select programmer as AVRISP mkII.
Now, upload this ArduinoISP sketch to Arduino UNO to convert it as a programmer for your custom board. Once the uploading is done you have successfully converted Arduino UNO as ISP programmer.
Before we proceed with playing around with the custom board, we need to download the proper core files to bootload the IC. To do this,
go to File -> Preferences or press Ctrl + comma on your keyboard.
Paste the following boards link that will help to download and update the boards field of Arduino IDE.
Once it is pasted, click on Ok and exit the window.
Go to Tools -> Boards -> Boards Manager
Find the MiniCore boards file from MCUdude and click on install button to install the boards.
After completing the previous steps, you will now be able to locate the Atmega328, 168, 88, 48, 8 boards within the MiniCore boards section. For this particular tutorial, choose Atmega328p, as it is the one we are utilizing. Under this selection, you will find various options like BOD (Brown out detection), EEPROM, Compiler, and others. For simplicity, it is recommended to leave these settings as they are.
However, it is crucial to ensure that you select the correct programmer. Choose “Arduino as ISP (minicore)” as the programmer. This step is of paramount importance since the Arduino IDE needs to know the correct path through which the code should be sent. Failure to set this programmer correctly may result in errors during the programming process.
Once you have verified that all the options are properly selected, proceed to click on the “Burn Bootloader” option at the end of the menu. This action will initiate the process of burning the Arduino bootloader into the Atmega328p IC. The bootloader enables the Atmega328p to accept various types of codes and instructions over ICSP (In-Circuit Serial Programming) lines.
By following these steps carefully, you will successfully burn the Arduino bootloader into the Atmega328p IC, making it ready to be programmed with your desired sketches and projects. This critical step sets the stage for smooth and seamless uploading of code onto your custom board.
Once this step is successful it is time to write your own sketches and upload them to the custom board. Open your sketch, go to Tools -> Boards -> Arduino Nano
After this step ,finally you need to upload your code using the option
Sketch -> Upload Using Programmer or simply press Ctrl + Shift + U