CyU3PDmaMultiChannelCommitBuffer Return ErrorCode:CY_U3P_ERROR_INVALID_SEQUENCE

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

cross mob
xixu_4093676
Level 3
Level 3
25 replies posted 10 replies posted 10 questions asked

Hi Cypress Support,

We are refer to Asyn Slave fifo AN65974 , to use two DMA Thread to transfer data with FPGA then forward the data to USB.

But after some time, I see CyU3PDmaMultiChannelCommitBuffer(...) get error code (0x47) = CY_U3P_ERROR_INVALID_SEQUENC.

Then The FPGA still check the status of FLAGA and FLAGB  is Low.

I also attach the GPIF design file and my application code.

What's the reason lead to the issues?

Thanks,

Martin

0 Likes
1 Solution
Hemanth
Moderator
Moderator
Moderator
First like given First question asked 750 replies posted

Hi Martin,

1. Please perform CyU3PDmaMultiChannelCommitBuffer() only when CyU3PDmaMultiChannelGetBuffer() succeeds as done in AN75779 firmware and then let me know the behavior. As of now maintain 16KB buffer as it was before.

2. After FPGA starts writing into one thread when Flag A/B is high, can you let me know when will it stop writing into the socket?

Note: When you are using MultiChannel, it is expected that the data is filled into the sockets in order i.e Sck 0, Sck 1, Sck 0, Sck 1...You should make sure it will not miss this order.

Regards,

Hemanth

Hemanth

View solution in original post

0 Likes
19 Replies
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello,

The error code 0x47 for CyU3PDmaMultiChannelCommitBuffer() after some time of streaming indicates that the host is not able to issue IN tokens fast enough to pull out the data from the U Port. Eventually the DMA buffers associated with the channel between P Port and U Port will be filled and hence FLAGA and FLAGB stay low. Please try the suggestions mentioned in the following KBA and let me know the result:

Invalid Sequence Error in Multi-Channel Commit Buffer - KBA218830

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

What's  define START_SCK0 and ALPHA_START_SCK0,

I get failure when  build the code.

in my orign code, for start gpif, we onlyl CyU3PGpifSMStart (RESET,ALPHA_RESET). no call  CyU3PGpifSMSwitch (257, 0, 257, 0, 2);

for fix  the issues, we must use your call logic?

0 Likes

Hello,

Please let me know the following:

1. Did you try increasing the DMA buffer size allocated with the P to U channel? If you tried increasing, please let me know what is the buffer size you are using now.

2. The maximum supported clock for GPIF II block is 100MHz. Please confirm that your clock frequency is less than 100MHz.

Regarding your query in previous response, you can call the CyU3PGpifSMStart (RESET,ALPHA_RESET) instead of the call mentioned in the KBA. This is because the changes mentioned in the KBA are meant for the firmware that comes along with AN75779 and the corresponding state machine. It is okay to modify it based on your application. Also, you can call the CyU3PGpifSMSwitch() as mentioned in the KBA without any changes as it wont make any undesirable effects.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

For single Thread, DMA size is 15*1024 + 16, count is 8.

For two thread , DMA size is 15*1024 + 16, count is 4.

if I use count 8 with two thread DMA size is 15*1024 + 16, count is 8, I will get malloc memory failure error code.

I try to increasing the DMA buffer size to 5, I still see the 0x47 error code.

Now my GPIF block clock frequency is 100MHz.

It is a little strange that we use single thread, I don't see the error.

it get more lower transfer speed with dual thread.

We just want to improve camera frame rate , what's more best soluation?

0 Likes

Hello,

Please try increasing the buffer size to 31*1024+16 and reducing the buffer count in steps so that the memory failure error is not seen. Then check if you are facing the error again. If you are still facing the error, then try increasing buffer size further and decrease the buffer count so that memory failure error is not seen.

If you still face the error, please perform the suggestions mentioned in the KBA shared before. While implementing the changes, please check if any of the APIs are failing. Please let me know if no APIs are failing and still you are seeing this error.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Can you help us confirm if dual thread mode get higher performance.

Currently, the app working ok under single thread(50fps) , But app get the error under dual thread(50fps) .

0 Likes

Hello,

When single thread is used, the producer socket will fill up a buffer and then switch to the next buffer. This buffer switching takes a bit long to happen. Hence there will be a reduction in data rate. When multiple producer sockets are used, you can fill the DMA buffers associated with each socket alternatively by performing a socket switch. The socket switching takes relatively less time compared to buffer switching and hence can increase data rate.

The error occurs because the host application is too slow to issue IN tokens to clear the filled buffers associated with the producer sockets. The workaround for this is to increase the buffer size so that we match the rate at which producer fills the buffer and USB emptying it.

