STM32 USB device - device descriptor request failed

I'm using STM32F7-45 on my own board, and I am trying to program USB device (I tried virtual COM and HID, separately).

But after plugging into PC it is detected (after a while) with "Unknown device (device descriptor request failed)" error.

Electrically (PCB):
I think that PCB is not an error here - I just have D+ and D- short tracks from the connector to the uC and that's all.
I have a pull-up 1.5k (I tried with and without it), but it is not even needed in STM32. I have check connection and a cable and I'm certain it connects.

Code:
I'm using HAL and STM32CubeMx generated code merged with my project. Generally programs freezes.

1) After executing line (from library code) USBx->GAHBCFG |= USB_OTG_GAHBCFG_GINT;. I know that, as I tried printing before and after that line and only first printf() prints. I don't understand how the program can stuck there.
Anyway, if I disable VBUS sensing then the program doesn't get stuck there and the whole MX_USB_DEVICE_Init finishes.

2) But then, program executes few cycles (for example, it will print "done" and lit the LED) and after that it freezes. Completely. This LED should blink in an infinite loop, but it doesn't. I have other LED to be enabled in all error handlers (like hard fault etc.) and it seems that the the program doesn't go there (as the LED is off), so I don't understand where it get stuck.

• After virtual COM, I tried HID but to no avail. It gives me the same behavior.
• If I power the board from the charger (not PC) then the program doesn't get stuck.
• Hi MasMas :). Do you have a debugger? What does it mean freezes? What does it mean 'But then, program executes few cycles'? Cycles of what? 'it will print "done" and lit the LED' - via just initialised USB?. Actually your description is far from being technical or understandable. – P__J__ Oct 30 '17 at 19:10
• It may be not the best description as I wanted to keep it short.. Freezes? Well, I thought it's unambiguous - it doesn't do next instructions in the code, just stops executing them, probably jumps into some interrupt (or I don't know) or have some other error. Few cycles of what? Of course of CPU = few instructions. It will print "done" on terminal through UART. I have ST-Link. – zupazt3 Oct 31 '17 at 10:15
• I have ST-Link - so check where you end up. Having the debugger and writing probably jumps somewhere shows that your debugging effort was far from being sufficient. – P__J__ Oct 31 '17 at 10:18
• Well, I just have never used ST-Link for anything other than programming the flash, that's why... Usually I was fine with UART. I'm using Visual Studio and VirtualGDB but I couldn't make my st-link work with that. I first have to learn it, then I will try it and get back here. – zupazt3 Oct 31 '17 at 16:30