updates
This commit is contained in:
parent
2941508920
commit
b39d53e392
@ -10,7 +10,7 @@ CFG=/boot/config.txt
|
||||
grep -q 'dtoverlay=dwc2,dr_mode=peripheral' "$CFG" || echo 'dtoverlay=dwc2,dr_mode=peripheral' >> "$CFG"
|
||||
|
||||
# 2) Load kernel modules (idempotent)
|
||||
modprobe dwc2 || { echo "dwc2 missing; abort" >&2; exit 1; }
|
||||
modprobe dwc2 || { echo "dwc2 not in kernel; abort" >&2; exit 1; }
|
||||
modprobe libcomposite || { echo "libcomposite not in kernel; abort" >&2; exit 1; }
|
||||
|
||||
# 3) Mount configfs once
|
||||
@ -19,9 +19,12 @@ G=/sys/kernel/config/usb_gadget/navka
|
||||
|
||||
# 4) Tear down any previous half-built gadget
|
||||
if [[ -d $G ]]; then
|
||||
echo "" > "$G/UDC" || true
|
||||
find "$G/configs" -type l -delete || true
|
||||
rm -rf "$G/functions/"*; rmdir "$G" || true
|
||||
echo "" >"$G/UDC" 2>/dev/null || true
|
||||
find "$G/configs" -type l -delete 2>/dev/null || true
|
||||
for fn in "$G"/functions/*; do
|
||||
[[ -d $fn ]] && rmdir "$fn" || true
|
||||
done
|
||||
rmdir "$G" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# 5) Create gadget (boot-keyboard + UAC2 mic/spkr, 500 mA max)
|
||||
@ -46,18 +49,20 @@ echo -ne '\x05\x01\x09\x06\xa1\x01\x05\x07\x19\xe0\x29\xe7\x15\x00\x25'\
|
||||
'\x08\x15\x00\x25\x65\x05\x07\x19\x00\x29\x65\x81\x00\xc0' \
|
||||
>"$G/functions/hid.usb0/report_desc"
|
||||
|
||||
# -- Simple Audio
|
||||
mkdir -p $G/functions/uac2.usb0
|
||||
echo 48000 > $G/functions/uac2.usb0/c_srate
|
||||
echo 2 > $G/functions/uac2.usb0/c_ssize
|
||||
echo 2 > $G/functions/uac2.usb0/p_chmask
|
||||
# # -- UAC2 Audio
|
||||
# mkdir -p $G/functions/uac2.usb0
|
||||
# echo 48000 > $G/functions/uac2.usb0/c_srate
|
||||
# echo 2 > $G/functions/uac2.usb0/c_ssize
|
||||
# echo 2 > $G/functions/uac2.usb0/p_chmask
|
||||
|
||||
# -- Config and Binds
|
||||
# -- Config
|
||||
mkdir -p $G/configs/c.1/strings/0x409
|
||||
echo "Config 1" > $G/configs/c.1/strings/0x409/configuration
|
||||
echo 500 > $G/configs/c.1/MaxPower
|
||||
|
||||
# -- Bindings
|
||||
ln -s $G/functions/hid.usb0 $G/configs/c.1/
|
||||
ln -s $G/functions/uac2.usb0 $G/configs/c.1/
|
||||
# ln -s $G/functions/uac2.usb0 $G/configs/c.1/
|
||||
|
||||
# 6) Finally bind to first available UDC
|
||||
echo $(ls /sys/class/udc | head -n1) > $G/UDC
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user