Skip to content

Add USBCDC_ECM class #9443

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

Merged
merged 5 commits into from
May 20, 2019
Merged

Add USBCDC_ECM class #9443

merged 5 commits into from
May 20, 2019

Conversation

juhaylinen
Copy link
Contributor

@juhaylinen juhaylinen commented Jan 21, 2019

Description

Add initial Ethernet over USB communication support using
the ECM (Ethernet Control Model) subclass of USB CDC.

Pull request type

[ ] Fix
[ ] Refactor
[ ] Target update
[x] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Reviewers

@c1728p9

@ciarmcom
Copy link
Member

@juhaylinen, thank you for your changes.
@c1728p9 @ARMmbed/mbed-os-maintainers please review.

@ciarmcom ciarmcom requested review from c1728p9 and a team January 21, 2019 14:00
@juhaylinen
Copy link
Contributor Author

FYI @mikter

Copy link
Contributor

@c1728p9 c1728p9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If read and write are implemented can linux then use this class to provide an internet connection over USB?


_bulk_buf_size = read_finish(_bulk_out);

read_start(_bulk_out, _bulk_buf, MAX_PACKET_SIZE_BULK);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without being able to receive data the functionality of this device is quite limited.

if (setup->bmRequestType.Type == CLASS_TYPE) {
//printf("In USBCallback_request: CLASS specific Request: %02x\n", setup->bRequest);
switch (setup->bRequest) {
case SET_ETHERNET_MULTICAST_FILTERS:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be forwarded to the user of this call as a callback? Alternatively, if this class took in a an EMAC phy then you could call the appropriate functions. @kjbracey-arm what are your thoughts on this?

void _bulk_in_callback();
void _bulk_out_callback();
bool _notify_network_connection(uint8_t value);
bool _notify_connection_speed_change(uint32_t up, uint32_t down);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_notify_network_connection and _notify_connection_speed_change are private and I don't see them being used anywhere in this class. Is this dead code?


const uint8_t *USBCDC_ECM::string_iconfiguration_desc()
{
static uint8_t string_imac_addr[26] = {0};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This array should probably be a member of the class rather than static.

return NULL;
}

static const uint8_t configDescriptor[] = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This array should probably be a member of the class rather than static. Also the local static initialization will cause mutexes to be used in interrupt context.

@cmonr
Copy link
Contributor

cmonr commented Jan 28, 2019

@c1728p9 Mind taking another look? New commit looks like it resolved old comments.

@juhaylinen
Copy link
Contributor Author

@c1728p9 I have addressed the changes requested. Please review.

@cmonr
Copy link
Contributor

cmonr commented Feb 14, 2019

@c1728p9 Please rereview.

@c1728p9
Copy link
Contributor

c1728p9 commented Feb 20, 2019

Hi @juhaylinen, to progress this further you'll need to create documentation on how to use this containing an API reference along with one or more examples on how to use this. For reference the documentation for all the existing USB classes can be found at https://github.com/ARMmbed/mbed-os-5-docs/tree/development/docs/api/usb.

Also from our email conversations it sounds like this only works on Linux. Is that correct? To be accepted as part of mbed-os this needs to work on Windows, Linux and OSX.

Once these two points are addressed I'll mark this as approved.

CC @cmonr

@juhaylinen
Copy link
Contributor Author

juhaylinen commented Feb 21, 2019

Linux and OSX have native support for USBCDC_ECM. Windows seem to require 3rd party driver (Belcarra, Thesycon, etc.) for the CDC-ECM support. Is this OK?

@c1728p9
Copy link
Contributor

c1728p9 commented Feb 21, 2019

Hi @juhaylinen, if you provide instructions in the documentation on how to setup and use USBCDC_ECM on Windows with freely available 3rd party software it will be OK.

@juhaylinen
Copy link
Contributor Author

@c1728p9 Any change getting this in 5.12 since only documentation is needed?

@c1728p9
Copy link
Contributor

c1728p9 commented Feb 22, 2019

Hi @juhaylinen I don't feel comfortable merging this without at least some preliminary docs/example. Without those I don't know how to test this on Windows. I'm also having a hard time seeing how users could easily make use of this in its current form, which docs would help to clarify.

@cmonr
Copy link
Contributor

cmonr commented Feb 22, 2019

I also share @c1728p9 concern about lack of documentation.

@cmonr
Copy link
Contributor

cmonr commented Feb 28, 2019

@c1728p9 Should this be retargeted to master since the feature branch was merged?

@c1728p9
Copy link
Contributor

c1728p9 commented Feb 28, 2019

@cmonr yeah, this PR should be against master now.

@cmonr cmonr changed the base branch from feature-hal-spec-usb-device to master February 28, 2019 02:45
@cmonr
Copy link
Contributor

cmonr commented Feb 28, 2019

@juhaylinen Please rebase against master when possible.

Add initial Ethernet over USB communication support using
the ECM (Ethernet Control Model) subclass of USB CDC.
Replace static arrays used for iMAC and config descriptor with class members
Minor coding style fixes
Handle SET_ETHERNET_PACKET_FILTER request
@adbridge
Copy link
Contributor

@juhaylinen is this still waiting for docs and examples ? As per @c1728p9 and @cmonr comments ?

@cmonr
Copy link
Contributor

cmonr commented Mar 27, 2019

LGTM, but this still needs docs, and replies to @c1728p9 comments.
Not sure an example is required, but would be nice to have.

@juhaylinen
Copy link
Contributor Author

@adbridge Docs and examples are still missing. I have been busy with more urgent tasks and I'm not sure when I can continue with this.
Adding Windows support is a bit tricky since I was not able to find free driver for USB ECM. Belcarra offers demo version of the commercial driver https://usblan.belcarra.com/2015/12/usblan-for-windows-10.html but it is not part of the company's Windows update. The demo version can be installed manually but I was not able to capture Ethernet packets from USB device. Maybe firewall or antivirus SW is blocking the traffic.

@mikter
Copy link

mikter commented Mar 28, 2019

We will continue this work when our plans go forward. remaining part of work is planned to next release.

For widows support it is quite clear it does not support it and we should not do anything more to add support for windows for this feature. perhaps link in documentation to places where to get windows support could be added.
This is a valid feature for platforms that do support it (macOS and Linux)

@c1728p9
Copy link
Contributor

c1728p9 commented Mar 28, 2019

For widows support it is quite clear it does not support it and we should not do anything more to add support for windows for this feature.

Windows support is an important aspect of this, as the a large number of mbed users are on Windows. It may be more appropriate to push USBCDC_ECM into its own repository rather than merge it into mbed-os. That way it doesn't set the expectation this has the support/compatibility of the existing USB classes. @bulislaw what do you think?

@mikter
Copy link

mikter commented Mar 29, 2019

@c1728p9 I don't understand your approach Windows does not support it we can't add support for windows as what ever we do it does not support it. Windows supports proprietary RNDIS protocol which this is not. Here is a link for different protocols https://usblan.belcarra.com/p/protocols.html

Windows support can be added by external companies and you can find driver for windows that will support ECM. https://usblan.belcarra.com/2015/12/usblan-for-windows-10.html

@paspik @AnttiKauppila any idea how to continue this as requirement as we can't make all the different USB ethernet protocols

@bulislaw
Copy link
Member

bulislaw commented Apr 4, 2019

I don't like the idea of not adding support for all 3 platforms. If there's a way of making it work on Windows, external drivers, we should be exploring it. If there are issues with our corporate setup we need to either figure out why is that (and work with IT to remove it) or request non-IT managed windows (VM?) to complete setup and testing.

Also we'll need the requested docs before bringing it to master.

@0xc0170
Copy link
Contributor

0xc0170 commented May 13, 2019

@juhaylinen Besides one platform lacking, can we at least get the rest completed? @c1728p9 will soon move from USB, it would be nice to have this completed (even if parked on feature branch). Please talk to him this week.

@TuomoHautamaki
Copy link

we at least get the rest completed

No more work has been planned for this. What do you think is missing if we exclude windows support?

@TuomoHautamaki
Copy link

@bulislaw do you have an update to the windows support topic?

Copy link
Member

@bulislaw bulislaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good arguments were raised during offline discussions. Specifically:

  • Feature branch maintenance is expensive
  • By pushing it to master we will add value
  • Mbed OS promise is around development on 3 OSs, not feature support
  • Feature can be used on OSs with standard ECM support, proprietary drivers can be explored when Windows support will be required

@adbridge
Copy link
Contributor

CI started

@mbed-ci
Copy link

mbed-ci commented May 17, 2019

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 2
Build artifacts

@0xc0170
Copy link
Contributor

0xc0170 commented May 20, 2019

Docs PRs are there, I reviewed them. This should be ready for integration now.

@0xc0170 0xc0170 merged commit d299b3f into ARMmbed:master May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants