Repository navigation
feat(fqbn): convert the linked ELF into the package's firmware images (#1298 4f) - #2246
Merged
Merged
Conversation
…#1298 4f) A board does not flash an ELF. `fbuild fqbn --objcopy <name>.elf` now plans and runs every non-empty `recipe.objcopy.<ext>.pattern` the package declares, in name order, and reports each image it wrote. Two rules are the builder's, not the template's: - Order is the suffix's name order (bin, eep, hex, zip) because a later step can consume an earlier step's output: the Seeeduino `mbed` core's recipe.objcopy.zip.pattern packages `{build.project_name}.hex`, not the ELF. - An empty recipe is not a recipe: Seeeduino:[email protected] declares `recipe.objcopy.eep.pattern=` with no value, and Arduino skips it. Each image path is derived as `{build.path}/{build.project_name}.<ext>` from the ELF's own directory and stem, and the expansion must name it (`require_names`), so a recipe that writes elsewhere is refused by name. Success is "every step exited 0 and every declared image exists", not "every image is non-empty": the real AVR eep recipe writes a zero-byte `.eep` for a sketch with no EEPROM data, while a step that exits 0 and writes nothing at all is the failure worth catching. The link half's shared helpers (`base_props`, `merge_caller`, `require_names`, `remove_stale`, `size_of`, `file_stem`) move to `pub(crate)` rather than being reimplemented, so the post-link stage cannot drift from the derivation rules.
This was referenced Dec 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up 4f of #1298: the step after the link.
fbuild fqbn <FQBN> --objcopy <name>.elfconverts the linked ELF through everynon-empty
recipe.objcopy.<ext>.patternthe package declares and reportseach image it wrote.
--linkand--objcopymay be one invocation, exactlylike
--archiveand--link— the ELF only has to exist when the step runs.The two decisions
bin,eep,hex,zip), because a step mayconsume an earlier step's output. Real
Seeeduino:[email protected]platform.txt:recipe.objcopy.zip.pattern="{tools.nrfutil.cmd}" dfu genpkg … "{build.project_name}.hex" "{build.project_name}.zip"packages the
.hex, not the ELF, sohexmust run first.Seeeduino:[email protected]declaresrecipe.objcopy.eep.pattern=with no value. Arduino skips it; a plannerthat expanded it would refuse a perfectly good package with "expands to an
empty command".
Each output is derived as
{build.path}/{build.project_name}.<ext>from theELF's directory and stem, and the expansion must name that path
(
require_names), so a recipe writing elsewhere is refused by name instead ofbeing reported as a file the caller did not ask for. A non-
.elfinput isrefused.
Success is "every step exited 0 and every declared image exists" — not
"every image is non-empty": the real AVR eep recipe writes a 0-byte
.eepfora sketch with no EEPROM data.
Real e2e (real
arduino:[email protected]package + avr-gcc 7.3.0, not a fixture)24/24 core units compiled →
core.a347,362 B → sketch TU → linkBlink.elf14,160 B (link_exit=0) →--objcopy build/Blink.elf --run:Non-ELF input:
the objcopy step converts the linked.elf, not build/Blink.eeelf(exit 1).Gates (real output)
soldr cargo test -p fbuild-build-engine --lib→ 716 passed / 0 failed / 6 ignored(7 new in
fqbn_objcopy::tests).soldr cargo test -p fbuild-cli --bin fbuild→ 592 passed / 0 failed(3 new: text report, JSON report, link+objcopy in one invocation).
soldr cargo clippy -p fbuild-build-engine -p fbuild-cli --all-targets -- -D warnings→ exit 0.ci/enforce_platform_boundary.py --print-totals→rows=0; dylint_rows=0.soldr cargo fmt --check→ clean.RED, twice, each guard disabled and restored (then re-run green):
skips_an_empty_recipe_and_runs_a_consumer_after_its_inputand
refuses_a_package_with_no_objcopy_recipefail (2 failed).require_namescall →refuses_a_recipe_that_does_not_name_its_derived_imagefails (1 failed).
The CLI tests drive
plan_and_run, the same function the binary calls, so thewiring is proven and not just the helpers.
#1298 stays open: the remaining cell is the upload/deploy side of a vendor
core (naming the board a vendor FQBN produced and flashing the image above).