Skip to main content
Visitor II
July 28, 2022
Solved

HAL USB_CoreReset times out on the CM4 core of a Nucleo-H745zi-q

  • July 28, 2022
  • 2 replies
  • 2389 views

Attempting to get USB CDC running on the CM4 core of a stock Nucleo-H745zi-q board. USB_CoreReset() times out waiting for a soft reset. Any help would be greatly appreciated.

Timeout is in stm32h7xx_ll_usb.c, lines 1456-1469:

/* Core Soft Reset */
 count = 0U;
 USBx->GRSTCTL |= USB_OTG_GRSTCTL_CSRST;
 
 do
 {
 count++;
 
 if (count > 200000U)
 {
 return HAL_TIMEOUT;
 }
 } while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_CSRST) == USB_OTG_GRSTCTL_CSRST);

USB clock is RC48

Project built with CubeMX V6.6.1, CubeIDE V1.10.1, Firmware FW_H7 V1.10.0

 I moved the USB from the CM4 core to the CM7, and this issue does not occur.

    This topic has been closed for replies.
    Best answer by mƎALLEm

    Hello,

    If you look at usbd_desc.c/line 337: Get_SerialNum() function does access the system memory. Unfortunately, CM4 doesn't have access to this region.

    So to use the device ID as a serial number, you have to read it by CM7, save it in the RAM which will be available later-on for CM4. 

    You can test it by -in Get_SerialNum()- replacing:

    deviceserial0 = *(uint32_t *) DEVICE_ID1;

    deviceserial1 = *(uint32_t *) DEVICE_ID2;

    deviceserial2 = *(uint32_t *) DEVICE_ID3;

    by:

    deviceserial0 = 0xABCDEF12;

    deviceserial1 = 0x12345678;

    deviceserial2 = 0x12A3D459;

    2 replies

    Visitor II
    August 26, 2022

    Hello @WLear​ ,

    You can refer to the following example provided under the H7 Firmware Package which uses both cores CM4 and CM7:

    Path: Projects\STM32H747I-EVAL\Applications\USB_Device\HID-CM4_MSC-CM7

    I hope this helps.

    BeST Regards,

    Walid

    WLearAuthor
    Visitor II
    August 26, 2022

    Thankyou. Unfortunately, this example exhibits the same issue as my code. See the response from @SofLit for the root cause.

    mƎALLEmAnswer
    Technical Moderator
    August 26, 2022

    Hello,

    If you look at usbd_desc.c/line 337: Get_SerialNum() function does access the system memory. Unfortunately, CM4 doesn't have access to this region.

    So to use the device ID as a serial number, you have to read it by CM7, save it in the RAM which will be available later-on for CM4. 

    You can test it by -in Get_SerialNum()- replacing:

    deviceserial0 = *(uint32_t *) DEVICE_ID1;

    deviceserial1 = *(uint32_t *) DEVICE_ID2;

    deviceserial2 = *(uint32_t *) DEVICE_ID3;

    by:

    deviceserial0 = 0xABCDEF12;

    deviceserial1 = 0x12345678;

    deviceserial2 = 0x12A3D459;

    WLearAuthor
    Visitor II
    August 26, 2022

    Yes, This test patch does allow the USB init function to return without timing out. I trust this bug will be fixed in the next H7 firmware release.

    Explorer
    March 19, 2024

    I just ran into this bug, CubeIDE version 1.14.1, STM32H755, USB running on the CM4. Stepping through initialization I don't see it hitting the Get_SerialNum function before attempting the CoreReset. It times out waiting on USB_OTG_GRSTCTL_CSRST. I changed the Get_SerialNum function as described above but I'm still getting the time out. Were you able to implement a workaround to allow the CM4 to run USB? Thanks!