core repair
This commit is contained in:
parent
0d7e401add
commit
26a4786ea9
@ -13,12 +13,23 @@ grep -q 'dtoverlay=dwc2,dr_mode=peripheral' "$CFG" || echo 'dtoverlay=dwc2,dr_mo
|
||||
# 2) Load kernel modules (idempotent)
|
||||
modprobe dwc2 || { echo "dwc2 not in kernel; abort" >&2; exit 1; }
|
||||
modprobe libcomposite || { echo "libcomposite not in kernel; abort" >&2; exit 1; }
|
||||
modprobe -r uvcvideo || true
|
||||
|
||||
modprobe -r uvcvideo 2>/dev/null || true
|
||||
modprobe uvcvideo || { echo "uvcvideo not in kernel; abort" >&2; exit 1; }
|
||||
|
||||
udevadm control --reload
|
||||
udevadm trigger --subsystem-match=video4linux
|
||||
udevadm settle
|
||||
|
||||
echo "[lesavka-core] ⏳ waiting for UDC to register ..."
|
||||
UDC=""
|
||||
for _ in {1..40}; do # 40 × 100 ms = 4 s max
|
||||
UDC=$(ls /sys/class/udc 2>/dev/null | head -n1) && [ -n "$UDC" ] && break
|
||||
sleep 0.1
|
||||
done
|
||||
[ -n "$UDC" ] || { echo "❌ no UDC present after 4 s"; exit 1; }
|
||||
echo "[lesavka-core] ✅ UDC detected: $UDC"
|
||||
|
||||
# 3) Mount configfs once
|
||||
mountpoint -q /sys/kernel/config || mount -t configfs none /sys/kernel/config
|
||||
G=/sys/kernel/config/usb_gadget/lesavka
|
||||
@ -81,5 +92,5 @@ ln -s $G/functions/hid.usb1 $G/configs/c.1/
|
||||
# ln -s $G/functions/uac2.usb0 $G/configs/c.1/
|
||||
|
||||
# 7) Finally bind to first available UDC
|
||||
echo $(ls /sys/class/udc | head -n1) > $G/UDC
|
||||
echo "[lesavka-core] gadget ready (keyboard on hidg0, mouse on hidg1)"
|
||||
echo "$UDC" > "$G/UDC"
|
||||
echo "[lesavka-core] 🎉 gadget ready on $UDC (keyboard: hidg0, mouse: hidg1)"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user