ESP32-S3 as USB Host for Ethernet via usb-adapter

iParcelBox
Posts: 46
Joined: Sun Oct 27, 2019 3:12 pm

ESP32-S3 as USB Host for Ethernet via usb-adapter

Postby iParcelBox » Mon Feb 10, 2025 9:16 pm

I'm wanting to provide wired (i.e. ethernet) network access for an esp32s3 device via the available USB pins 19/20 using a POE Ethernet to USB adapter. I'm thinking I should be able to setup the ESP32 as a USB Host, and then when the Ethernet cable is connected via the POE to Usb adapter, get an IP address from the network's DHCP server and route network data via the ethernet cable (so no need to use WiFi).

I've found a few examples of setting up USB Host for e.g. MSC devices, but I can't find anything relevant for connecting the USB Host to a network device (NCM) or how to then get the ESP32 to use that for networking.

Is anybody able to give me some advice on how to achieve this, point me in the direction of any suitable examples?

ahsrabrifat
Posts: 58
Joined: Sat Jan 18, 2025 2:31 pm

Re: ESP32-S3 as USB Host for Ethernet via usb-adapter

Postby ahsrabrifat » Tue Feb 11, 2025 5:46 am

I do not think it is practically feasible. The ESP32-S3 does not have built-in support for USB Ethernet (NCM/ECM). I think one option can be to use a Raspberry Pi as a USB-to-Ethernet bridge. The ESP32-S3 will communicate with the bridge over a standard interface like SPI, UART, or I2C.

iParcelBox
Posts: 46
Joined: Sun Oct 27, 2019 3:12 pm

Re: ESP32-S3 as USB Host for Ethernet via usb-adapter

Postby iParcelBox » Tue Feb 11, 2025 8:28 am

TinyUSB implemented in esp32 does now seem to have NCM for USB capabilities. I found this example that allows routing of WiFi from the esp device over usb via NCM. https://github.com/espressif/esp-idf/tr ... e/tusb_ncm

I’m wanting to do similar but the other way around, using the Ethernet / usb cable as the networking source for the esp32s3 for when customers don’t have wifi available.

iParcelBox
Posts: 46
Joined: Sun Oct 27, 2019 3:12 pm

Re: ESP32-S3 as USB Host for Ethernet via usb-adapter

Postby iParcelBox » Tue Feb 11, 2025 10:31 am

After some further research, I think what' I'm attempting to achieve is very similar to this example:
https://github.com/espressif/esp-protoc ... pos_client

However, rather than connecting a USB modem to the ESP32S3 D+ and D- pins, I'm connecting an ethernet to USB dongle - this is the one I'm using for testing purposes:

https://www.amazon.co.uk/gp/product/B09 ... UTF8&psc=1

If I could somehow reconfigure the existing pppos_client example so that it allows hot-swapping of a usb-to-ethernet dongle as an additional option to connecting a usb modem, I think it would give me exactly what I need.

I'm not quite sure where to start with this thought, so if anyone could give me some suggestions I'd be most grateful!

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

Re: ESP32-S3 as USB Host for Ethernet via usb-adapter

Postby chegewara » Tue Feb 11, 2025 4:28 pm

Hi,
as far as i know you wont find USB host code for USB-ETH dongle, at least not from espressif.
You could try to make one, but like with different LCD IC it is required to write drivers for different realtek chips (or other ICs).
USB NCM is standard, but initialization is different for different chip. You can see it when you check linux drivers.

iParcelBox
Posts: 46
Joined: Sun Oct 27, 2019 3:12 pm

Re: ESP32-S3 as USB Host for Ethernet via usb-adapter

Postby iParcelBox » Tue Feb 11, 2025 5:53 pm

Ah OK that's a shame. From what I'd seen from the tech specs of a few USB to Ethernet chipsets they mostly came with driverless CDC-NCM these days, so I'd assumed that meant I'd be able to communicate with it using tinyUSB and the existing capabilities.

I'll try and have a play, see if I get get anywhere with creating my own implementation.

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

Re: ESP32-S3 as USB Host for Ethernet via usb-adapter

Postby chegewara » Thu Feb 13, 2025 12:47 pm

I may be wrong, since we have sta2eth example in esp-idf, which is working perfectly fine on linux and there is no driver for espressif for sure on linux.

iParcelBox
Posts: 46
Joined: Sun Oct 27, 2019 3:12 pm

Re: ESP32-S3 as USB Host for Ethernet via usb-adapter

Postby iParcelBox » Thu Feb 13, 2025 1:22 pm

When I connected the usb-ethernet dongle to a Mac and check the USB Hardware settings, I see it reported as follows:

Code: Select all

USB 10/100 LAN:

  Product ID:	0x8152
  Vendor ID:	0x0bda  (Realtek Semiconductor Corp.)
  Version:	20.00
  Serial Number:	00E04C3603D6
  Speed:	Up to 480 Mb/s
  Manufacturer:	Realtek
  Location ID:	0x14200000 / 1
  Current Available (mA):	500
  Current Required (mA):	100
  Extra Operating Current (mA):	0
I guess that means I'd need the ESP32 USB Host to be able to create a device stack that is compatible with whatever specific Realtek chip is used? It does look as though the RTL8152 is a pretty common usb to ethernet chip, e.g. https://github.com/wget/realtek-r8152-linux

If anyone is able to help me make this work with the USB Host stack I'd really appreciate it - I do think it would be super-cool to provide ethernet access to an ESP32s3 (including POE) almost out-of the box using a £30 dongle - opens up a whole world of additional possibilities on the back of the USB interface.

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

Re: ESP32-S3 as USB Host for Ethernet via usb-adapter

Postby ESP_Sprite » Fri Feb 14, 2025 12:03 am

Note that likely very few people are interested in this as the USB on the S3 only is full-speed, meaning you'd get a speed of like 10MBit/s at max, which is a far cry from the 1GBit/s that is the default nowadays. The P4 could go up to 100MBit, so it may make more sense there, but that chip is not in mass manufacturing yet.

iParcelBox
Posts: 46
Joined: Sun Oct 27, 2019 3:12 pm

Re: ESP32-S3 as USB Host for Ethernet via usb-adapter

Postby iParcelBox » Fri Feb 14, 2025 9:29 am

I totally understand the "need for speed", but if the esp32s3 is being used predominantly as an IoT device (e.g. MQTT or similar), 10MBit/s is more than enough bandwidth, and would provide a very convenient alternative to WiFi (particularly when used in conjunction with PoE).

Am I right that to get this to work, initially I'd need to create a custom Device Class for a USB Host running on the esp32s3?

Who is online

Users browsing this forum: No registered users and 57 guests