Showing results for 
Search instead for 
Did you mean: 

CubeMX problem in USB Host Enumeration with STM32F105.

Brian 1246


Currently I'm working with a CubeMX project in which STM32F105 acts as a USB Host and communicates with USB flash drives. The problem is after detecting attached device and getting device speed successfully the enumeration stage fails. Tracing down the problem I see that when the host try to send out a packet to get the description of max packet size the TX channel is halted and the transaction error code HC_XACTERR is returned in HCD_HC_OUT_IRQHandler(). I'm using a custom board which works well with an old USB library, so I conclude that the hardware is correct and the problem lies within the CubeMX setting or USB library. Can anyone suggests about this problem? Here is a few more details of my project and what I've tried so far:

- Hardware: USB DP and DM are connected directly to the USB port without any pull-up resistor, the USB device is powered by a fixed 5V bus.

- CubeMX version: 5.3.0. Firmware package version: STM32Cube FW_F1 V1.8.0. IDE: Keil v5.28.0.

- Pinout&configuration: USB Host: Mode Mass Storage Class, FreeRTOS is disabled, Drive_VBUS_FS pin is unconnected. USB OTG FS: Mode Host only, PA11 and PA12 are USB DM and DP. FATFS: USB Disk is selected. The other options are kept the same as default. UART3 is used to send debug messages to a PC. Interrupt priority level is 5 for USB OTG and 6 for UART3.

- Clock: Using HSE source with a 25MHz oscillator, USB frequency is 48MHz, other units frequency is 25MHz.

- The current program is the same as the default generated code, MX_USB_HOST_Init() is called first in the setup routine, the while() loop of the main() only contains function MX_USB_HOST_Process().

- What I've tried so far:

+ Compare the old USB library and the CubeMX library. The functions for Host Enumeration

are implemented almost the same in the driver level. I've changed a few details like the amount of time delayed according to the old library but the results are still the same.

+ Enable and disable debug messages, the results are the same.

+ Try different USB flash drives having USB protocol 2.0 and capacity range from 500MBs to 8GBs, the results are the same.

+ Try the HID class with mice and keyboards, the process also fails with the same enumeration error.


I have the exact same problem.


i have the same problem,the enumeration can't reach APPLICATION_READY,just stay at APPLICATION_START,not sure why


This worked for me:

  1. Use CubeMX V1.7

I needed long names for my project so additional were required

  1. In file ff.c change *lfname to lfname[_MAX_LFN]
  2. If the function f_readdir(&dir, &fno) is called in the project just before it I added fno.lfsize = _MAX_LFN