@@ -71,12 +71,15 @@ uint8_t resp[MAX_RESP_LEN];
71
71
#define ENDPOINT_TYPE_BULK 2
72
72
#define ENDPOINT_TYPE_INT 3
73
73
74
+ // This is an arbitrary value used in bRequest
75
+ #define MS_VENDOR_CODE 0xFF
76
+
74
77
//Convert machine byte order to USB byte order
75
78
#define TOUSBORDER (num )\
76
79
(num&0xFF), ((num>>8)&0xFF)
77
80
78
81
uint8_t device_desc [] = {
79
- DSCR_DEVICE_LEN , DSCR_DEVICE_TYPE , 0x00 , 0x01 , //Length, Type, bcdUSB
82
+ DSCR_DEVICE_LEN , DSCR_DEVICE_TYPE , 0x00 , 0x02 , //Length, Type, bcdUSB
80
83
0xFF , 0xFF , 0xFF , 0x40 , // Class, Subclass, Protocol, Max Packet Size
81
84
TOUSBORDER (USB_VID ), // idVendor
82
85
TOUSBORDER (USB_PID ), // idProduct
@@ -165,6 +168,49 @@ uint16_t string_3_desc[] = {
165
168
'n' , 'o' , 'n' , 'e'
166
169
};
167
170
171
+ #ifdef PANDA
172
+ // WCID (auto install WinUSB driver)
173
+ // https://github.com/pbatard/libwdi/wiki/WCID-Devices
174
+ // https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/winusb-installation#automatic-installation-of--winusb-without-an-inf-file
175
+ uint8_t string_238_desc [] = {
176
+ 0x12 , 0x03 , // bLength, bDescriptorType
177
+ 'M' ,0 , 'S' ,0 , 'F' ,0 , 'T' ,0 , '1' ,0 , '0' ,0 , '0' ,0 , // qwSignature (MSFT100)
178
+ MS_VENDOR_CODE , 0x00 // bMS_VendorCode, bPad
179
+ };
180
+ uint8_t winusb_ext_compatid_os_desc [] = {
181
+ 0x28 , 0x00 , 0x00 , 0x00 , // dwLength
182
+ 0x00 , 0x01 , // bcdVersion
183
+ 0x04 , 0x00 , // wIndex
184
+ 0x01 , // bCount
185
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , // Reserved
186
+ 0x00 , // bFirstInterfaceNumber
187
+ 0x00 , // Reserved
188
+ 'W' , 'I' , 'N' , 'U' , 'S' , 'B' , 0x00 , 0x00 , // compatible ID (WINUSB)
189
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , // subcompatible ID (none)
190
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 // Reserved
191
+ };
192
+ uint8_t winusb_ext_prop_os_desc [] = {
193
+ 0xCC , 0x00 , 0x00 , 0x00 , // dwLength
194
+ 0x00 , 0x01 , // bcdVersion
195
+ 0x05 , 0x00 , // wIndex
196
+ 0x02 , 0x00 , // wCount
197
+ // first property
198
+ 0x84 , 0x00 , 0x00 , 0x00 , // dwSize
199
+ 0x01 , 0x00 , 0x00 , 0x00 , // dwPropertyDataType
200
+ 0x28 , 0x00 , // wPropertyNameLength
201
+ 'D' ,0 , 'e' ,0 , 'v' ,0 , 'i' ,0 , 'c' ,0 , 'e' ,0 , 'I' ,0 , 'n' ,0 , 't' ,0 , 'e' ,0 , 'r' ,0 , 'f' ,0 , 'a' ,0 , 'c' ,0 , 'e' ,0 , 'G' ,0 , 'U' ,0 , 'I' ,0 , 'D' ,0 , 0 , 0 , // bPropertyName (DeviceInterfaceGUID)
202
+ 0x4E , 0x00 , 0x00 , 0x00 , // dwPropertyDataLength
203
+ '{' ,0 , 'C' ,0 , 'C' ,0 , 'E' ,0 , '5' ,0 , '2' ,0 , '9' ,0 , '1' ,0 , 'C' ,0 , '-' ,0 , 'A' ,0 , '6' ,0 , '9' ,0 , 'F' ,0 , '-' ,0 , '4' ,0 , '9' ,0 , '9' ,0 , '5' ,0 , '-' ,0 , 'A' ,0 , '4' ,0 , 'C' ,0 , '2' ,0 , '-' ,0 , '2' ,0 , 'A' ,0 , 'E' ,0 , '5' ,0 , '7' ,0 , 'A' ,0 , '5' ,0 , '1' ,0 , 'A' ,0 , 'D' ,0 , 'E' ,0 , '9' ,0 , '}' ,0 , 0 , 0 , // bPropertyData ({CCE5291C-A69F-4995-A4C2-2AE57A51ADE9})
204
+ // second property
205
+ 0x3E , 0x00 , 0x00 , 0x00 , // dwSize
206
+ 0x01 , 0x00 , 0x00 , 0x00 , // dwPropertyDataType
207
+ 0x0C , 0x00 , // wPropertyNameLength
208
+ 'L' ,0 , 'a' ,0 , 'b' ,0 , 'e' ,0 , 'l' ,0 , 0 , 0 , // bPropertyName (Label)
209
+ 0x24 , 0x00 , 0x00 , 0x00 , // dwPropertyDataLength
210
+ 'p' ,0 , 'a' ,0 , 'n' ,0 , 'd' ,0 , 'a' ,0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 // bPropertyData (panda)
211
+ };
212
+ #endif
213
+
168
214
// current packet
169
215
USB_Setup_TypeDef setup ;
170
216
uint8_t usbdata [0x100 ];
@@ -345,6 +391,11 @@ void usb_setup() {
345
391
USB_WritePacket ((const uint8_t * )string_3_desc , min (sizeof (string_3_desc ), setup .b .wLength .w ), 0 );
346
392
#endif
347
393
break ;
394
+ #ifdef PANDA
395
+ case 238 :
396
+ USB_WritePacket ((uint8_t * )string_238_desc , min (sizeof (string_238_desc ), setup .b .wLength .w ), 0 );
397
+ break ;
398
+ #endif
348
399
default :
349
400
// nothing
350
401
USB_WritePacket (0 , 0 , 0 );
@@ -372,6 +423,23 @@ void usb_setup() {
372
423
USB_WritePacket (0 , 0 , 0 );
373
424
USBx_OUTEP (0 )-> DOEPCTL |= USB_OTG_DOEPCTL_CNAK ;
374
425
break ;
426
+ #ifdef PANDA
427
+ case MS_VENDOR_CODE :
428
+ switch (setup .b .wIndex .w ) {
429
+ // Extended Compat ID OS Descriptor
430
+ case 4 :
431
+ USB_WritePacket ((uint8_t * )winusb_ext_compatid_os_desc , min (sizeof (winusb_ext_compatid_os_desc ), setup .b .wLength .w ), 0 );
432
+ break ;
433
+ // Extended Properties OS Descriptor
434
+ case 5 :
435
+ USB_WritePacket ((uint8_t * )winusb_ext_prop_os_desc , min (sizeof (winusb_ext_prop_os_desc ), setup .b .wLength .w ), 0 );
436
+ break ;
437
+ default :
438
+ USB_WritePacket (0 , 0 , 0 );
439
+ }
440
+ USBx_OUTEP (0 )-> DOEPCTL |= USB_OTG_DOEPCTL_CNAK ;
441
+ break ;
442
+ #endif
375
443
default :
376
444
resp_len = usb_cb_control_msg (& setup , resp , 1 );
377
445
USB_WritePacket (resp , min (resp_len , setup .b .wLength .w ), 0 );
0 commit comments