linux usb虚拟网卡(NCM)

 

1. kernel config

   USB Gadget precomposed configurations

         Ethernet Gadget (with CDC Ethernet support)

             Network Control Model (NCM) support

 

linux usb虚拟网卡(NCM)_第1张图片

 

 

2. build modules

make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- modules

  LD [M]  drivers/usb/gadget/function/u_ether.ko

  LD [M]  drivers/usb/gadget/function/usb_f_ncm.ko

  LD [M]  drivers/usb/gadget/legacy/g_ncm.ko

  LD [M]  drivers/usb/gadget/libcomposite.ko

 

 

3. test on ubuntu

ubuntu ver: ubuntu 14(kernel 3.13)

test mc40 usb2.0 device in haps

3.1 config & build module, then copy these ko to ~/repo-usb/rootfs/rootfs-m/opt/ko/usb/gadget

 

3.2 boot kernel and insmod ko(enable NCM)

cd /opt/ko/usb/gadget/

insmod  ./function/u_ether.ko

insmod libcomposite.ko

insmod ./function/usb_f_ncm.ko

insmod ./legacy/g_ncm.ko

 

after insmod ./legacy/g_ncm.ko:

[  628.442369] using random self ethernet address

[  628.501629] using random host ethernet address

[  628.606386] usb0: HOST MAC 06:58:53:5b:52:79

[  628.634146] usb0: MAC 32:03:c1:66:a6:d0

[  628.658956] g_ncm gadget: NCM Gadget

[  628.668534] g_ncm gadget: g_ncm ready

[  636.719628] g_ncm gadget: high-speed config #1: CDC Ethernet (NCM)

 

3.3 check if usb ethernet is ok or not

1) on device side

linux usb虚拟网卡(NCM)_第2张图片

 

2) on pc host side

linux usb虚拟网卡(NCM)_第3张图片

 

3.4 configure

1) device

ifconfig usb0 up

ifconfig usb0 192.168.1.2

2) pc host

ifconfig usb0 192.168.1.3

 

3.5 ping test

1) pc host

ping 192.168.1.2

linux usb虚拟网卡(NCM)_第4张图片

 

2) device

ping 192.168.1.3

linux usb虚拟网卡(NCM)_第5张图片

 

 

你可能感兴趣的:(USB开发,USB,Linux,Driver,usb)