USB VID and PID / Name / Manufacturer issues

I'm running into a strange issue related to USB VID / PID.

I'm developing a product based on Arduino that is designed to work as a USB device. I was previously using a hacked core to allow for USB MIDI on the 32U4 / Leonardo platform but I've been experimenting with the ATSAMD21 / Zero boards for a couple of days. The new pluggable USB stuff is nice, it allows me to use my boards with the standard IDE and core and everything seems to work.

I've changed the USBCore.h to include my VID as follows:

#if USB_VID == 0x2341
#  if defined(USB_MANUFACTURER)
#    undef USB_MANUFACTURER
#  endif
#  define USB_MANUFACTURER "Arduino LLC"

# elif USB_VID == MY_VID
#	if defined(USB_MANUFACTURER)
#		undef USB_MANUFACTURER
#	endif
#	define USB_MANUFACTURER "MFG_NAME"
#elif !defined(USB_MANUFACTURER)
// Fall through to unknown if no manufacturer name was provided in a macro
#  define USB_MANUFACTURER "Unknown"
#endif

Where MY_VID is replaced with my USB VID, and MFG_NAME is replaced with the company name.

I've also edited boards.txt to add a device based on the Leonardo platform but with my VID and PID as follows:

myboard.build.mcu=atmega32u4
myboard.build.f_cpu=16000000L
myboard.build.vid=MY_VID
myboard.build.pid=MY_PID
myboard.build.usb_product="MFG_NAME"
myboard.build.board=AVR_LEONARDO
myboard.build.core=arduino
myboard.build.variant=leonardo
myboard.build.extra_flags={build.usb_flags}

The remainder of the board definition is identical to the standard Leonardo, including fuses, lock bits, protocol, etc.

If I compile and upload this to a 32U4, the device is enumerated correctly, the VID and PID are changed to my chosen values, and the manufacturer name is displayed. Everything works just fine.

Moving on to the Zero, I can change the VID and PID by tweaking USBCore.cpp in the samd folder (inside Arduino15) but the manufacturer name does not update. Additionally, even if I program the board as an Arduino Zero with USB MIDI selected the device name is still blank.

Here's the excerpt from boards.txt for the SAMD hardware:

# My G3 (Native USB Port)
# ---------------------------------------
my_g3.name=My G3 (Native USB Port)
my_g3.vid.0=0x16d0
my_g3.pid.0=0x08b0

my_g3.upload.tool=bossac
my_g3.upload.protocol=sam-ba
my_g3.upload.maximum_size=262144
my_g3.upload.use_1200bps_touch=true
my_g3.upload.wait_for_upload_port=true
my_g3.upload.native_usb=true
my_g3.build.mcu=cortex-m0plus
my_g3.build.f_cpu=48000000L
my_g3.build.usb_product="My G3"
my_g3.build.usb_manufacturer="My Company"
my_g3.build.board=SAMD_ZERO
my_g3.build.core=arduino
my_g3.build.extra_flags=-D__SAMD21G18A__ {build.usb_flags}
my_g3.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
my_g3.build.openocdscript=openocd_scripts/arduino_zero.cfg
my_g3.build.variant=arduino_zero
my_g3.build.variant_system_lib=
my_g3.build.vid=MY_VID
my_g3.build.pid=MY_PID
my_g3.bootloader.tool=openocd
my_g3.bootloader.file=zero/samd21_sam_ba.bin

Am I missing something here? The VID and PID are being changed, but the SAMD core doesn't appear to populate the build.usb_product or build.usb_manufacturer correctly. The AVR core is working fine, though.

you use the native USB and you got a "original" Zero (from arduino.cc) ?
which OS (on the Host PC) do you use ?

The board I'm using for testing is an M0 Pro with the Zero bootloader flashed. The end product will not be an Arduino at all but a standalone board with an ATSAMD21G18A, just like I have been making a standalone board with an ATMEGA32U4 for a couple of years now.

I'm not an expert on USB but I can offer some data for you:

The Arduino.cc ZERO comes out-of-the-box with the following:
EDBG PORT VID=03EB, PID=2157
Native port VID=03EB, PID=6121

The Arduino.org ZERO PRO came out-of--the box with:
EDBG PORT VID=03EB, PID=2111
Native port VID=2A03, PID=804D

