-
Notifications
You must be signed in to change notification settings - Fork 997
machine/usb: set the vid and pid to valid values supplied by Adafruit and Arduino #884
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
|
Another thing I discovered that might be tripping up windows is that I think we are sending the string descriptors incorrectly. See here: https://github.com/tinygo-org/tinygo/blob/master/src/machine/machine_atsamd51.go#L1876-L1887 There are several problems:
|
|
Hi @syoder I think you are totally correct about errors in that descriptor. I was looking in to that lasts night a little, but did not get quite as far as identifying specifics as you did. I am going to try to correct a couple of those things today and see where that gets me. |
src/machine/board_feather-m0.go
Outdated
|
|
||
| // USB CDC identifiers | ||
| const ( | ||
| usb_STRING_PRODUCT = "Feather M0 Express" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be "Feather M0 Express" or just "Feather M0"? I'm not sure what the difference is but there are separate board definitions in the Arduino IDE for each and the board I have is just the M0 Feather not the express board.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They have the same vendor ID (VID) and product ID (PID), so the description does not need to match. In any case, the initial descriptor 0 does not seem to be getting sent correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@torntrousers FYI the difference between "express" and non-"express" boards is the addition of extra SPI flash (for circuitpython)
|
What is the state of this PR? Does it fix the problem on Windows? It looks good to me but I haven't tested it. |
|
We should merge in #883 first, and then I will rebase/cleanup this PR. Also I will try to correct the other errors in the sending of the descriptors. |
I fixed usb-cdc on windows 10. I'm not sure if this fix is correct. I have confirmed that when I connect pyportal / trinket-m0 on Windows 10, it is recognized as a USB serial device. However, I have only tested it on Windows 10, so I'm not sure it works on mac and linux. test code I think that URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR in the figure below was bad, but I don't know. |
|
Reduced call conditions for sendZlp(). |
2f1d7d4 to
40584c5
Compare
|
Made several updates to this branch to correct issues pointed out by @syoder and @sago35 although my fixes are slightly different. I addressed the byte ordering and corrected skipping the header bytes when creating the descriptor strings. I also removed the case that an extra zero length packet was being sent in error along with the valid descriptor string I did change the descriptor class being returned with the full descriptor, but I changed it to 0x02 as this is the correct base class for CDC https://www.usb.org/defined-class-codes#anchor_BaseClass02h I have tested these changes on both Linux and Windows 10, using a Circuit Playground Express, a ItsyBitsy-M4, and a Circuit Playground Bluefruit. All performed as expected using the example/serial program. The ATSAMD21 and ATSAMD51 boards also worked using the example/echo program. The Circuit Playground Bluefruit board did not work correctly with the example/echo program, in fact causing it to become unresponsive, however I think that issue is not related to this PR, and I will enter an issue to look into it separately. That said, I think this PR is now ready for merge. UPDATE: also tested all three boards on macOS and also worked. |
Is that a regression or was the problem already present? |
|
That problem is already present in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You sometimes prefix the device name with the manufacturer name (e.g. "Adafruit Circuit Playground Bluefruit") and sometimes you don't (e.g. "Circuit Playground Express"). Was that intentional?
That problem is already present in the
devbranch.
Ok, then it's fine.
| // USB CDC identifiers | ||
| const ( | ||
| usb_STRING_PRODUCT = "Nordic nRF52840DK (PCA10056)" | ||
| usb_STRING_MANUFACTURER = "Nordic Semiconductor" | ||
| ) | ||
|
|
||
| var ( | ||
| usb_VID uint16 = 0x239A | ||
| usb_PID uint16 = 0x8029 | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Is there a reason you're re-using the VID from Adafruit?
- It looks like the nrf52*-based boards do not use these
usb_STRING_PRODUCTetc constants yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
see https://github.com/adafruit/Adafruit_nRF52_Arduino/blob/master/boards.txt#L419
-
That is true, I will add another commit that uses the constant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the nrf52840 boards all do use the constants. See https://github.com/tinygo-org/tinygo/blob/feature/usb-cdc-ids/src/machine/usb_nrf52840.go#L432 and https://github.com/tinygo-org/tinygo/blob/feature/usb-cdc-ids/src/machine/usb_nrf52840.go#L440
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh okay, then it's fine.
… and Arduino for boards that support USB CDC Signed-off-by: Ron Evans <ron@hybridgroup.com>
… CDC device and string descriptors Signed-off-by: Ron Evans <ron@hybridgroup.com>
…boards Signed-off-by: Ron Evans <ron@hybridgroup.com>
…ptor for nrf52840 based boards Signed-off-by: Ron Evans <ron@hybridgroup.com>
aykevl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I'm only wondering about the inconsistency in product naming as mentioned previously?
|
Let me modify the product names that are inconsistent, then. |
…ptors consistent Signed-off-by: Ron Evans <ron@hybridgroup.com>
40584c5 to
24e68b1
Compare
|
OK, added another commit for name consistency. |
|
I tried feature/usb-cdc-ids in example/echo but it didn't work. |
|
Hello @sago35 you are correct that the echo example does not yet work on Windows. But it at least solves the original problem, which is to get the correct name, and the board driver+USB Serial port drivers to be installed. The problem whatever it might be with Windows and reading data off of the USB CDC from the device will have to be solved in another PR. This is at least progress. |


The PR sets the vid and pid to valid values supplied by Adafruit and Arduino for boards that support USB CDC.
It might be able to help Windows 10 users get their devices to auto-mount as USB CDC without special drivers. cc/ @torntrousers