Versions Compared

Key

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

...

Code Block
#!/bin/sh

USB2_ACM_EN=on
USB3_ACM_EN=on

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_SERIAL=$FUNCTION_PATH/u_serial.ko

insmod $COMPOSITE
insmod $U_SERIAL

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

mkdir -p /sys/kernel/config
mount -t configfs none /sys/kernel/config

if [ $USB2_ACM_EN = on ]
then
    cd /sys/kernel/config/usb_gadget

    # create gadget folder
    mkdir g1
    cd g1

    # setup gadget
    echo 64 > bMaxPacketSize0
    echo 0x200 > bcdUSB

    # composite class
    echo 0x02 > bDeviceClass

    mkdir -p configs/c.1
    mkdir -p configs/c.1/strings/0x409
    echo "USB2.0 Serial Console" > configs/c.1/strings/0x409/configuration

    mkdir strings/0x409
    echo "1234" > strings/0x409/serialnumber
    echo "Sunplus" > strings/0x409/manufacturer
    echo "SP7350" > strings/0x409/product

    mkdir functions/acm.gs0
    ln -s functions/acm.gs0 configs/c.1

    # bind UDC
    echo "f8102800.usb" > UDC
fi

if [ $USB3_ACM_EN = on ]
then
    cd /sys/kernel/config/usb_gadget

    # create gadget folder
    if [ $USB2_ACM_EN = on ]
    then
        mkdir g2
        cd g2
    else
        mkdir g1
        cd g1
    fi

    # setup gadget
    echo 64 > bMaxPacketSize0
    echo 0x300 > bcdUSB

    # composite class
    echo 0x02 > bDeviceClass
    
    mkdir -p configs/c.1
    mkdir -p configs/c.1/strings/0x409
    echo "USB3.0 Serial Console" > configs/c.1/strings/0x409/configuration
    
    mkdir strings/0x409
    echo "5678" > strings/0x409/serialnumber
    echo "Sunplus" > strings/0x409/manufacturer
    echo "SP7350" > strings/0x409/product
    
    mkdir functions/acm.gs1
    ln -s functions/acm.gs1 configs/c.1
    
    # bind UDC
    echo "f80a1000.dwc3" > UDC
fi

...