0

Is there any way to speed up stm32 USB host applications. For example I am running at 207 MHz in stm32f730v8 my USB clock is 48 MHz and I want to open a director.

It takes about 30 milliseconds on average. For a very complicated and hierarchal folders .

Does Enabling this line has any effect on the USB read or write speed.

hhcd_USB_OTG_FS.Init.dma_enable = ENABLE;
Nima Aghayan
  • 109
  • 1
  • 7
  • There is more to DMA than enabling a controller. How are you doing it now? – Martin James Dec 31 '22 at 13:01
  • 30 milliseconds - not bad. Remember that FS hardware has 1ms frame rate – 0___________ Dec 31 '22 at 13:20
  • What fs hardware frame rate how can i find it in fatfs elm chan library @0___________ – Nima Aghayan Dec 31 '22 at 14:07
  • @MartinJames I dont know how to enable dma for stm32 usb host – Nima Aghayan Dec 31 '22 at 14:10
  • DMA only speeds up memory copy between CPU and USB peripheral. Unless you are already achieving more than 20 MB/s over USB high speed, the effect will hardly be measurable. Do you have an analysis of where the time is actually spent? You might need to have the next USB request ready when the previous one completes. Not all USB / MSC / file system libraries support this. – Codo Dec 31 '22 at 16:27
  • 1
    What makes you think that is a USB performance issue? It is not likely to be down to USB data-throughput or latency, and more likely down to the filesystem. I guess you are using FatFs? You really beet to profile it to determine where the delay is coming from. Does the filesystem support disk caching? – Clifford Jan 01 '23 at 09:12
  • 1
    Also without knowing what USB stack you are using, it is difficult to advise on DMA in any case. If you are using the CubeMX tool and DMA is supported, it will no doubt be an option in the stack/driver configuration. It seems likely that the line you mentioned does enable DMA for USB. But you ask whether it has any effect on performance - have you tried it? It seems easier for you to answer that than us. If it had no effect I refer you to my earlier comment. – Clifford Jan 01 '23 at 09:27
  • 1
    Some caution however. If the driver uses a DMA buffer in cachable memory, it will have to invalidate/flush the cache on every buffer read/write and will slow down your entire application rather non-deterministically. It does need to use the MPU no make the buffer non-cachable, and ideally use an SRAM on a separate bus. SRAM2 is good for that as it is relatively small. I have no idea if the STM32Cube code takes any of that into account (I avoid using it). – Clifford Jan 01 '23 at 09:32
  • I am using fatfs and I don't see any noticeable difference in enabling this option. I couldn't find any information for enabling DMA for USB MSC host in stm32. My fatfs readdir is very slow I was trying to optimize its speed @Clifford – Nima Aghayan Jan 01 '23 at 10:14
  • The DMA occurs at the physical layer, nothing to do with MSC. – Clifford Jan 01 '23 at 11:41
  • I asked this in one of your previous questions, but you did not address it: How many files do you have in each directory? https://stackoverflow.com/questions/52821728/fatfs-significant-slow-down-in-directories-with-many-files may apply. You seem to be asking a series of X-Y questions, in this case deciding that DMA is the solution to some problem, and asking about DMA rather than the actual problem. – Clifford Jan 01 '23 at 11:50
  • I am asking how to speed up USB MSC host. Is there any way for dealing with this problem and if we could do anything about it using DMA. Look at a car stereo player It has a USB port and we could attach a USB with unknown number of audio files or folders. The number of files is not limited by user can have 1000 songs in each folder. User can have 1000 folders which may or maynot have audio files in them. My problem occurs in scanning a USB drive with this scenario. – Nima Aghayan Jan 01 '23 at 12:58

0 Answers0