それマグで!

知識はカップより、マグでゆっくり頂きます。 takuya_1stのブログ

習慣に早くから配慮した者は、 おそらく人生の実りも大きい。

USB OTG でOTGで 複数の機器を有効にする。

OTGで 複数の機器を有効にする。

root@OrangePi:~# cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

g_cdc

Raspi からみると・・・ usb0 ネットワークが出現した

takuya@raspi-ubuntu:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 8: usb0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether d6:f8:81:1e:7c:23 brd ff:ff:ff:ff:ff:ff

USBを見てみると・・・

takuya@raspi-ubuntu:~$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 006: ID 0525:a4aa Netchip Technology, Inc. Linux-USB CDC Composite Gadge (Ethernet and ACM)
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Ethernetカードとして認識されている強い。

OrangePi Zero 側からみてみると。usb0が出現した

root@OrangePi:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 3: usb0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 2a:80:fe:93:0b:78 brd ff:ff:ff:ff:ff:ff

通信してみる。

takuya@raspi-ubuntu:~$ sudo  ip link set usb0 up 
takuya@raspi-ubuntu:~$ sudo  ip addr add 10.1.1.1/24 dev usb0
root@OrangePi:~# ip link set usb0 up 
root@OrangePi:~# ip addr add 10.1.1.2/24 dev usb0

ping 疎通確認

takuya@raspi-ubuntu:~$ ping 10.1.1.2
PING 10.1.1.2 (10.1.1.2) 56(84) bytes of data.
64 bytes from 10.1.1.2: icmp_seq=1 ttl=64 time=0.474 ms
64 bytes from 10.1.1.2: icmp_seq=2 ttl=64 time=0.352 ms

iperf3 で速度チェック

root@OrangePi:~# iperf3 -c 10.1.1.1
Connecting to host 10.1.1.1, port 5201
[  4] local 10.1.1.2 port 51210 connected to 10.1.1.1 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec  11.7 MBytes  97.8 Mbits/sec    0    146 KBytes
[  4]   1.00-2.00   sec  7.46 MBytes  62.4 Mbits/sec    0    232 KBytes
[  4]   2.00-3.00   sec  2.55 MBytes  21.4 Mbits/sec    0    253 KBytes
[  4]   3.00-4.00   sec  5.28 MBytes  44.4 Mbits/sec    0    253 KBytes
[  4]   4.00-5.02   sec  9.69 MBytes  79.6 Mbits/sec    0    253 KBytes
[  4]   5.02-6.00   sec  4.66 MBytes  39.9 Mbits/sec    0    253 KBytes
[  4]   6.00-7.01   sec  7.77 MBytes  64.9 Mbits/sec    0    253 KBytes
[  4]   7.01-8.00   sec  2.17 MBytes  18.3 Mbits/sec    0    253 KBytes
[  4]   8.00-9.00   sec  2.49 MBytes  20.9 Mbits/sec    0    253 KBytes
[  4]   9.00-10.01  sec  10.3 MBytes  85.7 Mbits/sec    0    253 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.01  sec  64.0 MBytes  53.7 Mbits/sec    0             sender
[  4]   0.00-10.01  sec  63.5 MBytes  53.3 Mbits/sec                  receiver

iperf Done.

逆も念の為。

takuya@raspi-ubuntu:~$ iperf3 -c 10.1.1.2
Connecting to host 10.1.1.2, port 5201
[  5] local 10.1.1.1 port 35584 connected to 10.1.1.2 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  10.7 MBytes  90.1 Mbits/sec    0   52.3 KBytes
[  5]   1.00-2.00   sec  10.5 MBytes  87.7 Mbits/sec    0   52.3 KBytes
[  5]   2.00-3.00   sec  10.5 MBytes  88.2 Mbits/sec    0   52.3 KBytes
[  5]   3.00-4.00   sec  10.5 MBytes  88.5 Mbits/sec    0   52.3 KBytes
[  5]   4.00-5.00   sec  10.4 MBytes  87.4 Mbits/sec    0   52.3 KBytes
[  5]   5.00-6.00   sec  9.99 MBytes  83.8 Mbits/sec    0   83.4 KBytes
[  5]   6.00-7.00   sec  1.07 MBytes  8.99 Mbits/sec    1    197 KBytes
[  5]   7.00-8.00   sec   827 KBytes  6.78 Mbits/sec    0    225 KBytes
[  5]   8.00-9.00   sec   636 KBytes  5.21 Mbits/sec    1    247 KBytes
[  5]   9.00-10.00  sec  5.22 MBytes  43.8 Mbits/sec    0    274 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  70.4 MBytes  59.0 Mbits/sec    2             sender
[  5]   0.00-10.00  sec  69.2 MBytes  58.1 Mbits/sec                  receiver

iperf Done.
takuya@raspi-ubuntu:~$

そこまで速度が出るわけじゃないけど、便利。

ethtool では情報が出ないですね

takuya@raspi-ubuntu:~$ sudo ethtool usb0
Settings for usb0:
        Current message level: 0x00000007 (7)
                               drv probe link
        Link detected: yes
root@OrangePi:~# ethtool usb0
Settings for usb0:
        Link detected: yes

他にもマスストレージ、オーディオになれる。強い。

https://qiita.com/alt-core/items/a3b37a96e16e771e6cb1 https://linux.yebisu.jp/memo/1160