Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


products:sbc:edge2:configurations:usb-gadget

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
products:sbc:edge2:configurations:usb-gadget [2025/08/18 01:51]
nick
products:sbc:edge2:configurations:usb-gadget [2025/09/18 06:07] (current)
jacobe
Line 1: Line 1:
 {{indexmenu_n>30}} {{indexmenu_n>30}}
- 
  
 ====== Edge2 USB Gadget ====== ====== Edge2 USB Gadget ======
- 
  
 {{page>/products/sbc/common/configurations/usb-gadget&noheader}} {{page>/products/sbc/common/configurations/usb-gadget&noheader}}
Line 9: Line 7:
 ===== Usage of ADB ===== ===== Usage of ADB =====
  
-Try to access the devices via adb.+ADB is enabled by default, you can access the device directly via adb:
  
-```shell+<code shell>
 $ adb kill-server $ adb kill-server
 $ adb devices $ adb devices
 * daemon not running; starting now at tcp:5037 * daemon not running; starting now at tcp:5037
 * daemon started successfully * daemon started successfully
 +
 List of devices attached List of devices attached
 12036c819990    device 12036c819990    device
 +
 $ adb shell $ adb shell
 root@Khadas:/# root@Khadas:/#
-root@Khadas:/+</code>
-root@Khadas:/# +
-root@Khadas:/# +
-```+
  
-===== RNDIS Setup IP Address =====+===== Enable Other USB Functions =====
  
-Edit ''/etc/profile.d/usbdevice.sh'' and uncomment ''#export USB_FUNCS="rndis"'' to enable RNDIS  and reboot.+You can dynamically switch USB functions by writing to ''/tmp/.usb_config'' and restarting the ''usbdevice'' service.
  
-```diff +  * **Enable RNDIS** 
-diff --git a/etc/profile.d/usbdevice.sh b/etc/profile.d/usbdevice.sh +<code shell> 
-index d10b84df..06d1ab22 100644 +echo usb_rndis_en > /tmp/.usb_config 
---- a/etc/profile.d/usbdevice.sh +sudo usbdevice restart 
-+++ b/etc/profile.d/usbdevice.sh +</code>
-@@ -11,8 +11,8 @@ +
- # @ UMS_RO: The flag of read only. 0->Read & Write, 1->Read Only.+
  
- export USE=1 +  * **Enable ACM** 
--export USB_FUNCS="adb" +<code shell> 
-+#export USB_FUNCS="adb" +echo usb_acm_en > /tmp/.usb_config 
--#export USB_FUNCS="rndis" +sudo usbdevice restart 
-+export USB_FUNCS="rndis" +</code>
- #export USB_FUNCS="ums" +
- #export USB_FUNCS="adb ums" +
- export UMS_MOUNT=0 +
-```+
  
-Setup IP address manyally, e.g. setup IP address as ''192.168.35.100''+  * **Enable UAC** 
 +<code shell> 
 +echo usb_uac_en > /tmp/.usb_config 
 +sudo usbdevice restart 
 +</code>
  
-```shell +  * **Enable UVC** 
-sudo ifconfig usb0 192.168.35.100 up +<code shell> 
-```+echo usb_uvc_en > /tmp/.usb_config 
 +sudo usbdevice restart 
 +</code>
  
-You also need to setup the IP address on your PCe.g. ''192.168.35.110''+After enabling UVCrun: 
 +<code shell> 
 +uvc-gadget rockchip/functions/uvc.0 -d /dev/videoX 
 +</code> 
 +> Note: Replace ''X'' with the actual video node number.
  
-Check network connection:+  * **Enable UMS** 
 +<code shell> 
 +echo usb_ums_en > /tmp/.usb_config 
 +sudo mkdir -p /userdata/ 
 +dd if=/dev/zero of=/userdata/ums_shared.img bs=1M count=1024 
 +</code>
  
-```shell +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.
-khadas@Khadas:~$ ping -I usb0 192.168.35.110 +
-PING 192.168.35.110 (192.168.35.110from 192.168.35.100 usb0: 56(84) bytes of data. +
-64 bytes from 192.168.35.110: icmp_seq=1 ttl=64 time=1.19 ms +
-64 bytes from 192.168.35.110: icmp_seq=2 ttl=64 time=1.33 ms +
-64 bytes from 192.168.35.110: icmp_seq=3 ttl=64 time=1.21 ms +
-64 bytes from 192.168.35.110: icmp_seq=4 ttl=64 time=1.22 ms +
-64 bytes from 192.168.35.110: icmp_seq=5 ttl=64 time=1.28 ms +
-^C +
---- 192.168.35.110 ping statistics --- +
-5 packets transmitted5 received, 0% packet loss, time 4007ms +
-rtt min/avg/max/mdev = 1.193/1.245/1.328/0.050 ms +
-```+
  
 +===== RNDIS Setup IP Address =====
  
-===== Troubleshooting =====+After enabling RNDIS, configure the IP address manually. For example, set the device IP to ''192.168.35.100'': 
 + 
 +<code shell> 
 +sudo ifconfig usb0 192.168.35.100 up 
 +</code>
  
-If adb not work on windowsyou can edit ''/etc/profile.d/usbdevice.sh'' to comment ''export USB_FUNCS="rndis"'' and reboot.+Also configure the IP on the host PCfor example ''192.168.35.110''.
  
-```diff +Test the network connection:
-diff --git a/etc/profile.d/usbdevice.sh b/etc/profile.d/usbdevice.sh +
-index d10b84df..06d1ab22 100644 +
---- a/etc/profile.d/usbdevice.sh +
-+++ b/etc/profile.d/usbdevice.sh +
-@@ -11,8 +11,8 @@ +
- # @ UMS_ROThe flag of read only. 0->Read & Write, 1->Read Only.+
  
- export USE=1 +<code shell> 
- export USB_FUNCS="adb" +ping -I usb0 192.168.35.110 
-+#export USB_FUNCS="rndis" +</code>
- #export USB_FUNCS="ums" +
- #export USB_FUNCS="adb ums" +
- export UMS_MOUNT=0 +
-```+
  
Last modified: 2025/08/18 01:51 by nick