none
USB OTG with serial profile RRS feed

  • Question

  • Hi all,

    WinEC700 + iMX51.

    On our board I have a USB OTG port.

    By default WinEC configure it for ActiveSync (VID 0x045E, PID 0x00CE): we need to customize it to connect a PC with a virtual serial port.

    To achieve it, i overwrote the default values with new configurations in platform.reg file:

    [HKEY_LOCAL_MACHINE\Drivers\USB\FunctionDrivers\Serial_Class]
       "Dll"="serialusbfn.dll"
       "DeviceName"="USBFNS1:"
       "Prefix"="COM"
       "DeviceArrayIndex"=dword:0
       "RxBufferSize"=dword:4000
       "IClass"="{CC5195AC-BA49-48a0-BE17-DF6D1B0173DD}"
       "idVendor"=dword:xxxx	;my VID
       "idProduct"=dword:yyyy	;my PID
       "Manufacturer"="Mnf"
       "Product"="MyProd"
       "bcdDevice"=dword:0
       "CompositeFn_DefaultClient"=dword:0

    and then enabled the full USB OTG support and recompiled the OS image.

    When i connect the cable to the PC, i install the inf file to load the usbser+serenum drivers: the VID and PID received values are correct but when the installation ends, i see the error 10 as result.

    On the PC I see a new serial port with a yellow '!'.

    On the device side I see nothing: no new serial port but the serialusbfn.dll library is listed in the Process View Remote Tool window.

    Now i don't understand where is the problem...

    PS: OTG always works as device


    SteMMo


    • Edited by SteMMo Thursday, August 29, 2013 9:58 AM
    Thursday, August 29, 2013 9:02 AM

