2024-06-25 11:06 PM
Using B-L072Z-LRWAN Board, I'm trying to Enumerate the USB Port as a Ethernet Adapter.(As Device not Host)
Thereby I integrated just the USB-ECM Stack provided by the STM32 itself.
I initially had issues with Driver, Post Following the Guide/Post from @tjaekel , i.e USB ECM demo - how to setup host? I used Belcarra USBLAN Driver, Though it got installed and is shown under Network Adapter, I see a Warning Sign for it
On Linux though, It gets identified as Android Tethering Device but doesn't show up on Wireshark nor Control Panel(Under Network).
So Below are my Issues:
2024-06-26 09:34 AM
If you use the USB-ECM as provided as Azure demo - the USB descriptors have a small bug (something missing). The Belcarra Driver will not accept the USB-ECM because of it. You can find a fixed version on my GitHub:
GitHub - tjaekel/STM32U5xx_USB_ECM: NUCLEO-U575ZI-Q with USB ECM, without SD Card
There is a fix needed on the USB enumeration:
In file "ux_device_descriptors.c":
#define PATCH
#ifdef PATCH
/* PATCH added */
/* Append ECM Interrupt IN Endpoint Descriptor to Configuration descriptor */
__USBD_FRAMEWORK_SET_EP((pdev->tclasslist[pdev->classId].Eps[2].add),
(USBD_EP_TYPE_INTR),
(uint16_t)(pdev->tclasslist[pdev->classId].Eps[2].size),
(0x00U), (0x00U));
/* Append ECM Data class interface descriptor to Configuration descriptor */
__USBD_FRAMEWORK_SET_IF(pdev->tclasslist[pdev->classId].Ifs[1], 0U, 0U, 0x0AU, 0U, 0U, 0U);
/* end of PATCH */
#endif
#if 0
/* Append ECM Communication IN Endpoint Descriptor to Configuration descriptor */
__USBD_FRAMEWORK_SET_EP(pdev->tclasslist[pdev->classId].Eps[2].add,
USBD_EP_TYPE_INTR,
(uint16_t)pdev->tclasslist[pdev->classId].Eps[2].size,
USBD_CDCECM_EPINCMD_HS_BINTERVAL,
USBD_CDCECM_EPINCMD_FS_BINTERVAL);
#endif
/* Append ECM Data class interface descriptor to Configuration descriptor */
#ifdef PATCH
/* PATCH - change */
__USBD_FRAMEWORK_SET_IF(pdev->tclasslist[pdev->classId].Ifs[1], 1U, 2U, 0x0AU, 0U, 0U, 0U);
#else
__USBD_FRAMEWORK_SET_IF(pdev->tclasslist[pdev->classId].Ifs[1], 0U, 2U, 0x0AU, 0U, 0U, 0U);
#endif
2024-06-26 12:34 PM
About your questions:
USB_ECM is great if you want to access MCU via network (e.g. using UDP sockets in a Python script or running a web server in MCU and access it from a host with web browser).
LwIP should work with USB_ECM. No idea how much RAM is needed. Why USB_ECM does use so much memory? Potentially for buffers, for USB and for network packets, Maybe possible to tweak (fewer and/or smaller buffers). Potentially, some stuff which could be const (e.g. USB enumeration) hold in SRAM (instead as const in ROM).
Yes, USB_ECM is the emulation of network traffic (Ethernet) via USB. It behaves like a network connected device and you can use the network adapter (virtual Ethernet) on host computer. If the USB_ECM host drivers will see properly the MCU with USB_ECM - there should be a virtual network adapter available (like an Ethernet interface).
At the end it depends on what you want to do: if you have just a USB FS (with USB_ECM) - a USB VCP UART might be an option. USB VCP UART does not need any driver as USB_ECM does not need one. USB_ECM via USB FS might be convenient to have it as a regular network connection, but potentially the throughput is not really fast.
BTW: without fixing the USB enumeration USB_ECM was working for me on Android and Linux systems (just Windows Belcarra needs the fix). It was also working running on Windows a Linux VM.
2024-06-26 12:40 PM
2024-06-27 02:22 AM
@tjaekel, Thanks for your response.
Please Correct if My understandings are wrong,
2024-06-27 02:41 AM
@Pavan_LohiaGroup wrote:
- With no Network Stack such as LwIP, If we integrate just the USB-ECM, The Device Should get detected as Virtual Ethernet Port, Is my Understanding Correct?
But the whole point of USB-ECM, surely, is to provide an IP network link - so what's the point of doing that and then not having an IP Stack ?
@Pavan_LohiaGroup wrote:
- My End Goal is, The Development Board should get Detected as a Ethernet Port on all OS Platforms
If the OS platforms see it as an Ethernet Port, they will expect to be sending IP to it - won't they?
So, again, that means your microcontroller will need to speak IP - ie, it will require an IP stack
2024-06-27 02:44 AM - edited 2024-06-27 02:58 AM
@Pavan_LohiaGroup wrote:4. Keeping in mind the Board/Controller, STM32L072CZx, Wouldn't Implementing Server Logic use too much of memory?
Yes, I would suspect that's going to be a big issue!
@tjaekel suggested using VCP instead - I think major OSs should still be able to recognise that as "dial-up" networking - with PPP, SLIP, or similar ... ?
Addendum:
Just received this in a mailshot from ST:
It's a dual-core Cortex-M4 + M0 with 256K Flash - so might be more suitable to your application:
https://www.st.com/en/microcontrollers-microprocessors/stm32wl5moc.html
It's based on the STM32WL5x:
https://www.st.com/en/microcontrollers-microprocessors/stm32wl5x.html
(Single-core, M4-only, versions are availale)
Addendum 2:
For a really tiny IP stack. maybe consider uIP: https://dunkels.com/adam/software.html
2024-06-27 02:54 AM
@tjaekel wrote:USB_ECM via USB FS might be convenient to have it as a regular network connection, but potentially the throughput is not really fast.
Throughput is still going to be waaaaaaaaaaaay faster than the LoRa radio!
2024-06-27 03:22 AM
> But the whole point of USB-ECM, surely, is to provide an IP network link - so what's the point of doing that and then not having an IP Stack ?
@Andrew Neil It is possible to use raw "ethernet" packets without IP stack. There were times before IP...
2024-06-27 03:32 AM
@Pavel A. wrote:@Andrew Neil It is possible to use raw "ethernet" packets without IP stack. There were times before IP...
:thumbs_up:
I guess!
But @Pavan_LohiaGroup's objective seems to be to have this "just work" with the standard, built-in networking of "all OS Platforms" - not custom crafting raw packets ... ?
:thinking_face: