AN75779 with CYUSB3012 - DMA Channel Error

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

cross mob
gbust
Level 1
Level 1
5 sign-ins First reply posted First question asked

We have populated a CYUSB3KIT-003 with a CYUSB3012 instead of the CYUSB3014.

When running the AN75779 code, we get the following error :

"DMA Channel Creation Failed, Error Code = 16"

Because of the smaller SRAM on the 3012 (256K vs 512K), I have already reduced the size of the .img and added the build flag (CYMEM_256K) for the 256K memory.  The .img is sitting at 126KB, which should fit in the 128KB allocated space for the code area (if I'm understanding correctly).

The default UVC total stream buffer size sits at 64KB. I've already tried adjusting some of the defined variables to reduce this, but still get the same error.

Is there a way to adjust the firmware such that the DMA channel can be created? And, what else needs to change for the application to run properly on a 3012?

Memory map comment taken from cyfxtx.c

A reduced memory map is used with the CYUSB3011/CYUSB3012 devices:

Descriptor area Base: 0x40000000 Size: 12 KB
Code area Base: 0x40003000 Size: 128 KB
Data area Base: 0x40023000 Size: 24 KB
Driver heap Base: 0x40029000 Size: 28 KB
Buffer area Base: 0x40030000 Size: 32 KB
2-stage boot area Base: 0x40038000 Size: 32 KB

0 Likes
1 Solution
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi gbust,

To find the limit value of LD_DATA_COUNT AND LD_ADDR_COUNT,  please find the formula on page 18 of this app note : https://www.cypress.com/file/123506/download.

Line width is the number of(bytes/pixel) * width of the frame. Instead, make sure the total frame size is not divisible by the DMA buffer size and the line width should be divisible by the data bus width.

As the DMA Channel is multichannel, the buffer size is CY_FX_EP_BULK_VIDEO_PKT_SIZE*CY_FX_EP_BULK_VIDEO_PKTS_COUNT*CY_FX_UVC_STREAM_BUF_COUNT*No. of producer Sockets(which in this case is 2), which equals to 64KB. But complete 64KB cant be used.
No. of producer sockets and buf_count cant changed.
Change other two parameters(packet size and packet count) to get their product below 14KB.

Best Regards,
AliAsgar

View solution in original post

0 Likes
6 Replies
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hello,

"The default UVC total stream buffer size sits at 64KB." But in cyfxtx.c, buffer heap size allocated is just 32KB.

If 2-stage Bootloader is not used, Buffer Heap size can be made 64KB by merging 32KB memory from 2-stage boot area. This can be done by changing CY_U3P_SYS_MEM_TOP to 0x40080000 in cyfxtx.c file for the flag CYMEM_256K.

Even though the Buffer Heap Size is 64KB, the complete 64KB memory size can not be used to allocate DMA buffers. Try allocating lesser buffer memory size than 64KB.

Also make sure in the Build Settings of the firmware project, add fx3_256k.ld instead of the default fx3.ld LD file.

Best Regards,
AliAsgar

0 Likes
gbust
Level 1
Level 1
5 sign-ins First reply posted First question asked

Hey Ali,

Thanks for the reply.

I have adjusted the CY_U3P_SYS_MEM_TOP to 0x40040000 to remove the 2-stage Bootloader area. I also added the fx3_256k.ld in the Build Settings.

I have also changed CY_FX_UVC_STREAM_BUF_COUNT from (4) to (2). If I'm understanding correctly, this should be a change from 64KB to 32KB, which should fit inside the now 64KB Buffer Area.

However, I still receive the same "DMA Channel Creation Failed, Error Code =  16" message.

I have tried adjusting CY_FX_EP_BULK_VIDEO_PKTS_COUNT from (0x10)  to (0x08) alongside changes to the CY_FX_UVC_STREAM_BUF_COUNT to greatly reduce the size. These don't give me a DMA error, but when I connect with VLC or my application for viewing the camera, I don't believe I am getting frames (VLC just shows the cone).

Is there something else I am missing? If I freed up 32KB of space by removing the bootloader space, shouldn't I be able to assign that 32KB to the DMA channel?

Thanks for your time.

-gbust

0 Likes
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hello gbust,

Make sure to change the limit value in LD_DATA_COUNT and LD_ADDR_COUNT in the gpif state machine, and make sure that the line width is not divisible by the DMA buffer size.

Please make the following changes to include 2 stage bootloader memory in the DMA buffer space:

1. Change CY_U3P_SYS_MEM_TOP to 0x40080000.(This will assign the freed 32KB of 2 stage boot area to DMA buffer)
2.  Make sure fx3_256k.ld is used in the build settings.|
3. Allocate DMA buffer size and count such that the total DMA buffer memory is around 50KB.

Best Regards,
AliAsgar

0 Likes
gbust
Level 1
Level 1
5 sign-ins First reply posted First question asked

Hey Ali,

What should the limit value in LD_DATA_COUNT and LD_ADDR_COUNT be set to exactly? From looking at the .xml, it seems as though the value should be CY_FX_UVC_BUF_FULL_SIZE - 1, which is what it is currently at. 

My apologies, but I'm not sure what line width you are referring to.

CY_U3P_SYS_MEM_TOP has been changed and fx3_256k.ld is being used in the build.

For reference, I'm currently receiving the error with a CY_FX_EP_BULK_VIDEO_PKT_SIZE  of 0x400 and CY_FX_EP_BULK_VIDEO_PKTS_COUNT of 0x10 (which are unchanged), and a CY_FX_UVC_STREAM_BUF_COUNT of 2. That should only be 32KB. It also fails when I change CY_FX_UVC_STREAM_BUF_COUNT to 3 (48KB).

-gbust

0 Likes
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi gbust,

To find the limit value of LD_DATA_COUNT AND LD_ADDR_COUNT,  please find the formula on page 18 of this app note : https://www.cypress.com/file/123506/download.

Line width is the number of(bytes/pixel) * width of the frame. Instead, make sure the total frame size is not divisible by the DMA buffer size and the line width should be divisible by the data bus width.

As the DMA Channel is multichannel, the buffer size is CY_FX_EP_BULK_VIDEO_PKT_SIZE*CY_FX_EP_BULK_VIDEO_PKTS_COUNT*CY_FX_UVC_STREAM_BUF_COUNT*No. of producer Sockets(which in this case is 2), which equals to 64KB. But complete 64KB cant be used.
No. of producer sockets and buf_count cant changed.
Change other two parameters(packet size and packet count) to get their product below 14KB.

Best Regards,
AliAsgar

0 Likes
gbust
Level 1
Level 1
5 sign-ins First reply posted First question asked

Thanks Ali! Got it working now.

-gbust

0 Likes