USB CDC / USBnet (ECM, NCM, ACM)

USB CDC-ACM (Abstract Control Model), CDC-ECM (Ethernet Networking Control Model), CDC-NCM (Network Control Model), OBEX (Object Exchange) and WCM-Device Management USB class and function drivers

CDC-ACM (Abstract Control Model) allows any communication device to provide a serial communication interface (e.g modem devices that send and receive AT commands).

/lib/modules/$(uname -r)/kernel/drivers/usb/class目录下看到cdc-acm.ko文件。


CDC-ECM (Ethernet Networking Control Model) offers device manufacturers to interface as a standard NIC (Network Interface Card) device. This interface is usually adopted by high speed LAN networking devices allowing high speed Ethernet data transfer over USB.

CDC-NCM (Network Control Model).

OBEX (Object Exchange) is compliant with the Wireless Mobile Communication OBEX function model, supporting OBEX applications over USB.

WMC-Device Management is compliant with the Device Management function model, supporting a minimal AT command based control model.

RNDIS - provides CDC like communication capabilities on Windows PCs supporting the Microsoft RNDIS protocol. Please refer to theRNDIS webpage for more info.

  • ACM - Abstract Communication Model
  • ECM - Ethernet Control Module
  • NCM - Network Control Model
  • OBEX - Object Exchange Function Model
  • WMC - Device management Function Model 

The CDC ACM driver exposes the USB device as a virtual modem or a virtual COM port to the operating system.

The driver enables sending both data and AT commands, either through ACM (separating data and AT commands over different channels) or through Serial Emulation (passing the AT commands as is and as part of the data stream).


The ECM ( Ethernet Networking Control Model) protocol is used for exchanging Ethernet-framed data between the device and host. A CDC ECM compliant device exposes itself as a virtual NIC to the host operating system. The NIC is assigned with a MAC and an IP address.

A general use case of a CDC ECM device is a point-to-point Ethernet adapter to a LAN/WLAN.


The  NCM  ( Network Control Model ) protocol is used for exchanging High Speed Ethernet-framed data between the device and host. A CDC NCM compliant device exposes itself as a virtual NIC to the host operating system. The NIC is assigned with a MAC and an IP address.

A general use case of a CDC NCM device is a Wireless Network Adapter which supports 3.5G/4G networks such as: HSPA+ and LTE.

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
### 回答1: 编写USB2.0 ECM驱动需要以下步骤: 1. 确认系统内核版本和驱动框架:ECM驱动可以在Linux内核版本2.6.29和更高版本上运行,并需要使用USBnet框架。 2. 确认硬件:确认所使用的硬件支持ECM协议。 3. 编写驱动程序:编写ECM驱动程序,包括初始化函数、发送和接收数据函数等。 4. 注册驱动程序:将驱动程序注册到系统中。 5. 测试驱动程序:使用ECM协议测试驱动程序,确保其能够正常工作。 下面是一个简单的USB2.0 ECM驱动程序示例: ``` #include <linux/module.h> #include <linux/usb.h> #include <linux/usb/usbnet.h> static int ecm_bind(struct usbnet *dev, struct usb_interface *intf) { int status; status = usbnet_get_ethernet_addr(dev, intf); if (status) return status; return register_netdev(dev->net); } static void ecm_unbind(struct usbnet *dev, struct usb_interface *intf) { unregister_netdev(dev->net); } static struct driver_info ecm_info = { .description = "USB ECM driver", .bind = ecm_bind, .unbind = ecm_unbind, }; static int __init ecm_init(void) { return usbnet_driver_register(&ecm_info); } static void __exit ecm_exit(void) { usbnet_driver_unregister(&ecm_info); } module_init(ecm_init); module_exit(ecm_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Your Name"); MODULE_DESCRIPTION("USB ECM driver"); ``` 需要注意的是,这只是一个简单的示例程序,实际的驱动程序需要更多的代码来实现完整的ECM协议支持。另外,需要仔细了解Linux内核和USBnet框架的相关知识才能编写出可靠的驱动程序。 ### 回答2: 编写USB2.0 ECM驱动需要遵循以下步骤: 1. 理解ECM驱动原理:ECM(Ethernet Control Model)是一种通过USB连接的网络设备驱动程序。它使用特定的USB描述符和协议和主机进行通信,并通过将USB传输层转换为以太网帧来实现网络通信。 2. 检查设备硬件:确认设备支持USB2.0接口,并且具备ECM功能。检查设备的硬件规格和技术文档,了解接口和通信要求。 3. 创建基本驱动程序:使用适当的开发工具,如C或C++,创建驱动程序的框架。这包括初始化和配置USB设备和主机通信,处理中断和事件,以及收发数据的功能。 4. 定义USB描述符:根据ECM规范,定义USB描述符。这些描述符包括设备描述符、配置描述符、接口描述符和端点描述符。确保与设备的硬件和功能要求相匹配。 5. 实现USB传输层:根据ECM规范,在驱动程序中实现USB传输层。这包括使用USB传输协议进行初始化和通信,并处理传输中断和错误。 6. 实现以太网协议:将USB传输层转换为以太网帧,实现以太网协议栈。这包括处理以太网帧的构造、解析和转发。 7. 调试和测试:使用合适的调试工具对驱动程序进行测试和调试。确保驱动程序能够正确地连接到主机,并能够实现网络通信。 8. 完善驱动程序:根据需求进行优化和改进,确保驱动程序的性能和稳定性。 需要注意的是,编写USB驱动程序需要对USB协议和以太网协议有一定的了解,并熟悉相关的开发工具和调试技巧。这个过程可能需要深入的研究和实践,以确保驱动程序的正确实现和功能。 ### 回答3: 编写USB2.0 ECM驱动需要以下步骤: 1. 硬件准备:确保你有一台支持USB2.0 ECM的设备可以用于测试驱动程序,并连接到开发计算机上。如果没有这样的设备,可以考虑使用模拟器或者虚拟机。 2. 搭建开发环境:下载并安装适合开发驱动程序的集成开发环境(IDE),如Visual Studio等。确保所使用的IDE支持驱动程序开发,并安装相应的开发工具。 3. 初始化驱动程序:创建驱动程序项目,并编写初始化函数。在初始化函数中,设置驱动程序的设备对象以及相关的参数和回调函数。 4. 定义USB接口:定义驱动程序所支持的USB接口。这涉及到定义接口类型、传输方向、端点、传输类型等。需要根据规范实现相应的数据结构和方法。 5. 接收和发送数据:实现驱动程序的数据传输功能。这包括接收和处理从USB设备发送的数据,以及将数据发送到USB设备。需要实现数据缓冲区的分配、数据的读写操作、端点的配置等。 6. 错误处理:处理使用驱动程序时可能出现的错误。这包括设备连接或断开的错误、数据传输错误等。能够及时诊断和解决错误是保证驱动程序稳定性的重要因素。 7. 编译和调试:编译驱动程序并进行调试。在编译驱动程序之前,确保代码没有语法错误和逻辑错误。在调试过程中,使用调试工具跟踪代码执行,诊断和解决问题。 8. 测试和优化:连接目标设备并测试驱动程序的功能和性能。如果发现问题,需要进行优化并重新测试,直到驱动程序达到预期的稳定性和效果。 编写USB2.0 ECM驱动需要具备深入理解USB协议和驱动开发的知识。同时,需要根据具体的驱动程序需求和目标设备的特性来进行开发。掌握相关技术,并不断学习和实践,可以提高驱动程序的质量和效率。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值