Burning a Bootloader on ATMega328P-PU without a Crystal (On Arduino Uno R3)

Cover Photo

Recently, I've been building a circuit which uses an ATMega328P-PU. In order to run code on the microcontroller, it must first have a bootloader installed on it. The ones I bought do not have it installed, so it's left to me. After following the Arduino guide for burning a bootloader, I've run into various problems. In this guide, I will show you how to successfully burn a bootloader onto an ATMega328P-PU without a external crystal on a Arduino Uno R3 and the issues I ran into along the way.

Hardware

  • Microcontroller: ATMega328P-PU (without an external crystal)
  • Elegoo Arduino Uno R3
  • Arduino IDE 2.x

Setup

First we need to install MiniCore (steps are on the Github page). This adds support for the ATMega328 and options to select a clock and other settings.

Burn Bootloader on ATMega328P-PU

Setup Arduino Embedded Microsoft as ISP

Before burning the bootloader, we need to setup the Arduino's embdedded microcontroller (which is also an ATMega328). We do this by uploading a specific sketch to it before proceeding.

  1. Files > Examples > 11.ArduinoISP > ArduinoESP
  2. Click the Upload button with the Arduino Uno board selected

This allows us to use the embedded microcontroller as a an ISP (in-system programmer) in the following steps.

Setup Circuit

Now that we have the embedded microcontroller setup as an ISP, we have to setup our circuit on a breadboard and place our ATMega328P-PU. This will allow us to communicate with it from the Arduino (so that we can burn the bootloader and program it).

  • Ensure there's a 10nanoF capacitor with negative leg in ground and positive in reset on Arduino. This resolved one of my errors mentioned below.

Burn Bootloader onto External MC

Now that the external microcontroller is setup the Arduino, it's ready to have the bootloader burned on it.

Make sure the following settings are chosen:

  1. Click Tools > Burn Bootloader

Note: Ensure debugging mode is on Arduino IDE, so script commands can be copied if your encounter any of the errors below.

Upload Code to ATMega328P-U

  1. Open the sketch you want to upload
  2. Sketch -> Upload Using Programmer

Errors

1. Failed connection (device signature 0x000000)

At first, I was receiving an error when trying to write to the MC. It was saying the device signature was 0x000000. Which seems to mean there's an issue with the connection. To solve this problem, I added a 10uF capacitor between the reset and ground. The positive terminal in the reset and negative in the ground.

2. Incorrect Signature

After resolving the first issue, the device signature came up, but it was incorrect. So, burning the bootloader and uploading sketches failed. To resolve this, I copied the avrdude commands and appended -F to force. This worked perfectly!

Arduino IDE is erroring out on a signature error: avrdude: device signature = 0x1e950f (probably m328p). So, we must force each of the commands manually since we know we're selecting the correct MC.

Workaround for Errors

If running these commands through the Arduino IDE fail, make sure to enable debugging so you can copy the command that's failing. Then you can append -F to the end to force the command through.

For example: "/Users/drew/Library/Arduino15/packages/MiniCore/tools/avrdude/7.2-arduino.1/bin/avrdude" "-C/Users/drew/Library/Arduino15/packages/MiniCore/hardware/avr/3.0.2/avrdude.conf" -v -patmega328 -cstk500v1 -P/dev/cu.usbmodem212101 -b19200 -e -Ulock:w:0xff:m -Uefuse:w:0b11111101:m -Uhfuse:w:0xd7:m -Ulfuse:w:0xe2:m -F