Please let us know if this application is UVC compliant or not.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hello,

  Our application is UVC compliant.

I don't think the host application is slow,

I don't see the commit failure (CY_U3P_ERROR_INVALID_SEQUENCE) when frame rate to  50fps with single thread 8 dma buffer.

But  I see the commit failure (CY_U3P_ERROR_INVALID_SEQUENCE) even if the frame rate set to 20fps with dual thread 6 dma buffer with the same application as  single threade mode

1. Can you please confirm all reason on the commit buffer error (CY_U3P_ERROR_INVALID_SEQUENCE).

2. Are there any uvc sample code with dual thread mode?

3. Also,Can you help us confirm following releated code (use 16bit mode)?

#if (CY_FX_SLFIFO_GPIF_16_32BIT_CONF_SELECT == 0)
CyU3PGpifSocketConfigure(0, CY_U3P_PIB_SOCKET_0, 12*1024/4, CyFalse, 1);

CyU3PGpifSocketConfigure(1, CY_U3P_PIB_SOCKET_1, 12*1024/4, CyFalse, 1);
#else
if (CY_FX_SLFIFO_GPIF_16_32BIT_CONF_SELECT == 1)
CyU3PGpifSocketConfigure (0,CY_U3P_PIB_SOCKET_0,3,CyFalse,1);
#endif

About Create MultiChannel:

CyU3PMemSet ((uint8_t *)&dmaMultiConfig, 0, sizeof(dmaMultiConfig));
dmaMultiConfig.dmaMode = CY_U3P_DMA_MODE_BYTE;
dmaMultiConfig.notification = CY_U3P_DMA_CB_PROD_EVENT | CY_U3P_DMA_CB_CONS_EVENT;
dmaMultiConfig.cb = CyFxUvcApplnDmaCallback;
dmaMultiConfig.prodHeader = CY_FX_UVC_MAX_HEADER;
dmaMultiConfig.prodFooter = CY_FX_UVC_MAX_FOOTER;
dmaMultiConfig.consHeader = 0;
dmaMultiConfig.prodAvailCount = 0;

/* Create a DMA AUTO channel for P2U transfer. */
dmaMultiConfig.size = CY_FX_UVC_STREAM_BUF_SIZE; //increase buffer size for higher performance
dmaMultiConfig.count = CY_FX_UVC_STREAM_BUF_COUNT; // increase buffer count for higher performance
CyU3PDebugPrint(4, " dmaMultiConfig.size = %d\n", dmaMultiConfig.size);
CyU3PDebugPrint(4, " dmaMultiConfig.count = %d\n", dmaMultiConfig.count);
dmaMultiConfig.validSckCount  = 2;
//dmaMultiConfig.prodSckId = CY_FX_PRODUCER_PPORT_SOCKET;  // Thread0 ==> EP 0x83
dmaMultiConfig.prodSckId [0]  = (CyU3PDmaSocketId_t)CY_U3P_PIB_SOCKET_0;
    dmaMultiConfig.prodSckId [1]  = (CyU3PDmaSocketId_t)CY_U3P_PIB_SOCKET_1;
dmaMultiConfig.consSckId [0]  = (CyU3PDmaSocketId_t)(CY_U3P_UIB_SOCKET_CONS_0 | CY_FX_EP_VIDEO_CONS_SOCKET);
apiRetStatus = CyU3PDmaMultiChannelCreate (&glChHandleSlFifoPtoU, CY_U3P_DMA_TYPE_MANUAL_MANY_TO_ONE,&dmaMultiConfig);
    if (apiRetStatus != CY_U3P_SUCCESS)
{
  CyU3PDebugPrint(4, "CyU3PDmaMultiChannelCreate failed, Error code = %d\n", apiRetStatus);
  CyFxAppErrorHandler(apiRetStatus);
}

Thanks,

Martin

0 Likes

Hello JayakrishnaT

Let's provide update more infomation:

Commit Err1: 47 369  //Show get  CY_U3P_ERROR_INVALID_SEQUENCE)

Commit Err1: 47 370

CYU3P_PIB_ERR_THR0_WR_OVERRUN

Commit Err1: 47 371

CYU3P_PIB_ERR_THR0_WR_OVERRUN

CYU3P_PIB_ERR_THR0_WR_OVERRUN

CYU3P_PIB_ERR_THR1_WR_OVERRUN

CYU3P_PIB_ERR_THR1_WR_OVERRUN

Clear feature request detected.. //windows send feature request then stream been stopped.

CYU3P_PIB_ERR_THR0_WR_OVERRUN  // FPGA write the data to P port only when the FLAG is High state, why still see CYU3P_PIB_ERR_THR0_WR_OVERRUN and CYU3P_PIB_ERR_THR1_WR_OVERRUN.

