Projects

Fixing Firmware - Part 2

Updating Firmware on the Arduino Bootloader: Part 2

Geoff Cohen

Issue 34, May 2020

This article includes additional downloadable resources.
Please log in to access.

Log in

We show you how to build an ISP (In-System Programmer) to fix or upgrade firmware in your Arduino-based microcontrollers.

In Issue 33, we showed you how to upgrade the bootloader in Uno and Mega compatible boards that have onboard WiFi. In this project, we will build an ISP (In-System Programmer) to install or upgrade the bootloader in Arduino’s and Arduino-based 3D printers. By the way, ISP’s may also be called an ICSP or In-Circuit Serial Programmer. ISP or ICSP both refer to the same device and the names are interchangeable.

As well as uploading (or burning) a bootloader to an old or bricked Arduino, an ISP is also needed to upgrade some 3D printers, including the widely used Creality Ender 3.

THE BROAD OVERVIEW

Occasionally, we’ve received Arduino MCU chips and Arduino clones that don’t have a bootloader. Without the bootloader, they were unusable bricks, put in our “too hard, fix it later” box.

In addition, we sometimes come across Arduino Nano’s that have the “Old bootloader”. Annoyingly, you can’t upload the Arduino program code if you select the wrong option, which is not as bad as a brick, but still a time waster.

Recently, we found having “no bootloader” can also be a 3D printer problem. The widely used Creality Ender 3 has Arduino compatible electronics, but NO bootloader. This wouldn’t be a problem, except, the Ender 3 also runs an extremely old version of Marlin (Open Source software for controlling 3D printers). The missing bootloader prevents Marlin upgrades, including essential improvements such as auto-levelling and thermal runaway protection. They are impossible to install on a stock Ender 3 without a bootloader.

IMPORTANT: Thermal runaway protection is absolutely necessary for any 3D printer to avoid melting a 3D printer or worse, burning your house down in extreme circumstances.

While not critical, auto-levelling will save you many, many hours. Levelling is only needed when the PEI surface is replaced, after several months, but without auto-levelling, you usually waste 5 to 20 minutes levelling before every print. We still have bad memories of 3D printing before we added auto-levelling to our very first 3D printer.

THE IN-SYSTEM PROGRAMMER

We knew having an ISP/ICSP would solve most of our Arduino bootloader problems. We had experimented with a few ISP boards from China, however, none worked reliably. All were really difficult to use (which wire goes where/which ISP does it emulate, etc.). They also had a habit of dying unexpectedly.

Searching the web provided many examples of DIY ISPs, but none matched what we wanted i.e. a small, permanent, cheap and easy to use ISP. A “black box” that could be picked up and used immediately, every time we needed it, without any delays looking for manuals or figuring out arcane plug wiring.

This ISP project is cheap and easy to build, and only needs an Arduino Nano, one 6-pin socket, and some hookup wire. We’ll also used some LEDs and resistors for testing purposes.

As you can see in the images, the prototype was a bit of a kludge, but it did work, so we’ll stand by the old engineering maxim – “If it works, it’s right”. The actual hardware couldn’t be much simpler, 1 x Nano, 1 x Socket and 6 x wires (plus, optionally - 3 LEDs and 3 resistors). The complexity is all in the software, which is included with the Arduino IDE and it’s used as-is, no changes needed to the code.

HOW IT WORKS

This Nano ISP sits between your computer and the target Arduino needing a bootloader install or upgrade. All you have to do is change a few settings on your Arduino IDE and press “Burn Bootloader”

To make a simple, reliable and easy to build ISP from readily available parts – everything we found pointed one way - use an Arduino as the “brain”, controlled by the free “ArduinoIDE.ino” example software from Arduino.cc.

After checking the readily available Arduino boards, cost, availability, and size led us away from the almost universally used Uno, to the much smaller Arduino Nano. While both Uno and Nano should work identically, it’s always better to test than theorise, so we breadboarded a really quick and dirty prototype for a real world check. Amazingly, everything worked perfectly the first time.

In theory, it’s pretty straightforward, but in practice, we encountered several time wasting traps. However, following the steps here, will have you quickly making an ISP and burning a bootloader to your Arduino or 3D printer.

SOFTWARE: The software effort is easy because it’s already been done by the folks at Arduino.cc. They have provided us with ArduinoISP.ino that is usable as-is. Nothing else needs changing in the code.

HARDWARE: The hardware requirements are also minimal - just solder six wires between an Arduino Nano and 6-pin plug, change a few settings in your Arduino IDE and burn a new bootloader.

The Build:

Parts Required:JaycarAltronicsCore Electronics
1 x Arduino Nano or equivalentXC4414Z6372CE05101
1 x 6-way (2 x 3) Socket*HM3208P5375^SPRT-13010
6 x 250mm Lengths of Hook-up Wire or 1m RibbonWM4516W2510CAB-10649

Parts Required:

Optional Parts Required:JaycarAltronicsCore Electronics
2 x 70(L)mm x 20mm Clear Heatshrink*WH5557Z6372-
1 x 100mm Cable Tie*HP1244P5375^FIT0343
6 x 2.5mm Heatshrink for 6 pin ICSP socket wires*WH5531W2510ADA344
3 x LEDs #ZD0100POLOLU-1070
3 x 330Ω Resistors* #RR0560PRT-14490

Optional Parts Required:

2 x 70(L)mm x 20mm Clear Heatshrink*WH5557
1 x 100mm Cable Tie*HP1244
6 x 2.5mm Heatshrink for 6 pin ICSP socket wires*WH5531
3 x LEDs #ZD0100

