im-tomu / valentyusb

FPGA USB stack written in LiteX
BSD 3-Clause "New" or "Revised" License
125 stars 25 forks source link

Is it possible to use this core to connect a USB-Camera to an FPGA? #22

Closed ratzupaltuff closed 1 year ago

ratzupaltuff commented 1 year ago

Hi,

I am starting to learn more about FPGAs, litex and this project. I can't figure out if this core supports USB host mode for video-usb-devices.

My plan would be to connect a uvcvideo camera to the FPGA and connect it to the RISC-V cpu on the FPGA. Is it possible to realize something like that with this project or should I choose a dedicated hardware chip to do the USB-Host heavy lifting which exposes a simpler interface to the FPGA?

xobs commented 1 year ago

Thank you for the interest!

There are two reasons why this would not be an appropriate project for that. First, cameras use isochronous mode, which this library doesn't support.

But more importantly, this only provides device mode.

You might try Luna (https://luna.readthedocs.io/en/latest/features.html#support-for-host-mode) which seems to have support for host mode. I'm not sure about isochronous mode though.

ratzupaltuff commented 1 year ago

Thanks for your quick reply! As far as I understand the section you linked, Luna currently does not support host mode. But I might look into the latest commits, maybe just the documentation is outdated. Thanks a lot!

bunnie commented 1 year ago

In case Luna doesn't work out, SpinalHDL has an OHCI controller: https://spinalhdl.github.io/SpinalDoc-RTD/master/SpinalHDL/Libraries/Com/usb_ohci.html

It can be integrated into LiteX with some elbow grease, but you have to put a wrapper around it. Here's an example of how I did it for their device core:

https://github.com/betrusted-io/gateware/tree/main/gateware/usb

It's an adventure through the undocumented boundary waters between Spinal and Litex ecosystems, but it can be done.