tobozo / ESP32-USB-Soft-Host

An Arduino wrapper to @sdima1357's usb_soft_host esp-idf example
GNU Affero General Public License v3.0
294 stars 44 forks source link

Merging forks #31

Open tobozo opened 1 year ago

tobozo commented 1 year ago

@suarezvictor your fork is very impressive and I wish I found it earlier.

Before starting to integrate your changes, I need to establish an exhaustive board list to handle to the workflow matrix that will run the build tests. Did I miss any device?

suarezvictor commented 1 year ago

Thanks! I'd add FPGA soft-cores. Note that the Teensy (4.1) supports various clock frequencies

By the way, development continued here https://github.com/suarezvictor/litex_imgui_usb_demo/tree/main/Libs/usbhost

Among other things, I made the interface compatible with C, see https://github.com/suarezvictor/litex_imgui_usb_demo/commit/26b7972421d6fbf9417b7031b68274557da2f89a

We should continue merging from there and maybe delete this old repo

On Sat, Mar 4, 2023 at 11:31 AM tobozo @.***> wrote:

@suarezvictor https://github.com/suarezvictor your fork https://github.com/tobozo/ESP32-USB-Soft-Host/compare/main...suarezvictor:ESP32-USB-Soft-Host:main is very impressive and I wish I found it earlier.

Before starting to integrate your changes, I need to establish an exhaustive board list to handle to the workflow matrix that will run the build tests. Did I miss any device?

  • ESP32-Wroom
  • ESP32-Wrover
  • ESP32-C3
  • ESP32-S2
  • ESP32-S3
  • Teensy

— Reply to this email directly, view it on GitHub https://github.com/tobozo/ESP32-USB-Soft-Host/issues/31, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBHVWMYHAQFFD27SYIANJDW2NG4XANCNFSM6AAAAAAVPSP2OY . You are receiving this because you were mentioned.Message ID: @.***>

suarezvictor commented 1 year ago

I'd really like support for FS devices at 12mbps, and that way test a game controller Do you know of a good library that does good packet decoding of various types of hardware? I wasn't able to find even a mouse handler that supports both 8-bit protocol and 12-bit protocol (I'm currently assuming 12-bit)

tobozo commented 1 year ago

I'd really like support for FS devices at 12mbps

12mbps sound way over limit with the USB 1.0 specifications of this USB driver, unless you're talking of using tinyusb?

Do you know of a good library that does good packet decoding of various types of hardware?

The USB_Host_Shield library is a very good source of inspiration.

I wasn't able to find even a mouse handler that supports both 8-bit protocol and 12-bit protocol

Neither did I when I played with the ESP32-WUD, so I made a tinyusb descriptor for absolute mouse that uses signed 16bits values.

suarezvictor commented 1 year ago

I'm talking about pushing this exact core to 12mbps, the teensy runs at 600MHz... Great to know about absolute mouse! they may use it with touchscreens, I have one and didn't figure out how it works, they may use absolute coordinates regardind the host shield library I'll take a look

what about keeping a C interface and a C++ wrapper for those that require it? C++ in FPGA environments is a bit harder

tobozo commented 1 year ago

have you seen the this teensy library? it seems to handle mass storage, filesystem and game controllers altogether

separating C++ wrapper from C interface sounds good but I've never tried FPGA devices before, do I need additional hardware such as an oscilloscope or other special tools to play with that?

suarezvictor commented 1 year ago

yes, the teeny library may be useful I've seen a more complete one but can't remember it now btw such a library doesn't support 12-bit mouse protocol (all my mouses are like that so it may be the norm), see https://github.com/PaulStoffregen/USBHost_t36/blob/master/mouse.cpp#L63

In regards to the C interface, i think that's mandatory. you can do C++ in the FPGA but it's not as usual (indeed I implemented a complete UI with mouse/keyboard support in C++ and using C++ libraries)

go get a FPGA! you need nothing for simple to intermediate things indeed you can run simulated designs with verilator on your PC at useable speeds (i.e. run a linux console with a custom CPU done in the FPGA)

tobozo commented 1 year ago

https://github.com/cociorbaandrei/LOGITacker_nrf52832/blob/master/logitacker/logitacker_usb.h this one has a 12bit report descriptor.

suarezvictor commented 1 year ago

a good driver should detect the protocol, like windows and Linux do I've seen no embedded development with such a capability

tobozo commented 1 year ago

it's not the driver's job to negociate a story between USB devices, windows and linux/mac use different strategies anyway.

For example a problem with libraries derived from tinyUSB is that their descriptor/reports are macro based, which makes it nearly impossible to have variable ID or device order, thus rendering any mixed-device implementation limited to some situations only (e.g. can't add hybrid absolute mouse/keyboard as device number 1 to a windows laptop with an existing touchpad if a second mouse already exists on the bus).

Otherwise there's a way to identify the OS if you manage to capture some low level reports, then you can apply some different magic to your report descriptors depending on the situation.

suarezvictor commented 1 year ago

are we talking about doing a USB host right? so the host hast to adapt to the device capabilities

suarezvictor commented 1 year ago

we need to split the development in a module that communicates with USB devices (packet exchanging), an other that does the decoding and interpretation of packets, the latest one should be really general... just one implementation for all platforms

tobozo commented 1 year ago

Tried for a dozen hours but I can't get my head around those tinyusb changes, whatever I try doesn't compile with ESP32. I guess it's enough research for a sunday :-)