ethernet over USB

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

ethernet over USB

Postby chegewara » Wed Oct 02, 2024 8:10 am

Hello community,
recently Ive found some cool protocol
https://en.wikipedia.org/wiki/Ethernet_over_USB

and I think it may be useful in many situations, for example when we dont want or cant to expand esp32-p4 with radio module.
In this case we still can implement http server in our code and access it from host PC over USB. This lets us to have some web UI to control device, change settings, or even to OTA it. Its easy to implement it on any USB featured SoC, which is S2/S3/P4.
Some quick performance test shows it is possible to achieve over 5mbit/s on S3 and over 32mbit/s on P4, which is not that bad.

With this component we can use websockets and should be possible to run ftp server, telnet server and some other TCP/IP and UDP protocols we can run on esp32 with wifi.

After adding this captive portal component we can have really nice apps
https://github.com/espressif/esp-idf/tr ... ive_portal

Here we can find simplest example
https://github.com/esp32-open-source/usb-netif-example

and my first component
https://components.espressif.com/compon ... /usb-netif

Have a fun playing with it

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

Re: ethernet over USB

Postby chegewara » Fri Oct 04, 2024 7:10 am

Hi,
in my previous post it is very simple example, but today i would like to show some more "real life" example.
In general i wanted to make some firmware which is flashed on factory app with option to OTA tools-like application and rollback enabled, so factory app run each time esp32 restart.
This way i can have prepared dozens of tools binaries and only one device which can make use of it.
Currently its only possible to OTA from web UI by sending binary to esp32, but the real goodies is when all tools-like binaries are store on attached sd card and from web UI we could select which one currently we want to flash and use.

By design it is using ethernet over USB, so it is working only on USB capable SoCs like S2, S3 or P4. You may ask why to make such design? Well there is few ideas behind this:
- the main goal was to provide some way to OTA P4 which does not have wifi or ble; yes, i know we can easily connect P4 ev board over wifi or ethernet, but i was thinking about standalone P4
- another option is to use ble-mesh or just ble on S3 (maybe on P4 too with additional SoC) with web UI, so we dont have to worry about ble + wifi coex
- it is somehow "real life" example because i am using extended version of it in my work for various purposes
- it may be good starting point to display video from cam on P4, if you know how to stream video to web page


https://github.com/esp32-p4-excercises/ ... ed-example

Have a fun

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

Re: ethernet over USB

Postby chegewara » Sun Oct 06, 2024 11:41 am

In other topic i reported performance of ethernet over USB, which is over 34mbit/s with iperf.
I wanted to test speed with real life app, so i added few html and js files with very simple speedtest code and here we have results.
To clarify, this is USB speed from PC to esp32-p4, not the internet speed.

Read file from fat partition (with some trick, to increase size):
Screenshot from 2024-10-06 13-31-33.png
Screenshot from 2024-10-06 13-31-33.png (46.72 KiB) Viewed 2235 times

The same test, but instead of reading file i created buffer in memory:
Screenshot from 2024-10-06 13-23-43.png
Screenshot from 2024-10-06 13-23-43.png (46.94 KiB) Viewed 2235 times

DrMickeyLauer
Posts: 168
Joined: Sun May 22, 2022 2:42 pm

Re: ethernet over USB

Postby DrMickeyLauer » Mon Oct 07, 2024 11:48 am

That's not bad, thanks for the results and your work!

Who is online

Users browsing this forum: No registered users and 19 guests