USBX CustomHID OUT Report size issue
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-03-31 3:50 AM - last edited on 2025-03-31 3:56 AM by Peter BENSCH
USB HID Endpoint Size Challenge - My Experience
Issue Description
I'm experiencing an issue with USB HID endpoint sizes in my firmware running on an STM32U5 microcontroller with ThreadX RTOS and USBX middleware. Specifically:
- My host is sending 20-byte messages (1 byte report ID + 1 byte page number + 18 bytes of data)
- I've tried setting the endpoint maximum packet size (USBD_HID_CUSTOM_EPOUT_HS_MPS and USBD_HID_CUSTOM_EPOUT_FS_MPS) to 24U and 32U, but neither worked
- Only a 16-byte endpoint size works with my hardware, which creates a mismatch with my 20-byte report size
- Most importantly, my USBD_Custom_HID_SetReport callback function does not get called at all when using 24U or 32U endpoint sizes
Technical Details
- Hardware Platform: STM32U5 series microcontroller
- RTOS: ThreadX
- USB Stack: USBX middleware
- USB Class: Device HID Custom Class
- Report Size: 20 bytes (defined in HID report descriptor)
- Working Endpoint Size: 16 bytes
- Non-working Endpoint Sizes: 24, 32, 64 bytes
- Thread Stack Size: 2048 bytes
- Memory Usage: ~70% of available RAM
Attempted Solutions
- I initially tried setting the endpoint size to match the report size (24U)
- I tried increasing the endpoint size to 32U and 64U (power of 2)
- I modified USBD_Custom_HID_EventMaxLength to return 16U instead of 20U to match the working endpoint size but I'm loosing 4 bytes
- I've tried to increase memory, thread size and bits alignment
My Questions
- Why don't 24-byte or 32-byte endpoint sizes work with the STM32U5 USB controller when using USBX?
- Why does USBD_Custom_HID_SetReport not get called when using 24U or 32U endpoint sizes?
- Is there a hardware limitation or configuration issue that restricts the endpoint size to 16 bytes?
- Are there specific alignment requirements for USB endpoint sizes on STM32U5 that aren't documented?
- Could this be a bug in the USBX implementation for STM32U5?
- Are there any specific USB controller registers or configurations that need to be adjusted to support larger endpoint sizes?
- Is there a memory allocation or thread stack size issue that could be affecting larger endpoint sizes?
CUBEMx Project Settings for USBX
USBX.BSP.number=1
USBX.Core_System=1
USBX.IPParameters=Core_System,UX_Device_CoreStack,UX_Device_Controller,UX_SLAVE_REQUEST_DATA_MAX_LENGTH,USBD_PID,USBD_PRODUCT_STRING,USBD_SERIAL_NUMBER,UX_DEVICE_APP_MEM_POOL_SIZE,USBD_COMPOSITE_USE_IAD,USBX_DEVICE_SYS_SIZE,MAX_POWER_IN_MILLI_AMPER,UX_DEVICE_HID_CORE,USBD_MANUFACTURER_STRING,REG_USBX_DEVICE_CON_CK,UX_DEVICE_HID_CUSTOM,USBD_HID_CUSTOM_EPIN_FS_MPS,USBD_HID_CUSTOM_EPIN_HS_MPS,USBD_VID,UX_THREAD_PRIORITY_DCD,UX_DEVICE_CLASS_HID_INTERRUPT_OUT_SUPPORT,USBD_HID_CUSTOM_EPOUT_ADDR,USBD_HID_CUSTOM_EPOUT_FS_MPS,USBD_HID_CUSTOM_EPOUT_HS_MPS
USBX.MAX_POWER_IN_MILLI_AMPER=500
USBX.REG_USBX_DEVICE_CON_CK=1
USBX.USBD_COMPOSITE_USE_IAD=1
USBX.USBD_HID_CUSTOM_EPIN_FS_MPS=64
USBX.USBD_HID_CUSTOM_EPIN_HS_MPS=64
USBX.USBD_HID_CUSTOM_EPOUT_ADDR=2
USBX.USBD_HID_CUSTOM_EPOUT_FS_MPS=16
USBX.USBD_HID_CUSTOM_EPOUT_HS_MPS=16
USBX.USBD_MANUFACTURER_STRING=XXX
USBX.USBD_PID=XXX
USBX.USBD_PRODUCT_STRING=XXX
USBX.USBD_SERIAL_NUMBER=XXX
USBX.USBD_VID=XXX
USBX.USBX_DEVICE_SYS_SIZE=8*1024
USBX.UX_DEVICE_APP_MEM_POOL_SIZE=11*1024
USBX.UX_DEVICE_CLASS_HID_INTERRUPT_OUT_SUPPORT=1
USBX.UX_DEVICE_HID_CORE=1
USBX.UX_DEVICE_HID_CUSTOM=1
USBX.UX_Device_Controller=1
USBX.UX_Device_CoreStack=1
USBX.UX_SLAVE_REQUEST_DATA_MAX_LENGTH=64
USBX.UX_THREAD_PRIORITY_DCD=20
USBX0.BSP.STBoard=false
USBX0.BSP.api=Unknown
USBX0.BSP.component=
USBX0.BSP.condition=SEMAOoUSBOoDRDOoFSOoDEVICEOoFOROoUSBX & DIE455
USBX0.BSP.instance=USB_DRD_FS
USBX0.BSP.ip=USB_DRD_FS
USBX0.BSP.mode=Device_Only_FS
USBX0.BSP.name=USB_Device
USBX0.BSP.semaphore=
USBX0.BSP.solution=USB_DRD_FS
Thanks!
Labels:
- Labels:
-
STM32U5 series
-
USB
0 REPLIES 0
