USB/IP on ESP32-S2

hibenji
Posts: 3
Joined: Sat Mar 26, 2022 11:18 am

USB/IP on ESP32-S2

Postby hibenji » Sat Mar 26, 2022 11:21 am

I recently bought a Adafruit QT Py ESP32-S2, i was wondering if it possible to make it act as a host for USB and let my Computer be the client to recieve any USB data?

Any help or information is appreciated.

ESP_Sprite
Posts: 9727
Joined: Thu Nov 26, 2015 4:08 am

Re: USB/IP on ESP32-S2

Postby ESP_Sprite » Sat Mar 26, 2022 12:10 pm

That doesn't make sense... the ESP32-S2 can be a host alright, but unless you have a very specific USB setup, computers generally cannot be a device. What specifically are you planning to do that you would need this functionality for?

hibenji
Posts: 3
Joined: Sat Mar 26, 2022 11:18 am

Re: USB/IP on ESP32-S2

Postby hibenji » Sat Mar 26, 2022 2:16 pm

Hey, thanks for your response, i am not sure if this is possible, but it would be cool.
I am looking to use the ESP32 as a host for a controller to make a non wireless controller, wireless so i can connect to it from my PC.

Similar like virtualhere, but ofc there is no virtualhere for ESP32, so i am looking for an alternative.

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: USB/IP on ESP32-S2

Postby chegewara » Sat Mar 26, 2022 8:32 pm

ESP_Sprite wrote: That doesn't make sense... the ESP32-S2 can be a host alright, but unless you have a very specific USB setup, computers generally cannot be a device. What specifically are you planning to do that you would need this functionality for?
That make a lot of sense. It allows to connect USB device to esp32 S2/S3 and pass all USB traffic between PC and that device using TCP sockets. With USB/IP PC is thinking that device is connected to local port when in real it is connected to esp32 and with good design it may be accesses over WAN, just like virtualhere.
Another use case may be intercept and altering HID packets or making printers work wireless etc, all without writing drivers on esp32, because all drivers are used on PC.
Of course it not very popular protocol, because only linux has some good support, windows not so much and i dont know about macOS.
http://usbip.sourceforge.net/
hibenji wrote: Hey, thanks for your response, i am not sure if this is possible, but it would be cool.
Yes, it is totally possible. I do have some early code, which is working with CDC, CP210x, HID etc, but there is some limitation thou (or just my code is not very good).
For example CP210X/CDC based devkit cant be flashed, because device is disconnected for very short time. Maybe there should be implemented some mechanism that would reconnect device, but i think its not possible. I didnt do stress test yet, but with simple serial com it works for few hours without problem. Another problem i have so far is that only full speed device works. So, i have vireless keyboard and mouse with USB dongle, and this works, but wired keyboard is not working yet. I have only USB3 pendrive right now, and i cant make it works, because my linux MSC driver is trying to reset device after getting all descriptors and cant assign address to it.
I have to say i had a lot of problems to solve to get it work even if it seems to be easy protocol to implement.

Im not saying i will do it any time soon, but i would like to do a simple device that could intercept USB packets and display on simple website hosted on the same esp32, or maybe even on small server with use of UDP or WS, and make esp32 hardware USB analyzer.


esp32 running simple app, connected to another esp32 S3 running USB/IP
Screenshot from 2022-03-26 21-35-52.png
Screenshot from 2022-03-26 21-35-52.png (113.92 KiB) Viewed 14384 times

PS i just did quick test: esp32 S2, with

Code: Select all

void loop() {
	delay(10);
	Serial.println("test");
}
And here are results:

Code: Select all

wired connection to PC:
22:12:07.357 -> test
22:12:07.357 -> test
22:12:07.357 -> test
22:12:07.390 -> test
22:12:07.390 -> test
22:12:07.390 -> test
22:12:07.423 -> test
22:12:07.423 -> test
22:12:07.423 -> test
22:12:07.423 -> test

wireless connection with USB/IP:
22:13:24.912 -> test
22:13:24.945 -> test
22:13:24.945 -> test
22:13:24.945 -> test
22:13:24.945 -> test
22:13:24.945 -> test
22:13:24.978 -> test
22:13:24.978 -> test

hibenji
Posts: 3
Joined: Sat Mar 26, 2022 11:18 am

Re: USB/IP on ESP32-S2

Postby hibenji » Sun Mar 27, 2022 12:08 am

Hey, that seems awesome, thanks, can you share some more code with me or how you did it?
I havent used USB/IP or ESP32 much so i dont really know too much there.

maybe cotact me on discord if possible: Benji#1652

puterboy
Posts: 4
Joined: Thu Aug 18, 2022 3:57 am

Re: USB/IP on ESP32-S2

Postby puterboy » Thu Aug 25, 2022 4:03 pm

Would also love to play with the code if you are willing to share...
I am seeking to create a VirtualHere-like functionality using the esp32 to host a remote USB connection for a Windows or Linux client (which is what VirtualHere does in the world of Windows, Linux, and Android but not esp32)

My use case is that my oscilloscope and my function generator are each viewable and controllable via USB.
However, IMO, the whole benefit is when the test instruments are remote and one can monitor and control them from a distance longer than a USB cord.

(other similar use cases would be to convert USB keyboards, game controllers, etc. to wireless via WiFi)

Until now, I have been using VirtualHere with a RaspberryPi Zero as the USB server (the one that connects to the remote USB device) but that is not ideal because Raspberry PIs are:
1. More expensive
2. Currently in short supply
3. Larger
4. Not made to be turned on/off abruptly
5. Require more power
6. Are overkill
etc.

Unfortunately, VirtualHere and other similar apps are not available for esp32.
But it seems like the esp32-S2 with its built-in full USB stack should be powerful enough to perform this function.

Unfortunately, I lack the knowledge of USB to make this work from scratch, so looking for some guidance and ideally some code that I can modify and extend.

Thanks!

puterboy
Posts: 4
Joined: Thu Aug 18, 2022 3:57 am

Re: USB/IP on ESP32-S2

Postby puterboy » Sun Aug 28, 2022 2:45 am

Agree this is awesome would be great if you could share code so that we can "play" with it :)

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: USB/IP on ESP32-S2

Postby chegewara » Mon Aug 29, 2022 2:23 am

This is PoC code, which works with some simple USB devices, like serial etc:
https://github.com/chegewara/esp32-usbip-poc

Sly#7481
Posts: 1
Joined: Sun Mar 03, 2024 2:47 pm

Re: USB/IP on ESP32-S2

Postby Sly#7481 » Sun Mar 03, 2024 2:49 pm

Hi guys !
Did manage to get something functionnal since the time ?
I would be very interested !

Thanks

Who is online

Users browsing this forum: Google [Bot], jsmith56x and 74 guests