Raid1 example code issue

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

cross mob
MoLa_3842091
Level 3
Level 3
5 likes given First like given

I'm using the raid1 usb-dongle-on-chip and using Raid1 example code to run the device. I'm trying to display the data that is written to the SD card using the  CyU3PDebugPrint  but when doing this it prints the first 8 bytes and then it stucks!

This is the code:

   if (type == CY_U3P_DMA_CB_PROD_EVENT)

    {

    CyU3PDmaCBInput_t *input1=input;

            for (index = 9; index < input1->buffer_p.count; index++)

            {

            CyU3PDebugPrint (4, "Write buffer before change [%d] = %x\r\n", index, input1->buffer_p.buffer[index]);

            }

/* This is a produce event notification to the CPU. This notification is

* received upon reception of every buffer. The buffer will not be sent

* out unless it is explicitly committed. The call shall fail if there

* is a bus reset / usb disconnect or if there is any application error. */

status = CyU3PDmaMultiChannelCommitBuffer (chHandle, input->buffer_p.count, 0);

if (status != CY_U3P_SUCCESS)

{

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

}

GLCommitCount++;

    }

}

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

You are not supposed to use CyU3PDebugPrint  in DMACallback.

Please copy the input buffer to a global buffer and print in the main thread.

What is the amount of data that you are sending to SD card at a time and expecting to print in the dma callback?

Thanks,

>>What is the amount of data that you are sending to SD card at a time and expecting to print in the dma callback?

I'm sending a small text file containing numbers 1 to 8 from host to sd-card.

Even if i try to change data in the DMA callback function [CyFxMscApplnMultiDmaCb] as shown in the code below, the copy process from host to SD-card stuck forever, what is wrong in doing this step?

    if (type == CY_U3P_DMA_CB_PROD_EVENT)

    {

/* This is a produce event notification to the CPU. This notification is

* received upon reception of every buffer. The buffer will not be sent

* out unless it is explicitly committed. The call shall fail if there

* is a bus reset / usb disconnect or if there is any application error. */

    for (index = 0; index < input->buffer_p.count; index++)

    {

    input->buffer_p.buffer[index] = ~(uint8_t)input->buffer_p.buffer[index];

    }

status = CyU3PDmaMultiChannelCommitBuffer (chHandle, input->buffer_p.count, 0);

if (status != CY_U3P_SUCCESS)

{

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

}

GLCommitCount++;

    }

}

0 Likes

As said in FX3SMSC_RAID1_Rev2 , there are additional overheads
(related to the file system that you use in your case) that sends to the sd card before writing the actual data.

Hence, you will receive producer event for every buffer of data transfer from UIB to SD card. It will have overhead + data.

Please let us know why you want to modifty the data being sent to SD card.

0 Likes

Thanks,

Because I want to XOR the data passing IN/OUT  through the fx3s processor. It's a study project that I need to accomplish.

Any helpful feedback is appreciated

0 Likes

Hello,

FX3S Raid 1 application is not recommended for modifiying the data in the firmware.

If you want to do any such modifications, please identify what is the overhead and what is actual data in the firmware and do XOR.

You may capture USB trace with Wireshark to idently flow of data from USB host to device. This will help you to identify what is the overhead and what is the actula data being sent.

Regards,

Sridhar

0 Likes