I advise you to follow this FAQ:USB device not recognizedwith the solution to either increase the heap size, or configure the USB library.
This STM32 USB training video will help you for setting up the USB device.
In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks