Introducing a new way to review your PRs.

Read the announcement

hathach / tinyusb

An open source cross-platform USB stack for embedded system

View on GitHub

18 documents · Updated Nov 23, 2026

docs / verification-and-automation

Verification and automation

TinyUSB uses layered checks to validate USB behavior and the supported build space. Host tests find logic faults quickly. Fuzz tests explore unsafe input. Firmware builds and hardware-in-the-loop (HIL) tests then show that selected boards, roles, toolchains, and USB fixtures work together. CI narrows work when it can prove the scope, and widens the run when selection data is unsafe. Board and example context is shared with the USB device stack, USB host stack, and USB controller drivers.

Verification model

The verification model moves from isolated rules to real USB links. Unit tests use controlled host-side boundaries. Fuzz tests exercise protocol input. Build checks compile supported combinations. HIL tests run firmware on physical boards and fixtures. Size and SystemView checks add evidence about image cost and run-time behavior.

This diagram shows how a source change moves through the main evidence layers.

flowchart LR
    A[Source change] --> B[Pre-commit checks]
    B --> C[Unit tests]
    B --> D[Fuzz build and replay]
    A --> E[Change impact selection]
    E --> F[Build and dependency matrix]
    F --> G[HIL firmware]
    G --> H[Boards and USB fixtures]
    E --> I[Coverage and size checks]
    H --> J[USB stress battery]
    H --> K[SystemView capture]
    K --> L[Offline performance report]

Each result has a limited claim. A build proves that one configuration compiles. A HIL result proves that the selected firmware ran on the selected rig. A size or SystemView result applies only to the images and captures that were built and compared. Incomplete work remains visible instead of becoming an implied pass.

Unit verification

Unit test suite

The unit test suite checks reusable device, host, and controller behavior on the host. Ceedling supplies the test runner and mocks for the main suite. CMake also exposes selected tests as real host executables and CTest entries. Tests drive stack callbacks, descriptor rules, transfer boundaries, and controller state without a microcontroller or USB cable. Per-test build settings keep host, device, feature, and trace variants separate.

Recent tests extend the suite in several areas:

  • Common endpoint checks validate full-speed and high-speed bulk packet-size rules.
  • Device DFU checks cover alternate-setting limits and control-request direction.
  • Device mass-storage checks cover padded and unpadded full-speed replies, reset recovery, partial and asynchronous I/O, sense data, and invalid transfer lengths.
  • Device-core checks cover dropped events, control-request bounds, endpoint ownership, stream limits, deferred work, and SOF state.
  • Host class checks cover audio descriptor and control flows, MIDI 2.0 alternate settings, mass-storage enumeration and recovery, and large transfers.
  • Host-core checks cover configuration completion, hub status bounds, speed rules, endpoint stall handling, idle task behavior, deferred callbacks, stop-event handling, and enumeration retry state.
  • Host-controller checks cover DWC2 split scheduling, retry order, DMA and slave paths, channel aborts, and FIFO limits.
  • The STM32 FSDEV fixture checks control SETUP handling against RAM-backed register and packet-memory models.

These tests make boundary rules visible in small host-side models. They do not prove that a real controller, board, probe, host driver, or physical USB link behaves like the model. HIL provides that wider check.

References: test/…/CMakeLists.txt• L27-78 test/…/CMakeLists.txt• L102-167 test/…/project.yml• L102-287 test/…/test_dfu_device.c• L184-240 test/…/test_msc_device.c• L439-563 test/…/test_msc_nopad_device.c• L174-466 test/…/test_usbd.c• L299-550 test/…/test_dwc2_split.c• L154-180 test/…/test_midi2_host.c• L489-631 test/…/test_msc_host.c• L305-383

Host controller fixtures

The host fixtures add direct CMake and CTest paths for controller behavior. The WCH USBHS fixture runs speed and hub variants and models DMA, scheduling, transfer completion and cancellation, periodic transfers, detach recovery, and transaction-translator behavior. The EHCI fixture runs controller scheduling, split transactions, descriptor pools, completion and cancellation, endpoint limits, and frame-counter wrap. The STM32 FSDEV fixture models a device controller's RAM register block and packet memory to check EP0 SETUP and status handling. These fixtures keep controller coverage available even when Ceedling is not installed.

The fixtures keep target assumptions visible. They use host compilers, keep assertions enabled, and model the address limits needed by simulated DMA. The EHCI cases are reported as skipped on macOS when that address model cannot be made safe. These fixtures model controller state but not physical DMA coherency or USB timing, so they complement rather than replace HIL.

References: test/…/CMakeLists.txt• L15-81 test/…/CMakeLists.txt• L84-111 test/…/stm32f0xx.h• L3-22 test/…/test_setup.c• L1-31 test/…/test_setup.c• L56-117 test/…/tusb_config.h• L3-9 test/…/README.md• L3-31 test/…/test_hcd.c• L146-188 test/…/test_iso.c• L7-37 test/…/cache_stubs.c• L14-31

Pre-commit gates

The pre-commit workflow runs repository hooks and prepares the host checks before larger CI work. It installs the required Ceedling release, fetches the pinned HIL support dependency, runs all configured hooks, and builds and replays the fuzz targets with Clang. The hooks also protect the change selector and HIL contracts without requiring hardware.

Multi-step hooks use tools/hook_steps.py as a shell-free runner. It resolves Python commands to the hook's interpreter, supports a repository-relative working directory, and stops at the first non-zero result. This keeps the same hook steps usable on systems that do not provide a POSIX shell. Its unit tests check ordering, directory changes, command lookup, interpreter choice, and missing-command errors.

The fuzz step gives each device and host harness a short bounded run. This catches broken target wiring and immediate failures early. The longer pull-request fuzz campaign remains a separate check.

References: .github/…/pre-commit.yml• L13-57 .pre-commit-config.yaml• L40-74 .pre-commit-config.yaml• L98-127 tools/hook_steps.py• L1-43 test/…/test_hook_steps.py• L42-138 test/…/project.yml• L9-30 .github/…/build.yml• L33-71

Fuzz verification

Fuzz harnesses

The fuzz layer feeds generated bytes and USB protocol events into selected device and host paths on the host. Device harnesses cover class parsing, transfer progress, callback results, and recovery state. Host enumeration harnesses drive descriptors and control-transfer completion through the host state machine. The harness boundary is synthetic, so it targets input handling and protocol state rather than a complete electrical transfer.

The device mass-storage BOT harness treats the input as a command block followed by callback controls and bulk data. It explores complete, partial, busy, error, and asynchronous application results. It also exercises endpoint stall and clear-stall recovery. A bounded step count limits callback retries and transfer progress even when the input requests a large transfer.

The device NCM harness feeds raw network transfer blocks into receive validation. Its exact-size buffer and sanitizer run make malformed length and offset fields visible as memory errors before the driver walks the datagram list.

The host mass-storage msch_open harness checks the descriptor walk as a bounded span. It verifies that accepted interfaces open two correctly directed endpoints and that rejected input opens none. CI builds the same input path with normal validation and with validation disabled, so descriptor bounds remain part of the harness contract in both modes.

Local fuzz checks use Clang with sanitizers and replay known seed inputs before mutation. Seed replay is a CTest check with a bounded run. OSS-Fuzz supplies the hosted campaign environment.

References: test/…/README.md• L1-44 test/…/CMakeLists.txt• L8-20 test/…/CMakeLists.txt• L59-74 test/…/CMakeLists.txt• L144-165 test/…/fuzz.c• L11-60 test/…/fuzz.c• L87-145 test/…/fuzz.c• L173-231 test/…/fuzz.c• L8-21 test/…/fuzz.c• L8-10 test/…/fuzz.c• L94-139

Fuzz automation

CIFuzz runs on pull requests that change C or C++ inputs and can also run on demand. It builds the fuzz project, runs each target for a bounded time, and preserves crash data when a target fails. The shorter pre-commit run finds local wiring errors before the hosted campaign starts.

References: .github/…/pre-commit.yml• L42-57 .github/…/cifuzz.yml• L1-39

Hardware-in-the-loop verification

HIL test scope

HIL tests exercise firmware on physical boards with debug probes and USB fixtures. A roster defines the board identity, USB role, firmware variants, attached devices, flasher, and recovery path. Active rosters cover device, host, and dual-role paths. The HFP roster adds a separate attached-board set for device-side checks and its IAR build lane. Parked boards remain known coverage rather than being mistaken for active coverage.

The normal battery checks enumeration and class traffic across storage, audio, networking, and throughput examples. USB network checks place the board interface in a private network namespace. They verify the web server with complete asset data and measure the optional iperf path without changing host routing. A separate USB test battery adds kernel-level control, bulk, interrupt, isochronous, halt, unlink, and performance cases. Its tier comes from the test device, and every selected case must produce a result. A case that is gated off or not started is not a pass.

The USB battery resets a hub transaction translator after unlink or failed cases. An unconfirmed reset ends the battery and marks the remaining cases as not run, rather than allowing a shared hub fault to look like a clean pass.

References: test/…/tinyusb.json• L1-44 test/…/hfp.json• L1-78 test/…/hil_util.py• L18-56 test/…/hil_test.py• L184-232 test/…/hil_test.py• L1338-1346 test/…/net_test.py• L1-11 test/…/net_test.py• L119-224 test/…/usbtest.py• L74-87 test/…/usbtest.py• L408-470 test/…/test_hil_usbtest_tt.py• L61-99

Targeted workloads cover transitions that ordinary examples do not create. They check delayed control requests, configuration changes during bulk traffic, and recovery after transfer faults. The HIL runner also rechecks device identity after re-enumeration so results stay tied to the intended board.

References: test/…/hil_test.py• L2071-2169 test/…/usbtest.py• L310-423 test/…/test_hil_dual_parse.py• L21-120

This sequence shows the main physical-test lifecycle.

sequenceDiagram
    participant CI
    participant Build as Firmware build
    participant Rig as HIL rig
    participant Board
    participant USB as Host and fixture
    CI->>Build: Select board, role, example, and toolchain
    Build-->>CI: Firmware artifact
    CI->>Rig: Reserve board and select flasher
    Rig->>Board: Flash and reset
    Rig->>USB: Check identity and run USB tests
    USB-->>Rig: Traffic and result
    Rig-->>CI: Per-test report and state

The runner bounds external work and the HIL pool. A timeout records the boards that did finish and marks unfinished boards for a focused retry. A wedged or ambiguous device stops further traffic on that board. Recovery is attempted only through a bounded path that proves the process ended before the board can be reused.

References: test/…/hil_test.py• L2280-2315 test/…/hil_test.py• L2143-2213 test/…/usbtest.py• L170-225 test/…/test_hil_bounded.py• L151-185 test/…/test_hil_wedge_sweep.py• L133-176

HIL dependency identity

The HIL harness uses a shared agentrc service for board locks, flash operations, reports, USB observation, RTT, and SystemView support. test/…/agentrc.json pins the CI checkout to a repository commit. A staged checkout is used for a remote run. Outside CI, an installed checkout is used. The loader checks the API and the complete file closure before it runs provider code.

The selection is strict. CI accepts only explicit true or false values and uses the clean checkout at the recorded commit. A staged tree takes priority but does not fall back when its manifest or files differ. The process keeps one identity and refuses a closure file that changes after loading. This gives build, rig, and report jobs one compatible support layer.

References: test/…/agentrc.json• L1 test/…/agentrc.py• L3-17 test/…/agentrc.py• L58-80 test/…/agentrc.py• L83-121 test/…/agentrc.py• L124-167 test/…/agentrc.py• L176-201 test/…/test_hil_agentrc.py• L112-187 test/…/test_hil_agentrc.py• L189-277

HIL resource safety

HIL protects shared hardware before it tests firmware. Board locks prevent a developer session and a CI job from using one board at the same time. Farm checks select the host roster, find the correct probe, reset the target, and verify that the target responds.

An unfinished flash or debug session is a cleanup blocker, not ordinary contention. The lock stays held until recovery proves that the session ended. The same rule protects later jobs from a process that survived a canceled run. Network checks also keep the namespace client tied to the selected USB serial and interface index, so a shared MAC or renamed interface cannot redirect traffic to another board. Farm checks also exclude TinyUSB device firmware from probe matches, so a board cannot be mistaken for its own debug probe.

References: test/…/hil_util.py• L177-191 test/…/hil_flash.py• L181-253 test/…/net_test.py• L48-87 test/…/net_test.py• L119-167 test/…/farm_profile.py• L26-59 test/…/farm_profile.py• L69-92 test/…/test_hil_farm_check.py• L318-381 test/…/test_hil_lock.py• L104-166

HIL reports

HIL writes one machine-readable report and renders the human report from that document. Board and test states distinguish pass, fail, skip, lock refusal, wedge, timeout, build refusal, cleanup pending, and aborted work. A retry updates only the work it exercised while keeping earlier attempts as history.

