cancel
Showing results for 
Search instead for 
Did you mean: 

How to export Alternate memory regions for USB DFU?

jhgorse
Associate III
Posted on July 28, 2017 at 07:56

Greetings,

I am rolling my own USBD DFU bootloader for an STM32F427. I have a CubeMX project reading and writing to Internal Flash. Now I need to expose the OTP memory region, similar to the System Memory USBD DFU bootloader.

I had to roll my own because the System Memory USBD DFU initializes GPIO to states that are unacceptable for me at startup.

When I change &sharpdefine 

USBD_DFU_MAX_ITF_NUM to 4, I get four entries in the PC-side DFU utility, but they are all named the same thing. I cannot seem to figure out how to add additional descriptions to the subsequent 'Alternate' memory regions.

Cheers,

Joe

#dfu #dfu-bootloader #usb-bootloader #usbdfubootloader #usb
3 REPLIES 3
STOne-32
ST Employee
Posted on July 28, 2017 at 16:46

Dear

Gorse.Joseph

‌,

You need to change and update your string descriptor as explained in the DFU Manual to export a new region , here OTP region or another external Memory. see our Examples in IAP mode provided inbox.

Cheers,

STOne-

Posted on August 11, 2017 at 09:04

THIS IS MY EXAMPLE:

/* DFU Class Config */

#define USBD_DFU_MAX_ITF_NUM                   2//1

#if (USBD_SUPPORT_USER_STRING == 1) 

#define FLASH_DESC_STR1      '@Internal Flash   /0x08000000/120*128 a,1416*128 g'

#define FLASH_DESC_STR2      '@Dollar Flash   /0x00000000/120*4096 a,512*4096 g'

static uint8_t* USBD_DFU_GetUsrStringDesc (USBD_HandleTypeDef *pdev, uint8_t index , uint16_t *length)

{

  static uint8_t USBD_StrDesc[255];

  /* Check if the requested string interface is supported */

  if (index <= (USBD_IDX_INTERFACE_STR + USBD_DFU_MAX_ITF_NUM))

  {

    //USBD_GetString ((uint8_t *)((USBD_DFU_MediaTypeDef *)pdev->pUserData)->pStrDesc, USBD_StrDesc, length);

    if(index==(USBD_IDX_INTERFACE_STR + 1))

   USBD_GetString ((uint8_t *)FLASH_DESC_STR1, USBD_StrDesc, length);

  else

   USBD_GetString ((uint8_t *)FLASH_DESC_STR2, USBD_StrDesc, length);

  

  return USBD_StrDesc; 

  }

  /* Not supported Interface Descriptor index */

  else

  {

    return NULL;

  }

}

#endif
Posted on August 14, 2017 at 16:33

Hi,

You can use our demonstrations examples  as a starting point and then you can customize with different Alternates.

By the way in your string descriptor,  do not forget to add the Units : Bytes, Kbytes, Mbytes etc. in this way :

 ''@Internal Flash   /0x08000000/120*128 a,1416*128 g''  MUST be

 ''@Internal Flash   /0x08000000/120*128Ba,1416*128Bg''  B to mean Bytes  and a '' Readable here is the definition in

http://www.st.com/content/ccc/resource/technical/document/user_manual/01/c6/32/df/79/ad/48/32/CD00158241.pdf/files/CD00158241.pdf/jcr:content/translations/en.CD00158241.pdf

.

Page 71/72

0690X00000607s9QAA.png

Cheers,

STOne-32.