CX3: CyU3PDmaMultiChannelCommitBuffer error 0x47 when restarting Custom Uvc Host.

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

cross mob
CoCo_4528381
Level 1
Level 1
First like given

Hello everyone!

I have a problem with the DmaMultiChannel used for the frame transmission on the CX3 when working on a custom uvc host app.

I'll explain you the problem in the following steps:

  1. If I use a UVC host app such as e-CAMView I don't have problems when, after flashing the FW in the CX3 I start and restart the Frame transmission (by opening and reopening e-camview).

  2. With the Custom Uvc Host app that I previously mentioned, when I first start the streaming after rebooting the FW I have a normal transmission. When I send the command to stop the transmission I somehow generate an overflow on the DMA multichannel: I can easily notice this by using, as soon as the function CyCx3UvcAppStop is activated, a CyU3PDmaMultiChannelGetBuffer command. At this point I noticed (thanks to the UART debugger) that the status of the DmaMultiChannel buffer is set to 0x8 (CY_U3P_DMA_BUFFER_OCCUPIED) and that the channel count parameter is equal to the size of the buffer. From a comparison with the output of e-camview, I know that at this point of the execution the status should be set to 0x0 and the count to 0x0.

  3. Even if in the UvcAppStop function I perform the standard reset of the channel and the EP cleanup, when I restart the uvc host app the DmaMultiChannel is still on the same status (CY_U3P_DMA_BUFFER_OCCUPIED) and I get the CyU3PDmaMultiChannelCommitBuffer error 0x47 (CY_U3P_ERROR_INVALID_SEQUENCE) when the UVC thread starts running. More specifically, the reset that I perform is the following:

    CyU3PMipicsiSleep(),
    CyU3PGpifDisable(CyFalse);
    glIsApplnActive = CyFalse;
    CyU3PUsbSetEpNak(CX3_EP_BULK_VIDEO, CyTrue);
    CyU3PBusyWait(100);
    CyU3PDmaMultiChannelReset(&glChHandleUVCStream);
    CyU3PThreadSleep(25);
    CyU3PUsbFlushEp(CX3_EP_BULK_VIDEO);
    CyU3PUsbSetEpNak(CX3_EP_BULK_VIDEO, CyFalse);
    CyU3PBusyWait(200);

    if (glIsClearFeature) {
    CyU3PUsbStall(CX3_EP_BULK_VIDEO, CyFalse, CyTrue);
    glIsClearFeature = CyFalse;
    }

  4. The only effective solution to restart the DmaMultiChannel so far is to unplug and replug the device and to flash the FW again.

I think that the problem might be related to the UvcHostApp not consuming the buffer committed the the consumer socket when I stop the execution, thus generating some sort of overflow. I tried to apply this suggestions without success Invalid Sequence Error in Multi-Channel Commit Buffer - KBA218830  .

Do you have any suggestions on where the problem could be? Do you know why the DMaMultiChannnel is not properly reset?

I thank you in advance for your answer.

Best regards,

Costantino

0 Likes
1 Solution

Hello Costantino,

Apologies for the delay.

In particular, I can always receive the  start request (setcur if I'm not wrong) on both uvc host (e-cam view and custom one). The problem with the custom one is that I never receive the uvc stop request and, when restarting, I miss the usb suspend and resume events before UvcAppStart is called"

=> Please refer to Section 5.8 of the appnote AN75779 from the link: https://www.cypress.com/file/123506/download

You will have to send the appropriate requests as mentioned (CLEAR_FEATURE) in the above section while closing the custom host application so that the streaming is stopped on the device side as well.

Also, can you trying using VLC media player in Linux and see if you can get the streaming properly?

You can find the VLC for Ubuntu from the link: https://www.videolan.org/vlc/download-ubuntu.html

Regards,

Yashwant

View solution in original post

0 Likes
5 Replies
YashwantK_46
Moderator
Moderator
Moderator
100 solutions authored 50 solutions authored 50 likes received

Hello Costantino,

I understand that this issue exists only after stopping and restarting the host application. Please confirm.


Can you please let me know what is the command being used to stop the stream in the custom host application?

If possible, please share the code snippet for stopping the stream.


Regards,Yashwant

0 Likes

Hello Yashwant and thank you for your reply.

Yes, I confirm that the issue exists only after stopping and restarting the host application.

I'm using a libuvc command named uvc_stop_streaming() to stop the stream in the custom host application.

In order to exit from the main loop where I get camera frames, a callback is activated when the SIGINT signal (ctrl + c) is received. This callback changes the value of a parameter and, thanks to this simple operation, I can exit the main loop and execute the uvc_stop_streaming() command.

Edit: I replicated the same issue using this simple example from libuvc:  https://github.com/libuvc/libuvc/blob/master/src/example.c ​(uvc_stop_streaming is on line 182, I commented line 177).

Let me know if you need some additional information.

Regards,

Costantino

0 Likes

Hello Costantino,

In the UvcAppStop(), please use the following reset code (in Bold😞

CyU3PMipicsiSleep();

CyCx3_ImageSensor_Sleep();     //Puts the image sensor to sleep to avoid sync issues

CyU3PGpifDisable(CyFalse);

glIsApplnActive = CyFalse;

CyU3PUsbSetEpNak(CX3_EP_BULK_VIDEO, CyTrue);

CyU3PBusyWait(100);

CyU3PDmaMultiChannelReset(&glChHandleUVCStream);

CyU3PThreadSleep(25);

CyU3PUsbFlushEp(CX3_EP_BULK_VIDEO);

CyU3PUsbSetEpNak(CX3_EP_BULK_VIDEO, CyFalse);

CyU3PBusyWait(200);

if (glIsClearFeature) {

CyU3PUsbStall(CX3_EP_BULK_VIDEO, CyFalse, CyTrue);

glIsClearFeature = CyFalse;

In case you haven't used the CyCx3_ImageSensor_Sleep();, it is important to put the sensor to sleep after putting the MIPI RX to sleep so as to maintain the sync between TX and RX and to not fill the DMA buffers inside CX3.

Please give it a try and let me know if you see any changes.

Regards,

Yashwant

0 Likes

Hello Yashwant and thank you for your answer.

Yes, the codes you are mentioning were already in my code.

In the meantime I've discovered something about my setup: I do not receive all the usb requests coming from the UVC host. The main difference that I neglected before is that I use e-cam view on Windows and my custom Uvc host on Ubuntu. Is it somehow possible that the usb requests are different when working with Ubuntu?

In particular, I can always receive the  start request (setcur if I'm not wrong) on both uvc host (e-cam view and custom one). The problem with the custom one is that I never receive the uvc stop request and, when restarting, I miss the usb suspend and resume events before UvcAppStart is called.


I hope these details will help you.

Regards,

Costantino

0 Likes

Hello Costantino,

Apologies for the delay.

In particular, I can always receive the  start request (setcur if I'm not wrong) on both uvc host (e-cam view and custom one). The problem with the custom one is that I never receive the uvc stop request and, when restarting, I miss the usb suspend and resume events before UvcAppStart is called"

=> Please refer to Section 5.8 of the appnote AN75779 from the link: https://www.cypress.com/file/123506/download

You will have to send the appropriate requests as mentioned (CLEAR_FEATURE) in the above section while closing the custom host application so that the streaming is stopped on the device side as well.

Also, can you trying using VLC media player in Linux and see if you can get the streaming properly?

You can find the VLC for Ubuntu from the link: https://www.videolan.org/vlc/download-ubuntu.html

Regards,

Yashwant

0 Likes