Please enable javascript, or click here to visit my ecommerce web site powered by Shopify.
Jump to: navigation, search

Difference between revisions of "Rock3/dev/usb-device-network"

< Rock3‎ | dev
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 
{{rock3_header}}
 
{{rock3_header}}
 
 
{{Languages|rock3/dev/usb-device-network}}
 
{{Languages|rock3/dev/usb-device-network}}
   [[rock3 | ROCK 3]] > [[rock3/dev | Development Guide]]>[[
+
 
 +
   [[rock3 | ROCK 3]] > [[rock3/dev | Development Guide]] > [[rock3/dev/usb-device-network | Usb device network]]
 +
 
 
===Requirements===
 
===Requirements===
  
Line 13: Line 14:
 
* Kernel version
 
* 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.
+
USB gadget driver must be enabled to configure usb net.
  
 
* Stop conflicting services
 
* 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.
+
So far, Type-C OTG port only supports one Gadget function. To use USB net, need to disable rockchip-adbd service.
  
 
<pre>
 
<pre>
Line 27: Line 28:
 
===Load kernel module===
 
===Load kernel module===
  
* Connect the ROCK CM3 IO to PC with a USB to USB A cable.
+
* Connect the Radxa CM3 IO to PC with one microUSB to Type-A cable.
* Install kernel module on ROCK CM3 IO
+
* Install kernel module on Radxa CM3 IO
  
 
<pre>
 
<pre>
root@radxa-cm3-io:modprobe g_ether
+
root@radxa-cm3-io:~# modprobe g_ether
 
</pre>
 
</pre>
  
 
<pre>
 
<pre>
root@radxa-cm3-io: dmesg -c
+
root@radxa-cm3-io:~# dmesg -c
 
[  25.792177] using random self ethernet address
 
[  25.792177] using random self ethernet address
 
[  25.792239] using random host ethernet address
 
[  25.792239] using random host ethernet address
Line 76: Line 77:
 
</pre>
 
</pre>
  
Test the network, on ROCK Pi S
+
Test the network, on Radxa CM3 IO
  
 
<pre>
 
<pre>
Line 82: Line 83:
 
</pre>
 
</pre>
  
 +
===Throughout===
  
 
+
==== Radxa CM3 IO ---> PC ====
===Text===
+
 
+
 
<pre>
 
<pre>
 
radxa@x86_64_pc:~$ iperf3 -s
 
radxa@x86_64_pc:~$ iperf3 -s
Line 133: Line 133:
 
iperf Done.
 
iperf Done.
 
</pre>
 
</pre>
 +
 +
==== PC ---> Radxa CM3 IO ====
  
 
<pre>
 
<pre>
Line 155: Line 157:
  
 
iperf Done.
 
iperf Done.
 
 
  
 
root@radxa-cm3-io:/home/rock# iperf3 -s
 
root@radxa-cm3-io:/home/rock# iperf3 -s
Line 193: Line 193:
 
</pre>
 
</pre>
  
===Remind===
+
===FAQs===
 
+
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
+
 
+
<pre>
+
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
+
</pre>
+
 
+
In PC
+
 
+
<pre>
+
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
+
</pre>
+

Latest revision as of 12:21, 11 November 2022

  ROCK 3 >  Development Guide >  Usb device network

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.

  • Stop conflicting services

So far, Type-C OTG port only supports one Gadget function. To use USB net, need to disable 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 Radxa CM3 IO to PC with one microUSB to Type-A cable.
  • Install kernel module on Radxa 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 Radxa CM3 IO

root@radxa-cm3-io::~# ping $HOST_IP

Throughout

Radxa CM3 IO ---> PC

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.

PC ---> Radxa CM3 IO

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

FAQs