Why CDC Serial Device installation fails on Windows Vista and 7 ?

Post
chinzei
Super Member
2010/03/26 05:54:59
Because of Microchip's INF file bug, you may succeed or fail on installation of CDC device driver to Vista and 7 boxes.

Version of the stack and INF files with this problem

Microchip Application Libraries v2010-02-09 (v2.6a)
http://ww1.microchip.com/downloads/en/devicedoc/MCHP_App_%20Lib%20v2010_02_09_Installer.zip

C:\Microchip Solutions\USB Device - CDC - Basic Demo\inf\mchpcdc.inf
C:\Microchip Solutions\USB Device - CDC - Serial Emulator\inf\win2k_winxp\mchpcdc.inf
C:\Microchip Solutions\USB Device - Composite - MSD + CDC\inf - Composite Device\mchp-MSD+CDC.inf
C:\Microchip Solutions\USB Tools\USB CDC Serial Demo\inf\mchpcdc.inf


Temporary workaround for Windows Vista and 7

Manually copy usbser.sys from an archive on your PC to drivers folder, if you fail to install.

These archive files open when you click it on an explorer window. (*1)
To see these folders in C:\Windows folder, you may set "folder options"

Windows Vista (x86 32bit)
- Source of usbser.sys: C:\Windows\System 32\DriverStore\FileRepository\mdmcpq.inf_e99692b4 (archive file)
- Destination to copy: C:\Windows\System 32\drivers

Windows Vista (x64 64bit)
- Source of usbser.sys: C:\Windows\System 32\DriverStore\FileRepository\mdmcpq.inf_ec18f765 (archive file)
- Destination to copy: C:\Windows\System 32\drivers

Windows 7 (x86 32bit)
- Source of usbser.sys: C:\Windows\System 32\DriverStore\FileRepository\mdmcpq.inf_x86_neutral_1b9e317b2982c778 (archive file)
- Destination to copy: C:\Windows\System 32\drivers

Windows 7 (x64 64bit)
- Source of usbser.sys: C:\Windows\System 32\DriverStore\FileRepository\mdmcpq.inf_amd64_neutral_9bb71004e7b8f7ae (archive file)
- Destination to copy: C:\Windows\System 32\drivers



Bug fix of microchip INF files

mchpcdc.inf (and its derivatives)

[DestinationDirs]
FakeModemCopyFileSection=12 ; <------ add this line
DefaultDestDir=12

[DriverInstall.nt]
include=mdmcpq.inf
;; CopyFiles = DriverCopyFiles.nt ; <------ wrong one: reference to this INF file
CopyFiles = FakeModemCopyFileSection ; <------ right one: reference to a section in mdmcpq.inf
AddReg=DriverInstall.nt.AddReg

;; [DriverCopyFiles.nt] ; <------ delete these lines
;; usbser.sys,,,0x20 ; <------



Background of the bug

a) Source location of usbser.sys
There is no difference on the CDC (usbser.sys) INF file among Win XP, Vista and 7
The major difference lies in the pre-installation of usbser.sys to the driver folder on each PC.

Most of Win XP pre-install still have usbser.sys in the driver folder,
For Vista and 7, usbser.sys is not installed there, but it is held in the installation archive.
When INF [SourceDisk] section points to this archive correctly, usbser.sys is copied from the archive.

MS has warned to us not to refer usbser.sys source location directly on our custom INF file.
Instead, they suggest to "include" mdmcpq.inf AND refer to "FakeModemCopyFileSection" (awful naming sense) section, because mdmcpq.inf of each pre-installation knows the right place on which the original usbser.sys exists (*2).

Just writing "include = mdmcpq.inf" does nothing. Refer to the section, "FakeModemCopyFileSection", correctly.

Current version of Microchip INF file works just when usbser.sys has been already copied to the driver folder manually, or by another right INF file.


b) Driver signing on 64bit Windows
Above bug fix to INF file breaks driver signing of the installation package.
Broken sign prevents us from installation and use on 64bit Windows, unless we apply test-mode power up.
To complete the fix, we have to wait for Microchip until they get driver signing again.



(*1) there is no space on the folder name, "System 32". but without the space, this forum engine rejects my post

(*2) "How to use or to reference the Usbser.sys driver from universal serial bus (USB) modem .inf files"
http://support.microsoft.com/kb/837637

Tsuneo
post edited by chinzei - 2010/03/26 06:10:08
xiaofan
Super Member
RE: Why CDC Serial Device installation fails on Windows Vista and 7 ? 2010/03/26 06:45:57

ORIGINAL: chinzei
b) Driver signing on 64bit Windows
Above bug fix to INF file breaks driver signing of the installation package.
Broken sign prevents us from installation and use on 64bit Windows, unless we apply test-mode power up.
To complete the fix, we have to wait for Microchip until they get driver signing again.


Is this true? I know the fix will break the WHQL. But usbser.sys supposedly is already digitally signed (KMCS, Kernel-Mode Code Signing) by Microsoft. So I assume you will get a warning, but you can still install the driver.

It is similar to drivers using WinUSB. You can use your own INF file, the whole driver package has no WHQL, so you will receive a warning, but you can still install it.

Sorry I can not test this as my machine is a 32bit Windows Vista desktop.
mzoran
Super Member
RE: Why CDC Serial Device installation fails on Windows Vista and 7 ? 2010/03/26 12:01:54
I do have 64bit Vista now, so maybe I can try things.

I can confirm like you said that INF files for presigned driver packages like WinUSB only cause a warning popup instead of failing to install.

I know this is at least true for INFs, but it may also apply to kernel mode drivers as well. It's possible using tools in the WinDDK to sign your own driver packages and at least in the cases I've tried you don't even get the warning popup. The process involves creating a self signed certificate and installing it as a trusted root and a trusted publisher. You run the tool signability to generate the cat, then run signtool to sign the catalog.

This process is documented in the WinDDK, albit in a very convoluted way. It's meant to be used by test organizations to distribute test binaries and corporations to distribute custom drivers within their org( kernel mode filter drivers for example ). So you can use this process if what you are working on is for internal use only/ in the development stage.

Also, as found in the WinDDK. Microsoft has two ways to get your driver package signed.
1. You go through the WHQL process and get it signed by MS. The user gets no pops or warnings in this case.
2. You get your package signed by a trusted security authority( sort of like verisign ) by paying them a fee. In this case, the user gets a popup asking if you trust your organization. I noticed this is the process being taken by small distribution software such as my hardware USB analyzer and a virtual drive DVD drive emulator that I use.

My point is that options are available for hobbiest, student projects, and internal development without paying fees for every little change. I personally, would not recommend using usbser.sys in a commercial product though.
post edited by mzoran - 2010/03/26 12:06:13
Re:Why CDC Serial Device installation fails on Windows Vista and 7 ? 2010/07/31 11:59:30
I am seeing this issue.  The changes you show are only in the windows 2000 32 bit area

Are changes required in Vista 64 bit ?

This is the one in the installer:

;  Vista-64bit Sections
;------------------------------------------------------------------------------

[DriverInstall.NTamd64]
include=mdmcpq.inf
CopyFiles=DriverCopyFiles.NTamd64
AddReg=DriverInstall.NTamd64.AddReg

[DriverCopyFiles.NTamd64]
%DRIVERFILENAME%.sys,,,0x20

Thanks

Geoff


