1. 简述
之前见过其他项目组的开发板,发现他们没有网口,但是可以通过IP进行ssh连接和scp文件传输到开发板,百度发现他们用的是USB虚拟网卡,于是我在我的开发板进行测试。
主机:windows
开发板:imx8mq
firefly参考文档
2. 配置内核
linux$ make menuconfig
> Device Drivers > USB support > USB Gadget Support
<M> Ethernet Gadget (with CDC Ethernet support)
[*] RNDIS support
3. 开发板
/* 1. 安装g_ether.ko */
root@imx8mqevk:/lib/modules/5.4.3# find -name g_ether.ko
./kernel/drivers/usb/gadget/legacy/g_ether.ko
root@imx8mqevk:/lib/modules/5.4.3# cp ./kernel/drivers/usb/gadget/legacy/g_ether.ko ./
root@imx8mqevk:/lib/modules/5.4.3# depmod
root@imx8mqevk:/lib/modules/5.4.3# modprobe g_ether
root@imx8mqevk:/lib/modules/5.4.3# ifconfig -a
eth0 Link encap:Ethernet HWaddr fe:00:f6:8e:96:47
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:127 errors:0 dropped:15 overruns:0 frame:0
TX packets:92 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:13938 (13.6 KiB) TX bytes:11535 (11.2 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:122 errors:0 dropped:0 overruns:0 frame:0
TX packets:122 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9320 (9.1 KiB) TX bytes:9320 (9.1 KiB)
usb0 Link encap:Ethernet HWaddr 76:9c:2a:8b:11:94
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
/* 2. 设置ip */
root@imx8mqevk:/lib/modules/5.4.3# ifconfig usb0 up
root@imx8mqevk:/lib/modules/5.4.3# ifconfig usb0 172.31.111.35
4. 主机设置
C:\Users\llj> netsh interface ipv4 add address name="以太网 4" 172.31.111.36 255.255.255.0 172.31.111.1
5. 测试
C:\Users\llj> ping 172.31.111.35
root@imx8mqevk:/lib/modules/5.4.3# ping 172.31.111.36
如果主机能ping通开发板,开发板ping不同主机,把主机防火墙关闭。
172.31.111.35、172.31.111.36都是虚拟ip,能互相ping通。文章来源:https://uudwc.com/A/jVyBY
6. 使用
文章来源地址https://uudwc.com/A/jVyBY