Hard Fault error with stm32 HAL USB host library

Hard Fault error with stm32 HAL USB host library

Hello all!
I have custom board with stm32f469 mcu. Use STM32CubeIDE.
At first I created a project with only GUI and hardware buttons for control. Except for a few little things, the project worked well.
Now I need to add touchscreen support to the project. The touchscreen works via USB. Receiving data from the touchscreen was tested on my board without LVGL.
When connecting and initializing the LVGL (touchscreen not add like control device), USB device is initialized, receives all the necessary descriptors, goes into the touchscreen polling mode. At the first poll goes to Hard Fault.

Code from usbh_hid.c

    case HID_GET_DATA:
      USBH_InterruptReceiveData(phost, HID_Handle->pData,
                                (uint8_t)HID_Handle->length,
                                HID_Handle->InPipe);

      HID_Handle->state = HID_POLL;
      HID_Handle->timer = phost->Timer;
      HID_Handle->DataReady = 0U;
      break;
    case HID_POLL:
      if (USBH_LL_GetURBState(phost, HID_Handle->InPipe) == USBH_URB_DONE)
      {
        XferSize = USBH_LL_GetLastXferSize(phost, HID_Handle->InPipe);

        if ((HID_Handle->DataReady == 0U) && (XferSize != 0U))
        {
          USBH_HID_FifoWrite(&HID_Handle->fifo, HID_Handle->pData, HID_Handle->length);
          HID_Handle->DataReady = 1U;
          USBH_HID_EventCallback(phost);
...

In HID_GET_DATA or HID_POLL the following happens:
lv_task_handler is called and _lv_task_ll have bad .head pointer

Error in pointer


Then _lv_ll_get_next return HardFault error

I tried v7.0 and 7.1 versions. I try change optimization in project. No effect.

Please help me, I really like this library, but it is also necessary to support the touchscreen

If the issue only happens when you introduce the USB library I suspect that there’s memory corruption within that somewhere.