* Quantity required, may only be sold in packs or minimum lengths.

^ Refer to text about turning a header socket/strip into a 2 x 3 way socket.

# See text regarding throughhole or SMD LEDs

CONSTRUCTION

Follow either the Fritzing diagram or this connection list to see how to wire up your ISP.

^ Note: If you don’t have enough hook-up wire colours on hand, strip an old CAT6 network cable (We keep CAT6 cables with broken plastic tabs just for the good quality multi-coloured wire inside).

The Fritzing diagram shows how to wire up your ISP/ICSP programmer - all you need is good soldering skills.

First, we need the socket. We didn’t have a 2x3, 6-way socket at hand, but we did have several 40-pin socket strips left over from our H20 Timer build, so we just cut-off off two 3-way lengths and glued them together. (To make sure they would fit, we plugged the 2x3 socket into a (spare) Arduino’s 6 pin ICSP plug while the 5min epoxy glue dried).

Next, we need wire (preferably six different colours to prevent errors), each length around 250mm. Strip and tin one end of each wire and solder it to the Nano, following the Fritzing diagram/connection table.

When finished, bundle all the wires together and cut them to the same length. Strip and tin each wire and solder it to the 6 pin socket, again using the Fritzing diagram/connection table.

Note: Before soldering the socket end, slide a short length of 1.5mm or 2.5mm heatshrink over each wire and also allow each wire to cool down after soldering or the tiny heatshrink won’t slide over the socket. It’s also an excellent idea to mark the 5V end of the socket in red (Texta or Nail-Polish) – this polarity indicator makes using the ISP a lot easier to use.

When finished, secure a small cable tie around the Nano and six way loom.

Your ISP is 99% finished! It just needs testing before finishing with the 20mm heatshrink insulation.

LED INDICATOR OPTION

On our earlier prototypes (and first 'real' build) we added the three LEDs mentioned in the ArduinoISP sketch (line 34 …), You don’t necessarily need these, as the Nano’s internal LEDs show the upload as well as the Arduino IDE’s status bar. However, if you want to add the LEDs, any LEDs and 330Ω resistors should be fine.

We used through-hole type resistors on the prototype and SMD components for the final build (so they fitted underneath the 20mm heatshrink). To add them, just solder a 330Ω resistor in series between each LED and GND. The three LEDs positive legs go to pins 7, 8 and 9 respectively.

Using regular through hole type LEDs
Using SMD LEDs

TESTING

Arduino.cc has been exceptionally helpful and provided example software to convert any Arduino into an ISP, which is called, unsurprisingly, ArduinoISP. To use it, open your Arduino IDE (Integrated Development Environment) software and go to: File > Examples > 11. ArduinoISP > ArduinoISP

After you’ve loaded it, change the Board to “Arduino Nano” (Tools Menu > Board) then select the processor, which is usually a Mega 328 (Tools Menu > Processor).

Upload the ArduinoISP code to your Nano, exactly like any other Arduino software upload (if it doesn’t work, it may have a Nano with an “Old Bootloader”, select this Processor in Tools Menu > Processor, and upload again).

Now that the code has been uploaded, your Nano is now an ISP, we just need to test it.

To test our new ISP we need to tell the Arduino IDE which programmer we are using to upload a bootloader. In Tools Menu > Programmer, select ‘Arduino as ISP’. Be very careful here. If you select the nearly identical ArduinoISP, you will get the error “Could not find USBtiny device”. We wasted an hour chasing down this bug the first time we tried to use our ISP.

BURNING A BOOTLOADER

You can use any Arduino as a test target to verify your ISP works correctly. Just remember, burning a bootloader erases any uploaded Arduino code on the target Arduino. It’s not usually a problem, just remember you need to re-upload program code after burning a bootloader.

Plug your new Nano ISP into a USB port on your computer and also plug the Nano ISP’s 6-way socket into the target Arduino‘s 6 pin ICSP plug.

Arduino boards in our collection have Pin 1 (the 5V or Red end) marked. If yours doesn’t, use a multimeter to verify which end of the ICSP plug is pin 1 (5V) and put a red mark there.

If connected correctly, the LEDs on the ISP and target Arduino will both be on.

Check exactly which Arduino your target is, and select it in (Tools Menu > Board), along with its processor in (Tools Menu > Processor). For example, if your target is a Mega2560 select Arduino Mega as the Board and Mega2560 as the Processor.

Finally, it’s time to burn a bootloader. In the Tools Menu, select Burn Bootloader.

The IDE’s status bar changes to “Burning bootloader to IO Board (this may take a minute)…” and the LEDs on your Nano ISP should flash for a few seconds (our test Mega took about 15 secs)

A “Done burning bootloader” message on the Arduino IDE Status Bar confirms success (if it doesn’t work, press the target Arduino’s Reset button and try Burning again)

To complete the build, unplug everything, and slide a short piece of 20mm clear heatshrink over your Nano ISP. Once you shrink the heatshrink using your favourite method, your ISP is finally finished and ready for future use.

Note: If your Nano ISP has the usual 2 rows of 15 pins on the bottom, it may be better to use two layers of heatshrink for insulation. We tested one of these Nano’s with 20mm Jaycar heatshrink and two layers of heatshrink just fit over the Nano and pins but, if the heatshrink is too tight to slide over the Nano's ICSP pins, just bend them SLIGHTLY.

Part 1