Flash latest bootloader on Arduino Nano China clone

🔄 Updated:

🗓️ Posted:

🏷️ Category:

⏱️ Reading time:

15–22 minutes

Arduino Nanos are available on Amazon starting for example at $15.99. You can get it cheaper directly from China. However, these boards often come with an old bootloader. This article explains how to reflash the bootloader on a Nano using another Arduino.

×
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on https://www.amazon.com/ at the time of purchase will apply to the purchase of this product.

Is the Old or New Bootloader Installed?

First, you should find out whether the old or the new bootloader is installed on your board.

Connect your Arduino Nano to your computer via USB cable and open the Arduino IDE.

  • Select FileExamples01.Basics and choose the Blink example sketch.
  • Under ToolsBoard select Arduino Nano and under ToolsPort select the corresponding port of your Arduino Nano.
  • Under ToolsProcessor select ATmega328P (and not ATmega328P (Old Bootloader)).
  • Start the upload of the sketch.

Upload Successful?

If the sketch upload was successful, then the new bootloader is already installed on your Arduino Nano and you can stop reading here 🙂

Upload Failed?

Are you getting an error message like this?

  • avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
  • An error occurred while uploading the sketch

Then the old (or no) bootloader is installed on your Arduino Nano.

         Using Port                    : COM16
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
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
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

avrdude done.  Thank you.

An error occurred while uploading the sketch

Counter-Check

Now select ToolsProcessor and choose ATmega328P (Old Bootloader) and start the sketch upload again. This time the upload should be successful and finish with the message avrdude done. Thank you.

The Blink sketch will make the LED on the Arduino Nano blink. In the Arduino IDE output window, you will also see the message Upload complete and more details about the upload process.


         Using Port                    : COM16
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

[...]

         Programmer Type : Arduino
         Description     : Arduino
         Hardware Version: 2
         Firmware Version: 1.16
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "C:\Users\user\AppData\Local\Temp\arduino_build_372348/Blink.ino.hex"
avrdude: writing flash (924 bytes):

Writing | ################################################## | 100% 0.29s

avrdude: 924 bytes of flash written
avrdude: verifying flash memory against C:\Users\user\AppData\Local\Temp\arduino_build_372348/Blink.ino.hex:
avrdude: load data flash data from input file C:\Users\user\AppData\Local\Temp\arduino_build_372348/Blink.ino.hex:
avrdude: input file C:\Users\user\AppData\Local\Temp\arduino_build_372348/Blink.ino.hex contains 924 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.22s

avrdude: verifying ...
avrdude: 924 bytes of flash verified

avrdude done.  Thank you.
Expand

This confirms that your Arduino Nano has the old bootloader installed. We can replace it with the new bootloader without any problems, as it is simply different software. The hardware of an Arduino Nano with an old bootloader does not differ from one with a new bootloader. But why should we upgrade at all?

Differences Between the New and Old Bootloader

The old bootloader is “ATmegaBOOT”, while the new bootloader is called “optiboot” and is also used in other Arduino models.

This StackExchange post1 outlines the two main advantages:

  • When the Arduino Nano is reset by the watchdog, a bug in ATmegaBOOT causes the Arduino Nano to restart endlessly. This error does not exist in optiboot.
  • During sketch upload, ATmegaBOOT operates at a baud rate of 57600. The optiboot bootloader, however, is twice as fast with a baud rate of 115200. This means sketches can be loaded onto the Nano much faster with the new bootloader. Since different baud rates are used, you must always select the correct bootloader in the Arduino IDE sketch upload process. From the bootloader’s perspective, it would otherwise receive no meaningful data, as the sketch would be transmitted too slowly or too quickly.

Another minor advantage of the new bootloader is that you can use the default Arduino IDE settings and don’t have to remember to switch the bootloader in the Processor menu.

What Do You Need?

To flash a bootloader onto an Arduino, you need a “programmer”. This can either be a dedicated board built specifically for this purpose or you can use another Arduino for the task. If you have a second Arduino lying around, it’s recommended to use it as a programmer since you won’t have to purchase an additional (rarely used) dedicated programmer board.

You will need the following materials and tools:

⚙️ Hardware & Material

Arduino as Programmer: In general, any Arduino model can be used as a programmer – whether Arduino Uno, Nano, Mega, Pro Mini, or other variants.

Do you have multiple Arduino Nanos (with old bootloader)? No problem, because mutual flashing of Arduino Nanos should also work! The only small hurdle: Since the Nano doesn’t have female pin headers, the capacitor mentioned below will need to be connected via a breadboard.

In the following, we use an Arduino Uno as the programmer. If you’ve successfully used a different Arduino as a programmer, we are happy to hear about it in the comments 🙂

Arduino Uno

Arduino Uno (Original)


Jumper Cables: To wire the two Arduinos together, you will need six jumper cables. Depending on your Arduino model and wiring approach, these can be either male-to-female (M2F) or female-to-female (F2F) cables. It’s best to get a set with different types of jumper cables so you’re equipped for all situations.

Set with different types of jumper cables


Capacitor: For the flashing process, you will need a 10 µF capacitor. In the linked capacitor assortment, you will find exactly this value along with many others.

Assortment of capacitors, includes 10 µF capacitors

👨‍💻 Software & Tools

Arduino IDE: The software must be installed on your computer.
Note: You cannot use the Arduino Cloud Editor (web app) to flash the bootloader.

Flash a New Bootloader onto the Arduino Nano

Prepare the Programmer (Arduino Uno)

First, we prepare the programmer – in our case the Arduino Uno (or another Arduino variant of your choice). We configure the Arduino as a so-called ISP, an In-System Programmer. To do this, we load special software onto the Arduino Uno, with the help of which we can then flash the bootloader of the Arduino Nano.

Don’t worry: the ISP software is not permanently installed. It can be overwritten at any time, so the Arduino can continue to be used without any problems for other projects.

  • Important: Do not connect any jumper cables and no capacitor (!) to the Arduino Uno yet.
  • Connect the Arduino Uno to the computer via USB cable.
  • Open the Arduino IDE and load the sketch ArduinoISP via the menu FileExamples11.ArduinoISPArduinoISP
    • Note: The Arduino Cloud Editor (web app) does not have the functions for bootloader flashing built-in!
  • Set the board and port settings according to the Arduino model used for the programmer:
    • ToolsBoardArduino Uno
    • ToolsPort → Select the port number of the Arduino Uno
  • Upload the sketch to the Arduino Uno.
  • If everything has been successfully uploaded, then your ISP Arduino is ready!
  • Disconnect the Arduino Uno (programmer) from the computer.

Understanding Communication

For the ISP/programmer (Arduino Uno) to flash the bootloader target device (Arduino Nano), both Arduinos must be wired together.

Comment at the beginning of the ArduinoISP sketch

How does communication between the two Arduinos work?

  • The target device (Arduino Nano) must be supplied with power – usually via 5V and GND.
  • A look at the code of the ArduinoISP sketch tells us that communication between the Arduinos takes place via SPI (Serial Peripheral Interface). The corresponding signal lines are:
    • MISO (also called POCI or CIPO2)
    • MOSI (also called PICO or COPI)
    • SCK (also called SLK)
  • Additionally, the programmer Arduino must restart or reset the target Arduino for the flashing process, which happens via its RST/RESET pin.

Pin Assignment on the Programmer (Arduino Uno)

During the flash process, the programmer Arduino (Uno) must trigger a reset on the target Arduino (Nano). This reset signal is generated on the programmer side via a normal digital output pin.
Important: Do not accidentally use the RST/RESET pin of the programmer Arduino.

A look at the source code of the ArduinoISP sketch tells us which pin number the programmer Arduino uses to trigger the reset of the target Arduino:

Pin assignment: RESET trigger on pin D10

Specifically, this means:
The programmer Arduino (Uno) sends the reset signal via D10. This signal is received on the target device (Nano) side at the RST/RESET pin and triggers the required reset there.

The programmer (Arduino Uno) requires the following pins:

  • Power supply (outgoing): 5V and GND
  • Communication: MISO/POCI/CIPO, MOSI/PICO/COPI and SCK/SLK
  • Reset (sending/trigger): D10

Where do we find these pins? On the Arduino board, usually only pin numbers are printed. The assignment between these numbers and the hardware functions of the individual pins can be found in the so-called pinout of the Arduino Uno3, a special document that describes the pin assignment of the specific Arduino model. It turns out that all the pins mentioned above – with the exception of the reset trigger (D10) – are present twice on the Arduino Uno: both on the ICSP pin block and on the normal, side pin headers. We are therefore free to choose one of the following two options.

×
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on https://www.amazon.com/ at the time of purchase will apply to the purchase of this product.

Option 1: Pin Assignment on ICSP Pin Block

The ICSP pin block consists of 2 x 3 pins, labeled ICSP on the board.

Important: If you use the ICSP pin block, the 5th ICSP pin (RESET) remains free! Because the programmer Arduino should not receive a reset signal, but rather send one to the other Arduino, and this happens via the digital pin D10, which is only available on the side pin header.

Option 2: Pin Assignment on Normal, Side Pins

The normal, side pins of the Arduino Uno can also be used for the connection. For better clarity, the following pinout diagram only shows the required pins. The pin numbers printed on your board are highlighted in  orange .

  • SCK/SLK:  13 
  • MISO/POCI/CIPO:  12 
  • MOSI/PICO/COPI:  11 
  • Reset trigger:  10 

Pin Assignment on the Target Device (Arduino Nano)

On the target device (Arduino Nano) side, we correspondingly need the following pins:

  • Power supply (receiving): 5V and GND
  • Communication: MISO/POCI/CIPO, MOSI/PICO/COPI and SCK/SLK
  • Reset (receiving): RST/RESET

Similarly to the previous step, we can look up the specific pin assignment in the pinout of the Arduino Nano4. Here too, all the pins mentioned above are present twice – both on the ICSP pin block and on the normal, side pin headers. So there are again two options for the connection:

×
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on https://www.amazon.com/ at the time of purchase will apply to the purchase of this product.

Option 1: Pin Assignment on ICSP Pin Block

The ICSP pin block consists of 2 x 3 pins, labeled ICSP on the board.

Note: The ICSP pins are standardized and should have the same pin assignment on every Arduino model, should you want to flash a different Arduino model instead of an Arduino Nano.

Option 2: Pin Assignment on Normal, Side Pins

In the comments it was pointed out that instead of the ICSP pin block, the normal, side pins of the Arduino Nano can also be used for the connection. For better clarity, the following pinout diagram only shows the required pins:

  • SCK/SLK:  13 
  • MISO/POCI/CIPO:  12 
  • MOSI/PICO/COPI:  11 

Wiring: Connect Arduino Uno (Programmer) to Arduino Nano (Bootloader Target Device)

In the two previous steps, we presented two wiring options per Arduino. These can be combined as desired. This results in the following wiring options between the two Arduinos:

Programmer (Arduino Uno)Bootloader Target Device (Arduino Nano)
FunctionOption 1:
ICSP pin block
Option 2:
normal, side pins
FunctionOption 1:
ICSP pin block
Option 2:
normal, side pins
Power supply 5V (outgoing)ICSP pin 25V 5V (receiving)ICSP pin 25V
■ GNDICSP pin 6GND■ GNDICSP pin 6GND
Communication MISO/POCI/CIPOICSP pin 1D12 MISO/POCI/CIPOICSP pin 1D12
MOSI/PICO/COPIICSP pin 4D11 MOSI/PICO/COPIICSP pin 4D11
SCK/SLKICSP pin 3D13 SCK/SLKICSP pin 3D13
Reset Reset sending/triggerD10D10 Reset receivingICSP pin 5RST/RESET

To connect the Arduino Uno to the Arduino Nano, we now use six jumper cables. Two of the wiring options are shown below. For more information about the capacitor shown, be sure to also check out the next step; without a capacitor, the flash process usually doesn’t work!

×
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on https://www.amazon.com/ at the time of purchase will apply to the purchase of this product.

Option 1: Wiring via ICSP Pin Blocks

Option 2: Wiring via Normal, Side Pins

In the following photo, you can see that the two wiring options shown can also be “mixed”:

  • on the programmer: normal, side pins
  • on the target device: ICSP pin block

Connect Capacitor to Programmer

The Arduino website about ISP points out that on the Arduino Uno as a programmer (and also on other models such as the Mega, Mini, and Nano), an additional 10 µF capacitor must be connected with the pins GND (minus (-), short leg of the capacitor) and RST/RESET (plus (+), long leg of the capacitor). The capacitor must only be inserted after the ArduinoISP sketch (Step 1) has been loaded onto the board.

Note: The capacitor prevents the programming Arduino from automatically resetting during the flash process. This is the only way the ArduinoISP sketch can remain active throughout the entire programming process. In practice, it has been shown that the flash process (see next step) usually only works reliably with the capacitor inserted.

In the comments, this has been confirmed several times – thank you for the helpful feedback! An additional tip from the community: If no 10 µF capacitor is available, you can possibly use a 0.1 µF capacitor as a replacement.

×
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on https://www.amazon.com/ at the time of purchase will apply to the purchase of this product.

Start Flash Process

Now we can flash the new bootloader onto the Arduino Nano.

  • To do this, change the settings in the Arduino IDE in the Tools menu:
    • change Programmer to Arduino as ISP (select exactly this entry and not ArduinoISP or ArduinoISP.org)
    • under Port select the port number of the Arduino Uno (programmer)
    • under Board and Processor set the parameters for the target Arduino, on which we want to reflash the bootloader, in this case:
      • BoardArduino Nano
      • ProcessorATmega328P (and not ATmega328P (Old Bootloader))
  • In the Tools menu, click Burn Bootloader. (Since no sketch is being uploaded here, but rather the bootloader is being transferred via the Arduino Uno’s ArduinoISP program, it doesn’t matter what sketch is open.)

The flash process usually only takes a few seconds. If the bootloader was successfully flashed, you’ll get a message that looks something like this: avrdude done. Thank you.

         Using Port                    : COM16
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

[...]

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "C:\Users\user\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2/bootloaders/optiboot/optiboot_atmega328.hex"
avrdude: writing flash (32768 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 32768 bytes of flash written
avrdude: verifying flash memory against C:\Users\user\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2/bootloaders/optiboot/optiboot_atmega328.hex:
avrdude: load data flash data from input file C:\Users\user\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2/bootloaders/optiboot/optiboot_atmega328.hex:
avrdude: input file C:\Users\user\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2/bootloaders/optiboot/optiboot_atmega328.hex contains 32768 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 32768 bytes of flash verified
avrdude: reading input file "0x0F"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x0F:
avrdude: load data lock data from input file 0x0F:
avrdude: input file 0x0F contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lock verified

avrdude done.  Thank you.
Expand

Have fun with your freshly flashed Arduino Nano! 🙂

Sources and Further Information

  1. Arduino StackExchange – Arduino Nano ATmega328P bootloader difference ↩︎
  2. A Resolution to Redefine SPI Signal Names ↩︎
  3. Arduino Uno (Rev3) Pinout ↩︎
  4. Arduino Nano Pinout ↩︎

Cover image: by Nizzah Khusnunnisa on Unsplash, modified with Canva

Comments

4 responses to “Flash latest bootloader on Arduino Nano China clone”

  1. Dmitry

    Thanks, it works!
    I forget to change old bootloader to new in menu, so that was the problem 🙂

    1. Thing King

      Glad to hear it worked 🙂

  2. Yvon

    Thanks!
    It works, had to uncomment typedef old connection style and add the capacitor

    1. Thing King

      Glad it worked for you, and thanks for sharing!

      For some Arduino models, it’s indeed necessary to enable the old wiring style in the ArduinoISP sketch. You can do this by removing the // in // #define USE_OLD_STYLE_WIRING. Thanks for pointing this out!

      // Uncomment following line to use the old Uno style wiring
      // (using pin 11, 12 and 13 instead of the SPI header) on Leonardo, Due...
      // #define USE_OLD_STYLE_WIRING

Leave a Reply

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

WordPress Cookie Notice by Real Cookie Banner