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

cross mob

DMA buffer count and size allocation in EZ-USB™ FX3/CX3

DMA buffer count and size allocation in EZ-USB™ FX3/CX3

Anonymous
Not applicable

How many Direct Memory Access (DMA) buffers can be allocated in EZ-USB™ FX3/CX3 for each DMA channel?

 

Creation of DMA channels for EZ-USB™ FX3/CX3 requires two resources:

  1. DMA buffers
  2. DMA descriptors

The allocation of the maximum number of DMA buffers is not fixed and depends on the size of the buffers being allocated; the number of DMA descriptors is fixed to a maximum of 510.

 

DMA buffer and descriptor usage in the EZ-USB™ FX3 SDK

 

APIs in the EZ-USB™ FX3 SDK that consume some part of the overall memory available for Direct Memory Access buffers:

  • The CyU3PDebugInit() function in the EZ-USB™ FX3 SDK creates one internal DMA channel that uses 2 KB of DMA buffer space and 9 DMA descriptors.
  • The CyU3PUsbStart() function in the EZ-USB™ FX3 SDK creates two internal DMA channels that use a total of 1 KB of DMA buffer space and 6 DMA descriptors.
  • When an AUTO DMA channel with ‘N’ buffers of ‘S’ bytes each is created, it requires N × S bytes of DMA buffer space and N+1 DMA descriptors. An AUTO DMA channel creation fails when N > 510-9-6-1 = 494 (where 9 and 6 are the number of DMA descriptors used by CyU3PDebugInit and CyU3PUsbStart respectively).
  • When a MANUAL DMA channel with ‘N’ buffers of ‘S’ bytes each is created, it requires N × S bytes of DMA buffer space and 2N+1 DMA descriptors. A MANUAL DMA channel creation fails when N > (510-9-6-1)/2 = 247. 

 

What is the maximum memory that can be allocated to DMA buffers in EZ-USB™ FX3?

 

EZ-USB™ FX3 with 512 KB SRAM

 

The total Direct Memory Access buffer space available in EZ-USB™ FX3 with 512 KB SRAM (CYUSB3013 and CYUSB3014) is 224 KB.

An additional 32 KB reserved for the second-stage bootloader can be used by setting the CY_U3P_SYS_MEM_TOP macro to 0x40080000 in the cyfxtx.c file. See the Modifying the Default Memory Map in FX3, CX3, FX3S, SD3, FX2G2, and SD2 for more details on modifying the DMA memory map.

EZ-USB™ FX3 with 256 KB SRAM

 

In EZ-USB™ FX3 with 256 KB SRAM (CYUSB3011 and CYUSB3012), the DMA buffer space available is 32 KB.

An additional 32 KB reserved for the second-stage bootloader can be used by setting the CY_U3P_SYS_MEM_TOP macro to 0x40040000 in the cyfxtx.c file.

The default DMA memory map used for EZ-USB™ FX3 applications is provided in the fx3_512k.ld (for 512-KB SRAM) and fx3_256k.ld (for 256-KB SRAM) files available in the following path: C:\Program Files (x86)\Infineon\EZ-USB FX3 SDK\1.3\fw_build\fx3_fw.

When the total size of DMA buffers allocated in the firmware exceeds the limit, CY_U3P_ERROR_MEMORY_ERROR (error code: 0x10) is generated.

Note: In the case of EZ-USB™ CX3, answers to both questions hold. However, as the streaming DMA channel is many-to-one DMA channel, the total number of DMA buffers for that channel = dmaConfig.count * no. of producer sockets.

 

What is the maximum size of a single DMA buffer that can be set in UVC-based firmware in the EZ-USB™ FX3 SDK?

 

The factors that affect the value of Direct Access Memory (DMA) buffer size for video streaming

 

  1. RX payload size for the UVC probe structure. Ensure that the DMA buffer size configured for the video streaming DMA channel is smaller than the maximum RX payload size in the probe structure.
  2. Memory allocated to DMA buffers. The DMA buffer size can be increased unless the total memory allocated to DMA buffers is not exhausted. Therefore, the second-stage bootloader usage and DMA memory usage of other channels should also be considered.
  3. Host and image sensor speed in DMA buffer. If the speed with which the host requests data is slow as mentioned in Scenario 2 of Handling Commit Buffer Failures Occurred during Video Transfers using FX3, then the DMA buffer size for video streaming has to be large. Therefore, the time required for filling the large DMA buffer can account for the speed with which the host requests these buffers.

Because a 12-bit field (DSCR_SIZE.BUFFER_SIZE) is used to indicate the size of the DMA buffers in multiples of 16 bytes, the maximum size of an individual DMA buffer can be as much as 0xFFF0 bytes = 65520 bytes.

Creating a DMA buffer size with a high value and keeping the DMA buffer count low may result in commit buffer failures if the partial packet is small.

It is recommended to have a good balance between the DMA buffer size and DMA buffer count for a UVC application.

For video streaming with 1080p at 30fps using the OV5640 image sensor and CX3, the maximum DMA buffer size (header/footer excluded) can be set as high as 0xDCD0 = 56,528 bytes with the DMA buffer count set as 2 per socket.

Considerations for choosing a DMA buffer size

 

  1. The Direct Memory Access buffer size must be a multiple of 16 bytes.
  2. The total frame size must not be perfectly divisible by the DMA buffer size. This is required because a partial buffer denotes the end of a frame in the firmware.


Note:  If EZ-USB™ FX3 is used for a UVC application with the AN75779 firmware and the DMA buffer size has to be changed, see Section 3.5 of the AN75779 application note for details on changes required in the GPIF II state machine with the buffer size change.

 

Version: *A

Translation - Japanese: DMAバッファ数 - KBA218339 - Community Translated (JA)

3117 Views