post edited by microchip@proaa.com - 2010/07/31 12:00:37
Okrad
New Member
Re:Why CDC Serial Device installation fails on Windows Vista and 7 ? 2011/02/22 04:16:00
Hi, maybe this is not perfect place for this question, but I didn't want to start new thread and this is 100% related with thread name.  I am new to USB, and few months ago I started CDC + LibUSB project. PIC 32MX..  and windows XP (32-sp3) as a host. I used Microchip examples CDC and LibUSB as start point and finally got everything working with composite device ( generic USB interface 0, and IAD for six CDC ).
There is sample of descriptor:
ROM USB_DEVICE_DESCRIPTOR device_dsc=
{
    0x12,    // Size of this descriptor in bytes
    USB_DESCRIPTOR_DEVICE,                // DEVICE descriptor type
    0x0200,                 // USB Spec Release Number in BCD format
//    0x00,                   // Class Code
//    0x00,                   // Subclass code
    0xEF,                   // Class Code
    0x02,                   // Subclass code
    0x01,                   // Protocol code when AID is used
    //0x00,                   // Protocol code
    USB_EP0_BUFF_SIZE,          // Max packet size for EP0, see usb_config.h
    0x04D8,                 // Vendor ID
    0x004F,                 // Product ID: Mouse in a circle fw demo
    0x0001,                 // Device release number in BCD format
    0x01,                   // Manufacturer string index
    0x02,                   // Product string index
    0x00,                   // Device serial number string index
    0x01                    // Number of possible configurations
};


/* Configuration 1 Descriptor */
ROM BYTE configDescriptor1[]={
    /* Configuration Descriptor */
    0x09,//sizeof(USB_CFG_DSC),    // Size of this descriptor in bytes
    USB_DESCRIPTOR_CONFIGURATION,                // CONFIGURATION descriptor type
    //0xAC,0x01,
    0x84,0x01,
    13,                      // Number of interfaces in this cfg
    1,                      // Index value of this configuration
    2,                      // Configuration string index
    _DEFAULT | _SELF,               // Attributes, see usb_device.h
    50,                     // Max power consumption (2X mA)


    /* Interface Descriptor */
    0x09,//sizeof(USB_INTF_DSC),   // Size of this descriptor in bytes
    USB_DESCRIPTOR_INTERFACE,               // INTERFACE descriptor type
    0,                      // Interface Number
    0,                      // Alternate Setting Number
    2,                      // Number of endpoints in this intf
    0xFF,                   // Class code
    0xFF,                   // Subclass code
    0xFF,                   // Protocol code
    0,                      // Interface string index
        /* Endpoint Descriptor */
    0x07,                       /*sizeof(USB_EP_DSC)*/
    USB_DESCRIPTOR_ENDPOINT,    //Endpoint Descriptor
    _EP01_OUT,                  //EndpointAddress
    _BULK,                       //Attributes
    USBGEN_EP_SIZE,0x00,        //size
    1,                         //Interval


    0x07,                       /*sizeof(USB_EP_DSC)*/
    USB_DESCRIPTOR_ENDPOINT,    //Endpoint Descriptor
    _EP01_IN,                   //EndpointAddress
    _BULK,                       //Attributes
    USBGEN_EP_SIZE,0x00,        //size
    1,                          //Interval


    // Interface Association Descriptor
    0x08,                                       // sizeof(Tinterface_association_descriptor),  // bLength
    0x0B,                                       // DSC_TYPE_IAD  bDescriptorType = 11
    0x01,                                       // bFirstInterface
    0x02,                                       // bInterfaceCount
    0x02,                                       // bFunctionClass (Communication Class)
    0x02,                                       // bFunctionSubClass (Abstract Control Model)
    0x01,                                       // bFunctionProcotol (V.25ter, Common AT commands)
    0x00,                                       // iInterface


Enumeration was OK (checked on XP using USBlyser) an I modified inf file for CDC (add &MI_01) extension to this line
%DESCRIPTION%=DriverInstall, USB\VID_04D8&PID_004F&MI_01
And everything was OK I was able to use theese ports (two of them was tested) with no problem. Also I used LibUSB wizrd to create inf file for generic interface 0. And it was next->next->next... operation, everything run smoothly.


After that I change my developer PC with one that use WIN 7 x64. I tried to use same inf files without success. It seems to me that it is some problem that my device which is shown as composite device in device manager is not enumerated correctly. When I use lines with additional &MI_00 at %DESCRIPTION%=DriverInstall, USB\VID_04D8&PID_004F section i have a message that inf file does not contains a valid driver (also tested with win7 32-bit). If I use %DESCRIPTION%=DriverInstall, USB\VID_04D8&PID_004F than device is recognized and it is possible to start driver installation, but BSOD is output from that process (think that is expected because interfaces are not enumerated correctly). One more thing, I tried to see if there is any problem with USBlyser but everything seems to be OK. Also, I tried device on ubuntu for I while and looks that enumeration was OK ( I wasn't make any further tests)


So I am stacked here and I will use old development PC running on XP for now but I would be thankful if someone can help me to solve this issue.

Okrad
New Member
Re:Why CDC Serial Device installation fails on Windows Vista and 7 ? 2011/02/24 08:58:15
OK just an update if someone would have similar problem.

    // Interface Association Descriptor
    0x08,                                       // sizeof(Tinterface_association_descriptor),  // bLength
    0x0B,                                       // DSC_TYPE_IAD  bDescriptorType = 11
    0x01,                                       // bFirstInterface
    0x01,                                       // bInterfaceCount
    COMM_INTF,                                  // bInterfaceClass of the first interface
    ABSTRACT_CONTROL_MODEL,                     // bInterfaceSubclass of the first interface
    V25TER,                                     // bInterfaceProtocol of the first interface
    0x00

 
    // Interface Descriptor
    0x09,//sizeof(USB_INTF_DSC),                // Size of this descriptor in bytes
    USB_DESCRIPTOR_INTERFACE,                   // INTERFACE descriptor type
    CDC_COMM1_INTF_ID,                          // Interface Number
    0x00,                                       // Alternate Setting Number
    0x03,                                       // Number of endpoints in this intf
    COMM_INTF,                                  // Class code
    ABSTRACT_CONTROL_MODEL,                     // Subclass code
    V25TER,                                     // Protocol code
    0x00,                                       // Interface string index

    // CDC Class-Specific Descriptors
    sizeof(USB_CDC_HEADER_FN_DSC), CS_INTERFACE, DSC_FN_HEADER, 0x10,0x01,
    sizeof(USB_CDC_ACM_FN_DSC), CS_INTERFACE, DSC_FN_ACM, USB_CDC_ACM_FN_DSC_VAL,
    sizeof(USB_CDC_UNION_FN_DSC), CS_INTERFACE, DSC_FN_UNION, CDC_COMM1_INTF_ID, CDC_DATA1_INTF_ID,
    sizeof(USB_CDC_CALL_MGT_FN_DSC), CS_INTERFACE, DSC_FN_CALL_MGT, 0x00, CDC_DATA1_INTF_ID,

    // Endpoint Descriptor
    0x07,                                       //sizeof(USB_EP_DSC)
    USB_DESCRIPTOR_ENDPOINT,                    //Endpoint Descriptor
    _EP02_IN,                                   //EndpointAddress
    _INTERRUPT,                                 //Attributes
    0x08,0x00,                                  //size
    0x02,                                       //Interval
       
    // Endpoint Descriptor
    0x07,                                       //sizeof(USB_EP_DSC)
    USB_DESCRIPTOR_ENDPOINT,                    //Endpoint Descriptor
    _EP03_OUT,                                  //EndpointAddress
    _BULK,                                      //Attributes
    CDC_DATA_IN_EP_SIZE,0x00,                   //size
    0x00,                                       //Interval

    // Endpoint Descriptor
    0x07,                                       //sizeof(USB_EP_DSC)
    USB_DESCRIPTOR_ENDPOINT,                    //Endpoint Descriptor
    _EP03_IN,                                   //EndpointAddress
    _BULK,                                      //Attributes
    CDC_DATA_IN_EP_SIZE,0x00,                   //size
    0x00,               
 

This is IAD configuration which is OK. This means that for CDC 3 endpoints and one interface are used.

Previous one that I was using had 3 endpoints and TWO interfaces (additional interface descriptor for Data EP, this is solution that is used in some project that I have seen so I used it before this issue). It works fine with XP but no way to make it works on Win7.

I don't know what exactly causes this issue but I am for now satisfied with this solution.