-
Notifications
You must be signed in to change notification settings - Fork 1k
USB-related improvements #887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
7db8b4f
to
34daed6
Compare
I improved things based on the comments, and rebased on top of master. |
34daed6
to
a0badeb
Compare
Previously, there were a few problems: - USB manufacturer string was only configurable when an unknown VID was used. - USB product string would always include CDC/HID and HS/FS indication, it was not possible to specify the full string. - USB PID was always hardcoded, depending on the CDC/HID mode. These hardcoded PIDs are really only valid within the ST PID, so it made now sense that the vid *could* be specified. This commit cleans this up: - Boards must now either specify both the VID and PID, or neither. - When boards specify no VID and PID, they use the ST VID with a pid based on the CDC or HID mode like before. - All boards used to specify the ST vid explicitly in boards.txt, now they do not and rely on the default in the code. - When no USB_MANUFACTURER_STRING is defined (can be in boards.txt or variant.h now), a default is selected based on the VID, or "Unknown" is used if the VID is unknown. - When no USB_PRODUCT_STRING is defined (can be in boards.txt or variant.h now), a default is based on the BOARD_NAME, CDC/HID and FS/HS mode. All included boards should work as before. Third-party board definitions that use this core should be updated: - If build.vid is 0x0483, it should be removed. Otherwise, both vid and pid should be specified. - If build.usb_manufacturer is specified, it should be replaced by adding '-DUSB_MANUFACTURER_STRING="My Company"' to build.extra-flags.
This value should probably be configurable by the sketch, so a meaningful value can be picked. As long is this is not possible, best to use 0, rather than 2.0, otherwise it later becomes impossible to use 2.0 in a meaningful way (you'll never know if the device is really 2.0, or an old version that had no meaningful version number).
a0badeb
to
0e24dcb
Compare
I've pushed another update, which rebases on top of master, fixes the comments above, fixes one typo and replaces an I've done a bit more thorough testing this time, define no pid/vid, or just one, no mfg/product string, or just one, and confirming they show up in a device as expected. I also tested with your fpistm@0df5657 commit to confirm that the interface and configuration strings are also created properly. I have not been able to test the included board definitions (since I have no STM32 dev boards with native USB), but I tested with our own board definition, making the needed changes there. |
The main goal of this PR is to make configuration of USB details (VID, PID, manufacturer and product strings) more flexible, allowing (third-party) board.txt files more control over how a board identifies on the USB side.
A related minor change is to set the device version number to 0, since this is a value that should really be configured by the sketch (and until then, should not have a meaningful value).
See the commit messages for details.