Description
Different boards use different USB controllers (dwc2, dwc3, tegra-xudc). The gadget should auto-detect and configure appropriately.
Current Problem
The current implementation assumes dwc2 controller and doesn't adapt to different hardware platforms.
Implementation
Detect USB controller type and configure:
- USB version (2.0 vs 3.0)
- Power settings (bus-powered vs self-powered)
- Device class and attributes
Detection Logic
# Check for dwc3 (USB 3.x)
if lsmod | grep -q "dwc3" || find /sys/class/udc -name "*dwc3*"; then
USB_VERSION="0x0300" # USB 3.0
USB_CONTROLLER="dwc3"
# Check for dwc2 (USB 2.0)
elif lsmod | grep -q "dwc2" || find /sys/class/udc -name "*dwc2*"; then
USB_VERSION="0x0200" # USB 2.0
USB_CONTROLLER="dwc2"
# Check for Tegra (Jetson)
elif lsmod | grep -q "tegra_xudc" || find /sys/class/udc -name "*tegra*"; then
USB_VERSION="0x0300" # USB 3.0
USB_CONTROLLER="tegra-xudc"
fi
Power Configuration
if [ "$USB_CONTROLLER" = "dwc3" ]; then
# Self-powered device
echo 0xC0 > configs/c.1/bmAttributes
else
# Bus-powered device
echo 0x80 > configs/c.1/bmAttributes
echo 250 > configs/c.1/MaxPower
fi
Acceptance Criteria
Description
Different boards use different USB controllers (dwc2, dwc3, tegra-xudc). The gadget should auto-detect and configure appropriately.
Current Problem
The current implementation assumes dwc2 controller and doesn't adapt to different hardware platforms.
Implementation
Detect USB controller type and configure:
Detection Logic
Power Configuration
Acceptance Criteria