USB3 Vision DMA on Leader packet on FX3

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

cross mob
user_1484456
Level 2
Level 2
25 sign-ins 10 replies posted 10 sign-ins

USB3 vision is used for camera on a FX3 solution. the DSI stream DMA callback method has been able to send picture packets successfully. According to USB3 vision protocol, the leader packet must be sent previously. how to do it with DMA?

If  the DSI stream DMA channel is used to sebd leader packet in method CyFxUSB3VisionDSIDmaCallback,  its buffer contains the valid pixel data. if the leader packet is copied into current DMA buffer, this buffer of pixel data lost. if the method CyU3PDmaMultiChannelSetupSendBuffer is used with a specific DMA buffer to send out leader packet, it always failed to do it. should I use a specific DMA channel to send leader & trailer packet?

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.

Hello,

If the DMA channel is used in override mode, to transmit leader, payload, and trailer packet in a sequence, the DMA channel has to be reset and configured for every DMA event. it is ineffective. in the meantime, the GPIF always gets pixel data continuously, to have DMA switch in different modes will cause pixel data loss.

>> Yes, if the DMA is configured in override mode the streaming would be slow

Please find the attached modified GPIF state machine for adding a leader and trailer for every frame.

In the default AN75779 state machine, 6 states have been added i.e. State 18,19,20,21,22,23

The DMA callback which comes due to state 19 / state 22 is for trailer addition;

The DMA callback which comes due to state 18 / state 21 is for leader addition.

Modifications need to be done in the DMA callback such that when the first buffer with buffer.count == 0  (i.e. empty buffer is committed) occurs (state 18/state 21) where the leader needs to be added and from the next time i.e. state 19 /state 22 trailers should be added. In all these four states Commit action is done which commits empty DMA buffer. So, you can check for empty DMA buffer and add trailer and leader accordingly.

Please try using this GPIF  state machine in your application and let me know if it works

Regards,

Rashi

Regards,
Rashi

View solution in original post

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

Hello,

The same DMA channel can be used to send the leader and trailer packets.

Please refer to this KBA DMA Channel in Override Mode in FX3/CX3 - KBA229098  which explains the DMA channel in Override mode.

You can also refer to the firmware attached with this thread cx3 use overridemode

Note: The firmware attached with the above thread is for CX3, similar changes can be done in the FX3 firmware that you are working on

Please let me know if any queries on it.

Regards,

Rashi

Regards,
Rashi
0 Likes

Hi Rashi,

when the DMA is used to get pixel data of picture, its buffer has robin-round fashion. the buffer is just able to get from prod socket buffer robin-round, and put into cons socket ones by API getbuffer and commitbuffer. it is impossible to transmit leader or trailer packet with same a DMA channel. how to transmit leader and trailer to comply to U3V protocol?

If the DMA channel is used in override mode, to transmit leader,payload, and trailer packet in sequence, the DMA channel has to be reset and configured for every DMA event. it is ineffective. in the meantime, the GPIF always gets pixel data continuously, to have DMA switch in different mode will cause pixel data loss.

can the conclusion be drawn: for FX3014 camera solution without DDR buffer, it is impossible to implement USB3 vision camera design?

If this conclusion is incorrect, how to resove these issues?how to use DMA for leader and trailer packet while DMA channel is busy in pixel data?

0 Likes
lock attach
Attachments are accessible only for community members.

Hello,

If the DMA channel is used in override mode, to transmit leader, payload, and trailer packet in a sequence, the DMA channel has to be reset and configured for every DMA event. it is ineffective. in the meantime, the GPIF always gets pixel data continuously, to have DMA switch in different modes will cause pixel data loss.

>> Yes, if the DMA is configured in override mode the streaming would be slow

Please find the attached modified GPIF state machine for adding a leader and trailer for every frame.

In the default AN75779 state machine, 6 states have been added i.e. State 18,19,20,21,22,23

The DMA callback which comes due to state 19 / state 22 is for trailer addition;

The DMA callback which comes due to state 18 / state 21 is for leader addition.

Modifications need to be done in the DMA callback such that when the first buffer with buffer.count == 0  (i.e. empty buffer is committed) occurs (state 18/state 21) where the leader needs to be added and from the next time i.e. state 19 /state 22 trailers should be added. In all these four states Commit action is done which commits empty DMA buffer. So, you can check for empty DMA buffer and add trailer and leader accordingly.

Please try using this GPIF  state machine in your application and let me know if it works

Regards,

Rashi

Regards,
Rashi
0 Likes

I can transmit leader and part of pixel data, but with something wrong with stream DMA.

