Skip to content

fix(nrf52): build Seeed XIAO nRF52840 boards against Seeed's core (#2017) - #2030

Merged
zackees merged 5 commits into
mainfrom
fix/xiao-nrf52-seeed-core-2017
Nov 17, 2026
Merged

zackees merged 5 commits into
mainfrom
fix/xiao-nrf52-seeed-core-2017

Conversation

@zackees

@zackees zackees commented Nov 17, 2026

Copy link
Copy Markdown
Member

Fixes #2017.

Root cause

xiaoble_adafruit (variant Seeed_XIAO_nRF52840) and xiaoblesense_adafruit (variant Seeed_XIAO_nRF52840_Sense) were added to the board DB in #293, but the nRF52 orchestrator always provisions Adafruit's framework-arduinoadafruitnrf52 1.10601.0. That core has no XIAO variants. platform = <maxgerhardt URL> changes nothing because fbuild does not run platform.py.

Upstream, maxgerhardt/platform-nordicnrf52's platform.py swaps the Arduino package for these two boards by board name, to framework-arduinoadafruitnrf52-seeed, an unpinned git mirror of Seeed's fork of the Adafruit core. That fork ships the XIAO variants, the nrf52840_s140_v7.ld script the boards name, and the S140 7.3.0 SoftDevice API headers.

Fix

  • Board data drives the core. A new fbuild-only board JSON field, build.framework_package (BoardConfig::framework_package, overridable with board_build.framework_package), names the PlatformIO framework package. Both XIAO JSONs set framework-arduinoadafruitnrf52-seeed. They also gain upstream's extra_flags (-DARDUINO_Seeed_XIAO_nRF52840[_Sense] -DNRF52840_XXAA), which Seeed's Wire_nRF52.cpp uses for pin muxing. Boards without the field keep Adafruit's core. An unknown value is a typed ConfigError. ci/validate_boards.py lists the field as an fbuild extension.
  • Pinned Seeed package. Nrf52Framework::{Adafruit, Seeed} in fbuild-library pins Seeed nRF52 Boards 1.1.13: https://files.seeedstudio.com/arduino/core/nRF52/Seeed_nRF52_Boards-1.1.13.tar.bz2, SHA-256 5243bd456e8b7a3328725e17e6c6efc9712662f5aa27b7dc807911aeb0e93071. The URL and hash come verbatim from Seeed's board-manager index, and I verified the hash against the download. It is cached separately as nrf52-core-seeed. platform_packages / registry overrides key off the selected package's name, as SAMD does.
  • SoftDevice headers follow the linker script. fbuild hardcoded s140_nrf52_6.1.1_API. core_select::softdevice_api_dir now selects the newest <sd>_nrf52_<major>.*_API matching the board's resolved linker script (nrf52840_s140_v7.ld gives s140_nrf52_7.3.0_API). It falls back to 6.1.1, which is the same as before for every Adafruit board.
  • MDK system file. Seeed's core drops the #ifdef NRF52832_XXAA / NRF52840_XXAA guards that Adafruit's has around nrfx/mdk/system_nrf52{,840}.c, so both define SystemInit. Arduino and PIO archive the core, but fbuild links core objects directly, so this was a duplicate-symbol link error. retain_mcu_system_source keeps only system_<mcu>.c. That is what Adafruit's guards already produce, so Adafruit builds are unaffected.

No deploy changes: fbuild has no nRF52 deployer. No VID/PID added: Seeed's hwids were not copied.

Commits

  1. refactor: shrinks BoardConfig::from_board_id_in_project (an opt closure) and extracts nrf52_core_include_dirs from Nrf52Orchestrator::build, with no behaviour change, so neither #[expect(too_many_lines)] function grows.
  2. refactor: drops the loader's now-unfulfilled #[expect].
  3. fix: the behaviour change above.

Tests

New crates/fbuild-build-arm/src/nrf52/core_select_tests.rs:

  • xiao_boards_resolve_to_seeed_core: both XIAO boards resolve to framework-arduinoadafruitnrf52-seeed, 1.1.13, with the pinned URL and SHA-256. RED before the board JSON change: it got framework-arduinoadafruitnrf52.
  • adafruit_boards_still_resolve_to_adafruit_core: adafruit_feather_nrf52840, nrf52840_dk and nrf52840_dk_adafruit resolve to Adafruit 1.10601.0.
  • Separate cache identity, the unknown-package ConfigError, the board_build.framework_package override, SoftDevice header selection (v7, v6, newest release, fallback), and the MDK system-file filter.

Validation

  • soldr cargo fmt --all -- --check: clean
  • soldr cargo clippy --workspace --all-targets -- -D warnings: clean
  • bash test -p passes for fbuild-config, fbuild-library, fbuild-build-arm and fbuild-cli
  • ci/test_validate_boards.py (35 tests) and ci/check_usb_vidpid_literals.py pass; ruff is clean on ci/validate_boards.py
  • Touched files are all under 1000 lines. Neither #[expect(too_many_lines)] function grew: Nrf52Orchestrator::build is net ~26 lines shorter, and the loader's expect was deleted.