By my understand if see CYU3P_PIB_ERR_THR1_WR_OVERRUN, it means that FPGA write to P Port when FLAGA/B stay Low level , is it correctly?

For detail information on GPIF design file please refer to the first comment's attached file.

Thanks,

Martin

0 Likes

Update debug information Bus hound:

single thread:

Dual thread mode:single_thread.JPG

dual_thread.JPG

  Some founds between single/dual thread mode.

  single mode:

  UVC head packet seqnumber is continue and Bus Hound Delta time(between two packet) = 70~160us

  Dual mode:

  UVC head packet seqnumber is not continue(02/05/04/07/06/09/08/0b/0a/0d) and Bus Hound Delta time(between two packet) = 70~100us

  so, I have two question:

  1. Dual thread mode don't keep the packet seq that it been send out on usb bus by call CyU3PDmaMultiChannelCommitBuffer()?

  2. Dual thread mode will lead packet ready to send out to usb slow?

0 Likes

Hello,

Please find my comments for your response 8,9 and 10.

Regarding your questions in response 8,

1. We have seen the error code 0x47 for CyU3PDmaMultiChannelCommitBuffer() when there is a DMA overflow. This is again confirmed in your debug prints shown in response 9.

2. Yes, we do have an implementation of image sensor interface using FX3 in UVC Framework. Please refer to the following link which has the complete documentation and project for this implementation

https://www.cypress.com/documentation/application-notes/an75779-how-implement-image-sensor-interface...

3. Please let me know why you have used the watermark value as 12*(1024/4). Also, please confirm that the macro CY_FX_SLFIFO_GPIF_16_32BIT_CONF_SELECT when set to 0 is 16 bit mode and is 32 bit mode when set to 1.

Regarding your question in response 9, the overrun error occurs when a write to a socket is done beyond the available buffer size. Your understanding is correct, FPGA might also be writing to the socket when the buffers are full.

Regarding your question in response 10,

1. Packet sequence will be followed properly. This happens because in between transmission of buffers from P Port to U Port, some buffers are not sent because the API CyU3PDmaMultiChannelCommitBuffer() fails. This is why you do not see the sequence continuously.

2. Generally dual thread will increase data rate.

According to the logs shared in your response 10, I find that the data buffer size is not changed to 31*1024+16 as I recommended in Response 7. Also, please let me know the logical implementation on the FPGA side. I understand that the thread switching is done  by the FPGA. Please let me know how you are implementing this.

Also, please let me know what is the value of the macro CY_FX_EP_BULK_VIDEO_PKT_SIZE.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hello Jayakrishna,

 

Please see the following my comment key "My Answer"

3. Please let me know why you have used the watermark value as 12*(1024/4). Also, please confirm that the macro CY_FX_SLFIFO_GPIF_16_32BIT_CONF_SELECT when set to 0 is 16 bit mode and is 32 bit mode when set to 1.

My Answer: Yes,  CY_FX_SLFIFO_GPIF_16_32BIT_CONF_SELECT been set 0.

Regarding your question in response 9, the overrun error occurs when a write to a socket is done beyond the available buffer size. Your understanding is correct, FPGA might also be writing to the socket when the buffers are full.

My  Answer: It is a little strange, on the FPGA side, if FLAGA/B is not ready(FLAG=0), FPGA will wait and not write to GPIF.

We don't know why we still see CYU3P_PIB_ERR_THR0/1_WR_OVERRUN event sometimes .

Regarding your question in response 10,

1. Packet sequence will be followed properly. This happens because in between transmission of buffers from P Port to U Port, some buffers are not sent because the API CyU3PDmaMultiChannelCommitBuffer() fails. This is why you do not see the sequence continuously.

2. Generally dual thread will increase data rate.

My  Answer:  I expect see the Packet sequence is 1/2/3/4/5..., but dual thread I see 5/4/7/6/9/8 (it seem like there are not  CommitBuffer fails)

According to the logs shared in your response 10, I find that the data buffer size is not changed to 31*1024+16 as I recommended in Response 7. Also, please let me know the logical implementation on the FPGA side. I understand that the thread switching is done  by the FPGA. Please let me know how you are implementing this.

My  Answer: It is a little strange, on the FPGA side, please see following process

  1. if FLAGA pin status is Idle(High level),FPGA write data to Thread0 Slave fifo by config AddressBus(GPIO29:28 = b'00).

  2. if FLAGB pin status is Idle(High level),FPGA write data to Thread1 Slave fifo by config AddressBus(GPIO29:28 = b'01).

  3. FPGA use pingpong model, this time write data to Thread0 Slave fifo , and next time write data to Thread1 Salve fifo.

Also, please let me know what is the value of the macro CY_FX_EP_BULK_VIDEO_PKT_SIZE.

Currently, CY_FX_EP_BULK_VIDEO_PKT_SIZE = 0x400.

0 Likes

Hello,

I find that in the GPIF II project that you shared before, Watermark flags are not used. Generally, Ready flags are to be monitored for starting a data transfer and watermark flags are to be monitored for ending the data transfer. You can understand more about this by going through AN65974. The link to the same is given below:

https://www.cypress.com/file/136056/download

Please refer to Figure 4 of the above document. From this, you can understand that there is a 3 cycle latency between last WR signal (buffer full) and FLAG going low. So, during these clock cycles, the READY flag will stay HIGH and FPGA will keep on writing data which can cause overrun. To avoid this, you need to use watermark flag. To understand more about watermark flag and how to use it, you can go through from section 9.3 of AN65974(link shared before). Please make use of watermark flag also in the project. For start of the data transfer to a particular socket, you need to check ready flag and for ending the data transfer, you need to check watermark flag for that socket. Please implement this and let me know if you are still seeing overrun error.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hello,

    

      if change buffersize  to 31*1024 + 16,  I see xact error in bus hound.

IMG_5384.JPG

  Are there any other lost to changes?

0 Likes

Regrading as  AN65974 section 4.3 say:

Example 3 Slave FIFO with 16-bit data bus:

▪ In GPIF II Designer, FLAGA is configured as Current_thread_DMA_RDY and FLAGB is configured as Current_thread_DMA_watermark.

  ▪ CyU3PGpifSocketConfigure (0, PIB_SOCKET_3, 3, CyFalse, 1).

▪ Burst write is performed from external FPGA to EZ-USB FX3 over Slave FIFO (the last data to be written is 0x0200).

The following figure is a logic analyzer screenshot of how the flags go to 0 at the end of the transfer.

You can see that FLAGB (the partial flag) goes LOW three cycles before the last data. This means, two words of data may be written after the cycle in which FLAGB goes LOW.

Just a question, how to understand the two input param threadIndex and socketNum? how to match my project setting?

0 Likes
Hemanth
Moderator
Moderator
Moderator
First like given First question asked 750 replies posted

Hi Martin,

1. Please perform CyU3PDmaMultiChannelCommitBuffer() only when CyU3PDmaMultiChannelGetBuffer() succeeds as done in AN75779 firmware and then let me know the behavior. As of now maintain 16KB buffer as it was before.

2. After FPGA starts writing into one thread when Flag A/B is high, can you let me know when will it stop writing into the socket?

Note: When you are using MultiChannel, it is expected that the data is filled into the sockets in order i.e Sck 0, Sck 1, Sck 0, Sck 1...You should make sure it will not miss this order.

Regards,

Hemanth

Hemanth
0 Likes

Hello Hemanth,

1. Please perform CyU3PDmaMultiChannelCommitBuffer() only when CyU3PDmaMultiChannelGetBuffer() succeeds as done in AN75779 firmware and then let me know the behavior. As of now maintain 16KB buffer as it was before.

Answer: In my project, We no need to call CyU3PDmaMultiChannelGetBuffer, just call the CyU3PDmaMultiChannelCommitBuffer in the Dmacallback.

2. After FPGA starts writing into one thread when Flag A/B is high, can you let me know when will it stop writing into the socket?

Answer: if FPGA firmware detect the FLAG A/B is High status, it will write one full/less packet data(in my application, it is 15*1024 + 16).

We still are facing the question that if use dual thread mode, see many CommitBuffer failure with same host application.

It seem like the dual thread get more slower transfer speed than single thread mode.

Thanks,

Martin

0 Likes
Hemanth
Moderator
Moderator
Moderator
First like given First question asked 750 replies posted

Hi Martin,

Yes, I understand that you are not calling CyU3PDmaMultiChannelGetBuffer() as of now. Can you please try it. Perform CyU3PDmaMultiChannelGetBuffer() and if succeeds do CyU3PDmaMultiChannelCommitBuffer() as done in reference code of  https://www.cypress.com/documentation/application-notes/an75779-how-implement-image-sensor-interface...

Regards,

Hemanth

Hemanth
0 Likes
Hemanth
Moderator
Moderator
Moderator
First like given First question asked 750 replies posted

One more point: Referring to your comment: "if FPGA firmware detect the FLAG A/B is High status, it will write one full/less packet data": This does not assure that writing starts from sck0 and then moves to sck1...It can also be sck1, sck0,.. Can you please confirm the same?

Regards,

Hemanth

Hemanth
0 Likes