FX3 Frame size must be divisible by 1024, How to adjust this fixed variable?

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

cross mob
Wellington
Level 4
Level 4
100 sign-ins 50 sign-ins 25 replies posted

Hi,

I am developing image sensor application. Basically we want to grab frame send from fpga to FX3. Then FX3 send to PC via usb.

Lets say I have a frame size of 18432bytes, my SW is able to grab the frame successfully. Because 18432 is divisible by 1024.

However, if my frame size is 23040bytes, the frame grab will fail. I have checked the data grabbed using wireshark, it shows that only 22528 bytes is grabbed, and failed to grabbed the remaining data. We also checked on other inputs bytes, where any input data bytes if is not divisible by 1024, SW will fail.

 

Based on the Firmware, the usb setting are using CY_U3P_SUPER_SPEED, size = 1024, burstlength = 16.

 

May i know why this could happened or how to adjust the data input where it can divisible by any number?

Let me know if you need further input.

Thanks!

 

 

0 Likes
1 Solution

Hello,

USB 3.0 supports maximum packet size of 1024 bytes.

where to refer the the maximum packet size in firmware?

>> You can check the USB descriptor file  (for example : cyfxbulkdscr.c ) of the  firmware. In this case the maximum packet size is 1024 bytes 

/* Endpoint descriptor for consumer EP */

0x00,0x04, /* Max packet size = 1024 bytes */

It is expected that the host requests the data in multiple of maximum packet size (in this case 1024 bytes). 

Short packet means packet less than maximum packet size?

>> Yes. If maximum packet size for USB 3.0 is 1024 bytes so data less than 1024 will be short packet.

For example, if host requests for 1024 bytes (multiple of maximum packet size) of data from the device. But if device has only 1023 bytes (<1024 bytes i.e. short packet), then only 1023 bytes will be sent by the device and XferData API will return with 1023 bytes of data.

This above example is tested using Control center and the results are as below

Data requested (bytes to transfer) : 1024 bytes

Data received from FX3: 1023 bytes (short packet)

checkk_sp.PNG

Regards,
Rashi

View solution in original post

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

Hello,

From the description I understand that on the host application side the frame is not being grabbed if the transfer size is not multiple of 1024. Is this correct?

Please let me know which host application are you using for grabbing the frames. Is it a custom application using Cypress provided libraries (CyAPI.lib or CYUSB.NET)? 

From the descriptions it seems that the host application settings  avoids the USB short packets (less than 1024 bytes) 

Regards,
Rashi
0 Likes

Hi

From the description I understand that on the host application side the frame is not being grabbed if the transfer size is not multiple of 1024. Is this correct?

-> Yes

We are using CyAPI.lib

Any idea how to adjust the limit of 1024 where it can divisible by any number? 

0 Likes

Hello,

Please let me now how do you confirm that the short packets (<1024) are not received on the host application.

XferData API will return  in the mentioned three conditions - a. entire requested data is obtained from fx3 b. short packet is received (not max pkt size multiple) c. ZLP is received

Please refer to similar thread Solved: can XferData() receive partial BULKIN Packet ? - Cypress Developer Community 

Regards,
Rashi
0 Likes

Hi,

I tested 2 scenario.

1.) On control Center

input Transfer Data in 1024

Get good feedback from control center, check wireshark log: able to see 1024 data has been transfered.

input Transfer Data in 1023

Get timeout feedback 997 from control center, check wireshark log: not able to see 1023 data. (This is because 1024 is the minimum size and i would like to know how to change this)

2.)

input Transfer Data in 16384

Get good feedback from control center, check wireshark log: able to see 16384 data has been transferred.

input Transfer Data in 16383

Get timeout feedback 997 from control center, check wireshark log: CAN see 15360 data has been transfer. Somehow Xferdata only able to grab the data that is divisible by 1024. In this case which is 15360/1024. 

I would like to know how to adjust this 1024 to any variable? i just want to achieve any frame data bytes can be divided by 1024.

 

Thanks!

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

Hello,

Please confirm if the device has only 1023/16383 bytes of data when 1023/16383 bytes are requested from control center.

If the device FX3 has 1024/16384 bytes committed to USB socket and the host asks only for 1023/16383 bytes i.e. not multiple of maximum packet size then USBD_STATUS_BABBLE_DETECTED error is seen.

So, it is expected that the host sends the USB requests in multiple of maximum packet size. If the device is left with 1023 bytes (< 1024 bytes )of data and 1024 bytes are requested from host then short packet will be committed to the host.

Please check the following, I am committing 1023 bytes of data to USB socket in the firmware and requesting for 1024 bytes.

checkk_sp.PNG

So, from the host application it is expected to request data of maximum packet size and if the device will not have data equal to what is requested, a short packet will be sent.

Regards,
Rashi
0 Likes

Hi Rashi,

Sorry, i do not understand some of your reply above. I am very new to this cypress Firmware.

maximum packet size do you meant is 1024 bytes?

Short packet means packet less than maximum packet size?

where to refer the the maximum packet size in firmware?

 

Thanks

0 Likes

Hello,

USB 3.0 supports maximum packet size of 1024 bytes.

where to refer the the maximum packet size in firmware?

>> You can check the USB descriptor file  (for example : cyfxbulkdscr.c ) of the  firmware. In this case the maximum packet size is 1024 bytes 

/* Endpoint descriptor for consumer EP */

0x00,0x04, /* Max packet size = 1024 bytes */

It is expected that the host requests the data in multiple of maximum packet size (in this case 1024 bytes). 

Short packet means packet less than maximum packet size?

>> Yes. If maximum packet size for USB 3.0 is 1024 bytes so data less than 1024 will be short packet.

For example, if host requests for 1024 bytes (multiple of maximum packet size) of data from the device. But if device has only 1023 bytes (<1024 bytes i.e. short packet), then only 1023 bytes will be sent by the device and XferData API will return with 1023 bytes of data.

This above example is tested using Control center and the results are as below

Data requested (bytes to transfer) : 1024 bytes

Data received from FX3: 1023 bytes (short packet)

checkk_sp.PNG

Regards,
Rashi
0 Likes