cancel
Showing results for 
Search instead for 
Did you mean: 

USBDEVICE core : pbuf[1] instruction occur an hard fault !

thln47
Associate III
Posted on November 30, 2015 at 10:22

in file : STM32Cube_FW_F3_V1.3.0\Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ctlreq.c

Lines : 340, 345, 403:

 

case

USB_DESC_TYPE_CONFIGURATION:    

   

if

(pdev->

dev_speed

==

USBD_SPEED_HIGH

)  

    {

      pbuf   = (uint8_t *)pdev->

pClass

->

GetHSConfigDescriptor

(&len);

      pbuf[1] = USB_DESC_TYPE_CONFIGURATION;

    }

   

else

    {

      pbuf   = (uint8_t *)pdev->

pClass

->

GetFSConfigDescriptor

(&len);

      pbuf[1] = USB_DESC_TYPE_CONFIGURATION;

    }

   

break

;

…

   

if

(pdev->

dev_speed

==

USBD_SPEED_HIGH

  )  

    {

      pbuf   = (uint8_t *)pdev->

pClass

->

GetOtherSpeedConfigDescriptor

(&len);

      pbuf[1] = USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION;

     

break

;

    }

When, I define my descriptor directly in FLASH memory with const statement, an hard fault occurs because the instruction below attempts to write on a read only memory.

       pbuf[1] = something_is_not_recommanded_here;

Why ST does this? The USB descriptors have been already set with right values.

0 REPLIES 0