Skip to main content
Visitor II
August 19, 2025
Question

STM32H7S3L8 USB core reset timeout

  • August 19, 2025
  • 2 replies
  • 449 views

Hey, we have purchased the Nucleo board H7S3L8-B02. We always run in a timeout during USB core reset. This problem seems quite popular with multiple forum posts. However we still didn't manage to get it to run. I will give a set by step explanation of what we've done. Maybe someone catches the mistake. We made all of our settings in "Application", none in "Boot".

  • USB_OTG_FS settings:USB_OTG_FSUSB_OTG_FS
  • Middleware CDC settings:

 

 

CDCCDC

 

  • Power settings:PWRPWR

     

  • Clock settings (automatic by IDE)

CLKCLK

  • main.c:
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "usb_device.h"


/* Private function prototypes -----------------------------------------------*/
static void MPU_Config(void);
static void MX_GPIO_Init(void);


int main(void)
{

 MPU_Config();

 /* Update SystemCoreClock variable according to RCC registers values. */
 SystemCoreClockUpdate();

 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
 HAL_Init();

 /* Initialize all configured peripherals */
 MX_GPIO_Init();
 MX_USB_DEVICE_Init();

 while (1)
 {
 /* USER CODE END WHILE */

 /* USER CODE BEGIN 3 */
 }
 /* USER CODE END 3 */
}

static void MX_GPIO_Init(void)
{
 /* GPIO Ports Clock Enable */
 __HAL_RCC_GPIOM_CLK_ENABLE();
}


 /* MPU Configuration */
static void MPU_Config(void)
{
 MPU_Region_InitTypeDef MPU_InitStruct = {0};

 /* Disables the MPU */
 HAL_MPU_Disable();

 /* Disables all MPU regions */
 for(uint8_t i=0; i<__MPU_REGIONCOUNT; i++)
 {
 HAL_MPU_DisableRegion(i);
 }

 /** Initializes and configures the Region and the memory to be protected
 */
 MPU_InitStruct.Enable = MPU_REGION_ENABLE;
 MPU_InitStruct.Number = MPU_REGION_NUMBER0;
 MPU_InitStruct.BaseAddress = 0x0;
 MPU_InitStruct.Size = MPU_REGION_SIZE_4GB;
 MPU_InitStruct.SubRegionDisable = 0x87;
 MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
 MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS;
 MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;
 MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
 MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
 MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;

 HAL_MPU_ConfigRegion(&MPU_InitStruct);
 /* Enables the MPU */
 HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);

}

void Error_Handler(void)
{
 __disable_irq();
 while (1)
 {
 }
}
#ifdef USE_FULL_ASSERT

void assert_failed(uint8_t *file, uint32_t line)
{

}
#endif /* USE_FULL_ASSERT */

 

 _hal_msp.c

/* Includes ------------------------------------------------------------------*/
#include "main.h"

void HAL_MspInit(void)
{

 PWR_PVDTypeDef sConfigPVD = {0};

 /* System interrupt init*/

 /** PVD Configuration
 */
 sConfigPVD.PVDLevel = PWR_PVDLEVEL_1;
 sConfigPVD.Mode = PWR_PVD_MODE_NORMAL;
 HAL_PWR_ConfigPVD(&sConfigPVD);

 /** Enable the PVD Output
 */
 HAL_PWR_EnablePVD();

 /* Enable USB Voltage detector */
 if(HAL_PWREx_EnableUSBVoltageDetector() != HAL_OK)
 {
 /* Initialization error */
 Error_Handler();
 }

 HAL_PWREx_EnableUSBReg();
}
  • usbd_conf.c
void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle)
{
 GPIO_InitTypeDef GPIO_InitStruct = {0};
 RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
 if(pcdHandle->Instance==USB_OTG_FS)
 {
 /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */

 /* USER CODE END USB_OTG_FS_MspInit 0 */

 /** Initializes the peripherals clock
 */
 PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USBOTGFS;
 PeriphClkInit.UsbOtgFsClockSelection = RCC_USBOTGFSCLKSOURCE_HSI48;
 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
 {
 Error_Handler();
 }

 /** Enable USB Voltage detector
 */
 HAL_PWREx_EnableUSBVoltageDetector();

 __HAL_RCC_GPIOM_CLK_ENABLE();
 /**USB_OTG_FS GPIO Configuration
 PM14 ------> USB_OTG_FS_VBUS
 */
 GPIO_InitStruct.Pin = GPIO_PIN_14;
 GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
 GPIO_InitStruct.Pull = GPIO_NOPULL;
 HAL_GPIO_Init(GPIOM, &GPIO_InitStruct);

 /* Peripheral clock enable */
 __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
 __HAL_RCC_USBPHYC_CLK_ENABLE();

 /* Peripheral interrupt init */
 HAL_NVIC_SetPriority(OTG_FS_IRQn, 0, 0);
 HAL_NVIC_EnableIRQ(OTG_FS_IRQn);
 /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */

 /* USER CODE END USB_OTG_FS_MspInit 1 */
 }
}

 

  • problem:
static HAL_StatusTypeDef USB_CoreReset(USB_OTG_GlobalTypeDef *USBx)
{
 __IO uint32_t count = 0U;

 /* Wait for AHB master IDLE state. */
 do
 {
 count++;

 if (count > HAL_USB_TIMEOUT)
 {
 return HAL_TIMEOUT;
 }
 } while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_AHBIDL) == 0U);

 /* Core Soft Reset */
 count = 0U;
 USBx->GRSTCTL |= USB_OTG_GRSTCTL_CSRST;

 do
 {
 count++;

 if (count > HAL_USB_TIMEOUT)
 {
 return HAL_TIMEOUT;
 }
 } while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_CSRST) == USB_OTG_GRSTCTL_CSRST);

 return HAL_OK;
}
    This topic has been closed for replies.

    2 replies

    Technical Moderator
    August 21, 2025

    Hi @STesil 

    Did you compare your configuration and setup with the provided examples. Also this article FAQ: Troubleshooting a USB core soft reset stuck could be helpful.

    Technical Moderator
    September 1, 2025

    Hi @STesil 

    Any update regarding the issue? Did you follow up the provided example firmware check USB cables?