Skip to content

v0.11.0b2

Choose a tag to compare

@github-actions github-actions released this 10 Jul 21:07
· 41 commits to master since this release
4491a5d

Added

  • CLI long-option aliases matching the C reference: --configuration, --interface,
    --altsetting (alongside the existing --cfg, --intf, --alt).
  • Full <vid>:<pid>[,<vid_dfu>:<pid_dfu>] dual-spec and */- wildcard support for -d/--device.
  • Static type checking with ty, wired into pre-commit and a dedicated ty.yml CI workflow.
  • usb-stubs/ PEP 561 stub package for pyusb, filling in previously-missing submodules (usb.legacy, usb._lookup, usb.backend, usb._objfinalizer, etc.) so the codebase type-checks cleanly end to end.
  • pre-commit configuration (uv sync, ty check, ruff check --fix, ruff format, pytest).
  • docs/SYNC_WITH_C_UPSTREAM_BACKLOG.md — the itemized
    upstream-parity audit (moved from the former top-level BACKLOG.md, now with every item marked
    resolved or explicitly documented as an intentional, reviewed difference from upstream).

Changed

  • Renamed CI workflow python-package.yml to pytest.yml.
  • Bumped CI/build tooling and dependencies (actions/checkout 6→7, ruff, dependabot config).
  • pydfuutil-suffix/pydfuutil-prefix now parse the target file with pathlib.Path instead of argparse.FileType('r+b').
  • Removed the unused, unreferenced _old/__main__.py legacy module (~1000 lines of dead code from an earlier implementation).

Fixed

  • A full function-by-function audit against the upstream C dfu-util (master) turned up and
    fixed ~40 behavioral divergences introduced during the port — logic/semantics bugs invisible to
    ty/ruff that only a behavioral comparison against the reference implementation catches. Full
    itemized list, C references, and verification notes:
    docs/SYNC_WITH_C_UPSTREAM_BACKLOG.md. Highlights:
    • CLI entry point (__main__.py): -D/--download was completely non-functional (a dead
      elif branch on an already-handled condition meant it could never fire); -d/--device
      vendor:product filtering was parsed but never applied to device matching (now supports the
      full <vid>:<pid>[,<vid_dfu>:<pid_dfu>] syntax plus */- wildcards, matching the C
      reference's parse_vendprod/parse_match_value); an inverted runtime-vs-DFU-mode branch
      condition swapped the "claim a runtime device" and "already in DFU mode" code paths on every
      probe; DfuSe downloads almost never routed to the DfuSe path because a required or had been
      written as and; a swapped IFF.DFU/IFF.ALT flag check, an inverted pipe-error fallback,
      a dropped dfu_root.detach() call before -R/--reset, non-O_EXCL upload-file writes,
      and a swallowed process exit code were also fixed.
    • Core protocol (dfu.py, portable.py): milli_sleep() truncated every sub-second poll
      delay to a no-op busy loop; the DFU control-transfer TIMEOUT defaulted to -1 (wrapping to
      an effectively infinite libusb timeout) since dfu.init() was never called anywhere in the
      CLI; StatusRetVal.from_bytes() validated bState against the wrong response byte;
      QUIRK_POLLTIMEOUT is now applied centrally inside DfuIf.get_status() (matching where the C
      reference applies it) instead of being re-implemented ad hoc, and inconsistently, at
      individual call sites.
    • Plain DFU download/upload (dfu_load.py): do_download() was non-functional end to end
      (it tried to read firmware from a file handle that is only ever opened in write-only mode for
      the upload path); no DFU transaction counter was tracked across download chunks; uploads with
      no explicit -Z/--upload-size were truncated to a single transfer chunk instead of running
      until the device signals completion; added the missing DFU_MANIFEST_WAIT_RESET handling
      (explicit USB reset for devices with ManifestationTolerant=0).
    • DfuSe protocol (dfuse.py): most download paths were non-functional end to end — a stale
      module-level memory-layout reference instead of the per-interface one, a call site missing a
      required parameter, an inverted/wrong polling-loop exit condition risking flash corruption, an
      unbounded data slice overrunning the intended chunk boundary, a mass-erase request that sent
      the wrong DfuSe command byte, and inverted will-reset handling. parse_options() didn't
      recognize the documented hyphenated option syntax (mass-erase, will-reset) nor fast at