Skip to main content
Visitor II
March 13, 2025
Solved

Bug in USB Host core STM32Cube_FW_H7_V1.12.0 causes USBH_Init failure.

  • March 13, 2025
  • 3 replies
  • 892 views

(found using STM32H723 NUCLEO board)

 

Hi,

When trying to implement a USG OTG application, where the USB port is required to switch backwards and forwards many times between device and host mode, there appears to be an error in the USBH_DeInit function in usbh_core.c: 

The function does not call USBH_LL_DeInit and as a result a subsequent re-initialisation of the host stack fails because the host state is not set back to RESET and the peripheral clock does not then get re-started.

Compare this with the equivalent function in the device stack (USBD_DeInit in usbd_core.c). This correctly calls the equivalent function USBD_LL_DeInit at the end of the function and as a result the device stack can be de-initialised and re-initialised many times.

The fix is simply to add the call to USBH_LL_DeInit at the end of USBH_DeInit and the host stack can then be de-initialised and re-initialised many times without issue.

Thanks,

Steve

    This topic has been closed for replies.
    Best answer by FBL

    Hi @steve_edwards 

    The definition of USBH_LL_DeInit is user code implementation in usbh_conf.c, how should it be called in lower level drivers? You may use HAL_HCD_MspDeInit user section as well if needed. Do you agree?

    3 replies

    FBLAnswer
    Technical Moderator
    March 13, 2025

    Hi @steve_edwards 

    The definition of USBH_LL_DeInit is user code implementation in usbh_conf.c, how should it be called in lower level drivers? You may use HAL_HCD_MspDeInit user section as well if needed. Do you agree?

    Visitor II
    March 13, 2025

    Hi @FBL ,

     

    Thanks for your reply. There are already a number of calls in usbh_core.h to other USB_LL_ functions, for instance the Init, Start, Stop and all these are implemented in the user code implementation of usbh_conf.c. And usbh_conf.c is implemented as per the supplied usbh_conf_template.c.

    The bug stems from the fact that it fails to call the USBH_LL_DeInit at the end of de-initialisation - please compare this with the device case in USBD_DeInit where you will see that this function does call the corresponding USBD_LL_DeInit function.

    Technical Moderator
    March 13, 2025

    Hi again @steve_edwards 
    Would you share a minimum project to reproduce?

    The bug stems from the fact that it fails to call the USBH_LL_DeInit at the end of de-initialisation -

    Maybe it calls USBH_LL_DeInit but the sequence in USB_StopHost is missing something to clean properly low layer driver.