Last active
August 18, 2021 09:10
-
-
Save kkebo/0c7b044ad9d992a41ed02467bb0d2d71 to your computer and use it in GitHub Desktop.
Pi4 USB-C Gadget for Arch Linux ARM (参考: https://www.hardill.me.uk/wordpress/2019/11/02/pi4-usb-c-gadget/)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
modprobe libcomposite | |
cd /sys/kernel/config/usb_gadget/ | |
mkdir -p pi4 | |
cd pi4 | |
echo 0x1d6b > idVendor # Linux Foundation | |
echo 0x0104 > idProduct # Multifunction Composite Gadget | |
echo 0x0100 > bcdDevice # v1.0.0 | |
echo 0x0200 > bcdUSB # USB2 | |
echo 0xEF > bDeviceClass | |
echo 0x02 > bDeviceSubClass | |
echo 0x01 > bDeviceProtocol | |
mkdir -p strings/0x409 | |
echo "fedcba9876543211" > strings/0x409/serialnumber | |
echo "Ben Hardill" > strings/0x409/manufacturer | |
echo "PI4 USB Device" > strings/0x409/product | |
mkdir -p configs/c.1/strings/0x409 | |
echo "Config 1: ECM network" > configs/c.1/strings/0x409/configuration | |
echo 250 > configs/c.1/MaxPower | |
# Add functions here | |
# see gadget configurations below | |
# End functions | |
mkdir -p functions/ecm.usb0 | |
HOST="00:dc:c8:f7:75:14" # "HostPC" | |
SELF="00:dd:dc:eb:6d:a1" # "BadUSB" | |
echo $HOST > functions/ecm.usb0/host_addr | |
echo $SELF > functions/ecm.usb0/dev_addr | |
ln -s functions/ecm.usb0 configs/c.1/ | |
udevadm settle -t 5 || : | |
ls /sys/class/udc > UDC | |
ip link set usb0 up |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment