Skip to content

Fix Windows USB timeouts and Sahara HELLO handling - #841

Open
Xblur wants to merge 2 commits into
bkerler:masterfrom
Xblur:fix/windows-usb-timeouts
Open

Xblur wants to merge 2 commits into
bkerler:masterfrom
Xblur:fix/windows-usb-timeouts

Conversation

@Xblur

@Xblur Xblur commented Nov 14, 2026 •

Copy link
Copy Markdown

On Windows (and with some USB backends), Sahara connect used timeout=1. Under pyusb that is 1 ms, so the HELLO often missed, then XML/HDLC probes confused the device. USB reads also treated the timeout value in milliseconds as a retry counter (timeout == 10), so callers that pass timeout=1000 could hang forever on "Device detected".

Changes

  • Sahara connect: use 1000 ms read timeouts; treat END_TRANSFER as an error with a clear reboot/re-enter-EDL message (and handle HELLO that arrives after the firehose probe).
  • usblib: count USB timeout retries separately from the timeout value; accept both libusb1 (timed out) and libusb0-win32 (timeout error) strings.
  • Only call libusb_set_option on libusb1 backends, and do not clear the backend if that fails.

Windows backend selection is left as auto (backend = None). Related but different: #802 forces the bundled libusb-1.0.dll via libusb1.

Tested

  • Windows 10/11, Python 3.11, pyusb with libusb-win32 (Zadig)
  • Huawei MediaPad T3 10 (Qualcomm 9008 / EDL)
  • Sahara HELLO detected without hang; END_TRANSFER exits with a clear error instead of continuing as HELLO

Use millisecond-scale Sahara read timeouts, stop treating the timeout value as a retry budget, recognize libusb0 timeout strings, and fail cleanly on END_TRANSFER instead of continuing as HELLO.
Copilot AI balanced review requested due to automatic review settings November 14, 2026 22:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The timeout change can block serial connections for 1,000 seconds, and the unreachable END_TRANSFER branch prevents the recovery reset from being sent.

2 open issues
What changed in this PR

This PR aims to improve EDL connection reliability on Windows by correcting USB timeout handling and distinguishing Sahara END_TRANSFER responses from successful HELLO handshakes.

Changes:

  • Increase Sahara read timeouts and recognize late HELLO responses.
  • Bound USB timeout retries, recognize both backend timeout messages, and guard libusb1-specific setup.
  • Report END_TRANSFER as an error and add a reset-and-exit handler.
File Description
edlclient/​Library/​sahara.py Adjust connection timeouts and handle HELLO and END_TRANSFER responses.
edlclient/​Library/​Connection/​usblib.py Bound timeout retries and make backend handling safer.
edl.py Add END_TRANSFER recovery and error-exit handling.

Review effort: Balanced

Comment thread edl.py Resolved
Comment thread edlclient/Library/sahara.py Resolved
Handle END_TRANSFER by cmd before mode dispatch so cmd_reset runs, and use 1s on serial vs 1000ms on USB for Sahara HELLO reads.
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.

2 participants