ftdi-rs / libftd2xx

Rust safe wrappers for the libftd2xx drivers
MIT License
32 stars 15 forks source link

Unloading usbserial module on Linux #51

Closed jwillikers closed 2 years ago

jwillikers commented 2 years ago

Is it necessary to unload the usbserial module on Linux? It's kinda built-in to my kernel on Fedora.

$ sudo rmmod usbserial
rmmod: ERROR: Module usbserial is builtin.

I'm able to unload ftdi_sio.

newAM commented 2 years ago

I never had to unload usbserial on NixOS and Ubuntu, only ftdi_sio.

jwillikers commented 2 years ago

Shouldn't running the list example not be empty for my connected FT232H, though?

$ cargo run --example list --features static
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
     Running `target/debug/examples/list`
device: DeviceInfo { port_open: false, speed: Some(HighSpeed), device_type: FTAM, vendor_id: 0x0000, product_id: 0x0000, serial_number: , description:  }

I'm trying to run something using the ftdi-embedded-hal crate and it appears to be running but I'm wandering if it isn't actually connecting to anything.

newAM commented 2 years ago

The FTDI devices get the USB strings & VID/PID from the onboard EEPROM, I have seen that occur before with an invalid EEPROM when Adafruit shipped me a faulty FT232H.

You can change the EEPROM with the APIs in this crate, but I found that pyftdi's CLI tool for updating the EEPROM is much more user friendly.

jwillikers commented 2 years ago

Thanks, that was helpful. The manufacturer, serial number, and another field were all corrupted. Took me a while to figure out how to write to the EEPROM after erasing everything including the VID/PID.

Before doing that, though, why would driving the NeoPixels with Adafruit's NeoPixel SPI library, which uses pyftdi, not have any problems? It worked when the EEPROM was corrupted. Just curious, especially since the corrupt EEPROM issue seems to cause things to fail silently. Of course, I might be doing something else wrong.

newAM commented 2 years ago

Before doing that, though, why would driving the NeoPixels with Adafruit's NeoPixel SPI library, which uses pyftdi, not have any problems?

The libftd2xx driver is made for Windows unfortunately, and Linux support was shoehorned in afterwards. The result of this is a Windows-like experience on Linux.

pyftdi can make significantly better decisions about device detection because they are using libusb directly without any considerations for Windows. The open source driver, libftdi, would probably work as well, though the embedded-hal implementations for that driver are a work-in-progress: https://github.com/ftdi-rs/ftdi-embedded-hal/pull/2

Outside of this project I generally try to avoid libftd2xx on Linux because the open source ones are better.

jwillikers commented 2 years ago

That's awesome! Looking forward to it.

newAM commented 2 years ago

Closing this issue now as the first release of ftdi-embedded-hal has been made, feel free to reopen if that doesn't resolve it!