forked from arduino/adbd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwatcher.sh
executable file
·58 lines (58 loc) · 1.3 KB
/
watcher.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
modprobe dwc3
modprobe dwc3-pci
modprobe configfs
modprobe libcomposite
modprobe usb_f_serial
modprobe usb_f_fs
#insmod /root/usb_f_fs.ko
modprobe usb_f_acm
sleep 2
cd /sys/kernel/config/usb_gadget/
if [ ! -d /sys/kernel/config/usb_gadget/g1 ]; then
mkdir g1
cd g1
echo 0x8087 > idVendor
echo 0x101e > idProduct
mkdir strings/0x409
echo 012345678 > strings/0x409/serialnumber
echo Intel > strings/0x409/manufacturer
echo IoTplatform > strings/0x409/product
mkdir functions/acm.GS0
mkdir functions/ffs.adb
mkdir configs/c.1
mkdir configs/c.1/strings/0x409
echo "adb+cdc" > configs/c.1/strings/0x409/configuration
echo 120 > configs/c.1/MaxPower
ln -s functions/acm.GS0 configs/c.1
ln -s functions/ffs.adb/ configs/c.1
mkdir /dev/usb-ffs
mkdir /dev/usb-ffs/adb
mount -t functionfs adb /dev/usb-ffs/adb
adbd &
sleep 2
fi
while true; do
UDC_VAL=`ls /sys/class/udc`
UDC_VAL=$(echo $UDC_VAL|tr -d '\n')
UDC_MOUNTED=`cat /sys/kernel/config/usb_gadget/g1/UDC`
UDC_MOUNTED=$(echo $UDC_MOUNTED|tr -d '\n')
if [ x$UDC_MOUNTED == x ]; then
echo $UDC_VAL > /sys/kernel/config/usb_gadget/g1/UDC
if [ $? == 0 ]; then
#echo "USB configured"
sleep 10
else
#echo "USB configuration failed"
sleep 1
fi
else
if [ x$UDC_VAL == x ]; then
#echo "USB detached, sleeping"
sleep 1
else
#echo "USB already configured, sleeping"
sleep 10
fi
fi
done