Nano programming with Uno settings

While programming a number of Nano boards with the 328P processor, I noted that the IDE settings (Tools > Board) was set for Uno. There didn't seem to be any issues, so my question is:

What is the difference in compiling / uploading if both boards are set for the 328P controller?

Are there potential issues with programming a Nano (328P) board with the Uno setting?

Thanks for any insights.

-Paul

pkafig:
What is the difference in compiling / uploading if both boards are set for the 328P controller?

There are two differences:

The fuses are set for a 2 kB boot section on the Nano:

nano.menu.cpu.atmega328.bootloader.high_fuses=0xDA

Whereas the fuses on the Uno are set for a 0.5 kB boot section:

uno.bootloader.high_fuses=0xDE

The IDE has a setting where it fails the compilation if the sketch size exceeds the application section on the microcontroller, as determined by the board's upload.maximum_size property. You can see that the Nano and Uno's upload.maximum_size properties are different due to their different boot section sizes:

nano.menu.cpu.atmega328.upload.maximum_size=30720
uno.upload.maximum_size=32256

What this means is that if your sketch uses more than 30720 but less than 32256 bytes of flash memory, the compilation will succeed, but then the upload will fail with a confusing "verification failed" error because the last part of the upload won't be allowed to overwrite the boot section.

You can fix that by connecting an ISP programmer to your Nano and doing a Tools > Burn Bootloader with Tools > Board > Arduino AVR Boards > Arduiino Uno selected. This will set the fuses on the Nano to have a 0.5 kB boot section, freeing up 1.5 kB of precious flash memory for you to use in your sketches!


The two boards have different core variants:

uno.build.variant=standard
nano.build.variant=eightanaloginputs

But if you look at the "eightanaloginputs" variant, you'll see there really isn't so much of a difference:

#include "../standard/pins_arduino.h"
#undef NUM_ANALOG_INPUTS
#define NUM_ANALOG_INPUTS           8

All the code of the "standard" core variant is used by the "eightanaloginputs" variant, it just changes the value of the NUM_ANALOG_INPUTS macro from 6 to 8. The Arduino core library doesn't use NUM_ANALOG_INPUTS at all and I haven't found many uses of it elsewhere. The significant exception is in the Firmata Library.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.