Adding a board to boards.txt for Arduino

Boards definition at issue: Arduino AVR boards/Arduino Pro or Pro Mini (version 1.8.6)
Bootloaders location:C:
Users\xxxx\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\bootloaders\atmega
Boards.txt location: C:\Users\xxxx\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

I am trying to add a Pro Mini atmega328 16MHz board with an Optiboot bootloader installed. The standard Pro Mini bootloader for the 16MHz hardware version is ATmegaBOOT_168_atmega328.hex (in that bootloader folder).

I added the Optiboot bootloader for atmega328 in that folder: optiboot_atmega328.hex

And I modified the board.txt text as follows (to save space below only the original Pro Mini 328 16MHz text is shown, and below that the added definition for the Pro Mini atmeage328 16MHz using Optiboot):

##############################################################

pro.name=Arduino Pro or Pro Mini

pro.upload.tool=avrdude
pro.upload.protocol=arduino

pro.bootloader.tool=avrdude
pro.bootloader.unlock_bits=0x3F
pro.bootloader.lock_bits=0x0F

pro.build.board=AVR_PRO
pro.build.core=arduino
pro.build.variant=eightanaloginputs

## Arduino Pro Mini (5V, 16 MHz) w/ ATmega328
## -------------------------------------------------
pro.menu.cpu.16MHzatmega328=ATmega328 (5V, 16 MHz, old boot)

pro.menu.cpu.16MHzatmega328.upload.maximum_size=30720
pro.menu.cpu.16MHzatmega328.upload.maximum_data_size=2048
pro.menu.cpu.16MHzatmega328.upload.speed=57600

pro.menu.cpu.16MHzatmega328.bootloader.low_fuses=0xFF
pro.menu.cpu.16MHzatmega328.bootloader.high_fuses=0xDA
pro.menu.cpu.16MHzatmega328.bootloader.extended_fuses=0xFD
pro.menu.cpu.16MHzatmega328.bootloader.file=atmega/ATmegaBOOT_168_atmega328.hex

pro.menu.cpu.16MHzatmega328.build.mcu=atmega328p
pro.menu.cpu.16MHzatmega328.build.f_cpu=16000000L

## Arduino Pro Mini (5V, 16 MHz) w/ ATmega328 w/ Optiboot
## -------------------------------------------------
pro.menu.cpu.16MHzatmega328Optiboot=ATmega328 (5V, 16 MHz, Optiboot)

pro.menu.cpu.16MHzatmega328.upload.maximum_size=32256
pro.menu.cpu.16MHzatmega328.upload.maximum_data_size=2048
pro.menu.cpu.16MHzatmega328.upload.speed=57600

pro.menu.cpu.16MHzatmega328.bootloader.low_fuses=0xFF
pro.menu.cpu.16MHzatmega328.bootloader.high_fuses=0xDA
pro.menu.cpu.16MHzatmega328.bootloader.extended_fuses=0xFD
pro.menu.cpu.16MHzatmega328.bootloader.file=atmega/optiboot_atmega328.hex

pro.menu.cpu.16MHzatmega328.build.mcu=atmega328p
pro.menu.cpu.16MHzatmega328.build.f_cpu=16000000L

When compiling for the standard bootloader version all is ok. When compiling for the Optiboot version this error is show in verbose output:

avr-g++: error: missing device or architecture after '-mmcu='
exit status 1
Error for compiling board Arduino Pro or Pro Mini

Knowing that I added the correct Optiboot bootloader in the bootloaders\atmega\ location,
what is wrong in my new boards definition?

Hi @brice3010. The first thing you should know is that you don't need to do this. The board definition you are trying to create is identical to the Arduino Uno board definition that already exists. Just select Tools > Board > Arduino AVR Boards > Arduino Uno from the Arduino IDE menus, perform a "Burn Bootloader" operation, then remember to always select the "Arduino Uno" board option when using your Pro Mini after that.


Even though it is unnecessary in this particular case, it is interesting and possibly useful to know how to create your own custom board definitions, so I'll go ahead and explain what you did wrong.

Here you defined a "ATmega328 (5V, 16 MHz, Optiboot)" custom board option. The machine identifier for this option is 16MHzatmega328Optiboot. All the properties in boards.txt with the prefix pro.menu.cpu.16MHzatmega328Optiboot will be defined only when that option is selected from the "Processor" (machine identifier cpu) custom board option menu.

However, you didn't add any properties to boards.txt with that prefix. What you did instead was add properties with a different prefix pro.menu.cpu.16MHzatmega328. For example:

The 16MHzatmega328 ID is for the "ATmega328 (5V, 16 MHz, old boot)" custom board option:

This means that when you select Tools > Processor > ATmega328 (5V, 16 MHz, Optiboot) and compile a sketch, properties are not defined. One of those properties is build.mcu, which is referenced in the -mmcu= flag of the compilation command templates:

(note the -mmcu={build.mcu})

So instead of the correct flag -mmcu=atmega328p, your compilation commands had the flag -mmcu=, and thus the compilation failed with that "missing device or architecture after '-mmcu='" error.

You can learn more about the custom board option system from the documentation here:

https://arduino.github.io/arduino-cli/latest/platform-specification/#custom-board-options

@ptillisch so many thanks for your very useful, extensive and clarifying reply!

You are welcome. I'm glad if I was able to be of assistance.

Regards, Per

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