cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F2 USB OTG Host enumerates all values 0x00

adam23
Associate II
Posted on September 25, 2015 at 11:57

I have a STM32F2 with OTG periphery and STM32 USB Host Device library in FS host mode.

The other end is STM32F4 OTG FS with the same library but in Device mode as VCP.

When I connect the device to the Host, it is detected and enumerated, but the

USBH_HOST structure shows all values as zeros (0x00) (The bInterfaceClass  matches the 0x02 ~ CDC).

void deviceInit(USB_OTG_CORE_HANDLE* p_dev,

                      USBH_HOST*           p_host)

{

    uint8_t interfaceClass    = p_host->device_prop.Itf_Desc[0].bInterfaceClass;

    uint8_t interfaceSubClass = p_host->device_prop.Itf_Desc[0].bInterfaceSubClass;

    uint8_t interfaceProtocol = p_host->device_prop.Itf_Desc[0].bInterfaceProtocol;

    uint16_t idVendor  = p_host->device_prop.Dev_Desc.idVendor;

    uint16_t idProduct = p_host->device_prop.Dev_Desc.idProduct;

}

If I put the trace logs into all states, I do get this:

USBH_USR_DeviceAttached

USBH_USR_ResetDevice

USBH_USR_DeviceSpeedDetected: full

USBH_USR_Device_DescAvailable: VID 0x0000 PID 0x0000

USBH_USR_DeviceAddressAssigned

USBH_USR_Configuration_DescAvailable: 0x02

USBH_USR_Manufacturer_String: N/A

USBH_USR_Product_String: N/A

USBH_USR_SerialNum_String: N/A

USBH_USR_EnumerationDone

Against Windows and Linux the STM32F4 Device enumerates correctly.

Any idea what could be wrong?

#stm32-usb
1 REPLY 1
adam23
Associate II
Posted on October 01, 2015 at 15:50

To answer myself:

There is a bug in STM32 Host Device library in the Device part in usbd_req.c function USBD_GetDescriptor. I found that by sniffing the USB communication as the USB device was replying with incorrect Device Descriptor size (request was 0x12, response 0x08 bytes). Then verified this was removed in STM32 Cube too. Interesting side of this is, that Windows and Linux can somehow work around this behavior, but the Host part of STM USB stack can not.

    pbuf = pdev->dev.usr_device->GetDeviceDescriptor(pdev->cfg.speed, &len);

// HAL removes this inappropriate check

//    if ((req->wLength == 64) ||( pdev->dev.device_status == USB_OTG_DEFAULT))  

//    {                  

//      len = 8;

//    }