Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

USB superspeed peripherals Forum Discussions

rossi
Level 3
Level 3
25 sign-ins First solution authored 10 replies posted

Hello, 


While receiving data from UVC camera in my USB 2.0 host firmware,  ocasionally 0x53(CY_U3P_ERROR_STALLED) errors were found after CyU3PUsbHostEpWaitForCompletion  call. (Full log is attached)

 

 

...
CyU3PUsbHostEpSetXfer status=0x0,count=1024
CyU3PUsbHostEpWaitForCompletion...
CyU3PUsbHostEpWaitForCompletion status=0x53,ep=0x81,epStatus=0x34C4141
CyU3PDmaChannelWaitForCompletion...
CyU3PDmaChannelWaitForCompletion status=0x0
...

 

 

 

My endpoint setup is shown below

 

 

    size = 1024;
    /* Initialize the UVC */
    CyU3PMemSet ((uint8_t *)&epCfg, 0, sizeof(epCfg));
    epCfg.type = CY_U3P_USB_EP_ISO;
    epCfg.mult = 3;
    epCfg.maxPktSize = size;
    epCfg.pollingRate = 0;
    size = ((size + 0x0F) & ~0x0F);
    epCfg.fullPktSize = size;
    epCfg.isStreamMode = CyFalse;

 

 

 

The UVC webcam data receivinng thread is as below.

 

 

void
UvcRecvThread(
		uint32_t Value)
{
	...
	for (;;)
	{
        buf_p.buffer = buffer;
        buf_p.count  = 0;
        buf_p.size   = ((count + 0x0F) & ~0x0F);
        buf_p.status = 0;

        CyU3PDebugPrint(4,"CyU3PDmaChannelSetupRecvBuffer...\r\n");
        status = CyU3PDmaChannelSetupRecvBuffer (&glHostUvcCh, &buf_p);
        CyU3PDebugPrint(4,"CyU3PDmaChannelSetupRecvBuffer status=0x%x,size=%d\r\n",status,buf_p.size);
        if(status!=CY_U3P_SUCCESS) continue;

        CyU3PDebugPrint(4,"CyU3PUsbHostEpSetXfer(%d)...\r\n",count);
        status = CyU3PUsbHostEpSetXfer (glHostUvcEp,CY_U3P_USB_HOST_EPXFER_NORMAL, count);
        CyU3PDebugPrint(4,"CyU3PUsbHostEpSetXfer status=0x%x,count=%d\r\n",status,count);
        if(status!=CY_U3P_SUCCESS) continue;

        CyU3PDebugPrint(4,"CyU3PUsbHostEpWaitForCompletion...\r\n");
        status = CyU3PUsbHostEpWaitForCompletion (glHostUvcEp, &epStatus, 10);
        CyU3PDebugPrint(4,"CyU3PUsbHostEpWaitForCompletion status=0x%x,ep=0x%x,epStatus=0x%x\r\n",status,glHostUvcEp,epStatus);

        CyU3PDebugPrint(4,"CyU3PDmaChannelWaitForCompletion...\r\n");
        status = CyU3PDmaChannelWaitForCompletion (&glHostUvcCh, CYU3P_NO_WAIT);
        CyU3PDebugPrint(4,"CyU3PDmaChannelWaitForCompletion status=0x%x\r\n",status);
        if(status!=CY_U3P_SUCCESS) continue;

        status = CyU3PDmaChannelGetStatus (&glHostUvcCh, &state, &prodXferCount, &consXferCount);
        CyU3PDebugPrint (4,"CyU3PDmaChannelGetStatus status=0x%x state=0x%x length=%d\r\n",status,state,prodXferCount);

        for(uint32_t i=0;i<prodXferCount-1;i++) {
        	if(buffer[i]==0xff && buffer[i+1]==0xd8) CyU3PDebugPrint(4, "SOI=====================\r\n");
        	if(buffer[i]==0xff && buffer[i+1]==0xd9) CyU3PDebugPrint(4, "EOI---------------------\r\n");
        }
	}
}

 

 

 

