Skip to main content
Senior
October 23, 2021
Solved

STM32Cube FW_G4 V1.4.0 breaks USB HID communication

  • October 23, 2021
  • 4 replies
  • 3453 views

I have been having much difficulty trying to port a custom USB HID protocol from a previous project using the STM32F405 to the STM32G431. Connection would initially be established, immediately followed by pipe errors. Eventually I found that if I downgraded from the V1.4.0 firmware package to the V1.3.0, the application was able to successfully establish USB communication with my PC. After some painstaking file comparison and testing with GIT, I found the lines of code in V1.4.0 that break USB HID communication:

"Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pcd.c" - line 1854: A conditional that checks for non bulk transactions that was removed from V1.4.0

"Middlewares/ST/STM32_USB_Device_Libarary/Class/CustomHID/Src/usbd_customhid.c" - line 682: A call to "USBD_LL_PrepareReceive" was removed from the "USBD_CUSTOM_HID_DataOut" function.

Restoring both of these lines restored USB functionality.

This topic has been closed for replies.
Best answer by BPaik

It looks like STM32CubeG4 FW 1.5.0 resolved all mentioned issues.

4 replies

Walid ZRELLI
Visitor II
November 15, 2021

Hello @BPaik​ ,

Thanks for your contribution. This issue has been raised internally.

I will keep you informed as soon as possible.

BeST Regards,

Walid

Walid ZRELLI
Visitor II
November 15, 2021

Hello @BPaik​ ,

It seems that you are using an old version of USB lib on F4 project.

In fact, starting from V2.6.0 we added un update on CustomHID driver to let user decide when to reactivate the out endpoint to start receive the next Data report.

This allows application to process the already received data.

You can refer to the provided example on F4 cube or the template file of CustomHID class driver.

As well, you should call the USBD_CUSTOM_HID_ReceivePacket() function to prepare EP to receive the next data report.

I hope this helps you.

Please click on Select as Best if my post fully answered your question. This will help other customers with the same issue to find the solution faster!

BeST Regards,

Walid

BPaikAuthor
Senior
November 15, 2021

My issue is with the G4 library, not the F4.​ I was simply using an old F4 project as a reference.

Walid ZRELLI
Visitor II
November 15, 2021

Hello @BPaik​ ,

Yes, I know. I mean that you have faced this problem when porting from F4 to G4 because you started from an older F4 Cube version which have an old USB lib version.

The F4 CubeFW supports the USB lib V2.6.0 now.

BeST Regards,

Walid

BPaikAuthorBest answer
Senior
December 7, 2021

It looks like STM32CubeG4 FW 1.5.0 resolved all mentioned issues.

HLee.21
Associate II
August 20, 2022

@BPaik what line did you exactly change to what? I'm having a custom USB HID issue on current L0 Firmware (but not on V1.12.0).