JustPretender / fastboot

A simple library that implements Android Fastboot protocol.
MIT License
7 stars 5 forks source link

usbio: migrate to `nusb` instead of the `libusb-rs` #10

Open XVilka opened 5 months ago

XVilka commented 5 months ago

Currently, libusb-rs is unmaintained. What's worse, latest Rust (1.79) isn't able to compile it anymore because of the cargo changes:

Two most promising alternatives are:

orangecms commented 3 months ago

I'm using rusb in another project: https://github.com/orangecms/sg_boot

You're suggesting nusb in the title, could you elaborate a bit what your opinion is on each? :)

XVilka commented 3 months ago

Both are fine, it's just nusb is pure Rust, not a binding to anything like rusb

orangecms commented 3 months ago

I gave it a shot: https://github.com/platform-system-interface/fastboot/tree/nusb

The getvar example sorta works, but my target device hangs after it. I do get the expected reponse though.

Any idea?

I essentially rewrote the usbio crate based on https://github.com/probe-rs/probe-rs/blob/bba1bb553cc8b80902f498b7e7be4ba085197dcf/probe-rs/src/probe/usb_util.rs

orangecms commented 3 months ago

I figured it out:

Per https://android.googlesource.com/platform/system/core/+/master/fastboot/README.md the read buffer must be max. 512 bytes for super speed, but the current code has FB_MAX_REPLY_LEN set to 64 - changing that to 512 lets me do multiple runs. :)

orangecms commented 3 months ago

I've cleaned it up and pushed everything to main.

https://github.com/platform-system-interface/fastboot

Should we move there to continue discussions? Feel free to open issues, I just enabled it. :)