End-to-end

Built the issue's blink with FBUILD_DEV_MODE=1 fbuild <proj> build -e <env> --clean on a freshly built CLI/daemon, using the cached ARM GCC 15.2.Rel1. The nRF52 LTO default is still on, since #2028 is not merged.

env result core / variant SD headers FLASH origin
xiaoble_adafruit OK, flash 22908 B Seeed 1.1.13 variants/Seeed_XIAO_nRF52840 s140_nrf52_7.3.0_API 0x27000 (v7)
xiaoblesense_adafruit OK, flash 22908 B Seeed 1.1.13 variants/Seeed_XIAO_nRF52840_Sense s140_nrf52_7.3.0_API 0x27000 (v7)
xiaoble_adafruit + platform = https://github.com/maxgerhardt/platform-nordicnrf52 OK Seeed 1.1.13 7.3.0 0x27000
adafruit_feather_nrf52840 (control) OK, flash 27704 B Adafruit 1.10601.0 feather_nrf52840_express s140_nrf52_6.1.1_API 0x26000 (v6)

Before the system-file filter, the XIAO build compiled and then failed to link with multiple definition of SystemInit (system_nrf52.c and system_nrf52840.c).

FastLED CI (question in the issue)

FastLED's nrf52_xiaoblesense / adafruit_xiaoblesense jobs never build these boards. In ci/boards.py, xiaoblesense and xiaoblesense_adafruit set real_board_name="nrf52840_dk_adafruit" (Adafruit's pca10056 variant, S140 v6), plus -DTARGET_XIAOBLE_NRF52840_SENSE to select FastLED's own XIAO fastpin block and -fno-lto. The jobs only run on workflow_dispatch or on PRs labelled ci-full / ci-platform:xiaoblesense[_adafruit], which is why master shows skipped. After this ships, FastLED can drop that stand-in. That is a FastLED change and is not made here.

Not changed

fbuild lib-select (crates/fbuild-cli/src/lib_select.rs) is a diagnostic. It still reports Adafruit's libraries/ dir for every nRF52 board, as it does for other platforms' alternate cores.

Behaviour-preserving extractions so the #2017 fix does not grow two
functions that carry #[expect(clippy::too_many_lines)]:

- BoardConfig::from_board_id_in_project: fold the repeated
  override-then-default Option<String> lookup into an `opt` closure.
- Nrf52Orchestrator::build: move the Nordic SDK / SoftDevice / FreeRTOS /
  SystemView include list into nrf52_core_include_dirs().

Refs #2017
The previous commit brought BoardConfig::from_board_id_in_project back
under clippy's 100-line limit, so its baseline #[expect] is unfulfilled
and must be deleted (RUST-018).

Refs #2017
)

xiaoble_adafruit / xiaoblesense_adafruit name the Seeed_XIAO_nRF52840{,_Sense}
variants, but fbuild always provisioned Adafruit's nRF52 core 1.10601.0,
which does not ship them, so every build stopped at variant.h.
maxgerhardt/platform-nordicnrf52 maps these boards by name to
framework-arduinoadafruitnrf52-seeed, an unpinned mirror of Seeed's fork.

- Board JSON `build.framework_package` (BoardConfig::framework_package,
  overridable via board_build.framework_package) selects the core; both
  XIAO JSONs set framework-arduinoadafruitnrf52-seeed and gain upstream's
  extra_flags (-DARDUINO_Seeed_XIAO_nRF52840[_Sense], used by Seeed's
  Wire). Unknown values are a ConfigError; default stays Adafruit.
- Nrf52Framework pins Seeed nRF52 Boards 1.1.13 from Seeed's board-manager
  index (SHA-256 5243bd45...e0e93071), cached as nrf52-core-seeed.
- SoftDevice API headers follow the resolved linker script
  (nrf52840_s140_v7.ld -> s140_nrf52_7.3.0_API) instead of a hardcoded
  6.1.1; unchanged for Adafruit boards.
- Keep only the MCU's nrfx/mdk/system_<mcu>.c: Seeed's core drops the chip
  guards Adafruit's has, so system_nrf52.c and system_nrf52840.c both define
  SystemInit and fbuild links core objects directly.

Fixes #2017
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Conflict in crates/fbuild-build-arm/src/nrf52/orchestrator.rs: #2016
(e992e3d) removed the GCC 7 registry-toolchain LTO workaround
(for_registry_toolchain / is_gcc7_registry_toolchain / without_release_lto /
without_flags) now that no nRF52 profile enables -flto. Keep main's state and
retain only this PR's extracted nrf52_core_include_dirs, which the build now
calls with the resolved linker script (#2017).

Verified after resolution: fbuild-build-arm 296 passed / 0 failed / 2 ignored,
fbuild-config 254p, fbuild-library 349p, clippy -p arm/config/library
--all-targets --no-deps exit 0, fmt clean, validate_boards 35 tests OK,
platform boundary 44/43.
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.

xiaoble_adafruit, xiaoblesense_adafruit: board is in the database, its variant is not in the framework (2.5.51)

1 participant