Skip to main content
Graduate
January 15, 2024
Question

USB device as MSC starting from cubeMx

  • January 15, 2024
  • 2 replies
  • 1291 views

Hello,

 

I try to add MSC feature to my app. MCU is L452.

To avoid side effects, I started a brand new app with cubeIDE/Mx.

I activated USB_DEVICE feature.

I declared the USB_DEVICE as mass storage class.

I had a look to the MSC_standalone example from G0 cube library and did not see more calls to the usb lib from the main (except PD features that are not relevant for me) than the call to MX_USB_DEVICE_Init(); Nothing in the intrerrupt file too.

For this reason, I was expecting my device to appear in windows explorer as an external storage (of course with no data because nothing is implemented at this level) but it's not the case. I put some breakpoints in usbd_storage_if.c but none of the functions is called.

 

Are there some more calls I should do to make my PC discover my device as usb storage? or should I suspect a hardware failure?

 

Thanks

Julien

 

 

 

 

    This topic has been closed for replies.

    2 replies

    Super User
    January 15, 2024

    Hi,

    You should look at examples , like here :

    https://github.com/STMicroelectronics/STM32CubeF4/tree/master/Projects/STM32469I_EVAL/Applications/USB_Device/MSC_Standalone

    for L4xx ->

    https://github.com/STMicroelectronics/STM32CubeL4/tree/master/Projects/STM32L476G-EVAL/Applications/USB_Device/MSC_Standalone

    +

    When plug in USB , get some ding-dong (windows) or can see device connected (linux) ?

    If not - you do "nothing" on the usb bus ... something like this :

     

     

     */
    static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id)
    {
     switch (id)
     {
     case HOST_USER_SELECT_CONFIGURATION:
     break;
    
     case HOST_USER_DISCONNECTION:
     Appli_state = APPLICATION_DISCONNECT;
     if (f_mount(NULL, "", 0) != FR_OK)
     {
     LCD_ErrLog("ERROR : Cannot DeInitialize FatFs! \n");
     }
     if (FATFS_UnLinkDriver(USBDISKPath) != 0)
     {
     LCD_ErrLog("ERROR : Cannot UnLink FatFS Driver! \n");
     }
     break;
    
     case HOST_USER_CLASS_ACTIVE:
     Appli_state = APPLICATION_READY;
     break;
    
     case HOST_USER_CONNECTION:
     if (FATFS_LinkDriver(&USBH_Driver, USBDISKPath) == 0)
     {
     if (f_mount(&USBH_fatfs, "", 0) != FR_OK)
     {
     LCD_ErrLog("ERROR : Cannot Initialize FatFs! \n");
     }
     }
     break;
    
     default:
     break;
     }
    }

     

     

    You have it in your program - or not yet ?

     

    +++ read here, how to do:

    https://community.st.com/t5/stm32-mcus/how-to-use-stmicroelectronics-classic-usb-device-middleware-with/ta-p/599274

     

    Graduate II
    August 15, 2024

    Hi, @JulienD 

    Have you resolved this problem, I am here too...