Bootloader merit badge

How does the IDE know which bootloader to burn when you "Burn Bootloader" ?


OK I got some Nano Arduinos, and finally got them to blink using "old bootloader".

I used an easily found procedure using a UNO as "Arduino ISP".

Everything went along without incident, except: I wished to follow advice given somewhere to burn the UNO bootloader, at no point was I asked about this.

I got the result, a savings of memory, see below, and the Nano now can be called a UNO for regular programming.

Sketch uses 1004 bytes (3%) of program storage space. Maximum is 30720 bytes.

Sketch uses 1004 bytes (3%) of program storage space. Maximum is 32256 bytes.

Curiously, uploading blink appears to work selecting either Nano or UNO, the only difference is in the reported Maximum (30270 if I call it a Nano, 32256 if I call it a UNO).

So I just wanna know where I ended up.

TIA

a7

It's part of the board definition in boards.txt.

Here you can see the definition for the "ATmega328P (Old Bootloader)" variant of the Nano:
https://github.com/arduino/ArduinoCore-avr/blob/1.8.3/boards.txt#L167

nano.menu.cpu.atmega328old.bootloader.file=atmega/ATmegaBOOT_168_atmega328.hex

and here for the Uno:
https://github.com/arduino/ArduinoCore-avr/blob/1.8.3/boards.txt#L72

uno.bootloader.file=optiboot/optiboot_atmega328.hex

The "Burn Bootloader" process also sets the configuration fuses on the microcontroller, and these are also specified by the board definition.

So the bootloader and fuses are determined by which board you have selected from the Arduino IDE's Tools > Board menu at the time you run the "Burn Bootloader" process, in addition to any custom tools menus the board might have (e.g., Tools > Processor in the case of the Nano).

The "ATmega328P" variant of the Nano uses the same bootloader as the Uno:
https://github.com/arduino/ArduinoCore-avr/blob/1.8.3/boards.txt#L152

nano.menu.cpu.atmega328.bootloader.file=optiboot/optiboot_atmega328.hex

Unfortunately, it has different configuration fuses, which causes its boot section to be 2 kB even though the bootloader actually fits in a 0.5 kB boot section. The Uno has the correct fuse settings, which is the only reason you get an extra 1.5 kB of flash memory for your sketch when using the Uno's bootloader and board selection with the Nano.

1 Like

THX @pert , I do believe it was your original advices from whenever that I was heeding.

a7

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