2013-11-20 04:28 PM
I've come across an issue in usb_prop.c in the STM32 USB library examples. The _GetStringDescriptor function checks for the index of the Descriptor string, but allows an index of up to 4. There are actually only 4 strings in the Descriptor array, so index 4 is out of bounds and results in a hard fault. We've come across some applications that for whatever reason attempt to open all connected HID devices and grab a 5th string. The fix is to change the function as follows:
uint8_t *CustomHID_GetStringDescriptor(uint16_t Length)
{
uint8_t wValue0 = pInformation->USBwValue0;
// This is modified from ST's library. There are only 4 strings
if
(wValue0 >= 4)
{
return
NULL;
}
else
{
return
Standard_GetDescriptorData(Length, &String_Descriptor[wValue0]);
}
}