USB Driver Installation Issue for Microcontroller using Custom INF

3

I'm working with the NXP LPC1788 microcontroller and I'm trying to create a driver on the host computer to communicate with it via USB. I believe that I've managed to get the device handling standard USB requests properly (the PC is able to read the string descriptors properly).

I'm having trouble writing a sample USB driver and installing it for the device, though. I'm working with Microsoft Visual Studio 2013. My steps were:

  • Creating a WinUSB Application, which produces a "Driver" and "Driver Package" project.

  • Modifying the generated INF file to use my device's VID and PID.

  • Building the projects - both build successfully. The output folder contains an INF file, a catalog file and WdfCoinstaller01011.dll.

  • Plugging in the microcontroller via USB, going to Device ManagerUpdate Driver Software..., browsing to the folder containing the INF file and selecting it.

  • This causes the following screen to appear:

  • I select "Install this driver software anyway". After a short while, it presents this screen:

My INF file is given below:

;
; TestCubeDriver.inf
;
; Installs WinUsb
;

[Version]
Signature = "$Windows NT$"
Class     = USBDevice
ClassGUID = {88BAE032-5A81-49f0-BC3D-A4FF138216D6}
Provider = %ManufacturerName%
CatalogFile=TestCubeDriver.cat
DriverVer=04/16/2014,15.55.4.44

; ========== Manufacturer/Models sections ===========

[Manufacturer]
%ManufacturerName% = Standard,NTamd64

[Standard.NTamd64]
%DeviceName% =USB_Install, USB\VID_0483&PID_5720

; ========== Class definition ===========

[ClassInstall32]
AddReg = ClassInstall_AddReg

[ClassInstall_AddReg]
HKR,,,,%ClassName%
HKR,,NoInstallClass,,1
HKR,,IconPath,%REG_MULTI_SZ%,"%systemroot%\system32\setupapi.dll,-20"
HKR,,LowerLogoVersion,,5.2

; =================== Installation ===================

[USB_Install]
Include=winusb.inf
Needs=WINUSB.NT

[USB_Install.Services]
Include=winusb.inf
AddService=WinUsb,0x00000002,WinUsb_ServiceInstall

[WinUsb_ServiceInstall]
DisplayName     = %WinUsb_SvcDesc%
ServiceType     = 1
StartType       = 3
ErrorControl    = 1
ServiceBinary   = %12%\WinUSB.sys

[USB_Install.HW]
AddReg=Dev_AddReg

[Dev_AddReg]
; By default, USBDevice class uses iProduct descriptor to name the device in
; Device Manager on Windows 8 and higher.
; Uncomment for this device to use %DeviceName% on Windows 8 and higher:
;HKR,,FriendlyName,,%DeviceName%
HKR,,DeviceInterfaceGUIDs,0x10000,"{fcb251a5-6a1f-4e5b-9df8-e8de91d04cfe}"

[USB_Install.CoInstallers]
AddReg=CoInstallers_AddReg
CopyFiles=CoInstallers_CopyFiles

[CoInstallers_AddReg]
HKR,,CoInstallers32,0x00010000,"WdfCoInstaller01011.dll,WdfCoInstaller"

[CoInstallers_CopyFiles]
WdfCoInstaller01011.dll

[DestinationDirs]
CoInstallers_CopyFiles=11

; ================= Source Media Section =====================

[SourceDisksNames]
1 = %DiskName%

[SourceDisksFiles]
WdfCoInstaller01011.dll=1

; =================== Strings ===================

[Strings]
ManufacturerName=""
ClassName="Universal Serial Bus devices"
DiskName="TestCubeDriver Installation Disk"
WinUsb_SvcDesc="WinUSB Driver"
DeviceName="TestCubeDriver Device"
REG_MULTI_SZ = 0x00010000

.

