forked from harryausten/ydotool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
adb_init
50 lines (38 loc) · 1.54 KB
/
adb_init
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
#!/bin/bash
#https://wiki.linaro.org/LMG/Kernel/AndroidConfigFSGadgets#ADB_gadget_configuration
mkdir -p /sys/kernel/config/usb_gadget/g1
sleep 1
#Set default Vendor and Product IDs for now
echo 0x18d1 > /sys/kernel/config/usb_gadget/g1/idVendor
echo 0x4E26 > /sys/kernel/config/usb_gadget/g1/idProduct
#Create English strings and add random deviceID
mkdir -p /sys/kernel/config/usb_gadget/g1/strings/0x409
echo 0123459876 > /sys/kernel/config/usb_gadget/g1/strings/0x409/serialnumber
#Update following if you want to
echo "Lineo" > /sys/kernel/config/usb_gadget/g1/strings/0x409/manufacturer
echo "Board FAM Cloud" > /sys/kernel/config/usb_gadget/g1/strings/0x409/product
#Create gadget configuration
mkdir -p /sys/kernel/config/usb_gadget/g1/configs/c.1
mkdir -p /sys/kernel/config/usb_gadget/g1/configs/c.1/strings/0x409
echo "Conf 1" > /sys/kernel/config/usb_gadget/g1/configs/c.1/strings/0x409/configuration
echo 120 > /sys/kernel/config/usb_gadget/g1/configs/c.1/Maxpower
#Create Adb FunctionFS function
#And link it to the gadget configuration
#stop adbd
mkdir -p /sys/kernel/config/usb_gadget/g1/functions/ffs.adb
mkdir -p /dev/usb-ffs
mkdir -p /dev/usb-ffs/adb
sleep 1
killall adbd
mount -o uid=2000,gid=2000 -t functionfs adb /dev/usb-ffs/adb
ln -s /sys/kernel/config/usb_gadget/g1/functions/ffs.adb /sys/kernel/config/usb_gadget/g1/configs/c.1/ffs.adb
adbd &
sleep 1
# Find the available udc
udc=$(ls -1 /sys/class/udc/)
if [ -z $udc ]; then
echo "No UDC driver registered"
exit 1
fi
sleep 1
echo "${udc}" > /sys/kernel/config/usb_gadget/g1/UDC