Skip to content

hil: each board's flasher from a board registry keyed by probe serial - #400

Merged
hathach merged 10 commits into
mainfrom
hil-board-flasher
Nov 3, 2026
Merged

hathach merged 10 commits into
mainfrom
hil-board-flasher

Conversation

@hathach

@hathach hathach commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Every HIL project's roster repeated each board's flasher/flasher_recover and its arguments. On the farm each board
is wired to exactly one debugger, so the flasher belongs to the board: skills/hil/boards.json now holds it, keyed by
the serial of that debugger, and skills/hil/scripts/hil_boards.py resolves a roster entry through it. A roster names a
registered board by probe and keeps its own uid, the serial its firmware reports, which differs per firmware
(max32666fthr: 26 characters under TinyUSB, 32 under TinyUF2).

  • A roster entry with probe names no flasher; one that does is refused. A bench board the registry does not hold
    keeps its own flasher, unless its probe is registered.
  • The registry holds the 35 boards of tinyusb's tinyusb.json and hfp.json, boards-skip included. Each resolved
    entry equals tinyusb origin/master's inline flasher exactly.
  • Resolving through it: rtt.py, probe_state.py (and through it pc_sample, swo_capture, sysview_record),
    hil_reserve.py (one board under two lock names, by its probe or its uid, is a conflict), bin/lsusbt (a board's
    device label comes from the roster given, so a board running another project's firmware needs that project's roster:
    lsusbt: label serials from the board registry, rosters on top #402). hil_boards.py roster FILE prints a resolved roster.
  • The vid_pid grammar moves to usb_observe.py, shared by hil_flash and the registry.
  • A registered board's lock is its registry name on every host, whatever a roster calls the board
    (hil_boards.lock_name, hil_boards.py lock FILE BOARD); names are checked unique and file-name safe. Every current
    lock name already equals its registry name, so no lock file is renamed and repos at different pins still exclude each
    other. hil_reserve.py takes registered boards' locks from it.

Also folded in: flash_openocd halts both cores (-c init -c "catch halt") before program when the flasher's args
name target/rp2350.cfg (raspberry_pi_pico2, adafruit_fruit_jam). On the Fruit Jam at ci.lan, rcp_init failed
9 of 655 times without the halt and 0 of 655 with it; 20 of 20 flashes verified at the commit's origin. The reset run
paths (#395 step 3) stay out of scope.

Fixes #395

Project side: hathach/tinyusb#4402 and adafruit/tinyuf2#633 replace their inline flashers with probe and pin this
branch.

Rollout on a shared host (ci.lan): hil_reserve.py check across both rosters needs both migrated rosters and their
matching pins staged together. Update the installed standalone tools (lsusbt, the rtt/target-debug scripts) only
after both project PRs land.

Test: python -X utf8 -m unittest discover -s tests with TMPDIR on disk: 4263 tests OK (127 skipped).

Copilot AI balanced review requested due to automatic review settings November 2, 2026 19:15
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Walkthrough

The changes add a probe-keyed board registry and a resolver for registered and unregistered HIL board entries. HIL reservation, device labeling, RTT, and target-debug tools now use registry resolution for registered flashers and lock names. The changes also centralize VID/PID validation, add an RP2350-specific OpenOCD halt sequence, and update documentation, fixtures, and tests.

Possibly related issues

  • hathach/agentrc#402 — The PR changes lsusbt to use the registry resolver for labels; the issue’s remaining alias and malformed-roster scope is not fully established by these changes.
  • hathach/agentrc#409 — The PR moves registered flasher data into boards.json and migrates TinyUSB and TinyUF2 roster entries.
  • hathach/agentrc#198 — The PR adds a shared registry for board probe and flasher details and resolves roster entries through it.
  • hathach/agentrc#411 — The PR centralizes registered flasher configurations in the registry, although it does not establish whether roster debug.openocd arguments are removed.
  • hathach/agentrc#401 — The PR adds shared roster resolution and connects several consumers, including RTT and target-debug tools.
  • hathach/agentrc#395 — The PR adds init and catch halt before OpenOCD programming when arguments include target/rp2350.cfg.

Possibly related PRs

  • hathach/agentrc#307 — Both PRs change how rtt.py and probe_state.py validate or resolve the HIL flasher.
  • hathach/agentrc#279 — This PR continues the hil_flasher implementation by resolving flashers from the board registry.
  • hathach/agentrc#261 — Both PRs change flasher handling and VID/PID validation in the HIL flashing path.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to d3871

No confirmed issue blocks merging after normal checks.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Out of Scope Changes check Warning Issue #395 covers the RP2350 OpenOCD flash sequence. The pull request also moves flasher data into boards.json, adds roster resolution and registry lock handling, changes rtt.py, probe_state.py,… Move the board-registry migration and its consumer changes to a separate pull request, or link the active issue that requires them. Keep this pull request limited to the RP2350 flash change and its supporting tests and documentation.
Docstring Coverage Warning Docstring coverage is 35.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Description check Passed The description explains the change in detail. It covers the new boards.json registry keyed by debugger serial, the hil_boards.py resolver, the probe-based roster entries, the lock-name rule, the RP23…
Linked Issues check Passed Issue #395 requires an RP2350-only halt before programming and a command-line unit test. flash_openocd adds -c init -c "catch halt" before program when args contains target/rp2350.cfg. The `…
Title check Passed The title clearly and concisely describes the primary change: resolving each board's flasher from a probe-serial-keyed board registry.
Full details: Description check

Explanation

The description explains the change in detail. It covers the new boards.json registry keyed by debugger serial, the hil_boards.py resolver, the probe-based roster entries, the lock-name rule, the RP2350 OpenOCD halt fix, and the rollout order. It is related to the changeset throughout.

Full details: Linked Issues check

Explanation

Issue #395 requires an RP2350-only halt before programming and a command-line unit test. flash_openocd adds -c init -c "catch halt" before program when args contains target/rp2350.cfg. The rp2350_halt_first_delta test checks this command transformation and excludes other flashers and reset paths. The PR reports 20 of 20 verified Fruit Jam flashes.

Full details: Out of Scope Changes check

Explanation

Issue #395 covers the RP2350 OpenOCD flash sequence. The pull request also moves flasher data into boards.json, adds roster resolution and registry lock handling, changes rtt.py, probe_state.py, hil_reserve.py, and lsusbt, and moves vid_pid parsing. These changes do not implement or support the #395 halt fix, and no linked issue supplies this scope.

Resolution

Move the board-registry migration and its consumer changes to a separate pull request, or link the active issue that requires them. Keep this pull request limited to the RP2350 flash change and its supporting tests and documentation.

Full details: Docstring Coverage

Explanation

Docstring coverage is 35.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 34 functions across 14 files. (7 skipped: 7 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
Simplify code
  • Commit to this branch
  • Create a new PR
  • 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

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3692be30-c688-4135-b211-0712f697f61a
Commits

Reviewing files that changed from the base of the PR and between b9bb590 and d38714d.

Files selected for processing: 18
  • bin/lsusbt
  • skills/hil/SKILL.md
  • skills/hil/boards.json
  • skills/hil/scripts/hil_boards.py
  • skills/hil/scripts/hil_flash.py
  • skills/hil/scripts/hil_reserve.py
  • skills/rtt/scripts/rtt.py
  • skills/target-debug/SKILL.md
  • skills/target-debug/projects/tinyusb.md
  • skills/target-debug/scripts/probe_state.py
  • tests/data/hil_reserve/tinyuf2.json
  • tests/data/hil_reserve/tinyusb.json
  • tests/test_hil_boards.py
  • tests/test_hil_config.py
  • tests/test_hil_flash.py
  • tests/test_hil_reserve.py
  • tests/test_lsusbt.py
  • tests/test_target_debug.py
Files skipped from review as they are similar to previous changes: 1
  • skills/target-debug/projects/tinyusb.md

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@greptile-apps

greptile-apps Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Summary

Moves shared boards’ flash settings into a registry keyed by probe serial.

  • HIL tools get each registered board’s flash settings from one probe-keyed registry.
  • Registered boards use one lock name across project rosters.
  • RP2350 OpenOCD flashes halt the cores before programming.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  R[Project roster] --> H[hil_boards]
  B[Board registry] --> H
  H --> F[Resolved flash settings]
  H --> L[Shared board lock name]
  F --> T[RTT and target-debug tools]
  F --> U[lsusbt labels]
  L --> V[Host-wide reservation]
Loading

Reviews (6) · Last reviewed commit: "hil_flash: cite what the RP2350 document..." · Reviewed by Greptile

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 2, 2026
@hathach

hathach commented Nov 2, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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.

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread bin/lsusbt Resolved
@greptile-apps
greptile-apps Bot dismissed their stale review November 2, 2026 20:35

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@hathach

hathach commented Nov 2, 2026

Copy link
Copy Markdown
Owner Author

@greptileai

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 2, 2026
@hathach

hathach commented Nov 2, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

A board's USB serial depends on the firmware it runs (max32666fthr reports 26 characters under TinyUSB, 32 under
TinyUF2), so a registry keyed by it needed an alias per firmware. The probe a board is wired to is fixed: rosters name
it as `probe` and keep their own `uid`.
@greptile-apps
greptile-apps Bot dismissed their stale review November 3, 2026 04:15

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@hathach

hathach commented Nov 3, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@hathach

hathach commented Nov 3, 2026

Copy link
Copy Markdown
Owner Author

@greptileai

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 3, 2026
Each project named its lock after its own board name, kept equal to tinyusb's by hand (tinyuf2.lock). The registry
name is now the lock on every host; every current lock already equals it, so no lock file is renamed.
Comment thread skills/hil/scripts/hil_reserve.py Resolved
greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 3, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 3, 2026 07:36

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@hathach

hathach commented Nov 3, 2026

Copy link
Copy Markdown
Owner Author

@greptileai

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 3, 2026
@hathach

hathach commented Nov 3, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@greptile-apps
greptile-apps Bot dismissed their stale review November 3, 2026 08:38

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@hathach

hathach commented Nov 3, 2026

Copy link
Copy Markdown
Owner Author

@greptileai

@hathach

hathach commented Nov 3, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@hathach

hathach commented Nov 3, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

hil_flash: flash_openocd programs RP2350 boards with core1 running, so about 1 in 70 flashes fails rcp_init

2 participants