cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H723 USB Mass storage

GnasUhn
Associate II

I am trying to implement a USB mass storage using USB3300, STM32H723, and e eMMC. 

Project Setup:

* Clock config

clock1.png

clock2.png

USB_HS Config

USB_OTG_HS.png

USB_OTG_GPIO.png

USB Device config

USB_DEVICE.png

eMMC config

eMMC.png

MMC_GPIO.png

In the code I made these addons in the "usbd_storage_if.c" file:

Code1.png

code.png

Currently, my custom board is working as a Mass storage USB at a speed of 14MBps. 

I found that when I removed the code line in function 

"STORAGE_Read_HS()", and "STORAGE_Write_HS()":

while (HAL_MMC_GetCardState(&hmmc1)!=HAL_MMC_CARD_TRANSFER){

 

};

The transfer speed can be reached at 40MBps, but the data saved to the USB went wrong.

How can I speed up my USB?

 

4 REPLIES 4
FBL
ST Employee

Hello @GnasUhn 

Would you please check your USB clock config. The controller requires a dedicated 48 MHz clock that is generated by a PLL connected to the HSE oscillator.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

GnasUhn
Associate II

Hi, FBL

I adjusted my USB clock to 48Mhz, but I noticed that the speed of the USB still did not improve (13MBps). 

In STORAGE_Read_HS() and STORAGE_Write_HS() function, when we using HAL_MMC_ReadBlock() and HAL_MMC_WriteBlock(). we have to wait for CardState != HAL_MMC_CARD_TRANSFER to continue the next step.code.png

Can I use DMA to read and write in these functions, and How can I change file IOC file to do that?

FBL
ST Employee

Hi @GnasUhn 

We recommend reserving a minimum of 0x100 for EP1 bulk transfer (double buffer).

The fifo setting for MSC HS:

 

HAL_PCDEx_SetRxFiFo(&hpcd, 0x200);
HAL_PCDEx_SetTxFiFo(&hpcd, 0, 0x40);
HAL_PCDEx_SetTxFiFo(&hpcd, 1, 0x100);

 

Theoretically, it is possible to reach 60MBps but in practice using DMA we can reach around 40MBps.  In your application, you may need to implement a non-blocking delay or yield if using an RTOS.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hi, we followed the config of the EP1 transfer that you recommended but the speed of the USB did not change.

In my application, we do not use RTOS, the USB device is initiated by MX_USB_DEVICE_Init().

Are there any reasons that need attention in the firmware that can cause issues with the speed of the USB MSC?

The source code of the project is shared in the link below.

Link source code