Skip to content

Conversation

@santhosh-c-c
Copy link

@santhosh-c-c santhosh-c-c commented Nov 7, 2025

Dependency:

Upstream Reference:

This implementation contains all commits from #94590 & #99334 plus the following enhancements:

  • Adds support for USB CDC ECM (Ethernet Control Model) class to the USB host subsystem.

  • Enables Ethernet functionality for USB hosts.

WIP: Currently, this is a draft PR and further changes are planned.

Signed-off-by: Santhosh Charles [email protected]

Josuah Demangeon and others added 5 commits November 7, 2025 20:48
Add a "struct usbh_status" that contains a bitmask of flags to keep
track of the global state of the host context, like done for the
device_next implementation.

Signed-off-by: Josuah Demangeon <[email protected]>
Add a "struct usbh_class_api" for the host implementation, and move all
the function poitners to it. Add more fields to "struct usbh_class_data".

Signed-off-by: Josuah Demangeon <[email protected]>
Add API wrappers around the function pointers in struct usbh_class_api,
while also documenting the USB host class internal API.

Signed-off-by: Josuah Demangeon <[email protected]>
Add functions to probe/remove all classes as part of a new usbh_class.c
and a matching usbh_class.h. These functions are called from the function
usbh_init_device_intl() in usbh_core.c to initialize every class upon
connection of a device. Every class driver provide filters to match the
interfaces of the device.

Co-authored-by: Aiden Hu <[email protected]>
Signed-off-by: Josuah Demangeon <[email protected]>
Allocate extra room at the end of the USB descriptor buffer to ensure
that the device ends with `desc->bLength == 0`. For now, validating
`desc->bLength` from the device to ensure no access past the buffer
is still not done.

Signed-off-by: Josuah Demangeon <[email protected]>
@santhosh-c-c santhosh-c-c changed the title upstream/usbh ecm support Add USB Host CDC ECM Class Support for Ethernet Nov 11, 2025
@santhosh-c-c santhosh-c-c changed the title Add USB Host CDC ECM Class Support for Ethernet subsys: usb: host: Add USB Host CDC ECM Class Support for Ethernet Nov 11, 2025
@santhosh-c-c santhosh-c-c force-pushed the upstream/usbh-ecm-support branch 2 times, most recently from d9f8e29 to 3529d64 Compare November 13, 2025 19:58
@josuah
Copy link
Contributor

josuah commented Nov 15, 2025

Thank you for this implementation!
I took note of the bugfixes you noticed and am importing them in the API2 PR you are based upon.

@josuah
Copy link
Contributor

josuah commented Nov 16, 2025

@MarkWangChinese is this related to your ongoing effort for implementing ECM?

This commit invokes usbh_class_remove_all() in the device removal
handler to clean up USB classes when a device is disconnected.

Signed-off-by: Santhosh Charles <[email protected]>
This patch adds NULL checks in usbh_desc_get_next_function()
to prevent invalid dereferencing. Return the descriptor when
the requested interface is found to prevent infinite loop.

Signed-off-by: Santhosh Charles <[email protected]>
This patch modifies the USB device int sequence to read the device
descriptor only after setting a valid device address.

Signed-off-by: Santhosh Charles <[email protected]>
Introduce subsys/usb/common as a new directory intended to hold
sources and configuration that are shared between USB host and device
implementations. Integrate the new common directory into the build
system.

Signed-off-by: Santhosh Charles <[email protected]>
Signed-off-by: Josuah Demangeon <[email protected]>
Add devicetree binding file describing the USB Host CDC Ethernet
Control Model (ECM) implementation for Zephyr.

Signed-off-by: Santhosh Charles <[email protected]>
Add support for the USB CDC ECM (Ethernet Control Model) class to the
USB host subsystem. This implementation enables Ethernet functionality
for USB host.

Signed-off-by: Santhosh Charles <[email protected]>
@MarkWangChinese
Copy link
Contributor

@MarkWangChinese is this related to your ongoing effort for implementing ECM?

Thanks @josuah

Hi @santhosh-c-c As the comments #95661 (comment), our side (NXP) is trying to enable the USB Host ECM too, our plan is creating the formal pr before the end of December, we will do basic function test too. Could you tell me your plan? let's align to meet both our requirements. Thanks.

@santhosh-c-c
Copy link
Author

@MarkWangChinese is this related to your ongoing effort for implementing ECM?

Thanks @josuah

Hi @santhosh-c-c As the comments #95661 (comment), our side (NXP) is trying to enable the USB Host ECM too, our plan is creating the formal pr before the end of December, we will do basic function test too. Could you tell me your plan? let's align to meet both our requirements. Thanks.

Hello @MarkWangChinese

Our code has been tested on the hardware (MIMXRT1064-EVK), and we are currently waiting for the dependency to be merged first, namely this PR: #94590. Once that merge is complete, we will proceed with merging our ECM host class support.

An internal review is ongoing and we are looking for any features that should be added. This internal review should not take more than a week. If you would like, we can discuss any additional features that need to be added so we can align with your requirements.

@MarkWangChinese
Copy link
Contributor

Our code has been tested on the hardware (MIMXRT1064-EVK), and we are currently waiting for the dependency to be merged first, namely this PR: #94590. Once that merge is complete, we will proceed with merging our ECM host class support.

An internal review is ongoing and we are looking for any features that should be added. This internal review should not take more than a week. If you would like, we can discuss any additional features that need to be added so we can align with your requirements.

Thanks @santhosh-c-c I think our side can co-work on this pr. For example: the current codes doesn't send CDC ECM class specific control transfer, the mac address is not got from the attached device's descriptor. Our side can add commits to your pr and do test on our side too. Is it OK?
BYW, Could you please share your test flow? how did you test it on MIMXRT1064-EVK, what's your building cmd. Thanks.

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants