Control behavior in usb device mode

All systems provided by OpenStick use the Gadget Controller (hereinafter referred to as gc) based on libusbgx to manage the behavior of usb in device mode.
By default, Debian starts rndis and adb usb composite devices through the /usr/sbin/mobian-usb-network-config script, which means that if your device is installed with Debian, two devices will appear by default when plugged into the computer.
HandsomeMod calls gc through uci, and users can control gc through luci.
In Debian, the usb0 network established by rndis is managed by networkmanager, and dnsmasq is used as a dhcp server to assign ip addresses.
You can also add more functions through the following instructions (example) (the types of running different functions at the same time are limited and limited by hardware).
Note: rndis must be the first function added to the gadget under Windows, and Windows does not support dynamic updating of gadgets, so all gadgets can only be added once in the script.
The following commands require root privileges and will fail after restarting.

    # 列出当前usb活动的device
    gc -l
    # 加入一个串口设备
    # 有效的关键字为 serial ffs hid midi printer uvc mass rndis ecm acm
    gc -a serial
    # 删除指定串口设备 (X 为列表中的对应的config名称)
    gc -r serial.X
    # 清除所有的gadget
    gc -c
    # 关闭gadget
    gc -d
    # 开启gadget
    gc -e

Switch USB working mode

OpenStick does not have a usb-id pin, so you can only manually switch the usb to the main mode to insert devices such as a USB flash drive. You can add the following statement to the very beginning of /usr/sbin/mobian-usb-gadget setup() to realize the boot switch. All usb device functions will be disabled.

echo host > /sys/kernel/debug/usb/ci_hdrc.0/role

Of course, you can also change the usb-typea header to mircousb header, and then connect the gpio of the vol up (fb) contact to the usb-id to realize automatic switching (need to modify the device tree).

About Gadget Controller

The development time of the Gadget Controller is a bit short and maybe immature. . .
Welcome to star, issue and pull request to help me improve it~
Project home page