usar-arduino-para-reprogramar-el-bootloader

Using Arduino to Reprogram the Bootloader of Another Arduino

  • 3 min

The Arduino bootloader is software stored in flash memory that allows us to program Arduino through the serial port without the need for an external programmer.

In short, during the Arduino boot process, the bootloader checks if the Arduino is being programmed. If so, it writes the program to memory and restarts Arduino. Otherwise, the bootloader runs the last recorded program.

The Arduino bootloader is one of the essential parts that make Arduino easy and convenient to use (and therefore successful). In general, we don’t usually need to deal with it.

However, there are several circumstances in which we may need to be able to modify the Arduino bootloader. For example:

  • Advanced users may want to modify and customize the boot process.
  • In large projects, we may want to use the space occupied by the bootloader.
  • Some manufacturers ship their boards without the preloaded bootloader.
  • In some cases, the bootloader may become corrupted.

In any of these cases, we do not need to have an external programmer but we can use another Arduino as a programmer to burn the bootloader onto an Arduino.

The Arduino that acts as the programmer will be called master, and the one we are going to program will be called follower. The communication between the PC and the leader is done through the serial port, while the leader will communicate with the follower through SPI.

Prepare the Arduino Master

First, we will set up our Arduino Leader as a programmer. To do this, we simply have to load the “Arduino as ISP” sketch from the Arduino Examples library. We load it into the Leader like any other sketch.

arduino-as-isp

That’s it. With this, we have turned our Arduino into an ISP programmer.

Connect Arduino Leader with Follower

Disconnect the leader from the computer and connect the leader and follower. To do this, power the Arduino Follower from the Leader by connecting Vcc and Gnd from both boards. On the other hand, connect the SPI bus pins between both boards.

If, for example, we are using an Arduino UNO as the Leader programmer and an Arduino Mini as the follower, the connection scheme on the leader to the follower pins would be as follows.

arduino-grabar-bootloader-master

While the connection seen from the follower (Mini in the example) to the master’s pins would be as follows.

arduino-grabar-bootloader-follower

Burning the Bootloader

Now we can proceed to burn the bootloader onto the Arduino. Connect the leader to the computer via the serial port, keeping the connection between leader and follower.

Set up the Arduino IDE. Select:

  • The COM port to which the leader is connected.
  • The board model of the follower
  • As the programmer, “Arduino ISP”

arduino-as-isp-2

Finally, select “Burn bootloader” to start the recording process.

arduino-as-isp-3

After a lot of blinking lights and flashes on the LEDs of both boards, we will see a message in the IDE indicating that the bootloader has been successfully burned.

There you go, we have successfully burned the bootloader, and we can disconnect both Arduinos and use them as usual.

Download the code

All the code from this post is available for download on Github. github-full