All replies

  • You need to keep the VID/PID as they were (MS's VID/PID) so that the standard driver as shipped with Win7 (and Win8?) will work.

    If you change the VID/PID you will have to create your own driver for Win7 (and you need to sign it for it to work).

    Microsoft has given permission to use the VID/PID of Microsoft for USB Serial (ActiveStink/WMDC) connections so you don't have to do any Win32/64 USB driver development.

    So:

    1. Keep Microsoft's VID/PID
    2. Change the manufacturer and product strings as you want
    3. Ignore the warnings in common.reg (and platform.reg) that you have to change the VID/PID

    This was an official statement from Microsoft, but I can't find this anymore online. They stated that at the time when Windows 7 came out (because at that time all Win32/64 drivers had to be fully signed, causing major headaches for a lot of device manufacturers).

    Maybe someone from MS can confirm we are still allowed to keep using MS's VID/PID in this case?


    Good luck,

    Michel Verhagen, eMVP
    Check out my blog: http://guruce.com/blog

    GuruCE
    Microsoft Embedded Partner
    http://guruce.com
    Consultancy, training and development services.

    Thursday, August 29, 2013 12:28 PM
    Moderator
  • What happened if you uninstall and reinstall the driver through device manager?

    Also try with "UVCView.exe" - A tool given by Microsoft. you can capture all the enumeration information and see what ever is happening.


    Please mark as answer, if it is correct.
    Please vote,if it is helpful post.
    All the Best
    Vinoth.R
    www.e-consystems.com
    http://vinoth-vinothblog.blogspot.com

    Thursday, August 29, 2013 12:34 PM
  • On the PC I'm using XP Pro 32bit.


    SteMMo

    Thursday, August 29, 2013 2:05 PM
  • Doesn't matter. What happens if you keep VID/PID as Microsoft's ones? If it doesn't work with that then you have another problem.

    Good luck,

    Michel Verhagen, eMVP
    Check out my blog: http://guruce.com/blog

    GuruCE
    Microsoft Embedded Partner
    http://guruce.com
    Consultancy, training and development services.

    Thursday, August 29, 2013 10:58 PM
    Moderator
  • I commented out only my custom VID+PID so now the device send VID 045E and PID 00CE.

    On the PC side now have a new item (without yellow '!'): Windows CE USB device + Microsoft USB Sync, no new serial port.

    On the CE side I don't have the ActiveSync support (stripped out for security reason)!

    How can I have a serial communication between PC and device using this standard and allowed drivers?


    SteMMo


    • Edited by SteMMo Friday, August 30, 2013 9:20 AM
    Friday, August 30, 2013 8:26 AM
  • You are confusing CDC profile with ActiveSync. As far as I know there is no direct support for CDC profile in CE.

    To communicate using the Microsoft USB Sync adapter manually (so not using ActiveSync) you could have a look at the activesync API or possibly get it working using WinUSB.

    Or, select RNDIS and just use TCP/IP sockets.

    Some examples can be found here: http://msdn.microsoft.com/en-us/library/aa145853.aspx


    Good luck,

    Michel Verhagen, eMVP
    Check out my blog: http://guruce.com/blog

    GuruCE
    Microsoft Embedded Partner
    http://guruce.com
    Consultancy, training and development services.

    Friday, August 30, 2013 11:10 AM
    Moderator
  • My original idea is to try to install on both sides the virtual serial ports and then communicate using 'COMx' and 'COMy'.

    .. or better ..

    I need to connect with a USB cable PC with device implementing a custom protocol without ActiveSync.


    SteMMo



    • Edited by SteMMo Friday, August 30, 2013 1:00 PM
    Friday, August 30, 2013 12:44 PM
  • Then go for the WinUSB option. It's quite easy to implement. Have a look at this blog post (it's written with the .NET framework in mind, but this is easily applied to Windows CE):

    http://guruce.com/blogpost/communicating-with-your-microframework-application-over-usb


    Good luck,

    Michel Verhagen, eMVP
    Check out my blog: http://guruce.com/blog

    GuruCE
    Microsoft Embedded Partner
    http://guruce.com
    Consultancy, training and development services.

    Friday, August 30, 2013 1:11 PM
    Moderator
  • Ok, and for the device side, how can i control the communication?

    SteMMo

    Friday, August 30, 2013 1:13 PM
  • On the device side you create a custom USB function driver of course... You can use the descriptor example as per the blog post.

    Good luck,

    Michel Verhagen, eMVP
    Check out my blog: http://guruce.com/blog

    GuruCE
    Microsoft Embedded Partner
    http://guruce.com
    Consultancy, training and development services.


    Friday, August 30, 2013 1:15 PM
    Moderator
  • Anything in the Freescale BSP?  :)

    SteMMo

    Friday, August 30, 2013 1:26 PM
  • Haha, good one! ;)

    Good luck,

    Michel Verhagen, eMVP
    Check out my blog: http://guruce.com/blog

    GuruCE
    Microsoft Embedded Partner
    http://guruce.com
    Consultancy, training and development services.

    Friday, August 30, 2013 1:29 PM
    Moderator
  • Then the serialusbfn.dll what is for? No way to mount a virtual serial port on the USB port?

    SteMMo

    Friday, August 30, 2013 2:02 PM
  • As you can see, the standard Microsoft driver loads the device as "Microsoft USB Sync". I'm sure there is a way to utilize this driver, I'm guessing through the ActiveSync API or maybe even through WinUSB on the PC. You sure can have a look at the REPLLOG source code on the CE side, so there it should be fairly easy to create your own. On the PC side you'll have to investigate a bit what is possible...

    Did you look at any of the links I posted earlier? I think your answer can be found in one of the example programs!


    Good luck,

    Michel Verhagen, eMVP
    Check out my blog: http://guruce.com/blog

    GuruCE
    Microsoft Embedded Partner
    http://guruce.com
    Consultancy, training and development services.


    Saturday, August 31, 2013 7:52 AM
    Moderator
  • So, returning to the initial situation with my custom registry and with my custom VID and PID.

    If i understand the problem is not on the WinCE side, but on the XP side.

    The driver serialusbfn.ddl should be ok.

    On the XP side, the usbser.sys does not allow me to mount a new serial port, even if the driver is done by MS.

    The only solution should be re-write the usbser.sys driver and sign it.

    If i write a new driver to substitute the serialusbfn.dll driver on WinCE, i will not solve anything, is it?

    Even if i installed the serialusbfn on the device, i did not see any new serial port ....


    SteMMo

    Monday, September 2, 2013 5:06 PM
  • No, no, no and no.

    If you want your device to mount as a serial port in XP:

    1. Create a USB function driver on Windows CE that adheres to the CDC descriptors.

    2. The driver in XP should load automatically for the CDC device class and should mount your device as a serial port.

    If you just want to communicate with your device (and you don't care how), then you have a couple of options (as I have already said in my previous posts):

    1. Figure out how to use the Microsoft USB Sync adapter to communicate. I suspect through WinUSB.

    2. Instead of using the serial function driver on CE, use RNDIS. That will mount your device as a network adapter and you can use TCP/IP sockets to communicate with your device. This is by far the easiest solution.

    3. Create a custom function driver and on the XP side write a WinUSB driver. Note that you don't need a kernel code signing certificate to sign WinUSB drivers (a simple cheap code signing certificate is enough).

    I would investigate the options I listed last in the order I listed them. The CDC profile is the most work.

    Stay far away from "rewriting usbser.sys". That is never needed (because of WinUSB)!

    I hope I have been completely clear now?


    Good luck,

    Michel Verhagen, eMVP
    Check out my blog: http://guruce.com/blog

    GuruCE
    Microsoft Embedded Partner
    http://guruce.com
    Consultancy, training and development services.


    Monday, September 2, 2013 9:09 PM
    Moderator
  • Michel,

    i'm playing around the CDC driver.

    I built a CDC descriptor and checked with a USB analyzer: this one showed me useful things.

    I switch on the device and connect it to the PC: on the PC starts the driver installation request.

    If I sniff the USB data I see the expected data.

    Connection Status Device connected 
    Current Configuration 0 
    Speed High (480 Mbit/s) 
    Device Address 1 
    Number Of Open Pipes 0 
    
    Device Descriptor MisterBlack
    Offset Field Size Value Description 
    0 bLength 1 12h  
    1 bDescriptorType 1 01h Device 
    2 bcdUSB 2 0200h USB Spec 2.0 
    4 bDeviceClass 1 02h CDC Control 
    5 bDeviceSubClass 1 00h  
    6 bDeviceProtocol 1 00h  
    7 bMaxPacketSize0 1 40h 64 bytes 
    8 idVendor 2 0E05h  
    10 idProduct 2 0010h  
    12 bcdDevice 2 0001h 0.01 
    14 iManufacturer 1 01h "Me gmbh" 
    15 iProduct 1 02h "MisterBlack" 
    16 iSerialNumber 1 03h "00000000-0000-0000-0000-000000000000" 
    17 bNumConfigurations 1 01h 
    

    When I install the driver and I re-sniff the USB data I see an error that, i guess, causes the Error 10 on the PC:

    Connection Status Device connected 
    Current Configuration 0 
    Speed Low (1.5 Mbit/s) 
    Device Address 0 
    Number Of Open Pipes 0 
    
    Device Descriptor 
    Offset Field Size Value Description 
    0 bLength 1 12h  
    1 bDescriptorType 1 01h Device 
    2 bcdUSB 2 0200h USB Spec 2.0 
    4 bDeviceClass 1 02h CDC Control 
    5 bDeviceSubClass 1 00h  
    6 bDeviceProtocol 1 00h  
    7 bMaxPacketSize0 1 40h Should be 8 bytes for low-speed devices 
    8 idVendor 2 0E05h  
    10 idProduct 2 0010h  
    12 bcdDevice 2 0001h 0.01 
    14 iManufacturer 1 01h  
    15 iProduct 1 02h  
    16 iSerialNumber 1 03h  
    17 bNumConfigurations 1 01h 
    

    Actually, the CDC specifications says that bMaxPacketSize0 must be 8.

    Something in the driver is forcing the value = 64.


    SteMMo

    Wednesday, September 4, 2013 8:40 AM
  • You have to make EP0 interrupt (not bulk).

    Good luck,

    Michel Verhagen, eMVP
    Check out my blog: http://guruce.com/blog

    GuruCE
    Microsoft Embedded Partner
    http://guruce.com
    Consultancy, training and development services.

    Thursday, September 5, 2013 12:53 AM
    Moderator
  • I changed some parameters and now i have:

    Connection Status Device connected 
    Current Configuration 0 
    Speed High (480 Mbit/s) 
    Device Address 1 
    Number Of Open Pipes 0 
    
    Device Descriptor MisterBlack
    Offset Field Size Value Description 
    0 bLength 1 12h  
    1 bDescriptorType 1 01h Device 
    2 bcdUSB 2 0200h USB Spec 2.0 
    4 bDeviceClass 1 02h CDC Control 
    5 bDeviceSubClass 1 00h  
    6 bDeviceProtocol 1 00h  
    7 bMaxPacketSize0 1 40h 64 bytes 
    8 idVendor 2 0E05h  
    10 idProduct 2 0010h  
    12 bcdDevice 2 0001h 0.01 
    14 iManufacturer 1 01h "Eos S.r.l." 
    15 iProduct 1 02h "MisterBlack" 
    16 iSerialNumber 1 03h "00000000-0000-0000-0000-000000000000" 
    17 bNumConfigurations 1 01h  
    
    Device Qualifier Descriptor 
    Offset Field Size Value Description 
    0 bLength 1 0Ah  
    1 bDescriptorType 1 06h Device Qualifier 
    2 bcdUSB 2 0200h USB Spec 2.0 
    4 bDeviceClass 1 02h CDC Control 
    5 bDeviceSubClass 1 00h  
    6 bDeviceProtocol 1 00h  
    7 bMaxPacketSize0 1 40h 64 bytes 
    8 bNumConfigurations 1 01h  
    9 bReserved 1 00h  
    
    Configuration Descriptor 1 Self Powered
    Offset Field Size Value Description 
    0 bLength 1 09h  
    1 bDescriptorType 1 02h Configuration 
    2 wTotalLength 2 0020h  
    4 bNumInterfaces 1 01h  
    5 bConfigurationValue 1 01h  
    6 iConfiguration 1 00h  
    7 bmAttributes 1 C0h Self Powered 
     4..0: Reserved  ...00000   
     5: Remote Wakeup  ..0.....  No 
     6: Self Powered  .1......  Yes 
     7: Reserved (set to one)
    (bus-powered for 1.0)  1.......   
    8 bMaxPower 1 00h 0 mA 
    
    Interface Descriptor 0/0 CDC Data, 2 Endpoints
    Offset Field Size Value Description 
    0 bLength 1 09h  
    1 bDescriptorType 1 04h Interface 
    2 bInterfaceNumber 1 00h  
    3 bAlternateSetting 1 00h  
    4 bNumEndpoints 1 02h  
    5 bInterfaceClass 1 0Ah CDC Data 
    6 bInterfaceSubClass 1 00h  
    7 bInterfaceProtocol 1 00h  
    8 iInterface 1 00h  
    
    Endpoint Descriptor 81 1 In, Interrupt
    Offset Field Size Value Description 
    0 bLength 1 07h  
    1 bDescriptorType 1 05h Endpoint 
    2 bEndpointAddress 1 81h 1 In 
    3 bmAttributes 1 03h Interrupt 
     1..0: Transfer Type  ......11  Interrupt 
     7..2: Reserved  000000..   
    4 wMaxPacketSize 2 0200h 512 bytes 
    6 bInterval 1 00h  
    
    Endpoint Descriptor 02 2 Out, Bulk, 512 bytes
    Offset Field Size Value Description 
    0 bLength 1 07h  
    1 bDescriptorType 1 05h Endpoint 
    2 bEndpointAddress 1 02h 2 Out 
    3 bmAttributes 1 02h Bulk 
     1..0: Transfer Type  ......10  Bulk 
     7..2: Reserved  000000..   
    4 wMaxPacketSize 2 0200h 512 bytes 
    6 bInterval 1 00h  
    
    Other Speed Configuration Descriptor 1 Self Powered
    Offset Field Size Value Description 
    0 bLength 1 09h  
    1 bDescriptorType 1 07h Other Speed Configuration 
    2 wTotalLength 2 0020h  
    4 bNumInterfaces 1 01h  
    5 bConfigurationValue 1 01h  
    6 iConfiguration 1 00h  
    7 bmAttributes 1 C0h Self Powered 
     4..0: Reserved  ...00000   
     5: Remote Wakeup  ..0.....  No 
     6: Self Powered  .1......  Yes 
     7: Reserved (set to one)
    (bus-powered for 1.0)  1.......   
    8 bMaxPower 1 00h 0 mA 
    
    Interface Descriptor 0/0 CDC Data, 2 Endpoints
    Offset Field Size Value Description 
    0 bLength 1 09h  
    1 bDescriptorType 1 04h Interface 
    2 bInterfaceNumber 1 00h  
    3 bAlternateSetting 1 00h  
    4 bNumEndpoints 1 02h  
    5 bInterfaceClass 1 0Ah CDC Data 
    6 bInterfaceSubClass 1 00h  
    7 bInterfaceProtocol 1 00h  
    8 iInterface 1 00h  
    
    Endpoint Descriptor 81 1 In, Interrupt
    Offset Field Size Value Description 
    0 bLength 1 07h  
    1 bDescriptorType 1 05h Endpoint 
    2 bEndpointAddress 1 81h 1 In 
    3 bmAttributes 1 03h Interrupt 
     1..0: Transfer Type  ......11  Interrupt 
     7..2: Reserved  000000..   
    4 wMaxPacketSize 2 0040h 64 bytes 
    6 bInterval 1 00h  
    
    Endpoint Descriptor 02 2 Out, Bulk, 64 bytes
    Offset Field Size Value Description 
    0 bLength 1 07h  
    1 bDescriptorType 1 05h Endpoint 
    2 bEndpointAddress 1 02h 2 Out 
    3 bmAttributes 1 02h Bulk 
     1..0: Transfer Type  ......10  Bulk 
     7..2: Reserved  000000..   
    4 wMaxPacketSize 2 0040h 64 bytes 
    6 bInterval 1 00h  

    but i receive the same error and the same USB data.

    Why the device become low-speed devica after the installation of the driver?????


    SteMMo


    • Edited by SteMMo Thursday, September 5, 2013 10:38 AM
    Thursday, September 5, 2013 9:04 AM
  • Hi,

    i modified the driver to return the CDC desctiptors.

    Now the device is recognized and the PC loads the virtual serial port without problems.

    When i open the serial port on the PC i see on the serial log the error:

    PID:00400002 TID:0569001A Unrecognized Serial class bRequest -> 0xa1
    PID:00400002 TID:0569001A Unknown: DEBUGCHK failed in file c:\wince700\platform\misterblack\src\drivers\usbotgserialdevice\usbfndrv.cpp at line 1370 
      KdTrap: JIT debugging requested, waiting for OEM selection
      KdTrap: JIT debugging accepted
    
    !KITLRegisterDfltClient called before KitlInit. KITLGlobalState=00000080
    PID:00400002 TID:0569001A DEBUG_BREAK @ee11ac8c Ignored.
    PID:00400002 TID:0569001A Unknown: DEBUGCHK failed in file c:\wince700\platform\misterblack\src\drivers\usbotgserialdevice\usbfndrv.cpp at line 1372 
      KdTrap: JIT debugging requested, waiting for OEM selection
      KdTrap: JIT debugging accepted
    
    !KITLRegisterDfltClient called before KitlInit. KITLGlobalState=00000080
    PID:00400002 TID:0569001A DEBUG_BREAK @ee11acc4 Ignored.

    The error is near the check 

        if (udr.bmRequestType == 
                (USB_REQUEST_CLASS | USB_REQUEST_FOR_INTERFACE | USB_REQUEST_HOST_TO_DEVICE) ) { 
    
    and actually 0xa1 means USB_REQUEST_DEVICE_TO_HOST !

    does it means the wrong direction??

    Any idea?


    SteMMo

    Monday, September 16, 2013 4:18 PM