cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U5x: USB ECM demo - how to setup host?

tjaekel
Lead

I am progressing on porting the CubeU5 project for STM32U575I-EV as Ux_Device_CDC_ECM to a NUCLEO-U575ZI-Q board:

The USB enumeration seems to work: I hear the sound and I see also an USB "STM32 CDC ECM" device.
BTW: very important to go with the right BSP files: the NUCLEO-U575ZI-Q has a different USPD chip! (I have changed to the right BSP files for NUCLEO, the EVAL board BSP cannot work).

What I get:

  • an "Other devices" in device manager (the driver is not found):

USB_ECM_1.png

No idea what to install on a Windows OS to make the device driver happy.
What works:

  • if I select manually and select "USB devices", "STMicroelectronics" and "STLink Bridge" - the driver is happy
  • but it cannot be right (it does not look like a network interface is added to the system)
  • trying some NDIS and RNDIS drivers fail (Windows complains about issues to install)

USB_ECM_2.png

The MCU FW is not happy:

  • it does not progress on DHCP server: the MCU does not get any IP address (and the event for IP address changed is not coming)

If I try on a MacOS:

  • it looks like I see a new ETH network interface: an "en4" is there when I have connected the MCU board (via USB and FW running as USB ECM, without MCU it is not there)
  • but the FW does not progress here in the same way: it does not get an IP address via DHCP
  • I tried to ping the reported IP address on "en4" - it does not work

