|
|
View previous topic :: View next topic |
Author |
Message |
rwskinner
Joined: 08 Dec 2006 Posts: 125 Location: Texas
|
HID device works on everything but Windows 10 |
Posted: Fri Jan 25, 2019 4:53 pm |
|
|
I have a Data acquisition card I built many moons ago that uses HID and a 18F4550. It also has a CDC Bootloader as well.
The Bootloader and HID works great on XP and Windows 7, but on Windows 10, only the CDC works.
When in bootloader mode, it comes up as a virtual serial port and works fine and I can update the code.
In normal HID Mode, I get the infamous Device not recognized and the error code 10.
I have been over the usb-descriptors all day and tried all kinds of stuff but I'm lost and not sure what to check next.
Here is the important stuff in the main app...
Sends 64 bytes to the PC.
Allows 2 bytes to be received from PC
Code: |
#use delay(clock=48000000)
#use i2c(MASTER,SDA=PIN_B0, SCL=PIN_B1) //SDA moved to A2 for testing since B3 Interferes with ICD Programmer
//for including bootloader in hex file Comment out for APP only or leave for MASTER
#include "my_usb_bootloader.h"
#import(FILE=my_usb_bootloader.hex,HEX,RANGE=0:0x1FFF)
//Must also set these sizes in the CSI_desc_hid.h
#Define USB_Out_Size 64
#Define USB_In_Size 2
//USB Related
#DEFINE USB_HID_DEVICE TRUE
#define USB_EP1_TX_ENABLE USB_ENABLE_INTERRUPT //turn on EP1 for IN bulk/interrupt transfers
#define USB_EP1_TX_SIZE USB_Out_Size //was 40 allocate buffer for send to PC
#define USB_EP1_RX_ENABLE USB_ENABLE_INTERRUPT //turn on EP1 for OUT bulk/interrupt transfers
#define USB_EP1_RX_SIZE USB_In_Size //was 2 allocate buffer from PC
|
Here is the stuff in the usb-descriptors, which I believe is the problem...
Code: |
* HID Report Descriptor */
const char USB_CLASS_SPECIFIC_DESC[] = {
0x06, 0xA0,0xFF, // Usage Page = Vendor Defined ,0,255 rws
0x09, 0x01, // Usage = IO device
0xA1, 0x01, // Collection = Application
0x09, 0x03, //RWS Usage - Vendor Defined
0x19, 0x00, // Usage minimum 0
0x29, 0x24, // Usage maximum 36
0x15, 0x00, // Logical minimum (-128)
0x26, 0xFF, 0x00, // Logical maximum (127) //rws
0x75, 0x08, // Report size = 8 (bits)
0x95, 0x40, // Report count = Sending to PC 40 0x28
0x81, 0x02, // Input (Data, Var, Abs)
//End Point 1 Out - From PC to Pic
0x09, 0x04, //RWS Usage - Vendor Defined
0x19, 0x01, // Usage minimum
0x29, 0x08, // Usage maximum
0x75, 0x08, // Report size = 8 (bits)
0x95, 0x02, // Report count = From PC 0x02 32 bytes
0x91, 0x02, // Output (Data, Var, Abs)
0xc0 // End Collection
};
const int16 USB_CLASS_SPECIFIC_DESC_LOOKUP[USB_NUM_CONFIGURATIONS][1] =
{
//config 1
//interface 0
0
};
const int16 USB_CLASS_SPECIFIC_DESC_LOOKUP_SIZE[USB_NUM_CONFIGURATIONS][1] =
{
//config 1
//interface 0
// 32 Must modify this size to match endpoint descriptor up top
37 //rws
};
#DEFINE USB_TOTAL_CONFIG_LEN 41 //55 //Was 41 //config+interface+class+endpoint+endpoint (2 endpoints)
const char USB_CONFIG_DESC[] = {
//config_descriptor for config index 1
USB_DESC_CONFIG_LEN, //length of descriptor size ==1
USB_DESC_CONFIG_TYPE, //constant CONFIGURATION (CONFIGURATION 0x02) ==2
USB_TOTAL_CONFIG_LEN,0, //size of all data returned for this config ==3,4
0x01, //number of interfaces this device supports ==5
0x01, //identifier for this configuration. (IF we had more than one configurations) ==6
0x00, //index of string descriptor for this configuration ==7
0x80, //bit 6=1 if self powered, bit 5=1 if supports remote wakeup (we don't), bits 0-4 unused and bit7=1 ==8
0x64, //maximum bus power required (maximum milliamperes/2)rws (0x32 = 100mA) (0x64 = 100 x 2 = 200 ma)
//interface descriptor 1
USB_DESC_INTERFACE_LEN, //length of descriptor =10
USB_DESC_INTERFACE_TYPE, //constant INTERFACE (INTERFACE 0x04) =11
0x00, //number defining this interface (IF we had more than one interface) ==12
0x00, //alternate setting ==13
2, //number of endpoins, except 0 (pic167xx has 3, but we dont have to use all). ==14
0x03, //class code, 03 = HID ==15 was 03
0x00, //subclass code //boot ==16 was 0x00
0x00, //protocol code ==17 was 0x00 rws
0x00, //index of string descriptor for interface ==18 was 0x00 rws
//class descriptor 1 (HID)
USB_DESC_CLASS_LEN, //length of descriptor ==19
USB_DESC_CLASS_TYPE, //dscriptor type (0x21 == HID) ==20
0x01,0x01, //hid class release number (1.0) (try 1.10) ==21,22 0x00, 0x01
0x00, //localized country code (0 = none) ==23
0x01, //number of hid class descrptors that follow (1) ==24
0x22, //report descriptor type (0x22 == HID) ==25 was 22
USB_CLASS_SPECIFIC_DESC_LOOKUP_SIZE[0][0], 0x00, //length of report descriptor ==26,27
//endpoint descriptor 1
USB_DESC_ENDPOINT_LEN, //length of descriptor ==28
USB_DESC_ENDPOINT_TYPE, //constant ENDPOINT (ENDPOINT 0x05) ==29
0x81, //endpoint number and direction (0x81 = EP1 IN) ==30
0x03, //transfer type supported (0x03 is interrupt) ==31
USB_EP1_TX_SIZE,0x00, //maximum packet size supported ==32,33
10, //polling interval, in ms. (cant be smaller than 10) ==34
//endpoint descriptor 1
USB_DESC_ENDPOINT_LEN, //length of descriptor ==35
USB_DESC_ENDPOINT_TYPE, //constant ENDPOINT (ENDPOINT 0x05) ==36
0x01, //endpoint number and direction (0x01 = EP1 OUT) ==37
0x03, //transfer type supported (0x03 is interrupt) ==38
USB_EP1_RX_SIZE,0x00, //maximum packet size supported ==39,40
10 //polling interval, in ms. (cant be smaller than 10) ==41
};
//****** BEGIN CONFIG DESCRIPTOR LOOKUP TABLES ********
#define USB_NUM_HID_INTERFACES 1
#define USB_MAX_NUM_INTERFACES 1
const char USB_NUM_INTERFACES[USB_NUM_CONFIGURATIONS]={1};
const int16 USB_CLASS_DESCRIPTORS[USB_NUM_CONFIGURATIONS][1][1]=
{
//config 1
//interface 0
//class 1
18
};
#if (sizeof(USB_CONFIG_DESC) != USB_TOTAL_CONFIG_LEN)
#error USB_TOTAL_CONFIG_LEN not defined correctly
#endif
//////////////////////////////////////////////////////////////////
///
/// start device descriptors
///
//////////////////////////////////////////////////////////////////
const char USB_DEVICE_DESC[USB_DESC_DEVICE_LEN] ={
USB_DESC_DEVICE_LEN, //the length of this report ==1
0x01, //the constant DEVICE (DEVICE 0x01) ==2
0x01,0x10,
// 0x00,0x02, //usb version in bcd (pic167xx is 1.1) ==3,4 , 0x01,0x01 rws
0x00, //class code ==5 0x00 rws
0x00, //subclass code ==6
0x00, //protocol code ==7 0x00 rws
USB_MAX_EP0_PACKET_LENGTH, //max packet size for endpoint 0. (SLOW SPEED SPECIFIES 8) ==8
0x61,0x04, //vendor id (0x04D8 is Microchip, or is it 0x04 61 ??)
0x01,0x00, //product id ==11,12 //don't use ffff says usb-by-example guy. oops
0x01,0x00, //device release number ==13,14 EDIT HERE
0x01, //index of string description of manufacturer. therefore we point to string_1 array (see below) ==15
0x02, //index of string descriptor of the product ==16
0x03, //index of string descriptor of serial number ==17
USB_NUM_CONFIGURATIONS //number of possible configurations ==18
};
//////////////////////////////////////////////////////////////////
///
/// start string descriptors
/// String 0 is a special language string, and must be defined. People in U.S.A. can leave this alone.
///
/// You must define the length else get_next_string_character() will not see the string
/// Current code only supports 10 strings (0 thru 9)
///
//////////////////////////////////////////////////////////////////
//the offset of the starting location of each string. offset[0] is the start of string 0, offset[1] is the start of string 1, etc.
char USB_STRING_DESC_OFFSET[]={0,4,12,58};
//RWS All String Length - Must be 2 bytes more than Str. Len =1, StringType=1, then String itself
char const USB_STRING_DESC[]={
//string 0
4, //length of string index
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
0x09,0x04, //Microsoft Defined for US-English 0x0409
//string 1
8, //length of string index
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
'C',0,
'X',0,
'X',0,
//string 2
46, //length of string index
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
'C',0,
'X',0,
'X',0,
' ',0,
'U',0,
'S',0,
'B',0,
' ',0,
'M',0,
'U',0,
'L',0,
'T',0,
'I',0,
'-',0,
'I',0,
'O',0,
' ',0,
'B',0,
'O',0,
'A',0,
'R',0,
'D',0,
//string 3
10, //length of string index
USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
'1',0,
'0',0,
'0',0,
'4',0
};
#ENDIF
|
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Fri Jan 25, 2019 5:41 pm |
|
|
gotta play the Devil's advocate here...
OK so WHY do you think it's YOUR PICs code ? You say the SAME code works flawlessly under XP and 7...logic says it's NOT your code.
I suspect that '10' has a whack of 'improvements' and is not letting you operate the PC as before. I won't touch the '10' machine here in the office. I didn't install, I never took a course on it, so not my problem when 'things' go wrong. Now I am assuming this is the same physical PC and that no hardware changes have been made since XP or 7 AND that whatever program(er, 'ap') that is using the USB port hasn't changed either. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Sat Jan 26, 2019 1:47 am |
|
|
The commonest cause for Error 10, on Win10, is actually the power
management.
Go into the power options.
Change plan settings.
Change advanced settings.
USB Settings.
USB selective suspend - set this to disabled.
Then you may need to do a similar change for every hub on your computer.
Device manager.
Universal Serial Bus controllers.
USB Root Hub
Power management
Untick the box 'Allow the computer to turn off this device to save power'.
Repeat for every hub.
Then find the faulty device off the same 'tree' in device manager.
Driver.
Select 'Uninstall device'.
Reboot.
With this all done, you may well then find that Windows successfully now
installs the driver after the next boot...
There is also a known issue with W10 HID drivers. However if you have the
latest updates installed, this was meant to be fixed a little while ago by
MicroSoft, though a couple of chipsets are still having issues. Have you
tried another different motherboard computer?. If this works, you may
be unlucky, and hitting one of the computers with this issue. The
manufacturers own HID drivers (rather than the MicroSoft defaults), in
some cases fix this. It affects only certain devices. |
|
|
rwskinner
Joined: 08 Dec 2006 Posts: 125 Location: Texas
|
|
Posted: Sat Jan 26, 2019 8:28 am |
|
|
Unfortunately, it is a customer. Their IT department came in over the weekend and replaced their computers. So when the boards come off the production line, they get firmware put on them, then go off to QC.
QC then plugs the boards in to the PC, and performs functionality testing on the boards before they ship to end users.
This entire QC process is broken at this point. So I really do not have control over the PC's on their end, but, I have 3 windows 10 PC's here with 32 bit and 64 bit OS's and they all give an error code 10 and say unrecognized device - unable to start.
I read a couple of articles about Windows 10 being more strict and sometimes if the descriptors aren't exactly correct, in windows 10, it wont work, but previous versions were more forgiving.
I will try the power management to see if that helps any on my PC's here. |
|
|
rwskinner
Joined: 08 Dec 2006 Posts: 125 Location: Texas
|
|
Posted: Sat Jan 26, 2019 8:49 am |
|
|
I compiled the simple HID Example program, put it on the same board, and Windows 10 enumerates fine.
That probably means it doesn't like my descriptors somewhere, device type or class or something... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Sat Jan 26, 2019 9:47 am |
|
|
One glaring possible issue, is you have changed the PID. PID 1, on VID 461,
is a Hewlett Packard keyboard. It may well be trying to load a specific driver
for this, which then won't work (hence Code 10).
Windows 10, is far more likely than the older OS's, to 'know' what a device
should be and automatically try to load the driver for it. On the older OS's
you'd probably have to load the HP drivers to have an issue.
VID 461, is owned by Primax. CCS have purchased a license from them for a
small number of VID's. 0x20 for the HID device by default. |
|
|
rwskinner
Joined: 08 Dec 2006 Posts: 125 Location: Texas
|
Resolved |
Posted: Sat Jan 26, 2019 10:05 am |
|
|
Here is what I found....
Somehow, I had goofed up and transposed...
0x01,0x10, //usb version in bcd (pic167xx is 1.1) ==3,4
Instead of
0x10,0x01, //usb version in bcd (pic167xx is 1.1) ==3,4
Yes, thanks on the product ID. I have to see what all it impacts, on other software. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|