cancel
Showing results for 
Search instead for 
Did you mean: 

USB Superspeed Peripherals

saku_4625426
New Contributor

Hello Community,

Can we pass vendor requests without using control center i.e..,can we make it automatic in code itself?

Let me know whether this is possible or not.

Regards,

Sai.

0 Likes
1 Solution
YashwantK_46
Moderator
Moderator

Hi Srujana,

1.) " I changed it to 512*150 and count as 2"

--> This is not correct even if the device is enumerating because the type of dmaConfig. size is uint16_t and the max it can accommodate is 65535 but 512*150 = 76800.

So, the extra data will be truncated to only 2^16-bits of data and rest will be lost.

So, please change the msc.h file values as:

#define CY_FX_MSC_DMA_BUF_COUNT         (20)             /* MSC channel buffer count */

#define CY_FX_MSC_EP_BURST_SIZE         (15)             /* Burst setting for the endpoint. */

I have verified this on my end and the device is enumerating properly with the above setting and there are truncation warnings in the USB Suite as well.

​2.) Also, please add the cyu3sport library in the linker path as shown below, if you haven't added it already.

pastedImage_1.png

Regards,
Yashwant

View solution in original post

0 Likes
26 Replies
YashwantK_46
Moderator
Moderator

EDITED:

Hello Sai,

You can always automate code by using flags and then checking on them and once the flag is set, performing the action that you want to perform.


The main action that needs to be performed should be added in the for (;;) loop such that the condition will always check on the value of the flag.

Also, you can use the host application to send the vendor commands to the device. You can refer to Section 9.3 of the document (Standard USB Device Requests): https://www.usb3.com/whitepapers/USB%203%200%20%2811132008%29-final.pdf


Regards,

Yashwant

0 Likes
saku_4625426
New Contributor

Hello,

Thanks a lot for your quick reply.

I am mentioning my application clearly for correctness

I want to program FX3 into SPI Flash (Booting) and not to send vendor requests explicitly in Control Center.Whenever there exists a newly  sampled data in P-Port of FX3,it should be able to write into SD Card(Whenever needed We can read it using host application).This is what I am thinking to do.Is this Possible or not?

I have gone through the above document and assuming that above mentioned application can be implemented.

Do you have any piece of code about how to pass those(In Doc) values in main application for my reference?

Regards,

Sai.

0 Likes
saku_4625426
New Contributor

Hello,

Please do reply for my previous response.

Regards,

Sai.

0 Likes
saku_4625426
New Contributor

Hello,

As mentioned in table 9.2 of given document as attached,how to give those values in main function.( D7 - 1 , D6..5 -  2(11)  -> vendor , D4..0 -  0(00000) -> device )

D[7:0] -> 11100000

I want to select below configuration in Control Center

Direction     -     out

Req Type    -     Vendor

Target         -     Device

Regards,

Sai.

0 Likes
YashwantK_46
Moderator
Moderator

Hello Sai,

Can you tell me what is the final image size or the data size that the PIB block will commit to the SIB block?

I need this information to try and understand making your code autonomous.


Regards,
Yashwant

0 Likes
saku_4625426
New Contributor

Hello,

As of now my image pixel size is 640*480 and it is of 4KB and later on we will increase both resolution and size if this starts working.

Regards,

Sai.

0 Likes
saku_4625426
New Contributor

Hello,

Please let me know how to include that requests in main function or provide me any reference code for the same so that I can implement in my firmware.Waiting for your reply.

Regards,

Sai.

0 Likes
YashwantK_46
Moderator
Moderator

Hello Sai,

Can you please clarify what you mean by "my image pixel size is 640*480 and it is of 4KB" ?

If you take the pixel size into consideration, total size would be 640*480*pixel_depth (let's say 1Byte/Pixel) = 307200 Bytes/1024 = 300KB which is not equal to 4KB.

Please tell us the exact image size that you want to store in the SD card so that I can modify the firmware on my end.


Regards,
Yashwant

0 Likes
saku_4625426
New Contributor

Hello,

My exact image size is 640*480 and if it works for 640*480,I need to change the pixel size for 752*480.

And your calculation is exactly correct,according to pixel size we have to change buffer size. Correct?

Regards,

Sai.

0 Likes
YashwantK_46
Moderator
Moderator

Hello Sai,

Please perform the firmware modifications as suggested by me and get back to me with the results.

Regards,

Yashwant

0 Likes
GiSa_4520796
New Contributor II

Hello,

As you suggested I am modifying my firmware for removing vendor requests in my application.I commented the vendor requests declaration in firmware and trying to add the below snippet.Am I doing correct or not?Please let me know if this is wrong.

    if (evt == CY_U3P_DMA_CB_XFER_CPLT)

          {

               if(status == CY_U3P_SUCCESS)

    

                  {

  

                         status = CyU3PSibReadWriteRequest (CY_FX_SIB_WRITE, 0,glLunUnit[0], 8, (uint32_t)blkadd, 0);

                         if (status != CY_U3P_SUCCESS)

                              {

                         /* Abort the DMA Channel */

                          CyU3PDmaChannelReset (&glChHandleMscIn);

                              }

                          status = CyU3PSibReadWriteRequest (CY_FX_SIB_READ, 0,glLunUnit[0], 8, 2, 1);

                          if (status != CY_U3P_SUCCESS)

                               {

                          /* Abort the DMA Channel */

                          CyU3PDmaChannelReset (&glChHandleMscIn);

                               }

                         //SIB_XFER

                    }

          }

Regards,

Srujana.

0 Likes
GiSa_4520796
New Contributor II

Hello,

Waiting for your reply.

Regards,

Srujana.

0 Likes
GiSa_4520796
New Contributor II

Hello,

When i added the above snippet as mentioned in my previous response,the device is enumerating succesfully.But it is not going into the loop(I checked by adding DeviceReset over there).What modifications should be done still?

Regards,

Srujana.

0 Likes
YashwantK_46
Moderator
Moderator

Hello Srujana,


1.) Have you changed the second parameter's value in CyU3PDmaChannelSetXfer() to 150KB as suggested previously?

If not, replace apiRetStatus = CyU3PDmaChannelSetXfer (&glChHandleMscIn, 0); to

                                   apiRetStatus = CyU3PDmaChannelSetXfer (&glChHandleMscIn, 153600);               //150KB

2.) In the channel creation,  if you are using a USB2.0 connection, change the buffer size to 512 * 15 and count to 20 to make it 150KB.

If you are using USB3.0 connection, change the buffer size to 1024 * 15 and count to 10 to make it 150KB.

This is necessary to get the entire 150KB image data into the buffers.

3.) In the DMA callback for the, in PROD_EVENT, the buffers will be committed based on the USB speed, either 10 or 20 and will reach the SIB block buffers.

4.) In the CyFxMscApplnDmaCb(), under the case CY_U3P_DMA_CB_PROD_EVENT:, once committing is done, increment a variable and when that variable comes equal to the buffer count, either 10 or 20, based on the USB speed, set a flag like below:

    

uint8_t prod = 0;                                                                      //Declaration

CyBool_t prodSet = CyFalse;                                                  //Declaration

pastedImage_6.png

5.) Now check for this flag, prodSet in for (; ; ) loop and when it is set, call the CyU3PSibReadWriteRequest () to write it to SD card.

6.) Once all the data is written to the SD card. the CY_U3P_SIB_EVENT_XFER_CPLT event will be set in the CyFxMscApplnSibCB() function.

7.) In the callback, when (evt == CY_U3P_SIB_EVENT_XFER_CPLT), you will have to again call CyU3PDmaChannelSetXfer () just like below:

      apiRetStatus = CyU3PDmaChannelSetXfer (&glChHandleMscIn, 153600);               //150KB

You don't need to use the CY_U3P_DMA_CB_XFER_CPLT event since this event is triggered only when the data is read from the buffers.

Please do as mentioned and update me with the results.


Regards,
Yashwant

0 Likes
GiSa_4520796
New Contributor II

Hello,

I have done the above steps(1,2&3) before itself after our conversation and now added remaining things you mentioned in previous response including that I have set   #define CY_FX_SLFIFO_DMA_TX_SIZE  (153600). After all these modifications in my firmware,the device is not enumerating(when I am changing the buffer size and count).  

Also one thing I wanna ask you is can we give  buffer size as 512*150 and count as 2 (512*150*2 = 153600) , If I give size and count as I mentioned the device is enumerting properly.

After all these changes,I downloaded .img file into FX3 and the device enumerated as Streamer Example Device.After transfering data from FPGA,in control center I am getting 997 error.

Regards,

Srujana.

0 Likes
YashwantK_46
Moderator
Moderator

Hi Srujana,

You will have to perform the operations step by step to debug what is going wrong.


Are you able to see prod events after sending the data from FPGA?

Please check for prints and if you don't see any prints, please put a CyU3PDeviceReset(CyFalse); and see if the control is reaching to the prod events callback or not.


Regards,
Yashwant

0 Likes
GiSa_4520796
New Contributor II

Hello,

Are you able to see prod events after sending the data from FPGA?

     Yes,I am able to get PROD Events after sending data from FPGA.

please put a CyU3PDeviceReset(CyFalse); and see if the control is reaching to the prod events callback or not.

     Yes,even I checked the same.

After this ,in Control center I am getting 997 Error.

Regards,

Srujana.

0 Likes
GiSa_4520796
New Contributor II

Hello,

Can you please test the firmware at your end?

Thanks in Advance.

Regards,

Srujana.

0 Likes
YashwantK_46
Moderator
Moderator

Hello Srujana,

First of, we can't test the firmware on our end since we don't have the appropriate hardware with us, your custom board.

Its a good thing that you are getting PROD_EVENT's.

I believe that you have added the code that i have told in the response: 14 on 3rd March, 2020. That response only until data is written to the SD card, and the reading part from SD card is still not implemented

Once that's done, you should verify that the prodSet flag is set, so in the for (;;) condition where you check for the prodSet flag, put a device reset and see if its working.

