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

USB superspeed peripherals Forum Discussions

HuEl_264296
Level 5
Level 5
First like given 25 sign-ins First solution authored

According to this knowledge base article: FX3: Error in CyU3PDmaMultiChannelCommitBuffer: code 71 - KBA218830, it's possible to increase the size of the DMA buffer. How can I do this?

Presumably, this is the definition of the DMA buffer size:

#ifdef UVC_APPLICATION
#define CX3_UVC_DATA_BUF_SIZE (0x8FD0)
#else
#define CX3_UVC_DATA_BUF_SIZE (0x8000)
#endif

 

I have tried changing the size to various things, but values work, other than the original ones.

How can I calculate a larger value that will work?

I am using a monochrome camera with a resolution of 1280x480 x 10bits, and a frame rate of 100 FPS.

Many thanks

 

0 Likes
1 Solution
AliAsgar
Moderator
Moderator
Moderator
250 solutions authored 750 replies posted 50 likes received

Hi Hugo,

Apart from 

1. RX payload size for the uvc.
2. Whether second stage bootloader is used?
3. DMA buffers used in other channels in the firmware.
4. Host and image sensor speed.

There are no other factors affecting the BUF_SIZE.

Best Regards,
AliAsgar

View solution in original post

0 Likes
12 Replies
AliAsgar
Moderator
Moderator
Moderator
250 solutions authored 750 replies posted 50 likes received

Hi,

If CX3 variant used has a 512KB SRAM:

The maximum address space given to DMA buffers in CX3 is 224 KB. If the second stage bootloader is not used, this space can be increased to 256KB.

Then, the available DMA buffer space that can be used for your video channel is (224 or 256KB) - (3KB: which is used internally by SDK if you are using CyU3PDebugInit API)  - (DMA buffer space used by any other channels in your firmware). 

The DMA buffer space that a firmware requires can be calculated by:

CX3_APP_STREAM_BUF_SIZE  *  CX3_APP_STREAM_BUF_COUNT.

If the CX3 variant used has a 256KB SRAM:

The maximum address space provided to DMA buffers is 32KB with SSBL and 64KB without SSBL.

Best Regards,
AliAsgar

0 Likes

Hi AliAsgar,

Thank you for your reply. My problem really is that when I try to increase those values, I no longer get video back from the device. For example, if I use these values:

#ifdef UVC_APPLICATION
#define CX3_UVC_DATA_BUF_SIZE (0x8FD0 << 1)
#else
#define CX3_UVC_DATA_BUF_SIZE (0x8000 << 1)
#endif

it doesn't work. I get no video back from the device.

And if I use these values:

#ifdef UVC_APPLICATION
#define CX3_UVC_DATA_BUF_SIZE (0x10FD0)
#else
#define CX3_UVC_DATA_BUF_SIZE (0x10000)
#endif

it also doesn't work. So it looks like I can't trivially increase the buffer size. Looking at the comment in the code about the buffer size, I see this:

/*CX3_UVC_DATA_BUF_SIZE value of 0x8000 is compatible with 16-bit GPIF
* configuration;
* When using Streamer for getting the video data CX3_UVC_DATA_BUF_SIZE has to
* be a multiple of End point max packet size (1024), hence 0x8000 was chosen
* for CX3_UVC_DATA_BUF_SIZE when the application is non-UVC;
* CAUTION: 0x6000 can be used and is compatible with both 16-bit/24-bit GPIF,
* but cannot be used for 720p;
* 720p frame size is exact multiple of 0x6000, hence the frame end cannot be
* detected with this value for 720p, since partial buffer does not exist in
* this case;
*
* When using UVC, 0x8FD0 for CX3_UVC_DATA_BUF_SIZE will work for
* 16-bit/24-bit GPIF configuration and for all resolutions * with 3 as
* CX3_UVC_STREAM_BUF_COUNT;
*/

 

This comment seems to agree that not every buffer size is compatible with every camera resolution.

So my question is: How can I calculate a larger size that will work?

 

 

0 Likes
AliAsgar
Moderator
Moderator
Moderator
250 solutions authored 750 replies posted 50 likes received

Hi,

The maximum DMA buffer size available with us is 215KB.

Dividing the buffer size by 2, as we have two producer sockets, so DMA buffer size for a single socket is 107KB.

So the DMA buffer size * DMA buffer count should be equal to 107KB.

Please configure the DMA buffer size and buffer count accordingly.

Also make sure the frame size is not an exact multiple of DMA buffer size.

Best Regards,
AliAsgar

0 Likes

Hi,