According to the usb log, the leader and a packet of pixel data,512 bytes long, are transmited successfully. so that 2 pairs of PROD and CONS events are received. after the 3th packet is transmitted, no CONS event comes back. it seems that the streaming DMA stops. I can't find the reseaon. I use same DMA configuration with UVC project, the DMA runs correctly in the UVC streaming. Furthermore, the DMA packet length is not able to be longer than 512, or only leader is able to be transmitted correctly. but this issue doesn't exist in UVC project.

0 Likes

Hello,

Please confirm if you are using the GPIF state machine that I shared in response 3.

If yes, the GPIF state machine uses the default GPIF bus width of 8 bits (sensor- fx3 interface) and DATA_COUNT and ADDR_COUNT value as 16367 (i.e. DMA buffer size 16KB). Please confirm if your application makes use of a similar configuration.

If yes, please share the UART debug prints that track the PRODUCER and CONSUMER events and the amount of data transferred by enabling this  DEBUG_PRINT_FRAME_COUNT macro.

Please confirm if the device enumerates as a Superspeed device. You can try calling CyU3PUsbGetSpeed () API after CyU3PConnectState API and then check the return value of CyU3PUsbGetSpeed. If it enumerates as a Superspeed device, it will return 3.

Please share the complete USB log (from the enumeration of the device to video streaming) as well as the UART debug logs.

Regards,

Rashi

Regards,
Rashi
0 Likes

(1) The USB runs in SS mode, I think, for the application gives the following log out:

    UsbEventCB: Detected SS USB Connection

(2) after I start streaming,  I can find 2 USB data packets, one for leader, the other for pixel data with 512 bytes long. only 512-byte-length is valid for DMA, or no packets is given out by USB DMA.

(3) after I start streaming, the uart prints following logs. obviously, leader is transmitted; then 512 bytes are done; following 2 packets are transmitted, then the DMA hangs for cons event. however, in the USB tools, only leader and a packet are found. I think it related to dma configuration.

0 Likes

Hello,

From the description, I understand that there are only two CONSUMER events seen and after that, there are no CONSUMER events. Please confirm.

- Please confirm if the firmware that you are using is similar to AN75779 firmware except the modification needed for U3V

- Please let me know if  there are any Producer events after the once shown in debug prints you shared

- How many DMA buffers (CY_FX_UVC_STREAM_BUF_COUNT) are used for the DMA channel.

- Also let me know the number of  IN requests on the streaming endpoint (in the USB logs).

Please share the complete USB logs and UART debug prints for me to check. This will help us to debug the issue faster.

Regards,

Rashi

Regards,
Rashi
0 Likes

I add U3V protcol into  AN75779 firmware, but no modification is given to DMA configuration, and 4 buffer are used as AN75779 does.  

is it possible to be related to USB low power management?

0 Likes

Hello,

is it possible to be related to USB low power management?

>> As the CONSUMER events are not seen the host is not consuming the data from the DMA buffer (seems that there are no BULK IN requests from host). To comment on your question we need to check the complete USB logs and UART debug prints,

Please share the complete USB logs (from enumeration of device to streaming) and UART debug prints (from enumeration of device to streaming). This will help in debugging the issue faster.

Regards,

Rashi

Regards,
Rashi
0 Likes

There is no GPIF event in streaming. If the GPIF configuration from you is used, the GPIF state machine in the firmware needs update? is it same as that of UVC?

0 Likes
lock attach
Attachments are accessible only for community members.

Hello,

Please replace the cyfxgpif2config.h (old) in your project with the cyfxgpif2config.h (new) that I have shared in the response 3. I have modified the GPIF state machine for U3V (attached).

Also, changes are required in the DMA callback as mentioned in response 3

From response 3:

Please find the attached modified GPIF state machine for adding a leader and trailer for every frame.

In the default AN75779 state machine, 6 states have been added i.e. State 18,19,20,21,22,23

The DMA callback which comes due to state 19 / state 22 is for trailer addition;

The DMA callback which comes due to state 18 / state 21 is for leader addition.

Modifications need to be done in the DMA callback such that when the first buffer with buffer.count == 0  (i.e. empty buffer is committed) occurs (state 18/state 21) where the leader needs to be added and from the next time i.e. state 19 /state 22 trailers should be added. In all these four states Commit action is done which commits empty DMA buffer. So, you can check for empty DMA buffer and add trailer and leader accordingly.

>> Please make the necessary changes as mentioned above and share the firmware file for us to check

Regards,

Rashi

Regards,
Rashi
0 Likes