DFU mode with USB works weirdly (set address failed), while USB does
My USB user application works fine, but DFU mode using USB works weirdly, sometime it work, but regular it is not recognized by host PC.

My USB user application works fine, but DFU mode using USB works weirdly, sometime it work, but regular it is not recognized by host PC.

Welcome, @HDang.3, to the community!
If you are talking about DFU Boot Mode, it could be caused by an aged crystal or one that differs due to temperature changes. Details can be found in AN2606, Section 4.1:
For STM32 devices embedding bootloader using the DFU/CAN interface in which the external clock source (HSE) is required for DFU/CAN operations, the detection of the HSE value is done dynamically by the bootloader firmware and is based on the internal oscillator clock (HSI, MSI). When (because of temperature variations or other conditions) the internal oscillator precision is altered above the tolerance band (1% around the theoretical value), the bootloader might calculate a wrong HSE frequency value. In this case, the bootloader DFU/CAN interfaces might malfunction or not work at all.
Good luck!
If the problem is resolved, please mark this topic as answered by selecting Select as best. This will help other users find that answer faster.
/Peter
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.