Skip to content

Commit

Permalink
Merge #1902
Browse files Browse the repository at this point in the history
1902: USB: Add CDC support, update capsule stack r=ppannuto a=bradjc

### Pull Request Overview

This pull request is part of #1048, #1893.

This adds CDC support which implements `kernel::hil::Uart`. This allows us to run console over USB without having to write our own host-side kernel drivers.

On that path, this also updates the capsules USB stack to allow for the larger descriptors we use with the CDC device. This is also the first time we have needed multiple interface descriptors, so it adds support for that as well.

The bug fixes needed along the way are in separate PRs.


### Testing Strategy

This pull request was tested by running apps that use the console on imix, and setting up the console to use UART over CDC rather than the UART driver.


### TODO or Help Wanted

This does not work on the nRF52 (at least on my computer) because that driver does not support CTRL WRITE messages. FYI.

I had to add a platform-specific variable, since the nRF only works if the device descriptor says the packet size is 64, and the SAM4L driver only works if the device descriptor says the packet size is 8. This also makes the USB stack work on the SAM4L again.


### Documentation Updated

- [x] Updated the relevant files in `/docs`, or no updates are required.

### Formatting

- [x] Ran `make format`.
- [x] Fixed errors surfaced by `make clippy`.


Co-authored-by: Brad Campbell <bradjc5@gmail.com>
Co-authored-by: Branden Ghena <brghena@berkeley.edu>
Co-authored-by: Hudson Ayers <hayers@stanford.edu>
  • Loading branch information
4 people committed Jun 15, 2020
2 parents 5935e2e + 7d2c901 commit 126d711
Show file tree
Hide file tree
Showing 7 changed files with 907 additions and 185 deletions.
5 changes: 4 additions & 1 deletion boards/imix/src/imix_components/usb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ impl Component for UsbComponent {
// Configure the USB controller
let usb_client = static_init!(
capsules::usb::usbc_client::Client<'static, sam4l::usbc::Usbc<'static>>,
capsules::usb::usbc_client::Client::new(&sam4l::usbc::USBC)
capsules::usb::usbc_client::Client::new(
&sam4l::usbc::USBC,
capsules::usb::usbc_client::MAX_CTRL_PACKET_SIZE_SAM4L
)
);
sam4l::usbc::USBC.set_client(usb_client);

Expand Down
5 changes: 4 additions & 1 deletion boards/opentitan/src/usb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ impl Component for UsbComponent {
// Configure the USB controller
let usb_client = static_init!(
capsules::usb::usbc_client::Client<'static, lowrisc::usbdev::Usb<'static>>,
capsules::usb::usbc_client::Client::new(&ibex::usbdev::USB)
capsules::usb::usbc_client::Client::new(
&ibex::usbdev::USB,
capsules::usb::usbc_client::MAX_CTRL_PACKET_SIZE_IBEX
)
);

// Configure the USB userspace driver
Expand Down

0 comments on commit 126d711

Please sign in to comment.