cancel
Showing results for 
Search instead for 
Did you mean: 

USBD_FS_InterfaceStrDescriptor() is never call with fw 1.10 (USB 2.10), what need to be done to make it work?

GerHebert
Associate II

USBD_FS_InterfaceStrDescriptor() is not called.

I fix it by changing iInterface by 5. To match this define:

#define USBD_IDX_INTERFACE_STR                        0x05U

  /* Data class interface descriptor */
  0x09,                                       /* bLength: Endpoint Descriptor size */
  USB_DESC_TYPE_INTERFACE,                    /* bDescriptorType: */
  0x01,                                       /* bInterfaceNumber: Number of Interface */
  0x00,                                       /* bAlternateSetting: Alternate setting */
  0x02,                                       /* bNumEndpoints: Two endpoints used */
  0x0A,                                       /* bInterfaceClass: CDC */
  0x00,                                       /* bInterfaceSubClass */
  0x00,                                       /* bInterfaceProtocol */
  0x05,                                       /* iInterface */

Since it is erase by generate, I guess I'm doing something wrong to do it correcly. What should I do?

8 REPLIES 8

Hello @GerHebert​ 

Be sure to write your code in the User Section so that it will not be deleted after the re-generation with CubeMX.

I hope this helps you.

BeST Regards,

Walid

GerHebert
Associate II

Hi,

And how I do that for this descriptor in particular? Since it is static, I can't access it. Over that, usbd_cdc.c do not have any User Section.

And I think it should be set to 5 by default when generating the code and the field INTERFACE_STRING is fill-in into the IOC. No?

Germain

Hello @GerHebert​ 

In order to allow a better analysis of your problem, could you please give us the .ioc file that you are used to reproduce this issue, so that we can give you an answer.

BeST Regards,

Walid

GerHebert
Associate II

Hi Walid,

Here is the IOC.

Since the, I saw the new version of USB device 2.40 state it support composite descriptor. I didn't figure out how to use it yet. I don't see any options in IOC to do so. So I'm looking for the recipe to use with IOC if it is possible.

I was wondering if it is possible to do multiple CDC with new composite feature?

Thanks,

Pavel A.
Evangelist III

Maybe the host is not interested in the interface name at all.

Have you seen requests to this string before? maybe on other host OS?

GerHebert
Associate II

Hi Pavel,

Yes I did, on linux and windows. I was using the GetUserStrDescriptor and patching the descriptor. But now, with the new release, it is supported but it isn't working. It is just missing a small fix to tell the description on which index the interface name is.

Germain

Hello @GerHebert​ 

The USB Device library v2.10.0 supports new class drivers and composite device.

Unfortunately, we haven't provided yet any examples for this new USB device class driver.

Otherwise, you can find a short description in the driver files which may help you.

BeST Regards,

Walid

Walid,

Sorry, yes 2.10.0. I will get it without example. But I have question of how to do it with user section.

Example:

void MX_USB_DEVICE_Init(void)
{
  /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */
    USBD_CDC.GetUsrStrDescriptor = USBD_CDC_InterfaceStrDescriptor;
  
  /* USER CODE END USB_DEVICE_Init_PreTreatment */
 
  /* Init Device Library, add supported class and start the library. */
  if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK)
  {
    Error_Handler();
  }
  if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK)
  {
    Error_Handler();
  }
  if (USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK)
  {
    Error_Handler();
  }
  if (USBD_Start(&hUsbDeviceFS) != USBD_OK)
  {
    Error_Handler();
  }
 
  /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */
  HAL_PWREx_EnableUSBVoltageDetector();
  
  /* USER CODE END USB_DEVICE_Init_PostTreatment */
}

I can change stuff before and after. But I think I must call USBD_RegisterClassComposite() instead of USBD_RegisterClass(). How do I do that?

Same for USBD_CDC_RegisterInterface(), I'm quite sure it must be set before USBD_Start().

Do you have any hint for me.

Thanks,