cancel
Showing results for 
Search instead for 
Did you mean: 

STM32Cube FW_G4 V1.4.0 breaks USB HID communication

BPaik
Senior

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.

12 REPLIES 12

As mentioned in my original post, I needed to restore a line of code to "stm32g4xx_hal_pcd.c" (that was removed in CubeMX G4 V1.4.0) in order for the USB Custom HID to function properly. This appears to be an issue with the HAL driver code rather than the USB library. The HAL driver code from the example you linked is significantly different from that of CubeMX G4 V1.4.0, and thus does not provide insight on how to deal with this issue. Even though I can get the USB Custom HID interface to work, I don't think it should be necessary to modify the HAL driver source to do so. Let me know if there is an alternative workaround. Otherwise, I believe this should be fixed in the next version of CubeMX G4.

BPaik
Senior

It looks like STM32CubeG4 FW 1.5.0 resolved all mentioned issues.

HLee.21
Associate III

@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).