The relevant part of my setupapi.dev.log file is given here. The following kind of lines appeared multiple times in the log:

     sig:                               Key      = testcubedriver.inf
     sig:                               FilePath = C:\Windows\System32\DriverStore\Temp\{1bf7c0e3-30cb-6135-d9b8-7d1ac87a6c7c}\testcubedriver.inf
     sig:                               Catalog  = C:\Windows\System32\DriverStore\Temp\{1bf7c0e3-30cb-6135-d9b8-7d1ac87a6c7c}\TestCubeDriver.cat
!    sig:                               Verifying file against specific (valid) catalog failed! (0x800b0109)
!    sig:                               Error 0x800b0109: A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.

The following also appeared:

     ndv:                Installing device...
     dvi:                {DIF_INSTALLDEVICE} 09:58:11.087
     dvi:                     No class installer for 'TestCubeDriver Device'
     dvi:                     CoInstaller 1: Enter 09:58:11.087
     inf:                          Opened PNF: 'C:\Windows\INF\oem68.inf' ([strings])
!!!  dvi:                     CoInstaller 1: failed(0xe0000101)!
!!!  dvi:                     Error 0xe0000101: The required section was not found in the INF.
     dvi:                {DIF_INSTALLDEVICE - exit(0xe0000101)} 09:58:11.907
!!!  ndv:                Error(e0000101) installing device!

.

I use the following descriptors for my USB device:

/*----------------------------------------------------------------------------
 *      U S B  -  K e r n e l
 *----------------------------------------------------------------------------
 *      Name:    USBDESC.C
 *      Purpose: USB Descriptors
 *      Version: V1.10
 *----------------------------------------------------------------------------
 *      This software is supplied "AS IS" without any warranties, express,
 *      implied or statutory, including but not limited to the implied
 *      warranties of fitness for purpose, satisfactory quality and
 *      noninfringement. Keil extends you a royalty-free right to reproduce
 *      and distribute executable files created using this software for use
 *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
 *      else gives you the right to use this software.
 *
 *      Copyright (c) 2005-2009 Keil Software.
 *---------------------------------------------------------------------------*/
#include "lpc_types.h"
#include "usb.h"
#include "usbcore.h"
#include "usbhw.h"

/* USB Standard Device Descriptor */
const uint8_t USB_DeviceDescriptor[] = {
  USB_DEVICE_DESC_SIZE,              /* bLength */
  USB_DEVICE_DESCRIPTOR_TYPE,        /* bDescriptorType */
  WBVAL(0x0200), /* 2.00 */          /* bcdUSB */
  0xFF,                              /* bDeviceClass */
  0x00,                              /* bDeviceSubClass */
  0x00,                              /* bDeviceProtocol */
  USB_MAX_PACKET_SIZE,               /* bMaxPacketSize0 */
  WBVAL(0x0483),                     /* idVendor */
  WBVAL(0x5720),                     /* idProduct */
  WBVAL(0x0100), /* 1.00 */          /* bcdDevice */
  0x04,                              /* iManufacturer */
  0x30,                              /* iProduct */
  0x42,                              /* iSerialNumber */
  0x01                               /* bNumConfigurations */
};

/* USB Configuration Descriptor */
/*   All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
const uint8_t USB_ConfigDescriptor[] = {
/* Configuration 1 */
  USB_CONFIGURATION_DESC_SIZE,       /* bDescriptorType */
  USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
  WBVAL(                             /* wTotalLength */
    1*USB_CONFIGURATION_DESC_SIZE +
    1*USB_INTERFACE_DESC_SIZE     +
    2*USB_ENDPOINT_DESC_SIZE
  ),
  0x01,                              /* bNumInterfaces */
  0x01,                              /* bConfigurationValue */
  0x00,                              /* iConfiguration */
  USB_CONFIG_SELF_POWERED /*|*/      /* bmAttributes */
/*USB_CONFIG_REMOTE_WAKEUP*/,
  USB_CONFIG_POWER_MA(100),          /* bMaxPower */