There are some threads in Internet related to USB ECM: nothing mentioned for Windows OS, many application notes reference to use Linux (but no idea how to enable DHCP on such an USB EMC device, even it seems to be available (via ifconfig).

Does anybody have a clue how to install and use USB EMC?
(on Windows or MacOS)

What is missing so that MCU FW gets an IP address (via DHCP, as enabled in FW)?

How to install a driver on Windows?
And to make it working on Windows?

1 ACCEPTED SOLUTION

Accepted Solutions

Now all works!

Dear STM team: please, could you develop/provide a Windows USB EMC driver?
(or cooperate with other companies: Seeger, MCCI, NVidia seem to have such one).

Issue with SD Card solved:
The flying wires were causing the issue to open the web files. With a carrier board where SD Card adapter is connected - all works fine. BTW: I tried to lower SDMMC speed, clock dividers - nothing helped really, except to make the connection "directly" for SD Card adapter (I got CRC errors on SDMMC transactions).

STM32U575_USB_ECM_Android.jpg

So, all works fine (on my Android phone). Just Windows OS "sucks" (missing driver).

What could "we" do with it?:

  1. A host (Linux, Android, MacOS) could connect and control MCU board via TCP/IP (network) - even the MCU board is just connected via USB (and does not have ETH connection).
  2. Running my (Android) phone as "Mobile Hotspot" - the MCU would get access to Internet, or I can access the MCU via WiFi - even the MCU board does not have a WiFi chip,
  3. I can reuse my host scripts, e.g. Python, talking via network (TCP/IP, UDP sockets) like to my other MCU boards.

How to solve the issue with missing USB ECM driver on Windows?:

  • STM could think about to provide a Windows driver - would be very kind. Thank you.
  • Install a Virtual Machine (VM) on Windows, running Linux (e.g. Ubuntu) and try if USB in VM would see it as USB ECM.

So far, all accomplished what I had in mind.
Well done, STM team, to have such a USB ECM (with the new AZURE RTOS and USB stack),
which works now on NUCLEO-U575ZI-Q board as well.

I will cleanup my project and publish on (my) GitHub...

View solution in original post

21 REPLIES 21
tjaekel
Lead

Another progress: I can see my NUCLEO-U575ZI-Q board on an Android phone! Cool.

What I have figured out on Internet:

  • USB EMC is NOT supported by Microsoft OS: you would need a special vendor driver (and I could not find any USB EMC driver, STM does not provide any...)
  • (only) RNDIS is supported by Windows (very old), but it is not the same as USB EMC:
    all the RNDIS drivers I tried to install - FAIL (on my Windows 11 PC, "driver cannot be started")
  • I do not want to go with RNDIS (too old, hard to find STM32 examples, all new Middleware with AZURE does not seem to have RNDIS): it would need anyway a different USB stack on MCU board (and hard to find one, just very old stuff, not for my MCU...)

But USB EMC works fine on Linux, e.g. MacOS, Ubuntu Linux (not tried) but for sure on Android!

So, I could enable "Ethernet tethering" on my Android phone:

  • I can enable - a very good indication: it means: the USB EMC is recognized (provided by my MCU)
    (if MCU is not providing an USB EMC or it is not connected/not running - not possible to enable - great to see it works)
  • I can also "ping" the IP address (reported on ST-LINK UART) - works

Just: my SD Card interface or the SD Card seems to have a problem: the file system, to initialize and to open the request files (e.g. "index.html") does not work.
But the USB EMC is working! Cool

USB_EMC_log.png

When I connect via USB-C to Android phone, enable "Ethernet tethering" - the MCU progresses, gets an IP address (via DHCP server) - cool.

20240123_213101.jpg

I can also "ping" the MCU, via the IP address on UART log (ping tool on Android phone, I cannot reach MCU from PC: a different network, potentially a "route" setting needed, with a gateway to reach the other network)

So,

USB EMC works (just on Linux systems, I saw it popping up also on MacOS), just to fix my SD Card:

It looks like the NetX file system cannot be initialized successfully: no idea in which format the SD Card has to be (exFAT, FAT32, FAT16, NTFS, ...). MCU cannot open files. (but so far good to see USB EMC working).
(but looks now more like a minor issue).

Why do I "like" Windows so much? Because it is a live-long challenge to fix issues...  LOL

 

Now all works!

Dear STM team: please, could you develop/provide a Windows USB EMC driver?
(or cooperate with other companies: Seeger, MCCI, NVidia seem to have such one).

Issue with SD Card solved:
The flying wires were causing the issue to open the web files. With a carrier board where SD Card adapter is connected - all works fine. BTW: I tried to lower SDMMC speed, clock dividers - nothing helped really, except to make the connection "directly" for SD Card adapter (I got CRC errors on SDMMC transactions).

STM32U575_USB_ECM_Android.jpg

So, all works fine (on my Android phone). Just Windows OS "sucks" (missing driver).

What could "we" do with it?:

  1. A host (Linux, Android, MacOS) could connect and control MCU board via TCP/IP (network) - even the MCU board is just connected via USB (and does not have ETH connection).
  2. Running my (Android) phone as "Mobile Hotspot" - the MCU would get access to Internet, or I can access the MCU via WiFi - even the MCU board does not have a WiFi chip,
  3. I can reuse my host scripts, e.g. Python, talking via network (TCP/IP, UDP sockets) like to my other MCU boards.

How to solve the issue with missing USB ECM driver on Windows?:

  • STM could think about to provide a Windows driver - would be very kind. Thank you.
  • Install a Virtual Machine (VM) on Windows, running Linux (e.g. Ubuntu) and try if USB in VM would see it as USB ECM.

So far, all accomplished what I had in mind.
Well done, STM team, to have such a USB ECM (with the new AZURE RTOS and USB stack),
which works now on NUCLEO-U575ZI-Q board as well.

I will cleanup my project and publish on (my) GitHub...

Sorry,

Dear STM team: please provide an USB ECM driver for Windows OS.
Or ask Microsoft: why their AZURE RTOS does support USB ECM - but not their host (Windows)?

Thank you.

My project for "USB_ECM" on a NUCLEO-U575ZI-Q board (with external SD Card adapter!) is now on GitHub:

GitHub - tjaekel/NUCLEO-U575ZI-Q_USB_ECM: USB_ECM with NUCLEO-U575ZI-Q

Have fun with it.
BTW: I want to change project to get rid of needed SD Card, e.g. to read web pages from MCU flash memory.
(but a separate topic: AZURE RTOS FileX has a "missing feature", e.g. read files from flash, but without a FAT (block oriented) file system... - more in a separate thread)

I have the NUCLEO-U575ZI-Q working, for USB ECM - but without a need for the SD Card:
files are stored on internal MCU Flash memory (and read from there).

Approach: instead of using FileX function calls - I have implemented a subset needed to read files with similar functions (w/o a need for FileX, no FAT32 file system, no SD Card).

Project is here:

GitHub - tjaekel/NUCLEO-U575ZI-Q_USB_ECM_noSDCard: NUCLEO-U5757ZI-Q board for USB_ECM without SD Card

 

I can confirm now: USB ECM works on:

  • Android OS (my phone)
  • MacBookPro (MacOS - but not on my pretty old iMac)
  • Linux (Ubuntu in an Oracle VM)

USB_ECM_Ubuntu_1.png

USB_ECM_Ubuntu_2.png

So, just still looking for a Windows driver, as USB ECM (not RNDIS).

The latest project for:

  • NUCLEO-U5A5 or
  • NUCLEO-U575

is here:

https://github.com/tjaekel/STM32U5xx_USB_ECM 

It works now also on Windows OS.

Belcarra_USBLAN.png

See a new Ethernet adapter when USB-C is plugged in.
Watch the UART in order to know what the IP address of the MCU is.

Now a web browser should be able to open the MCU internal web page via: http://ipaddr/index.html

Dear STM Team:

please, could you consider to license the Belcarra USBLAN driver?
It would be nice if STM (or AZURE RTOS team (Microsoft)) could bundle this driver with their STM demos for USB ECM. Thank you.

The Belcarra USBLAN (USB ECM) driver can be found here:

http://usblan.belcarra.com       http://www.belcarra.com 

 

Very nice project. Thanks for all the details.

How did you connect the STM32U575ZI-Q board to the Android phone? Regular USB-C cable or OTG cable?

I've the same board and downloaded your github project, built and loaded on the board.

I See this on the Terra-Term

Starting DHCP Client....

It never get IP address.

Cool, you have already success to compile and run - good to know.

Android:
I use a regular USB-C to USB-C cable. My Galaxy has USB-C.
So, 2x USB: 1x for STM-LINK and power (with VCP UART, on PC), 1x USB-C USR (the other one to Android phone).

Go on (my) Android to "Settings" -> "Mobile Hotspot and Tethering":
see "Ethernet tethering" there (at the bottom for me):

  • if the slider is dark gray - a good sign: USB was seen (light gray is bad: not seen)
  • if dark gray - you can slide now: it should get blue (enabled)
    AND:
    the UART terminal should spit out now an IP address for MCU board,
    use this address displayed to launch web browser (as URL plus /index.html)

Yes, I like it as well (even I do not use right now, but cool to see that "network via USB" works).

If this fails on Android phone - still an option to ty on Linux (with a VM on Windows), on MacOS.

Please,
let me know if you see it working (I like to see it working "somewhere else").