The report writer treats the JSON sidecar as the source of truth. It validates and normalizes report input at the boundary, publishes the sidecar and its Markdown rendering together, and writes an explicit unavailable notice when it cannot prepare a trustworthy pair. The command line also records no-selection runs and exposes the retry-sequence verdict separately from the latest snapshot.

The report records scoped runs and no-selection runs. It also records when the worker pool stops before all selected boards report. These states affect the machine verdict, so a partial table cannot appear green only because its completed rows passed.

References: test/…/hil_report.py• L31-75 test/…/hil_report.py• L157-183 test/…/hil_report.py• L247-263 test/…/hil_report.py• L274-321 test/…/hil_report.py• L409-507 test/…/hil_report.py• L748-779 test/…/hil_report.py• L886-969 test/…/test_hil_report.py• L258-337 test/…/test_hil_report.py• L671-717

SystemView evidence

SystemView adds a bounded performance trace to selected HIL boards. It does not change the normal USB test verdict. The rig captures a named workload, then CI decodes the capture away from the hardware and compares it with a matching base capture.

The comparison uses only compatible workload and capture settings. It reports function timing, CPU load, and stack high-water data when the capture has a time base, no loss, a successful workload, and enough samples. Missing or partial captures remain unavailable evidence.

References: test/…/sysview_ci.py• L1-10 test/…/sysview_ci.py• L106-135 test/…/sysview_ci.py• L389-410 test/…/sysview_ci.py• L459-460 test/…/test_hil_sysview_capture.py• L74-163 test/…/hil_test.py• L2363-2387

Build and dependency automation

Supported configuration matrix

The build matrix checks MCU families, boards, roles, examples, variants, and compiler toolchains. GitHub Actions builds a repeatable pinned board set. Changed boards outside that set still receive a required compile check when no selected job covers them. Windows and macOS build lanes add cross-platform build-system coverage. Other CI paths extend family and toolchain coverage.

HIL firmware builds stay separate from physical rig jobs. The HIL matrix derives each board's firmware variants from the roster and adds a separate traced image when a selected device or dual-role workload needs SystemView evidence. Fast toolchains, slow Espressif builds, and the IAR HFP lane have their own timing and artifact paths. Empty scoped toolchain lists skip cleanly instead of creating invalid matrix jobs.

The build matrix validates selection data before it filters work. A valid empty selection can produce no legs. A selection that names no family buildable by the current matrix widens to the full safe matrix instead of running a green job that invokes no compiler.

References: .github/ci-pinned-boards.json• L1-49 .github/…/ci_set_matrix.py• L22-25 .github/…/ci_set_matrix.py• L137-186 .github/…/ci_set_matrix.py• L213-254 .github/…/ci_set_matrix.py• L257-310 .github/…/hil_ci_set_matrix.py• L69-146 .github/…/build.yml• L303-367 .github/…/build.yml• L392-455 .github/…/build.yml• L734-925 .github/…/build_util.yml• L36-57

Toolchain and dependency inputs

Build automation uses fixed external inputs. Toolchain archives are checked by URL and checksum. tools/get_deps.py fetches mandatory libraries for every build and selects optional SDKs and libraries by family, board, or explicit dependency path. Each dependency is checked as its own repository, reset before reuse, and placed at its recorded commit.

Traced builds add SystemView sources only when tracing is enabled. The same dependency table can generate the dependency documentation. The command-line shape also accepts build-matrix inputs that do not change dependency selection, so shared build jobs can call one stable fetch step. HIL host checks add pinned Python packages and separate system tools for storage, audio, USB networking, USBTMC, and iperf. This keeps the source, build, trace, HIL support, and host-test inputs reproducible across runners.

References: .github/…/toolchain.json• L2-48 tools/get_deps.py• L9-31 tools/get_deps.py• L299-321 tools/get_deps.py• L393-452 tools/get_deps.py• L465-525 .github/…/build_util.yml• L64-73 test/…/requirements.txt• L1-15

Code-size evidence

Code-size automation measures Flash and RAM for selected board and example images. It compares matching images with a baseline and can show changes by TinyUSB source file. A missing image, expected build leg, or baseline remains incomplete rather than becoming a zero-size result.

The size profile follows the board and example selection used by normal builds. It uses the image's own link inputs, including linker scripts and symbols, so a missing build graph or linker layout is an error rather than a report against guessed memory regions. Its tests also check the launcher-to-engine contract, board and example validation, dependency preparation, and the separate Espressif build path.

