Skip to main content
Associate II
October 21, 2025
Solved

"UX_DEVICE_CLASS_HID_EVENT_BUFFER_LENGTH" is commented out when set to 64

  • October 21, 2025
  • 2 replies
  • 291 views

STM32H5 USB Custom HID CubeMX issue.

When setting parameter "UX_DEVICE_CLASS_HID_EVENT_BUFFER_LENGTH" to 64 in CubeMX, the corresponding define in the "ux_user.h" file is commented out.

Setting this parameter to any other valid value (between 0 and 255, excluding 64) in CubeMX generates an uncommented define.

I presume CubeMX is doing this because it assumes the default value from USBX is 64 bytes.

In fact a default value is provided by usbx in "ux_device_class_hid.h", but this value is actually 32 bytes.

Thus, using out of the box CubeMX generated code when "UX_DEVICE_CLASS_HID_EVENT_BUFFER_LENGTH" set to 64 results in very nasty memory overwrites in the USBX device structures that subsequently result in hard fault.

Please update CubeMX to not comment out this define when set to 64.

Thank you.

 

 

 

 

Best answer by T_Hamdi

Hello @KaiY 

Thank you for bringing this issue to our attention.

I reported this internally.

Internal ticket number: 220335 (This is an internal tracking number and is not accessible or usable by customers).

2 replies

Technical Moderator
October 23, 2025

Hi @KaiY 

Would you attach your iOC file to reproduce ?

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.Best regards,FBL
T_Hamdi
T_HamdiBest answer
ST Employee
October 23, 2025

Hello @KaiY 

Thank you for bringing this issue to our attention.

I reported this internally.

Internal ticket number: 220335 (This is an internal tracking number and is not accessible or usable by customers).

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question.Hamdi Teyeb"