Skip to content

feat(fqbn): resolve an Arduino FQBN against an installed package (#1298) - #2227

Merged
zackees merged 1 commit into
mainfrom
agent/1298-fqbn
Dec 1, 2026
Merged

zackees merged 1 commit into
mainfrom
agent/1298-fqbn

Conversation

@zackees

@zackees zackees commented Dec 1, 2026

Copy link
Copy Markdown
Member

Resolves the first cell of #1298: parse an Arduino FQBN and resolve it against an installed Arduino data directory. #1298 stays open — the CLI surface, orchestrator mapping, index install and recipe evaluation are the follow-ups listed below (and in the design record).

Why

fbuild build --fqbn Seeeduino:mbed:xiaonRF52840Plus on fbuild 2.5.50:

error: unexpected argument '--fqbn' found
  tip: to pass '--fqbn' as a value, use '-- --fqbn'
Usage: fbuild build [OPTIONS] [PROJECT_DIR]

--board only accepts ids the bundled database or a project-local boards/<id>.json defines, and a vendor core the PlatformIO registry does not carry has neither. That is the exact gap #1298 was filed for, and this PR delivers the additive resolver a CLI flag will call.

What landed

crates/fbuild-build-engine/src/fqbn.rs (+ fqbn_tests.rs), design record docs/design/fqbn-resolution.md:

  • Fqbn::parse — vendor:architecture:board[:menu=value,...]. Structural characters (:, ,, =) and whitespace inside any field are refused (they cannot be escaped in the form), a trailing : is an error naming the fix, and a menu selected twice is refused rather than last-wins. Every rejection names the raw input and the offending field.
  • ArduinoPackage::locate — maps the identity onto <data_dir>/packages/<vendor>/hardware/<arch>/<version> (the layout arduino-cli installs). No version is ever guessed: an explicit version must be installed, no version resolves only when exactly one is installed, and several installed versions is an error listing them.
  • resolve — reads boards.txt and platform.txt (both required; a missing one names the expected path), validates every menu option against the package first — an unknown menu/option lists the available ones — then applies the selections through arduino_props::load_board_props_with_menu_overrides, the same helper the PlatformIO path uses, so board_build.<menu> and FQBN menus agree by construction.
  • ResolvedFqbn — normalized board properties (mcu, variant, board, …), verbatim platform.txt properties (name, version, compiler.*, recipe.*, tools.* with {…} unexpanded), and board_config() through the existing boards.txt constructor.

Deliberately absent, with reasons in the design record: no index download/install (cache layout + streaming checksum + offline behaviour + trust are their own decision), no recipe evaluation, and no orchestrator choice — fbuild-build-engine never references a platform module, so the resolved mcu is reported, not interpreted.

Measured vertical slice (real published package, not a fixture)

Downloaded https://files.seeedstudio.com/arduino/core/mbed/ArduinoCore-mbed-2.9.3.tar.bz2 (34,722,259 bytes, SHA-256 65d9de0b77010859dd1ca16bfb36b333ddcfbbd7a93270c431cbf49825fd784f, matches the checksum in package_seeeduino_boards_index.json), installed as <data>/packages/Seeeduino/hardware/mbed/2.9.3/, then:

IDENTITY Seeeduino:mbed:xiaonRF52840Plus
BOARD core=arduino mcu=cortex-m4 variant=SEEED_XIAO_NRF52840_PLUS board=SEEED_XIAO_NRF52840_PLUS
BOARD crossprefix=arm-none-eabi- ldscript=linker_script.ld
PLATFORM name="Seeed nRF52 mbed-enabled Boards" version=2.9.3 compiler.c.cmd="{build.crossprefix}gcc"

The package's build.mcu is cortex-m4 — an ARM core, not a chip — which is why the orchestrator mapping is a follow-up and not a table in this PR.

Tests (real output)

  • soldr cargo test -p fbuild-build-engine --lib → 624 passed / 0 failed / 6 ignored (existing PlatformIO resolution suites green).
  • soldr cargo test -p fbuild-build-engine --lib fqbn → 12 passed / 0 failed (parse/round-trip, 8 malformed-FQBN cases, structural chars, resolve, menu overlay + default = first declared option, Uno control, version ambiguity/explicit/absent, absent architecture listing siblings, unknown board listing defined ones, unknown menu/option diagnostics, missing package file, platform.txt properties).
  • RED proven twice: removing the validate_menu_options call fails the bad-selection test (11 passed / 1 failed); returning the first installed version in the ambiguity branch fails the version test (11 passed / 1 failed). Both restored + touched → 12/12 green.
  • soldr cargo clippy -p fbuild-build-engine --all-targets -- -D warnings → exit 0; soldr cargo fmt --check -p fbuild-build-engine → exit 0; ci/enforce_platform_boundary.py --print-totals → rows=0; dylint_rows=0.

Follow-ups (kept on #1298)

  1. CLI/config surface (--fqbn, board_build.fqbn) through ResolutionContext, with the RED evidence above as its regression test.
  2. architecture/core → orchestrator decision for vendor cores whose build.mcu is an ARM core, plus the toolchain mapping now expressed by compiler.path.
  3. Package index install: cache layout, streaming checksum enforcement, offline reuse, trust policy.
  4. platform.txt recipe evaluation for categories the native orchestrators do not model.

A PlatformIO board id names a registry row; an FQBN names a package, a
version, a board and a set of menu selections. Vendor cores the PlatformIO
registry does not carry -- Seeed's Seeeduino:[email protected] is the motivating
slice -- therefore cannot be named at all.

Add an additive engine module that does the three steps the Arduino builder
does, and nothing else:

1. `Fqbn::parse` turns `vendor:architecture:board[:menu=value,...]` into a
   typed identity. Structural characters and whitespace inside a field are
   refused (they cannot be escaped in the form), a trailing `:` is an error,
   and a menu selected twice is refused instead of last-wins.
2. `ArduinoPackage::locate` maps the identity onto
   `<data_dir>/packages/<vendor>/hardware/<arch>/<version>` and refuses an
   ambiguous version rather than picking the newest, because an FQBN carries
   no version and a build must not depend on what happens to be installed.
3. `resolve` reads the package's `boards.txt` (menu selections applied
   through `arduino_props::load_board_props_with_menu_overrides`, the same
   helper the PlatformIO path uses) and its `platform.txt` verbatim, and
   returns the normalized board properties plus `board_config()`.

Menu selections are validated against the package first, so an unknown menu
or option fails with the available names instead of silently falling back.

No index download, no recipe evaluation, no orchestrator choice: recipes
keep their `{...}` references and the resolved `mcu` is reported, not
interpreted -- `fbuild-build-engine` never references a platform module.

Design record, diagnostics table, the measured vertical slice (published
Seeeduino:[email protected] archive, SHA-256 65d9de0b..., build.mcu=cortex-m4) and
the four follow-ups are in docs/design/fqbn-resolution.md.

Gates: fbuild-build-engine lib 624 passed / 0 failed, fqbn module 12/12,
clippy -D warnings exit 0, fmt exit 0, boundary rows=0 dylint_rows=0.
RED proven twice: removing the menu-validation call fails the bad-selection
test, and returning the first installed version fails the ambiguity test.
@zackees
zackees added this pull request to the merge queue Dec 1, 2026
Merged via the queue into main with commit c086d1b Dec 1, 2026
44 checks passed
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant