Third party cookies may be stored when visiting this site. Please see the cookie information.

PenguinTutor YouTube Channel

Installing an Arduino Bootloader on an ATmega328p

Atmega328p programmer and bootloader shield on an Arduino for installing UNO boot code

In my earlier projects I've created custom Arduino Circuits, KiCAD Arduino PCB design and Model railway automation signals. These have all being based around custom Arduino like circuits based around the ATmega328p microcontroller. In those I recommended buying a ATmega328p with the bootloader pre-installed. This is useful for beginners as it means you can concentrate on the custom circuit, but in this I will go through details of how you can install a bootloader if you buy a basic IC with no bootloader.

The video below gives an introduction to this.

This can be created on a breadboard, but I have also designed a custom PCB shield that can be used as a dedicated programming.

Arduino Bootloader

The Arduino Bootloader is a piece of code responsible for running the user code and/or installing new user code. This runs whenever the ATmega microcontroller is powered-on or reset. Essential it looks to see if the IDE is trying to send new code to the Arduino and if so then it saves that new code to the application area of flash memory. If not then it jumps to the code already in flash memory and starts the microcontroller running. This is an oversimplification, but gives you an idea of how it works.

Without the bootloader then the microcontroller will not be able to do anything unless it is programmed directly using an in-system programmier or similar.

Dedicated AVR-ISP vs Arduino

You can get a dedicated AVR-ISP which is an In-system programmer designed specifically for microcontroller chips based around the AVR architecture (which includes the ATMel ATmega series chips). Alternatively you can install code to an Arduino so that it can act as an In-System Programmer. This is known as an Arduino as an ISP, which is what this guide covers.

Breadboard version

The below diagram shows the basic setup of how you can program the bootloader using an simple Arduino like circuit created on a breadboard.

Arduino Atmega328p programmer and bootloader using a breadboard

Shield version

The initial Arduino shield (shown at the top of this page) is based around the same circuit as the breadboard version, but made into a custom PCB. Whilst this circuit works correctly based on experience with the programmer it would be better with a ZIF socket and to have status LEDs. I have therefore created an updated circuit, although not yet had an opportunity to try it.

Arduino Atmega328p programmer and bootloader using a custom PCB shield

Installing the Bootloader

The following steps should be followed to install the bootloader.

Setup the Arduino as ISP

  • Open the Arduino IDE (preferably a recent version)
  • Open the Example Sketch for Arduino ISP
  • If not using a UNO then uncomment the entry
    #define USE_OLD_STYLE_WIRING
  • Choose the model of Arduino board that you will use as an Arduino ISP
  • Choose the appropriate port
  • Upload the sketch

Install the bootloader

  • Choose Arduino UNO for the board
  • Under Programmer choose Arduino as ISP
  • Choose Burn Bootloader

Install Code onto the Arduino

After installing the bootloader you can move the chip into your project and program from there, alternatively:

  • Disconnect the Arduino from USB and connect a CP2102 UART to the programming pins
  • Open an appropriate Sketch
  • Set board type to UNO
  • Select appropriate port for the UART
  • Choose upload code

Downloads

More information

Future project

I'll be adding new projects based around my own custom circuits in future.

I also plan to design my own custom circuit based around the ATMel ATMega328P which I'll be creating on a custom designed printed circuit board (PCB)

.

To be notified about future videos
Subscribe to the PenguinTutor YouTube Channel

Previous Create your own custom Arduino
Create your own custom Arduino
Next Future plans
Future plans