CT-UNO - BBFuino_bb

Using ISP to Burn Bootloader into Arduino

If you are building your own Arduino, or need to replace the IC, you will need to load a bootloader program into the Atmega328 (on UNO and BBFuino). There are also cases where you have put your board into a weird setting and you cannot upload code into it, reinstalling the bootloader will be the easiest and quickest way to fix it.

What is a bootloader? 

A bootloader is basically a .hex file that runs when we turn on the Arduino board and allows us to program Arduino board over the serial port. It is very similar to the BIOS that runs on our PC. Without the bootloader, we will need a special programmer, i.e. AVR USBASP Programmer, to program the Atmel AVR. Due to the effort of Arduino, now we just need a USB cable (on Arduino UNO) or USB to serial converter (On BBFuino) to program our Arduino board.

This tutorial will hopefully show you how to burn the bootloader into an Arduino board, and there is 3 sessions in this tutorial: 

  • Session 1: Burn Bootloader into CT-UNO
  • Session 2: Burn Bootloader into BBFuino
  • Session 3: Burn Bootloader into standalone Arduino

 

Session 1: Burn Bootloader into CT-UNO

Basically there are two steps involved in burn bootloader:

  • Step 1: Prepare ISP Programmer
  • Step 2: Burn Bootloader

An ISP (In-system programming) programmer is needed to burn bootloader. In this tutorial, we will use a CT-UNO as an ISP programmer. To prepare CT-UNO as ISP programmer, firstly we select “ArduinoISP” from the File > Examples menu. 

ScreenShot001

 And upload it into CT-UNO. 

ScreenShot002

After done uploading, we select “Arduino as ISP” from the Tools > Programmer menu.

ScreenShot003

Now the CT-UNO is working as an ISP programmer.

The next step is to do some wiring between ISP programmer and target Arduino, the connection is shown in table below: 

ISP Programmer (CT-UNO) Target Arduino Board
Pin 13 Pin 13
Pin 12 Pin 12
Pin 11 Pin 11
Pin 10 Reset
5V 5V
GND GND

Or, you can refer figure below: 

CT-UNO - CT-UNO_bb

 

After wiring up, go to Tools > Board and choose “Arduino Uno” as the board of the target Arduino.

 ScreenShot004

After that, click on “Burn Bootloader” from the Tools menu, the ISP programmer will start to burn the bootloader into the target Arduino. It usually takes few minute to complete burning bootloader.

ScreenShot005

Burn bootloader is in progress. 

ScreenShot007

 

Arduino IDE will display “Done burning bootloader” when it is done. 

ScreenShot008

After complete burn bootloader, your target Arduino is able to accept code from your Arduino IDE. Just unplug the ISP programmer and plug the target Arduino to PC via USB cable, and you can upload your sketch to the target Arduino as usual. Remember to change the Tools > Programmer from “Arduino as ISP” to “AVR mkII” before you upload sketch to the target Arduino.

ScreenShot009

Session 2: Burn Bootloader into BBFuino

BBFuino, or Breadboard Friendly Arduino, is the first Cytron version of Arduino compatible board. It is designed to fit breadboard for prototyping and learning purpose. An USB to UART converter, i.e. UC00A or UC00B, is required to upload Arduino sketch into BBFuino. If you get the BBFuino from Cytron, it is preloaded with bootloader :). So the following steps are only applicable if you replace fresh new IC on BBFuino, or in some cases, you corrupt the bootloader.

BBFuino is using ATmega328 IC instead of ATmega328P IC (at the time this tutorial is written). ATmega328 and ATmega328P are almost similar. The difference between these ICs is ATmega328P has the Atmel picoPower technology while ATmega328 does not have. With picoPower technology, ATmega328P are suitable to be used in low power application. Besides, only the ATmega328P is recognized by Arduino whereas the ATmega328 is not. Hence, it may cause an issue that we cannot burn bootloader into ATmega328 using the method we discussed in session 1. When we try to burn the bootloader into ATmega328, you will obtain the error as shown in figure below: 

error01

 

This is due to ATmega328-PU and ATmega328P-PU have the different identification signature: ATmega328 has signature of 0x1E 0x95 0x14 while ATmega328P has the signature of 0x1E 0x95 0x0F

Can we still burn the bootloader into ATmega328? The answer is YES! There are two methods can be used to burn the bootloader into ATmega328: 

  1. Burn the Optiloader into ATmega328. 
  2. Modify the configuration of Arduino IDE. 

The first method is burn the Optiloader into ATmega328. Optiloader is a sketch designed for bulk upgrading of Arduino board bootloaders using another Arduino as an ISP programmer. It is suitable for microcontroller ATmega8, ATmega168, ATmega328 and ATmega328P. To burn the Optiloader, just follow the procedure below: 

  1. Download the Optiloader in Github. Click on “Download ZIP” to start the download.
    ScreenShot010
  2. After done downloading, extract it using any unzip software. 
  3. There is 3 files in the OptiLoader – master directory, open the optiLoader.pde file using Arduino IDE.
    After a couple second, a window will pop out and prompts you whether you wanna create a sketch folder named “optiLoader” and move the optiLoader.pde inside that folder. Click on “OK”.
    ScreenShot011optiLoader.pde is opened:
    ScreenShot012
  4. OptiLoader.pde requires its library file to be included in the sketch file. Else, this sketch file cannot be compiled. To include the library file, first click on “Add File…” from the Sketch menu
    ScreenShot013
    Choose the “optiLoader.h” library file from the Optiloader – master directory and then click “Open”.
    ScreenShot014
    After you click “Open”, you will notice that there is a “optiLoader.h” tab beside “optiLoader” in the Arduino IDE:
    ScreenShot015
  5. Connect the CT-UNO and BBFuino as figure below:
    CT-UNO - BBFuino_bb
  6. Upload the sketch. It will takes up to 2 minutes. Be patient!
  7. The upload sketch process is completed when Arduino IDE displays “Done uploading”, at the same time, the BBFuino is completed burnt with optiLoader too!
    ScreenShot016

