cancel
Showing results for 
Search instead for 
Did you mean: 

!!! BUG FOUND !!! : New Firmware version 1.8 introduced a sort of bug in USB Host enumeration - tested with STM32F105

MAlek
Associate II

If you upgrade to the last firmware (1.8) it will make the USB enumeration process no more work.

To repeat the process just create a project using USB and put a breakpoint at the lines for each event

static void USBH_UserProcess  (USBH_HandleTypeDef *phost, uint8_t id)
{
  /* USER CODE BEGIN CALL_BACK_1 */
  switch(id)
  {
  case HOST_USER_SELECT_CONFIGURATION:
  break;
 
  case HOST_USER_DISCONNECTION:
  Appli_state = APPLICATION_DISCONNECT;
  break;
 
  case HOST_USER_CLASS_ACTIVE:
  Appli_state = APPLICATION_READY;
  break;
 
  case HOST_USER_CONNECTION:
  Appli_state = APPLICATION_START;
  break;
....

in usb_host.c file

You will see only the disconnection event being generated.

7 REPLIES 7
MAlek
Associate II

It seems that the port (phost->device.PortEnabled) never gets enabled

    case HOST_DEV_WAIT_FOR_ATTACHMENT: /* Wait for Port Enabled */
 
      if (phost->device.PortEnabled == 1U)
      {
        USBH_UsrLog("USB Device Reset Completed");
        phost->gState = HOST_DEV_ATTACHED;
      }

so the next state never goes to HOST_DEV_ATTACHED

Debug it working backwards - phost->device.PortEnabled gets set in USBH_LL_PortEnabled(), you should be calling that somewhere. In the demos USBH_LL_PortEnabled() gets called from HAL_HCD_PortEnabled_Callback() and that - condition to #if (USE_HAL_HCD_REGISTER_CALLBACKS == 1U) - from HAL_HCD_Init().

I might've been wrong in deciphering what's going on. Just looking at the code; don't use 'F105 and I wouldn't touch Cube with a stick.

JW

MAlek
Associate II

Yesterday i opened a ticket about that issue.

I think they missed "port enabling" thing because they changed the code just in the enumerating, in the state machine the old one (1.7 ) is just :

case HOST_DEV_WAIT_FOR_ATTACHMENT:
    break;

You see that PortEnabled verification does not exist.

Thank you @Community member​ 

ps: What's the meaning of " ...wouldn't touch Cube with a stick" ?

MAlek
Associate II

I forgot to mention that the function that set the portEnabled to '1' is :

void USBH_LL_PortEnabled(USBH_HandleTypeDef *phost)
{
  phost->device.PortEnabled = 1U;
 
#if (USBH_USE_OS == 1U)
  phost->os_msg = (uint32_t)USBH_PORT_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
 
  return;
}

And it is never called ! I took a look and discover that it is using the USB Host 3.3.3 and for STM32F4 MCUs ,for example, they are packing with 3.3.2. I mean, perhaps with a new upgrade all will have the same issue.

MAlek
Associate II

I found the solution! You need to implement the weak functions.

I don't know why they introduced this type of 'flexibility' . It make the code abruptly stop to work !

Well, just to help others with a similar problem, put the code in your usbh_conf.c

/* USER CODE BEGIN 1 */
void HAL_HCD_PortEnabled_Callback(HCD_HandleTypeDef *hhcd)
{
    USBH_LL_PortEnabled(hhcd->pData);
}
 
void HAL_HCD_PortDisabled_Callback(HCD_HandleTypeDef *hhcd)
{
    USBH_LL_PortDisabled(hhcd->pData);
}
/* USER CODE END 1 */

Cheers ! Marcelo Aleks

> What's the meaning of " ...wouldn't touch Cube with a stick" ?

 I avoid "touching it " (using it, getting into contact with it) at all costs; I have a strong aversion to it.

JW

LGree.1212
Associate

I also came across this bug. It really is a bug, as the advertised features of the USBH do not work unless this code is inserted.