Skip to content

fbuild deficiency vs PlatformIO: build.extra_flags stripped from many bundled board JSONs (breaks Arduino board-macro detection) #298

@zackees

Description

@zackees

Symptom

For many boards in crates/fbuild-config/assets/boards/json/, the build.extra_flags field is empty/missing — even though the upstream PlatformIO board JSON sets it.

Concrete repro from current master FastLED CI:

fbuild bundle fbuild's build.extra_flags Upstream PIO build.extra_flags
nrf52840_dk.json (missing) -DARDUINO_NRF52_DK
nrf52840_dk_adafruit.json (missing) -DARDUINO_NRF52840_PCA10056 -DNRF52840_XXAA
adafruit_feather_nrf52840_sense.json (missing) -DARDUINO_NRF52840_FEATHER_SENSE -DNRF52840_XXAA
adafruit_feather_nrf52840.json (missing) -DARDUINO_NRF52840_FEATHER -DNRF52840_XXAA
adafruit_clue_nrf52840.json (missing) -DARDUINO_NRF52840_CLUE -DNRF52840_XXAA
adafruit_itsybitsy_nrf52840.json (missing) -DARDUINO_NRF52840_ITSYBITSY -DNRF52840_XXAA -DARDUINO_NRF52_ITSYBITSY
adafruit_metro_nrf52840.json (missing) -DARDUINO_NRF52840_FEATHER -DARDUINO_NRF52840_METRO -DNRF52840_XXAA
...and ~16 nRF52 boards total + many others (missing) various

Why it matters

Most Arduino-framework board headers gate on -DARDUINO_<BOARD> macros. For example, FastLED's src/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h is a chain of:

#if defined(ARDUINO_NRF52_DK)
    // pin map for nRF52 DK
#elif defined(ARDUINO_NRF52840_FEATHER_SENSE)
    // pin map for Feather Sense
...
#elif defined(NRF52840_XXAA) && !defined(__FASTPIN_ARM_NRF52_VARIANT_FOUND)
    #warning "Unknown nRF52840 variant -- please report to FastLED developers what your board is."
    // fallback that intentionally marks many pins INVALID
#endif

Without extra_flags injected, every nRF52 board falls through to the "Unknown variant" fallback. That fallback marks pin 1 (and many others) invalid, so FastPin<1>::validpin() evaluates to false, and a static_assert in fl/system/fastpin_base.h:146 blows up any example that uses pin 1 for SPI data (e.g. examples/Apa102/Apa102.ino).

Result on master right now:

fl/system/fastpin_base.h:146: error: static assertion failed: This pin has been marked as an invalid pin...
fastspi_arm_nrf52.h:129: error: 'fl::FastPin<PIN>::LowSpeedOnlyRecommended()' is private within this context

CI workflows blocked

  • nrf52840_dk
  • nrf52840_supermini (maps via real_board_name="nrf52840_dk_adafruit" in FastLED ci/boards.py)
  • adafruit_feather_nrf52840_sense
  • (and any future nRF52840 board added to FastLED)

Root cause

crates/fbuild-config/src/bin/enrich_boards.rs is the one-off tool that imports build / upload sections from ~/.platformio/platforms/. It evidently dropped extra_flags when run (or was run before this field mattered). Same gap exists across many non-nRF52 boards (IAP15*, LGT8F*, etc.) — visible via:

python -c "import json,glob; [print(f) for f in sorted(glob.glob('crates/fbuild-config/assets/boards/json/*.json')) if 'extra_flags' not in json.load(open(f)).get('build',{})]"

Proposed fix

Either:

  1. Re-run enrich_boards with a corrected enrichment loop that copies build.extra_flags straight through (preferred — fixes ALL boards in one shot, scriptable).
  2. Or patch the bundle JSONs individually for affected board families as they get reported.

Test plan

For each fixed JSON: BoardConfig::from_board_id(...).get_defines() should now include the expected ARDUINO_<BOARD>=1 keys (get_defines already parses extra_flags per crates/fbuild-config/src/board/mod.rs::get_defines; just needs the data present).

Immediate FastLED unblock

Companion fbuild PR adds extra_flags to the 3 nRF52840 boards FastLED CI currently exercises (nrf52840_dk, nrf52840_dk_adafruit, adafruit_feather_nrf52840_sense), values mirrored verbatim from upstream PIO. That's the minimum needed to unblock FastLED master. The broader sweep (all ~16 nRF52 boards + every other board missing extra_flags) is the proper follow-up.


Filed during a coordinated CI-green sweep; immediate-unblock PR coming next.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions