Skip to main content
Visitor II
July 13, 2019
Question

[STM32F407]How to make the link between the SD in SDIO and the USB OTG in MSC ?

  • July 13, 2019
  • 5 replies
  • 1853 views

Hi

I have a Clicker2 demo card (it is like a discovery card).

I have a SD in SDIO 4 bits mode with DMA : no problem, work fine. I can read and write to it with the FatFS library.

I want to access this card with the USB port. So I initialize the USB_OTG_FS connectivity in Device Only mode. In the Middleware, I select USB_Device in Mass Storage Class mode.

Until this point all is ok !

Problem, when I connect the USB port to my computer, it always said that the device is not formatted and want to format it (and the description of the disk for the formatting is not correct).

It seems that the USB_OTG don't make the link with the SD.

Why ?

An idea ?

I attach my CubeMX test project.

Note : I see many discussions over this subject and I also see the STM32469I-Discovery MSC_Standalone sample but code is old and the comparison with the new code is very hard.

Thanks,

Lionel

    This topic has been closed for replies.

    5 replies

    Graduate II
    July 13, 2019

    STM32Cube_FW_F4_V1.21.0\Projects\STM32469I-Discovery\Applications\USB_Device\MSC_Standalone\readme.txt

    How is this "Old"? It uses the HAL libraries and should be a viable thing to port from, obviously it will be harder than pressing a button in CubeMX, but if it actually works that's clearly a better starting point.

    I'm not aware that the Clicker 2 has a MicroSD card slot, so perhaps your code doesn't access the card properly.

    I would validate that you can read the card properly on the F4 directly using FATFS. If that doesn't work, integrating the USB MSC will simply compound the problem.

    Lionel1Author
    Visitor II
    July 13, 2019

    I said "old" because when you compare the code generated (for example usbd_conf.c) with the code of the sample, it's really different.

    There is no card slot on Clicker 2 but I made one and I as said, work fine.

    One thing that is really bad with the sample is that there is no CubeMX project, so you can not regenerate the sample with the newest version.

    Note : The MSC class of the STM32_USB_Device_Library is present on my project.

    Regards,

    Lionel

    Graduate II
    July 13, 2019

    The examples were not built with CubeMX, but built by developers familiar with the hardware. This is why no .IOC files exist.

    The output form of CubeMX isn't particularly helpful for HAL developers, as it tends to hide and obfuscate stuff.

    I think the CubeMX team needs to seriously work on output validation, both on their own ST boards, but across a number of other popular boards. The whole selling point of CubeMX is you should just need a board template and click to select the functional blocks, ie MicroSD, USB + MSC.

    Lionel1Author
    Visitor II
    July 14, 2019

    I am not agree with you. CubeMX is a really great tool (before I have tried MikroC who is very bad). You can design quickly your project and don't spent time to configure every modules. So you can focus on the heart of you project. It is not a problem if there is no project demo for each board. But it is a pity that there is no ioc project for the samples provided. You have to do reverse engineering to get the ioc project and it is not evident.

    Regards,

    Lionel

    Lionel1Author
    Visitor II
    July 13, 2019

    There is one thing that is strange : in the file usbd_storage_if.c, practically all the functions just return USBD_OK.

    For example :

    int8_t STORAGE_Init_FS(uint8_t lun)
    {
     /* USER CODE BEGIN 2 */
     return (USBD_OK);
     /* USER CODE END 2 */
    }
    int8_t STORAGE_IsReady_FS(uint8_t lun)
    {
     /* USER CODE BEGIN 4 */
     return (USBD_OK);
     /* USER CODE END 4 */
    }

    The problem is perhaps here.

    Lionel1Author
    Visitor II
    July 16, 2019

    Hi

    Finally I found the problem : just bad priority !

    Thanks to Chinese forum that is more helpful than here :grinning_face:

    Regards,

    Lionel

    Visitor II
    March 18, 2020

    Lionel,

    By any chance can you remember the address of​ this helpful Chinese site?

    R​regards

    g66229r​