cancel
Showing results for 
Search instead for 
Did you mean: 

USB-RNDIS Works Partially and Later Results in HardFault

Pavan_LohiaGroup
Associate III

MCU: STM32L072CZx

Development Board: B-L072Z-LRWAN1

Middleware: USB-RNDIS From STM32's GitHib: STM32_MW_USB_DEVICE.

Entire Project for SMT32CubeIDE is attached as Attachment.

I have Integrated the USB-RNDIS Middleware Stack into the Project using STM32CubeIDE.

Below are my List of Issues:

  1. It Gets Detected as Ethernet Adapter on Windows, But the Adapter is Disabled on Network Adapter Settings thereby unusable on Windows.
    1. Trying to Enabling Doesn't workPavan_LohiaGroup_1-1719303853609.png

       

    2. Changing PID and VID too doesn't work
  2. It Gets Detected on Linux Platform and is also Enabled, Unfortunately Post a Specific Number of Packets (i.e. ~ 70-85 Packets) the Code Runs into a HardFault_Handler.Pavan_LohiaGroup_0-1719303720521.png

     

I also Installed the USBView on System to Check the Endpoints and Other Parameters, Not Sure what am I missing, But I see some Issue on USBView.

Pavan_LohiaGroup_2-1719303977767.png

 

Below are the Details From USBView Tool:

[Port3] : USB to Ethernet Adapter


Is Port User Connectable: yes
Is Port Debug Capable: no
Companion Port Number: 16
Companion Hub Symbolic Link Name: USB#ROOT_HUB30#4&3329762&0&0#{f18a0e88-c30c-11d0-8815-00a0c906bed8}
Protocols Supported:
USB 1.1: yes
USB 2.0: yes
USB 3.0: no

---===>Device Information<===---
String Descriptor for index 2 not available while device is in low power state.

ConnectionStatus:
Current Config Value: 0x00 -> Device Bus Speed: Full (is not SuperSpeed or higher capable)
Device Address: 0x16
Open Pipes: 0
*!*ERROR: No open pipes!

===>Device Descriptor<===
bLength: 0x12
bDescriptorType: 0x01
bcdUSB: 0x0200
bDeviceClass: 0x02
*!*ERROR: device class should be Multi-interface Function 0xEF
When IAD descriptor is used
bDeviceSubClass: 0x02 -> This is the Common Class Sub Class
bDeviceProtocol: 0x00
*!*ERROR: device Protocol should be USB IAD Protocol 1
When IAD descriptor is used
bMaxPacketSize0: 0x40 = (64) Bytes
idVendor: 0x0FE6 = Sospita ASA
idProduct: 0x9700
bcdDevice: 0x0200
iManufacturer: 0x01
String Descriptor for index 1 not available while device is in low power state.
iProduct: 0x02
String Descriptor for index 2 not available while device is in low power state.
iSerialNumber: 0x03
String Descriptor for index 3 not available while device is in low power state.
bNumConfigurations: 0x01

---===>Full Configuration Descriptor<===---

===>Configuration Descriptor<===
bLength: 0x09
bDescriptorType: 0x02
wTotalLength: 0x004B -> Validated
bNumInterfaces: 0x02
bConfigurationValue: 0x01
iConfiguration: 0x00
bmAttributes: 0xC0 -> Self Powered
MaxPower: 0x32 = 100 mA

===>IAD Descriptor<===
bLength: 0x08
bDescriptorType: 0x0B
bFirstInterface: 0x00
bInterfaceCount: 0x02
bFunctionClass: 0xE0
*!*CAUTION: This appears to be an invalid Interface Class
bFunctionSubClass: 0x01
bFunctionProtocol: 0x03
iFunction: 0x00

===>Interface Descriptor<===
bLength: 0x09
bDescriptorType: 0x04
bInterfaceNumber: 0x00
bAlternateSetting: 0x00
bNumEndpoints: 0x01
bInterfaceClass: 0x02 -> This is Communications (CDC Control) USB Device Interface Class
bInterfaceSubClass: 0x02
bInterfaceProtocol: 0xFF
iInterface: 0x00
-> This is a Communications (CDC Control) USB Device Interface Class

===>Descriptor Hex Dump<===
bLength: 0x05
bDescriptorType: 0x24
05 24 00 10 01
-> This is a Communications (CDC Control) USB Device Interface Class

===>Descriptor Hex Dump<===
bLength: 0x05
bDescriptorType: 0x24
05 24 01 00 01
-> This is a Communications (CDC Control) USB Device Interface Class

===>Descriptor Hex Dump<===
bLength: 0x04
bDescriptorType: 0x24
04 24 02 00
-> This is a Communications (CDC Control) USB Device Interface Class

===>Descriptor Hex Dump<===
bLength: 0x05
bDescriptorType: 0x24
05 24 06 00 01

===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x82 -> Direction: IN - EndpointID: 2
bmAttributes: 0x03 -> Interrupt Transfer Type
wMaxPacketSize: 0x0010 = 0x10 bytes
bInterval: 0x10

===>Interface Descriptor<===
bLength: 0x09
bDescriptorType: 0x04
bInterfaceNumber: 0x01
bAlternateSetting: 0x00
bNumEndpoints: 0x02
bInterfaceClass: 0x0A -> This is a CDC Data USB Device Interface Class
bInterfaceSubClass: 0x00
bInterfaceProtocol: 0x00
iInterface: 0x00

===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x01 -> Direction: OUT - EndpointID: 1
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x00

===>Endpoint Descriptor<===
bLength: 0x07
bDescriptorType: 0x05
bEndpointAddress: 0x81 -> Direction: IN - EndpointID: 1
bmAttributes: 0x02 -> Bulk Transfer Type
wMaxPacketSize: 0x0040 = 0x40 bytes
bInterval: 0x00

 

@Hana Slimi@ALABSTM, Team Please Support on this.

1 REPLY 1
Pavan_LohiaGroup
Associate III

The Issue I had earlier mentioned, i.e.

>> It Gets Detected on Linux Platform and is also Enabled, Unfortunately Post a Specific Number of Packets (i.e. ~ 70-85 Packets) the Code Runs into a HardFault_Handler.

This has been fixed, The Fix was as below

In the Source File, usbd_cdc_rndis_if_template.c, Under Function, CDC_RNDIS_Itf_Receive(uint8_t *Buf, uint32_t *Len), I had to Set the UserRxBuffer and not &Buf[0]

i.e. USBD_CDC_RNDIS_SetRxBuffer(&hUsbDeviceFS,UserRxBuffer);

 

But Now, I see another issue, i.e. The Data received is not as what is being sent. I see it as

  • either the Data in the Buffer is Jumbled or Has Extra Bytes which weren't a part of the actual data
  • Certain data is lost in certain packets too

 

Issue with Window's being disabled still persists