Skip to main content
Visitor II
February 7, 2022
Question

Is DMA possible with USB FS

  • February 7, 2022
  • 4 replies
  • 1997 views

I'm working on a STM32H750XB with USB. It works fine with the USB2_OTG_FS instance, but the speed is not reaching the maximum (only 875kB/s). I'm using the USB with diskio, FatFS and FreeRTOS.

I'd like to enable DMA to make it faster, so I set

hhcd.Init.dma_enable = 1;

and I also disable DCache.

But when it's set like this, the device crashes when the USB is getting enumerated.

Is it really possible to enable DMA on USB FS ?

Thanks !

    This topic has been closed for replies.

    4 replies

    Graduate II
    February 7, 2022

    What do you think the maximum speed for a USB FS MSC should be?​

    The interface is going to be most efficient doing high block count aligned transfers. FatFS doesn't have any inherent block caching or lazy-write algorithm. f_read / f_write need to be used with an awareness of underlying media expectation. doing many small transaction will be particularly slow.​

    T​he USB FIFO should be able to use DMA

    T​he H750 should be able to uses it's D-Cache, expect to have to manage coherency, either directly or by using specific memory areas you've set to be non-cacheable.

    BDELI.2Author
    Visitor II
    February 7, 2022

    The max speed for USB FS is 1.5MB/s in the most ideal case, according to the specification, so I wanted to be the closest as possible to this value.

    I'm doing "big" transactions, an f_read of ~65kB.

    Super User
    February 7, 2022

    Clock speed != max data transfer speed.

    yes, DMA can be used, provided you manage cache appropriately.

    Sending more data per transfer is going to more efficient.

    Should be able to get around 1 MBps transfer rate if you are quick to reinitiate transfer after the last one succeeds.

    BDELI.2Author
    Visitor II
    February 7, 2022

    What needs to be changed to move from non-DMA to DMA USB ?

    I did the

    hhcd.Init.dma_enable = 1;

    and also changed usb_diskio to usb_diskio_dma.