Skip to main content
Visitor II
May 2, 2024
Solved

Unique VID/PID for multiple VCP interfaces on STM32U5A5 using USBX

  • May 2, 2024
  • 2 replies
  • 1788 views

Hi all
I would like to create 2 virtual COM ports (VCPs) using the CDC class in USBX. The .ioc only allows for one unique PID and VID, but it appears that multiple interfaces can be created of the same class.

I want to know if it is possible to create two interfaces with the CDC class, using the USBX peripheral, and to assign a unique PID/VID to each one, instead of the same PID/VID, but different interface numbers. It appears impossible using the .ioc file alone, but can it be done somewhere in code?

The end result I am hoping for is to have something like this:

VCP_NR_ONE (COM1) with hardware ids: VID → 0x1234 PID →0x4567
VCP_NR_TWO (COM2) with hardware ids: VID → 0x1234 PID → 0x7890

while still using only the USB_OTG_HS peripheral on the STM32U5A5

Thanks☺

    This topic has been closed for replies.
    Best answer by Mohamed_AYED

    @HH_42 , i don't think that is allowed by the spec of USB 

     

    the PID and VID is defined in standard Device Descriptor

    Mohamed_AYED_0-1714675372176.png

    and the spec say that  "A USB device has only one device descriptor."

    Mohamed_AYED_1-1714675430403.png

    So your a device can not have to PID. 

    you can verifie the spec here: https://www.usb.org/document-library/usb-20-specification  (9.6.1 Device)

    2 replies

    Explorer
    May 2, 2024

    HI @HH_42,

    Yess USBX support composite device cdc_acm/cdc_acm, but cubemx does not support interface of the same class. 

     

    You need to ensure that you descriptor support 2 interface of CDC ACM and register class in usbx init phase, and dont forget endpoint fifo config. 

     

     /* Set the parameters for callback when insertion/extraction of a CDC device. */
     parameter1.ux_slave_class_cdc_acm_instance_activate = demo_cdc_instance1_activate;
     parameter1.ux_slave_class_cdc_acm_instance_deactivate = demo_cdc_instance1_deactivate;
    
     /* Initialize the device CDC class. This class owns both interfaces starting with 0. */
     status = ux_device_stack_class_register((UCHAR *)"ACM1",
     ux_device_class_cdc_acm_entry, 1, 0,
     &parameter1);
    
     /* Set the parameters for callback when insertion/extraction of a CDC device. */
     parameter2.ux_slave_class_cdc_acm_instance_activate = demo_cdc_instance2_activate;
     parameter2.ux_slave_class_cdc_acm_instance_deactivate = demo_cdc_instance2_deactivate;
    
     /* Initialize the device CDC class. This class owns both interfaces starting with 2. */
     status = ux_device_stack_class_register((UCHAR *)"ACM2",
     ux_device_class_cdc_acm_entry, 1, 2,
     &parameter2);

     

    HH_42Author
    Visitor II
    May 2, 2024

    Thanks @Mohamed_AYED , I appreciate the answer

    This does make sense to me that it will create 2 instances of COM ports, however, it does not answer my question regarding the PID/VID. I believe that part is put together in the USB FrameworkBuilder, but what I want to know, is can I have more than one PID in this system? Meaning I can end up with:

    VCP_NR_ONE (COM1) with hardware ids: VID → 0x1234 PID →0x4567
    VCP_NR_TWO (COM2) with hardware ids: VID → 0x1234 PID → 0x7890

    I am comfortable with diving into code to see if it works, but I do not yet have a development board with this MCU. I just want to know if multiple PID/VID's are possible with one physical USB interface

    Thanks again for the reply, it already helps☺

     

    Explorer
    May 2, 2024

    @HH_42 , i don't think that is allowed by the spec of USB 

     

    the PID and VID is defined in standard Device Descriptor

    Mohamed_AYED_0-1714675372176.png

    and the spec say that  "A USB device has only one device descriptor."

    Mohamed_AYED_1-1714675430403.png

    So your a device can not have to PID. 

    you can verifie the spec here: https://www.usb.org/document-library/usb-20-specification  (9.6.1 Device)