For a pull request, the baseline comes from a completed master build of the base commit when available. If that run is missing, the tool may use a nearby first-parent ancestor and labels the comparison as approximate. A failed lookup is recorded as unavailable evidence, not as a request to rebuild the baseline. Publication also checks that the Build run is still the latest run for the pull request before it replaces a report.

Size work is measurement only. A failed size snapshot does not replace the build verdict. The workflow records which size legs were expected, so a missing report can be distinguished from a leg that was never selected.

References: .github/…/code_size_ci.py• L1-18 .github/…/code_size_ci.py• L68-137 .github/…/code_size_ci.py• L141-177 .github/…/build.yml• L264-301 .github/…/build_util.yml• L115-142 .github/…/build_util.yml• L217-227 tools/code_size_profile.py• L30-69 tools/code_size_profile.py• L208-229 tools/membrowse_cli.py• L29-49 tools/membrowse_cli.py• L120-161 .github/…/pr_comment.yml• L270-374 test/…/test_code_size.py• L47-70 test/…/test_code_size.py• L73-115 test/…/test_code_size.py• L117-193 test/…/test_code_size.py• L235-325

Coverage evidence

Coverage checks compare controller drivers with the pinned CI board catalog and the physical HIL rosters. They keep compile coverage distinct from physical-board coverage. Required-board reporting makes a changed board visible when no pinned or physical lane covers it.

Change selection also follows class-header include edges and dependency-family mappings. This keeps a change in a shared header or fetched library connected to the examples and boards that actually compile it.

References: tools/change_impact.py• L443-484 tools/change_impact.py• L491-565 tools/change_impact.py• L887-908 .github/ci-pinned-boards.json• L35-49 .github/…/build.yml• L213-220 test/…/test_change_impact.py• L166-215

Change impact selection

Selection scope

The change-impact selector maps changed paths to the smallest safe set of build families, examples, boards, and HIL tests. It understands core roles, class use, board files, examples, dependency families, and SystemView inputs. Build selection and HIL selection remain separate because a family can need compilation without having a board on the rig.

The selector fails open. Unknown or unsafe input widens the run instead of producing an empty job. A valid documentation-only result can remain an explicit no-op. A build gap stays visible so firmware that no current matrix compiles is not silently ignored.

The selector checks keep port, board, MCU, and dependency-family mappings connected to real build coverage. They also protect flasher and role mappings so a scoped result cannot name work that the rig cannot dispatch. The two HIL rosters are checked together where their selection rules must agree.

References: test/…/test_change_impact.py• L102-162 test/…/test_change_impact.py• L216-274 test/…/test_change_impact.py• L283-310 test/…/test_change_impact.py• L704-790 test/…/test_change_impact.py• L863-922 .github/…/ci_set_matrix.py• L137-178 .github/…/ci_set_matrix.py• L213-254 .github/…/ci_set_matrix.py• L286-304 .github/…/build.yml• L40-71

Selection manifest

The selection manifest is the contract between change analysis and CI matrix builders. It carries build work and HIL work together with required boards, selected examples, HIL arguments, and the state of the selection. CI passes the manifest through a workspace file so large changes do not exceed an environment or argument-size limit.

The manifest distinguishes no work, a build gap, a scoped run, and the full matrix. Consumers validate it before they narrow work. Malformed or contradictory data falls back to the full safe matrix.

References: .github/…/build.yml• L101-177 .github/…/build.yml• L179-245 test/…/test_change_impact.py• L2408-2498 test/…/test_ci_metrics.py• L163-203

CI orchestration

GitHub Actions

GitHub Actions coordinates selection, toolchain and dependency setup, build matrices, HIL work, artifacts, size data, and SystemView data. Reusable build jobs produce firmware for the matching physical rig. HIL jobs download those artifacts, reserve boards, run the selected tests, and upload reports even when the test step fails.

Pull requests use best-effort scoped work. Selector suites run before their output is trusted. If selection fails, CI uses the full matrix. A rig with no affected boards writes an explicit skipped report rather than running a filter that matches nothing. Re-runs can use the recorded failed subset.

References: .github/…/build.yml• L19-245 .github/…/build.yml• L474-632 .github/…/build.yml• L640-727 .github/…/build.yml• L734-902 .github/…/build_util.yml• L75-113

