cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F429ZI, CubeMX generated USB host project gets caught in the HOST ENUMERATION state.

EHunc
Associate

I have linked the zipped test project that I used to verify the behavior that I will try to describe. I have a largely stripped down project with RTOS, USB Host Library with MSC, and a UART configured for printf() so I can utilize the USBLog debugging which has USBH_DEBUG_LEVEL at 3.

The test I was running is on a NUCLEO_F429ZI development board with a USB OTG cable as well as a UART connected for viewing the debug messages. I plug the USB drive in and the system enumerates the device. Typically, if I am being careful to be quick when disconnecting the USB drive, I can continuously disconnect and reconnect with successful enumeration each time.

If I am slow when disconnecting, the stack detects the disconnection, but then detects a faulty "USB Device Attached". At this point there is no drive installed. Any subsequent drive installations do not work. The MCU is still running, but it is stuck at the HOST_ENUMERATION state.

I found this in a different project an dug into the stack a fair bit, but thought that I should be able to get this going without any issues on a dev-kit with a largely CubeMX generated project. I saw the same issue in this project and would like to know if this is a known issue, or if there is a simple work around, or if I am overlooking something here.

Thanks for the help,

Eddie

2 REPLIES 2
Chensie
Associate II

Hi,

I have found it too.

I worked around as: ( in USBH_CtrReg.c) add static uint16_t timeout value;

in case CMD_WAIT, add timeout handle.

USBH_StatusTypeDef USBH_CtlReq   (USBH_HandleTypeDef *phost, 

               uint8_t       *buff,

               uint16_t      length)

{

 USBH_StatusTypeDef status;

 status = USBH_BUSY;

 static uint16_t timeout;

 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;

  timeout = 0;

   status = USBH_BUSY;

#if (USBH_USE_OS == 1)

  osMessagePut ( phost->os_event, USBH_CONTROL_EVENT, 0);

#endif    

  break;

   

 case CMD_WAIT:

  status = USBH_HandleControl(phost);

  if (status == USBH_OK) 

  {

   /* Commands successfully sent and Response Received */    

   phost->RequestState = CMD_SEND;

   phost->Control.state =CTRL_IDLE;  

   status = USBH_OK;    

  }

  else if (status == USBH_FAIL)

  {

   /* Failure Mode */

   phost->RequestState = CMD_SEND;

   status = USBH_FAIL;

  } 

  else if (++timeout > 100)

  {

   USBH_ReEnumerate(phost);

  }

  break;

   

 default:

  break; 

 }

 return status;

}

EHunc
Associate

I wanted to respond with a follow up that this issue ended up being resolved by updating the USB Host to v3.3.3. They have fixed this in there.