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


< Rockpi4‎ | dev
Revision as of 12:56, 14 December 2018 by Hipboi (Talk | contribs)

    ROCK Pi 4 >  Development >  USB Device Network

ROCK Pi 4 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.


  • ROCK Pi 4
  • USB 3.0 or 2.0 male type A to male type A cable
  • Host PC running Linux OS

Kernel version

USB gadget driver must be enabled to configure usb net. kernel should be newer than 5e70f1495c248cf6ffa62d974ada7fc2172912cd. For Debian Stretch or Ubuntu, you can install the latest kernel from For how to setup Radxa Apt, refer rockpi4/radxa-apt.

Load kernel module

  • insert kernel module

On ROCK Pi 4

   sudo modprobe g_ether
   sudo ifconfig usb0 up

Now you should have usb0 on ROCK Pi 4 enabled.

  • Connect the ROCK Pi 4 to PC with the USB A to A cable, make sure the OTG switch is turned at the device side.

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

[714332.981224] usb 1-2: USB disconnect, device number 4
[714332.981402] cdc_ether 1-2:1.0 enp0s20f0u2: unregister 'cdc_ether' usb-0000:00:14.0-2, CDC Ethernet Device
[714344.746165] usb 1-2: new high-speed USB device number 5 using xhci_hcd
[714344.906872] usb 1-2: New USB device found, idVendor=0525, idProduct=a4a2
[714344.906878] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[714344.906882] usb 1-2: Product: RNDIS/Ethernet Gadget
[714344.906887] usb 1-2: Manufacturer: Linux 4.4.154-ge855bba-dirty with dwc3-gadget
[714344.910058] cdc_subset: probe of 1-2:1.0 failed with error -22
[714344.912272] cdc_ether 1-2:1.0 usb0: register 'cdc_ether' at usb-0000:00:14.0-2, CDC Ethernet Device, 76:2d:db:75:e9:68
[714344.920359] cdc_ether 1-2:1.0 enp0s20f0u2: renamed from usb0
[714344.958391] IPv6: ADDRCONF(NETDEV_UP): enp0s20f0u2: link is not ready
[714362.107471] usb 1-2: USB disconnect, device number 5
[714362.107601] cdc_ether 1-2:1.0 enp0s20f0u2: unregister 'cdc_ether' usb-0000:00:14.0-2, CDC Ethernet Device

enp0s20f0u2 is the "USB network card" for ROCK Pi 4. Ifconfig enp0s20f0u2 gives us the info about it.

Setup USB Network

On ROCK Pi 4.

   sudo ifconfig usb0 $IP netmask

On host PC

   sudo ifconfig enp0s20f0u2 $HOST_IP netmask

Test the network, on ROCK Pi 4

   ping $HOST_IP

Test network traffic, on host PC

   iperf -s

on ROCK Pi 4:

   iperf -c $HOST_IP