If that is working, please put a device reset in the CY_U3P_SIB_EVENT_XFER_CPLT event in the CyFxMscApplnSibCB () function to see if the SD card write is completed.

If that's working as well, set another variable, only for debug prints, and print that in the for (;;) loop so that you know when XFER_CPLT is finished.

Once its set, you will have to pass the vendor command to read the data from the SD to USB, but with a small modification by changing the numBlks parameter from 8 to 150KB.

Please try the following and update me with the results.

Regards,

Yashwant

0 Likes
GiSa_4520796
New Contributor II

Hello,

I have added the steps you mentioned in previous response and also I replied that if I am giving buffer size as 20,the device is not enumerting. If I give buffer size as 512*150 and count as 2 (512*150*2 = 153600) , the device is enumerting properly.

After all this,i am getting PROD Events.

Once its set, you will have to pass the vendor command to read the data from the SD to USB, but with a small modification by changing the numBlks parameter from 8 to 150KB.

I dont want to pass vendor requests for reading and writing data into SD Card instead the code has to take control of it      accordingly when the buffer is full.

    

Note:Also we are having the same board (FX3S DVK) we only integrated Zynq FPGA in it.

Regards,

Srujana.

0 Likes
YashwantK_46
Moderator
Moderator

Hello Srujana,

I dont want to pass vendor requests for reading and writing data into SD Card instead the code has to take control of it      accordingly when the buffer is full.

--> I have suggested you to pass the vendor command only to check if the data is correctly written to the SD card first and if you are able to see the same data on the USB side or not. Once that is working properly, we can make that operation automated as well.

I only told it as for testing purposes.

Have you verified all these manually from my previous response?

Once that's done, you should verify that the prodSet flag is set, so in the for (;;) condition where you check for the prodSet flag, put a device reset and see if its working.

If that is working, please put a device reset in the CY_U3P_SIB_EVENT_XFER_CPLT event in the CyFxMscApplnSibCB () function to see if the SD card write is completed.

If that's working as well, set another variable, only for debug prints, and print that in the for (;;) loop so that you know when XFER_CPLT is finished.

Once its set, you will have to pass the vendor command to read the data from the SD to USB, but with a small modification by changing the numBlks parameter from 8 to 150KB.

Please verify these and share your findings so that we can continue with the automated reading of data from SD card to USB port of FX3S.

Regards,

Yashwant

0 Likes
GiSa_4520796
New Contributor II

Hello,

I only told it as for testing purposes.

     Okay.

I will share my observations and update you.

Regards,

Srujana.

0 Likes
GiSa_4520796
New Contributor II

Hello,

Please refer to the attached firmware with modifications you mentioned except ( 5.Now check for this flag, prodSet in for (; ; ) loop and when it is set, call the CyU3PSibReadWriteRequest () to write it to SD card).

Note: As I mentioned in my previous response,since the device is not enumerating for 512*15 and count as 20 I changed it to 512*150 and count as 2.Accordingly  I mentioned (prod==2) in DMA Cb.

Regards,

Srujana.

0 Likes
YashwantK_46
Moderator
Moderator

Hello Srujana,

1.) You have to set the second parameter of this to 150KB

                    apiRetStatus = CyU3PDmaChannelSetXfer (&glChHandlegpifOut, 0);

2.) The implementation in the CyFxMscApplnDmaCb() seem correct but that is not the end of what i have suggested you.

3.) After setting the prodSet flag, you have to check for it in the for (;;) loop and then call CyU3PSibReadWriteRequest () to write it to SD card

And follow the steps that i have suggested, all of them!!!

Also, please do the tests that i mentioned in my response no: 21 dated 10-Mar-2020 and share the results of each test so that we can understand if the firmware is working without issues.

Regards,

Yashwant

0 Likes
YashwantK_46
Moderator
Moderator

Hi Srujana,

1.) " I changed it to 512*150 and count as 2"

--> This is not correct even if the device is enumerating because the type of dmaConfig. size is uint16_t and the max it can accommodate is 65535 but 512*150 = 76800.

So, the extra data will be truncated to only 2^16-bits of data and rest will be lost.

So, please change the msc.h file values as:

#define CY_FX_MSC_DMA_BUF_COUNT         (20)             /* MSC channel buffer count */

#define CY_FX_MSC_EP_BURST_SIZE         (15)             /* Burst setting for the endpoint. */

I have verified this on my end and the device is enumerating properly with the above setting and there are truncation warnings in the USB Suite as well.

​2.) Also, please add the cyu3sport library in the linker path as shown below, if you haven't added it already.

pastedImage_1.png

Regards,
Yashwant

View solution in original post

0 Likes
GiSa_4520796
New Contributor II

Hello,

1.) " I changed it to 512*150 and count as 2"

--> This is not correct even if the device is enumerating because the type of dmaConfig. size is uint16_t and the max it can accommodate is 65535 but 512*150 = 76800.

So, the extra data will be truncated to only 2^16-bits of data and rest will be lost.

     Thank you for making me clear here.

I have done the steps you mentioned except checking for a flag(Step 5).Help me here.

Regards,

Srujana.

0 Likes