LPC54S018 WinUSB driver signing

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC54S018 WinUSB driver signing

Jump to solution
1,399 Views
VegiTech
Contributor II

Not sure which forum to post this in:

Has anyone had any luck signing the winusb.sys driver for their LPC USB based product?

Thank-you.

Tags (4)
0 Kudos
1 Solution
1,236 Views
Xu_Zhang
NXP Employee
NXP Employee

hi,VegiTech
I am based on the LPC54S018 development board and lpcxpresso54s018_dev_printer_virtual_plain_text_freertos to do the example, you can refer to it, I hope this can be helpful to you.

BR

Xu Zhang

View solution in original post

0 Kudos
7 Replies
1,300 Views
VegiTech
Contributor II

Hi Xu,

We are having problems implementing this for our processor LPC54S018J2MET180. Can you provide information on how to implement for this processor?

Thank you,

Alan

 

0 Kudos
1,339 Views
VegiTech
Contributor II

Hi Xu,

We are using the example specified as our starting example. If this information is implemented, will windows load the driver without the need of driver signing for production release?

Thank you,

Alan Howard

0 Kudos
1,321 Views
Xu_Zhang
NXP Employee
NXP Employee

Windows can load the WinUSB driver without signing, because WinUSB is part of the redistributable component of WDK, which is completely possible to do.

Xu Zhang

0 Kudos
1,346 Views
Xu_Zhang
NXP Employee
NXP Employee

Hi, VegiTech
Here are some suggestions,I use LPC54S018 and SDK lpcxpresso54114_dev_printer_virtual_plain_text_bm example to implement WinUSB driver device.

Xu_Zhang_0-1692002885469.png

The implementation method is as follows:

To meet the requirements of WinUSB, you need to modify the MCUXpressoSDK USB Stack to meet the following three items:

1. In response to the string descriptor request, return the OS string descriptor with index 0xEE

#define bMS_VendorCode ( 0xA0 )
//"MSFT100" : index : 0xEE : langId : 0x0000
uint8_tOS_StringDescritpor[ ] =
{0x12, 0x03, 'M', 0, 'S', 0, 'F', 0, 'T', 0, '1', 0, '0', 0, '0', 0, bMS_VendorCode, 0 };
When processing a USB string descriptor request, the OS_StringDescritpor response string descriptor is returned when the string index wIndex==0xEE. When this descriptor is returned, the USB device is recognized as a WCID device.
Note that Windows will only send a request for the OS string descriptor, indexed 0xEE, after the USB device is connected for the first time. The OS descriptor is stored in the registry. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\UsbFlags\VVVVPPPPRRRR(VVVV-VID; PPPP - PID; RRRR - Version number). If a device cannot be correctly identified as WCID during development, delete the registry key corresponding to the USB device, and then uninstall the USB device in Device Manager so that new device insertion behavior is always available.

2. Respond to the VendorRequest request provided by the vendor. The bRequest request number is the bMS_VendorCode value defined by the OS character descriptor (0xA0 in this routine). If bRequest== 0xA&&Windex == 0x04, the WCID Extended compatibility feature descriptor: "WINUSB" is returned.
//"WINUSB\0\0" : wIndex : 0x0004
uint8_tWINUSB_ExtendedCompatId_Descritpor[ ] =
{
0x28,0x00, 0x00, 0x00, // dwLength
0x00,0x01, // bcdVersion
0x04,0x00, // wIndex
0x01, // bCount
0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Reserved[7]
0x00, //bFirstInterfaceNumber
0x01, // RESERVED ( 0x01 )
'W','I', 'N', 'U', 'S', 'B', 0x00, 0x00, //compactiableID[8]
0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // subCompactiableID[8]
0x00,0x00, 0x00, 0x00, 0x00, 0x00 // Reserved[6]
};
3. Respond to the VendorRequest defined by the vendor. The bRequest request number is the bMS_VendorCode value defined by the OS character descriptor (0xA0 in this routine). If bRequest== 0xA&&Windex == 0x05, the device interface GUID descriptor: WINUSB_ExtendedProperty_InterfaceGUID_Descritpor is returned. This descriptor is used to distinguish between different WinUSB devices.
//L"DeviceInterfaceGUID" : wIndex = 0x0005
// L"{1D4B2365-4749-48EA-B38A-7C6FDDDD7E26}"
//
uint8_tWINUSB_ExtendedProperty_InterfaceGUID_Descritpor[ ] =
{
///////////////////////////////////////
/// WCID property descriptor
///////////////////////////////////////
0x8e, 0x00, 0x00, 0x00, /* dwLength */
0x00, 0x01, /* bcdVersion */
0x05, 0x00, /* wIndex */
0x01, 0x00, /* wCount */
///////////////////////////////////////
/// registry propter descriptor
///////////////////////////////////////
0x84, 0x00, 0x00, 0x00, /* dwSize */
0x01, 0x00, 0x00, 0x00, /*dwPropertyDataType */
0x28, 0x00, /* wPropertyNameLength */
/* DeviceInterfaceGUID */
'D', 0x00, 'e', 0x00, 'v', 0x00, 'i',0x00, /* wcName_20 */
'c', 0x00, 'e', 0x00, 'I', 0x00, 'n',0x00, /* wcName_20 */
't', 0x00, 'e', 0x00, 'r', 0x00, 'f',0x00, /* wcName_20 */
'a', 0x00, 'c', 0x00, 'e', 0x00, 'G',0x00, /* wcName_20 */
'U', 0x00, 'I', 0x00, 'D', 0x00, 0x00,0x00, /* wcName_20 */
0x4e, 0x00,0x00, 0x00, /* dwPropertyDataLength */
/* {7D9ADCFC-E570-4B38-BF4E-8F81F68964E0}*/
'{', 0x00, '7', 0x00, 'D', 0x00,'9', 0x00, /* wcData_39 */
'A', 0x00, 'D', 0x00, 'C', 0x00,'F', 0x00, /* wcData_39 */
'C', 0x00, '-',0x00, 'E', 0x00, '5', 0x00, /*wcData_39 */
'7', 0x00, '0', 0x00, '-', 0x00, '4',0x00, /* wcData_39 */
'B', 0x00, '3', 0x00, '8', 0x00, '-',0x00, /* wcData_39 */
'B', 0x00, 'F', 0x00, '4', 0x00, 'E', 0x00, /* wcData_39 */
'-', 0x00, '8', 0x00, 'F', 0x00, '8',0x00, /* wcData_39 */
'1', 0x00, 'F', 0x00, '6', 0x00, '8',0x00, /* wcData_39 */
'9', 0x00, '6', 0x00, '4', 0x00, 'E',0x00, /* wcData_39 */
'0', 0x00, '}', 0x00, 0x00, 0x00, /* wcData_39 */
4. Modify the MCUXpressoSDK USB routine to support WinUSB.
NXP's MCUXpresso SDK USB routine dev_printer_virtual_plain_text_bm was originally a printer routine that contained two Bulk transfer endpoints. Support for WinUSB can be quickly modified based on this routine.

Modify the following macro definition to change the printer device macro definition to the user-defined protocol WinUSB device.
#defineUSB_DEVICE_DEMO_BCD_VERSION (0x0200U)

#defineUSB_DEVICE_STRING_COUNT (4U)

#defineUSB_PRINTER_CLASS (0xFFU)
#defineUSB_PRINTER_SUBCLASS (0xFFU)
#defineUSB_PRINTER_PROTOCOL (0x00U)

#defineUSB_DEVICE_CONFIG_PRINTER_CLASS_CODE (0xFFU)
Add VendorRequest to the USB protocol stack description request:
/* Getdevice string descriptor request */
usb_status_tUSB_DeviceGetStringDescriptor(usb_device_handle handle,
usb_device_get_string_descriptor_struct_t*stringDescriptor)
{
uint8_t languageIndex = 0U;
uint8_t stringIndex = USB_DEVICE_STRING_COUNT;

if (stringDescriptor->stringIndex == 0U)
{
stringDescriptor->buffer = (uint8_t*)g_UsbDeviceLanguageList.languageString;
stringDescriptor->length =g_UsbDeviceLanguageList.stringLength;
}else if(stringDescriptor->stringIndex == 0xEE) // OSString
{
stringDescriptor->buffer = (uint8_t*)OS_StringDescritpor;
stringDescriptor->length =OS_StringDescritpor[0];
}else
{
…………………………………………
…………………………………………
}
return kStatus_USB_Success;
}

staticusb_status_t USB_DeviceCallback(usb_device_handle handle, uint32_t event, void*param)
{
…………………………………………
switch (event)
{
…………………………………………
…………………………………………
case kUSB_DeviceEventVendorRequest:
if (param)
{
status =USB_HandleVendorRequest(handle, event, param);
}
break;
default:
break;
}
return status;
}

usb_status_tUSB_HandleVendorRequest(usb_device_handle handle, uint32_t event, void *param)
{
usb_status_t error = kStatus_USB_Success;
uint8_t* pFlash;

/* Handle the vendor specific request. */
usb_device_control_request_struct_t*controlRequest = (usb_device_control_request_struct_t *)param;

if (controlRequest->setup->bRequest== WCID_VENDOR_CODE)
{
switch(controlRequest->setup->wIndex)
{
case 4:
controlRequest->buffer =(uint8_t*)WINUSB_ExtendedCompatId_Descritpor;
controlRequest->length =USB_LEN_OS_FEATURE_DESC;
break;
case 5:
controlRequest->buffer =(uint8_t*)WINUSB_ExtendedProperty_InterfaceGUID_Descritpor;
controlRequest->length =USB_LEN_OS_PROPERTY_DESC;
break;
default:
error = kStatus_USB_InvalidRequest;
break;
}
}
return error;
}
After responding correctly to the above three descriptor requests, you can successfully enumerate the WinUSB device. In Windows Device Manager you can see that the WinUSB device is working properly:

The code is attached.

BR

Xu Zhang

0 Kudos
1,289 Views
VegiTech
Contributor II

Hi Xu,

We were having issues getting this to work. Then I noticed we were using the lite version of the example. We are moving to the FreeRTOS version of the example (lpcxpresso54s018_dev-printer_virtual_plain_text_freertos). Any tips on getting this to work with the FreeRTOS version?

Thank you,

Alan

 

0 Kudos
1,237 Views
Xu_Zhang
NXP Employee
NXP Employee

hi,VegiTech
I am based on the LPC54S018 development board and lpcxpresso54s018_dev_printer_virtual_plain_text_freertos to do the example, you can refer to it, I hope this can be helpful to you.

BR

Xu Zhang

0 Kudos
1,216 Views
VegiTech
Contributor II

Thank you, they got it working.

0 Kudos