STM32 in DFU mode using system bootloader is not recognized by host PC, or the connection is not reliable.
But USB user application works fine.
The problem here might be caused by the HSE crystal, as mentioned in AN2606 (see section 3.1 page 21):
"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)."
If the internal oscillator precision is altered above the tolerance band (1% around the theoretical value) due to temperature or other conditions, then the bootloader might calculate a wrong HSE frequency value.
In this case the bootloader DFU/CAN interfaces might dysfunction or might not work at all.
- Use the bootloader with a temperature controlled environment, such as a production line at ambient temperature
- If UART is used, use lower baud-rates at 9600 Bauds to minimize communications errors
- If USB or CAN are used, it is highly recommended to use lower external crystal value below or equal to 8MHz.
The lower the value is, the better the precision of the HSE computation.