|
|
@@ -2,11 +2,12 @@
|
|
|
|
|
|
if [ $# -eq 0 ];
|
|
|
then
|
|
|
- usb_idx=0
|
|
|
+ usb_idx=1
|
|
|
else
|
|
|
- usb_idx=$1
|
|
|
+ usb_idx=2
|
|
|
fi
|
|
|
|
|
|
+echo "usb index $usb_idx"
|
|
|
|
|
|
# config adb function
|
|
|
KER_CONF="`grep '/sys/kernel/config' /proc/mounts`"
|
|
|
@@ -14,51 +15,51 @@ if [ -z "$KER_CONF" ]; then
|
|
|
mount -t configfs none /sys/kernel/config
|
|
|
fi
|
|
|
|
|
|
-if [ ! -d /sys/kernel/config/usb_gadget/g1 ]; then
|
|
|
- mkdir /sys/kernel/config/usb_gadget/g1
|
|
|
+if [ ! -d /sys/kernel/config/usb_gadget/g$usb_idx ]; then
|
|
|
+ mkdir /sys/kernel/config/usb_gadget/g$usb_idx
|
|
|
fi
|
|
|
|
|
|
-if [ ! -d /sys/kernel/config/usb_gadget/g1/strings/0x409 ]; then
|
|
|
- mkdir /sys/kernel/config/usb_gadget/g1/strings/0x409
|
|
|
+if [ ! -d /sys/kernel/config/usb_gadget/g$usb_idx/strings/0x409 ]; then
|
|
|
+ mkdir /sys/kernel/config/usb_gadget/g$usb_idx/strings/0x409
|
|
|
fi
|
|
|
|
|
|
-if [ ! -d /sys/kernel/config/usb_gadget/g1/functions/adb.g1 ]; then
|
|
|
- mkdir /sys/kernel/config/usb_gadget/g1/functions/adb.g1
|
|
|
+if [ ! -d /sys/kernel/config/usb_gadget/g$usb_idx/functions/adb.g$usb_idx ]; then
|
|
|
+ mkdir /sys/kernel/config/usb_gadget/g$usb_idx/functions/adb.g$usb_idx
|
|
|
fi
|
|
|
|
|
|
-if [ ! -d /sys/kernel/config/usb_gadget/g1/configs/c.1 ]; then
|
|
|
- mkdir /sys/kernel/config/usb_gadget/g1/configs/c.1
|
|
|
+if [ ! -d /sys/kernel/config/usb_gadget/g$usb_idx/configs/c.1 ]; then
|
|
|
+ mkdir /sys/kernel/config/usb_gadget/g$usb_idx/configs/c.1
|
|
|
fi
|
|
|
|
|
|
-if [ ! -d /sys/kernel/config/usb_gadget/g1/configs/c.1/strings/0x409 ]; then
|
|
|
- mkdir /sys/kernel/config/usb_gadget/g1/configs/c.1/strings/0x409
|
|
|
+if [ ! -d /sys/kernel/config/usb_gadget/g$usb_idx/configs/c.1/strings/0x409 ]; then
|
|
|
+ mkdir /sys/kernel/config/usb_gadget/g$usb_idx/configs/c.1/strings/0x409
|
|
|
fi
|
|
|
|
|
|
-echo "0x18d1" > /sys/kernel/config/usb_gadget/g1/idVendor
|
|
|
-echo "0x0002" > /sys/kernel/config/usb_gadget/g1/idProduct
|
|
|
+echo "0x18d1" > /sys/kernel/config/usb_gadget/g$usb_idx/idVendor
|
|
|
+echo "0x0002" > /sys/kernel/config/usb_gadget/g$usb_idx/idProduct
|
|
|
|
|
|
-echo "012345678adcdef" > /sys/kernel/config/usb_gadget/g1/strings/0x409/serialnumber
|
|
|
-echo "Arkmicro.Inc" > /sys/kernel/config/usb_gadget/g1/strings/0x409/manufacturer
|
|
|
-echo "ADB Device" > /sys/kernel/config/usb_gadget/g1/strings/0x409/product
|
|
|
+echo "012345678adcdef" > /sys/kernel/config/usb_gadget/g$usb_idx/strings/0x409/serialnumber
|
|
|
+echo "Arkmicro.Inc" > /sys/kernel/config/usb_gadget/g$usb_idx/strings/0x409/manufacturer
|
|
|
+echo "ADB Device" > /sys/kernel/config/usb_gadget/g$usb_idx/strings/0x409/product
|
|
|
|
|
|
-echo 0xc0 > /sys/kernel/config/usb_gadget/g1/configs/c.1/bmAttributes
|
|
|
-echo 500 > /sys/kernel/config/usb_gadget/g1/configs/c.1/MaxPower
|
|
|
+echo 0xc0 > /sys/kernel/config/usb_gadget/g$usb_idx/configs/c.1/bmAttributes
|
|
|
+echo 500 > /sys/kernel/config/usb_gadget/g$usb_idx/configs/c.1/MaxPower
|
|
|
|
|
|
-if [ ! -L /sys/kernel/config/usb_gadget/g1/configs/c.1/adb.g1 ]; then
|
|
|
- ln -s /sys/kernel/config/usb_gadget/g1/functions/adb.g1/ /sys/kernel/config/usb_gadget/g1/configs/c.1/adb.g1
|
|
|
+if [ ! -L /sys/kernel/config/usb_gadget/g$usb_idx/configs/c.1/adb.g$usb_idx ]; then
|
|
|
+ ln -s /sys/kernel/config/usb_gadget/g$usb_idx/functions/adb.g$usb_idx/ /sys/kernel/config/usb_gadget/g$usb_idx/configs/c.1/adb.g$usb_idx
|
|
|
fi
|
|
|
|
|
|
# start adbd daemon
|
|
|
killall adbd
|
|
|
adbd &
|
|
|
|
|
|
-if [ $usb_idx -eq 0 ];
|
|
|
+if [ $usb_idx -eq 1 ];
|
|
|
then
|
|
|
- echo 40000000.usb > /sys/kernel/config/usb_gadget/g1/UDC
|
|
|
+ echo 40000000.usb > /sys/kernel/config/usb_gadget/g$usb_idx/UDC
|
|
|
sleep 0.1
|
|
|
echo device > /sys/class/usb_role/40000000.usb-role-switch/role
|
|
|
else
|
|
|
- echo 40c00000.usb > /sys/kernel/config/usb_gadget/g1/UDC
|
|
|
+ echo 40c00000.usb > /sys/kernel/config/usb_gadget/g$usb_idx/UDC
|
|
|
sleep 0.1
|
|
|
echo device > /sys/class/usb_role/40c00000.usb-role-switch/role
|
|
|
fi
|