cancel
Showing results for 
Search instead for 
Did you mean: 

RNDIS Over USB Implementation on STM32L0

Pavan_LohiaGroup
Associate III

Board: B-L072Z-LRWAN1

MCU: STM32L072

IDE: STM32CubeIDE

I'm Trying to Implement RNDIS Over USB, Where When USB is Connected to Computer, It should get detected as USB Ethernet Adapter.

On the STM32CubeIDE, I could Implement and Test the VCP(Virtual COM Port) from the Generated Code,

I now Downloaded the Library for RNDIS From GitHub of STM32 (https://github.com/STMicroelectronics/stm32_mw_usb_device ), The Same Generated Code was Modified to use the RNDIS Library(USB_CDC Library was removed), Where I shall Pass the Respective Class/Structure/Variables of RNDIS etc. Post Compilation and Flashing of the Code, System is still detecting it as a VCP Only.

I later Referred to Various Examples from Github where Web Server using RNDIS is hosted to display a webpage on a Static webpage when connected, Which uses RTOS and it's implementation is for STM32F4, Studying the same I tried implementation of RNDIS Using RTOS for STM32L0 and Yet Still again I face the same issue of being identified as VCP. Few Links to which I referred are

  1. https://github.com/fetisov/lrndis 
  2. Others from STM32CubeIDE Example's

Not Sure About where and Why Things weren't working as intended, I moved to Try the Say for USB ECM (Ethernet Control Model) and I'm facing the same issue.

So I have now moved on trying to implement the same using Lwip Library and work is still in progress, I would be glad and happy if someone could guide me on the right path (Including and not limited to sequence of code, Functions to be invoked)and help in it's implementation with any example/references to codes etc.

Thanks in Advance.

11 REPLIES 11
Pavel A.
Evangelist III

If you have plugged your board in a Windows PC it could remember the previous class/driver in the registry. Try to locate this and remove (in device manager: View->show hidden devices ...) 

Then check that your device and interface descriptors correctly indicate the RNDIS class.

Pavan_LohiaGroup
Associate III

I did try the Solution Mentioned and it worked. Apart from the Said Solution, Changing of PID and VID to an Already Existing Devices in Market (USB-Ethernet Adapter) also solved my problem.

 

Now the Device is Getting Detected as a USB-Ethernet Adapter on Both Windows and Linux. Can you also help understand how to send and acknowledge data from System(Windows/Linux).? At the moment I had only Modified the Code such that when the Function CDC_RNDIS_Itf_Receive and CDC_RNDIS_Itf_TransmitCplt gets invoked respective LED's Should blink.

I tried manually assigning an Static IP address to the adapter and trying to ping or send data to that IP Address, But I couldn't see any data transfers happening.

What are the other methods now to communicate with Board using this Adapter Configuration.

Pavel A.
Evangelist III

 how to send and acknowledge data from System(Windows/Linux)

?? Are you asking how to cause Windows or Linux send something to the RNDIS NIC device or receive?

Yes, ping should do.

Then you will need wireshark (properly set up... TL;DR) and some test suite (at least the Microsoft's Ndistest).

 

Pavan_LohiaGroup
Associate III

As I have mentioned earlier, I did try to Ping the device, But I do not think ping data is being accepted by STM32 because None of the functions in the STM32 RNDIS Library are getting invoked when a Ping is sent. To Verify this(Communication), I added LED Blinking in most too all of the Functions. But None of the functions got invoked after a Ping.

I attach my Codes/Project here please see if I'm on the right track too.

Pavel A.
Evangelist III

The enumeration is successful (because host sees the device) and this takes a lot of data send forth and back. This means the hardware and the corresponding STM32 code most likely is ok. Do you see any errors in dmesg on Linux? What is the error shown by ping? On Windows: use USBview to see more device details. Maybe you'll have to instrument the Linux RNDIS driver to see what fails and how.

If this looks too hard or confusing, experienced consultant may help.

On Windows or On Linux, I don't see any errors on Device Manager or dmesg too. W.r.t ping, I first set a static IP to the Adaptor (STM32). In Linux, Ping is 100% successful and On Windows Ping(Tx) is successful but doesn't get a response back, So it becomes a Timeout.

Is it compulsory to implement TCP/IP Stack for Communication to be established? Such as lwIP or Webserver implementation on RTOS?

Pavel A.
Evangelist III

>  In Linux, Ping is 100% successful

Then I'm afraid there's a duplicate IP address on the network. 

> Is it compulsory to implement TCP/IP Stack for Communication to be established? Such as lwIP or Webserver implementation on RTOS?

If your firmware on STM32 side forwards the packets received from host outside, then of course you don't need TCP/IP stack or RTOS on STM32. If your device is not a honest ethernet adapter but something else (like a http or udp server) and you want it to respond to ping then you need a minimal "IP stack" such as LwIP. Some "IP stacks" depend on certain RTOS. LwIP can work without any RTOS. 

Pavan_LohiaGroup
Associate III

> Duplicate IP Address on the Network on Linux

No, The Device was not connected to any Network, Neither the Wifi or Ethernet. STM32 Adapter was Only Given/Assigned a Static IP from Settings Page of Linux. & Still the Ping was 100% Success.

> TCP/IP Stack

The Requirement is, All the Data Coming from Host Via Ethernet should just be Captured, This Data will be sent over(or Forwarded) via other modes(SPI, UART, etc).