precedence in boards.txt

27 views
Skip to first unread message

Cano

unread,
May 21, 2015, 12:26:21 PM5/21/15
to devel...@arduino.cc
I like the ability to separate clock speeds from the boards, it makes boards.txt more readable and also the menu in Arduino IDE is less crowded. My question is when I define something like this:

menu.clock=Clock

attiny84.name=ATTiny84
attiny84.upload.tool=arduino:avrdude
attiny84.upload.maximum_size=8192
attiny84.bootloader.tool=arduino:avrdude
attiny84.bootloader.file=empty/empty84at16.hex

attiny84.build.mcu=attiny84
attiny84.build.core=tiny
attiny84.build.variant=tinyX4
attiny84.build.board=ATTINY84 <----------

attiny84.menu.clock.external16=16 MHz  (external crystal; 4.3 V BOD)
attiny84.menu.clock.external16.bootloader.low_fuses=0xFF
attiny84.menu.clock.external16.bootloader.high_fuses=0xD4
attiny84.menu.clock.external16.bootloader.extended_fuses=0xFF
attiny84.menu.clock.external16.build.f_cpu=16000000L

attiny84.menu.clock.external16.build.board=ATTINY84X16 <------


see? the `build.board` is defined twice, which one takes the precedence? I could just deleted one and not worry about it, but in more complex scenarios, it's better to define a default values in the 'board' section and a redefined values IF NEEDED in the other menu section(s) this way the whole file is kept smaller and easier to read. Also what if there is more than one menu, for example 'clock' and 'processor' , which one would take the precedence if both defined the same attribute?

Cristian Maglie

unread,
May 22, 2015, 5:12:14 AM5/22/15
to devel...@arduino.cc
Il 21/05/2015 18:26, Cano ha scritto:
> attiny84.build.board=ATTINY84 <----------
>
> attiny84.menu.clock.external16.build.board=ATTINY84X16 <------
>
> the `build.board` is defined twice, which one takes the precedence?

A more specific option, when selected, overrides the "default" one. In
your case when clock=external16 option is selected the value of
build.board will be ATTINY84X16, otherwise ATTINY84.

> Also what if there is
> more than one menu, for example 'clock' and 'processor' , which one
> would take the precedence if both defined the same attribute?

The behavior in this case is undefined, maybe the IDE selects the latest
option listed? BTW this is not intentional, there is no guarantee on that.

C
Reply all
Reply to author
Forward
0 new messages