AnsweredAssumed Answered

Simplest possible CubeMX USB app fails to enumerate

Question asked by Gavin Baker on Oct 20, 2017
Latest reply on Jan 10, 2018 by Gowree K

I have a brand-new STM32F303 Nucleo144 and cannot get any CubeMX generated apps to work with USB. The app builds and runs fine, and I can see printf output via SWO, but the device never even begins enumeration. The following procedure was used to develop a minimal reproducible example:


  1. Start new project in CubeMX
  2. Select Board Selector, Type of Board: Nucelo144, MCU Series: STM32F3, Board NUCLEO-F303ZE
  3. Under RCC, select HSE = Bypass Clock Source
  4. Under USB, select Device(FS)
  5. Under USB_DEVICE, Class for FS IP: Human Interface Class
  6. Select Clock Configuration tab, allow autoconfiguration, ensure USB clock is correctly set to 48MHz
  7. Go to Project Settings, change Minimum Heap Size to 0x400, Minimum Stack Size to 0x800
  8. Choose toolchain to be Makefile (using GCC-ARM for Windows)
  9. Save file, Generate Source
  10. Edit main.c to insert some trivial test code (such as the `USBD_HID_SendReport` sample in the "STM32 USB in 10 Minutes" video)
  11. Run make, verify build success
  12. Using ST-Link Utility, flash bin file onto device
  13. Observe the tragic lack of USB enumeration (even no 'Unknown Device')


Plugging and unplugging the device's user USB port does nothing on the PC - not even showing an unknown device. Device Manager does not attempt a refresh (which is visually quite noticeable) when you plug in the device. So the failure is at a very early stage, perhaps not even beginning to enumerate. This leads me to suspect perhaps a clock or interrupt issue.


I have tried many fixes, including the following changes, and nothing helps at all:

  • Set heap and stack to much higher values
  • Set explicit priorities for SysTick and USB in NVCC (higher and lower)
  • Set HSE to crystal (rather than bypass, which it should be according to the docs)
  • Switch to using CDC and MSC classes
  • Use or disable FreeRTOS
  • Comment out SysTick handler


I also tried starting from scratch and following along with the official STM tutorial as shown in this video:



But that didn't work either. Thinking perhaps there was some faulty hardware, I tried another board. Still nothing. I've tried nearly every suggestion I could find in the forums.


The USB HAL code that ships with the SDK is not actually generated by CubeMX (and doesn't have gcc Makefiles) so it's not really that useful.


So is there a minimalist USB example that is actually generated from CubeMX that actually works?


Thanks -


  :: Gavin


stm32 cubemxusb