Skip to main content
Zhou JianQiang
Senior
January 8, 2020
Question

Why stm32 usb msc not work with freertos?

  • January 8, 2020
  • 3 replies
  • 1663 views

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);

    This topic has been closed for replies.

    3 replies

    Tesla DeLorean
    Guru
    January 8, 2020

    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Zhou JianQiang
    Senior
    January 8, 2020

    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
    January 8, 2020

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

    Piranha
    Principal III
    January 8, 2020

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

    Zhou JianQiang
    Senior
    January 9, 2020

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

    oleksandr.karbivsky
    Senior II
    January 9, 2020

    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).

    Zhou JianQiang
    Senior
    January 10, 2020

    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?