Skip to content

feat(doc): document empty vendor and arch in FQBN #2550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ When you run [`arduino-cli board list`][arduino cli board list], your board does
FQBN stands for Fully Qualified Board Name. It has the following format:
`VENDOR:ARCHITECTURE:BOARD_ID[:MENU_ID=OPTION_ID[,MENU2_ID=OPTION_ID ...]]`, with each `MENU_ID=OPTION_ID` being an
optional key-value pair configuration. Each field accepts letters (`A-Z` or `a-z`), numbers (`0-9`), underscores (`_`),
dashes(`-`) and dots(`.`). The special character `=` is accepted in the configuration value. For a deeper understanding
of how FQBN works, you should understand the [Arduino platform specification][0].
dashes(`-`) and dots(`.`). The special character `=` is accepted in the configuration value. The `VENDOR` and
`ARCHITECTURE` parts can be empty. For a deeper understanding of how FQBN works, you should understand the [Arduino
platform specification][0].

## How to set multiple board options?

Expand Down
24 changes: 20 additions & 4 deletions internal/arduino/cores/fqbn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestFQBN(t *testing.T) {
require.Equal(t, a.BoardID, "uno")
require.Zero(t, a.Configs.Size())

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

// Sort keys in fbqn config
s, err := ParseFQBN("arduino:avr:uno:d=x,b=x,a=x,e=x,c=x")
// Keeps the config keys order
s1, err := ParseFQBN("arduino:avr:uno:d=x,b=x,a=x,e=x,c=x")
require.NoError(t, err)
require.Equal(t, "arduino:avr:uno:d=x,b=x,a=x,e=x,c=x", s.String())
require.Equal(t, "arduino:avr:uno:d=x,b=x,a=x,e=x,c=x", s1.String())
require.Equal(t,
"properties.Map{\n \"d\": \"x\",\n \"b\": \"x\",\n \"a\": \"x\",\n \"e\": \"x\",\n \"c\": \"x\",\n}",
s1.Configs.Dump())

s2, err := ParseFQBN("arduino:avr:uno:a=x,b=x,c=x,d=x,e=x")
require.NoError(t, err)
require.Equal(t, "arduino:avr:uno:a=x,b=x,c=x,d=x,e=x", s2.String())
require.Equal(t,
"properties.Map{\n \"a\": \"x\",\n \"b\": \"x\",\n \"c\": \"x\",\n \"d\": \"x\",\n \"e\": \"x\",\n}",
s2.Configs.Dump())

// The config keys order is insignificant when comparing two FQBNs
require.True(t, s1.Match(s2))
require.NotEqual(t, s1.String(), s2.String())

// Test configs
c, err := ParseFQBN("arduino:avr:uno:cpu=atmega")
Expand All @@ -90,6 +104,8 @@ func TestFQBN(t *testing.T) {
// Do not allow empty keys or missing values in config
_, err = ParseFQBN("arduino:avr:uno:")
require.Error(t, err)
_, err = ParseFQBN("arduino:avr:uno,")
require.Error(t, err)
_, err = ParseFQBN("arduino:avr:uno:cpu")
require.Error(t, err)
_, err = ParseFQBN("arduino:avr:uno:=atmega")
Expand Down