Matthew Edwards

Burning Arduino Bootloader


So, you have created your first from-scratch Arduino and are ready to start programming. Congratulations! The first thing to do to your fresh board is to burn a bootloader onto the chip. The bootloader is a small program that the processor will start running when it is first powered on. In Arduino’s case, the bootloader’s main job is to detect whether your computer is trying to send it a new program (for example, pressing the “Upload” button from the Arduino IDE).

One of the main issues with my custom board was that it had no direct USB interface. This would make burning a bootloader and uploading programs more difficult, but not impossible. On my custom board, I had a six pin ICSP header. This allows the board to communicate over SPI (instead of UART via USB), and I could load the bootloader that way.

My solution was to use a different programmer on the Arduino IDE known as the “Arduino as ISP”, in which you can
configure a separate Arduino to act as the in-system programmer for your original microcontroller board. The official Arduino documentation has a fairly good tutorial on how to set this up with your IDE and Arduino. Remember that processors might have different BAUD rates at which they can communicate over SPI. The ArduinoISP sketch has some configuration to account for this near line 140:


// Configure the baud rate:

#define BAUDRATE	19200
// #define BAUDRATE	115200
// #define BAUDRATE	1000000

The second issue I had was that the processor on my custom board was an ATmega328pb, which is a slightly
different chip from the standard ATmega328p that the Arduino uses. In fact, when you tried to burn the bootloader to my custom board using the Arduino IDE, you would get the following error with verbose uploads:


avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00

...

Error while burning bootloader.

I solved this by using MiniCore, a hardware library package for Arduino. One of its strengths was that it supported all variants of ATmega, including the PB variant. In order to install it, I pulled the GitHub repo onto my local machine and moved its folder into ~/Documents/Arduino/hardware/ Then open Arduino IDE (restart it if you had it open already), and a new category in the boards menu called “MiniCore” will show up.

I could then burn the bootloader and load the “Blink” program. Now I have a small, working Arduino that I was able to make and program for a fraction of the normal retail cost!