Other point of reference is that the Atmel SAMD21XPlained board comes with:
EDBG PORT VID=03EB, PID=2111

And the USB organization thinks that VID 03EB is Atmel.

I don't know what the .org M0 PRO and M0 use, you could report this and help solve a puzzle.

I don't know how to change the VID and PID, and whether flashing drivers changes this. Please if you know how let me know, as the Arduino.org board conflicts with the Atmel reference board on my Windows computer.

Changing the VID and PID aren't the issue - it's not that hard to change the VID and PID of the user application / sketch. Edit the VID and PID in boards.txt and in USBCore.cpp. Flashing the M0 Pro with the Zero bootloader, then uploading a sketch will set the VID and PID to the Zero standards. Honestly they're pretty much the same in terms of hardware.

No, my issue is that the IDE doesn't change the USB manufacturer and device name on the Zero in the same way as it does on the Leonardo.

As to changing the VID and PID of the EBDG, that's hard-coded in the debugger. You might be able to change it using a JTAG cable and the Atmel ICE but that's a bit beyond what I want to accomplish.

This has been fixed with the 1.6.5 core. Adding USB descriptors via the boards.txt file now works as expected.

Pharaohamps,

did you finally make the standalone product with this uC?

did you include the embedded debugger?

It seems the 4-layer pcb it results of having both chips could be somewhat expensive if the final product is U$D 50.-, since the uC is not much more expensive than the atmega328

I want to make a standalone (but IDE compatible) board as well, but a 4 layer pcb is not within my capabilities, and I am wondering if the compatibility would be compromised if I exclude the Embedded debugger

sanotronics:
Pharaohamps,

did you finally make the standalone product with this uC?

did you include the embedded debugger?

It seems the 4-layer pcb it results of having both chips could be somewhat expensive if the final product is U$D 50.-, since the uC is not much more expensive than the atmega328

I want to make a standalone (but IDE compatible) board as well, but a 4 layer pcb is not within my capabilities, and I am wondering if the compatibility would be compromised if I exclude the Embedded debugger

Yes, I did. I did not include the debugger, as I implemented a bootloader that acts as a USB Mass Storage Class device. It breaks compatibility with the IDE but that's not a concern for me. SparkFun and others have made Zero clones and derivatives that do not include the EDBG but rather use the Native USB port for firmware upload. I did most of my development using the SAM-BA / CDC bootloader, and then switched to the USB MSC for deployment.

USB MSC is very easy for my customers to update in the field, since I can just export a .BIN file and they can update in 5-7 seconds without needing to have the IDE, my libraries, board files, etc.

Can you share the code for the mass storage bootloader? I think it would be a great feature that a lot of people would like to use.

@Massimo
Here is the MSD bootloader from Justin M. :slight_smile:
I don't know if pharaohamps has another one.
Atmel also provide an application note for an MSC Bootloader, which could also be used for field programming.

Atmel have an MSC bootloader that works as a host, you connect a USB flash drive to the native USB port. That's one way to do it, but my application uses a modified version of Justin Mattair's bootloader and requires connection to a computer. The only changes for my application are the addition of my USB VID and PID, and changing some of the text strings to display my product name and information. Justin helped me out by customizing the bootloader but the Arduino Zero version works fine and may be used without changes.

Pharaohamps, congrats on the achievement!

Is the final schematic exactly like this https://www.arduino.cc/en/uploads/Main/ArduinoZero-schematic.pdf, but without page 3?

Would you be willing to sharing yours?

I am quite new at Arduino, but understand the programming in general. Recently came across a problem on changing VID/PID on Pro Mini.

So, the task is as following:
The board has VID/PID 2341/8037 and I need C1ED/2312 to make my stupid "smart TV" believe it is a keyboard after all.

I have modified the boards.txt file as you stated above:

micro.build.mcu=atmega32u4
micro.build.f_cpu=16000000L
micro.build.vid=0xc1ed
micro.build.pid=0x2312
micro.build.usb_product="Keyboard"
micro.build.board=AVR_MICRO
micro.build.core=arduino
micro.build.variant=micro
micro.build.extra_flags={build.usb_flags}

-- compiled and uploaded a sketch.
The board still shown as 2341/8037, nothing changed.
Obviously I am missing some step, which the correspondents above consider trivial. A web search produced no useful links.

Could anybody enlighten the newbie?