cancel
Showing results for 
Search instead for 
Did you mean: 

Setup USB-OTG-FS with Mass Storage Class on a STM32469 Discovery Board with CubeMX

m.beddi
Associate II

Hello all,

I have been trying to implement the MSC_Standalone example (device mode with SD card) with the STM32469 discovery board and CubeMX for some time now (OTG_FS_MODE).

The example works perfectly in standalone mode, but when I now try to set up the same project with CubeMX, it is a huge mess.

I could leave it like this but it is desired and required to create the project with a CubeMX file so that other peripherals and settings can be made as I go along.

I proceed as follows: I first activate the USB_OTG_FS. Set the global interupt here.
Then I activate the Mass Storage Class under USB_DEVICE.
Furthermore, I have loaded the BSP from the example into my project folder.

As an optimist, I now assume that this should work. As I understand it, I don't need FatFS and I don't need to activate an SD card, as this should be taken over by the MSC and it is not used in the STM example. I also assume that CubeMX does the clock configuration correctly for me.
But that does not seem to be the case.


It seems that the USB initialisation works and the SD card is not recognised correctly or commands can be executed on it. I suspect there is a timing problem. I thought CubeMX also takes care of the clock and everything else.

 

At the moment the programme hangs up at the following point (Timeout Error):

 

 

 

uint32_t SDMMC_GetCmdResp1(SDIO_TypeDef *SDIOx, uint8_t SD_CMD, uint32_t Timeout)
{
  uint32_t response_r1;
  uint32_t sta_reg;
  
  /* 8 is the number of required instructions cycles for the below loop statement.
  The Timeout is expressed in ms */
  uint32_t count = Timeout * (SystemCoreClock / 8U /1000U);
  
  do
  {
    if (count-- == 0U)
    {
      return SDMMC_ERROR_TIMEOUT;
    }
    sta_reg = SDIOx->STA;
  }while(((sta_reg & (SDIO_FLAG_CCRCFAIL | SDIO_FLAG_CMDREND | SDIO_FLAG_CTIMEOUT)) == 0U) ||
         ((sta_reg & SDIO_FLAG_CMDACT) != 0U ));

 

 

 


Is there anyone here who has experience with this story. I would be happy if someone could give me some hints on how best to approach the problem. Unfortunately, it is quite overwhelming to understand every detail, e.g. in the clock configuration.

2 REPLIES 2
Led
Senior

Hi m.beddi

Did you find a solution for your issue?

I'm also getting stuck with SDIO_FLAG_CTIMEOUT, using non-blocking sdio communication to access the sd-card with the frameworks FileX and UsbX from ThreadX.

Any hint would be appreciated.

Best Regards, Led

vbesson
Senior

same here, any solution on this ?