cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX 5.6.1 USB HOST mass storage driver hangs on startup with usb memory plugged in.

FOlde.1
Associate

Since updating to CubeMX 5.6.1, my software won't start when there's a USB memory drive plugged into my system. It gets stuck , which is resolved by removing the USB device and plugging it back in.

I'm using STM32F756BGTx with FreeRTOS.

I think i pinpointed the problem.

Sincde CubeMX 5.6.1 the function USBH_CtlReq() contains a seccond occurence of a call to (void)osMessagePut(). I commented it out in the code fragment below.

I noticed the message sent there, results in call to USBH_CtlReq(), which results in sending the same message again, creating an endless loop.

Commenting out the second occurence off (void)osMessagePut() got my system working again.

USBH_StatusTypeDef USBH_CtlReq(USBH_HandleTypeDef *phost, uint8_t *buff,

                uint16_t length)

{

 USBH_StatusTypeDef status;

 status = USBH_BUSY;

 switch (phost->RequestState)

 {

  case CMD_SEND:

   /* Start a SETUP transfer */

   phost->Control.buff = buff;

   phost->Control.length = length;

   phost->Control.state = CTRL_SETUP;

   phost->RequestState = CMD_WAIT;

   status = USBH_BUSY;

#if (USBH_USE_OS == 1U)

   phost->os_msg = (uint32_t)USBH_CONTROL_EVENT;

#if (osCMSIS < 0x20000U)

   (void)osMessagePut(phost->os_event, phost->os_msg, 0U);

#else

   (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);

#endif

#endif

   break;

  case CMD_WAIT:

   status = USBH_HandleControl(phost);

   if ((status == USBH_OK) || (status == USBH_NOT_SUPPORTED))

   {

    /* Transaction completed, move control state to idle */

    phost->RequestState = CMD_SEND;

    phost->Control.state = CTRL_IDLE;

   }

   else if (status == USBH_FAIL)

   {

    /* Failure Mode */

    phost->RequestState = CMD_SEND;

   }

   else

   {

    asm("nop");

   /* .. */

   }

#if (USBH_USE_OS == 1U)

   //phost->os_msg = (uint32_t)USBH_CONTROL_EVENT;

#if (osCMSIS < 0x20000U)

   //(void)osMessagePut(phost->os_event, phost->os_msg, 0U);

#else

   (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);

#endif

#endif

   break;

  default:

   break;

 }

 return status;

}

0 REPLIES 0