79 lines
1.2 KiB
Bash
79 lines
1.2 KiB
Bash
#! /bin/sh
|
|
#
|
|
# adbd This script configure and launch the adbd service.
|
|
# It is called from the boot, halt and reboot scripts.
|
|
#
|
|
# Version: 0.1
|
|
#
|
|
|
|
#[ -c /dev/urandom ] || exit 0
|
|
#. /etc/default/rcS
|
|
|
|
start() {
|
|
printf "Starting adbd: "
|
|
mkdir /dev/pts
|
|
mount -t devpts none /dev/pts
|
|
|
|
mount -t configfs none /sys/kernel/config
|
|
cd /sys/kernel/config/usb_gadget
|
|
mkdir g_adb
|
|
cd g_adb
|
|
|
|
echo "0x18d1" > idVendor
|
|
echo "0x4e26" > idProduct
|
|
|
|
mkdir configs/c.1
|
|
mkdir functions/ffs.adb
|
|
|
|
mkdir strings/0x409
|
|
mkdir configs/c.1/strings/0x409
|
|
|
|
echo "0123456789ABCDEF" > strings/0x409/serialnumber
|
|
echo "AIC Inc." > strings/0x409/manufacturer
|
|
echo "FunctionFS gadget (adb)" > strings/0x409/product
|
|
|
|
echo "Conf 1" > configs/c.1/strings/0x409/configuration
|
|
echo 120 > configs/c.1/MaxPower
|
|
|
|
ln -s functions/ffs.adb configs/c.1
|
|
|
|
mkdir -p /dev/usb-ffs/adb
|
|
mount -o uid=2000,gid=2000 -t functionfs adb /dev/usb-ffs/adb
|
|
|
|
ifconfig lo up
|
|
ifconfig
|
|
|
|
cd /root
|
|
adbd&
|
|
|
|
sleep 1
|
|
|
|
echo `ls /sys/class/udc/` > /sys/kernel/config/usb_gadget/g_adb/UDC
|
|
|
|
echo "OK"
|
|
}
|
|
|
|
stop() {
|
|
printf "Stopping adbd: "
|
|
|
|
echo "OK"
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
start
|
|
;;
|
|
stop)
|
|
stop
|
|
;;
|
|
restart|reload)
|
|
stop
|
|
start
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|restart}"
|
|
exit 1
|
|
esac
|
|
|
|
exit $?
|