------------------------------------------------------------------- [1] USB blocks (and eventually timeouts) when received data are a multiple of the wMaxPacketSize
------------------------------------------------------------------- [2] We use USB smart card readers and we have a problem when the data to receive are a multiple of the wMaxPacketSize. I precise that they work fine on windows. :-( I wish to precise that not all the smart card readers are concerned by the bug. Some works fine. The problem is present with CCID compliant readers and other that are not CCID compliant. In the following example we describe the problem with a CCID reader because these specifications are available at http://www.usb.org/developers/devclass_docs/ccid_classspec_1_00a.pdf The reader used is the SCRx31 USB Smart Card Reader from SCM Microsystems Inc. It has a wMaxPacketSize equals to 64 bytes 0x40 and thus the exchange are done by the endpoint using packet of 0x40 bytes. The output of 'lsusb -v' is available at the [7.7] of this post. In the CCID specification, the block received from the smart card reader are composed by a header of 0x0A bytes (i.e. 10 bytes) followed by the data. Thus for example if the USB reader wants send to the host 0x50 bytes and as 0x50 > wMaxPacketSize we will receive 2 packets: one USB packet with 0x0A bytes of header + 0x36 bytes of data and an other packet with the last 0x1A bytes of data This works fine in all the cases excepted for those where the reader wants to send 0x36 or 0x76 or 0xB6 or 0xF6 bytes of data. - for 0x36 bytes of data: 1 packet: 0x0A bytes header + 0x36 bytes of data This is equal to 0x40 bytes thus it is exactly the size of wMaxPacketSize*1 - pour 0x76 bytes of data: 1 packet: 0x0A bytes header + 0x36 bytes of data 1 packet: 0x40 bytes of data This is equal to 0x40 bytes thus it is exactly the size of wMaxPacketSize*2 - pour 0xB6 bytes of data: 1 packet: 0x0A bytes header + 0x36 bytes of data 1 packet: 0x40 bytes of data 1 packet: 0x40 bytes of data This is equal to 0x40 bytes thus it is exactly the size of wMaxPacketSize*3 - pour 0xF6 bytes of data: 1 packet: 0x0A bytes header + 0x36 bytes of data 1 packet: 0x40 bytes of data 1 packet: 0x40 bytes of data 1 packet: 0x40 bytes of data This is equal to 0x40 bytes thus it is exactly the size of wMaxPacketSize*4 Below the content of /var/log/syslog if : (1) I plug the reader (2) I send my command and I except 0x36 data (3) I unplug the reader after the timeout (4) I plug again the reader (5) I send my command and I expect 0x76 data May 10 22:43:32 bdx-07 kernel: usb.c: USB device 13 (vend/prod 0x4e6/0xe001) is not claimed by any active driver. May 10 22:43:36 bdx-07 kernel: usb_control/bulk_msg: timeout May 10 22:44:40 bdx-07 kernel: usb_control/bulk_msg: timeout May 10 22:44:40 bdx-07 kernel: usbdevfs: USBDEVFS_BULK failed dev 13 ep 0x82 len 273 ret -110 May 10 23:11:53 bdx-07 kernel: usb.c: USB device 14 (vend/prod 0x4e6/0xe001) is not claimed by any active driver. May 10 23:13:03 bdx-07 kernel: usb_control/bulk_msg: timeout May 10 23:13:03 bdx-07 kernel: usbdevfs: USBDEVFS_BULK failed dev 14 ep 0x82 len 273 ret -110 May 10 23:14:03 bdx-07 kernel: usb_control/bulk_msg: timeout May 10 23:14:03 bdx-07 kernel: usbdevfs: USBDEVFS_BULK failed dev 14 ep 0x82 len 10 ret -110 May 10 23:15:03 bdx-07 kernel: usb_control/bulk_msg: timeout May 10 23:15:03 bdx-07 kernel: usbdevfs: USBDEVFS_BULK failed dev 14 ep 0x82 len 10 ret -110 May 10 23:16:03 bdx-07 kernel: usb_control/bulk_msg: timeout May 10 23:16:03 bdx-07 kernel: usbdevfs: USBDEVFS_BULK failed dev 14 ep 0x82 len 10 ret -110 May 10 23:17:03 bdx-07 kernel: usb_control/bulk_msg: timeout May 10 23:17:03 bdx-07 kernel: usbdevfs: USBDEVFS_BULK failed dev 14 ep 0x82 len 259 ret -110 ------------------------------------------------------------------- [3] usb, usbdevfs, uhci_hcd, ehci_hcd ------------------------------------------------------------------- [4] Tested on 2.4.26, 2.4.18, 2.4.23, 2.6.0, 2.6.2 ------------------------------------------------------------------- [7] Slackware 8.1, PC/SC Lite 1.2.9-beta1, ccid generic driver 0.4.1, libusb-0.1.8 ------------------------------------------------------------------- [7.7] [EMAIL PROTECTED]:~# lsusb -v Unknown line at line 1809 Duplicate HUT Usage Spec at line 2650 Bus 002 Device 001: ID 0000:0000 Virtual Hub Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 1.00 bDeviceClass 9 Hub bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 8 idVendor 0x0000 Virtual idProduct 0x0000 Hub bcdDevice 0.00 iManufacturer 0 iProduct 2 USB UHCI Root Hub iSerial 1 cf60 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 25 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0x40 Self Powered MaxPower 0mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 9 Hub bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type none wMaxPacketSize 8 bInterval 255 Language IDs: (length=4) 0000 (null)((null)) Bus 001 Device 001: ID 0000:0000 Virtual Hub Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 1.00 bDeviceClass 9 Hub bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 8 idVendor 0x0000 Virtual idProduct 0x0000 Hub bcdDevice 0.00 iManufacturer 0 iProduct 2 USB UHCI Root Hub iSerial 1 cf80 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 25 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0x40 Self Powered MaxPower 0mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 9 Hub bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type none wMaxPacketSize 8 bInterval 255 Language IDs: (length=4) 0000 (null)((null)) Bus 001 Device 013: ID 04e6:e001 Shuttle Technology Inc. Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 1.10 bDeviceClass 0 Interface bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 16 idVendor 0x04e6 Shuttle Technology Inc. idProduct 0xe001 bcdDevice 4.16 iManufacturer 1 SCM Microsystems Inc. iProduct 2 SCRx31 USB Smart Card Reader iSerial 5 280004C3 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 93 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 3 bmAttributes 0xa0 Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 11 bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 4 CCID Interface unknown descriptor type: 36 21 00 01 00 01 03 00 00 00 a0 0f 00 00 e0 2e 00 00 00 80 25 00 00 00 c2 01 00 00 fc 00 00 00 00 00 00 00 00 00 00 00 ba 00 01 00 07 01 00 00 ff ff 00 00 00 01 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x01 EP 1 OUT bmAttributes 2 Transfer Type Bulk Synch Type none wMaxPacketSize 64 bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type none wMaxPacketSize 64 bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 3 Transfer Type Interrupt Synch Type none wMaxPacketSize 16 bInterval 16 Language IDs: (length=4) 0409 English(US) ------------------------------------------------------------------- You can find some details on the bug opened on the pcsc-lite bug tracker at http://alioth.debian.org/tracker/index.php?func=detail&aid=300429&group_id=1225&atid=410085 Ludovic Rousseau and me are available do help you to debug, trace and test the proposed patches. Ludovic Rousseau <[EMAIL PROTECTED]> has developed the CCID driver (IFDHandler) for the PC/SC Lite project. Damien Sauveron <[EMAIL PROTECTED]> -- Damien Sauveron ---------------------------------------- LaBRI, Universit� Bordeaux 1 351, cours de la Lib�ration 33405 Talence cedex France T�l. On demand - Fax. +33 5 40 00 66 69 ---------------------------------------- ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. ------------------------------------------------------- This SF.Net email is sponsored by Sleepycat Software Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to deliver higher performing products faster, at low TCO. http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3 _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-users
