Skip to content

Fix Windows serial hangs and WinError 31 crashes#275

Open
af-t wants to merge 2 commits into
bkerler:mainfrom
af-t:main
Open

Fix Windows serial hangs and WinError 31 crashes#275
af-t wants to merge 2 commits into
bkerler:mainfrom
af-t:main

Conversation

@af-t

@af-t af-t commented Jul 8, 2026

Copy link
Copy Markdown
  • Skip slow comports() scan when an explicit port is given, since the Preloader only stays alive ~0.3s
  • Set write_timeout so a stuck write can't block forever uninterruptibly, and chunk usbwrite() at the packet size so timeout headroom is real per chunk; abort instead of retrying from a stale position if a write genuinely times out, since pyserial can't say how many bytes already went out
  • Bound flush() instead of trusting the driver's unreliable out_waiting/in_waiting reporting, which otherwise hangs indefinitely
  • Read DAXML frames staged with explicit lengths instead of one guessed read, fixing both premature "Wrong length" and framing corruption ("Wrong magic"); give the sub-reads real slack against driver jitter
  • Only reassign device.timeout when it actually changes, and never reassign it in the resplen=None path, to avoid WinError 31 right after a write burst; lower the constructor default so that path's wait bound is real instead of relying on a stale ambient value
  • Propagate serialportname onto Port so reconnects keep the same port
  • Fix mtk.py argparse: global options (--vid, --stock, etc.) given before the subcommand were silently reset to their defaults, since every subcommand parser redeclares them via parents=[base] and argparse's subparser dispatch overwrites the parent namespace with the subparser's own defaults

af-t added 2 commits July 8, 2026 23:52
- Skip slow comports() scan when an explicit port is given, since the
  Preloader only stays alive ~0.3s
- Set write_timeout so a stuck write can't block forever uninterruptibly,
  and chunk usbwrite() at the packet size so timeout headroom is real
  per chunk; abort instead of retrying from a stale position if a write
  genuinely times out, since pyserial can't say how many bytes already
  went out
- Bound flush() instead of trusting the driver's unreliable
  out_waiting/in_waiting reporting, which otherwise hangs indefinitely
- Read DAXML frames staged with explicit lengths instead of one guessed
  read, fixing both premature "Wrong length" and framing corruption
  ("Wrong magic"); give the sub-reads real slack against driver jitter
- Only reassign device.timeout when it actually changes, and never
  reassign it in the resplen=None path, to avoid WinError 31 right
  after a write burst; lower the constructor default so that path's
  wait bound is real instead of relying on a stale ambient value
- Propagate serialportname onto Port so reconnects keep the same port
- Fix mtk.py argparse: global options (--vid, --stock, etc.) given
  before the subcommand were silently reset to their defaults, since
  every subcommand parser redeclares them via parents=[base] and
  argparse's subparser dispatch overwrites the parent namespace with
  the subparser's own defaults
- Extract shared XFlash/XmlFlash/Legacy logic into extension_common.py mixin
- Consolidate register-clear, partition-lookup, and handshake-retry helpers
- Unify exploit payload() via PTYPE class attribute across 4 classes
- Share ARM instruction decoders in ArchTools, drop dead usblib override
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.

1 participant