AnsweredAssumed Answered

USB host stall

Question asked by epifania.vito on Apr 29, 2015
Latest reply on May 16, 2017 by srinivas reddy
Hi,
I'm trying to interface an USB barcode with discovery board F407. I'm using CubeMX 4.7 and keyboard example as starting point from Cube USB HOST library.

With some keyboards and usb wireless presenters (logitech) everything works, but with other keyboards and with barcode readers the USB library recognizes the device but then enter in stall. In particular in the case CTRL_DATA_IN_WAIT of function USBH_HandleControl in file usbh_ctlreq.c:

  case CTRL_DATA_IN_WAIT:
    
    URB_Status = USBH_LL_GetURBState(phost , phost->Control.pipe_in);
    
    /* check is DATA packet transferred successfully */
    if  (URB_Status == USBH_URB_DONE)
    {
      phost->Control.state = CTRL_STATUS_OUT;
    }
    /* manage error cases*/
    if  (URB_Status == USBH_URB_STALL)
    {
      /* In stall case, return to previous machine state*/
      status = USBH_NOT_SUPPORTED;

     /* HERE THE CODE ENTER LOOP  */

    }   
    else if (URB_Status == USBH_URB_ERROR)
    {
      /* Device error */
      phost->Control.state = CTRL_ERROR;  

Seems that the code, in case of stall, does not return to previous machine state as stated in the above comment (and so skip the URB packet not recognized) but remains in this loop forever.

This is the same situation from this old post:

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/USB%20state%20machine%20hangs%20with%20some%20usb%20keys&currentviews=667

but the suggested modification does not work for me.

I'm open to advice to move on
Thanks in advance

Outcomes