Skip to content

perf(ci): use fbuild for ESP32 QEMU merged-bin builds - #2292

Merged
zackees merged 1 commit into
masterfrom
qemu-fbuild-migration-2287
Apr 18, 2026
Merged

zackees merged 1 commit into
masterfrom
qemu-fbuild-migration-2287

Conversation

@zackees

@zackees zackees commented Apr 18, 2026 •

Copy link
Copy Markdown
Member

Summary

Completes the QEMU→fbuild migration tracked in #2287.

Approach chosen: option (1) from #2287 — "have fbuild emit bootloader/partitions natively" — which turns out to already be done in the currently-pinned fbuild (>=2.1.12 per `pyproject.toml`; installed 2.1.16). Reading `fbuild/crates/fbuild-build/src/esp32/orchestrator.rs` shows step 14 "Prepare boot artifacts for deployment / emulation" already writes `bootloader.bin`, `partitions.bin`, and `boot_app0.bin` into `.fbuild/build//release/` alongside `firmware.bin`. The assumption in PR #2285 that fbuild does not emit those files is stale.

So this PR is just plumbing:

No changes needed to the QEMU workflow templates — they still read from `.pio/build//` and the mirror puts the files there.

No changes needed to FastLED/fbuild.

Verification (local)

  • `bash compile esp32s3 --examples Blink` via fbuild produces `firmware.bin`, `bootloader.bin`, `partitions.bin`, `boot_app0.bin` in both `.fbuild/build/esp32s3/release/` and the mirrored `.pio/build/esp32s3/`.
  • `esptool --chip esp32s3 merge-bin` directly against fbuild's artifacts produces a valid 4MB merged image with `0xE9` magic byte at both `0x0` (bootloader) and `0x10000` (app). This is the same command `build_with_merged_bin()` runs.
  • `bash test --cpp`: 300/300 pass.
  • `bash lint` Python portion: clean. (Unrelated pre-existing C++ lint violation on `tests/fl/url_lnk.cpp` from feat(fl::url): add parse_lnk() for .lnk asset link files (slice 1 of #2284) #2286 is not touched by this PR.)

Remaining (CI)

Test plan

  • `bash test --cpp` locally — done, 300/300
  • ESP32-DEV QEMU Test on CI
  • ESP32-C3 QEMU Test on CI
  • ESP32-S3 QEMU Test on CI
  • AVR8JS Uno Test on CI (baseline — should stay green)
  • Add PIO-vs-fbuild wall-clock delta comment after first green CI run

Refs #2287

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Improved ESP32 build artifact handling to ensure bootloader, partition, and boot files are properly included in the build output directory.
    • Enhanced build system robustness with more flexible artifact detection and management.

fbuild's ESP32 orchestrator (>= 2.1.7) already emits bootloader.bin,
partitions.bin, and boot_app0.bin alongside firmware.bin. PR #2285
conservatively disabled fbuild for merged-bin builds based on an earlier
assumption that those artifacts were PIO-only; that assumption no longer
holds.

- Extend _mirror_fbuild_artifacts_to_pio() to also mirror the three ESP32
  boot/partition artifacts from .fbuild/build/<env>/release/ into the
  legacy .pio/build/<env>/ path.
- Drop the use_fbuild=False force-override inside build_with_merged_bin()
  so the compiler honors whichever build tool the caller asked for.

Verified locally:
- bash compile esp32s3 --examples Blink produces firmware.bin,
  bootloader.bin, partitions.bin, boot_app0.bin in both the fbuild
  release dir and the mirrored .pio/build/<env>/ path.
- esptool merge-bin produces a valid 4MB image (0xE9 magic at both
  bootloader and app offsets) directly from fbuild's artifacts.
- bash test --cpp: 300/300 pass.
- bash lint (Python): clean.

Refs #2287

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 18, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Updated fbuild-to-PlatformIO artifact mirroring in ci/compiler/pio.py to include ESP32 boot and partition binaries (bootloader.bin, partitions.bin, boot_app0.bin). Removed the forced use_fbuild=False workaround from build_with_merged_bin(), relying on expanded mirroring to provide all necessary artifacts.

Changes

Cohort / File(s) Summary
Artifact Mirroring & Build Flow
ci/compiler/pio.py
Extended _mirror_fbuild_artifacts_to_pio() to copy ESP32 boot and partition binaries alongside firmware artifacts; refactored build_with_merged_bin() to remove use_fbuild=False force-reset, allowing fbuild-enabled builds to proceed with complete artifact set via updated mirroring.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 Hop, skip, and a binary bound,
Bootloaders and partitions, all found!
No more tricks to force the flow,
Mirroring makes the artifacts glow! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: enabling fbuild for ESP32 QEMU merged-bin builds by mirroring boot/partition artifacts and removing the force-override in build_with_merged_bin().
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch qemu-fbuild-migration-2287

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
ci/compiler/pio.py (1)

1193-1210: Removal of use_fbuild=False override is sound; one stale docstring to tidy.

Routing through _internal_build_no_lock correctly honors self.use_fbuild:

  • fbuild path → _build_with_fbuild → now mirrors the full artifact set into .pio/build/<env>/ via the updated _mirror_fbuild_artifacts_to_pio.
  • PIO path → _init_platformio_build runs pio run producing the artifacts in .pio/build/<env>/ before _internal_build_no_lock returns “Built during initialization”.

Minor drift worth addressing while you're here: _internal_build_no_lock's docstring at line 708 still says "Only call from build()", but build_with_merged_bin is now a second legitimate caller. Either relax the docstring or add a brief note explaining the merged-bin call site.

✏️ Suggested docstring tweak
     def _internal_build_no_lock(
         self, example: str, cancelled: threading.Event
     ) -> SketchResult:
-        """Build a specific example without lock management. Only call from build()."""
+        """Build a specific example without lock management.
+
+        Intended callers: ``build()`` (normal per-example path) and
+        ``build_with_merged_bin()`` (single-example merged-bin path). Callers
+        are responsible for any lock management.
+        """
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ci/compiler/pio.py` around lines 1193 - 1210, Update the
_internal_build_no_lock docstring to reflect that it is called from both build()
and build_with_merged_bin (not only build()); locate the _internal_build_no_lock
function and change the docstring text to either list both legitimate callers or
phrase it generically (e.g., "Callers include build() and
build_with_merged_bin") so the documentation matches current usage and avoids
implying a single allowed caller.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@ci/compiler/pio.py`:
- Around line 1193-1210: Update the _internal_build_no_lock docstring to reflect
that it is called from both build() and build_with_merged_bin (not only
build()); locate the _internal_build_no_lock function and change the docstring
text to either list both legitimate callers or phrase it generically (e.g.,
"Callers include build() and build_with_merged_bin") so the documentation
matches current usage and avoids implying a single allowed caller.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0c86ba40-00c9-4f7b-89b1-3db21c266b66

📥 Commits

Reviewing files that changed from the base of the PR and between 73cd62b and b62c27d.

📒 Files selected for processing (1)
  • ci/compiler/pio.py

@zackees
zackees merged commit 7674a91 into master Apr 18, 2026
69 of 80 checks passed
@zackees
zackees deleted the qemu-fbuild-migration-2287 branch April 18, 2026 03:55
zackees added a commit that referenced this pull request Apr 18, 2026
… mirror

Replaces the ``_mirror_fbuild_artifacts_to_pio`` workaround with a direct
read from whichever backend produced the artifacts. Adds
``PioCompiler._artifacts_dir(env_name)`` returning either
``.fbuild/build/<env>/release/`` (when use_fbuild=True) or
``.pio/build/<env>/`` (PlatformIO). ``build_with_merged_bin`` and
``get_merged_bin_path`` both use the helper, so esptool merge_bin runs
against fbuild's output without any cross-directory copy.

The mirror was added in #2285 and extended in #2292 to bridge fbuild
output into ``.pio/build/`` so legacy consumers (QEMU/AVR8JS workflows,
crash decoder, ``build_with_merged_bin``) kept working. The new
``fbuild test-emu`` workflows (#2296) read fbuild's release dir
directly, leaving ``build_with_merged_bin`` as the only remaining
consumer — and that is now also fbuild-aware, so the mirror has no
callers left.

Diagnostic dump in the missing-artifacts branch now labels the active
backend's dir explicitly and lists both possible locations, so the
debug story when artifacts vanish is at least as good as before.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Apr 18, 2026
`ci/ci-cppcheck.py` shells out to `pio check`, which requires a fully
populated PlatformIO project tree. Boards now compiled by fbuild don't
get their partition CSVs (e.g. `huge_app.csv`) written into the PIO
project dir, so `pio check` fails in CMake configure:

    Missing partition table file `.../.build/pio/esp32c2/huge_app.csv`
    UserSideException: Processing esp32c2 ...

This has kept esp32c2 red on master since #2292 (2026-04-18) and blocks
PR #2300.

Short-term: detect fbuild output presence by testing
`.build/.fbuild/build/<env>/release/` (the fbuild artifact dir returned
by `PioCompiler._artifacts_dir` in `ci/compiler/pio.py`). When that
directory exists for the target board, skip `pio check` with a visible
SKIP notice and return 0 rather than fail CI.

This accepts a temporary cppcheck-coverage gap on fbuild-default boards
(esp32c2 today, s3/c3/c6 on deck) until the proper clang-tool-chain-bin
integration lands — tracked by:

- #2301 — fbuild cppcheck support
- #2302 — esp32c2 CI regression (closed by this commit)
- #2303 — umbrella: clang-tool-chain-bin for IWYU + cppcheck +
  other linting tools

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Apr 18, 2026
…CI (#2305)

`ci/ci-cppcheck.py` shells out to `pio check`, which requires a fully
populated PlatformIO project tree. Boards now compiled by fbuild don't
get their partition CSVs (e.g. `huge_app.csv`) written into the PIO
project dir, so `pio check` fails in CMake configure:

    Missing partition table file `.../.build/pio/esp32c2/huge_app.csv`
    UserSideException: Processing esp32c2 ...

This has kept esp32c2 red on master since #2292 (2026-04-18) and blocks
PR #2300.

Short-term: detect fbuild output presence by testing
`.build/.fbuild/build/<env>/release/` (the fbuild artifact dir returned
by `PioCompiler._artifacts_dir` in `ci/compiler/pio.py`). When that
directory exists for the target board, skip `pio check` with a visible
SKIP notice and return 0 rather than fail CI.

This accepts a temporary cppcheck-coverage gap on fbuild-default boards
(esp32c2 today, s3/c3/c6 on deck) until the proper clang-tool-chain-bin
integration lands — tracked by:

- #2301 — fbuild cppcheck support
- #2302 — esp32c2 CI regression (closed by this commit)
- #2303 — umbrella: clang-tool-chain-bin for IWYU + cppcheck +
  other linting tools

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant