2025-10-21 1:51 AM - last edited on 2025-10-21 2:38 AM by Andrew Neil
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.