Now the BBFuino is ready with bootloader firmware and can be use with UC00A to accept code from Arduino IDE. 

The second method is modify the configuration of Arduino IDE. As we mentioned earlier, the difference between ATmega328 and ATmega328P are the picoPower technology and their identification signature. Other than that, ATmega328 and ATmega328P are the same every sense architecturally. Hence, we can modify the configuration of Arduino IDE so that Arduino IDE can treat ATmega328 as ATmega328P. 

There are 3 steps for this method. 

The first step is preparing an ISP programmer. Refer to session 1 to turn CT-UNO into an ISP programmer. 

The second step is modifying the configuration of Arduino IDE, just follow the procedure below: 

  1. Close the Arduino IDE. 
  2. Locate your Arduino directory. In my case, my Arduino directory is C:\Users\user\Desktop\arduino-1.0.5
    Then, locate the directory hardware\tools\avr\etc. You will notice there is a file named “avrdude.conf” inside that directory. ScreenShot017
  3. Make a copy of file “avrdude.conf” for backup purpose. 
    ScreenShot024
  4. Open the file “avrdude.conf” using WordPad. 
    ScreenShot018
  5. Search for “m328p”. 
    ScreenShot019
  6. Look for “signature”. It should be few lines under “m328p”. 
    ScreenShot020
    Change 0x1e 0x95 0x0f to 0x1e 0x95 0x14
    ScreenShot021
  7. Click “Save” to save the edited configuration file and close it. Now you done modified the configuration of Arduino IDE. 

The third step is burn the bootloader. First, connect the ISP programmer to the BBFuino: 

CT-UNO - BBFuino_bb

Next, select “Arduino Uno” from the Tools > Board menu. 

ScreenShot022

Click on “Burn Bootloader” from the Tools menu and wait for few minutes for burning bootloader process. 

ScreenShot023

After the burn bootloader process is done,  the BBFuino is ready with bootloader firmware and can be use with UC00A to accept code from Arduino IDE. 

For this method, if you plan to burn the bootloader or load the program into ATmega328P device, i.e. CT-UNO, be sure you modify the configuration of Arduino IDE before you burn the bootloader or load the program. This is because after modify the configuration, ATmega328 is recognized by Arduino IDE but ATmega328P is not. Repeat the modifying the configuration of Arduino IDE procedure and change the signature from 0x1e 0x95 0x14 to 0x1e 0x95 0x0f

Session 3: Burn Bootloader into standalone Arduino

Standalone Arduino is the ATmega basic circuit, it is the simplest form of Arduino. Sometime it is called as Arduino on breadboard too. 

The hardware required are:

For your information, the ATmega328P ICs carried by Cytron are pre-loaded with Optiboat bootloader. You do not have to burn the bootloader into it before using it. 

Construct the standalone Arduino circuit as shown in figure below: 

 ATmega basic circuit_bb

If you refer the datasheet of ATmega328P, you will find that there are Port A, Port B, Port C and Port D in the pinout diagram of ATmega328P. Where is the digital pins and analog pins those label on the Arduino board? Don’t worry, figure below can help you to find out the pin location of Arduino digital pins and analog pins. Figure below is the ATmega168/328-Arduino pin mapping diagram.

Source: Arduino.cc

Similar with session 1, there are two steps in burning bootloader into standalone Arduino.

The first step is preparing the ISP programmer. Referring to session 1 to turn CT-UNO into ISP programmer.

Next, connect the ISP programmer to the standalone Arduino:

 CT-UNO - ATmega_bb

Select “Arduino Uno” from the Tools > Board menu:

 ScreenShot004

Click “Burn Bootloader” on the Tools menu and wait for few minute for burning bootloader process.

ScreenShot005

After the burn bootloader process is done, the standalone Arduino is ready to accept code from your Arduino IDE. To program it, you can use the CT-UNO as ISP programmer to upload code into the standalone Arduino.

Great! I am done sharing the possible method to load bootloader into Arduino main controller, hopefully it is helpful and if you have any inquiry, please do discuss in our technical forum as we seldom check the comment section in tutorial site. Do bear in mind, once the bootloader is successfully loaded into Atmega, you can utilize bootloader to load new program via normal method from Arduino IDE.

 

Buy

, , , ,

Related Post

Arduino Uno with ESPresso Lite V2

ESPresso Lite V2 with AT Firmware

Jpeg

How to Make your Line Following Robot Faster?

Control Mobile Robot through WiFi with ESP-WiFi Shield (Arduino + Andriod)

Arduino + 2A motor + Encoder

Arduino + 2A Motor Shield + Encoder Motor

3 thoughts on “Using ISP to Burn Bootloader into Arduino

  1. Not everyone who uses VPN screievs are doing so for privacy reasons.I currently live in China and I rely on the US servers so I can still access my pandora and hulu accounts I have back in America.These are two screievs I really enjoy using (and I pay to use) but I can’t use them while I’m living in China without being on a US server.I’m afraid this may be the straw the broke the camels back for me. After some situations where I was never responded to when I contacted customer support, then some situations where the servers I enjoyed using were down, and now this situation it seems it’s time to move onto a VPN provider who can provide me with the service that I’m paying for.Overall I’ve enjoyed using vpntunnel and I wish their company the best of luck in the future. Time for me to find a new vpn provider though.

Leave a Reply

Your email address will not be published. Required fields are marked *