首先:打开linux 内核配置菜单:
$ make CROSS_COMPILE=arm-arago-linux-gnueabi- ARCH=arm menuconfig
在主菜单选择 Device Drivers
...
...
Power management options --->
[ ] Networking support --->
Device Drivers --->
File systems --->
Kernel hacking --->
...
...
如下图选择USB support
...
...
Sound card support --->
[*] HID Devices --->
[*] USB support --->
MMC/SD/SDIO card support --->
...
...
进入USB Gadget Support菜单
...
...
< > USB YUREX driver support
USB Gadget Support --->
*** OTG and related infrastructure ***
< > GPIO based peripheral-only VBUS sensing 'transceiver'
...
...
如下所示选择Inventra HDRC USB Peripheral
...
...
(2) Maximum VBUS Power usage (2-500 mA)
(2) Number of storage pipeline buffers
USB Peripheral Controller (Inventra HDRC USB Peripheral (TI, ADI, ...)) --->
< > USB Gadget Drivers
...
...
如下所示选择Ethernet Gadget
...
...
USB Peripheral Controller (Inventra HDRC USB Peripheral (TI, ADI, ...)) --->
< > USB Gadget Drivers
...
Ethernet Gadget (with CDC Ethernet support)
[*] RNDIS support
[ ] Ethernet Emulation Model (EEM) support
...
...
注意:
一定要选择"RNDIS support"
设置完毕后需要make modules 以便生成g_ether.ko驱动
然后将生成的镜像文件下载到开发板中。
进入板子的文件系统,加载该驱动:insmod g_ether.ko
此时RNDIS驱动会生成网络设备usb0(/dev/usb0),为了能正常的通信可以设置ip地址及其掩码:
ifconfig usb0 netmask255.255.255.0 up
此时就可以正常的通信工作,测试可以使用:
ping -I