Skip to content

ci(flash-offsets): refuse to guess the platform default; add gate tests - #1922

Merged
zackees merged 1 commit into
mainfrom
agent/test-check-flash-offsets
Nov 5, 2026
Merged

zackees merged 1 commit into
mainfrom
agent/test-check-flash-offsets

Conversation

@zackees

@zackees zackees commented Nov 5, 2026

Copy link
Copy Markdown
Member

What

ci/check_flash_offsets.py verifies the ESP32 bootloader offset — a ROM-defined constant where a wrong value is a brick (#278 shipped 0x0 where the ROM loads at 0x2000). Its docstring promises it "never silently passes". Two argument paths broke that promise by fabricating the authoritative value.

The two fail-open paths (reproduced on main 672bc685)

Both fell through to a hard-coded DEFAULT_BOOTLOADER_ADDR = "0x1000":

  1. A boards.txt with no sibling platform.txt. --boards-txt / $FBUILD_ESP32_BOARDS_TXT read platform.txt only if platform_path.exists(), else "" → parse_platform_default("") returned the constant.
  2. A platform.txt that does not declare build.bootloader_addr. Same fallthrough.

Both were reported as verified against an authority. Measured with a 9-config fixture (esp32/esp32s2 on the default, the rest explicit):

$ python ci/check_flash_offsets.py --boards-txt fx/boards.txt     # no platform.txt
All 9 esp32 config(s) match the authoritative flash offsets.      # rc 0  <-- fabricated

After:

FAILED: 2 flash-offset problem(s):
  - esp32: no authoritative bootloader offset -- boards.txt has no `esp32.build.bootloader_addr`
    and the platform.txt default is unavailable (no platform.txt accompanies this boards.txt);
    refusing to guess
  - esp32s2: ... (platform.txt does not declare build.bootloader_addr)      # rc 1

An unresolved default is an unverifiable chip, not a pass. parse_platform_default now returns None, authoritative_offset refuses to resolve a default-reliant chip without it, and the message says which of the two situations occurred.

No behaviour change on the real repo

--boards-txt <cached 3.3.12 framework> and --download (the pioarduino 3.3.7 tag CI uses, which does declare build.bootloader_addr=0x1000) both produce output byte-identical to main's, rc 0 — all 9 configs PASS. This is not a false-RED risk for the Dylint policy job.

Structure

main carried a # noqa: C901, so it is split into parse_args / resolve_source / evaluate / report_lines — the check is now drivable in-process. --boards-txt with no value now says "--boards-txt needs a path" instead of "Unknown argument".

Tests

ci/test_check_flash_offsets.py, 28 tests: parsers and offset normalisation; every per-config failure face (stale offset, missing bootloader key, partition/firmware drift, chip unknown to boards.txt); both fail-open regressions as named cases; every real config's partitions/firmware pins; and end-to-end runs of the real script as a subprocess in a repo-shaped temp tree, so configs_dir()'s relative discovery is exercised.

$ uv run --no-project python -m unittest ci.test_check_flash_offsets
Ran 28 tests in 0.4s
OK

$ # hosted self-test set (all DRIFT_UNITTEST_MODULES)
Ran 214 tests in 12.3s
OK                                   # was 186 before this PR

$ uv run --no-project python ci/gate_script_coverage.py --budget 5
Every workflow-invoked gate script is accounted for      # rc 0

$ uv run --no-project python ci/check_python_complexity.py
All checks passed!
$ ruff check / ruff format --check <both files>
All checks passed! / 2 files already formatted

RED proven by restoring the old return "0x1000" fallback in place: 5 tests fail (parse_platform_default(None), both fail-open regressions, the e2e missing-platform case, and the changed-upstream-default case), then restored → 28/28 OK.

Ratchet

ci/gate_script_tests.toml: check_flash_offsets leaves untested (6 → 5) and declares its test; MAX_UNTESTED 6 → 5; registered in both entry points (ci/local_suites.py DRIFT_UNITTEST_MODULES + the ci-workflow-drift.yml unittest command) in matching order.

Remaining untested gates: build_backend, build_qemu_linux_runtime, cancel_superseded, check_dylint_allowlists, validate_boards.

Closes nothing — part of the gate-coverage burn-down (#1915).

`ci/check_flash_offsets.py` guards a bricking constant: the second-stage
bootloader offset is ROM-defined, and #278 shipped `0x0` where the ROM loads
at `0x2000`. Its docstring promises it "never silently passes", but two
argument paths made it fabricate the answer:

  - a boards.txt with no sibling `platform.txt` at all, and
  - a `platform.txt` that does not declare `build.bootloader_addr`

Both fell through to a hard-coded `DEFAULT_BOOTLOADER_ADDR = "0x1000"`, so a
chip that relies on the platform default was reported as matching an
authoritative value that came from nowhere. Reproduced on main `672bc685`
with a 9-config fixture: exit 0, "All 9 esp32 config(s) match". Both are hard
failures now -- an unresolved default is an unverifiable chip, not a pass.

`parse_platform_default` returns `None` when the key is absent or no
platform.txt exists, `authoritative_offset` refuses to resolve a
default-reliant chip without it, and the failure names which of the two
situations occurred. The one legitimate pass (a real default, or an explicit
`<chip>.build.bootloader_addr`) is unchanged: the real repo run against the
pioarduino 3.3.7 tag and against a cached 3.3.12 framework is byte-identical
to main's output, rc 0.

Also split `main` (which carried `# noqa: C901`) into `parse_args` /
`resolve_source` / `evaluate` / `report_lines` so the check is drivable
without a subprocess, and gave `--boards-txt` with no value a clear error
instead of "Unknown argument".

New `ci/test_check_flash_offsets.py` (28 tests) covers the parsers, per-config
failures, both fail-open regressions, every real config's partitions/firmware
pins, and drives the real script as a subprocess in a repo-shaped temp tree
(so `configs_dir()` discovery is exercised). Registered in both entry points;
`untested` 6 -> 5, `MAX_UNTESTED` 6 -> 5.

Real output: 28/28 OK; hosted self-test set 186 -> 214 OK;
`gate_script_coverage --budget 5` clean; `check_python_complexity` clean;
ruff + `ruff format --check` clean; RED proven by restoring the `"0x1000"`
fallback in place (5 tests fail), then restored.
@coderabbitai

coderabbitai Bot commented Nov 5, 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

@zackees
zackees added this pull request to the merge queue Nov 5, 2026
Merged via the queue into main with commit 0bc0d36 Nov 5, 2026
31 checks passed
@zackees
zackees deleted the agent/test-check-flash-offsets branch November 5, 2026 18:59
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 6, 2026
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.

1 participant