Can Only Enable 2 Classes Using Gadget ConfigFS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The attached script works only when 2 of the 3 given classes are
enabled. The failure is that UDC is not writeable. Is there a limit I
am reaching? I did not think I would get to 32 endpoints, so is there
a limitation due to my device's construction?

I can not find any good troubleshooting information.

Thanks in advance,
     R0b0t1


---


#!/bin/bash
set -euo pipefail

# General configuration:
GADGET_NAME="testgadget"
LANGUAGE=0x409
MANUFACTURER="Sidney Spry"
PRODUCT="Test Gadget"

# Function configuration:
HOST_ADDRESS="1a:55:89:a2:69:42"
DEV_ADDRESS="1a:55:89:a2:69:41"


if [ "$EUID" -ne 0 ]; then
echo "This script must run as root."
exit 1
fi


echo "Loading libcomposite..."
CONFIGFS="/sys/kernel/config/usb_gadget"
GADGET="$CONFIGFS/$GADGET_NAME"
modprobe libcomposite

while [ ! -d $CONFIGFS ]; do
sleep 0.01
done


echo "Cleaning existing gadget..."
find $GADGET/configs/*/* -maxdepth 0 -type l -exec rm {} \; || true
find $GADGET/configs/*/strings/* -maxdepth 0 -type d -exec rmdir {} \; || true
find $GADGET/os_desc/* -maxdepth 0 -type l -exec rm {} \; || true
find $GADGET/functions/* -maxdepth 0 -type d -exec rmdir {} \; || true
find $GADGET/strings/* -maxdepth 0 -type d -exec rmdir {} \; || true
find $GADGET/configs/* -maxdepth 0 -type d -exec rmdir {} \; || true
rmdir $GADGET || true

#find "$GADGET/configs" -maxdepth 2 -type l -exec "rm" {} \;
#find "$GADGET"/configs/*/strings/* -maxdepth 0 -type d -exec "rmdir" {} \;
#find "$GADGET"/os_desc/* -maxdepth 0 -type l -exec "rm" {} \;
#find "$GADGET"/configs/functions/* -maxdepth 0 -type d -exec "rmdir" {} \;
#find "$GADGET"/configs/* -maxdepth 0 -type d -exec "rmdir" {} \;
#rmdir "$GADGET"

echo "Creating gadget..."
mkdir "$GADGET"
cd "$GADGET"

echo "Configuring device identifiers..."
echo 0x1d6b > idVendor  # Linux Foundation
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x0001 > bcdDevice # v0.1.0
echo 0x0200 > bcdUSB    # USB 2.0
mkdir "strings/$LANGUAGE"
echo "$MANUFACTURER" > "strings/$LANGUAGE/manufacturer"
echo "$PRODUCT" > "strings/$LANGUAGE/product"

echo "Configuring composite device..."
echo 0xEF > bDeviceClass
echo 0x02 > bDeviceSubClass
echo 0x01 > bDeviceProtocol

echo "Configuring OS-specific descriptors..."
echo 1       > os_desc/use
echo 0xcd    > os_desc/b_vendor_code
echo MSFT100 > os_desc/qw_sign

echo "Creating Ethernet endpoint (CDC NCM) (1/1)..."
mkdir "functions/ncm.usb0"
#echo "$HOST_ADDRESS" > "functions/ncm.usb0/host_addr"
#echo "$DEV_ADDRESS" > "functions/ncm.usb0/dev_addr"

echo "Creating serial endpoint (1/2)..."
mkdir "functions/acm.usb0"

echo "Creating serial endpoint (2/2)..."
mkdir "functions/acm.usb1"

echo "Creating configuration..."
mkdir "configs/c.1"
echo 500 > "configs/c.1/MaxPower"
mkdir "configs/c.1/strings/$LANGUAGE"
echo "Config 1" > "configs/c.1/strings/$LANGUAGE/configuration"
ln -s "functions/ncm.usb0" "configs/c.1"
ln -s "functions/acm.usb0" "configs/c.1"
ln -s "functions/acm.usb1" "configs/c.1"
ln -s "configs/c.1" "os_desc/c.1"

echo "Attaching device..."
udevadm settle
ls "/sys/class/udc/" > UDC

echo "Done."
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux