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

Add USBCDC_ECM class #9443

Merged
merged 5 commits into from May 20, 2019

Conversation

Projects
None yet
10 participants
@juhaylinen
Copy link
Contributor

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

@juhaylinen juhaylinen force-pushed the juhaylinen:usbcdc_ecm branch Jan 21, 2019

@ciarmcom

This comment has been minimized.

Copy link
Member

commented Jan 21, 2019

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

@ciarmcom ciarmcom requested review from c1728p9 and ARMmbed/mbed-os-maintainers Jan 21, 2019

@juhaylinen

This comment has been minimized.

Copy link
Contributor Author

commented Jan 22, 2019

FYI @mikter

@c1728p9
Copy link
Contributor

left a comment

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);

This comment has been minimized.

Copy link
@c1728p9

c1728p9 Jan 23, 2019

Contributor

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:

This comment has been minimized.

Copy link
@c1728p9

c1728p9 Jan 23, 2019

Contributor

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);

This comment has been minimized.

Copy link
@c1728p9

c1728p9 Jan 23, 2019

Contributor

_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?

usb/device/USBCDC_ECM/USBCDC_ECM.cpp Outdated

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

This comment has been minimized.

Copy link
@c1728p9

c1728p9 Jan 23, 2019

Contributor

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

usb/device/USBCDC_ECM/USBCDC_ECM.cpp Outdated
return NULL;
}

static const uint8_t configDescriptor[] = {

This comment has been minimized.

Copy link
@c1728p9

c1728p9 Jan 23, 2019

Contributor

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

This comment has been minimized.

Copy link
Contributor

commented Jan 28, 2019

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

@c1728p9 c1728p9 force-pushed the ARMmbed:feature-hal-spec-usb-device branch from 091b0e7 to e23e57d Jan 29, 2019

@juhaylinen juhaylinen force-pushed the juhaylinen:usbcdc_ecm branch Feb 4, 2019

@juhaylinen

This comment has been minimized.

Copy link
Contributor Author

commented Feb 5, 2019

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

@cmonr

This comment has been minimized.

Copy link
Contributor

commented Feb 14, 2019

@c1728p9 Please rereview.

@c1728p9

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor Author

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor Author

commented Feb 22, 2019

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

@c1728p9

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

commented Feb 22, 2019

I also share @c1728p9 concern about lack of documentation.

@cmonr

This comment has been minimized.

Copy link
Contributor

commented Feb 28, 2019

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

@c1728p9

This comment has been minimized.

Copy link
Contributor

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 Feb 28, 2019

@cmonr

This comment has been minimized.

Copy link
Contributor

commented Feb 28, 2019

@juhaylinen Please rebase against master when possible.

juhaylinen added some commits Jan 21, 2019

Add USBCDC_ECM class
Add initial Ethernet over USB communication support using
the ECM (Ethernet Control Model) subclass of USB CDC.
Fix USBCDC_ECM descriptors
Replace static arrays used for iMAC and config descriptor with class members
Minor coding style fixes
USBCDC_ECM: Add receive functionality
Handle SET_ETHERNET_PACKET_FILTER request

@juhaylinen juhaylinen force-pushed the juhaylinen:usbcdc_ecm branch to 4b71459 Mar 13, 2019

@adbridge

This comment has been minimized.

Copy link
Contributor

commented Mar 27, 2019

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

@cmonr

cmonr approved these changes Mar 27, 2019

@cmonr

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor Author

commented Mar 28, 2019

@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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link

commented May 16, 2019

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

This comment has been minimized.

Copy link

commented May 16, 2019

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

@bulislaw
Copy link
Member

left a comment

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 adbridge added needs: CI and removed needs: work labels May 17, 2019

@adbridge

This comment has been minimized.

Copy link
Contributor

commented May 17, 2019

CI started

@mbed-ci

This comment has been minimized.

Copy link

commented May 17, 2019

Test run: SUCCESS

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

@0xc0170 0xc0170 added ready for merge and removed needs: CI labels May 20, 2019

@0xc0170

This comment has been minimized.

Copy link
Member

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

26 checks passed

continuous-integration/jenkins/pr-head This commit looks good
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jenkins-ci/build-ARM Success
Details
jenkins-ci/build-GCC_ARM Success
Details
jenkins-ci/build-IAR Success
Details
jenkins-ci/cloud-client-test Success
Details
jenkins-ci/dynamic-memory-usage Success
Details
jenkins-ci/exporter Success
Details
jenkins-ci/greentea-test Success
Details
jenkins-ci/mbed2-build-ARM Success
Details
jenkins-ci/mbed2-build-GCC_ARM Success
Details
jenkins-ci/mbed2-build-IAR Success
Details
jenkins-ci/unittests Success
Details
travis-ci/astyle Local astyle testing has passed
Details
travis-ci/docs Local docs testing has passed
Details
travis-ci/doxy-spellcheck Local doxy-spellcheck testing has passed
Details
travis-ci/events Passed, runtime is 9275 cycles (-145 cycles)
Details
travis-ci/gitattributestest Local gitattributestest testing has passed
Details
travis-ci/include_check Local include_check testing has passed
Details
travis-ci/licence_check Local licence_check testing has passed
Details
travis-ci/littlefs Passed, code size is 8408B (+0.00%)
Details
travis-ci/psa-autogen Local psa-autogen testing has passed
Details
travis-ci/tools-py2.7 Local tools-py2.7 testing has passed
Details
travis-ci/tools-py3.5 Local tools-py3.5 testing has passed
Details
travis-ci/tools-py3.6 Local tools-py3.6 testing has passed
Details
travis-ci/tools-py3.7 Local tools-py3.7 testing has passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.