Skip to content
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

Planned USB device/host support rework/enhancements #42066

Open
25 of 57 tasks
jfischer-no opened this issue Jan 22, 2022 · 40 comments
Open
25 of 57 tasks

Planned USB device/host support rework/enhancements #42066

jfischer-no opened this issue Jan 22, 2022 · 40 comments
Assignees
Labels
area: USB Universal Serial Bus Meta A collection of features, enhancements or bugs

Comments

@jfischer-no
Copy link
Collaborator

jfischer-no commented Jan 22, 2022

This is a meta issue for maintainers and developers of relevant subsystems to track progress on new USB support.

Introduction

Currently we have only USB device support in Zephyr OS. Existing USB device support has many disadvantages and issues, like missing support for multiple driver instances, no endpoint (request) buffers management, missing class instances management and possibility to configure/enable class instance at runtime, not a good notification channel to the user/application, messy callback architecture, no API to set/reconfigure idVendor/iSerialNumber/bcdDevice at runtime, confusing usb_dc_ep_read()/usb_dc_ep_write() API, and more.

There is no USB host support in the project. It is asked again and again for it and there was effort like #30361, but that is far from suitable. USB device stack would also benefit from the host support and allow self-contained tests with emulated device and host controllers, and better support for USBIP.

Since many problems with the USB device support are due to the way it is designed (imported in Zephyr OS), we would like to redesign USB device support. That means USB device controller driver API and USB device stack will be rewritten in parallel and independent to existing implementation. Due to the need for testing/validation, USB host controller driver API and some parts of higher level will also be implemented.

Rough plan

Choice of support of the legacy stack

a) Remove the legacy stack entirely after 4.0.0 (hard switch)
b) Keep the stack, but remove tests and samples
c) Keep the stack, keep tests and some samples, but deprecated and not building in CI
d) Keep the stack, keep tests and some samples, but deprecated. Have a special build in CI that does not fail with deprecation

Agreement to go with d), with samples for the legacy stack placed under a legacy/ folder.

Timeline for transitioning to USB device "next" support

Main "switch":

menuconfig USB_DEVICE_STACK_NEXT

@jfischer-no jfischer-no added area: USB Universal Serial Bus RFC Request For Comments: want input from the community labels Jan 22, 2022
@jfischer-no jfischer-no self-assigned this Jan 22, 2022
@koffes
Copy link
Collaborator

koffes commented Jan 24, 2022

This is good news. I would like to link to this issue: #26857, and hopefully the high CPU load will be resolved here as well. FYI @alexsven
Also, any plans for async USB audio support?

@henrikbrixandersen henrikbrixandersen added the Meta A collection of features, enhancements or bugs label Jan 24, 2022
@qipengzha
Copy link
Contributor

For driver support, will you plan to enable Synopsys DWC USB2.0 OTG controller ? thx

@dleach02
Copy link
Member

dleach02 commented Mar 2, 2022

Do we need a separate tracking ticket for USB Host?

@jfischer-no
Copy link
Collaborator Author

Do we need a separate tracking ticket for USB Host?

No, not at this time. My plan is that host controller driver API immediately follows device controller API (+ device stack), details of host support come afterwards.

@dleach02
Copy link
Member

dleach02 commented Mar 9, 2022

@jfischer-no Is there any of this that can be parallelized if additional resources are made available?

Also, what forum are we to use to have some open discussions about the API changes and requirements?

@jfischer-no
Copy link
Collaborator Author

@jfischer-no Is there any of this that can be parallelized if additional resources are made available?

Not yet.

@jfischer-no
Copy link
Collaborator Author

Plan updated.

@lenghonglin
Copy link
Contributor

hello, i use usb audio these , and the usb audio leak some feature unit, like volume . It there have some plan to do this?

@fabiobaltieri
Copy link
Member

