-
Notifications
You must be signed in to change notification settings - Fork 77
Description
Hi!
Target STM32f. USB RNDIS.
I have turned on the MPU with checking access to address 0 and Flash area.
In the code of the file third_party/st/drivers/stm32_usb_device_library/core/src/usbd_ctrlreq.c:
Function:
static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
Line 413:
case USB_DESC_TYPE_CONFIGURATION:
if (pdev->dev_speed == USBD_SPEED_HIGH)
{
pbuf = pdev->pClass->GetHSConfigDescriptor(&len);
pbuf[1] = USB_DESC_TYPE_CONFIGURATION;
}
else
{
pbuf = pdev->pClass->GetFSConfigDescriptor(&len);
pbuf[1] = USB_DESC_TYPE_CONFIGURATION; <<<< Line 413
}
break;
Writing to the second element of the array that is located on the flash: Mem_Fault!
Descriptor is const:
CycloneTCP/drivers/usb_rndis/usbd_desc.c
Line 99 in 2325b88
| const UsbConfigDescriptors usbdConfigDescriptors = |
Link to official repository:
https://github.com/STMicroelectronics/stm32_mw_usb_device/blob/5af065de854f4573511e023aa76c3462c60a0a21/Core/Src/usbd_ctlreq.c#L414
In examples from st.com, descriptors are always not constants!
/* USB CDC device Configuration Descriptor */
__ALIGN_BEGIN static uint8_t USBD_CDC_CfgFSDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN_END =
and
/* USB CDC_RNDIS device Configuration Descriptor */
__ALIGN_BEGIN static uint8_t USBD_CDC_RNDIS_CfgHSDesc[] __ALIGN_END =
etc.
There is also no alignment!
Thanks!