cancel
Showing results for 
Search instead for 
Did you mean: 

Mistake in HAL USB libraries for STM32G0B1xx (and maybe bootloader)

Fluxon
Associate II

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.

3 REPLIES 3
TDK
Guru

Clearly a bug (in CubeMX generation, not bootloader). See:

https://community.st.com/s/question/0D53W00000qwRCQSA2/possible-stm32g0-cube-mx-generation-error-for-usb

If you feel a post has answered your question, please click "Accept as Solution".
Fluxon
Associate II

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.

PDawi
Associate

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?