thanks for the reply. However, I don't think this is correct. When you say 107KB, I assume you mean 107x1024 bytes. I tried this:

#ifdef UVC_APPLICATION
#define CX3_UVC_DATA_BUF_SIZE (0x1BBD0)
#else
#define CX3_UVC_DATA_BUF_SIZE (0x1AC00)
#endif

and this:

#ifdef UVC_APPLICATION
#define CX3_UVC_DATA_BUF_SIZE (0x1AC00)
#else
#define CX3_UVC_DATA_BUF_SIZE (0x1AC00)
#endif

but neither of them work.

I'm sure that I need to calculate specific values, rather than just an arbitrary 107kB. The reason I think this is because 0x8000 works, but 0xA000 doesn't., and nor does any other value that I have tried.

What is going on here? Is there some other value I need to change to match this value?

 

 

 

 

 

0 Likes

After some experimenting, I have found that these work:

#define CX3_UVC_DATA_BUF_SIZE (0x8FD0 + 0x0010)

and

#define CX3_UVC_DATA_BUF_SIZE (0x8FD0 + 0x0020)

But these do not work:

#define CX3_UVC_DATA_BUF_SIZE (0x8FD0 + 0x0030)

and

#define CX3_UVC_DATA_BUF_SIZE (0x8FD0 + 0x0040)

 

Clearly, it's very sensitive to the exact buffer size, even if the size is a multiple of 16.

 

0 Likes
AliAsgar
Moderator
Moderator
Moderator
250 solutions authored 750 replies posted 50 likes received

Hi,

The maximum DMA buffer size and the DMA buffer count depend on the speed of the host to read data from FX3/CX3, and the speed of the sensor to write data to FX3/CX3.

Maximum available DMA buffer space is about 107KB.
One complete frame data must not be divisible by the DMA buffer size.

You cannot keep the DMA buffer size very high and DMA buffer count very low or vice versa. There has to be a proper match between the two.

Best Regards,
AliAsgar.

0 Likes

Hi,

Thanks for the reply. But I still don't understand how I can work out what sizes will actually work.

For example. Why does (0x8FD0 + 0x0020) work, but (0x8FD0 + 0x0040) does not work?

I am not changing the buffer size by much.

If you wanted to make the buffer size larger, can you tell me exactly how you would go about working out the correct value?

Many thanks

 

0 Likes
AliAsgar
Moderator
Moderator
Moderator
250 solutions authored 750 replies posted 50 likes received

Hi,

The maximum rx payload for UVC in the descriptor files is configured as 0x00, 0x90, 0x00, 0x00, which is 36KB. You could increase the RX payload size in the descriptors. After this 0x8FF0 + 0x40 should work. Please do try and let me know.

Buffer size + 12 +4 * buffer count should always be lesser than the maximum rx payload.

Best Regards,
AliAsgar

0 Likes

Hi,

Thanks, that was a good tip.

I changed the RX payload from 0x9000 to 0xF000 (60KB). Doing this allowed me to increase the CX3_UVC_DATA_BUF_SIZE.

However, I was only able to increase it by 0x2C0 (to 0x9290). Any number above that fails, but 0x9290 and lower seem to work OK.

Of course, this means that the payload only needs to be 0x929C or above.

Is there some other constant in the code which is preventing the CX3_UVC_DATA_BUF_SIZE from going above 0x9290?

Many thanks

Hugo

 

0 Likes
AliAsgar
Moderator
Moderator
Moderator
250 solutions authored 750 replies posted 50 likes received

Hi Hugo,

Apart from 

1. RX payload size for the uvc.
2. Whether second stage bootloader is used?
3. DMA buffers used in other channels in the firmware.
4. Host and image sensor speed.

There are no other factors affecting the BUF_SIZE.

Best Regards,
AliAsgar

0 Likes

OK, that's very strange then, because I really can't increase the CX3_UVC_DATA_BUF_SIZE to more than 0x9290.

Any number greater than that (with a corresponding RX payload) causes it to fail.

For example,

CX3_UVC_DATA_BUF_SIZE RX payload result
0x8FD0 0x8FDC Works
0x9290 0x929C Works
0x9291 0x929D Fails
0x92A0 0x92AC Fails
0x9390 0x939C Fails

 

These are only very small changes, so I'm not sure why they are not working.

0 Likes
AliAsgar
Moderator
Moderator
Moderator
250 solutions authored 750 replies posted 50 likes received

Hi,

Could you confirm if the failed issue is not due to MEMORY_ERROR?

Best Regards,
AliAsgar

0 Likes