IT

Arduino Micro as ISP (flashing the bootloader of an Arduino Leonardo)

Arduino Leonardo refused to accept a new sketch once a very large one was uploaded (code / memory). The board would hang just after the upload started (and power cycling it did not fix the problem).

Since I found no tutorials online how to use an Arduino Micro as an ISP (since I had one lying around), I’ve decided to investigate the if a Leonardo can be used as an ISP, given that Micro is similar to it and both have ICSP connectors.

The resources I found were:
https://petervanhoyweghen.wordpress.com/2012/09/16/arduinoisp-on-the-leonardo/
http://forum.arduino.cc/index.php?topic=332158.0
and it might work!

Step 1 – Modifying programmers.txt file:

As explained in the first link above, Arduino IDE (at the time my version was 1.6.9) still cannot use an Arduino Leonardo (and I assumed also a Micro) to burn the bootloader to a different board because the protocol it chooses locks up the controller that does the flashing.

The first hurdle was to locate which programmers.txt file to use. My setup had two, one in c:\Arduino\hardware\arduino\avr\programmers.txt and another one in c:\Users\Root\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.11\programmers.txt.

The File > Preferences might give a hint of where the local folder is (but you still have to find the programmers.txt file and not the preferences.txt!)

arduino_prefs

The correct one to edit is the last one (in the AppData folder) and I had to add these lines:

arduinoispleo.name=Arduino as ISP (Micro/Leonardo)
arduinoispleo.communication=serial
arduinoispleo.protocol=arduino
arduinoispleo.speed=19200
arduinoispleo.program.protocol=arduino
arduinoispleo.program.speed=19200
arduinoispleo.program.tool=avrdude
arduinoispleo.program.extra_params=-P{serial.port} -b{program.speed}

The lines should be added after the lines defining Arduino as ISP.

The difference between this entry and the Arduino as ISP is that the protocol is arduino instead of stk500v1. The name Arduino as ISP (Micro/Leonardo) was chosen not because it is using a Micro to flash a Leonardo but because the same configuration can be used for an Arduino Leonardo to flash a different Arduino Leonardo.

Arduino IDE has to be restarted after these changes and a new programmer has to appear on the Tools > Programmer menu.

Step 2 – Schematic

Only the Arduino Micro is connected to the PC since the Leonardo stays connected (and is powered) by the Micro through via its ICSP port.

img_8386_wm

The yellow cable is connected to pin 10 of the Arduino Micro (it will act as a reset):

img_8388_wm

Few closeups:

Step 3 – flashing the ArduinoISP sketch on the Arduino Micro.

For Arduino Micro to work as an ISP, an ArduinoISP.ino sketch has to be uploaded to Arduino Micro. The sketch is already provided within the Arduino IDE: C:\Arduino\examples\11.ArduinoISP\ArduinoISP\ArduinoISP.ino

No modifications were required to the file.

Step 4 – Flashing the bootloader

To flash the bootloader, few Tools menu settings have to be properly chosen:

Board should be the one board that the bootloader is being written to – that is Arduino Leonardo.
Port should display board that is writing the bootloader – that is Arduino/Genuino Micro.
Programmer should be the newly added configuration – that is Arduino as ISP (Micro/Leonardo)

The last step is to choose Tools > Burn Bootloader. This will take about a minute, and if flashing is successful, Leonardo will start the Blink code (which is also written by default) and the ‘L’ LED will blink every second.

menu_bootloader

If the ‘L’ LED blinks the everything went ok!

2 Comments

  1. mts

    Dude, you are my hero. i wasted like 5 hours till i found this article. Thanks ALLLOOOOTTT 😀

  2. Benjamin

    Thanks a lot,
    the photo of the seperate reset pin on the leg of the micro let me think twice about my setup.

Leave a Reply