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


< RockpiS‎ | dev
    ROCK Pi S >  Development >  USB Device Network

ROCK Pi S has one USB OTG port, which can be configured as USB devices with the Linux USB gadget driver, supporting multiple functions as a USB device such as Massive Storage Device and USB networking. We describe how to configure USBNET with a HOST PC.

Hardware required

  • ROCK Pi S
  • USB 3.0 or 2.0 male type A to type C 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@rockpis:~# systemctl stop rockchip-adbd
root@rockpis:~# systemctl disable rockchip-adbd
root@rockpis:~# reboot

Load kernel module

  • Connect the ROCK Pi S to PC with a USB C to USB A cable.
  • Install kernel module on ROCK Pi S
root@rockpis:~# modprobe g_ether

dmesg shoule output the folowing:

root@rockpis:~# 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@rockpis:~# ifconfig usb0 up

Now you should have usb0 on ROCK Pi S enabled.

On the host PC Ubuntu 16.04, the dmesg gives something like below:

radxa@x86_64_pc:~$ sudo dmesg -c
[974637.533636] usb 1-4.1: new high-speed USB device number 121 using xhci_hcd
[974637.635515] usb 1-4.1: New USB device found, idVendor=0525, idProduct=a4a2
[974637.635520] usb 1-4.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[974637.635523] usb 1-4.1: Product: RNDIS/Ethernet Gadget
[974637.635525] usb 1-4.1: Manufacturer: Linux 4.4.143-46-rockchip-gef70dd2c725e with ff400000.usb
[974637.636655] cdc_subset: probe of 1-4.1:1.0 failed with error -22
[974637.637971] cdc_ether 1-4.1:1.0 usb0: register 'cdc_ether' at usb-0000:00:14.0-4.1, CDC Ethernet Device, 8a:11:bc:e7:60:26
[974637.650141] cdc_ether 1-4.1:1.0 enp0s20f0u4u1: renamed from usb0
[974637.678705] IPv6: ADDRCONF(NETDEV_UP): enp0s20f0u4u1: link is not ready
[974637.694633] IPv6: ADDRCONF(NETDEV_UP): enp0s20f0u4u1: link is not ready

enp0s20f0u4u1 is the "USB network card" for ROCK Pi S. ifconfig enp0s20f0u4u1 gives us the info about it.

Setup USB Network


root@rockpis:~# IP=
root@rockpis:~# HOST_IP=
root@rockpis:~# ifconfig usb0 $IP netmask
root@rockpis:~# route

On host PC

radxa@x86_64_pc:~$ HOST_IP=
radxa@x86_64_pc:~$ sudo ifconfig enp0s20f0u4u1 $HOST_IP netmask

Test the network, on ROCK Pi S

root@rockpis:~# ping $HOST_IP

Test network traffic, on host PC

radxa@x86_64_pc:~$ iperf -s
Server listening on TCP port 5001
TCP window size:  128 KByte (default)
[  4] local port 5001 connected with port 48264
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0-10.0 sec   113 MBytes  94.6 Mbits/sec

Test network traffic, on ROCK Pi S:

root@rockpis:~# iperf -c $HOST_IP
Client connecting to, TCP port 5001
TCP window size: 85.0 KByte (default)
[  3] local port 48264 connected with port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec   113 MBytes  94.8 Mbits/sec