@jfischer-no do you think we should push this to the v3.3 milestone? (it's currently tagged for v3.2)

@troica65
Copy link

Hi, any estimate for when host support will be available ?

@hongshui3000
Copy link
Contributor

+1

@jfischer-no
Copy link
Collaborator Author

hello, i use usb audio these , and the usb audio leak some feature unit, like volume . It there have some plan to do this?

Yes, but it is not directly relevant to this topic.

Hi, any estimate for when host support will be available ?

ASAP!

@jfischer-no
Copy link
Collaborator Author

Virtual controller and host support has been separated from #38679 and moved to #50985. Updated the list of drivers and class implementations to be ported.

@raveslave
Copy link

@MaureenHelm any interest from NXP to support the mcux usb host (and device) drivers for LPC and i.MXRT in zephyr?

@koffes
Copy link
Collaborator

koffes commented Dec 6, 2022

Wrt. Audio. Could someone please enlighten me on the status/plans for async USB support? We need the SoC to poll the PC host for new Audio data.

@jfischer-no
Copy link
Collaborator Author

Wrt. Audio. Could someone please enlighten me on the status/plans for async USB support? We need the SoC to poll the PC host for new Audio data.

I commented to a similar question above. It would be nice if you open a well-described enhancement issue or discussion, but it does not belong here!

@MaureenHelm any interest from NXP to support the mcux usb host (and device) drivers for LPC and i.MXRT in zephyr?

It appeared to me in a dream that progress on NXP USB controller support is inversely proportional to how often you ask the same question in different topics.

@MaureenHelm
Copy link
Member

@MaureenHelm any interest from NXP to support the mcux usb host (and device) drivers for LPC and i.MXRT in zephyr?

I don't work at NXP anymore. Please contact @dleach02 for NXP-related questions.

@dleach02
Copy link
Member

dleach02 commented Apr 1, 2024

@jfischer-no,

Yes, there is interest from NXP and USB host support.
@jfischer-no, what is the right forum to discuss this? Is it here in this ticket?

@dleach02 Please not here, maybe discussions, but once you have started implementing a UHC driver, please add a note to the description or ask me for an update. However, the priority is and should be to get the new device support to a state where we can start calling the current stack legacy. This means there should be alternatives to all the class implementations we have for the current stack, and a few more drivers.

If I look at the list of items for moving over to the new UDC it looks like mostly porting vendor's USB drivers. I think it makes sense to work in parallel on the host layer instead of serializing this effort. If we are blocked by other vendors conversions we may never get to the host work.

We have needs for host support and the resources available to assist in this effort. Just need some guidance on how you want this done.

@josuah
Copy link
Collaborator

josuah commented May 7, 2024

I got started with UVC.

For now a continuation of the Video driver interface. #72311

The recent UAC2 seems like a good reference for how to implement it. #70029

@ddavidebor
Copy link

is the USB-ip supposed to work with native_sim and the device_next stack?

@nashif nashif moved this from v3.5 to Future in Release Plan Jun 11, 2024
@henrikbrixandersen
Copy link
Member

is the USB-ip supposed to work with native_sim and the device_next stack?

Please see #74141

@tannewt
Copy link

tannewt commented Jun 25, 2024

Why not use TinyUSB instead of making a new stack? It has device and host support already. It has an OS abstraction layer as well. License is MIT.

Both Espressif and Raspberry Pi use it in their SDKs already.

@josuah
Copy link
Collaborator

josuah commented Jul 3, 2024

Why not use TinyUSB instead of making a new stack? It has device and host support already. It has an OS abstraction layer as well. License is MIT.

Wonderful work from Ha Thach! Very simple callback-based API that is convenient to debug... Just follow the calls.
Many classes implemented as well. UVC contributed by someone working at Toshiba even!

I am not from Nordic and do not know the original rationale for a from-scratch implementation for Zephyr, but here are some clues that I am trying to guess:

  • allow to have a Zephyr driver API without too much abstraction in-between
  • leverage existing Zephyr code snippets (i.e. net_buf, events, work queues, threads...)
  • leverage existing Zephyr subsystems (i.e. CDC_NCM implementation is mostly glue)
  • at this stage, the existing amount of effort already put into it

Just my wild guesses!

Related

@josuah
Copy link
Collaborator

josuah commented Aug 3, 2024

Some progress on UVC: #63421 (comment)

@mmahadevan108
Copy link
Collaborator

@jfischer-no , we have moved this to be in the 4.0 Release Plan for the conversion of the USB Device.
Do you want to create a separate issue for the remaining tasks related to USB Host?

@mmahadevan108
Copy link
Collaborator

@jfischer-no, can you please share some insight on what the plans are for the remaining tasks related to USB Host. Should we create a separate RFC for this so we can track it for future Zephyr releases.

@jfischer-no
Copy link
Collaborator Author

@jfischer-no, can you please share some insight on what the plans are for the remaining tasks related to USB Host. Should we create a separate RFC for this so we can track it for future Zephyr releases.

No.

As mentioned the beginning:
"This is a meta issue for maintainers and developers of relevant subsystems to track progress on new USB support."
This is not a release specific issue. There are parts of device support that depend on parts in host support. Please keep this topic free of irrelevant discussions, (also free of irrelevant concerns and wishes).

@mmahadevan108
Copy link
Collaborator

@jfischer-no, we have moved this meta issue to be fixed in 4.0. How should we track the items that are not addressed in 4.0 release?

@dkalowsk dkalowsk moved this from 4.0 to Future in Release Plan Sep 24, 2024
carlescufi added a commit to carlescufi/zephyr that referenced this issue Oct 16, 2024
The device_next stack now supports almost all classes that were covered
by the legacy stack, and many controllers have been ported already.

See zephyrproject-rtos#42066 for more info.

Signed-off-by: Carles Cufi <[email protected]>
@jfischer-no jfischer-no removed the RFC Request For Comments: want input from the community label Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: USB Universal Serial Bus Meta A collection of features, enhancements or bugs
Projects
Status: In Progress
Status: Future
Development

No branches or pull requests