Coder Social home page Coder Social logo

majbthrd / d21ecm Goto Github PK

View Code? Open in Web Editor NEW
19.0 4.0 3.0 3.54 MB

CDC-ECM (Linux and macOS USB network) example SAMD21 embedded web server (lwip 2.1.2 based)

C 99.04% HTML 0.05% Perl 0.05% C++ 0.33% CMake 0.29% Shell 0.01% Makefile 0.22%
usb-cdc-ecm usb cdc-ecm ecm samd21 samd21g18 samd21j18 microchip usb-devices lwip

d21ecm's Introduction

USB CDC-ECM example for SAMD21

Inspired by lrndis, this is a CDC-ECM implementation for the Atmel/Microchip SAMD21. It leverages a variant of the SAMDx1 USB stack from vcp.

As with lrndis, lwIP is utilized to provide a rudimentary TCP/IP stack, DHCP server, and web server.

This is closely related to D21rndis, a RNDIS implementation, and D21eem, a CDC-EEM implementation. All implementations share most of the same code, differing only in the driver.

Note that this project was tested with Linux, macOS (High Sierra 10.13.16), and some smartphones (Moto E 2nd Gen and Moto G 1st Gen).

Alternatives

I have been making pull requests to TinyUSB to provide similar or greater capabilities. I am hoping this will be a worthwhile expenditure of effort, as TinyUSB would have the added benefit of supporting multiple processors and being build-able with only open source tools.

Usage

Due to the high memory usage of TCP/IP, a SAMD21 with 32kBytes of RAM and at least 128kBytes of FLASH is needed. Development was done with the SAMD21 Xplained Pro (ATSAMD21J18), but the SparkFun SAMD21 Mini Breakout (ATSAMD21G18) and Arduino Zero (ATSAMD21G18) ought to also be feasible.

Specifics

Look at the ./project/app.c to get an idea of how the code could be modified. As written, one quantity (systick) is shown in real-time as "Device Time" on the embedded web server (192.168.7.1) and another three quantities (alpha, bravo, and charlie) are "User Controls" on the web page that cause app.c code to be executed.

Arduino Zero Boards with Problems

This code normally uses the USBCRM mode of the SAMD21. In this mode, the part disciplines its own 48MHz RC clock using the USB SOF messages. The advantage of this is simple: it doesn't require optional external components.

Until buying a PCB from Sparkfun, I have had zero issues with USBCRM across several hardware designs. However, the Sparkfun design (derived from Arduino Zero) uses a 32k external crystal and USB will NOT work reliably on it unless this optional crystal is used as the timing source. Furthermore, the Arduino Zero bootloader source code depends on a 32k external crystal without any explanation as to why. There is no verbiage in the datasheet to indicate special requirements for USBCRM. AT07175 (the SAM-BA app note that served as a basis for the "Arduino Zero" bootloader) makes no special requirements. There are no errata notes on possible scenarios where USBCRM should not function.

The USBCRM mode should be universal, as it doesn't depend on optional external components. For that reason, the source code uses this mode by default. However, the source code now has an "#if 1" that can be changed to "#if 0" to cause the optional external 32k crystal (if populated on your design) to be used instead of USBCRM.

Requirements for compiling

Rowley Crossworks for ARM is presently needed to compile this code. The project file is under ./ide/Rowley/.

All the code is gcc/clang compatible, and as time permits, other options may be added.

d21ecm's People

Contributors

majbthrd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

d21ecm's Issues

Question: USB Host RNDIS

Hi @majbthrd thanks for your brilliant contributions to TinyUSB's networking side of things. I agree that TinyUSB is the way forward for development but I traced back your work to this repo and your stm32 version, noting that there is a newer version of lwip here and also you have implemented actions on button presses, which is better than the RNDIS example you ported to TinyUSB, in my view.

I spoke to Ha at TinyUSB about RNDIS on USB host and as expected, it's not high on his agenda (and I don't expect it to be high on yours). I'm pretty new to USB so it will take me some time to learn the ropes but it's a feature I'm interested in and would be happy to do so under TinyUSB for all to benefit from if I can get my contributions to the required standard.

Finally getting to my question: do you think implementing an RNDIS host with TinyUSB/lwIP is feasible? From a naive perspective it all looks doable but I bow to your clear insight and experience in this area. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.