Simplest possible CubeMX USB app fails to enumerate
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 evenbegins enumeration. The following procedure was used to develop a minimal reproducible example:
- Start new project in CubeMX
- Select Board Selector, Type of Board: Nucelo144, MCU Series: STM32F3, Board NUCLEO-F303ZE
- Under RCC, select HSE = Bypass Clock Source
- Under USB, select Device(FS)
- Under USB_DEVICE, Class for FS IP: Human Interface Class
- Select Clock Configuration tab, allow autoconfiguration, ensure USB clock is correctly set to 48MHz
- Go to Project Settings, changeMinimum Heap Size to 0x400, Minimum Stack Size to 0x800
- Choose toolchain to be Makefile (using GCC-ARM for Windows)
- Save file, Generate Source
- Edit main.c to insert some trivial test code (such as the `USBD_HID_SendReport` sample in the 'STM32 USB in 10 Minutes' video)
- Run make, verify build success
- Using ST-Link Utility, flash bin file onto device
- Observe the tragic lack ofUSB enumeration (evenno '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.
TheUSB HAL code that ships with theSDK 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-cubemx #usb Note: this post was migrated and contained many threaded conversations, some content may be missing.