cancel
Showing results for 
Search instead for 
Did you mean: 

Why stm32 usb msc not work with freertos?

I use STM32746G-Discovery to learn usb msc.

I copied STM32Cube_FW_F7_V1.15.0\Projects\STM32746G-Discovery\Applications\USB_Device\MSC_Standalone and it works fine.

but when i use Freertos to drive msc, the PC popup a dialog that the device can't be recognized.

the attachment is the files my project use.

I almost changed nothing,just use a thread to call line below:

I think the interrupter priority may be the cause.

    USBD_Init(&usbd_device,&MSC_Desc,0);
    USBD_RegisterClass(&usbd_device,USBD_MSC_CLASS);
    USBD_MSC_RegisterStorage(&usbd_device,&USBD_DISK_fops);
    USBD_Start(&usbd_device);

8 REPLIES 8

Definitely situations where you can't yield to other threads. Would check interrupt, SDMMC transfers and malloc/free

Instrument code so you can understand the realtime interactions

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I check the STM32Cube_FW_F4_V1.24.2\Projects\STM324x9I_EVAL\Demonstrations\STemWin\MB1046 demo, but not find anything useful.

i think i must missing something, but i really don't know.

berendi
Principal

The STM32 USB driver has lots of hardcoded delays that might confuse RTOS.

To be fair, it's the other way around - ST's USB driver ir the one, which is "confused" (i.e. incorrect) with RTOS.

yes,but actually,official board like F412 discovery or 4x9i_eval use the lib。so it should be able to transplant to any st mcus。

i think the matter should be there is no any docs to guide how to transplant the lib。

Hi. I think you have problem with interrupt priorities. All USB actions perform in interrupt handler HAL_PCD_IRQHandler. First, ST USB driver call HAL_Delay, so interrupt priority of delay timer must be higher then USBs. Second, if you use BSP_SD_ReadBlocks_DMA/BSP_SD_WriteBlocks_DMA, DMA and SDMMC interrupt priorities must be higher. Try to use functions with simple polling (like BSP_SD_ReadBlocks).

yes, you are right,i have set SD dma priority to 0xf and using simple polliing,meanwhile i changed delay priority to 0x0.

but delay priority was 0xf in conf file,is it ok to set to 0x0? and how can i use dma in sd?