Repository navigation
v0.11.0b2
·
41 commits
to master
since this release
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-commitand a dedicatedty.ymlCI workflow. usb-stubs/PEP 561 stub package forpyusb, filling in previously-missing submodules (usb.legacy,usb._lookup,usb.backend,usb._objfinalizer, etc.) so the codebase type-checks cleanly end to end.pre-commitconfiguration (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-levelBACKLOG.md, now with every item marked
resolved or explicitly documented as an intentional, reviewed difference from upstream).
Changed
- Renamed CI workflow
python-package.ymltopytest.yml. - Bumped CI/build tooling and dependencies (
actions/checkout6→7,ruff,dependabotconfig). pydfuutil-suffix/pydfuutil-prefixnow parse the target file withpathlib.Pathinstead ofargparse.FileType('r+b').- Removed the unused, unreferenced
_old/__main__.pylegacy 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/ruffthat 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/--downloadwas completely non-functional (a dead
elifbranch 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'sparse_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 requiredorhad been
written asand; a swappedIFF.DFU/IFF.ALTflag check, an inverted pipe-error fallback,
a droppeddfu_root.detach()call before-R/--reset, non-O_EXCLupload-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-transferTIMEOUTdefaulted to-1(wrapping to
an effectively infinite libusb timeout) sincedfu.init()was never called anywhere in the
CLI;StatusRetVal.from_bytes()validatedbStateagainst the wrong response byte;
QUIRK_POLLTIMEOUTis now applied centrally insideDfuIf.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-sizewere truncated to a single transfer chunk instead of running
until the device signals completion; added the missingDFU_MANIFEST_WAIT_RESEThandling
(explicit USB reset for devices withManifestationTolerant=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 invertedwill-resethandling.parse_options()didn't
recognize the documented hyphenated option syntax (mass-erase,will-reset) norfastat
- CLI entry point (