alambe94 / I-CUBE-USBD-Composite

Create STM32 USB Composite devices with ease.
MIT License
142 stars 30 forks source link

Incorrect user string descriptor responses when DMA is enabled #31

Open shadowfox6 opened 12 months ago

shadowfox6 commented 12 months ago

When USB DMA is enabled, the string descriptors are not transmitted properly through the control endpoint. The issue is that the local USB_StrDesc array in USBD_COMPOSITE_GetUsrStringDesc() is not aligned. Also, it is bad form to use a temporary local array outside of the function it is used in.

Note that the global USB_StrDesc array declared in usbd_desc.c is aligned, and so the top-level string descriptors handled by usbd_desc.c are transmitted properly.

To resolve this, either the locally defined USB_StrDesc array should be globally defined with a different name, or you could extern the existing array for direct access in usbd_composite.c.

shadowfox6 commented 12 months ago

Using the global USB_StrDesc array in usbd_composite.c did not work for me and caused an abort. Making the local variable in USBD_COMPOSITE_GetUsrStringDesc() global, changing its name to something like USBD_UsrStrDesc and aligning it did work for me.