2021-06-10 03:11 AM
As soon as I enabled any of the USB modes via CubeMX and generated code, the MCU goes to the error handler at startup and the USB host (PC) doesn't detect the MCU.
This happens because the HAL_PCD_ResetCallback in usbd_conf.c is called and there is a faulty line within this function.
On line 205 it reads "if(( hpcd->Init.speed != USB_DRD_SPEED_FS) || (hpcd->Init.speed != USB_DRD_SPEED_LS))". This statement however is always true, because it is either one or the other. This line can be fixed by changing || to &&. After this change, the MCU can be detected by the host.
I expect this mistake is also in the bootloader, as I get a Device Descriptor Request Failed from Windows connected to the MCU. This error was also there with the mistake on line 205.
Could there be another reason why the bootloader doesn't work in USB DFU mode?
And could the staff correct these mistakes to ensure the proper functionality of the bootloader?
PS: As of now I don't expect any hardware issues, as the STM32G0B1 connections are very straightforward, and I was able to get USB working with the correction to line 205.
2021-06-10 07:05 AM
Clearly a bug (in CubeMX generation, not bootloader). See:
2021-06-11 12:44 AM
Thank you for your reply. This indeed solves my problem in user flash. I was not able to find the linked thread myself, maybe because of the name, so thank you for the link. I will continue looking for a reason why the DFU is not recognized in bootloader mode.
2021-10-12 03:43 AM
Hello,
I have similar problem in my project. I am using STMIDE with MXCube 6.3.0 version and clear project for NUCLEO-G0B1RE. When i upload firmware Windows cant recognise device. I was testing on CDC and ADC device types.
APB Timer set to 48MHz
Is it possible that library still didnt working well?