Skip to content

Instantly share code, notes, and snippets.

@phhusson
Created December 19, 2021 18:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phhusson/fa8cfecc73bc26090d61784dfbccfcf6 to your computer and use it in GitHub Desktop.
Save phhusson/fa8cfecc73bc26090d61784dfbccfcf6 to your computer and use it in GitHub Desktop.
mkdir /config
mount -t configfs none /config
# Init USB gadget
g=/config/usb_gadget/g1
mkdir $g
echo > $g/UDC
rm -Rf $g/configs
rm -Rf $g/configs
echo 0x18d1 > $g/idVendor
echo 0x4ee0 > $g/idProduct
mkdir -p $g/strings/0x409
echo "rock-pi-s" > $g/strings/0x409/serialnumber
echo rock-pi-s > $g/strings/0x409/manufacturer
echo rock-pi-s > $g/strings/0x409/product
mkdir $g/configs/c.1/
mkdir $g/configs/c.1/strings/0x409
echo 'conf' > $g/configs/c.1/strings/0x409/configuration
echo 0x0409 > $g/bcdDevice
mkdir $g/functions/acm.0
mkdir $g/functions/rndis.rndis
ln -s $g/functions/acm.0 $g/configs/c.1/f1
ln -s $g/functions/rndis.rndis $g/configs/c.1/f2
echo 0x1 > $g/os_desc/b_vendor_code
echo MSFT100 > $g/os_desc/qw_sign
echo 1 > $g/os_desc/use
ln -s $g/configs/c.1 $g/os_desc/c.1
echo 0x3f > $g/configs/c.1/MaxPower
ls /sys/class/udc | head -n 1 | cat > $g/UDC
# Now there is a /dev/ttyGS0, you can launch a getty on it
# Also there is a `usb0` network interface
@rkakrik
Copy link

rkakrik commented Dec 26, 2021

Cool! It's for armbian?

@phhusson
Copy link
Author

For anything, it's only using standard Linux kernel api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment