Getting More Program Space on an Arduino Nano

I recently compiled Grbl with the COREXY features enabled. To my surprise, the upload to my Nano failed because it did not have enough program space. I was surprised because the Nano and Arduino UNO use the same ATmega328p microcontroller. A little researched showed that they use different bootloaders.

Normally you a special programmer to program microcontrollers like Arduinos. You plug the programmer into the ICSP (In Circuit Serial Programming) pins on the microcontroller.

Bootloaders eliminate the need for this by putting the programmer right on the microcontroller. When you start (boot) the microcontroller, the bootloader runs first. It looks for someone trying to load a program. If it does not see that it switches to running the last uploaded program in another part of memory. The only penalty to this is that the bootloader needs to use a small amount of memory and it delays the start of your program a little. The total amount of memory available to the users is the flash memory size (32k for the …328P chip) minus the bootloader. The Nano and UNO use different bootloaders. The Nano uses a 2k bootloader and the UNO uses a 0.5k bootloader.

To get more memory of the Nano we have two options. We can use an ICSP programmer to use all of the memory. This removes the bootloader. The other option is to use a programmer to put the smaller UNO bootloader on the Nano.

Changing the Bootloader

You will need a programmer. you can get any of a dozen types of dedicated programmers, but you can also use another Arduino with a special sketch loaded on it.

How to use an UNO to Program a Nano

Use the Arduino IDE to upload the Arduino ISP (In-System Programmer) sketch to the UNO.

You will need 6 jumper wires. It is helpful to have a few colors to make it easy to verify the connections. They should have male pins on the UNO side and typically female sockets on the Nano side.  These ribbon style jumpers are nice because you can peel off what you need and they have a lot of colors.



Arduino Uno (the programmer) Nano I/O (the target) Nano ICSP (the target)
5V 5V 5V
Gnd Gnd Gnd
D13 Reset Reset
D11 D11 MOSI
D12 D12 MISO
D13 D13 SCK

Using I/O pins

Or using the ICSP Header

Install the Bootloader.

Be sure UNO is selected in the boards menu. This will make sure the UNO bootloader is used.

Change the programmer to Arduino ISP in the programmer menu. Remember to return it to current setting, typically AVR ISP, after you are done installing the bootloader.

Now select the Burn Bootloader menu. This will now install the UNO bootloader onto the Nano using the Arduino UNO as a programmer.

Using the Nano.

The Nano should now have the smaller UNO bootloader. When programming from now on, be sure to select UNO in the boards menu. The IDE will no longer be able program it as a Nano. You might want to mark the Nano so you remember this.

Extra Reading…..

How does the USB cable reboot the microcontroller?

In order to program the microcontroller via USB it needs to restart (boot). It does this using a special trick. Arduinos show up as a serial port (COM port).  The Arduino only uses the Tx and Rx signals to transmit data. The USB adapter supports other RS232 signals. The DTR (Data Terminal Ready) signal is used to reset the Arduino. The DTR signal can be controlled by the program uploading the firmware.

Not shown in the schematic is a 1K pull up resistor on the reset pin near the ATmega328p. To reset the microcontroller you pull the reset pin to ground. The uploader program pulls the DTR signal low. The cap passes this change through, causing a reset, but the 1k pull up returns the reset back to the high (run) state. Remember: Capacitors pass changes (AC), but block a steady voltage (DC). 

Why do they use different bootloaders?

I do not know the answer, but it probably due to the fact that they use different USB chips.

Leave a Reply