Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


Sidebar

products:sbc:edge2:configurations:usb-gadget

Edge2 USB Gadget

Introduction

This document mainly introduces the usage of USB gadget.

From version 1.7.5, USB gadget is enabled by default, no need any setup, you can just skip the overlay and service setup.

System Configuration

Upgrade System

Follow Upgrade System to upgrade the system to latest version.

Enable USB Gadget Service

You can follow the command below to enable the USB Gadget service.

sudo systemctl enable usb-gadget-khadas.service

Reboot to effect.

sync
sudo reboot
2022/07/06 02:12 · nick

Usage of ADB

ADB is enabled by default, you can access the device directly via adb:

$ adb kill-server
$ adb devices
* daemon not running; starting now at tcp:5037
* daemon started successfully
 
List of devices attached
12036c819990    device
 
$ adb shell
root@Khadas:/#

Enable Other USB Functions

You can dynamically switch USB functions by writing to /tmp/.usb_config and restarting the usbdevice service.

  • Enable RNDIS
echo usb_rndis_en > /tmp/.usb_config
sudo usbdevice restart
  • Enable ACM
echo usb_acm_en > /tmp/.usb_config
sudo usbdevice restart
  • Enable UAC
echo usb_uac_en > /tmp/.usb_config
sudo usbdevice restart
  • Enable UVC
echo usb_uvc_en > /tmp/.usb_config
sudo usbdevice restart

After enabling UVC, run:

uvc-gadget rockchip/functions/uvc.0 -d /dev/videoX
Note: Replace X with the actual video node number.
  • Enable UMS
echo usb_ums_en > /tmp/.usb_config
sudo mkdir -p /userdata/
dd if=/dev/zero of=/userdata/ums_shared.img bs=1M count=1024

UMS mode requires the empty ums_shared.img file (1GB in the example above), which will be recognized as a storage drive by the host system.

RNDIS Setup IP Address

After enabling RNDIS, configure the IP address manually. For example, set the device IP to 192.168.35.100:

sudo ifconfig usb0 192.168.35.100 up

Also configure the IP on the host PC, for example 192.168.35.110.

Test the network connection:

ping -I usb0 192.168.35.110
Last modified: 2025/09/18 06:07 by jacobe