Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Usb: Vendor_id, manufacturer_name

  1. #1
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    8,605

    Usb: Vendor_id, manufacturer_name

    @Paul, can we talk about user-setable USB IDs?

    At least for non-Arduino IDEs it is possible to set defines, so it would be possible to use something like that:

    Code:
    #if !defined(VENDOR_ID) && !defined(MANUFACTURER_NAME) && !defined(MANUFACTURER_NAME_LEN)
      #define VENDOR_ID          0x16C0
      #define MANUFACTURER_NAME    {'T','e','e','n','s','y','d','u','i','n','o'}
      #define MANUFACTURER_NAME_LEN 11
    #endif


    in usb_desc.h, at the beginning of the file and remove all later #defines.

    It would (at least) make development much easier when using multiple Teensys on one computer. I use one as a USB sound card, and it is irritating when Teensyduino tries to program the board (best would be "invisible" to TD unless I press the button - Usually, I don't want to program it).
    I don't think I'm the only user who experiences this issue.
    The above change has the intended nice side effect of allowing users to easily set their own IDs without having to patch TD every time.

    It could be extended with PRODUCT_NAME

    Edit:
    Example: With Platformio you could just add it to the project (platformio) ini:
    Code:
    build_flags = 
        -D USB_MIDI_AUDIO_SERIAL
        -D VENDOR_ID=0xffff
        -D MANUFACTURER_NAME="{'F','r','a','n','k','y','d','u','i','n','o'}"
    
        -D MANUFACTURER_NAME_LEN=11
    
    
    The MANUFACTURER_NAME_LEN is not needed.
    It can be caluclated during compile-time (optional addition to usb_desc.h) :
    Code:
    #if !defined(VENDOR_ID) && !defined(MANUFACTURER_NAME)
      #define VENDOR_ID        0x16C0
      #define MANUFACTURER_NAME    {'T','e','e','n','s','y','d','u','i','n','o'}  
    #endif
    
    #define MANUFACTURER_NAME_LEN sizeof((char[])MANUFACTURER_NAME)
    Same for PRODUCT_NAME_LEN.
    Last edited by Frank B; 07-07-2021 at 08:53 AM.

  2. #2

  3. #3
    Senior Member vjmuzik's Avatar
    Join Date
    Apr 2017
    Posts
    752
    This made me curious about a better way to handle this from the user sketch, as far as the Manufacturer Name, Product Name, and Serial Number goes these can already be changed from the user sketch with the use of the usb_names.h file. That is mostly used for usbMIDI devices, but it does work for any device even if the USB Type doesn't have usbMIDI.

    For the VID and the PID these can surprisingly be changed from the user sketch since the device descriptor isn't constant, here's the code I've tested on a Teensy 4.0:
    Code:
    #define LSB(n) ((n) & 255)
    #define MSB(n) (((n) >> 8) & 255)
    #ifdef __cplusplus
    extern "C" {
    #endif
    void startup_early_hook(){
      typedef struct {
      uint16_t  wValue;
      uint16_t  wIndex;
      const uint8_t *addr;
      uint16_t  length;
    } usb_descriptor_list_t;
    extern const usb_descriptor_list_t usb_descriptor_list[];
      uint8_t* device_descriptor = (uint8_t*)usb_descriptor_list[0].addr;
    
    //  8-9 VID
    //    device_descriptor[8] = LSB(VENDOR_ID);
    //    device_descriptor[9] = MSB(VENDOR_ID);
    //  10-11 PID
        device_descriptor[10] = LSB(0x3000);
        device_descriptor[11] = MSB(0x3000);
    }
    #ifdef __cplusplus
    }
    #endif
    It compiles for Teensy 3.x so I suspect it should work on those models as well.

  4. #4
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    8,605
    Thanks!

    Seems that i completely missed that!


    (btw, have you tried to contact Butok?)

  5. #5
    Senior Member
    Join Date
    Aug 2019
    Location
    Melbourne Australia
    Posts
    225
    Played around with usb_desc.h and boards.txt to create MIDIx2 and MIDIx8 using PJRC's VID and PID.

    Later, added a MIDI, x2, x4, x8 and x16 using some other VID and PID. Ended up seriously breaking Win7.

    Assigning a unique BCD_DEVICE to each new entry got things working without breaking any more Windows.

    Just mentioning as a potential headscratch alert.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •