{{indexmenu_n>30}}
====== Edge-2L USB gadget ======
{{page>products:sbc:common:configurations:usb-gadget&noheader}}
===== Usage of ADB =====
ADB (Android Debug Bridge) is enabled by default. You can access the device directly via ADB:
$ adb kill-server
$ adb devices
Expected output:
```txt
* daemon not running; starting now at tcp:5037
* daemon started successfully
List of devices attached
12036c819990 device
```
To obtain a shell on the device:
```shell
$ adb shell
```
You should see a prompt like: ''root@Khadas:/#''
===== Enable other USB functions =====
You can dynamically switch USB gadget functions by writing the desired mode to the file ''/tmp/.usb_config'' and restarting the 'usbdevice' service.
* **Enable RNDIS (Ethernet over USB):**
echo usb_rndis_en > /tmp/.usb_config
sudo usbdevice restart
* **Enable ACM (Serial Port over USB):**
echo usb_acm_en > /tmp/.usb_config
sudo usbdevice restart
* **Enable UAC (USB Audio Class):**
echo usb_uac_en > /tmp/.usb_config
sudo usbdevice restart
* **Enable UVC (USB Video Class):**
echo usb_uvc_en > /tmp/.usb_config
sudo usbdevice restart
After enabling UVC, start the UVC gadget application:
uvc-gadget rockchip/functions/uvc.0 -d /dev/videoX
> Note: Replace ''X'' with the actual video device node number (e.g. /dev/video0).
* **Enable UMS (USB Mass Storage):**
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 an empty disk image file (''ums_shared.img'' in the example above, 1GB size). This file will be presented to the host system as a removable storage drive.
===== RNDIS setup IP address =====
After enabling the RNDIS function, you need to configure the IP address manually on both the device and the host PC.
Such as set the IP address for the usb0 interface (e.g., to 192.168.35.100):
sudo ifconfig usb0 192.168.35.100 up
On the host PC, configure the corresponding USB network interface with an IP address on the same subnet (e.g., 192.168.35.110).
Test the connection form the device to the host:
ping -I usb0 192.168.35.110