9 Replies Latest reply on Jul 4, 2012 4:35 AM by rama.sai.krishna.vakkantula

    FX3 API cannot set OS String Descriptor

    andrew.beveridge

      I need to set the MS OS String Descriptor (index = 0xEE)

         

      This is necessary for WinUSB class driver support on Windows 8.

         

      But a call to CyU3PUsbSetDesc(CY_U3P_USB_SET_STRING_DESCR, 0xEE,...)

         

      just fails, returning Error code = 75

         

      I assume this is because the descriptors are hardwired to IDs 0 to 15?

         

      Can we get a fix for this?

         

      Am I going to have similar trouble with OS Feature descriptors?

         

      Thanks

        • 1. Re: FX3 API cannot set OS String Descriptor
          anand.srinivasan.asokan

          Yep. You're right.

             

          The error code being returned is CY_U3P_ERROR_BAD_INDEX and is being triggered due to CY_U3P_MAX_STRING_DESC_INDEX in cyu3usb.h. You can see the required description above the #define.

             

          I'll talk our software team and let you know.

             

          Regards,

             

          Anand

          • 2. Re: FX3 API cannot set OS String Descriptor
            karthik.sivaramakrishnan

            Hi,

               

            You are right that the FX3 SDK does not let you set a OS descriptor using the CyU3PUsbSetDesc() API.

               

            However, this does not prevent you from supporting a OS descriptor in your application. You can support do this at the application level by handling the request in your setup callback function. See the below code snippet:

               
            /* Microsoft OS Descriptor. */ const uint8_t CyFxUsbOSDscr[] __attribute__ ((aligned (32))) = { 0x0E, CY_U3P_USB_STRING_DESCR, 'O', 0x00, 'S', 0x00, ' ', 0x00, 'D', 0x00, 'e', 0x00, 's', 0x00, 'c', 0x00 }; /* Callback to handle the USB setup requests. */ CyBool_t CyFxBulkSrcSinkApplnUSBSetupCB ( uint32_t setupdat0, /* SETUP Data 0 */ uint32_t setupdat1 /* SETUP Data 1 */ ) { /* Fast enumeration is used. Only requests addressed to the interface, class, * vendor and unknown control requests are received by this function. * This application does not support any class or vendor requests. */ uint8_t bRequest, bReqType; uint8_t bType, bTarget; uint16_t wValue, wIndex, wLength; CyBool_t isHandled = CyFalse; /* Decode the fields from the setup request. */ bReqType = (setupdat0 & CY_U3P_USB_REQUEST_TYPE_MASK); bType = (bReqType & CY_U3P_USB_TYPE_MASK); bTarget = (bReqType & CY_U3P_USB_TARGET_MASK); bRequest = ((setupdat0 & CY_U3P_USB_REQUEST_MASK) >> CY_U3P_USB_REQUEST_POS); wValue = ((setupdat0 & CY_U3P_USB_VALUE_MASK) >> CY_U3P_USB_VALUE_POS); wIndex = ((setupdat1 & CY_U3P_USB_INDEX_MASK) >> CY_U3P_USB_INDEX_POS); wLength = ((setupdat1 & CY_U3P_USB_LENGTH_MASK) >> CY_U3P_USB_LENGTH_POS); if (bType == CY_U3P_USB_STANDARD_RQT) { /* Handle Microsoft OS String Descriptor request. */ if ((bTarget == CY_U3P_USB_TARGET_DEVICE) && (bRequest == CY_U3P_USB_SC_GET_DESCRIPTOR) && (wValue == ((CY_U3P_USB_STRING_DESCR << 8) | 0xEE))) { /* Make sure we do not send more data than requested. */ if (wLength > CyFxUsbOSDscr[0]) wLength = CyFxUsbOSDscr[0]; CyU3PUsbSendEP0Data (wLength, (uint8_t *)CyFxUsbOSDscr); isHandled = CyTrue; } /* Handle other requests below as required. */ } return isHandled; } For now, please use the above work-around. API level support for registering a OS descriptor will be added in a later FX3 SDK release. 
            • 3. Re: FX3 API cannot set OS String Descriptor
              karthik.sivaramakrishnan

              The code formatting in the last post does not look good. I am attaching the complete example source code.

                 

              Regards,

                 

              Karthik

              • 4. Re: FX3 API cannot set OS String Descriptor
                andrew.beveridge

                Thanks guys.

                   

                I'm travelling now so although I can build OK I can't deploy it right now.

                   

                I've picked it up and will give it a shot when I am back in my office next week.

                   

                And if I run into any trouble with the other MS specific feature descriptors I'll report back here.

                • 5. Re: FX3 API cannot set OS String Descriptor
                  andrew.beveridge

                  I thought I should report back.

                     

                  I did run into a bit more trouble trying to make a WinUSB class device for Windows 8.

                     

                  The OS feature Descriptor is fetched as Vendor specific request.   ie   bType == CY_U3P_USB_VENDOR_RQT
                  but it is still a string descriptor.   ie  bRequest == CY_U3P_USB_SC_GET_DESCRIPTOR and wValue == 0x03EE
                  I modified the example code for  CyFxBulkSrcSinkApplnUSBSetupCB()  accordingly.

                     

                  Same goes for the Extended Compat ID OS Feature Descriptor.
                  That also gets fetched as a Vendor type, with the user-specified (in the OS descriptor) value in bRequest.

                     

                   

                     

                  I think you have to do all this if you want to use WinUSB on Windows 8 because if I try to load my Windows 8 signed inf+cat specifying winusb (as I do on Windows 7 x64) I get an error message from Windows-8 saying "Windows found driver software for your device but encountered an error whil attempting to install it". Unliek Win7 it also would nto even look at my inf file unless I also gave it a matching signed cat file.

                     

                  Can anyone here using WinUSB confirm this? Do Win7 style WinUSB inf installs relly not work on Win8?

                     

                  Thanks

                  • 6. Re: FX3 API cannot set OS String Descriptor
                    andrew.beveridge

                    Hi aasi

                       

                    also, I cannot build the example code you posted. It looks like it may be for a SDK newer than the one I have.

                       

                    I have the v1.1 SDK from http://www.cypress.com/?rID=57990

                       

                    Where can I get a newer SDK?

                       

                    Error output building with v1.1 is like this:-

                       

                    ../cyfxbulksrcsink.c: In function 'CyFxBulkSrcSinkApplnUSBEventCB':
                    ../cyfxbulksrcsink.c:536:14: error: 'CY_U3P_USB_EVENT_EP0_STAT_CPLT' undeclared (first use in this function)
                    ../cyfxbulksrcsink.c:536:14: note: each undeclared identifier is reported only once for each function it appears in
                    ../cyfxbulksrcsink.c: In function 'BulkSrcSinkAppThread_Entry':
                    ../cyfxbulksrcsink.c:712:17: warning: implicit declaration of function 'CyU3PUsbSendDevNotification'
                    ../cyfxbulksrcsink.c:714:17: warning: implicit declaration of function 'CyU3PUsbDoRemoteWakeup'

                    • 7. Re: FX3 API cannot set OS String Descriptor
                      rama.sai.krishna.vakkantula

                      For latest SDK, please have a look at the last but one post in the below given thread:

                         

                      http://www.cypress.com/?app=forum&id=167&rID=63875

                         

                      Regards,

                         

                      sai krishna.

                      • 8. Re: FX3 API cannot set OS String Descriptor
                        andrew.beveridge

                        Thanks. I (eventually) have the newer SDK and can build the code OK now.

                           

                        However it does not seem to work.
                        So I added a CyU3PDebugPrint to the start of CyFxBulkSrcSinkApplnUSBSetupCB()

                           

                        It seems that CyFxBulkSrcSinkApplnUSBSetupCB() only gets called once. Just once.

                           

                        When it is called, bType =0, bTarget =0, bRequest =6, bReqType = 0x80

                           

                        It does not appear to get called for the MS OS descriptor.

                           

                        I carefully used regedit to delete

                           

                        HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbflags\------

                           

                        And Windows thinks it has sent the 0xEE string request OK because afterwards it recreates the registry entry again.

                           

                        And I can verify this behavior on anotehr (not FX3) device. In that case I see the 0xEE string request just fine. 

                           

                        Any idea why this code is not seeing any more calls?

                        • 9. Re: FX3 API cannot set OS String Descriptor
                          andrew.beveridge

                          Oops. Ignore my last two posts. Sorry, I would unpost them if I could.

                             

                          It seems your original code was correct... I misunderstood the way the FX3 API uses that bType parameter.

                             

                          This OS descriptor request is indeed a    bType == CY_U3P_USB_STANDARD_RQT

                             

                          and then the subsequent feature compatid requests are   bType == CY_U3P_USB_VENDOR_RQT

                             

                           

                             

                          With that adjusted it seems to work now, even if I setup the callback with CyTrue as second param.

                             

                          ie.     CyU3PUsbRegisterSetupCallback(CyFxBulkSrcSinkApplnUSBSetupCB, CyTrue);

                             

                           

                             

                           

                          • 10. Re: FX3 API cannot set OS String Descriptor
                            rama.sai.krishna.vakkantula

                            Good to know that it is working at your end.