Commit Graph

49 Commits

Author SHA1 Message Date
e02f93158c test/hil: usbtest fleet enablement, shuffled scheduling, unique PIDs
Pool/config:
- record real uids (ra8m1_ek), enable usbtest for espressif s3/p4, then
  park ra6m5_ek and ra8m1_ek in boards-skip (ra6m5's usbtest/MSC traffic
  can kill the uPD720201 host on its ROM firmware; ra8m1 USBHS bring-up
  pending); max32666/nrf54lm20 stay enabled - their MosChip flakiness
  never wedges
- re-enable device/usbtest on HS boards (mimxrt1064, ch32v307) now that
  uPD720201 firmware 2.0.2.6 fixes the command-ring death; mimxrt1015
  stays skipped - its HS battery killed the controller on both ROM and
  2.0.2.6 firmware (board-specific); match the moved host-test bundles
  (f723 <-> rt1064); skip never-passing tests on the new
  nrf5340dk/nrf54lm20dk boards and the detached pico host bundle, each
  documented with a comment

Host-controller quirk gating in usbtest.py (auto-skip, self-heals on a
healthy xHCI):
- MosChip MCS9990 EHCI: case 25 (int-OUT never scheduled, FRINDEX bug)
  and case 11 (unlinked reads complete short/EREMOTEIO)
- Renesas uPD720201 xHCI: firmware-gated. The card must run firmware
  >= 2.0.2.6 (RAM-uploaded - it reverts to ROM on every power cycle):
  on older firmware the command ring dies under unlink stress (a
  Configure Endpoint command stops completing; the hub worker deadlocks
  holding the device lock; only a host power cycle recovers; three
  boards reproduced it). usbtest.py reads the FW version register (PCI
  config 0x6c) and refuses to run at all on older firmware - hil_test
  surfaces that as a failed test with the reason. On current firmware
  the full 30-case battery runs (validated FS+HS: metro_m4, f723,
  f723-DMA all 30/30).

Scheduling (hil_test.py):
- Shuffle each (board, variant)'s test order with a seeded RNG
  (HIL_SHUFFLE_SEED to replay) so usbtest batteries and flash churn spread
  across the timeline instead of convoying on one controller.
- Per-controller usbtest + flash semaphores: HIL_USBTEST_PARALLEL
  (default 4) concurrent usbtest batteries and HIL_FLASH_PARALLEL
  (default 8) concurrent flashes per host controller. Profiled on
  uPD720201 firmware 2.0.2.6 across 8/1..12/8: wall time falls
  22.2/14.3/12.5/10.8 min at usbtest width 1/2/3/4 and plateaus there;
  zero controller errors everywhere; first battery case failures
  (leaf-hub bandwidth stretch) appear at 12/8, and flash width 12 only
  amplifies flasher-hub contention flakes - so 8/4 is the optimum. A
  separate battery-window flash throttle was profiled and dropped.
- Give every example a unique hardcoded USB PID (0x4001-0x4022, usbtest
  keeps 0x4010) instead of the PID_MAP interface bitmap: different
  examples now always re-enumerate back-to-back, even on boards whose
  CPU reset does not drop D+ (WCH CH58x), so the EXAMPLE_PID table and
  same-PID adjacency reordering in hil_test.py are gone; only the
  variant-boundary same-example repeat needs a swap.
- Report matrix: stable columns with the metric-bearing tests pinned
  first (usbtest, cdc_msc_throughput, msc_file_explorer[_freertos]),
  the rest alphabetical.

Fail fast:
- enum wait budget 8 s on the first attempt, 4 s on retries; dfu waits
  are deadline-based so dfu-util's own runtime counts against the
  budget.
  A device-absent failure now costs ~3-5x a passing test (20-30 s)
  instead of 10-30x (47-150 s).
- CI runs hil_test with --retry 1 and no in-run second pass: a broken
  fixture fails the job fast instead of holding the self-hosted runner
  for hours and blocking other PRs' HIL jobs. hil_test still writes the
  .skip sidecar, so a manual re-run attempt only retests what failed.

Review fixes (multi-agent adversarial review of this commit):
- tinyusb_win_usbser.inf: the PID rework moved five CDC examples onto
  even PIDs the INF's odd-only DeviceList never matched (legacy-Windows
  usbser binding) - appended 0x4006/4008/400a/4020/4022 to both lists.
- usbtest example: USBTEST_TIER is now overridable and the descriptors
  and pumps are tier-conditional, so a board whose DCD cannot serve a
  tier lowers it instead of skipping the whole example - RA2A1 (RUSB2
  with no isochronous pipe) builds at tier 3 via its BOARD_ define; the
  host battery follows the tier advertised in bcdDevice. Tier-4 output
  verified byte-identical after the refactor.
- dynamic_configuration's second config derived USB_PID + 11 = 0x4018,
  colliding with net_lwip_webserver - now USB_PID + 0x0100, outside the
  per-example space. tools/check_example_pids.py (pre-commit hook)
  enforces PID uniqueness incl. derived and literal idProduct values.
- usbtest.py firmware gate: matched by device ID (uPD720201/720202,
  both use the 0x6c FW register), and an unreadable version (setpci
  missing/denied) now refuses with its own message instead of
  masquerading as "firmware 0x00000000"; noted the gate is necessary
  but not sufficient (board-specific kills stay per-board skips).
- hil_test: deadline waits use time.monotonic(); multiprocessing
  context pinned to fork (raw semaphores in Pool initargs); flash and
  usbtest permits unified into one fail-closed, exception-safe
  ctrl_permit (unknown controller takes every slot and logs a warning
  instead of silently borrowing slot 0); an all-skipped battery
  reports as skip, not "0/0" failure; slow-body polls (mtp, printer,
  disk read) go through a shared deadline-based wait_until so their
  bodies count against the enum budget; throughput's FS detection
  compares serials case-insensitively like every other walk; a missing
  MSC read-speed line now fails the host msc_file_explorer test
  instead of passing with an empty metric.

Hardening:
- fail fast (15 s) when a driver-registry sysfs write blocks: a wedged
  device otherwise turns every subsequent battery into an unkillable
  D-state writer and silently hangs the whole run
- usb-recover skill: a VM reboot is not a reliable cure (MosChip hubs
  latch up across the PCIe reset); full host power cycle is

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HeF2gZ1M7GWkz6Av4BpKPg
2026-07-14 13:22:48 +07:00
4b1c8d16f7 docs: add build-doc tooling and a README for every example
Documentation tooling:
- Add the `build-doc` skill and `tools/build_doc.py` wrapper for local
  Sphinx builds (clean / -W / open).