/* Interface 0, Alternate Setting 0, MSC Class */
  USB_INTERFACE_DESC_SIZE,           /* bLength */
  USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */
  0x00,                              /* bInterfaceNumber */
  0x00,                              /* bAlternateSetting */
  0x02,                              /* bNumEndpoints */
  0xFF,                              /* bInterfaceClass */
  0x0,                               /* bInterfaceSubClass */
  0x0,                               /* bInterfaceProtocol */
  0x5C,                              /* iInterface */
/* Interrupt In Endpoint */
  USB_ENDPOINT_DESC_SIZE,            /* bLength */
  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
  USB_ENDPOINT_IN(2),                /* bEndpointAddress */
  USB_ENDPOINT_TYPE_INTERRUPT,       /* bmAttributes */
  WBVAL(0x0040),                     /* wMaxPacketSize */
  0xA,                               /* bInterval */
/* Interrupt Out Endpoint */
  USB_ENDPOINT_DESC_SIZE,            /* bLength */
  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
  USB_ENDPOINT_OUT(2),               /* bEndpointAddress */
  USB_ENDPOINT_TYPE_INTERRUPT,       /* bmAttributes */
  WBVAL(0x0040),                     /* wMaxPacketSize */
  0xA,                               /* bInterval */
/* Terminator */
  0                                  /* bLength */
};

/* USB String Descriptor (optional) */
const uint8_t USB_StringDescriptor[] = {
/* Index 0x00: LANGID Codes */
  0x04,                              /* bLength */
  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
  WBVAL(0x0409), /* US English */    /* wLANGID */
/* Index 0x04: Manufacturer */
  0x2C,                              /* bLength */
  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
  'A',0,
  'T',0,
  'P',0,
  ' ',0,
  'I',0,
  'n',0,
  'd',0,
  'u',0,
  's',0,
  't',0,
  'r',0,
  'i',0,
  'e',0,
  's',0,
  ' ',0,
  'G',0,
  'r',0,
  'o',0,
  'u',0,
  'p',0,
  ' ',0,
/* Index 0x30: Product */
  0x12,                              /* bLength */
  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
  'T',0,
  'e',0,
  's',0,
  't',0,
  'C',0,
  'u',0,
  'b',0,
  'e',0,
  ' ',0,
/* Index 0x42: Serial Number */
  0x1A,                              /* bLength */
  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
  'D',0,
  'E',0,
  'M',0,
  'O',0,
  '0',0,
  '0',0,
  '0',0,
  '0',0,
  '0',0,
  '0',0,
  '0',0,
  '0',0,
/* Index 0x5C: Interface 0, Alternate Setting 0 */
  0x0E,                              /* bLength */
  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
  'M',0,
  'e',0,
  'm',0,
  'o',0,
  'r',0,
  'y',0,
};
c
usb
microcontroller
lpc
winusb
asked on Stack Overflow Apr 17, 2014 by Tagc • edited Apr 17, 2014 by Tagc

2 Answers

2

I tried out the INF template that Daniel K suggested here with my own configurations:

;This .inf file is a modified version of the example INF provided
;in the Microsoft document:
;"How to Use WinUSB to Communicate with a USB Device"


[Version]
Signature = "$Windows NT$"
Class = USBDevices
ClassGuid= {88BAE032-5A81-49f0-BC3D-A4FF138216D6}
Provider = %MFGNAME%
DriverVer=04/17/2014,1.0.0.0
CatalogFile=winusb.cat    ;CAT file needed for a signed driver pacakage
;------------------------------------------------------------------------------
; ========== Manufacturer/Models sections ===========
;------------------------------------------------------------------------------
[Manufacturer]
%MFGNAME% = MyDevice_WinUSB,NTx86,NTamd64

;------------------------------------------------------------------------------
;  Vendor and Product ID Definitions
;------------------------------------------------------------------------------
; When developing your custom USB device, the VID and PID used in the PC side
; application program and the firmware on the microcontroller must match.
; Modify the below lines to use your VID and PID.  Use the format as shown below.
; Note: One INF file can be used for multiple devices with different VID and PIDs.
; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line.
; There is a maximum number of devices that can be supported per line however.
; If you append a large number of VID/PIDs to the end of the line, and get a:
; "The data area passed to a system call is too small." error when trying to install
; the INF, try removing some of the VIDs/PIDs.
;------------------------------------------------------------------------------
[MyDevice_WinUSB.NTx86]
%DESCRIPTION% =USB_Install, USB\VID_0483&PID_5720

[MyDevice_WinUSB.NTamd64]
%DESCRIPTION% =USB_Install, USB\VID_0483&PID_5720


;=========================================================================================
;ClassInstall32 and ClassInstall_AddReg sections used to make new device manager category.
;=========================================================================================
[ClassInstall32]
AddReg=ClassInstall_AddReg

[ClassInstall_AddReg]
HKR,,,,%DEVICEMANAGERCATEGORY%
HKR,,Icon,,"-20"


; =================== Installation ===================

[USB_Install]
Include=winusb.inf
Needs=WINUSB.NT

[USB_Install.Services]
Include=winusb.inf
AddService=WinUSB,0x00000002,WinUSB_ServiceInstall

[WinUSB_ServiceInstall]
DisplayName     = %WinUSB_SvcDesc%
ServiceType     = 1
StartType       = 3
ErrorControl    = 1
ServiceBinary   = %12%\WinUSB.sys

[USB_Install.Wdf]
KmdfService=WINUSB, WinUsb_Install

[WinUSB_Install]
KmdfLibraryVersion=1.11

[USB_Install.HW]
AddReg=Dev_AddReg

[Dev_AddReg]
HKR,,DeviceInterfaceGUIDs,0x10000,"{fcb251a5-6a1f-4e5b-9df8-e8de91d04cfe}"
;When editing the GUID (the big hex number with dashes inside the squiggly 
;braces), make sure to write the intended PC application to use the same GUID.
;Otherwise the application won't be able to find the USB device properly.

[USB_Install.CoInstallers]
AddReg=CoInstallers_AddReg
CopyFiles=CoInstallers_CopyFiles

[CoInstallers_AddReg]
HKR,,CoInstallers32,0x00010000,"WdfCoInstaller01011.dll,WdfCoInstaller",

[CoInstallers_CopyFiles]
;WinUSBCoInstaller2.dll
WdfCoInstaller01011.dll

[DestinationDirs]
CoInstallers_CopyFiles=11

; ================= Source Media Section =====================

[SourceDisksNames]
1 = %DISK_NAME%

[SourceDisksFiles]
WdfCoInstaller01011.dll=1

; =================== Strings ===================

[Strings]
MFGNAME="ATP Industries Group" ; ManufacturerName
DESCRIPTION="TestCube" ; DeviceName
WinUSB_SvcDesc="WinUSB Device"
DISK_NAME="TestCubeDriver Installation Disk" ; DiskName
DEVICEMANAGERCATEGORY="Universal Serial Bus devices" ; ClassName

My device driver installed successfully and Device Manager reports that the device is working properly. I tried running my application and it's able to find my device and retrieve details about it. It all works now, and I can finally start working on the application-side of things.

Edit: Even though it's all working now, I have no idea what was wrong with the original template - could anyone please explain to me why the second template works and not the first?

answered on Stack Overflow Apr 17, 2014 by Tagc • edited May 23, 2017 by Community
2

You're running 32-bit Windows, right? One reason the original file wouldn't work for you because it doesn't have a section for 32-bit drivers, it only has an NTamd64 section.

From the original file:

[Standard.NTamd64]
%DeviceName% =USB_Install, USB\VID_0483&PID_5720

From the new file, where MyDevice_WinUSB is analogous to Standard:

[MyDevice_WinUSB.NTx86]
%DESCRIPTION% =USB_Install, USB\VID_0483&PID_5720

[MyDevice_WinUSB.NTamd64]
%DESCRIPTION% =USB_Install, USB\VID_0483&PID_5720

The new file has an extra section that your old file didn't have.

answered on Stack Overflow Apr 17, 2014 by David Grayson

User contributions licensed under CC BY-SA 3.0