Static analysis

Static analysis builds representative board configurations before it checks C and C++ quality. CodeQL runs on a hosted board build and uploads filtered security findings. PVS-Studio and SonarQube add separate analysis lanes for trusted, non-fork pull requests because they require secrets. The analysis lanes are evidence in addition to, not a replacement for, build and HIL checks.

References: .github/…/static_analysis.yml• L30-90 .github/…/static_analysis.yml• L92-143 .github/…/static_analysis.yml• L145-188

Pull-request reports

The report workflow runs in the base repository after Build completes. It resolves the pull request from trusted workflow metadata, downloads HIL and performance artifacts, and posts sticky comments. It keeps HIL correctness, SystemView performance, and code-size measurement as separate report sections.

The separate Membrowse comment workflow summarizes memory changes after a Build run. It resolves fork pull requests from trusted run metadata, skips superseded runs, serializes comment jobs per branch, and supports a manual re-post for an existing commit. This keeps source-size evidence current without allowing an older run or PR-controlled names to replace the latest comment.

Artifact downloads and report rendering are bounded and best effort. The workflow posts an unavailable notice when evidence is missing, and checks that the run is still current before it replaces a pull-request comment. Report content is escaped so data from a fork cannot create mentions or change the comment structure.

References: .github/…/pr_comment.yml• L9-44 .github/…/pr_comment.yml• L46-144 .github/…/pr_comment.yml• L145-269 .github/…/pr_comment.yml• L270-374 .github/…/membrowse-comment.yml• L1-98 test/…/test_membrowse_cli.py• L227-252

CircleCI matrix

CircleCI extends family and toolchain coverage from shared selection data. It rewrites a controlled matrix input instead of maintaining a second large board list. Its selector tests protect the hand-off and return to the full matrix when the generated scoped data cannot be trusted.

References: test/…/test_ci_metrics.py• L24-76 test/…/test_ci_metrics.py• L78-160

Change checklist

When these files or sections are changed, remember to consider these:

  • When a unit-test fixture or shared protocol helper changes, keep its mock boundary, configuration variant, transfer-completion mode, and Ceedling registration aligned.
  • When a new CMake host fixture changes, keep its compiler limits, simulated hardware assumptions, CTest registration, and macOS skip behavior aligned.
  • When the STM32 FSDEV fixture changes, keep the stand-in vendor header, RAM register and packet-memory model, EP0 capacity assumptions, and CMake test registration aligned.
  • When a new unit target uses a support header, keep its generated mock set, source list, compile definitions, and host-only boundary aligned.
  • When a fuzz target changes, keep its CMake target, seed archive, local replay, sanitizer mode, and alternate validation configuration aligned.
  • When a multi-step pre-commit hook changes, keep its interpreter, working directory, command lookup, step order, and Windows shell-free path aligned.
  • When the HIL support pin or loader changes, keep the fetched commit, closure files, API check, identity selection, and staging rules aligned.
  • When board locks, farm checks, or USB observation changes, keep developer sessions, CI jobs, probe identity, and stale-process recovery on one board identity.
  • When a HIL battery changes, keep its selected-case denominator, device identity checks, timeout budget, recovery path, and report verdict aligned.
  • When the USB test battery changes, keep tier selection, packet-safe parameters, transaction-translator reset handling, budget back-fill, and wedge recovery aligned.
  • When a new protocol battery such as USBTMC changes, keep its device identity, host dependency, subprocess bound, case selection, recovery, and remote staging aligned.
  • When a roster changes, keep variants, roles, attached devices, flashers, recovery paths, firmware artifacts, and flasher-split jobs aligned.
  • When the HFP roster or IAR lane changes, keep full compile coverage, scoped HIL selection, fork-secret rules, and the shared runner schedule aligned.
  • When HIL report fields or status cells change, keep the JSON sidecar, Markdown rendering, retry merge, summary verdict, and PR comment aligned.
  • When selection rules or manifest fields change, update both build and HIL consumers and preserve fail-open behavior for unsafe input.
  • When the pinned board catalog changes, check required-board reporting, family coverage, alternate toolchain ownership, and membrowse ownership together.
  • When a toolchain or dependency changes, check its family mapping, checksum or commit pin, build bucket, size eligibility, and HIL eligibility together.
  • When size or SystemView data changes, keep expected-leg tracking, baseline pairing, capture identity, evidence gates, and unavailable notices consistent.
  • When Membrowse command or comment behavior changes, keep target names, linker inputs, identical uploads, current-run checks, escaping, and sticky-comment replacement aligned.
  • When PR publication changes, keep trusted PR lookup, artifact layout normalization, current-run checks, escaping, and sticky-comment replacement aligned.

