VID and PID Explanation - lycilph/SpaceMouse GitHub Wiki

This is an explanation from ChatGPT (so take it with a grain of salt)

In the boards.txt file used by the Arduino IDE (and Arduino cores), these fields control different aspects of how the board is recognized and used. Here's a breakdown of the difference between leonardo.vid.0, leonardo.upload_port.0.vid, and leonardo.build.vid:


๐Ÿ”น leonardo.vid.0

Purpose: Used to identify the board when connected via USB, for automatic port detection in the Arduino IDE.

Explanation: This is part of a pair: leonardo.vid.0 and leonardo.pid.0. Together, these define the Vendor ID (VID) and Product ID (PID) for the USB device so the Arduino IDE can recognize the board in the port list.

Example:

leonardo.vid.0=0x2341
leonardo.pid.0=0x8036

The IDE uses this to show the correct name in the Tools โ†’ Port menu, like โ€œArduino Leonardo (COM3)โ€.


๐Ÿ”น leonardo.upload_port.0.vid

Purpose: Used for upload-time port matching, especially for boards that switch to a different VID/PID when in bootloader mode.

Explanation: Some boards like the Leonardo change their USB identity briefly during the upload (when resetting to bootloader). This field helps the IDE wait for and select the correct port that appears during upload.

Example:

leonardo.upload_port.0.vid=0x2341
leonardo.upload_port.0.pid=0x0036

Here, the 0x0036 PID might be the bootloader PID, which is different from the normal runtime PID.


๐Ÿ”น leonardo.build.vid

Purpose: Used when building the firmware (compiled code) to set the USB VID in the binary.

Explanation: This value gets passed to the compiler and defines what VID is embedded into the USB descriptor of the final firmware.

Example:

leonardo.build.vid=0x2341
leonardo.build.pid=0x8036

This makes sure that when the board runs the firmware, it identifies itself with the correct USB VID/PID to the host system.


โœ… Summary

Field Used For Notes
leonardo.vid.0 IDE port detection during normal operation Works with pid.0
leonardo.upload_port.0.vid Upload-time bootloader port detection Matches bootloader VID/PID
leonardo.build.vid USB VID embedded in compiled firmware Affects how the board identifies over USB when running

Let me know if you'd like help customizing these fields for a custom board or clone!

Claude expands on this: Key Differences leonardo.vid.0 and leonardo.upload_port.0.vid are typically the same value and relate to board identification and upload port detection. leonardo.build.vid can be different and determines the VID your actual program will use when communicating over USB. This allows your sketch to present itself with a specific vendor identity when running. For most standard Arduino Leonardos, all three values are usually set to 0x2341 (Arduino's official USB Vendor ID), but they can differ in custom board definitions or when you want your application to present a different USB identity than the bootloader.