Difference between revisions of "Rock3/dev/usb-device-network"
Line 2: | Line 2: | ||
{{Languages|rock3/dev/usb-device-network}} | {{Languages|rock3/dev/usb-device-network}} | ||
− | + | [[rock3 | ROCK 3]] > [[rock3/dev | Development Guide]]>[[ | |
===Requirements=== | ===Requirements=== | ||
Revision as of 08:38, 2 August 2022
ROCK 3 > Development Guide>[[
Contents
Requirements
- ROCK CM3 IO
- USB 3.0 or 2.0 male type A to male type A cable
- Host PC running Linux OS
Software preparation
- Kernel version
USB gadget driver must be enabled to configure usb net. You need to update the kernel to at least version 4.4.143-46-rockchip.
- Stop conflicting services
So far, Type-C OTG port only supports one Gadget function. To use use USB net, here need to stop rockchip-adbd service.
root@radxa-cm3-io:~# systemctl stop rockchip-adbd root@radxa-cm3-io:~# systemctl disable rockchip-adbd root@radxa-cm3-io:~# reboot
Load kernel module
- Connect the ROCK CM3 IO to PC with a USB to USB A cable.
- Install kernel module on ROCK CM3 IO
root@radxa-cm3-io:modprobe g_ether
root@radxa-cm3-io: dmesg -c [ 25.792177] using random self ethernet address [ 25.792239] using random host ethernet address [ 25.794179] usb0: HOST MAC fe:fc:51:10:b2:fa [ 25.794444] usb0: MAC 82:21:a8:1b:f3:4a [ 25.794539] using random self ethernet address [ 25.794589] using random host ethernet address [ 25.794787] g_ether gadget: Ethernet Gadget, version: Memorial Day 2008 [ 25.794819] g_ether gadget: g_ether ready [ 25.797133] dwc2 ff400000.usb: bound driver g_ether [ 25.988410] dwc2 ff400000.usb: new device is high-speed [ 26.068210] dwc2 ff400000.usb: new device is high-speed [ 26.132742] dwc2 ff400000.usb: new address 39 [ 26.154634] g_ether gadget: high-speed config #1: CDC Ethernet (ECM)
Bring up the usb0 device
root@radxa-cm3-io:~# ifconfig usb0 up
Setup USB Network
On ROCK Pi S.
root@radxa-cm3-io::~# IP=10.0.1.1 root@radxa-cm3-io::~# HOST_IP=10.0.1.2 root@radxa-cm3-io::~# ifconfig usb0 $IP netmask 255.255.255.0 root@radxa-cm3-io::~# route
On host PC
radxa@x86_64_pc:~$ HOST_IP=10.0.1.2 radxa@x86_64_pc:~$ sudo ifconfig usb0 $HOST_IP netmask 255.255.255.0
Test the network, on ROCK Pi S
root@radxa-cm3-io::~# ping $HOST_IP
Text
radxa@x86_64_pc:~$ iperf3 -s ----------------------------------------------------------- Server listening on 5201 ----------------------------------------------------------- Accepted connection from 10.0.1.1, port 59778 [ 5] local 10.0.1.2 port 5201 connected to 10.0.1.1 port 59780 [ ID] Interval Transfer Bitrate [ 5] 0.00-1.00 sec 34.4 MBytes 289 Mbits/sec [ 5] 1.00-2.00 sec 36.0 MBytes 302 Mbits/sec [ 5] 2.00-3.00 sec 35.9 MBytes 302 Mbits/sec [ 5] 3.00-4.00 sec 36.0 MBytes 302 Mbits/sec [ 5] 4.00-5.00 sec 36.0 MBytes 302 Mbits/sec [ 5] 5.00-6.00 sec 36.0 MBytes 302 Mbits/sec [ 5] 6.00-7.00 sec 36.0 MBytes 302 Mbits/sec [ 5] 7.00-8.00 sec 36.0 MBytes 302 Mbits/sec [ 5] 8.00-9.00 sec 35.9 MBytes 302 Mbits/sec [ 5] 9.00-10.00 sec 36.0 MBytes 302 Mbits/sec [ 5] 10.00-10.04 sec 1.52 MBytes 301 Mbits/sec - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate [ 5] 0.00-10.04 sec 360 MBytes 301 Mbits/sec receiver ----------------------------------------------------------- Server listening on 5201 -------------------------- root@radxa-cm3-io:/home/rock# iperf3 -c 10.0.1.2 Connecting to host 10.0.1.2, port 5201 [ 5] local 10.0.1.1 port 59780 connected to 10.0.1.2 port 5201 [ ID] Interval Transfer Bitrate Retr Cwnd [ 5] 0.00-1.00 sec 37.0 MBytes 310 Mbits/sec 0 238 KBytes [ 5] 1.00-2.00 sec 35.8 MBytes 300 Mbits/sec 0 238 KBytes [ 5] 2.00-3.00 sec 36.3 MBytes 304 Mbits/sec 0 238 KBytes [ 5] 3.00-4.00 sec 35.8 MBytes 300 Mbits/sec 0 238 KBytes [ 5] 4.00-5.00 sec 35.8 MBytes 300 Mbits/sec 0 238 KBytes [ 5] 5.00-6.00 sec 36.3 MBytes 304 Mbits/sec 0 238 KBytes [ 5] 6.00-7.00 sec 35.8 MBytes 300 Mbits/sec 0 238 KBytes [ 5] 7.00-8.00 sec 36.3 MBytes 304 Mbits/sec 0 238 KBytes [ 5] 8.00-9.00 sec 35.8 MBytes 300 Mbits/sec 0 238 KBytes [ 5] 9.00-10.00 sec 35.8 MBytes 300 Mbits/sec 0 238 KBytes - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-10.00 sec 361 MBytes 303 Mbits/sec 0 sender [ 5] 0.00-10.04 sec 360 MBytes 301 Mbits/sec receiver iperf Done.
radxa@x86_64_pc:~$ iperf3 -c 10.0.1.1 Connecting to host 10.0.1.1, port 5201 [ 5] local 10.0.1.2 port 37554 connected to 10.0.1.1 port 5201 [ ID] Interval Transfer Bitrate Retr Cwnd [ 5] 0.00-1.00 sec 19.9 MBytes 167 Mbits/sec 0 107 KBytes [ 5] 1.00-2.00 sec 19.1 MBytes 161 Mbits/sec 0 107 KBytes [ 5] 2.00-3.00 sec 19.4 MBytes 163 Mbits/sec 0 107 KBytes [ 5] 3.00-4.00 sec 19.4 MBytes 163 Mbits/sec 0 107 KBytes [ 5] 4.00-5.00 sec 19.9 MBytes 167 Mbits/sec 0 107 KBytes [ 5] 5.00-6.00 sec 19.1 MBytes 161 Mbits/sec 0 107 KBytes [ 5] 6.00-7.00 sec 19.6 MBytes 165 Mbits/sec 0 107 KBytes [ 5] 7.00-8.00 sec 19.4 MBytes 163 Mbits/sec 0 107 KBytes [ 5] 8.00-9.00 sec 19.4 MBytes 163 Mbits/sec 0 107 KBytes [ 5] 9.00-10.00 sec 19.4 MBytes 163 Mbits/sec 0 107 KBytes - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-10.00 sec 195 MBytes 163 Mbits/sec 0 sender [ 5] 0.00-10.00 sec 194 MBytes 163 Mbits/sec receiver iperf Done. root@radxa-cm3-io:/home/rock# iperf3 -s ----------------------------------------------------------- Server listening on 5201 ----------------------------------------------------------- Accepted connection from 10.0.1.2, port 37552 [ 5] local 10.0.1.1 port 5201 connected to 10.0.1.2 port 37554 [ 1572.486275] NOHZ: local_softirq_pending 08 [ 1572.832822] NOHZ: local_softirq_pending 08 [ 1572.962856] NOHZ: local_softirq_pending 08 [ 1572.969171] NOHZ: local_softirq_pending 08 [ 1573.022734] NOHZ: local_softirq_pending 08 [ 1573.062681] NOHZ: local_softirq_pending 08 [ ID] Interval Transfer Bitrate [ 5] 0.00-1.00 sec 19.3 MBytes 162 Mbits/sec [ 1573.496222] NOHZ: local_softirq_pending 08 [ 1573.923641] NOHZ: local_softirq_pending 08 [ 1573.923827] NOHZ: local_softirq_pending 08 [ 1574.085957] NOHZ: local_softirq_pending 08 [ 5] 1.00-2.00 sec 19.3 MBytes 162 Mbits/sec [ 5] 2.00-3.00 sec 19.4 MBytes 162 Mbits/sec [ 5] 3.00-4.00 sec 19.4 MBytes 163 Mbits/sec [ 5] 4.00-5.00 sec 19.7 MBytes 165 Mbits/sec [ 5] 5.00-6.00 sec 19.4 MBytes 162 Mbits/sec [ 5] 6.00-7.00 sec 19.4 MBytes 163 Mbits/sec [ 5] 7.00-8.00 sec 19.4 MBytes 163 Mbits/sec [ 5] 8.00-9.00 sec 19.5 MBytes 163 Mbits/sec [ 5] 9.00-10.00 sec 19.5 MBytes 163 Mbits/sec [ 5] 10.00-10.00 sec 36.8 KBytes 177 Mbits/sec - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate [ 5] 0.00-10.00 sec 194 MBytes 163 Mbits/sec receiver ----------------------------------------------------------- Server listening on 5201
Remind
If you can't ping the PC or rock pi.You should check your gateway.
Here's how to check for hardware problems.If it is successful, then the hardware is ok.
In Rock CM3 IO
root@radxa-cm3-io:~# route add -net 10.0.1.0/24 gw 10.0.1.1 dev usb0 root@radxa-cm3-io:~# iperf3 -s
In PC
radxa@x86_64_pc:~$ radxa@x86_64_pc:~$ route add -net 10.0.1.0/24 gw 10.0.1.2 dev usb0 radxa@x86_64_pc:~$ iperf3 -c 10.0.1.1