- Enable Markdown (MyST) in conf.py and auto-collect
  examples/{device,host,dual}/*/README.md into a 3-level Examples nav
  (Examples > Device/Host/Dual > example), noting each page's source
  location and normalizing headings to a single H1.
- Remove the stale `.claude/commands/build-doc.md`; point the AGENTS.md
  Documentation section at the skill.

Example docs:
- Add a README.md for every device/host/dual example: what it does, USB
  interface table, notable tusb_config.h settings, generic CMake + Make
  build steps, and how to try it.
- Fold each *_freertos variant into its base README, noting the FreeRTOS
  source path and any RTOS-specific behavior.

Generated docs/examples/ output is git-ignored. Builds clean with
`sphinx-build -W`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-29 10:16:25 +07:00
09f8208f5b Add GetPartialObject to MTP example
Added support for GetPartialObject for better compatibility with Linux file explorers.
2026-05-13 22:27:57 +02:00
f9e79844ed replace TUD_ENDPOINT_ONE_DIRECTION_ONLY with CFG_TUD_ENDPOINT_ONE_DIRECTION_ONLY for improved configuration consistency across examples and core sources 2026-04-21 11:26:51 +07:00
9a03a16c81 mtp: add sending mtp response if MTP_RESP_OPERATION_NOT_SUPPORTED 2026-03-25 15:43:48 +07:00
8444c25ab6 replace board_millis() with tusb_time_millis_api() 2026-02-28 00:01:40 +07:00
237e9f21fd example/mtp: fix root parent id
Signed-off-by: HiFiPhile <admin@hifiphile.com>
2025-12-29 20:54:04 +01:00
49a8529dcf clean up cmake, remove family_get_project_name() 2025-12-19 12:33:42 +07:00
652342b57b fix more alerts found by pvs-studio 2025-11-07 23:50:16 +07:00
1f04fe7924 added .clang-format
fix more alerts
disable IAR CStat since pvs-studio check is better integrated with clion
2025-11-05 17:34:27 +07:00
d92b810df7 fix Identifiers that start with '__' or '_[A-Z]' are reserved.
fix compiling with nuc family
2025-10-28 14:14:01 +07:00
a12806a6cd fix descriptor warning when shifting zero 2025-10-28 00:17:26 +07:00
f39dcae9f1 fix several warnings 2025-10-24 13:04:49 +07:00
c48bbfab5e more make refactor 2025-10-14 17:53:55 +07:00
9bf18d080b move make.mk to hw/bsp/family_support.mk 2025-10-14 15:14:43 +07:00
044512c459 fix typo 2025-10-06 13:34:05 +07:00
3b007249cf fix iar build 2025-10-03 11:26:14 +07:00
3773d60a1e fix typos 2025-10-02 17:15:22 +07:00
981dc982ce mtp example work with highspeed device 2025-10-02 15:57:59 +07:00
4a0613cbaf fix mtp serial 2025-10-02 12:49:38 +07:00
6d32256188 HIL add timeout for opening mtp device 2025-10-02 10:43:55 +07:00
4e4e2be566 test mtp with hil 2025-10-01 16:25:38 +07:00
732d4a8c97 fix serial, try to test mtp with hil 2025-09-30 22:44:58 +07:00
ff492dc2b6 fix ci 2025-09-29 15:32:53 +07:00
4f3a5f92fa refactor mtp examples, add phase and session id to callback data 2025-09-29 15:08:12 +07:00
a09c65c4e4 make command container more consistent 2025-09-27 18:43:46 +07:00
adce3bbac0 implement serial for MTP 2025-09-27 17:33:00 +07:00
cb21ca1b0c implement control request 2025-09-27 17:08:21 +07:00
5c630ee0d0 skip mtp for cynthion_d11 2025-09-26 12:50:30 +07:00
e92262eb5c fix more ci build 2025-09-26 11:51:09 +07:00
e4f7fcf7ec fix compile warnings 2025-09-26 10:06:32 +07:00
34be38db19 clean up, wrap up bulk command supported 2025-09-25 18:58:25 +07:00
879f02f69c implement delete object 2025-09-25 18:47:43 +07:00
c9a8330081 implement send object command, able to create new file 2025-09-25 17:47:50 +07:00
f8397717ea implement MTP_OP_SEND_OBJECT_INFO, refactor fs example 2025-09-25 15:32:13 +07:00
b8126d9c4e clean up 2025-09-24 15:27:20 +07:00
6317730be6 unify callback argument. support multiple packet get object 2025-09-24 12:49:52 +07:00
3c39f60f63 refactor API 2025-09-23 15:23:16 +07:00
1ab45bc525 try to add logo png to mtp example 2025-09-23 09:34:03 +07:00
6fa5268a9c implement get object, close session 2025-09-22 13:10:22 +07:00
4c818998d4 implement get object info 2025-09-21 21:39:27 +07:00
f5a3f25456 implement get objection handles 2025-09-21 20:32:50 +07:00
d9c6dfbe2b implement get device properties describer and device properties value 2025-09-20 17:37:47 +07:00
b70804b0c4 implement get device properties value 2025-09-20 00:42:06 +07:00
e76d09bb42 rework get storageIDs and get storage info 2025-09-19 16:05:37 +07:00
f99f203c28 reworking MTP API, adding callback, getting GetDeviceInfo working 2025-09-19 12:07:47 +07:00
4ef99ecb27 fix copying readme.txt contents 2025-09-15 22:41:56 +07:00
802819d271 add all constant from MTP specs appendix, rename some e.g OPEC to OP, EVTC to EVENT 2025-09-12 17:13:52 +07:00
283b06bb54 Add MTP class device 2025-08-06 06:14:13 +02:00