PORTS Forum
Ports and Interfaces => USB => Topic started by: jb on September 06, 2018, 02:34:26 pm
-
If bcdDevice is 0x0103
macOS System Report displays it as "Version: 1.03"
NirSoft USBDeview displays it as "1.03"
But I thought it was conceptually "1.0.3".
USB 3.2 spec says
The bcdUSB field contains a BCD version number. The value of the bcdUSB field is 0xJJMN for version JJ.M.N (JJ - major version number, M - minor version number, N - sub-minor version number), e.g., version 2.1.3 is represented with value 0213H and version 3.0 is represented with a value of 0300H.
and Beyond Logic (https://www.beyondlogic.org/usbnutshell/usb5.shtml) says
The value is in binary coded decimal with a format of 0xJJMN where JJ is the major version number, M is the minor version number and N is the sub minor version number.
The bcdDevice has the same format than the bcdUSB and is used to provide a device version number.
-
The spec is the final authority. 1.0.3 is correct.
-
Well the spec doesn't explicitly say "bcdDevice uses the same format as bcdUSB" that I can find. It just says "binary-coded decimal". Beyond Logic says they're the same format, but isn't official.
Also found XMOS document (https://www.xmos.com/published/usb-audio-software-design-guide) that says
BCD_DEVICE Description Device firmware version number in Binary Coded Decimal format: 0xJJMN where JJ: major, M: minor, N: sub-minor version number. ... Default: XMOS USB Audio Release version (e.g. 0x0651 for 6.5.1).
-
The LUFA project uses this:
https://github.com/abcminiuser/lufa/blob/master/LUFA/Drivers/USB/Core/StdDescriptors.h
/** Macro to encode a given major/minor/revision version number into Binary Coded Decimal format for descriptor
* fields requiring BCD encoding, such as the USB version number in the standard device descriptor.
*
* \note This value is automatically converted into Little Endian, suitable for direct use inside device
* descriptors on all architectures without endianness conversion macros.
*
* \param[in] Major Major version number to encode.
* \param[in] Minor Minor version number to encode.
* \param[in] Revision Revision version number to encode.
*/
#define VERSION_BCD(Major, Minor, Revision) \
CPU_TO_LE16( ((Major & 0xFF) << 8) | \
((Minor & 0x0F) << 4) | \
(Revision & 0x0F) )
-
Lacking any evidence to the contrary in the specs, I believe it is safe to assume that both "bcd" fields use the same format.