-
Notifications
You must be signed in to change notification settings - Fork 531
Accept WCH-Link as DAPv1 #1399
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
Accept WCH-Link as DAPv1 #1399
Conversation
|
Should I also include |
|
Hi @eugene-bright! Please take a look at commit a926e94 that adds support for another non-compliant CMSIS-DAP probe. (Man, I wish people would properly implement the spec… 😩) Those changes match solely against the VID/PID, so you won't need the accepted names change. (It also works on all supported OSes/backends.) The only change needed should be adding the WCH-Link VID/PID to You'll also need to rebase your changes onto the Finally, please add your copyright below the existing copyrights in the file(s) you edit. If you're quick, you can get it in before the 0.34 release coming late today or tomorrow! 😉 Thanks! |
|
Lol! 😄 Sorry, I'm behind on issues lately since I've been focusing on preparing for the upcoming release, so I hadn't seen the comments from @elfmimi. Imo, there's are arguments to be made both for matching by name and ID pair.
|
| # Now read the product name string. | ||
| device_string = dev.product | ||
| if (device_string is None) or ("CMSIS-DAP" not in device_string): | ||
| if (device_string is None) or not any(map(lambda s: s in device_string, ACCEPTED_DEVICE_NAMES)): |
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.
Quick Python note: any() is the right idea! However, you can simply the inner expression using a comprehension as any(s in device_string for s in ACCEPTED_DEVICE_NAMES). It's faster, too. 😄
|
At the minimum, please include the VID/PID in the list in It's up to you if you want to add a generalised device name matching mechanism like your initial commit for this PR. However, it will need to work with all USB backends for CMSIS-DAP (hidapi, pyusb, pyusb_v2, pywinusb). So if you decide to implement this, please move |
|
I think I need to leave a comment on that VID(0x2a86) , which my instinct tells me is not officially approved. |
|
@elfmimi Very good point. According to the official USB-IF vendor IDs list, VID 0x2a86 (decimal 10886) is registered to "KITRIS AG". Ummm… (Aside: Why is the world would the USB-IF list vendor IDs in decimal? Have you ever heard of someone reference a VID in decimal? Of course not. 🤣 ) |
|
Fwiw, Patrick Yang, the CTO of WCH, is on twitter. Someone might ask him publicly why the WCH USB VID is assigned to Kitris AG. 😜 |
|
There's more to this VID story! Apparently another version (?) of the WCH-Link has the VID 0x1A86. (See #1121) This value is correctly registered to Nanjing Qinheng Microelectronics Co., Ltd., aka WCH-IC. So either someone made a stupid typo in the code? Or something more nefarious is going on. 🤨 Is this 2a86 variant a clone of the real WCH-Link? |
|
Probably |
|
The |
|
It works for me |
flit
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.
Requested changes
Would you mind adding your copyright below existing in modified files?
Please move the version script to scripts/.
Next steps
👉🏽 Do you mind if I push some additional changes to your branch? (GitHub permissions allow project owners to push to PR source branches, but I always ask first.)
There are actually some further issues I've found in pyusb_backend.py and pyusb_v2_backend.py. The latter should be checking the device name in addition to interface name (either should be accepted). And the interface name checks for both should use your is_known_device_string() function.
Also, use of is_known_device_string() needs to be integrated into hidapi_backend.py and pywinusb_backend.py.
My plan is to go ahead and release v0.34 today while we finish this PR. Then I'll cherry pick the changes over to main and release v0.34.1.
|
I'm in Ukraine and have to go to sleep to not die from exhaustion. I'm not interested in having any copyrights (and recommend to follow Linux kernel |
|
'Night! Take care. |
|
I moved the script, but the rest is outside of the scope of this ticket. My adapter doesn't have |
|
Right, the pyusb v1 and v2 files are very similar and need to be refactored. |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Closes #1395