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

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

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

Postby iParcelBox » Sat Mar 08, 2025 12:00 am

For anyone else looking to do similar, I now have a version of cdc-ecm-host working for RTL8152 devices:

https://github.com/gadget-man/cdc-acm-host

It works for a basic ping, still need to test for other network events and it needs some tidying up, so PRs welcome!

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

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

Postby chegewara » Sat Mar 08, 2025 1:27 pm

Hi, thanks for sharing.
I have RTL8153 device, but sadly it is using 0xFF driver, so it is not recognized.
I also tried with USB-NCM device on esp32-p4, but it also is not working, even if its recognized.

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

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

Postby iParcelBox » Sat Mar 08, 2025 2:04 pm

I believe that both RTL8152 and RTL8153 have both primary (0xFF) and Secondary configurations (CDC-ECM), so it should be working. I've just tested with a Belkin usb-c to ethernet dongle here which uses the RTL8153 chipset and was able to get an IP address over DHCP and then ping the device.

Could you test our example script and let me know what console output you get, so that we can look into whether it's a device-specific problem?

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

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

Postby chegewara » Sat Mar 08, 2025 2:14 pm

Sadly the one i have, from waveshare, is using 0xFF interface too:

Code: Select all

Config Number: 1
	Number of Interfaces: 1
	Attributes: 80
	MaxPower Needed: 350mA

	Interface Number: 0
		Name: r8152
		Alternate Number: 0
		Class: ff
		Sub Class: ff
		Protocol: 00
		Number of Endpoints: 3
		

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

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

Postby iParcelBox » Sat Mar 08, 2025 4:58 pm

That looks as though it's the details for bConfigurationValue 1. On Realtek 8152 the cdc-ecm interface is on bConfigurationValue 2. Have you enabled `CONFIG_USB_HOST_ENABLE_ENUM_FILTER_CALLBACK` and captured the callback to set the second configuration?

Can you post the full device and config descriptors for your device, just to check that you have `bConfigurationValue 2`

Also, have you tried the sample code from my repo to test it?

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

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

Postby DrMickeyLauer » Thu Mar 13, 2025 5:29 pm

I'm trying to have the ESP32S3 pose as USB-C-Ethernet adapter for the use with iOS. With the USB-NCM example I get an Ethernet device on iOS and so far it looks good. What's the difference between USB-CDC-NCM and USB-CDC-ACM though and why would it be beneficial to use one over the other?

In the end, on the ESP32S3 side, I'd like an esp-netif to be initialized, so that I can run a DHCP-SERVER and some additional TCP services. Can I do that with NCM and ACM alike?

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

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

Postby chegewara » Thu Mar 13, 2025 9:08 pm

CDC-NCM is network port over USB
CDC-ACM is a serial port over USB, like regular UART

If you want, here is simple example with my usb-netif component. This example is for P4, but it will also work on S3
https://github.com/esp32-open-source/usb-netif-example

You actually dont have to use my component anymore, because espressif simplified and provided very good API and example, which i posted earlier.
My component is just a C++ wrapper, which can initialize usb-netif with just one of code with default settings.
From my experience simpler than espressif usb-netif is only blink example. Everything is configured with just a few lines of code, less than a 10 probably.

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

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

Postby DrMickeyLauer » Sat Jan 03, 2026 11:07 am

Coming back to that after some months. I'm having problems with USB-NCM when talking to Apple devices. Switching to ECM/RNDIS seems to help with initial detection (it gets a DHCP address), but it doesn't properly survive iOS device suspend/resume.

UPDATE: Actually some tweaking to the USB-NCM makes DHCP negotiation at plug/replug work, but it also suffers from not surviving iOS device suspend/resume.

Note that it works just fine for Linux, but as much as I'm inclined to drop it as an "Apple-specific problem", I need to get this working.

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], PerplexityBot, Qwantbot, Semrush [Bot] and 5 guests