Important failure modes

TriggerConsequenceGuard
The pinned HIL support checkout is missing, dirty, or off its commitThe harness refuses to load or CI cannot safely use board and report servicesPinned fetch, API check, closure identity, and import-closure tests
CI has an invalid truth value for CI or GITHUB_ACTIONSThe HIL loader refuses to choose a support checkoutStrict true-or-false parsing and bootstrap tests
A staged HIL support tree differs from its manifestA remote run cannot use a possibly mixed support layerManifest byte checks and no-fallback refusal
A dependency path is not its own checkout or cannot reach its recorded commitBuild setup can stop instead of using the parent repository or an unpinned libraryOwn-checkout validation, recorded repository URL, shallow fetch, and detached commit
A host fixture violates its compiler or low-address assumptionsThe fixture can fail to build or can test the wrong DMA address modelGCC or Clang gate, active assertions, low-address link settings, and explicit macOS skip
The STM32 FSDEV stand-in does not match the RAM register or packet-memory modelThe setup test can pass without checking the controller path it claims to modelDedicated vendor-header stand-in, bounded PMA reads, and CTest registration
A fuzz target is wired into CMake but its seed or host configuration is missingPre-commit can miss the target or fail before it exercises the intended input pathTarget-specific seed replay and dedicated host configuration
A mass-storage fuzz input requests unbounded callback retries or transfer stepsOne input can consume excessive time instead of reaching a bounded verdictRetry limits and a hard step cap
A malformed NCM transfer block claims data beyond the received bufferThe receive validator can read outside the fuzz inputExact-size receive allocation and sanitizer-backed fuzzing
A hook step needs a shell or names a command that cannot startThe pre-commit hook stops before later checks and returns the launch errorShell-free step runner, interpreter substitution, PATH lookup, and 127 launch status
Two jobs or a developer session use one board without the same lockFlashing or USB traffic can affect the wrong runShared board locks and non-waiting lock refusal
A flash or debug process remains alive after a timeoutThe board can be unsafe for the next testRetained locks, cleanup blockers, bounded rechecks, and recovery evidence
A USB test case is gated off, budgeted, or has no resultThe battery denominator shrinks and a capability gap can look greenExplicit NOTRUN or BUDGET states and selected-case accounting
A transaction-translator reset is not confirmed after a USB test transitionLater cases can inherit a hub fault or report a clean partial batteryBounded reset polling and a failing battery with remaining cases marked BUDGET
A device disappears or has an ambiguous identity after re-enumerationResults can be assigned to the wrong device or later traffic can wedge the rigSerial identity checks and fail-closed board wedge handling
A USB network serial maps to no interface or to more than one interfaceThe test can move the wrong link or cannot prove which board it testedSerial-based discovery, one-interface checks, udev readiness, and ifindex checks
The network namespace client or iperf process hangsThe board worker can wait without a useful resultProcess bounds, signal cleanup, a client alarm, and bounded iperf execution
The optional iperf server is absentHTTP coverage still runs but no throughput metric is recordedTreat connection refusal as a reported no-server condition, not a false pass metric
A HIL worker pool expires before every board reportsFinished rows are lost or the run looks green from partial workTimeout markers, retained completed rows, and failed-subset retry specs
A report sidecar is malformed or absentHuman and machine results can disagree or old rows can look currentBoundary normalization, one renderer, explicit unavailable markers, and freshness checks
A SystemView capture has loss, no time base, too few samples, or changed setupPerformance deltas compare unlike or unreliable evidenceCapture configuration checks and metric withholding
Selector output is malformed or its suites failCI can skip required work or create a vacuous green matrixSelector tests, manifest validation, UNSCOPED fallback, and full-matrix fallback
A selected family is not built by any matrix toolchainA scoped job can run no compiler and still appear successfulBuildability check and full-matrix fallback
A required board has no matching firmware artifactThe board is selected but cannot be flashedVariant-aware artifact names, build gates, and artifact download checks
A size leg lacks an image, expected-leg record, or baselinePartial measurement can look like a clean size resultIncomplete comparison state, baseline notes, and always-written report notices
A size profile has no build graph or linker scriptMemory results could use false default regionsExplicit build-graph and linker-input checks
A PR comment uses an old or untrusted runAn obsolete or fork-controlled result can replace current evidenceTrusted head lookup, current-run checks, escaped content, and sticky comments

