cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 CDC ECM HOST Lib

Gwen1
Associate III

Hello,

I'm working on an adapter USB to Ethernet and it is working only as a DEVICE. Now I would like to do the same but I want my STM to work as HOST.

Is ST providing the same code stm32-mw-usb-device but for host?

Thanks,

G.

3 REPLIES 3
STackPointer64
ST Employee

Hello @Gwen1,

You may want to take a look at this example and this thread, then try adapting them to your STM project:

Best regards,

To improve visibility of answered topics, please click 'Accept as Solution' on the reply that resolved your issue or answered your question.

Hello @STackPointer64
I already read those topics... And this is for CDC ECM Device.

In my case, I would like my STM32 to work as an HOST.

What I have now:

Linux (HOST) : USB Port <-> USB Port : STM32 F207 with CDC ECM for USB (DEVICE) : Ethernet Port <-> Ethernet Port : Windows Machine (Linux and Windows can ping each other, so it works!)

And now I want this:

Linux (DEVICE) : USB port <-> USB port: STM32 F207 with CDC ECM for USB (HOST) : Ethernet Port <->Ethernet Port : Windows Machine 


I tried to use the same code for the second case, but when I ping my Linux machine with Windows, the ARP table can't tell what the IP and MAC address of the Linux...

STackPointer64
ST Employee

Hello,

From what you describe, your current setup works fine with Linux as the USB HOST and STM32 as the DEVICE using CDC ECM, allowing Linux and Windows to communicate over Ethernet. However, when you switch roles—making STM32 the HOST and Linux the DEVICE, and try to use the same ECM code, Windows cannot resolve the Linux device’s IP and MAC addresses in the ARP table. This is a common issue related to how Windows handles USB Ethernet protocols.

Windows primarily supports RNDIS, a proprietary Microsoft protocol for Ethernet over USB, and does not natively support ECM devices well. That’s why when your STM32 acts as HOST and Linux as DEVICE using ECM, Windows struggles with ARP resolution. but keep in mind that memory-limited MCUs cannot support these protocols properly.

To summarize:

  • RNDIS is widely supported on Windows and is the preferred protocol for USB Ethernet communication on that platform.
  • ECM is a standard protocol used mainly on non-Windows systems like Linux and macOS, offering good cross-platform compatibility.
  • Windows does not promote ECM and expects RNDIS devices instead.
  • Your STM32 HOST scenario with Linux DEVICE using ECM will face issues on Windows due to this protocol mismatch.
  • Also, ensure your STM32 MCU has enough memory to handle the USB Ethernet protocol you want to implement.

If possible, try configuring the Linux device to use RNDIS when connected to Windows. This should help resolve the ARP and connectivity issues you’re facing.

Best regards,

To improve visibility of answered topics, please click 'Accept as Solution' on the reply that resolved your issue or answered your question.