cancel
Showing results for 
Search instead for 
Did you mean: 

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

Lionel1
Associate II

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

8 REPLIES 8

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.

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

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

Lionel1
Associate II

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.

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.

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

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

That's fine but you're here complaining the tool isn't generating usable code, and in a form you want.

As I said, the examples aren't built with CubeMX, so it is not like you can reverse engineer them back into existence.

I believe there should be .IOC examples, but they also shouldn't be necessary if the point-n-click methodology worked flawlessly.

I'd prefer ST focus on ensuring that all CubeMX output #WorksForSure

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

Hi

Finally I found the problem : just bad priority !

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

Regards,

Lionel

GnR
Associate II

Lionel,

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

​

R​regards

g66229r​