Setting the USB CDC-ACM Serial Number at Runtime

If I have an application where I have implemented USB CDC-ACM, how can I set the serial number seen by the PC when I connect my device? Is it possible to set it at runtime?

Parents Reply Children
  • Sorry, but in the last few days, I haven't had the chance to try your suggestion. I just tried integrating your code into mine, but I'm getting an error

    error: 'sample_sn' undeclared (first use in this function)

    Additionally, I don't understand how to set the serial number at runtime using USBD_DESC_SERIAL_NUMBER_DEFINE, since the macro only defines the variable sample_sn, and I don't see where to insert the serial number string.

    I also tried setting the serial number using CONFIG_USB_DEVICE_SN, but I didn't get any results. It doesn't even set the manufacturer or the product.

    CONFIG_USB_DEVICE_STACK=y
    CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n
    CONFIG_USB_DEVICE_MANUFACTURER="Company"
    CONFIG_USB_DEVICE_PRODUCT="Product"
    CONFIG_USB_DEVICE_SN="S1234567890"
    CONFIG_USB_DEVICE_PID=0x0002
    CONFIG_USB_DEVICE_VID=0xAD5A

    Any suggestions?

  • Hello,

    Sorry, if you look at the projects using "USB stack next" you can find they are using CONFIG_USB_DEVICE_STACK_NEXT=y. So try that.

    Kenneth

Related