Key files

FileWhy to read it
.pre-commit-config.yamlDefines the local hook groups, their scope, and their Python environments.
test/…/project.ymlDefines the host unit-test scope and configuration variants.
test/…/CMakeLists.txtShows how selected Ceedling tests become host executables and CTest entries.
test/…/CMakeLists.txtDefines the standalone controller fixture variants and host safety rules.
test/…/test_setup.cShows RAM-backed verification of STM32 FSDEV EP0 SETUP handling.
test/…/stm32f0xx.hDefines the minimal vendor-header boundary used by the FSDEV fixture.
test/…/test_hcd.cShows direct host verification for WCH USBHS DMA, scheduling, hubs, and transfer recovery.
test/…/test_iso.cShows the controller scheduling and transfer cases modeled without hardware.
test/…/test_dfu_device.cShows device DFU alternate-setting and control-direction checks.
test/…/test_usbd.cShows device event, control-stage, endpoint, and task-queue boundary checks.
test/…/test_dwc2_split.cShows DWC2 split scheduling, retry, DMA, FIFO, and abort checks.
test/…/test_midi2_host.cShows host MIDI 2.0 descriptor, endpoint, alternate-setting, and fallback checks.
test/…/test_msc_host.cShows host storage descriptor, LUN, large-transfer, enumeration, and recovery checks.
test/…/CMakeLists.txtDefines fuzz targets, sanitizers, seed replay, and host build rules.
test/…/fuzz.cShows bounded device mass-storage fuzzing for callback outcomes and transfer recovery.
test/…/fuzz.cShows bounded NCM receive validation fuzzing for malformed transfer blocks.
test/…/fuzz.cShows bounded descriptor-span fuzzing for host mass-storage interface opening.
.github/…/pre-commit.ymlShows the fast hook and fuzz gates.
test/…/agentrc.jsonPins the shared HIL support checkout used in CI.
test/…/agentrc.pySelects and verifies the installed, pinned, or staged HIL support layer.
test/…/test_hil_agentrc.pyProtects support-layer selection, pin, staging, API, closure, and module-loading contracts.
test/…/tinyusb.jsonDefines the active HIL board roster, roles, variants, workloads, and parked hardware.
test/…/hil_test.pyShows the board lifecycle, test dispatch, timeout, retry, and park boundaries.
test/…/net_test.pyShows isolated USB network, HTTP asset, and iperf verification.
test/…/usbtest.pyDefines the kernel USB battery, recovery, budget, and verdict boundary.
test/…/hil_report.pyDefines the report document, status vocabulary, rendering, retry merge, and machine verdict.
test/…/sysview_ci.pyDefines capture validity and offline performance comparison.
test/…/requirements.txtDefines Python and host-tool inputs for HIL tests.
.github/ci-pinned-boards.jsonDefines the repeatable board catalog and visible uncovered controller paths.
.github/…/ci_set_matrix.pyMaps validated selections to toolchain matrices, required-board checks, and safe fallbacks.
.github/…/hil_ci_set_matrix.pyMaps HIL roster boards and variants to firmware and traced-image build legs.
tools/get_deps.pyPins and fetches build, trace, and library dependencies.
.github/…/code_size_ci.pyFinds a safe code-size baseline and rejects stale pull-request publication.
tools/code_size_profile.pyConnects board builds and link inputs to the code-size engine.
test/…/test_code_size.pyProtects the code-size launcher, build profile, linker inputs, dependency preparation, and baseline contracts.
.github/…/build.ymlOrchestrates selection, matrices, artifacts, HIL jobs, and evidence scope.
.github/…/build_util.ymlDefines reusable toolchain, dependency, build, size, and firmware artifact steps.
.github/…/static_analysis.ymlDefines representative CodeQL, PVS-Studio, and SonarQube analysis lanes.
.github/…/pr_comment.ymlPublishes trusted HIL, SystemView, and code-size results.
test/…/test_change_impact.pyProtects selection, role mapping, coverage mappings, and fail-open behavior.
test/…/test_ci_metrics.pyProtects selection hand-off and generated CI matrix limits.