Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
#!/bin/bash

# enable USB2 or USB3
ADB_EN=USB2

KERNEL_PATH=/lib/modules/`uname -r`/kernel
GADGET_PATH=$KERNEL_PATH/drivers/usb/gadget
FUNCTION_PATH=$GADGET_PATH/function

COMPOSITE=$GADGET_PATH/libcomposite.ko
U_FFS=$FUNCTION_PATH/usb_f_fs.ko

insmod $COMPOSITE
insmod $U_FFS

# disable debug message
echo 0 > /sys/module/sunplus_udc/parameters/dmsg

if [ ! -d /dev/pts ]
then
        mkdir /dev/pts
        mount -t devpts none /dev/pts
fi

if [ ! -d /sys/kernel/config ]
then
        mkdir -p /sys/kernel/config
        mount -t configfs none /sys/kernel/config
fi

cd /sys/kernel/config/usb_gadget
mkdir g_adb
cd g_adb

echo "0x1d6b" > idVendor
echo "0x0105" > idProduct

mkdir configs/c.1
mkdir functions/ffs.adb
mkdir strings/0x409
mkdir configs/c.1/strings/0x409

echo "20240807" > strings/0x409/serialnumber
echo "Sunplus" > strings/0x409/manufacturer
echo "FunctionFS gadget (adb)" > strings/0x409/product
echo "adb" > configs/c.1/strings/0x409/configuration
echo 120 > configs/c.1/MaxPower

mkdir -p functions/ffs.adb
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
adbd&

sleep 1

if [ $ADB_EN = USB2 ]
then
        echo "f8102800.usb" > UDC
else ifelif [ $ADB_EN = USB3 ]
then
        echo "f80a1000.dwc3" > UDC
fi

...