Sunday, October 27, 2024

USB notes - 2

Using Linux USB Gadget

Documentation/usb/gadget_configfs.rst details how linux USB gadget is configured through configfs

To get ethernet over USB working on beaglebone-white using NCM (Network Control Model), do something like the following

modprobe libcomposite
mount -t configfs none /sys/kernel/config/
cd /sys/kernel/config/usb_gadget/
mkdir g
cd g/
echo "0xA55A" > idVendor 
echo "0x0111" > idProduct 
mkdir strings/0x409
echo "0123" > strings/0x409/serialnumber 
echo "hello" > strings/0x409/manufacturer 
echo "ncm" > strings/0x409/product 
mkdir functions/ncm.usb0
mkdir configs/c.1
mkdir configs/c.1/strings/0x409
echo "ncm" > configs/c.1/strings/0x409/configuration 
ln -s functions/ncm.usb0 configs/c.1/
echo "musb-hdrc.0" > UDC