1 2 3 Previous Next 40 Replies Latest reply on Apr 20, 2020 2:44 AM by RashiV_61

    Why IN endpoint is always STALLED

    WGT_4383351

      With Slave/Master example in AN87216, without any data transfer, CyUSBDevice.UsbdStatusString(inEndpoint.UsbdStatus) will returns a stalled state. Is this normal? If so then how to decide when the device is dead?

       

      quote:

      "

      As an endpoint memory reset will result in some loss of data on the in-flight

      endpoint; it is required that the firmware application perform an error recovery on

      the corresponding endpoint. This can be done by registering for the

      CYU3P_USBEP_SS_RESET_EVT event on all IN endpoints, and performing an

      endpoint specific recovery when the event is received. The recommended recovery

      procedure is to STALL the endpoint, and then stop and restart the DMA data path

      when the CLEAR_FEATURE request is received.

      "

       

      When will CLEAR_FEATURE be sent to the device? Is it when inEndpoint.Reset() on the host? But how to decide when to inEndpoint.Reset() if you can't decide whether the device is dead for not if inEndpoint.UsbdStatus will return stalled even the device is not dead?

        • 1. Re: Why IN endpoint is always STALLED
          RashiV_61

          Hello,

           

          Please confirm that the status  is being checked after calling XferData API /BeginXferData

           

          stall_status.PNG

          So after doing the transfers, the status has to be checked and not without transfer. Please try doing some transfer and then check the result.

          Please send the snippet of your C# application ,which implements this, for us to confirm

           

          Regards,

          Rashi

          • 2. Re: Why IN endpoint is always STALLED
            WGT_4383351

            The problem is, although UsbdStatusString after XferData will give SUCCESS if the transfer success, it will still give STALL if there is no ready data and the slave timeout.

             

            Then how can the host application tell between a no data time out STALL or a dead STALL? Since reset the endpoint will stall the host application for seconds, you can only do this when the device is really dead.

            • 3. Re: Why IN endpoint is always STALLED
              RashiV_61

              Hello,

               

              Please print the value of status and confirm that the code for both cases i.e.

              - stall due to time out

              - endpoint stall (when the API CyU3PUsbStall is called in error handler)

              are same.

               

              When the endpoint is stalled (when the API CyU3PUsbStall is called in error handler) the error code expected is 0xC0000030 USBD_STATUS_ENDPOINT_HALTED

               

              Please refer to this link for the error codes USBD_STATUS (Windows Drivers) | Microsoft Docs

               

              Regards,

              Rashi

              • 4. Re: Why IN endpoint is always STALLED
                WGT_4383351

                In normal no data receive time out status,

                inEndpoint.UsbdStatus=0xc0010000,

                I thought they are the same since I only check the result of CyUSBDevice.UsbdStatusString which is both "state=HALTED status=UNKNOWN"

                 

                 

                BTW, isn't there some pre defined values in the C# API like:

                public const int USBD_STATUS_ENDPOINT_HALTED =0xC0000030;

                or the client code have to define these values?

                 

                It's common to define an Enum type for such value, for example, inEndpoint.UsbdStatus is better to be a Enum type instead of uint.

                 

                 

                • 5. Re: Why IN endpoint is always STALLED
                  RashiV_61

                  Hello,

                   

                  You can do any way you like.

                  The bulkloop application directly checks the error code

                                      if (inEndpoint.BeginDataXfer(ref cBufs, ref buffer, ref len, ref inOvLap) == false)

                                       {

                                           // Error Occurred.

                                           if (inEndpoint.UsbdStatus == 0xC0000030) // USBD_STATUS_ENDPOINT_HALTED

                                           {

                                               inEndpoint.Reset();

                                               if (inEndpoint.BeginDataXfer(ref cBufs, ref buffer, ref len, ref inOvLap) == false)

                                               {

                                                   failure++;

                                                   Thread.Sleep(10);

                                                   continue;

                                               }

                                           }

                   

                  So you just need to check the error code that is returned by usbdstatusString

                   

                  Regards,

                  Rashi

                  • 6. Re: Why IN endpoint is always STALLED
                    WGT_4383351

                    Now the problem is, when use inEndpoint.XferData to receive data from slave, and when it fails (at the same times serial port tells CYU3P_USBEP_SS_RESET_EVT is sent on slave), inEndpoint.UsbdStatus is 0xc0000011 what is this?

                     

                    Can you provide a reference of all the possible values for inEndpoint.UsbdStatus?

                    • 7. Re: Why IN endpoint is always STALLED
                      WGT_4383351

                      Does 0xC0000030 only work for BeginDataXfer?

                      • 8. Re: Why IN endpoint is always STALLED
                        WGT_4383351

                        Experiments shows that

                         

                        if (inEndpoint.UsbdStatus == 0xc0000011) inEndpoint.Reset();

                         

                        works after inEndpoint.XferData.

                         

                        Can you check why not 0xC0000030?

                         

                        The remaining problem is as my newest post - reset and stall for seconds each a few minutes is not acceptable by end user.

                        • 9. Re: Why IN endpoint is always STALLED
                          RashiV_61

                          Hello,

                           

                          Please refer to this link USBD_STATUS (Windows Drivers) | Microsoft Docs which mentions different error codes and their description

                           

                          Please confirm that you are handling the CYU3P_USBEP_SS_RESET_EVT correctly by calling CyU3PUsbStall API. Please check tha part of the code is executed by putting CyU3PDeviceReset(CyFalsE) in the condition where CYU3P_USBEP_SS_RESET_EVT  is handled.

                          endpoint_stall.PNG

                           

                          When CyU3PUsbStall API (source code) is called, ERDY is sent to host so that host can initiate transfer and find that endpoint has been stalled and then send Clear feature request

                           

                          BeginxferData is asynchronous method of performing transfer while XferDats is synchronous method. You can use either XferData or BeginXferData but you need to confirm that the stall is sent from the firmware

                           

                          Regards,

                          Rashi

                          • 10. Re: Why IN endpoint is always STALLED
                            WGT_4383351

                            0xC0000011 is USBD_STATUS_XACT_ERROR, why?

                             

                            Your last post is confusing:

                             

                            "Please check tha part of the code is executed by putting CyU3PDeviceReset(CyFalsE) in the condition where CYU3P_USBEP_SS_RESET_EVT  is handled." -why?

                             

                            CyU3PDeviceReset will reset the device and all state will be lost.

                             

                            Shouldn't I print some information to serial port when handling CYU3P_USBEP_SS_RESET_EVT? That is already done:

                             

                             

                             

                            "When CyU3PUsbStall API (source code) is called, ERDY is sent to host so that host can initiate transfer and find that endpoint has been stalled and then send Clear feature request"

                             

                            Who will send clear feature reset? Is inEdnpoint.Reste()?

                            • 11. Re: Why IN endpoint is always STALLED
                              RashiV_61

                              Hello,

                               

                              0xC0000011 is USBD_STATUS_XACT_ERROR, why?

                              >>The status code (0xC0000011) is mapped to USBD_STATUS_XACT_ERROR. This XACT error refers to a Transaction Error.

                                

                                       A device driver for a USB device may observe that a USB Transfer to or from the device fails due to a Transaction Error. This error is reported to USB device drivers by the Microsoft USB core driver stack via the USB status code USBD_STATUS_XACT_ERROR. In the USB EHCI specification, the following is the definition of a transaction error:

                                

                                       Transaction Error (XactErr). Set to a one by the Host Controller during status update in the case where the host did not receive a valid response from the device (Timeout, CRC, Bad PID, etc.).

                               

                               

                              "Please check tha part of the code is executed by putting CyU3PDeviceReset(CyFalsE) in the condition where CYU3P_USBEP_SS_RESET_EVT  is handled." -why?

                              CyU3PDeviceReset will reset the device and all state will be lost

                              >> I asked to do this just to check whether the stall is being called when CYU3P_USBEP_SS_RESET_EVT occurs. Now after looking at the debug prints it seems that the CyU3PUsbStall is executed

                               

                               

                              "When CyU3PUsbStall API (source code) is called, ERDY is sent to host so that host can initiate transfer and find that endpoint has been stalled and then send Clear feature request"

                              >> inEndpoint.Reset(); needs to be called in the host application when endpoint stall (0xC0000030) is detected

                               

                              When this request is sent from the host application to FX3, the firmware should clear the endpoint stallstall_1.PNG

                               

                              Regards,

                              Rashi

                               

                               

                              • 12. Re: Why IN endpoint is always STALLED
                                WGT_4383351

                                Why in my case it is 0xC0000011 instead of 0xC0000030? Does this difference mean anything?

                                 

                                My code is:

                                 

                                 

                                There is no CyU3PUsbSetEpNak and CyU3PUsbSetAckSetup, not sure whether this difference has impact.

                                • 13. Re: Why IN endpoint is always STALLED
                                  WGT_4383351

                                  Why in my case it is 0xC0000011 instead of 0xC0000030? Maybe both value should be checked for?

                                  • 14. Re: Why IN endpoint is always STALLED
                                    RashiV_61

                                    Hello,

                                     

                                    I think it is getting confusing. Let's go step by step

                                    Please confirm that  CYU3P_USBEP_SS_RESET_EVT is handled as follow and then check the return value of status when this part of code is executed

                                    endpoint_stall.PNG

                                     

                                    When this code is executed and endpoint is stalled the return value of  status should be 0xC0000030.

                                    Please check for this condition in the host application code and check whether this is executed or not. You an put some debug prints when this condition is met to know whether code in the if condition is executed or not. Please don't include 0xC0000011, as of now, to debug the problem

                                      if (inEndpoint.UsbdStatus == 0xC0000030) // USBD_STATUS_ENDPOINT_HALTED

                                                             {

                                                                //Put debug print

                                                                 inEndpoint.Reset();

                                    }

                                     

                                    Regards,

                                    Rashi

                                    1 2 3 Previous Next