cancel
Showing results for 
Search instead for 
Did you mean: 

Cube USB Library

lucas23
Associate II
Posted on April 08, 2015 at 22:00

Hi,

I have a STM32F4-Discovery board and I am trying to detect a memory stick using the USB library generated by CubeMX (Mass Storage Class).

The USB process state machine have the following states:

/* Following states are used for gState */

typedef enum 

{

  HOST_IDLE =0,

  HOST_DEV_WAIT_FOR_ATTACHMENT,  

  HOST_DEV_ATTACHED,

  HOST_DEV_DISCONNECTED,  

  HOST_DETECT_DEVICE_SPEED,

  HOST_ENUMERATION,

  HOST_CLASS_REQUEST,  

  HOST_INPUT,

  HOST_SET_CONFIGURATION,

  HOST_CHECK_CLASS,

  HOST_CLASS,

  HOST_SUSPENDED,

  HOST_ABORT_STATE,  

}HOST_StateTypeDef;

When I attach my memory stick in the board, the state machine goes to the HOST_CLASS_REQUEST state and never leaves it.

The problem is that I never get a OK status, but I never get a ABORT also.

case HOST_CLASS_REQUEST:  

    /* process class standard control requests state machine */

    if(phost->pActiveClass != NULL)

    {

      status = phost->pActiveClass->Requests(phost);

      

      if(status == USBH_OK)

      {

        phost->gState  = HOST_CLASS;        

      }  

    }

    else

    {

      phost->gState  = HOST_ABORT_STATE;

      USBH_ErrLog (''Invalid Class Driver.'');

    

#if (USBH_USE_OS == 1)

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

#endif       

    }

    

    break;

What can I do?

Thanks in advance!

1 REPLY 1
AndreaC
Associate III
Posted on December 09, 2016 at 18:02

(Old thread, so I put my answer just like a 'memo reminder')

I had the same problem and found out it was caused by not having allocated (enough) heap.

=> USB libraries rely on dynamic memory allocation!