Skip to content

Let an ISPDevice be driven over WebUSB - #155

Closed
carlossless wants to merge 1 commit into
feat/runtime-backend-fallbackfrom
feat/webusb
Closed

Let an ISPDevice be driven over WebUSB#155
carlossless wants to merge 1 commit into
feat/runtime-backend-fallbackfrom
feat/webusb

Conversation

@carlossless

Copy link
Copy Markdown
Owner

Stacked on #152. Needs carlossless/hidra#9.

A device whose interface declares a vendor-specific class never appears in WebHID — Blink only surfaces interfaces the host recognises as HID — but it is reachable over WebUSB and still speaks the ISP protocol. ISPDevice now holds an ISPHandle, which is either a hidra::HidDevice or, on wasm with the new webusb feature, a hidra::webusb::HidDevice.

The protocol code is unchanged: ISPHandle dispatches the only two operations ISPDevice needs, send_feature_report and get_feature_report.

Compatibility

ISPDevice::new takes impl Into<ISPHandle> for the command handle, so existing callers pass a HidDevice unchanged. The Windows two-handle path converts explicitly — that branch is #[cfg(target_os = "windows")], so a Linux build would not have caught it; verified with cargo check --target x86_64-pc-windows-msvc.

The webusb feature is off by default and forwards to hidra/nusb; nothing changes for the CLI or the existing WebHID path.

Testing

fmt, cargo test --workspace --lib --bins, the wasm build with and without webusb, and cargo check for x86_64-pc-windows-msvc, all pass locally.

A device whose interface declares a vendor-specific class never appears
in WebHID, but is reachable over WebUSB and still speaks the ISP
protocol. ISPDevice now holds an ISPHandle, which is either.

The command handle takes an `impl Into<ISPHandle>` so existing callers
are unchanged; the Windows two-handle path converts explicitly.
@carlossless

Copy link
Copy Markdown
Owner Author

Closing along with carlossless/smk-web#3 and carlossless/hidra#9.

WebUSB cannot claim the Sinowealth ISP bootloaders: they declare bInterfaceClass 0x03, which Blink blocks. Verified against a real device (258a:0036) in Chrome — it enumerates over WebUSB, but the claim is refused with "blocked because it implements a protected interface class".

So ISPHandle has no second variant worth carrying, and ISPDevice can keep holding a HidDevice directly.

Worth keeping from this: the bootloaders declare bNumEndpoints 0, so every report goes over the control pipe. That is a real property of the devices this crate drives, and the native nusb backend's control-only path is currently untested (the linux-nusb e2e uses g_hid, which always has an endpoint).

@carlossless carlossless closed this Sep 3, 2026
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