This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to change the usb serial number

Hi

I have a unique serial number saved in EEPROM for each PCB, I want to assign that serial number string to the USB descriptor, so on windows, I can see that serial number. How can I do this? I see the USB descriptor serial number is defined as macro, can't be changed in run-time.

Thanks
Wang

Parents
  • An interesting thing here is this part:

    __weak \   <==== weak linkage, so another file can contain a symbol of same name to replace this.
    const struct {
      struct {
        U8  len;
        U8  type;
        U16 langid;
      } desc_langid;
    

    So in case this file contains lots of other things that a user do not want to change, then another source file should be able to redeclare USBD_StringDescriptor.

Reply
  • An interesting thing here is this part:

    __weak \   <==== weak linkage, so another file can contain a symbol of same name to replace this.
    const struct {
      struct {
        U8  len;
        U8  type;
        U16 langid;
      } desc_langid;
    

    So in case this file contains lots of other things that a user do not want to change, then another source file should be able to redeclare USBD_StringDescriptor.

Children
  • Aha, I know how how "__week" works.
    But in this case, USBD_StringDescriptor definition uses bunch of #define macros and conditional compilation, which are defined in usb_lib.c and usb_config.c. To extract USBD_StringDescriptor definition, we have to make these macros referable. It's so troublesome. In this reason, above method is easier and safer, just to delete "const" modifier.

    Tsuneo