From: <ja...@t-...> - 2003-07-24 10:23:13
|
> It would probably help to know what the device is. As an absolute minim= um, > seeing the HID descriptor (at least the Application) from lsusb or from > your source code would help. > libusb can probably do this, but hiddev might be a better bet. Out isn'= t > really good on Linux though - we'd need substantial design information = to > tell if that is going to be a big problem. neither the application nor the source are finished yet and design=20 changes may required to fit the USB. The device is nothing ordinary but a= =20 "cable" gateway from USB to several other interfaces. The purpose is uC f= lash=20 programming (but this is low level and something completly diffrent from = the=20 USB-DFU Class) RS232 Converters to USB are out of the shelf but there see= ms=20 nothing to connect to ICC (from STM), BDM (from Motorola) and OCDS what i= s a=20 JTAG superset. (used by Infineon/Motorola/Atmel and others) . The protocol of some of the uC is not good for fullspeed USB becouse a re= ad=20 address is only a 3 byte sequence with opcode, lowbyte, highbyte what is=20 followed by a single byte response from device. Such ping - pong transmis= sion=20 in reading consecutive addresses would change the direction too offen and= =20 not fill the 64 bytes of a full speed buffer. This slows down the availab= le=20 bandwidth to less than 9,6kBaud even if host polls every msec. Thats why = I=20 think about more abstract telegram sequences what can fit the 64 byte slo= ts=20 and make a protocol translation inside the cable. With other words: I like to use a report identifier in the first byte wha= t=20 indicates the type of report. After that, 63 bytes of raw data follow. Th= is=20 data is in the moment exactly what goes over the other interfaces of the=20 uC. The content can be considered as raw data, the instructions are=20 defined by semiconductor manufacturers and the order and content depends = from=20 the file what user likes to download to uC chip. This moment int-in and=20 int-out endpoint are a exact copy of that what is going over the other=20 interface. For additional and rarely used commands (like setup of cable=20 baudrate or target voltage) I think its best to use a feature report with= =20 control transfers. This avoids to pack and identify additional commands=20 inside the transparent stream of EP1/2. Tommorow I may have a better idea= for=20 a more efficient protocol and set the report ID from 01 to 02 and then th= e=20 cable is free to decode both contents. To be more specific, the following is a report descriptor taken from the=20 Cypress Reference design #6401 for a RS232 converter cable what can possi= bly=20 do most of the requirements of my device (except that there is no report = ID).=20 I modified the maximum value to 255 to transmit 8 bit values what requier= es a=20 16 bit argument for signed integer:=20 static DESCRIPTOR_MEMORY UCHAR ReportDescriptor[SIZE_ReportDescriptor] =3D { 0x06, 0x0A0, 0xFF,=09 // Usage Page (FFA0H =3D vendor defined) 0x09, 0x01, // USAGE (Vendor Usage 1) 0xa1, 0x01, // COLLECTION (Application) 0x09, 0x01, // USAGE (Vendor Usage 1)input r= eport 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255) was a bu= g 0x75, 0x08, // REPORT_SIZE (8) 0x95, 0x40, // REPORT_COUNT (64) 0x81, 0x02, // INPUT (Data,Var,Abs) 0x09, 0x02, // USAGE (Vendor Usage 2) out re= port 0x75, 0x08, // REPORT_SIZE (8) 0x95, 0x40, // REPORT_COUNT (64) 0x91, 0x02, // OUTPUT (Data,Var,Abs) 0x09, 0x03, // USAGE (Vendor Usage 3) featur= e rep 0x75, 0x08, // REPORT_SIZE (8) 0x95, 0x05, // REPORT_COUNT (5) 0xb1, 0x02, // FEATURE (Data,Var,Abs) 0xc0 // END_COLLECTION }; Linux seems to read the report descriptor but what instance is doing anyt= hing=20 with this descriptor? Therefore the application is responsible? This only= used=20 for mice and keyboards?=20 With the USB Firmware I first=20 tried to start with the full speed library from STM what can be downloade= d=20 from www.stmcu.com but I give that up soon becouse the thing contains too= =20 much inline assembly and too many people were involved in writing this co= de=20 and each one seems not to understand what the previous did. Thats why I=20 started writing a own one using computed jumps to decode the device reque= sts.=20 Its completely C and occupies currently about 600 bytes plus descriptor d= ata=20 what are that moment in experimantal version: ;************************************************************************= ************************** ; public symbols =09xref _cnfdsc,_str0,_str1,_str2,_devdsc,_repdsc,_hiddsc _devdsc:=09dc.b 0x12=09=09;0 bLength, the Standard Device Descriptor leng= th is 0x12=20 =09dc.b 0x01=09=09;1 bDescriptorType is Device, USB spec 2.0, page 251, t= able 9-5 =09dc.b 0x10,0x01=09; Complies with USB Spec. Release (0110h =3D release = 1.10) =09dc.b 0x00=09=09;4 bDeviceClass, each interface comes with individual c= lass =09dc.b 0x00=09=09;5 bDeviceSubClass, must be zero if bDeviceClass is als= o zero =09dc.b 0x00=09=09;6 bDeviceProtocol, no class specific protocol on inter= face basis =09dc.b 0x08=09=09;7 maximum packet size for endpoint0, the ST7 would als= o allow 16 =09dc.b 0x70,0x0c=09;8,9 idVendor for www.elektronikladen.de 0x0c70 =09dc.b 0x3f,0x07=09;a,b idProduct ID for the Cable 0x073f =09dc.b 0x01,0x00=09;c,d bcdDevice indicates product version 00.01 =09dc.b 0x00=09=09;e (01) iManufacturer, Index of String=20 =09dc.b 0x02=09=09;f iProduct, Index of String what describes the product =09dc.b 0x00=09=09;10 iSerialNumber,=20 =09dc.b 0x01=09=09;11 bNumConfigurations, there is only one configuration= possible _cnfdsc:=09dc.b 0x09=09=09;0 bLength, the Standard Configuration Descript= or=20 =09dc.b 0x02=09=09;1 bDesciptorType is Config, see USB spec 2.0, page 251= , table 9-5 =09dc.b 0x22,0x00=09;2,3 wTotalLength, of following descriptors of this c= onfig =09dc.b 0x01=09=09;4 bNumInterfaces, this configuration has one interface =09dc.b 0x01=09=09;5 bConfigurationValue, is selected by this value =09dc.b 0x00=09=09;6 iConfiguration, Index of String describing this conf= iguration =09dc.b 0x80=09=09;7 bmAttributes, bus powered =09dc.b 0x32=09=09;8 bMaxPower in 2 mA steps, this are 100 mA _ifdsc:=09dc.b 0x09=09;0 bLength, Descriptor length is 9 from 0 to 08 =09dc.b 0x04=09;1 bDescriptorType is Interface Descriptor =09dc.b 0x00=09;2 bInterfaceNumber, identifies this Interface =09dc.b 0x00=09;3 bAlternateSettung, value used to select alternate setti= ng =09dc.b 0x01=09;4 bNumEndpoints, number of endpoints used additional to E= P0 =09dc.b 0x03=09;5 bInterfaceClass, is a Human Interface Device =09dc.b 0x00=09;6 bInterfaceSubClass, no subclass not bootable =09dc.b 0x00=09;7 bInterfaceProtocol, this device uses no protocol =09dc.b 0x00=09;8 iInterface, Index to String describing the interface _hiddsc:=09dc.b 0x09=09=09;0 bLength, Descriptor length is 9 from 0 to 08 =09dc.b 0x21=09=09;1 bDescriptorType is HID =09dc.b 0x00,0x01=09;2,3 bcdHID complies with HID version 1.0 =09dc.b 0x00=09=09;4 bCountryCode, 0=3Dnot supported =09dc.b 0x01=09=09;5 bNumDescriptors, one class specific descriptor will = follow =09dc.b 0x22=09=09;6 bDescriptorType what followes is a report descriptor =09dc.b repend-_repdsc =09dc.b 0x00=09=09;7,8 wDescriptorLength, total size of report descriptor _epdsc:=09dc.b 0x07=09=09;0 bLength, Descriptor length is 7 from 0 to 6 =09dc.b 0x05=09=09;1 bDescriptorType is endpoint descriptor =09dc.b 0x81=09=09;2 bEndpointAddress, bit 0=3D1 is IN Endpoint, bit 1,2,= 3 is address =09dc.b 0x03=09=09;3 bmAttributes, bit1,0=3DInt transfer, other bits=3D0 = non isochron =09dc.b 0x06,0x00=09;4,5 wMaxPacketSize is 6 bytes =09dc.b 0x0a=09=09;6 bInterval for polling endpoint in number of frames, = 10 msec _repdsc:=09dc.b 0x06,0xa0,0xff=09;USAGE_PAGE (Vendor Defined FFA0) =09dc.b 0x09,0x01=09;USAGE (Vendor Usage 1) =09dc.b 0xa1,0x01=09;Collection (Application) =09dc.b 0x09,0x02=09;Usage (Vendor Usage 2) =09dc.b 0xa1,0x00=09;Collection Physical =09dc.b 0x06,0xA1,0xFF=09;Usage Page (vendor defined)=20 =09dc.b 0x09,0x03=09;usage - vendor defined =09dc.b 0x09,0x04=09;usage - vendor defined =09dc.b 0x15,0x80=09;Logical Minimum (-128) =09dc.b 0x25,0x7F=09;Logical Maximum (127) =09dc.b 0x35,0x00=09;Physical Minimum (0) =09dc.b 0x45,0xFF=09;Physical Maximum (255) =09dc.b 0x75,0x08=09;Report Size (8) (bits) =09dc.b 0x95,0x02=09;Report Count (2) (fields) =09dc.b 0x81,0x02=09;Input (Data, Variable, Absolute), that was the input= report =09dc.b 0x09,0x05=09;usage - vendor defined =09dc.b 0x09,0x06 =09;usage - vendor defined =09dc.b 0x15,0x80 =09;Logical Minimum (-128) =09dc.b 0x25,0x7F =09;Logical Maximum (127) =09dc.b 0x35,0x00 =09;Physical Minimum (0) =09dc.b 0x45,0xFF =09;Physical Maximum (255) =09dc.b 0x75,0x08 =09;Report Size (8) (bits) =09dc.b 0x95,0x02 =09;Report Count (2) (fields) =09dc.b 0x91,0x02 =09;Output (Data, Variable, Absolute) =20 =09dc.b 0xC0=09=09;End Collection =09dc.b 0xC0=09=09;End Collection repend:=09dc.b 0 ;************************************************************************= ************************** ; string descriptors, read USB Spec 2.0 page 273 chapter 9.6.7, String 0=20 announces the languages ; supported by the device but language identifier codes are not found in = the=20 USB specification ; For Language ID read seperate document "langids" version 1.0 issued 3/2= 9/00 =20 _str0:=09dc.b 0x04,0x03,0x09,0x04=09;language ID Englisch (US) _str1: _str2:=09dc.b _str3-_str2=09=09;lenght of string in bytes =09dc.b 0x03=09=09=09;constant for string descriptors =09dc.b "C",0x00,"a",0x00,"b",0x00,"l",0x00 =09dc.b "e",0x00 _str3:=09=09 =09end |