-
Notifications
You must be signed in to change notification settings - Fork 947
Implement common USB 2.0 package #1829
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
base: dev
Are you sure you want to change the base?
Conversation
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.
Some short drive-by comments, I haven't looked at this in any real depth.
96f2dca
to
e9ddbdf
Compare
I really need this for something. Specifically I need HID keyboard support. So suddenly this PR is oh so very interesting again. All kidding aside, @ardnew you have done a lot of work here. @sago35 I know you have done some testing with it. It is pretty complex code for sure. Perhaps just the exercise of trying to implement some of these interfaces on SAMD21 would help clarify a process for getting it implemented on other hardware platforms? For sure I want to help out, what are the next steps? |
Bear with me, this is a rather long one...@deadprogram getting some help is necessary at this point — specifically due to my personal time available to work on this. I'm currently finishing graduate school and have to dedicate my free time (outside my day job) to my master's thesis. So it probably won't be until 2022 before I can resume work on it. To answer your question plainly, the next steps would be (in no particular order):
Current statusThere has been a substantial amount of work on this package which is not shown in this branch. As you suggested, to exercise the API for another target, I've done just that and used it to add USB support for a completely different target (STM32). The only caveat is that it's an STM32 target not officially supported by TinyGo, the Arduino Portenta H7 (multi-core board support here). The following branch uses this package to implement USB support for two different TinyGo targets —
Since the USB hardware interfaces are so drastically different between these two targets, I feel this branch demonstrates the general requirements necessary to add support for any given target. I believe it also proves the package is versatile enough to support any TinyGo target. Next targetFor a new developer, I would recommend choosing nRF52 as the next target for adding support for a couple reasons. First, the baked-in firmware or hardware in that device does quite a few tasks for managing memory and USB protocol communication automatically (some of which are currently performed on-demand by this TinyGo USB package); e.g., More than any other target, there are perhaps more third-party and hobbyist implementations of a USB device library for the SAM D21/D51 families of MCUs. This variety would lend well to understanding different ways to integrate support for these targets with this USB package. Thus, these would also be very good choices for a new developer to use as their first target. Each of these choices — nRF52 and SAM D21/D51 — also benefit from the fact that TinyGo currently has a minimal, functioning USB CDC serial implementation. These implementations are very stripped down and are not well-suited to generalization, but they are good references for understanding any TinyGo-specific nuances, bus/clock control, and necessary peripheral register configurations. A source-level debug probe is highly recommended. |
910cc45
to
0a9c859
Compare
Hello @ardnew and @bgould I am trying to look into this myself just to try to catch up to where you both are at. @bgould seems like https://github.com/bgould/tinygo/tree/usb-common-keyboard-firmware contains your latest work. I see comments there referring to "STM32H7 USB implemenetation" but do not actually see that implementation in that branch, for example in this directory: https://github.com/bgould/tinygo/tree/usb-common-keyboard-firmware/src/machine/usb @ardnew I do see that you have done work on that board in the branch https://github.com/ardnew/tinygo/tree/feature/usb-common-arduino-portenta I see implementation in https://github.com/ardnew/tinygo/tree/feature/usb-common-arduino-portenta/src/machine/usb referring to stm32. Basically I am just trying to figure out "what are the specific interfaces that need to be implemented to get a simple USB CDC working?" Perhaps you both can help me out here? If I had a skeleton of what is needed to start with without all of the machine-specific implementation I would be able to get going more easily. I cannot really easily tell which parts are interface and which are implementation at the moment. I see there is a Same question for |
1 similar comment
Hello @ardnew and @bgould I am trying to look into this myself just to try to catch up to where you both are at. @bgould seems like https://github.com/bgould/tinygo/tree/usb-common-keyboard-firmware contains your latest work. I see comments there referring to "STM32H7 USB implemenetation" but do not actually see that implementation in that branch, for example in this directory: https://github.com/bgould/tinygo/tree/usb-common-keyboard-firmware/src/machine/usb @ardnew I do see that you have done work on that board in the branch https://github.com/ardnew/tinygo/tree/feature/usb-common-arduino-portenta I see implementation in https://github.com/ardnew/tinygo/tree/feature/usb-common-arduino-portenta/src/machine/usb referring to stm32. Basically I am just trying to figure out "what are the specific interfaces that need to be implemented to get a simple USB CDC working?" Perhaps you both can help me out here? If I had a skeleton of what is needed to start with without all of the machine-specific implementation I would be able to get going more easily. I cannot really easily tell which parts are interface and which are implementation at the moment. I see there is a Same question for |
Hi @deadprogram: Unfortunately I don't have a straightforward answer to that question because that interface hasn't been well-defined yet. The idea was that a well-defined interface would simply reveal itself after implementing this USB package for several different targets. However, so far, Teensy 4.0 is the only target that has fully implemented the package. As you mentioned, the Portenta H7 (STM32) target made quite a bit of headway with the CDC device class (HID has not been started). But another target you may not have reviewed is for SAMD51: This implementation is actually much more complete than the STM32 target. CDC is fully implemented, HID registration is working for me on Linux, but not on Windows. This is as far as I've had time to get. This branch should make the distinction between interface and implementation much clearer, as it supports two different targets: Note that Hope this gives you a better idea of status on this effort. |
@ardnew thank you very much for the update. That branch is a lot easier for me to follow thus far, although I have not gotten too much time to look at it. @bgould have you seen the branch at https://github.com/ardnew/tinygo/tree/feature/usb-common-samd51 ? |
Yes I looked at it, was going to see if I could use that to get RP2040 working. Things just freed up for me at work, and also finally got a hold of a couple RP2040 Feather boards to work on this. |
@ardnew @deadprogram @bgould
|
Now that #2889 has been merged into Hopefully this will help simplify the process of getting this capability merged in! |
This PR serves as working area and development notes/discussion for a common USB 2.0 API and package implementation reusable by various TinyGo targets.
A functioning model — including a Device Controller driver with CDC-ACM device class support — is provided for Teensy 4 (NXP iMXRT1062). This can be used to iterate and evaluate changes to the architecture.
This is more than enough work for a single PR. But I feel it's all necessary to develop a robust baseline API for future USB targets.