In the above log, I think this following is very ominous one.

 

 

CyU3PUsbHostEpWaitForCompletion status=0x53,ep=0x81,epStatus=0x34C4141

 

 

 

But lack of information, it is hard for me to figure out what it tells exactly.

According to this article, I could extract some information as below

0x4141 = b(0100 0001 0100 0001)

Name Value Description
EP_NUM 1 Endpoint number
Direction 0 IN
Active 0 EP got deactivated
Halt 1 EP is halted
Overrun/Underrun 0

No overrun/underrun condition

Babble 1

Babble was detected

XactErr 0

 

Ping 0

No ping token has been issued

Byte Count 0x34C (844)

Total byte count left

 

I think that STALL error(0x53) is related with the above epStatus, especially babble and halt. But I have no idea how can I explain the above test result. I expect that maybe the endpoint setup is not matched with the camera. (not for sure)

 

It would be great if I can understand the meaning of those parameters better.

I believe that understanding will lead me to a solution on this issue.

 

Regards,

Rossi

0 Likes
1 Solution
Rashi_Vatsa
Moderator
Moderator
Moderator
5 likes given 500 solutions authored 1000 replies posted

Hello,

From the description, I understand that the endpoint is in the STALLED state. As per the epStatus we can also see that the host has detected a BABBLE ERROR is detected. Which could be the reason why endpoint is stalled. This error is seen when the device is not sending the expected amount of data. In this case it looks like device has more data than the host has requested. The host can retrieve the device endpoint back by sending clear feature on the endpoint.  

To avoid the problem, the host is expected to request data in multiples of wMaxPacketSize (endpoint maximum packet size). Can you try requesting 3 * 1024 bytes of data instead of 1024 as the cam device (mentioned in https://community.infineon.com/t5/USB-superspeed-peripherals/UVC-host-firmware-could-not-receive-dat... ) supports wMaxPacketSize of 3072 bytes (in one micro frame).

Please let me know if it is possible for you to change the device endpoint wMaxPacketSize to 1024 i.e. with MULT  setting as 1

Regards,
Rashi

View solution in original post

0 Likes
3 Replies
Rashi_Vatsa
Moderator
Moderator
Moderator
5 likes given 500 solutions authored 1000 replies posted

Hello,

From the description, I understand that the endpoint is in the STALLED state. As per the epStatus we can also see that the host has detected a BABBLE ERROR is detected. Which could be the reason why endpoint is stalled. This error is seen when the device is not sending the expected amount of data. In this case it looks like device has more data than the host has requested. The host can retrieve the device endpoint back by sending clear feature on the endpoint.  

To avoid the problem, the host is expected to request data in multiples of wMaxPacketSize (endpoint maximum packet size). Can you try requesting 3 * 1024 bytes of data instead of 1024 as the cam device (mentioned in https://community.infineon.com/t5/USB-superspeed-peripherals/UVC-host-firmware-could-not-receive-dat... ) supports wMaxPacketSize of 3072 bytes (in one micro frame).

Please let me know if it is possible for you to change the device endpoint wMaxPacketSize to 1024 i.e. with MULT  setting as 1

Regards,
Rashi
0 Likes

Hello Rashi

 

As your recommendation, I changed my host to request 3*1024 bytes of data instead of 1024.

  • Before

 

count = 1024;
status = CyU3PUsbHostEpSetXfer (glHostUvcEp,CY_U3P_USB_HOST_EPXFER_NORMAL, count);

 

 

  • After

 

count = 3*1024;
status = CyU3PUsbHostEpSetXfer (glHostUvcEp,CY_U3P_USB_HOST_EPXFER_NORMAL, count);

 

 

Thankfully, the stall error is gone now.

As your explanation, the babble error seems to cause the stall which happens when the data size required or expected on both sides do not match.

 

Thank you very much.

Regards,

Rossi

0 Likes
Rashi_Vatsa
Moderator
Moderator
Moderator
5 likes given 500 solutions authored 1000 replies posted

Hello,

Glad to hear that the issue is resolved!

Regards,
Rashi
0 Likes