Skip to content

[contradiction/bug] Flash area access (const). STM32. USB RNDIS. ST USB Device Lib #14

@bullitmaster

Description

@bullitmaster

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:

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions