2021-10-23 12:08 AM
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.
Solved! Go to Solution.
2021-12-07 08:42 AM
It looks like STM32CubeG4 FW 1.5.0 resolved all mentioned issues.
2021-11-15 06:47 AM
Hello @BPaik ,
Thanks for your contribution. This issue has been raised internally.
I will keep you informed as soon as possible.
BeST Regards,
Walid
2021-11-15 07:37 AM
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
2021-11-15 07:42 AM
My issue is with the G4 library, not the F4. I was simply using an old F4 project as a reference.
2021-11-15 07:56 AM
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
2021-11-15 08:14 AM
"Porting" may have been the wrong choice of words. I didn't actually copy any of the driver code from the F4 project. All of the USB driver code was generated by cube MX for the G4. Essentially all I did was setup the project with cube MX and modified the code according to this guide https://youtu.be/3JGRt3BFYrM.
2021-11-15 08:34 AM
Hello @BPaik
In the video you have linked above, an older USB lib version is used.
Please refer to this example.
BeST Regards,
Walid
2021-11-17 06:42 PM
I did not use the library from the video in my project. I used the latest G4 library from CubeMX, and made a few modifications to source files based on the video. For additional clarification, I have already solved the issues and gotten USB custom HID communication working in my project. The purpose of this post is simply to point out issues with CubeMX generated code for the G4 so that they can be fixed in future versions of the G4 Firmware Package. I have identified the issues with the G4 Firmware Package and listed the file and line numbers in my original post.
2021-11-18 11:31 AM
You said that F4 CubeFW now supports the USB lib V2.6.0. What does the G4 CubeFW currently support?
2021-11-22 12:01 AM
Hello @BPaik ,
You can check the release note provided under the CubeFW package to know which version is supported.
Otherwise, the version of the USB library supported by G4 is V2.7.1.
BeST Regards,
Walid