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

Zero/Linux/usbnet

< Zero‎ | Linux
    Radxa Zero >  Working with Linux  >  Enable USB Ethernet gadget

Enable USB Ethernet gadget on Radxa Zero

This guide describes how to enable USB Ethernet gadget on Radxa Zero. USB Ethernet gadget emulates a normal Ethernet NIC over OTG port, allowing both the host computer and Radxa Zero to communicate over standard Ethernet protocol, like SSH and HTTP.

Requirement

  • Radxa Zero with a Linux distro
  • USB A to C cable
  • Any host computer
  • Any means to configure Radxa Zero. Some possibilities are SSH over WiFi, direct keyboard and monitor, and serial console.

Step 1: Make sure the port is not used

In some Linux distros bundle and enable amlogic-adbd in their image. Some examples are our official images and Manjaro.

amlogic-adbd also uses OTG port to emulate an Android debug bridge device. As such you need to disable this device to free the resource for USB gadget.

Run the following command to check if you have amlogic-adbd running. The output will show Active: active (running) if it is running:

sudo systemctl status amlogic-adbd.service

If amlogic-adbd is indeed running, disable it with the following command:

sudo systemctl disable amlogic-adbd.service

Then shutdown your Zero, unplug the cable, and replug to computer of your choice.

Step 2: Enable USB Ethernet gadget

Run the following commands to enable USB Ethernet gadget:

# Based on https://www.collabora.com/news-and-blog/blog/2019/02/18/modern-usb-gadget-on-linux-and-how-to-integrate-it-with-systemd-part-1/
sudo -i
modprobe libcomposite
# different distro could have a different configfs mounting point: /sys/kernel/config
# if the following command fails you need to check with your distro
mkdir /sys/kernel/config/usb_gadget/radxa/
cd /sys/kernel/config/usb_gadget/radxa/
echo 0x1d6b > ./idVendor
echo 0x104 > ./idProduct
mkdir -p ./strings/0x409
echo "Radxa" > ./strings/0x409/manufacturer
echo "ECM" > ./strings/0x409/product
mkdir -p ./configs/r.1
mkdir -p ./functions/ecm.usb0
ln -s ./functions/ecm.usb0/ ./configs/r.1/
# ls /sys/class/udc to see available UDCs
# the value below could be different on your system
echo ff400000.usb > ./UDC

The above commands were tested on our official Ubuntu Server 211120 image, and Manjaro by one of our forum user.