Skip to content

Commit 2d6300a

Browse files
committed
feat(doc): document empty vendor and arch in FQBN
The spec should be aligned with the implementation; empty `vendor` and `architecture` parts are allowed in the FQBN. Signed-off-by: dankeboy36 <[email protected]>
1 parent 870a48f commit 2d6300a

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

Diff for: docs/FAQ.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ When you run [`arduino-cli board list`][arduino cli board list], your board does
1212
FQBN stands for Fully Qualified Board Name. It has the following format:
1313
`VENDOR:ARCHITECTURE:BOARD_ID[:MENU_ID=OPTION_ID[,MENU2_ID=OPTION_ID ...]]`, with each `MENU_ID=OPTION_ID` being an
1414
optional key-value pair configuration. Each field accepts letters (`A-Z` or `a-z`), numbers (`0-9`), underscores (`_`),
15-
dashes(`-`) and dots(`.`). The special character `=` is accepted in the configuration value. For a deeper understanding
15+
dashes(`-`) and dots(`.`). The special character `=` is accepted in the configuration value. The `VENDOR` and `ARCHITECTURE` parts can be empty. For a deeper understanding
1616
of how FQBN works, you should understand the [Arduino platform specification][0].
1717

1818
## How to set multiple board options?

Diff for: internal/arduino/cores/fqbn_test.go

+20-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func TestFQBN(t *testing.T) {
3030
require.Equal(t, a.BoardID, "uno")
3131
require.Zero(t, a.Configs.Size())
3232

33-
// Allow empty plaforms or packages
33+
// Allow empty platforms or packages (aka. vendors + architectures)
3434
b1, err := ParseFQBN("arduino::uno")
3535
require.Equal(t, "arduino::uno", b1.String())
3636
require.NoError(t, err)
@@ -65,10 +65,24 @@ func TestFQBN(t *testing.T) {
6565
_, err = ParseFQBN("arduino:avr")
6666
require.Error(t, err)
6767

68-
// Sort keys in fbqn config
69-
s, err := ParseFQBN("arduino:avr:uno:d=x,b=x,a=x,e=x,c=x")
68+
// Keeps the config keys order
69+
s1, err := ParseFQBN("arduino:avr:uno:d=x,b=x,a=x,e=x,c=x")
7070
require.NoError(t, err)
71-
require.Equal(t, "arduino:avr:uno:d=x,b=x,a=x,e=x,c=x", s.String())
71+
require.Equal(t, "arduino:avr:uno:d=x,b=x,a=x,e=x,c=x", s1.String())
72+
require.Equal(t,
73+
"properties.Map{\n \"d\": \"x\",\n \"b\": \"x\",\n \"a\": \"x\",\n \"e\": \"x\",\n \"c\": \"x\",\n}",
74+
s1.Configs.Dump())
75+
76+
s2, err := ParseFQBN("arduino:avr:uno:a=x,b=x,c=x,d=x,e=x")
77+
require.NoError(t, err)
78+
require.Equal(t, "arduino:avr:uno:a=x,b=x,c=x,d=x,e=x", s2.String())
79+
require.Equal(t,
80+
"properties.Map{\n \"a\": \"x\",\n \"b\": \"x\",\n \"c\": \"x\",\n \"d\": \"x\",\n \"e\": \"x\",\n}",
81+
s2.Configs.Dump())
82+
83+
// The config keys order is insignificant when comparing two FQBNs
84+
require.True(t, s1.Match(s2))
85+
require.NotEqual(t, s1.String(), s2.String())
7286

7387
// Test configs
7488
c, err := ParseFQBN("arduino:avr:uno:cpu=atmega")
@@ -90,6 +104,8 @@ func TestFQBN(t *testing.T) {
90104
// Do not allow empty keys or missing values in config
91105
_, err = ParseFQBN("arduino:avr:uno:")
92106
require.Error(t, err)
107+
_, err = ParseFQBN("arduino:avr:uno,")
108+
require.Error(t, err)
93109
_, err = ParseFQBN("arduino:avr:uno:cpu")
94110
require.Error(t, err)
95111
_, err = ParseFQBN("arduino:avr:uno:=atmega")

0 commit comments

Comments
 (0)