cancel
Showing results for 
Search instead for 
Did you mean: 

USB state machine hangs with some usb keys

Posted on August 14, 2013 at 17:47

Hello,

I'm using the STM USB library version V2.1.0 with an host profile and I found a problem working with some usb keys: the library was going up to enumeration but after if was hanging. Debugging the problem I finally got that the problem was in usbh_core.c in function USBH_HandleControl at case CTRL_DATA_IN_WAIT.

If after sending a request in the previous case, CTRL_DATA_IN, I got a Stall irq in HCINT the library was hanging without trying again with another request.

I solved the problem adding a ''phost->Control.state = CTRL_STALLED;'' in the 

if  (URB_Status == URB_STALL)

case CTRL_DATA_IN_WAIT:

   

    URB_Status = HCD_GetURB_State(pdev , phost->Control.hc_num_in);

   

    /* check is DATA packet transfered successfully */

    if  (URB_Status == URB_DONE)

    {

      phost->Control.state = CTRL_STATUS_OUT;

    }

  

    /* manage error cases*/

    if  (URB_Status == URB_STALL)

    {

      /* In stall case, return to previous machine state*/

      phost->gState =   phost->gStateBkp;

      phost->Control.state = CTRL_STALLED; ///<<<<< MY MODIFICATION

    }  

    else if (URB_Status == URB_ERROR)

    {

      /* Device error */

      phost->Control.state = CTRL_ERROR;   

    }

    else if ((HCD_GetCurrentFrame(pdev)- phost->Control.timer) > timeout)

    {

      /* timeout for IN transfer */

      phost->Control.state = CTRL_ERROR;

    }  

    break;

Debugging the code I noticed in fact that it was going back to the previous state machine but not starting form its initial case but going directly in a case in the middle of the state machine.

I would like to have your feedback if my modification has any sense for you and if yes I would suggest to add it in the next release of the library.

With this modification now it works with all the usb key I found around in my collegues desks (10 different types).

thanks

michele

#usb-msc-stm32-hang
2 REPLIES 2
Posted on August 24, 2013 at 08:42

Hello,

is there anybody that can confirm my modification? Without that I cannot mount 2 of the 3 usb keys I have on my desk.

I'm also experiencing other problems after mounting trying to read a file in the key: is there an issue board of the modifications in progress on the USB library? Just to see if there are knows issues and maybe some of them are solved.

Thanks

Michele

miguelmoreto
Associate
Posted on January 26, 2014 at 03:28

Hello Michele,

thanks a lot for your post! I can confirm that your modification worked for me too. I was trying with the USB Host Device demo (DRD) but I also got stuck in that state machine that hangs. I do not know USB very well so I couldn't find the cause of the hanging. I applied your modification and the demo worked. I was struggling with this for a week!

Maybe is something related with the revision Z chip error as stated in this post:

https://my.st.com/6e645738

I am using a custom board based on a STM32F107VC (rev. Z) with Coocox IDE (ARM GCC compiler 4.7).

Best regards!

Miguel