Skip to content

nRF52: Wire and SPI are only include paths, so Wire.begin() fails to link #2072

Closed

Description

@zackees

Found during #2042 (PR #2070).

The nRF52 orchestrator (crates/fbuild-build-arm/src/nrf52/orchestrator.rs, "Framework library includes") adds the core's Wire and SPI folders as include paths only. It never compiles Wire.cpp or SPI.cpp. So a sketch that calls Wire.begin() fails to link with undefined reference to TwoWire::begin(), even though lib-select picks Wire. It's the same on main.

PlatformIO compiles the framework's built-in libraries through LDF when they're included. fbuild should compile the libraries it selects for nRF52, as other platforms do.

Part of #2035.

Activity

  1. added
    bug
    on Nov 18, 2026
  2. zackees commented on Nov 18, 2026

    @zackees
    MemberAuthor

    Reproduced on main (installed CLI 2.5.50) with tests/platform/nrf52840_dk plus a five-line Wire sketch (Wire.begin(), beginTransmission, write, endTransmission):

    undefined reference to `TwoWire::begin()'
    undefined reference to `TwoWire::beginTransmission(unsigned char)'
    undefined reference to `TwoWire::endTransmission()'
    undefined reference to `Wire'
    collect2: error: ld returned 1 exit status
    

    So the include path is there (the sketch compiles) and only the library's translation units are missing — exactly as reported.

    Fix is up as #2077: the orchestrator now resolves the core's libraries/ tree with the same shared LDF finder the Teensy/STM32/RP2040/ESP8266/Renesas orchestrators use, adds the reached libraries' include dirs and sources, excludes Adafruit_TinyUSB_Arduino (already compiled by the TinyUSB block) and de-duplicates sources already in the core set (the SPI.cpp the TinyUSB host adapter needs). Unit receipts: soldr cargo test -p fbuild-build-arm --lib 307 passed / 0 failed / 2 ignored, with 7 new tests in nrf52/framework_libs_tests.rs covering the flat 1.0 layout the Adafruit BSP uses (libraries/Wire/Wire_nRF52.cpp, libraries/SPI/SPI.cpp + SPI_nrf52832.cpp).

    Keeping this open until the end-to-end fbuild build on the fix (not just the unit selection) is attached — that build is queued behind the host's current load (~90-120/16).

  3. zackees commented on Nov 18, 2026

    @zackees
    MemberAuthor

    Claimed by the fbuild-74 coordinator. A sub-agent is working on this now (meta #2035).

  4. zackees commented on Nov 18, 2026

    @zackees
    MemberAuthor

    Correction: another session already has this in PR #2077, so fbuild-74 is not working on it.

  5. zackees commented on Nov 18, 2026

    @zackees
    MemberAuthor

    Closing: the defect is fixed on main by #2077 (0aad6801, merged 2026-11-18T08:15:27Z).

    What landed — crates/fbuild-build-arm/src/nrf52/framework_libs.rs runs the shared LDF
    (resolve_framework_library_selection_active_declared_with_extra) over Nrf52Cores::get_libraries_dir()
    (the same directory fbuild lib-select already inspects) and contributes the include dirs and the
    sources
    of the libraries a sketch actually reaches, instead of only pushing libraries/{SPI,Wire} onto
    the include path. Adafruit_TinyUSB_Arduino stays excluded (the orchestrator compiles that stack itself),
    and sources already in the core set (the manual SPI.cpp) are filtered out by NormalizedPath. The
    orchestrator's step 6b now hoists lib_deps above the library selection.

    Receipts

    • Before (installed CLI 2.5.50, tests/platform/nrf52840_dk + a five-line Wire sketch) the sketch
      compiled and the link died on undefined reference to TwoWire::begin()/beginTransmission/endTransmission/Wire.
    • After: fbuild build -e nrf52840_dk → build succeeded in 59.0s (flash: 48208, ram: 8776), with
      Wire_nRF52.cpp in compile_commands.json (102 TUs), SPI.cpp compiled exactly once, and no
      Bluefruit52Lib/Adafruit_LittleFS pulled in.
    • soldr cargo test -p fbuild-build-arm --lib → 307 passed / 0 failed / 2 ignored (7 new tests: flat BSP
      layout, unreached library, TinyUSB exclusion, dedup, lib_deps, missing library dir).
    • Post-merge on 0aad6801: 37 check-runs success / 16 skipped / 10 running / 0 failure; the Nordic sample
      builds (nRF52840 DK, SuperMini, nRFMicro, Feather) are green.

    Meta #2035 stays open for the rest of its batch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions