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

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

cross mob
lock attach
Attachments are accessible only for community members.
amjoc_3854616
Level 3
Level 3

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??

0 Likes
1 Solution

Please change the timeout parameter in the Control Center application source code and re-build.

View solution in original post

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

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

Hemanth
0 Likes

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.

0 Likes

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.

0 Likes

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.

0 Likes

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? 

0 Likes

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

0 Likes

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.

0 Likes

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.

0 Likes

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?

0 Likes

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?

0 Likes

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.

0 Likes
KandlaguntaR_36
Moderator
Moderator
Moderator
25 solutions authored 10 solutions authored 5 solutions authored

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

0 Likes

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?

0 Likes

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?

0 Likes

I'm not using SPI Flash for programming my fx3 controller. Im using SPI interface to sent data to NOR flash for storing few data which need to be used in application.

Steps followed :

1. After power up in fx3 board, Cypress FX3 USB Bootloader device is enumerated.

2. Select the device, Program->FX3->RAM, select the USBBulkLoopManualAdd.img image.

In this code, after getting the data in producer end, i'm trying to send 400KB data to NOR flash through SPI, which i'm not able to send.

Even after discarding the buffer, free buffer is not available. The code is as follows :

void

CyFxBulkLpDmaCallback (

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

        CyU3PDmaCbType_t  type,      /* Callback type.             */

        CyU3PDmaCBInput_t *input)    /* Callback status.           */

{

    if (type == CY_U3P_DMA_CB_PROD_EVENT)

    {

    //CyU3PEventSet (&glAppEvent, CYFX_APP_SPI_TASK, CYU3P_EVENT_OR);

    spi_count++;

    glIsCallBack = CyTrue;

   /* Increment the counter. */

    glDMARxCount++;

    }

}

In thread entry function,

if (glIsCallBack)

{

        stat = CyU3PDmaChannelGetBuffer (&glChHandleBulkLp, &SpiBuf_p, 0);

        if (stat != CY_U3P_SUCCESS)

        {

        CyU3PDebugPrint (4, "CyU3PDmaGetBuffer failed, Error code = %d\n", stat);

        }

        stat = CyFxSpiTransfer (spi_addr, SpiBuf_p.count, SpiBuf_p.buffer, CyFalse);

        if (stat != CY_U3P_SUCCESS)

        {

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

        }

        if(CyU3PDmaChannelDiscardBuffer (&glChHandleBulkLp) != CY_U3P_SUCCESS){ // Wait 2000 ms(?)

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

        }

        glIsCallBack = CyFalse;

}

After 200KB, CyU3PDmaChannelGetBuffer  fails. Where am going wrong?

0 Likes

The snippet looks correct.

Can you please share the complete firmware? I would like to see what is the DMA buffer size you have set.

Meanwhile, I will test with Ascilla Kit using SPI DMA example and let you know.

0 Likes

Hi,

I've attached the firmware with the main post, please do check.

0 Likes

The attached firmware is with SPI over GPIO right?. Please try with SPI DMA or Register mode.

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

Hi,

As I said earlier, I used the AutoBulkLoop Transfer and modified for SPI write in DMA mode. When 'Transfer File Out' is used to transfer data to NOR flash, the following error is observed

BULK OUT transfer

BULK OUT transfer failed with Error Code:997

SPI clock freq is configured to 33MHz.

When we try to  write 500Kb data, it is being written to the NOR till the error is shown. Is there anyway that we can avoid this time out error and write the complete data?

I've attached the firmware code.

0 Likes

Please change the timeout parameter in the Control Center application source code and re-build.

0 Likes