1 2 Previous Next 15 Replies Latest reply on Dec 6, 2018 9:38 PM by amal.john_3854616

    How to send data greater than 3 MB through control center?

    amal.john_3854616

      Hi,

      I'm trying to write NOR flash via SPI interface through the control center utility. The example code used is UsbSpiGpioMode found along with the FX3-SDK.

      I'm able to send data of size 27608 bytes without any error. If the size is further increased, the program gets stuck at the function CyU3PUsbGetEP0Data.

      NOR Flash used : Micron Serial NOR Flash Memory, MT25QU01GBBB

       

      Is there anything i need to do before writing to the NOR flash?

      Or is there any other method to write 81MB to the NOR flash with/without USB Control Center Utility??

        • 1. Re: How to send data greater than 3 MB through control center?
          hman

          Hi,

           

          Do you need to transfer all the 81MB data in one transfer/ it is okay to split it into multiple transfers?

          And is it okay to use BULK endpoint?

           

          Regards,

          Hemanth

          • 2. Re: How to send data greater than 3 MB through control center?
            amal.john_3854616

            Hi,

            I'll be storing the bit file which is required for configuring FPGA. 81MB data need to be stored in NOR flash. It can be split into multiple transfers.

            Can read/write via SPI be done using BULK endpoints? If its okay then no problem.

            • 3. Re: How to send data greater than 3 MB through control center?
              srdr

              Please use control center application to program the SPI Flash.

              Click on Program -> FX3 -> SPI FLASH.

               

              This will load the BootProgrammer.img file and enumerates the device as boot programmer device. Then it will ask for the path of the file.

              Please check this and update.

               

              If there is a stuck, update the return values of APIs in the firmware.

              • 4. Re: How to send data greater than 3 MB through control center?
                amal.john_3854616

                My application is to configure FPGA through fx3. For which NOR flash is pre-loaded with the configuration file which is of large size.So this file needs to be written to the NOR flash with SPI write, which gets failed when the 'bytes to be transfered' is greater than 27KB in USB Control Center. This where I need help.

                • 5. Re: How to send data greater than 3 MB through control center?
                  amal.john_3854616

                  Hi hemanth,

                  For transferring data through spi, i tried through bulk endpoint which is working fine. But i'm not able to transfer when the data size is greater than the buffer size.

                  Can you help me with the example code for multiple transfers? 

                  • 6. Re: How to send data greater than 3 MB through control center?
                    srdr

                    Have you used multiple buffers for a DMA Channel? i.e. buffer.count > 1. If no, please try with maximum possible buffer count.

                    • 7. Re: How to send data greater than 3 MB through control center?
                      amal.john_3854616

                      Thank you for the reply. It seems to be working.

                      I have another doubt on how to get access to the data that are sent through the endpoints and to buffer in bulk loop example.I need to get the data and perform some algorithm on those and commit it to the buffer. how to get the data?

                       

                      Sorry if these are silly questions but I'm new to cypress controller. Hope to get an answer.

                      • 8. Re: How to send data greater than 3 MB through control center?
                        srdr

                        Please create Manual DMA channel.

                        You can access the buffers in the DMA Call back and perform the algorithm then commit it.
                        If the algorithm takes too much time than the time that takes the data from host is filled all the available buffers, reduces the throughput.

                        Note that the buffers will be available once consumer drained them.

                        • 9. Re: How to send data greater than 3 MB through control center?
                          amal.john_3854616

                          Hi,

                          I modified the bulklpauto example code as follows:

                          dmaCfg.size = 13824;  (for 13KB)

                          dmaCfg.count = 16;  (for 16 buffers)

                           

                          void CyFxBulkLpDmaCallback (

                                  CyU3PDmaChannel   *chHandle, /* Handle to the DMA channel. */

                                  CyU3PDmaCbType_t  type,      /* Callback type.             */

                                  CyU3PDmaCBInput_t *input)    /* Callback status.           */

                          {

                              CyU3PReturnStatus_t status = CY_U3P_SUCCESS;

                              uint8_t *ptr;

                              uint16_t count;

                           

                              if (type == CY_U3P_DMA_CB_PROD_EVENT)

                              {

                                  ptr = input->buffer_p.buffer;

                                  SpiBuf_buffer = ptr;

                                  count = input->buffer_p.count;

                                  spi_count++;

                           

                                  status = CyFxSpiTransfer (spi_addr, count, ptr, CyFalse);

                                  if (status != CY_U3P_SUCCESS)

                                  {

                                  CyU3PDebugPrint (4, "\r\n SPI write failed\n", status);

                                  }

                           

                                  status = CyU3PDmaChannelDiscardBuffer (chHandle);

                                  if (status != CY_U3P_SUCCESS)

                                  {

                                  CyU3PDebugPrint (4, "CyU3PDmaChannelDiscardBuffer failed, Error code = %d\n", status);

                                  }

                                  CyU3PThreadSleep (50);

                              }

                          }

                           

                          This works properly for small size data. For large size, once 16 buffers are filled, function stops working. This is maybe buffer not getting freed. I tried to Discard the buffer, tried clearing the buffer after Spi transfer, still no hope.

                           

                          How can the buffers be drained manually without the help of consumer port? Or is there anything wrong in what i do?

                          • 10. Re: How to send data greater than 3 MB through control center?
                            amal.john_3854616

                            From the above set of code, (13824 * 16 = 221184) about 200KB data transfer is possible, how can data greater than 200KB be written to NOR flash?

                            • 11. Re: How to send data greater than 3 MB through control center?
                              srdr

                              Looks like SPI is taking much time to transfer larger buffers. You can measure the duration of transfer by asserting a GPIO before SPI transfer and De-assert the GPIO after the SPI transfer.

                               

                              Can you please remove thread sleep in the call back?

                              In the DMA Callback, you are not supposed to use any blocking API - like debugprints

                               

                              If you are looking for any notifications, set a flag and look for it in infinite for loop in main thread.

                              • 12. Re: How to send data greater than 3 MB through control center?
                                srdr

                                Hello,

                                 

                                Have you used Cypress USB Control Center to write to the SPI Flash?

                                If not, please give a try.

                                 

                                If yes, what are the consequences.

                                 

                                Note that control center load Bootprogrammer.img file to the USB bootloader. Hence, the device enumerate as Cypress USB Boot Programmer device then it will ask you for the image file that you want to write to SPI.

                                 

                                Steps:

                                1. Connect the device to PC

                                2. It enumerates as USB boot loader device

                                3. Open control center and click program -> SPI Flash

                                4. Control center loads the Bootprorgammer.img

                                5. Device enuemerates as USB Boot Programmer Device

                                6. Asks for the application firmware that you want to write to SPI Flash

                                • 13. Re: How to send data greater than 3 MB through control center?
                                  amal.john_3854616

                                  Yes, I've used the Cypress USB Control Center to perform the SPI read/write to the NOR flash,

                                  example code used : C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\serialif_examples\cyfxusbspigpiomode

                                  even in this 64K data can be sent above which whole thread gets stuck.

                                   

                                  SPI transfer is taking about 500ms in between the bulk transfer, when checked with all the blocking apis removed in callback functions.

                                  What is the use of CyU3PDmaChannelDiscardBuffer function? Will it empty the buffer and make it available for producer to fill up?

                                  When the dmaCfg.count fills up, if CyU3PDmaChannelDiscardBuffer is performed on the buffers, will the buffers be available for further data storing?

                                  • 14. Re: How to send data greater than 3 MB through control center?
                                    srdr

                                    While using control center, why are you loading Spigpiomode example firmware. You are not supposed to use any FW. Control center itself will load the bootprogrammer.img file after you selected Program->SPI Flash from menu.

                                     

                                    Can you please mention the steps that you followed using control center?

                                    1 2 Previous Next