2025-06-01 2:10 PM
Hello, I have been trying to implement USB support on an STM32u5g9vjt6Q using USBX in standalone mode without success as of yet. I have been referencing this guide (How to implement USBX in standalone mode ) I am trying to use the onboard USB Phy in full speed mode, I think my issue comes down to clock configuration. I am able to perform a USB DFU firmware update through the onboard ST bootloader so I am fairly certain I do not have a hardware issue, I also have a 16mhz external crystal.
My firmware will end up in a Error_Handler after a timeout, the timeout is happening during this block of code inside of USB_CoreReset()
do
{
count++;
if (count > HAL_USB_TIMEOUT)
{
return HAL_TIMEOUT;
}
} while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_CSRST) == USB_OTG_GRSTCTL_CSRST);
Debugging shows GRSTCTL = 0x80000001, CSRST = 0x1
I will attach a picture of the call stack w/ the section of code and the contents of the register. I will also attach the CubeIDE project.
Thanks!
Solved! Go to Solution.
2025-06-01 7:27 PM
After many hours scouring these forums and trying everything I could find I finally got it working. It all came down to 1 missing function call that was not generated by cubeMX or part of the usbx standalone guides I was following. I added the following call after the clocks are configured but before MX_USBX_DEVICE_Init is called. I placed this inside of the USER CODE BEGIN SysInit section
__HAL_RCC_SYSCFG_CLK_ENABLE();
2025-06-01 7:27 PM
After many hours scouring these forums and trying everything I could find I finally got it working. It all came down to 1 missing function call that was not generated by cubeMX or part of the usbx standalone guides I was following. I added the following call after the clocks are configured but before MX_USBX_DEVICE_Init is called. I placed this inside of the USER CODE BEGIN SysInit section
__HAL_RCC_SYSCFG_CLK_ENABLE();
2025-06-02 6:41 AM
Hi @brohr01
Glad you solved your issue. This FAQ: Troubleshooting a USB core soft reset stuck should be helpful in your case.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.